| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <template>
- <div class="ele-body">
- <el-card shadow="never" v-loading="loading">
- <!-- 数据表格 -->
- <ele-pro-table
- ref="table"
- row-key="id"
- :columns="columns"
- :datasource="datasource"
- :default-expand-all="false"
- :need-page="false"
- cache-key="systemMenuTable"
- @done=""
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="openEdit()"
- >
- 添加
- </el-button>
- <el-button class="ele-btn-icon" size="small" @click="expandAll">
- 展开全部
- </el-button>
- <el-button class="ele-btn-icon" size="small" @click="foldAll">
- 折叠全部
- </el-button>
- <el-button type="primary" size="mini" icon="el-icon-upload2" plain @click="uploadFile">导入</el-button>
- </template>
- <!-- 标题列 -->
- <template v-slot:name="{ row }">
- <i :class="row.icon"></i> {{ row.name }}
- </template>
- <!-- 类型列 -->
- <template v-slot:type="{ row }">
- <el-tag
- type="primary"
- size="mini"
- :disable-transitions="true"
- v-if="row.type == 1"
- >
- 菜单
- </el-tag>
- <el-tag
- type="warning"
- size="mini"
- :disable-transitions="true"
- v-if="row.type == 2"
- >
- 按钮
- </el-tag>
- </template>
- <template v-slot:status="{ row }">
- <el-tag
- type="danger"
- :disable-transitions="true"
- v-if="row.status == 0"
- >
- 关闭
- </el-tag>
- <el-tag
- type="primary"
- :disable-transitions="true"
- v-if="row.status == 1"
- >
- 开启
- </el-tag>
- </template>
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <el-link
- type="primary"
- :underline="false"
- icon="el-icon-edit"
- @click="openEdit(row)"
- >
- 修改
- </el-link>
- <el-popconfirm
- class="ele-action"
- title="确定要删除吗?"
- @confirm="remove(row)"
- v-if="row.id != 99999"
- >
- <template v-slot:reference>
- <el-link type="danger" :underline="false" icon="el-icon-delete">
- 删除
- </el-link>
- </template>
- </el-popconfirm>
- </template>
- </ele-pro-table>
- </el-card>
- <!-- 编辑弹窗 -->
- <org-edit
- :visible.sync="showEdit"
- :data="editData"
- :parent-id="parentId"
- :organization-list="data"
- @done="reload"
- />
- <importDialog :defModule="moudleName" ref="importDialogRef" @success="reload" />
- </div>
- </template>
- <script>
- import OrgEdit from './components/org-edit.vue';
- import importDialog from "@/components/upload/import-dialog.vue";
- import {
- listOrganizations,
- removeOrganization
- } from '@/api/system/organization';
- export default {
- name: 'SystemOrganization',
- components: {OrgEdit, importDialog},
- data() {
- return {
- //模块名称
- moudleName : "mainGroup",
- // 加载状态
- loading: false,
- // 列表数据
- data: [],
- // 选中数据
- current: null,
- // 是否显示表单弹窗
- showEdit: false,
- // 编辑回显数据
- editData: null,
- // 上级id
- parentId: null
- };
- },
- computed: {
- // 表格列配置
- columns() {
- return [
- {
- columnKey: 'index',
- type: 'index',
- width: 45,
- align: 'center',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- prop: 'name',
- label: '部门名称',
- showOverflowTooltip: true,
- minWidth: 110,
- slot: 'name'
- },
- {
- prop: '',
- label: '负责人',
- showOverflowTooltip: true,
- align: 'center',
- formatter: (_row) => {
- return _row.manager.map(item => item.name).join(',')
- },
- minWidth: 110,
- },
- {
- prop: 'sort',
- label: '排序',
- showOverflowTooltip: true,
- align: 'center',
- width: 60
- },
- {
- prop: 'status',
- label: '状态',
- showOverflowTooltip: true,
- align: 'center',
- width: 80,
- slot: 'status'
- },
- {
- prop: 'createTime',
- label: '创建时间',
- showOverflowTooltip: true,
- align: 'center',
- minWidth: 110,
- formatter: (_row, _column, cellValue) => {
- return this.$util.toDateString(cellValue);
- }
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 190,
- align: 'center',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true
- }
- ]
- },
- },
- created() {
- //this.query();
- },
- methods: {
- /* 查询 */
- async datasource() {
- const data = await listOrganizations()
- this.data = this.$util.toTreeData({
- data: data,
- idField: 'id',
- parentIdField: 'parentId'
- });
- return this.data
- },
- /* 刷新表格 */
- reload(where) {
- this.$refs.table.reload();
- },
- /* 选择数据 */
- onNodeClick(row) {
- if (row) {
- this.current = row;
- this.parentId = row.id;
- this.$refs.tree.setCurrentKey(row.id);
- } else {
- this.current = null;
- this.parentId = null;
- }
- },
- /* 展开全部 */
- expandAll() {
- this.$refs.table.toggleRowExpansionAll(true);
- },
- /* 折叠全部 */
- foldAll() {
- this.$refs.table.toggleRowExpansionAll(false);
- },
- /* 显示编辑 */
- openEdit(item) {
- this.editData = item;
- this.showEdit = true;
- },
- /* 删除 */
- remove(row) {
- this.$confirm('确定要删除选中的机构吗?', '提示', {
- type: 'warning'
- }).then(() => {
- const loading = this.$loading({lock: true});
- removeOrganization([row.id])
- .then((msg) => {
- loading.close();
- this.$message.success(msg);
- this.reload();
- })
- .catch((e) => {
- loading.close();
- // this.$message.error(e.message);
- });
- })
- .catch(() => {
- });
- },
- uploadFile () {
- this.$refs.importDialogRef.open();
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .sys-organization-list {
- height: calc(100vh - 264px);
- box-sizing: border-box;
- border-width: 1px;
- border-style: solid;
- overflow: auto;
- }
- .sys-organization-list :deep(.el-tree-node__content) {
- height: 30px;
- & > .el-tree-node__expand-icon {
- margin-left: 10px;
- }
- }
- </style>
|