| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- <template>
- <div>
- <!-- 数据表格 -->
- <ele-pro-table
- ref="table"
- :columns="columns"
- :datasource="datasource"
- height="calc(100vh - 265px)"
- full-height="calc(100vh - 116px)"
- tool-class="ele-toolbar-form"
- cache-key="systemOrgUserTable"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <org-user-search @search="reload">
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="openEdit()"
- >
- 添加
- </el-button>
- <el-button type="primary" size="mini" icon="el-icon-upload2" plain @click="uploadFile">导入</el-button>
- </org-user-search>
- </template>
- <!-- 角色列 -->
- <template v-slot:roles="{ row }">
- <el-tag
- v-for="item in row.roles"
- :key="item.roleId"
- type="primary"
- size="mini"
- :disable-transitions="true"
- >
- {{ item.roleName }}
- </el-tag>
- </template>
- <!-- 状态列 -->
- <!-- <template v-slot:status="{ row }">
- <el-switch
- :active-value="0"
- :inactive-value="1"
- v-model="row.status"
- @change="editStatus(row)"
- />
- </template> -->
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="openEdit(row)"
- >
- 修改
- </el-link>
- <el-link
- v-if="row.loginName"
- type="primary"
- :underline="false"
- icon="el-icon-unlock"
- @click="toUnBind(row)"
- >
- 解绑
- </el-link>
- <el-popconfirm
- class="ele-action"
- title="确定要删除此用户吗?"
- @confirm="remove(row)"
- >
- <template v-slot:reference>
- <el-link type="danger" :underline="false" icon="el-icon-delete">
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- <!-- 编辑弹窗 -->
- <org-user-edit
- :data="current"
- :visible.sync="showEdit"
- :organization-list="organizationList"
- :institutionList="institutionList"
- :organization-id="organizationId"
- @done="reload"
- />
- <importDialog :defModule="moudleName" ref="importDialogRef" @success="reload" />
- </div>
- </template>
- <script>
- import OrgUserSearch from './org-user-search.vue';
- import OrgUserEdit from './org-user-edit.vue';
- import importDialog from "@/components/upload/import-dialog.vue";
- import {
- getUserPage,
- removePersonnel,
- unbindLoginName
- } from '@/api/system/organization';
- export default {
- components: {importDialog, OrgUserSearch, OrgUserEdit},
- props: {
- // 机构id
- organizationId: [Number, String],
- // 全部机构
- organizationList: Array,
- institutionList: Array,
- },
- data() {
- return {
- moudleName : "mainUser",
- // 表格列配置
- columns: [
- {
- columnKey: 'index',
- type: 'index',
- width: 45,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- prop: 'name',
- label: '姓名',
- sortable: 'custom',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'jobNumber',
- label: '工号',
- sortable: 'custom',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'loginName',
- label: '用户账号',
- sortable: 'custom',
- showOverflowTooltip: true,
- minWidth: 110
- },
- {
- prop: 'sex',
- label: '性别',
- sortable: 'custom',
- showOverflowTooltip: true,
- minWidth: 80,
- formatter: (_row, _column, cellValue) => {
- return cellValue == 1 ? '男' : cellValue == 2 ? '女' : '';
- }
- },
- {
- prop: 'status',
- label: '状态',
- align: 'center',
- sortable: 'custom',
- width: 80,
- formatter: (_row, _column, cellValue) => {
- const dom = this.statusOptions.find((item) => {
- return item.value == cellValue;
- });
- return dom ? dom.label : '';
- }
- },
- {
- prop: 'createTime',
- label: '创建时间',
- sortable: 'custom',
- showOverflowTooltip: true,
- minWidth: 110,
- formatter: (_row, _column, cellValue) => {
- return this.$util.toDateString(cellValue);
- }
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 200,
- align: 'left',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true
- }
- ],
- // 当前编辑数据
- current: null,
- // 是否显示编辑弹窗
- showEdit: false,
- statusOptions: [
- { value: 1, label: '全职' },
- { value: 2, label: '兼职' },
- { value: 3, label: '实习' },
- { value: 4, label: '正式' },
- { value: 5, label: '试用' },
- { value: 6, label: '离职' }
- ]
- };
- },
- methods: {
- /* 表格数据源 */
- datasource({ page, limit, where, order }) {
- return getUserPage({
- ...where,
- ...order,
- pageNum: page,
- size: limit,
- groupId: this.organizationId
- });
- },
- /* 刷新表格 */
- reload(where) {
- this.$refs.table.reload({ pageNum: 1, where: where });
- },
- /* 显示编辑 */
- openEdit(row) {
- this.current = row;
- this.showEdit = true;
- },
- // 解除绑定
- toUnBind(row) {
- const loading = this.$loading({ lock: true });
- unbindLoginName(row.id)
- .then((res) => {
- loading.close();
- this.$message.success('解绑成功');
- this.reload();
- })
- .catch((e) => {
- loading.close();
- // this.$message.error(e.message);
- });
- },
- /* 删除 */
- remove(row) {
- const loading = this.$loading({ lock: true });
- removePersonnel([row.id])
- .then((msg) => {
- loading.close();
- this.$message.success(msg);
- this.reload();
- })
- .catch((e) => {
- loading.close();
- // this.$message.error(e.message);
- });
- },
- /* 更改状态 */
- editStatus(row) {
- const loading = this.$loading({ lock: true });
- updateUserStatus(row.userId, row.status)
- .then((msg) => {
- loading.close();
- this.$message.success(msg);
- })
- .catch((e) => {
- loading.close();
- row.status = !row.status ? 1 : 0;
- // this.$message.error(e.message);
- });
- },
- uploadFile () {
- this.$refs.importDialogRef.open();
- }
- },
- watch: {
- // 监听机构id变化
- organizationId() {
- this.reload();
- }
- }
- };
- </script>
|