<template> 
 | 
  <zt-dialog ref="dialog" @confirm="formSubmit" column="2" append-to-body> 
 | 
    <el-form :model="dataForm" ref="dataForm" :disabled="dataForm.disabled" label-width="120px"> 
 | 
      <el-collapse v-model="activeNames"> 
 | 
        <el-collapse-item name="1"> 
 | 
          <template slot="title"> 
 | 
            <el-tag>{{ $t('user.title') }}</el-tag> 
 | 
          </template> 
 | 
          <el-form-item prop="avatar" :label="$t('user.avatar')"> 
 | 
            <zt-uploader v-model="dataForm.avatar" crop :size="60"/> 
 | 
          </el-form-item> 
 | 
          <zt-form-item prop="username" :label="$t('user.username')" rules="required"> 
 | 
            <el-input v-model="dataForm.username" :placeholder="$t('user.username')"></el-input> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="realName" :label="$t('user.realName')" rules="required"> 
 | 
            <el-input v-model="dataForm.realName" :placeholder="$t('user.realName')"></el-input> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="nickName" :label="$t('user.nickName')"> 
 | 
            <el-input v-model="dataForm.nickName" :placeholder="$t('user.nickName')"></el-input> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="simpleSpelling" :label="$t('user.simpleSpelling')" rules="required"> 
 | 
            <el-input v-model="dataForm.simpleSpelling" :placeholder="$t('user.simpleSpelling')"></el-input> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="fullSpelling" :label="$t('user.fullSpelling')" rules="required"> 
 | 
            <el-input v-model="dataForm.fullSpelling" :placeholder="$t('user.fullSpelling')"></el-input> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="gender" :label="$t('user.gender')" rules="required"> 
 | 
            <zt-dict v-model="dataForm.gender" dict="gender" :radio="true"></zt-dict> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="mobile" :label="$t('user.mobile')" rules="required|mobile"> 
 | 
            <el-input v-model="dataForm.mobile" :placeholder="$t('user.mobile')"></el-input> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="dingcode" :label="$t('user.dingcode')"> 
 | 
            <el-input v-model="dataForm.dingcode" :placeholder="$t('user.dingcode')"></el-input> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="wechat" :label="$t('user.wechat')"> 
 | 
            <el-input v-model="dataForm.wechat" :placeholder="$t('user.wechat')"></el-input> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="email" :label="$t('user.email')" rules="email"> 
 | 
            <el-input v-model="dataForm.email" :placeholder="$t('user.email')"></el-input> 
 | 
          </zt-form-item> 
 | 
        </el-collapse-item> 
 | 
  
 | 
        <el-collapse-item name="2"> 
 | 
          <template slot="title"> 
 | 
            <el-tag>{{ $t('user.dept') }}</el-tag> 
 | 
          </template> 
 | 
          <zt-form-item prop="deptId" :label="$t('user.deptName')" rules="required"> 
 | 
            <zt-combo-tree v-model="dataForm.deptId" :datas="deptList" @select="onDeptSelect"/> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="userCode" :label="$t('user.userCode')"> 
 | 
            <el-input v-model="dataForm.userCode" :placeholder="$t('user.userCode')"></el-input> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="jobIdList" :label="$t('user.jobIdList')" class="role-list"> 
 | 
            <zt-combo-tree v-model="dataForm.jobIdList" :datas="jobList" multiple :check-strictly="true"/> 
 | 
          </zt-form-item> 
 | 
          <zt-form-item prop="postIdList" :label="$t('user.postIdList')" class="role-list"> 
 | 
            <zt-select v-model="dataForm.postIdList" :datas="postList" multiple :placeholder="$t('user.setPost')"></zt-select> 
 | 
          </zt-form-item> 
 | 
          <el-form-item prop="sort" :label="$t('dept.sort')"> 
 | 
            <el-input-number v-model="dataForm.sort" controls-position="right" :min="0" 
 | 
                            :label="$t('dept.sort')"></el-input-number> 
 | 
          </el-form-item> 
 | 
        </el-collapse-item> 
 | 
      </el-collapse> 
 | 
    </el-form> 
 | 
  </zt-dialog> 
 | 
</template> 
 | 
  
 | 
<script> 
 | 
  
 | 
  export default { 
 | 
    data() { 
 | 
      return { 
 | 
        activeNames: ['1', '2'], 
 | 
        postList: [], 
 | 
        jobList: [], 
 | 
        deptList: [], 
 | 
        dataForm: { 
 | 
          userCode: '', 
 | 
          username: '', 
 | 
          deptId: '', 
 | 
          deptName: '', 
 | 
          realName: '', 
 | 
          nickName: '', 
 | 
          headUrl: '', 
 | 
          simpleSpelling: '', 
 | 
          fullSpelling: '', 
 | 
          gender: 0, 
 | 
          email: '', 
 | 
          mobile: '', 
 | 
          dingcode: '', 
 | 
          wechat: '', 
 | 
          sort: 1, 
 | 
          status: 1 
 | 
        } 
 | 
      } 
 | 
    }, 
 | 
    computed: { 
 | 
    }, 
 | 
    methods: { 
 | 
      init() { 
 | 
        this.getDeptList() 
 | 
      }, 
 | 
      // 获取部门列表 
 | 
      async getDeptList() { 
 | 
        let res = await this.$http.get('/sys/dept/tree') 
 | 
        if (res.success) { 
 | 
          this.deptList = res.data 
 | 
        } 
 | 
      }, 
 | 
      // 获取岗位列表 
 | 
      async getPostList(deptId) { 
 | 
        let res = await this.$http.get('/sys/post/list?deptId=' + deptId) 
 | 
        if (res.success) { 
 | 
          this.postList = res.data 
 | 
        } 
 | 
      }, 
 | 
      // 获取职位列表 
 | 
      async getJobList(companyId) { 
 | 
        let res = await this.$http.get('/sys/job/tree?companyId=' + companyId) 
 | 
        if (res.success) { 
 | 
          this.jobList = res.data 
 | 
        } 
 | 
      }, 
 | 
      // 获取信息 
 | 
      async getInfo() { 
 | 
        let res = await this.$http.get(`/sys/user/${this.dataForm.id}`) 
 | 
        if (res.success) { 
 | 
          this.dataForm = { 
 | 
            ...this.dataForm, 
 | 
            ...res.data 
 | 
          } 
 | 
        } 
 | 
      }, 
 | 
      onDeptSelect(data, isChange) { 
 | 
        if (data) { 
 | 
          this.getJobList(data.companyId) 
 | 
          this.getPostList(data.id) 
 | 
        } else { 
 | 
          this.jobIdList = [] 
 | 
          this.postIdList = [] 
 | 
        } 
 | 
        if (isChange) { 
 | 
          this.dataForm.jobIdList = [] 
 | 
          this.dataForm.postIdList = [] 
 | 
        } 
 | 
      }, 
 | 
      // 表单提交 
 | 
      async formSubmit() { 
 | 
        this.dataForm.companyId = this.companyId 
 | 
        let res = await this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/user', this.dataForm) 
 | 
        if (res.success) { 
 | 
          await this.$tip.success() 
 | 
          this.$refs.dialog.close() 
 | 
          this.$emit('refreshDataList') 
 | 
        } 
 | 
      } 
 | 
    } 
 | 
  } 
 | 
</script> 
 | 
  
 | 
// <style lang="scss"> 
 | 
//   .mod-sys__user { 
 | 
//     .role-list { 
 | 
//       .el-select { 
 | 
//         width: 100%; 
 | 
//       } 
 | 
//     } 
 | 
//   } 
 | 
  
 | 
//   .avatar-uploader .el-upload { 
 | 
//     border: 1px dashed #d9d9d9; 
 | 
//     border-radius: 6px; 
 | 
//     cursor: pointer; 
 | 
//     position: relative; 
 | 
//     overflow: hidden; 
 | 
//   } 
 | 
  
 | 
//   .avatar-uploader .el-upload:hover { 
 | 
//     border-color: #409EFF; 
 | 
//   } 
 | 
  
 | 
//   .avatar-uploader-icon { 
 | 
//     font-size: 2.8px; 
 | 
//     color: #8c939d; 
 | 
//     width: 27.8px; 
 | 
//     height: 27.8px; 
 | 
//     line-height: 27.8px; 
 | 
//     text-align: center; 
 | 
//   } 
 | 
  
 | 
//   .avatar { 
 | 
//     width: 27.8px; 
 | 
//     height: 27.8px; 
 | 
//     display: block; 
 | 
//   } 
 | 
// </style> 
 |