weicd
2023-12-11 9d2fe06389cd3629e121fb16669242e47bfc1648
eladmin-web-master/src/views/system/user/index.vue
@@ -107,7 +107,7 @@
            </el-button>
          </crudOperation>
        </div>
        <!--表单渲染-->
        <!--表单组件-->
        <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="570px">
          <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="66px">
            <el-form-item label="用户名" prop="username">
@@ -199,8 +199,13 @@
                >{{ item.label }}</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="公司" prop="companyId">
              <el-select v-model="form.companyId" style="width: 437px" clearable>
            <el-form-item v-if="!isEditing" label="实习时间" prop="internshipTime" label-width="68px">
              <el-select v-model="form.internshipTime" clearable style="width: 437px">
                <el-option v-for="item in internshipTimeList" :key="item.id" :label="item.label" :value="item.id" />
              </el-select>
            </el-form-item>
            <el-form-item label="公司" prop="company.id">
              <el-select v-model="form.company.id" clearable style="width: 437px">
                <el-option v-for="item in companyList" :key="item.id" :label="item.label" :value="item.id" />
              </el-select>
            </el-form-item>
@@ -241,15 +246,14 @@
              <div>{{ scope.row.dept.name }}</div>
            </template>
          </el-table-column>
          <!-- 魏传栋 - 始 -->
          <el-table-column :show-overflow-tooltip="true" prop="companyId" label="公司" width="150">
            <template slot-scope="scope">
            <!-- <template slot-scope="scope">
              <span>{{ scope.row.company.label }}</span>
              <template v-for="item in companyList">
                <span v-if="scope.row.companyId == item.id" :key="item.id">{{ item.label }}</span>
                <span v-if="scope.row.company.id == item.id" :key="item.id">{{ item.label }}</span>
              </template>
            </template>
            </template> -->
          </el-table-column>
          <!-- 魏传栋 - 终 -->
          <el-table-column label="状态" align="center" prop="enabled">
            <template slot-scope="scope">
              <el-switch
@@ -306,7 +310,7 @@
import crudSysCompany from '@/api/system/sysCompany'
let userRoles = []
let userJobs = []
const defaultForm = { id: null, username: null, nickName: null, gender: '男', email: null, enabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null, birthday: null, address: null, dingding: null, sysRostering: { id: null }, levelId: null }
const defaultForm = { id: null, username: null, company: { id: null }, internshipTime:null, nickName: null, gender: '男', email: null, enabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null, birthday: null, address: null, dingding: null, sysRostering: { id: null }, levelId: null }
export default {
  name: 'User',
  components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
@@ -374,11 +378,12 @@
        address: [
          { min: 2, max: 100, message: '长度在 2 到 100 个字符', trigger: 'blur' }
        ],
        // 魏传栋 - 始
        companyId: [
          { required: true, message: '请选择公司', trigger: 'blur' }
        ]
        // 魏传栋 - 终
        ],
        'company.id': [
          { required: true, message: '公司不能为空', trigger: 'blur' }
        ],
      },
      // CRUD状态
      crudStatusPrepared: CRUD.STATUS.PREPARED,
@@ -386,10 +391,10 @@
      rosterings: [],
      // 级别
      levels: [],
      // 魏传栋-始
      // 公司
      companyList: []
      // 魏传栋-终
      companyList: [],
      internshipTimeList: Array.from({length: 12}, (v, i) => ({id: i+2, label: `${i+1}个月`})),
      isEditing: false
    }
  },
  computed: {
@@ -407,17 +412,18 @@
    }
  },
  methods: {
    // 魏传栋 - 始
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      // 查询配置参数
      crudSysCompany.getAll().then(res => {
        // 公司列表
        this.companyList = res
        this.companyList.forEach(image => {
          console.log('id:' + image.id)
      })
      })
      return true
    },
    // 魏传栋 - 终
    // 禁止输入空格
    keydown(e) {
      if (e.keyCode === 32) {
@@ -470,6 +476,7 @@
    [CRUD.HOOK.beforeToAdd]() {
      this.jobDatas = []
      this.roleDatas = []
      this.isEditing = false
    },
    // 初始化编辑时候的角色与岗位
    [CRUD.HOOK.beforeToEdit](crud, form) {
@@ -479,6 +486,7 @@
      userRoles = []
      userJobs = []
      const _this = this
      this.isEditing = true
      form.roles.forEach(function(role, index) {
        _this.roleDatas.push(role.id)
        const rol = { id: role.id }