src/views/system/user/index.vue
@@ -40,8 +40,6 @@
              </el-form>
            </div>
            <div class="options_button">
              <el-button type="primary" size="mini" @click="openthirdParty"
                v-hasPermi="['system:user:add']">获取三方人员</el-button>
              <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
                v-hasPermi="['system:user:add']">新增用户</el-button>
            </div>
@@ -206,49 +204,6 @@
      </div>
    </el-dialog>
    <!-- 获取人事系统人员信息 -->
    <el-dialog title="获取人事系统人员信息" :visible.sync="addthirdParty" width="70%">
      <div class="body" v-loading="thirdPartyLoading">
        <el-row>
          <el-col :span="8" style="height: 70vh;overflow: hidden;" v-if="companiesList.length != 1">
            <el-input v-model="search2" placeholder="输入关键字搜索" clearable size="small" @clear="searchFilter2"
              @keyup.enter.native="searchFilter2" prefix-icon="el-icon-search" style="margin-bottom: 20px;width: 90%" />
            <el-tree :data="datathirdParty" node-key="companyId" :props="defaultProps1" @node-click="nodeClick2"
              style="height: calc(100% - 42px);" @node-expand="nodeOpen0" :filter-node-method="filterNode2" ref="tree2"
              highlight-current>
            </el-tree>
          </el-col>
          <el-col :span="companiesList.length == 1 ? 24 : 16" style="height: 70vh;padding-left: 8px;">
            <div style="display: flex;align-items: center;margin-bottom: 10px">
              <span style="width: 140px">员工号/员工姓名:</span>
              <el-input size="small" placeholder="请输入员工号/员工姓名" @clear="searchPerson" clearable v-model="userSearch2"
                style="width: 50%" @keyup.enter.native="searchPerson()"></el-input>
            </div>
            <el-table height="67vh" stripe :data="personList" v-loading="personLoad" ref="personTable"
                      :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
              @selection-change="handleSelectionChange">
              <el-table-column type="selection" width="50">
              </el-table-column>
              <el-table-column prop="employeeID" label="员工号">
              </el-table-column>
              <el-table-column prop="name" label="员工姓名">
              </el-table-column>
              <el-table-column prop="department" label="部门" min-width="200">
              </el-table-column>
              <el-table-column prop="isLive" label="已存在" width="80" align="center">
                <template slot-scope="scope">
                  <el-tag type="success" effect="dark" v-if="scope.row.isLive === 1">√</el-tag>
                </template>
              </el-table-column>
            </el-table>
          </el-col>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="addthirdParty = false">取 消</el-button>
        <el-button type="primary" @click="addUser2" :loading="addLoad">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="架构新增" :visible.sync="addDia" width="400px">
      <div class="body">
        <el-row style="line-height: 50px;">
@@ -278,7 +233,7 @@
  resetUserPwd,
  changeUserStatus,
  deptTreeSelect,
  selectCompaniesList, selectSimpleList, addPersonUser, uploadFile, selectRoleList, selectCustomEnum, addDepartment
  uploadFile, selectRoleList, selectCustomEnum, addDepartment
} from "@/api/system/user";
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
@@ -331,10 +286,6 @@
        children: "children",
        label: "label"
      },
      defaultProps1: {
        children: "children",
        label: "companyName"
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层(用户导入)
@@ -378,9 +329,6 @@
        userName: [
          { required: true, message: "请填写账号", trigger: "blur" }
        ],
        // nameEn: [
        //   { required: true, message: "请输入姓名EN", trigger: "blur" }
        // ],
        status: [
          { required: true, message: "请选择状态", trigger: "change" }
        ],
@@ -388,7 +336,7 @@
          { required: true, message: "请选择角色", trigger: "change" }
        ],
        password: [
          { required: true, message: "密码不能为空", trigger: "blur" },
          { required: false, message: "密码不能为空", trigger: "blur" },
          { min: 8, max: 20, message: "密码长度必须在8-20个字符之间", trigger: "blur" },
          {
            validator: (rule, value, callback) => {
@@ -402,7 +350,7 @@
              const hasLowerCase = /[a-z]/.test(value);
              // 检查是否包含特殊符号
              const hasSpecialChar = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(value);
              if (!hasUpperCase) {
                callback(new Error('密码必须包含至少一个大写字母'));
              } else if (!hasLowerCase) {
@@ -425,19 +373,7 @@
          }
        ]
      },
      // 获取三方人员弹框
      addthirdParty: false,
      thirdPartyLoading: false,
      companiesList: [],
      search2: '',
      datathirdParty: [],
      currentCompaniesList: [],
      personList: [],
      personListCopy: [],
      personLoad: false,
      userSearch2: '',
      addLoad: false,
      //
      addDia: false, // 添加架构弹框
      addOb: {
        fatherId: 10001,
@@ -590,113 +526,6 @@
        default:
          break;
      }
    },
    // 获取三方人员
    async openthirdParty() {
      try {
        this.addthirdParty = true;
        this.thirdPartyLoading = true;
        const companiesResponse = await selectCompaniesList();
        this.companiesList = this.HaveJson(companiesResponse.data);
        if (this.companiesList.length === 1) {
          const personResponse = await selectSimpleList({ companyId: this.companiesList[0].companyId });
          this.personListCopy = JSON.parse(JSON.stringify(personResponse.data));
          this.personList = personResponse.data;
          this.$refs.personTable.doLayout();
        }
        this.datathirdParty = this.tranListToTreeData(this.companiesList, "ROOT");
        console.log(' this.datathirdParty---',  this.datathirdParty)
      } catch (error) {
        console.error("Error fetching third party data:", error);
      } finally {
        this.thirdPartyLoading = false;
      }
    },
    tranListToTreeData(list, rootValue) {
      return list.reduce((arr, item) => {
        if (item.parentCompanyId === rootValue) {
          const children = this.tranListToTreeData(list, item.companyId);
          if (children.length) {
            item.children = children;
          }
          arr.push(item);
        }
        return arr;
      }, []);
    },
    searchPerson() {
      let arr = JSON.parse(JSON.stringify(this.personListCopy))
      this.personList = arr.filter(a => {
        if (a.employeeID.includes(this.userSearch2) || a.nickName.includes(this.userSearch2)) {
          return true
        }
      })
    },
    searchFilter2() {
      this.$refs.tree2.filter(this.search2)
    },
    nodeClick2(ob, node, el) {
      this.getNodeParent(node)
      if (ob.companyId !== 'SC21') {
        this.personLoad = true
        selectSimpleList({ companyId: ob.companyId }).then(res => {
          this.personListCopy = JSON.parse(JSON.stringify(res.data))
          this.personList = res.data
          this.personLoad = false
          this.$refs.personTable.doLayout()
        })
      }
    },
    getNodeParent(val) {
      this.currentCompaniesList[val.level - 1] = val.data.companyId
      if (val.parent != null) {
        this.getNodeParent(val.parent)
      }
    },
    nodeOpen0(data, node, el) {
      // this.currentCompaniesList[node.level - nodeOpen01] = data.id
    },
    filterNode2(value, data) {
      if (!value) return true;
      return data['companyName'].indexOf(value) !== -1;
    },
    addUser2() {
      if (this.multipleSelection.length === 0) {
        return this.$message.error('请选择人员')
      }
      if (this.currentCompaniesList.length === 0) {
        return this.$message.error('请选择组织')
      }
      /* for (let index = this.currentCompaniesList.length-1; index >1; index--) {
        let obj = this.multipleSelection.find(a=>a.companyId==this.currentCompaniesList[index])
        if(!obj){
          this.currentCompaniesList.splice(index,1)
        }
      } */
      let arr = []
      this.currentCompaniesList.forEach(b => {
        let obj = this.companiesList.find(a => a.companyId == b)
        arr.push(obj)
      })
      this.addLoad = true
      addPersonUser({
        company: arr,
        person: this.multipleSelection,
        // roleId: this.componentData.entity.roleId
      }).then(res => {
        this.$message.success('操作成功')
        this.multipleSelection = []
        this.$refs.personTable.clearSelection()
        this.addLoad = false
        this.addthirdParty = false
        this.userSearch2 = ''
        this.getList()
      }).catch(e => {
        this.addLoad = false
      })
    },
    /** 新增按钮操作 */
    handleAdd() {