loulijun2021
2023-08-08 68edca7409736705db50504b003cba66bb4ccd6e
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>
@@ -29,12 +29,14 @@
            <el-form-item label="所属组织" style=" display: flex;">
              <el-cascader
                ref="cascader"
                v-model="form.StuOrg"
                filterable
                popper-class="elCascader"
                :options="StuOrgArr"
                :props="defaultProps"
                @change="cascaderChange"
              />
              <!--              @focus="getUserOrganization"-->
            </el-form-item>
@@ -133,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>
@@ -304,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>
@@ -317,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"
      />
@@ -364,6 +383,7 @@
          <el-cascader
            ref="dialogCascader"
            key="cascaderKey"
            v-model="dialogForm.StuOrg"
            filterable
            popper-class="elCascader"
            :options="StuOrgArr2"
@@ -371,6 +391,7 @@
            style="width: 200px;"
            @change="dialogCascaderChange"
          />
        </el-form-item>
        <el-form-item label="所属班组" prop="groupcode">
          <el-select
@@ -518,7 +539,7 @@
      v-el-drag-dialog
      title="生产班组"
      :visible.sync="workingDialogVisible"
      width="800px"
      width="1000px"
      top="15vh"
      :close-on-click-modal="false"
      class="workingDialogVisible"
@@ -555,6 +576,29 @@
          label="序号"
          prop="RowNum"
        />
        <el-table-column
          v-if="$store.state.settings.orgType!=='W'"
          prop="stu_torgcode"
          label="所属组织"
          sortable="custom"
          show-tooltip-when-overflow
        >
          <template slot-scope="{row}">
            <el-cascader
              v-if="row.isVisible===1"
              ref="dialogCascader"
              key="cascaderKey"
              v-model="row.storg_code"
              filterable
              popper-class="elCascader"
              :options="StuOrgArr2"
              :props="defaultProps"
              style="width: 200px;"
            />
            <div v-else> {{ row.org_name }}</div>
          </template>
        </el-table-column>
        <el-table-column
          prop="group_code"
          label="班组编码"
@@ -657,6 +701,7 @@
import { MesOrderStepReportSelectUserGroup } from '@/api/produceManager'
import elDragDialog from '@/directive/el-drag-dialog'
import TableColumnSettings from '@/components/TableColumnSettings'
import { StorgGroupSelect } from '@/api/basicInfo'
export default {
  name: 'YYQD',
@@ -703,7 +748,8 @@
      form: {
        UserCode: '', // 用户编码
        UserName: '', // 用户名称
        StuOrg: '', // 所属组织
        StuOrg: getCookie('stu_torgcode'), // 所属组织
        description: getCookie('description'), // 组织类型
        wagetype: '', // 工资类型
        Enable: '', // 在职状态
        prop: 'lm_date', // 排序字段
@@ -717,7 +763,8 @@
        checkStrictly: true,
        value: 'code',
        label: 'name',
        children: 'children'
        children: 'children',
        emitPath: false
      },
      EnableArr: [
        { value: 'Y', label: '在职' },
@@ -749,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,
@@ -816,7 +926,7 @@
        UserName: '',
        Password: '123456',
        Enable: 'Y',
        StuOrg: '',
        StuOrg: getCookie('stu_torgcode'),
        Mobile: '',
        Email: '',
        groupcode: '',
@@ -862,6 +972,8 @@
      },
      dialogVisibleRoles: false,
      dialogFormRoles: {
        stu_torgcode: '', // 所属组织
        description: '', // 所属组织类型
        username: '', // 用户名称
        usercode: '', // 用户编码
        rolesArr: [], // 角色类型集合
@@ -931,6 +1043,7 @@
    // 获取所属组织
    async getUserOrganization() {
      const { data: res } = await UserOrganization()
      this.StuOrgArr = clearAllChildren(res)
    },
    // 获取所属组织对话框
@@ -967,30 +1080,48 @@
    reset() {
      this.form.UserCode = ''
      this.form.UserName = ''
      this.form.StuOrg = ''
      this.form.Enable = 'Y'
      this.form.Enable = ''
      this.form.wagetype = ''
      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) {
      this.form.StuOrg = val[val.length - 1]
      this.form.description = this.StuOrgArr.find(i => i.code === val) ? 'D' : 'W'
    },
    dialogCascaderChange(val) {
      this.dialogForm.StuOrg = val[val.length - 1]
      this.dialogForm.groupcode = ''
      this.getStorgGroupSelect(val, this.StuOrgArr2.find(i => i.code === val) ? 'D' : 'W')
    },
    // 获取下拉生产班组
    async getMesOrderStepReportSelectUserGroup() {
      const { data: res } = await MesOrderStepReportSelectUserGroup()
    async getStorgGroupSelect(stu_torgcode, description) {
      const data = {
        stu_torgcode,
        description
      }
      const { data: res } = await StorgGroupSelect(data)
      this.usergroupArr = res
    },
    // 新增按钮
    add(operation) {
    async add(operation) {
      this.operation = operation
      this.dialogVisible = true
      this.getUserOrganization2()
      this.getMesOrderStepReportSelectUserGroup()
      // this.dialogForm.StuOrg = getCookie('stu_torgcode')
      // this.$refs.dialogCascader.checkedValue = [getCookie('stu_torgcode')]
      await this.getUserOrganization2()
      if (this.$store.state.settings.orgType !== '') {
        await this.getStorgGroupSelect(getCookie('stu_torgcode'), this.StuOrgArr2.find(i => i.code === getCookie('stu_torgcode')) ? 'D' : 'W')
      }
    },
    // 修改按钮
    edit(operation, row) {
@@ -1011,17 +1142,20 @@
        this.dialogForm.Email = row.email
        this.dialogForm.wagetype = row.wagetype
      })
      this.getMesOrderStepReportSelectUserGroup()
      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) {
@@ -1041,12 +1175,13 @@
      this.dialogForm.UserName = ''
      this.dialogForm.Password = '123456'
      this.dialogForm.Enable = 'Y'
      this.$refs.dialogCascader.checkedValue = ''
      this.dialogForm.StuOrg = ''
      this.$refs.dialogCascader.checkedValue = getCookie('stu_torgcode')
      this.dialogForm.StuOrg = getCookie('stu_torgcode')
      this.dialogForm.Mobile = ''
      this.dialogForm.Email = ''
      this.dialogForm.groupcode = ''
      this.dialogForm.wagetype = '2'
      this.usergroupArr = []
      this.$refs.dialogForm.clearValidate()
    },
    // 对话框取消
@@ -1112,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()
@@ -1179,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('保存成功!')
@@ -1243,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])// 过滤掉选中相同的
@@ -1409,6 +1555,7 @@
    workingTramClick() {
      this.workingDialogVisible = true
      this.getUserGroupSearch()
      this.getUserOrganization2()
      // 页面加载完后重新渲染表格
      this.$nextTick(() => {
        this.$refs.workingTableData.doLayout()
@@ -1421,7 +1568,6 @@
          this.workingTableData.splice(index, 1)
        }
      })
      this.getMesOrderStepReportSelectUserGroup()
    },
    // 生产班组排序
    sortChangeOfWorking({ column, prop, order }) {
@@ -1453,7 +1599,14 @@
      let number = Math.random() * Math.random()// 作为删除时的标识符
      number = number === 0 ? (10 + Math.random()) : number
      const data = { 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)
    },
    // 删除
@@ -1478,6 +1631,9 @@
    },
    // 保存
    async saveWorking(row) {
      if (row.storg_code.trim().length < 1) {
        return this.$message.info('车间不能为空!')
      }
      if (row.group_code.trim().length < 1) {
        return this.$message.info('班组编码不能为空!')
      }
@@ -1488,6 +1644,7 @@
      //   return this.$message.info('班组描述不能为空!')
      // }
      const data = {
        storg_code: row.storg_code,
        code: row.group_code,
        name: row.group_name,
        flag: row.description