小小儁爺
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>
@@ -34,8 +34,9 @@
                popper-class="elCascader"
                :options="StuOrgArr"
                :props="defaultProps"
                @change="cascaderChange"
              />
              <!--              @change="cascaderChange"-->
              <!--              @focus="getUserOrganization"-->
            </el-form-item>
@@ -134,10 +135,27 @@
            <template slot-scope="{row}">
              <div v-if="row[item.prop]==='1'&&row.wagetype">计时制</div>
              <div v-else-if="row[item.prop]==='2'&&row.wagetype">计件制</div>
              <div v-else-if="row[item.prop]==='Y'&& item.prop==='enable'"><i class="el-icon-success" :style="{color:$store.state.settings.theme}" style="margin-right: 2px" />在职</div>
              <div v-else-if="row[item.prop]==='N'&& item.prop==='enable'"><i class="el-icon-info" style="margin-right: 2px" />离职</div>
              <div v-else-if="row[item.prop]==='Y'&& item.prop==='is_role'"><i class="el-icon-share" :style="{color:$store.state.settings.theme}" @click="roleClick({row})" /></div>
              <div v-else-if="row[item.prop]==='N'&& item.prop==='is_role'"><i class="el-icon-share" style="color: rgb(180 ,181, 185)" @click="roleClick({row})" /></div>
              <div v-else-if="row[item.prop]==='Y'&& item.prop==='enable'"><i
                class="el-icon-success"
                :style="{color:$store.state.settings.theme}"
                style="margin-right: 2px"
              />在职
              </div>
              <div v-else-if="row[item.prop]==='N'&& item.prop==='enable'"><i
                class="el-icon-info"
                style="margin-right: 2px"
              />离职
              </div>
              <div v-else-if="row[item.prop]==='Y'&& item.prop==='is_role'"><i
                class="el-icon-share"
                :style="{color:$store.state.settings.theme}"
                @click="roleClick({row})"
              /></div>
              <div v-else-if="row[item.prop]==='N'&& item.prop==='is_role'"><i
                class="el-icon-share"
                style="color: rgb(180 ,181, 185)"
                @click="roleClick({row})"
              /></div>
              <div v-else-if="!row[item.prop]">/</div>
              <div v-else>{{ row[item.prop] }}</div>
            </template>
@@ -305,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>
@@ -318,7 +336,7 @@
        :page.sync="form.page"
        :limit.sync="form.rows"
        align="right"
        layout="total ,prev, pager, next,sizes"
        layout="total ,prev, pager, next,sizes,jumper"
        popper-class="select_bottom"
        @pagination="getUserSearch"
      />
@@ -561,18 +579,11 @@
        <el-table-column
          v-if="$store.state.settings.orgType!=='W'"
          prop="stu_torgcode"
          label="车间名称"
          label="所属组织"
          sortable="custom"
          show-tooltip-when-overflow
        >
          <template slot-scope="{row}">
            <!--            <el-input-->
            <!--              v-if="row.isVisible===1"-->
            <!--              v-model="row.group_code"-->
            <!--              oninput="value=value.replace(/[^0-9a-zA-Z]/g,'')"-->
            <!--              placeholder="请输入"-->
            <!--            />-->
            <el-cascader
              v-if="row.isVisible===1"
              ref="dialogCascader"
@@ -693,7 +704,7 @@
import { StorgGroupSelect } from '@/api/basicInfo'
export default {
  name: 'YYQD',
  name: 'UserList',
  components: {
    Pagination, ImportPicker, TableColumnSettings
  },
@@ -738,6 +749,7 @@
        UserCode: '', // 用户编码
        UserName: '', // 用户名称
        StuOrg: getCookie('stu_torgcode'), // 所属组织
        description: getCookie('description'), // 组织类型
        wagetype: '', // 工资类型
        Enable: '', // 在职状态
        prop: 'lm_date', // 排序字段
@@ -784,13 +796,76 @@
          fixed: false,
          sortable: true
        },
        { minWidth: 110, width: false, prop: 'password', label: '用户密码', id: 5, show: true, fixed: false, sortable: 'custom' },
        { minWidth: 110, width: false, prop: 'stu_torgcode', label: '组织编码', id: 6, show: false, fixed: false, sortable: 'custom' },
        { minWidth: 110, width: false, prop: 'org_name', label: '所属组织', id: 7, show: true, fixed: false, sortable: 'custom' },
        { minWidth: 110, width: false, prop: 'group_code', label: '班组编码', id: 8, show: false, fixed: false, sortable: 'custom' },
        { minWidth: 110, width: false, prop: 'group_name', label: '生产班组', id: 9, show: true, fixed: false, sortable: 'custom' },
        { minWidth: 110, width: false, prop: 'wagetype', label: '工资类型', id: 10, show: true, fixed: false, sortable: 'custom' },
        { minWidth: 110, width: false, prop: 'mobile', label: '联系方式', id: 11, show: true, fixed: false, sortable: 'custom' },
        {
          minWidth: 110,
          width: false,
          prop: 'password',
          label: '用户密码',
          id: 5,
          show: true,
          fixed: false,
          sortable: 'custom'
        },
        {
          minWidth: 110,
          width: false,
          prop: 'stu_torgcode',
          label: '组织编码',
          id: 6,
          show: false,
          fixed: false,
          sortable: 'custom'
        },
        {
          minWidth: 110,
          width: false,
          prop: 'org_name',
          label: '所属组织',
          id: 7,
          show: true,
          fixed: false,
          sortable: 'custom'
        },
        {
          minWidth: 110,
          width: false,
          prop: 'group_code',
          label: '班组编码',
          id: 8,
          show: false,
          fixed: false,
          sortable: 'custom'
        },
        {
          minWidth: 110,
          width: false,
          prop: 'group_name',
          label: '生产班组',
          id: 9,
          show: true,
          fixed: false,
          sortable: 'custom'
        },
        {
          minWidth: 110,
          width: false,
          prop: 'wagetype',
          label: '工资类型',
          id: 10,
          show: true,
          fixed: false,
          sortable: 'custom'
        },
        {
          minWidth: 110,
          width: false,
          prop: 'mobile',
          label: '联系方式',
          id: 11,
          show: true,
          fixed: false,
          sortable: 'custom'
        },
        {
          minWidth: 110,
          width: false,
@@ -897,6 +972,8 @@
      },
      dialogVisibleRoles: false,
      dialogFormRoles: {
        stu_torgcode: '', // 所属组织
        description: '', // 所属组织类型
        username: '', // 用户名称
        usercode: '', // 用户编码
        rolesArr: [], // 角色类型集合
@@ -1005,42 +1082,45 @@
      this.form.UserName = ''
      this.form.Enable = ''
      this.form.wagetype = ''
      this.form.StuOrg = getCookie('stu_torgcode')
      this.$refs.cascader.checkedValue = ''// 级联选择器的清空
      this.form.description = getCookie('description') === '' ? '' : getCookie('description')
      this.form.StuOrg = getCookie('stu_torgcode') === '' ? '' : getCookie('stu_torgcode')
      // console.log(getCookie('stu_torgcode') === '')
      // if (this.$store.state.settings.orgType === '') {
      //   this.$refs.cascader.checkedValue = ''
      // }
      this.getUserSearch()
    },
    // 级联选择器改变事件
    cascaderChange(val) {
      console.log(val)
      this.form.StuOrg = val[val.length - 1]
      // this.$refs.cascader.checkValue
      this.form.description = this.StuOrgArr.find(i => i.code === val) ? 'D' : 'W'
    },
    dialogCascaderChange(val) {
      console.log(val)
      this.dialogForm.groupcode = ''
      this.getStorgGroupSelect(val)
      this.getStorgGroupSelect(val, this.StuOrgArr2.find(i => i.code === val) ? 'D' : 'W')
    },
    // 获取下拉生产班组
    async getStorgGroupSelect(stu_torgcode) {
    async getStorgGroupSelect(stu_torgcode, description) {
      const data = {
        stu_torgcode,
        description: this.StuOrgArr2.find(i => i.code === stu_torgcode) ? 'D' : 'W'
        description
      }
      const { data: res } = await StorgGroupSelect(data)
      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')
      }
    },
    // 修改按钮
@@ -1062,17 +1142,20 @@
        this.dialogForm.Email = row.email
        this.dialogForm.wagetype = row.wagetype
      })
      this.getStorgGroupSelect()
      this.getStorgGroupSelect(row.stu_torgcode, this.StuOrgArr.find(i => i.code === row.stu_torgcode) ? 'D' : 'W')
      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) {
@@ -1164,11 +1247,14 @@
      this.dialogFormRoles.rolesArrSelectedArr = []
      this.dialogFormRoles.rolesArr = []
      this.dialogFormRoles.roleTree = []
      this.dialogFormRoles.roleTreeSelectedArr = []
      this.dialogFormRoles.username = row.username
      this.dialogFormRoles.usercode = row.usercode
      UserAssociationRole({ usercode: row.usercode }).then(res => {
      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(() => {
            loading.close()
@@ -1231,7 +1317,10 @@
    // 用户关联对话框确认事件
    async rolesDialogVisibleConfirm() {
      this.$store.state.app.buttonIsDisabled = true
      const res = await SaveUserAssoctRole(this.dialogFormRoles.roleTreeSelectedArr, this.dialogFormRoles.usercode)
      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('保存成功!')
@@ -1295,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])// 过滤掉选中相同的
@@ -1474,7 +1568,6 @@
          this.workingTableData.splice(index, 1)
        }
      })
      // this.getStorgGroupSelect()
    },
    // 生产班组排序
    sortChangeOfWorking({ column, prop, order }) {
@@ -1506,7 +1599,14 @@
      let number = Math.random() * Math.random()// 作为删除时的标识符
      number = number === 0 ? (10 + Math.random()) : number
      const data = { storg_code: getCookie('stu_torgcode'), group_code: '', group_name: '', description: '', isVisible: 1, number: number }
      const data = {
        storg_code: getCookie('stu_torgcode'),
        group_code: '',
        group_name: '',
        description: '',
        isVisible: 1,
        number: number
      }
      this.workingTableData.unshift(data)
    },
    // 删除