xiangpei
2025-02-27 c482628d3daf21dafba7e2b9eaba6e46ffda0fdb
src/views/system/dept/index.vue
@@ -56,7 +56,7 @@
      :default-expand-all="isExpandAll"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
    >
      <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
      <el-table-column prop="deptName" label="部门名称" width="500"></el-table-column>
      <el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
      <el-table-column prop="status" label="状态" width="100">
        <template slot-scope="scope">
@@ -100,7 +100,7 @@
    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="24" v-if="form.parentId !== 0">
          <el-col :span="24">
            <el-form-item label="上级部门" prop="parentId">
              <treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" />
            </el-form-item>
@@ -193,9 +193,9 @@
      form: {},
      // 表单校验
      rules: {
        parentId: [
          { required: true, message: "上级部门不能为空", trigger: "blur" }
        ],
        // parentId: [
        //   { required: true, message: "上级部门不能为空", trigger: "blur" }
        // ],
        deptName: [
          { required: true, message: "部门名称不能为空", trigger: "blur" }
        ],
@@ -226,10 +226,12 @@
    /** 查询部门列表 */
    getList() {
      this.loading = true;
      console.log(this.queryParams, "dddddd")
      listDept(this.queryParams).then(response => {
        this.deptList = this.handleTree(response.data, "deptId");
        this.loading = false;
      });
    },
    /** 转换部门数据结构 */
    normalizer(node) {
@@ -303,6 +305,13 @@
            const noResultsOptions = { deptId: this.form.parentId, deptName: this.form.parentName, children: [] };
            this.deptOptions.push(noResultsOptions);
          }
          if (row.parentId === 0) {
            this.deptOptions.push({
              deptId: 0,
              deptName: '无',
              children: []
            });
          }
        });
      });
    },