zhouwenxuan
2024-01-19 9cdbffc57965dbb88758d6cde8c174fc3a1c3fb3
src/views/safetyReview/userManage/expertUsers/components/expertDialog.vue
@@ -39,7 +39,8 @@
                <el-row :gutter="22">
                    <el-col :span="11">
                        <el-form-item label="所属机构:"  prop="agencyId" v-if="state.title !== '修改密码'">
                            <el-select v-model="state.form.agencyId"  style="width: 100%" v-loadMore="loadMore" class="m-2" placeholder="请选择机构" popper-class="more_select_dropdown"   >
                            <el-input v-if="isAgency" v-model="state.agencyName" disabled></el-input>
                            <el-select v-model="state.form.agencyId" v-else style="width: 100%" v-loadMore="loadMore" class="m-2" placeholder="请选择机构" popper-class="more_select_dropdown"   >
                                <el-option
                                    v-for="item in state.agencyList"
                                    :key="item.id"
@@ -180,7 +181,27 @@
                            <div class="el-upload__tip">上传jpg/png图片尺寸小于5M</div>
                        </template>
                    </el-upload>
                </el-form-item>
                <el-form-item prop="idPhoto" label="证件照:" v-if="state.title !== '修改密码'">
                  <el-upload
                      accept="image/*"
                      :action="state.uploadUrl"
                      :headers="state.header"
                      method="post"
                      :on-change="handleChangePic"
                      :on-success="handlePhotoSuccess"
                      :on-preview="handlePictureCardPreview"
                      v-model:file-list="state.photoList"
                      list-type="picture-card"
                      :before-upload="picSize"
                      :on-remove="handlePhotoRemove"
                      :limit="2"
                  >
                    <el-icon><Plus /></el-icon>
                    <template #tip>
                      <div class="el-upload__tip">上传jpg/png图片尺寸小于5M</div>
                    </template>
                  </el-upload>
                </el-form-item>
            </el-form>
            <template #footer >
@@ -207,6 +228,9 @@
import {resetUserPwd} from "../../../../../api/sysUsers";
import {getToken} from "@/utils/auth";
import {getInsitutionList} from "@/api/backManage/insitution";
import {getDictList} from "@/api/backManage/evaluate";
import Cookies from "js-cookie";
const emit = defineEmits(["getList"]);
const props = defineProps(['majorList','levelList','postList'])
const dialogVisible = ref(false)
@@ -302,6 +326,7 @@
        socialAttach: [],
        medicalAttach: [],
        salaryAttach: [],
        idPhoto: '',
        post: '',
        jobTitle: '',
        level: '',
@@ -311,9 +336,11 @@
        password: '',
        confirmPassword: '',
    },
    agencyName:'',
    socialList: [],
    medicalList: [],
    salaryList: [],
    photoList: [],
    formRules:{
        name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
        username: [{ required: true, validator: validateUsername, trigger: 'blur' }],
@@ -328,6 +355,7 @@
        socialAttach: [{required: true, trigger: "blur", message: "请上传社保图片"}],
        medicalAttach: [{required: true, trigger: "blur", message: "请上传医保图片"}],
        salaryAttach: [{required: true, trigger: "blur", message: "请上传工资清单"}],
        idPhoto: [{required: true, trigger: "blur", message: "请上传近期证件照"}],
    },
    areaList: [],
    agencyList: [],
@@ -341,8 +369,16 @@
    pageSize: 10
})
const isAgency = ref(false);
onMounted(()=>{
    getAgency()
    const userInfo = JSON.parse(Cookies.get('userInfo'))
    state.agencyName = userInfo.agentName;
    state.form.agencyId = userInfo.agentId;
    if(userInfo.identity === 1){
      isAgency.value = true;
    }
    console.log("userinfo",userInfo)
})
const openDialog = async (type, value) => {
@@ -373,19 +409,26 @@
                    name: url.name
                }
            });
            const arr = []
            const certificateList = JSON.parse(res.data.certificateNo)
            for( let key in certificateList) {
              arr.push( {
                id: parseInt(key),
                certificateNo: certificateList[key],
              })
              arr.forEach((item,index) => {
                item.label = res.data.majorNames[index]
              })
            const obj = {
              url: import.meta.env.VITE_APP_BASE_API +'/'+ res.data.idPhoto
            }
            state.form.majorShow = arr;
          console.log(state.form.majorShow,'certificateList')
            state.photoList.push(obj);
            if(res.data.certificateNo){
              const arr = []
              const certificateList = JSON.parse(res.data.certificateNo)
              for( let key in certificateList) {
                arr.push( {
                  id: parseInt(key),
                  certificateNo: certificateList[key],
                })
                arr.forEach((item,index) => {
                  item.label = res.data.majorNames[index]
                })
              }
              state.form.majorShow = arr;
              console.log(state.form.majorShow,'certificateList')
            }
        }else{
            ElMessage.warning(res.message)
        }
@@ -447,6 +490,7 @@
                state.salaryList = [];
                state.medicalList = [];
                state.socialList = [];
                state.photoList = [];
                dialogVisible.value = false;
            }else{
                ElMessage.warning(res.message)
@@ -509,6 +553,7 @@
       socialAttach: [],
       medicalAttach: [],
       salaryAttach: [],
       idPhoto: '',
       post: '',
       jobTitle: '',
       level:'',
@@ -521,6 +566,7 @@
    state.salaryList = [];
    state.medicalList = [];
    state.socialList = [];
    state.photoList = [];
    state.form.selectMajorList = [];
}
const picSize = async (rawFile) => {
@@ -571,6 +617,45 @@
    }
}
const handlePhotoSuccess = (res,file) => {
  if(res.code == 200){
    state.form.idPhoto = res.data.path;
  }else{
    ElMessage({
      type: 'warning',
      message: '文件上传失败'
    })
  }
}
const handleChangePic = (file,fileList) => {
  if (fileList.length > 1) {
    state.photoList.splice(0, 1);
  }
}
const handlePhotoRemove = async (file) => {
  console.log("fileD",file)
  let path = ""
  if(file.response && file.response.data){
    path = file.response.data.path
  }else {
    const base = import.meta.env.VITE_APP_BASE_API
    path = file.url.substring(base.length+1,file.url.length )
  }
  const res = await delPic({path: path})
  if(res.code == 200){
    ElMessage({
      type: 'success',
      message: '文件已删除'
    })
    state.form.idPhoto = ''
  }else{
    ElMessage({
      type: 'warning',
      message: res.message
    })
  }
}