org-user-list.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div>
  3. <!-- 数据表格 -->
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="datasource"
  8. height="calc(100vh - 265px)"
  9. full-height="calc(100vh - 116px)"
  10. tool-class="ele-toolbar-form"
  11. cache-key="systemOrgUserTable"
  12. >
  13. <!-- 表头工具栏 -->
  14. <template v-slot:toolbar>
  15. <org-user-search @search="reload">
  16. <el-button
  17. size="small"
  18. type="primary"
  19. icon="el-icon-plus"
  20. class="ele-btn-icon"
  21. @click="openEdit()"
  22. >
  23. 添加
  24. </el-button>
  25. <el-button type="primary" size="mini" icon="el-icon-upload2" plain @click="uploadFile">导入</el-button>
  26. </org-user-search>
  27. </template>
  28. <!-- 角色列 -->
  29. <template v-slot:roles="{ row }">
  30. <el-tag
  31. v-for="item in row.roles"
  32. :key="item.roleId"
  33. type="primary"
  34. size="mini"
  35. :disable-transitions="true"
  36. >
  37. {{ item.roleName }}
  38. </el-tag>
  39. </template>
  40. <!-- 状态列 -->
  41. <!-- <template v-slot:status="{ row }">
  42. <el-switch
  43. :active-value="0"
  44. :inactive-value="1"
  45. v-model="row.status"
  46. @change="editStatus(row)"
  47. />
  48. </template> -->
  49. <!-- 操作列 -->
  50. <template v-slot:action="{ row }">
  51. <el-link
  52. type="primary"
  53. :underline="false"
  54. icon="el-icon-edit"
  55. @click="openEdit(row)"
  56. >
  57. 修改
  58. </el-link>
  59. <el-link
  60. v-if="row.loginName"
  61. type="primary"
  62. :underline="false"
  63. icon="el-icon-unlock"
  64. @click="toUnBind(row)"
  65. >
  66. 解绑
  67. </el-link>
  68. <el-popconfirm
  69. class="ele-action"
  70. title="确定要删除此用户吗?"
  71. @confirm="remove(row)"
  72. >
  73. <template v-slot:reference>
  74. <el-link type="danger" :underline="false" icon="el-icon-delete">
  75. 删除
  76. </el-link>
  77. </template>
  78. </el-popconfirm>
  79. </template>
  80. </ele-pro-table>
  81. <!-- 编辑弹窗 -->
  82. <org-user-edit
  83. :data="current"
  84. :visible.sync="showEdit"
  85. :organization-list="organizationList"
  86. :institutionList="institutionList"
  87. :organization-id="organizationId"
  88. @done="reload"
  89. />
  90. <importDialog :defModule="moudleName" ref="importDialogRef" @success="reload" />
  91. </div>
  92. </template>
  93. <script>
  94. import OrgUserSearch from './org-user-search.vue';
  95. import OrgUserEdit from './org-user-edit.vue';
  96. import importDialog from "@/components/upload/import-dialog.vue";
  97. import {
  98. getUserPage,
  99. removePersonnel,
  100. unbindLoginName
  101. } from '@/api/system/organization';
  102. export default {
  103. components: {importDialog, OrgUserSearch, OrgUserEdit},
  104. props: {
  105. // 机构id
  106. organizationId: [Number, String],
  107. // 全部机构
  108. organizationList: Array,
  109. institutionList: Array,
  110. },
  111. data() {
  112. return {
  113. moudleName : "mainUser",
  114. // 表格列配置
  115. columns: [
  116. {
  117. columnKey: 'index',
  118. type: 'index',
  119. width: 45,
  120. align: 'center',
  121. showOverflowTooltip: true,
  122. fixed: 'left'
  123. },
  124. {
  125. prop: 'name',
  126. label: '姓名',
  127. sortable: 'custom',
  128. showOverflowTooltip: true,
  129. minWidth: 110
  130. },
  131. {
  132. prop: 'jobNumber',
  133. label: '工号',
  134. sortable: 'custom',
  135. showOverflowTooltip: true,
  136. minWidth: 110
  137. },
  138. {
  139. prop: 'loginName',
  140. label: '用户账号',
  141. sortable: 'custom',
  142. showOverflowTooltip: true,
  143. minWidth: 110
  144. },
  145. {
  146. prop: 'sex',
  147. label: '性别',
  148. sortable: 'custom',
  149. showOverflowTooltip: true,
  150. minWidth: 80,
  151. formatter: (_row, _column, cellValue) => {
  152. return cellValue == 1 ? '男' : cellValue == 2 ? '女' : '';
  153. }
  154. },
  155. {
  156. prop: 'status',
  157. label: '状态',
  158. align: 'center',
  159. sortable: 'custom',
  160. width: 80,
  161. formatter: (_row, _column, cellValue) => {
  162. const dom = this.statusOptions.find((item) => {
  163. return item.value == cellValue;
  164. });
  165. return dom ? dom.label : '';
  166. }
  167. },
  168. {
  169. prop: 'createTime',
  170. label: '创建时间',
  171. sortable: 'custom',
  172. showOverflowTooltip: true,
  173. minWidth: 110,
  174. formatter: (_row, _column, cellValue) => {
  175. return this.$util.toDateString(cellValue);
  176. }
  177. },
  178. {
  179. columnKey: 'action',
  180. label: '操作',
  181. width: 200,
  182. align: 'left',
  183. resizable: false,
  184. slot: 'action',
  185. showOverflowTooltip: true
  186. }
  187. ],
  188. // 当前编辑数据
  189. current: null,
  190. // 是否显示编辑弹窗
  191. showEdit: false,
  192. statusOptions: [
  193. { value: 1, label: '全职' },
  194. { value: 2, label: '兼职' },
  195. { value: 3, label: '实习' },
  196. { value: 4, label: '正式' },
  197. { value: 5, label: '试用' },
  198. { value: 6, label: '离职' }
  199. ]
  200. };
  201. },
  202. methods: {
  203. /* 表格数据源 */
  204. datasource({ page, limit, where, order }) {
  205. return getUserPage({
  206. ...where,
  207. ...order,
  208. pageNum: page,
  209. size: limit,
  210. groupId: this.organizationId
  211. });
  212. },
  213. /* 刷新表格 */
  214. reload(where) {
  215. this.$refs.table.reload({ pageNum: 1, where: where });
  216. },
  217. /* 显示编辑 */
  218. openEdit(row) {
  219. this.current = row;
  220. this.showEdit = true;
  221. },
  222. // 解除绑定
  223. toUnBind(row) {
  224. const loading = this.$loading({ lock: true });
  225. unbindLoginName(row.id)
  226. .then((res) => {
  227. loading.close();
  228. this.$message.success('解绑成功');
  229. this.reload();
  230. })
  231. .catch((e) => {
  232. loading.close();
  233. // this.$message.error(e.message);
  234. });
  235. },
  236. /* 删除 */
  237. remove(row) {
  238. const loading = this.$loading({ lock: true });
  239. removePersonnel([row.id])
  240. .then((msg) => {
  241. loading.close();
  242. this.$message.success(msg);
  243. this.reload();
  244. })
  245. .catch((e) => {
  246. loading.close();
  247. // this.$message.error(e.message);
  248. });
  249. },
  250. /* 更改状态 */
  251. editStatus(row) {
  252. const loading = this.$loading({ lock: true });
  253. updateUserStatus(row.userId, row.status)
  254. .then((msg) => {
  255. loading.close();
  256. this.$message.success(msg);
  257. })
  258. .catch((e) => {
  259. loading.close();
  260. row.status = !row.status ? 1 : 0;
  261. // this.$message.error(e.message);
  262. });
  263. },
  264. uploadFile () {
  265. this.$refs.importDialogRef.open();
  266. }
  267. },
  268. watch: {
  269. // 监听机构id变化
  270. organizationId() {
  271. this.reload();
  272. }
  273. }
  274. };
  275. </script>