Source/plt-web/plt-web-ui/src/views/system/department/index.vue
@@ -15,20 +15,32 @@
      @current-row-change="handleCurrentRowChange"
    >
      <template slot="menu" slot-scope="{row,size,type}">
        <el-button icon="el-icon-circle-plus-outline" size="small" type="text" @click="handleAdd()">新增子级</el-button>
        <el-button v-if="row.ALLDept !== 'ALLDept'" icon="el-icon-edit" size="small" type="text"
        <el-button v-if="permissionList.departmentAddChildrenBtn" icon="el-icon-circle-plus-outline" size="small"
                   type="text" @click="handleAdd()">新增子级
        </el-button>
        <el-button v-if="row.ALLDept !== 'ALLDept' && permissionList.editBtn" icon="el-icon-edit" size="small"
                   type="text"
                   @click="editBtnClick(row)">编辑
        </el-button>
        <el-button v-if="row.ALLDept !== 'ALLDept'" icon="el-icon-delete" size="small" type="text"
        <el-button v-if="row.ALLDept !== 'ALLDept' && permissionList.delBtn" icon="el-icon-delete" size="small"
                   type="text"
                   @click="rowDeleteHandler(row)">删除
        </el-button>
      </template>
      <template slot="menuLeft" slot-scope="scope">
        <el-button icon="el-icon-school" plain size="small" type="primary" @click="assignMembersHandler">分配成员</el-button>
        <el-button icon="el-icon-user" plain size="small" type="primary" @click="statisticsHandler">统计</el-button>
        <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="statisticsHandler">导入部门</el-button>
        <el-button icon="el-icon-download" plain size="small" type="primary" @click="downLoadHandler">下载导入模板</el-button>
        <el-button v-if="permissionList.assignMembersBtn" icon="el-icon-school" plain size="small" type="primary"
                   @click="assignMembersHandler">分配成员
        </el-button>
        <el-button v-if="permissionList.statisticsBtn" icon="el-icon-user" plain size="small" type="primary"
                   @click="statisticsHandler">统计
        </el-button>
        <el-button v-if="permissionList.importDepartmentBtn" icon="el-icon-upload2" plain size="small" type="primary"
                   @click="upLoadHandler">导入部门
        </el-button>
        <el-button v-if="permissionList.downloadImportTemplateBtn" icon="el-icon-download" plain size="small"
                   type="primary" @click="downLoadHandler">下载导入模板
        </el-button>
      </template>
    </avue-crud>
@@ -36,7 +48,6 @@
    <el-dialog
      v-dialogDrag
      v-loading="statisticsLoading"
      :destroy-on-close="true"
      :visible.sync="statisticsVisible"
      append-to-body="true"
      class="avue-dialog"
@@ -63,6 +74,10 @@
              @transferSend="departTransferSend">
    </transfer>
    <!-- 导入部门   -->
    <upload-file ref="upload" :fileType="upFileType" :fileUrl="fileUrl" :tipList="tipList" title="导入部门"
                 @updata="getTableList"></upload-file>
  </basic-container>
</template>
@@ -81,6 +96,7 @@
import basicOption from '@/util/basic-option';
import {column} from './option'
import func from "@/util/func";
import {mapGetters} from "vuex";
export default {
  name: "departmentManage",
@@ -91,12 +107,15 @@
        ...basicOption,
        rowKey: 'oid',
        rowParentKey: 'parentId',
        expandRowKeys: [],
        selection: false,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        gridBtn: false,
        menuWidth: 280,
        highlightCurrentRow: true,
        calcHeight: -50,
        column: column
      },
      tableLoading: false,
@@ -110,7 +129,9 @@
        selection: false,
        refreshBtn: false,
        addBtn: false,
        header: false,
        menu: false,
        calcHeight: 80,
        column: [
          {
            label: '部门',
@@ -131,19 +152,38 @@
            label: '角色',
            prop: 'pkPersonName',
            sortable: true,
            overHidden: true,
          },
        ]
      },
      leftTransferData: [],
      rightTransferData: [],
      transferTitle: ['待选人员', '已选人员'],
      tipList: ['导入模板中标明红色字体的为必输项', '导入结构为树结构时请保证ID列不能重复', '父ID请使用界面上部门的唯一标识ID或者Excel中手动输入的ID', '父ID列为空时,导入的部门即为顶层部门'],
      upFileType: ['xls', 'xlsx'],
      fileUrl: 'api/departmentQueryController/importDept',
    }
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        delBtn: this.vaildData(this.permission[this.$route.query.id].DELETE, false),
        editBtn: this.vaildData(this.permission[this.$route.query.id].EDIT, false),
        assignMembersBtn: this.vaildData(this.permission[this.$route.query.id].assignMembers, false),
        departmentAddChildrenBtn: this.vaildData(this.permission[this.$route.query.id].departmentAddChildren, false),
        downloadImportTemplateBtn: this.vaildData(this.permission[this.$route.query.id].downloadImportTemplate, false),
        importDepartmentBtn: this.vaildData(this.permission[this.$route.query.id].importDepartment, false),
        statisticsBtn: this.vaildData(this.permission[this.$route.query.id].statistics, false),
      };
    },
  },
  methods: {
    // 表格初始化请求
    getTableList() {
      refTree({queryAllLevel: true, 'extandParamsMap[showAllDepartmentNode]': true}).then(res => {
        this.tableData = this.departDtaFormAtter(res.data.treeData);
        this.option.expandRowKeys = [res.data.treeData[0].oid];
      })
    },
@@ -152,6 +192,7 @@
      return items.map(item => {
        // 转换当前节点的属性
        const formList = {
          expanded: item.expanded,
          oid: item.oid,
          id: item.attributes.id,
          name: item.attributes.name,
@@ -195,7 +236,6 @@
          done();
        }
      }).catch(err => {
        console.log(err);
        loading();
      })
@@ -223,7 +263,6 @@
          done();
        }
      }).catch(err => {
        console.log(err);
        loading();
      })
    },
@@ -273,7 +312,6 @@
      }
      countSmUserByDeptOid({pkDepartment: this.departCurrenRow.ALLDept === 'ALLDept' ? null : this.departCurrenRow.oid}).then(res => {
        console.log(res);
        if (res.data.code === 200) {
          const data = res.data.data;
          this.countData = data.map(item => {
@@ -326,11 +364,11 @@
    // 分配成员穿梭框回填
    departTransferSend(row) {
      let params = {
        userOids: row.join(','),
        userOIds: row.join(','),
        deptId: this.departCurrenRow.oid
      }
      saveUsersDepts(params).then(res => {
        console.log(res);
        //console.log(res);
        this.$message.success(res.data.obj);
        this.getTableList();
      }).catch(err => {
@@ -339,13 +377,16 @@
    },
    // 下载导入模板
    downLoadHandler(){
    downLoadHandler() {
      download().then(res => {
        func.downloadFileByBlobHandler(res);
        this.$message.success('下载成功')
      }).catch(err => {
        this.$message.error(err);
      })
      });
    },
    // 导入部门
    upLoadHandler() {
      this.$refs.upload.visible = true;
    }
  }
}