小小儁爺
2024-08-08 d20654ba067e5c0621d4d7d95915cbe47a10fe87
src/views/basicSettings/userList.vue
@@ -6,7 +6,7 @@
        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">新增</el-button>
        <div style="display: flex">
          <el-button v-waves icon="el-icon-menu" @click="workingTramClick">生产班组</el-button>
          <!--          <el-button v-waves icon="el-icon-menu" @click="workingTramClick">生产班组</el-button>-->
          <el-button v-waves icon="el-icon-download" @click="upload">导入</el-button>
        </div>
      </div>
@@ -323,7 +323,7 @@
                  />
                </el-tooltip>
                <el-tooltip v-del-tab-index class="item" effect="dark" content="删除" placement="top">
                  <i :style="{color:$store.state.settings.theme}" class="el-icon-delete" @click="del(row.id)" />
                  <i :style="{color:$store.state.settings.theme}" class="el-icon-delete" @click="del(row)" />
                </el-tooltip>
              </div>
            </template>
@@ -704,7 +704,7 @@
import { StorgGroupSelect } from '@/api/basicInfo'
export default {
  name: 'YYQD',
  name: 'UserList',
  components: {
    Pagination, ImportPicker, TableColumnSettings
  },
@@ -973,6 +973,7 @@
      dialogVisibleRoles: false,
      dialogFormRoles: {
        stu_torgcode: '', // 所属组织
        description: '', // 所属组织类型
        username: '', // 用户名称
        usercode: '', // 用户编码
        rolesArr: [], // 角色类型集合
@@ -1109,17 +1110,17 @@
      this.usergroupArr = res
    },
    // 新增按钮
    add(operation) {
    async add(operation) {
      this.operation = operation
      this.dialogVisible = true
      // this.dialogForm.StuOrg = getCookie('stu_torgcode')
      // this.$refs.dialogCascader.checkedValue = [getCookie('stu_torgcode')]
      this.getUserOrganization2()
      await this.getUserOrganization2()
      if (this.$store.state.settings.orgType !== '') {
        this.getStorgGroupSelect(getCookie('stu_torgcode'), this.StuOrgArr2.find(i => i.code === getCookie('stu_torgcode')) ? 'D' : 'W')
        await this.getStorgGroupSelect(getCookie('stu_torgcode'), this.StuOrgArr2.find(i => i.code === getCookie('stu_torgcode')) ? 'D' : 'W')
      }
    },
    // 修改按钮
@@ -1145,13 +1146,16 @@
      this.getUserOrganization2()
    },
    // 删除按钮
    async del(id) {
    async del(row) {
      if (getCookie('admin') === row.usercode) {
        return this.$message.info('无法删除用户本身!')
      }
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        DeleteUser({ Userid: id }).then(res => {
        DeleteUser({ Userid: row.id }).then(res => {
          if (res.code === '200') {
            this.$message.success('删除成功!')
            if (this.form.page > 1 && this.tableData.length === 1) {
@@ -1243,11 +1247,13 @@
      this.dialogFormRoles.rolesArrSelectedArr = []
      this.dialogFormRoles.rolesArr = []
      this.dialogFormRoles.roleTree = []
      this.dialogFormRoles.roleTreeSelectedArr = []
      this.dialogFormRoles.username = row.username
      this.dialogFormRoles.usercode = row.usercode
      this.dialogFormRoles.stu_torgcode = row.stu_torgcode
      this.dialogFormRoles.description = row.description
      UserAssociationRole({ usercode: row.usercode, stu_torgcode: row.stu_torgcode, description: row.description }).then(res => {
        if (res.code === '200') {
          setTimeout(() => {
@@ -1311,7 +1317,10 @@
    // 用户关联对话框确认事件
    async rolesDialogVisibleConfirm() {
      this.$store.state.app.buttonIsDisabled = true
      const res = await SaveUserAssoctRole(this.dialogFormRoles.roleTreeSelectedArr, this.dialogFormRoles.usercode, this.dialogFormRoles.stu_torgcode)
      this.dialogFormRoles.roleTreeSelectedArr.forEach(i => {
        i.Data = [...new Set(i.Data)]
      })
      const res = await SaveUserAssoctRole(this.dialogFormRoles.roleTreeSelectedArr, this.dialogFormRoles.usercode, this.dialogFormRoles.stu_torgcode, this.dialogFormRoles.description)
      if (res.code === '200') {
        this.dialogVisibleRoles = false
        this.$message.success('保存成功!')
@@ -1375,12 +1384,17 @@
              } else {
                this.dialogFormRoles.roleTreeSelectedArr.forEach((i, ind) => { // 当选子code时执行
                  if (i.Code === checkedFatherCode) {
                    let flag = true
                    this.dialogFormRoles.roleTreeSelectedArr[ind].Data.forEach((i1, ind2) => {
                      if (i1 === a[0]) {
                        // this.dialogFormRoles.roleTreeSelectedArr[ind].Data.splice(ind2, 1)// 当子code与现在的code相同时执行
                        this.dialogFormRoles.roleTreeSelectedArr[ind].Data = this.dialogFormRoles.roleTreeSelectedArr[ind].Data.filter(i2 => i2 !== a[0])
                        flag = false
                      } else {
                        this.dialogFormRoles.roleTreeSelectedArr[ind].Data.push(a[0])// //当子code与现在的code不相同时执行
                        if (flag) {
                          console.log('执行了')
                          this.dialogFormRoles.roleTreeSelectedArr[ind].Data.push(a[0])// //当子code与现在的code不相同时执行
                        }
                      }
                    })
                    // this.dialogFormRoles.roleTreeSelectedArr[ind].Data.filter((i1, ind2) => i1 !== a[0])// 过滤掉选中相同的