From 048a1d039d347cf109e053961865f7b01d721643 Mon Sep 17 00:00:00 2001 From: zhouwx <1175765986@qq.com> Date: 星期三, 27 八月 2025 16:36:27 +0800 Subject: [PATCH] 修改 --- src/views/safetyReview/projectManage/components/chooseExpert.vue | 224 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 183 insertions(+), 41 deletions(-) diff --git a/src/views/safetyReview/projectManage/components/chooseExpert.vue b/src/views/safetyReview/projectManage/components/chooseExpert.vue index 6620012..0e8a5e9 100644 --- a/src/views/safetyReview/projectManage/components/chooseExpert.vue +++ b/src/views/safetyReview/projectManage/components/chooseExpert.vue @@ -8,7 +8,7 @@ v-model.trim="queryParams.num" placeholder="请输入专家总人数" style="width: 150px;" - @input="queryParams.num = queryParams.num.replace(/[^1-9]/g,'')" + @input="queryParams.num = queryParams.num.replace(/[^0-9]/g,'')" :disabled="!state.isAble || state.newProgress >=3 " > @@ -20,7 +20,10 @@ <el-icon style="margin-left: 10px;margin-right: 4px;margin-top: 2px;color: #FE8E8A"><InfoFilled /></el-icon> <span style="font-size: 14px;color: #FE8E8A">仅专家组组长允许固定选取,仅允许固定选取1人</span> </div> - <el-button type="primary" :disabled="state.info.step == 4 || state.isAdmin" style="width: 120px;margin-bottom: 10px" @click="chooseExpert('选取专家')">选取专家组组长</el-button> + <div> + <el-button type="primary" :disabled="state.info.step == 4 || state.isAdmin" style="width: 120px;margin-bottom: 10px" @click="chooseExpert('选取专家')">选取专家组组长</el-button> + <el-button type="primary" :disabled="state.info.step == 4 || state.isAdmin" style="width: 120px;margin-bottom: 10px" @click="addOutExpertLeader">填报库外专家</el-button> + </div> </div> <el-table v-loading="fLoading" :data="fixedDataList" :border="true" ref="fTableRef" style="width: 100%;"> <el-table-column label="姓名" prop="name" align="center" /> @@ -47,7 +50,7 @@ <div style="display: flex;align-items: center"> <span style="font-weight: 600">随机选用部分</span> <el-icon style="margin-left: 10px;margin-right: 4px;margin-top: 2px;color: #FE8E8A"><InfoFilled /></el-icon> - <span style="font-size: 14px;color: #FE8E8A">随机人数为 {{queryParams.num-1}} 的5倍,可根据实际情况删除至 {{queryParams.num-1}} 人</span> + <span style="font-size: 14px;color: #FE8E8A">随机人数为 {{queryParams.num-1}} 的5倍,可根据实际情况选取{{queryParams.num-1}} 人</span> </div> <el-form :model="queryParams" ref="queryForm" :inline="true" style="margin-top: 10px" label-width="90px"> <el-row :gutter="24"> @@ -76,9 +79,12 @@ </el-col> <el-col :span="8"> - <el-form-item style="float: right;" v-if=" state.newProgress < 3 && state.isAble && Number(queryParams.num) !=1 && queryParams.num!=''"> - <el-button style="width: 100px;margin-right: -32px;" :disabled="state.info.step == 4 || state.isAdmin" type="primary" @click="random">随机抽取</el-button> - </el-form-item> + <div style="display: flex;align-items: center;justify-content: flex-end"> + <div style="float: right;" v-if=" state.newProgress < 3 && state.isAble && Number(queryParams.num) !=1 && queryParams.num!=''"> + <el-button style="width: 100px;margin-bottom: 20px;margin-right: 10px" :disabled="state.info.step == 4 || state.isAdmin" type="primary" @click="random">随机抽取</el-button> + </div> + <el-button type="primary" :disabled="state.info.step == 4 || state.isAdmin" style="width: 120px;margin-bottom: 20px" @click="addOutExpertLists">填报库外专家</el-button> + </div> </el-col> </el-row> <div style="display: flex;align-items: center;justify-content: flex-end;margin-top: -15px;margin-bottom: 10px" v-if="state.newProgress < 3"> @@ -99,7 +105,8 @@ <!-- </el-col>--> <!-- </el-row>--> </el-form> - <el-table v-loading="rLoading" :data="randomDataList" :border="true" ref="rTableRef" style="width: 100%;"> + <el-table v-loading="rLoading" :data="randomDataList" :border="true" ref="rTableRef" style="width: 100%;" @selection-change="handleSelectionChange"> + <el-table-column type="selection" width="55" /> <el-table-column label="姓名" prop="name" align="center" /> <el-table-column label="性别" prop="sex" align="center" > <template #default="scope"> @@ -113,14 +120,15 @@ </template> </el-table-column> <el-table-column label="专业领域" prop="domain" align="center" /> - <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" width="180"> - <template #default="scope"> - <el-button link type="primary" @click="delR(scope.row)" :disabled="state.info.step == 4 || state.isAdmin">删除</el-button> - </template> - </el-table-column> +<!-- <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" width="180">--> +<!-- <template #default="scope">--> +<!-- <el-button link type="primary" @click="delR(scope.row)" :disabled="state.info.step == 4 || state.isAdmin">删除</el-button>--> +<!-- </template>--> +<!-- </el-table-column>--> </el-table> </div> <experts-list ref="expertsListRef" @getName="getSelected"></experts-list> + <out-expert ref="outRef" @getList="getOutItem"></out-expert> </div> </template> @@ -131,9 +139,11 @@ import {ElMessage} from "element-plus"; import {addProject, choose, expertRound, getCheckInfo, getProjectInfo} from "@/api/projectManage"; import Cookies from "js-cookie"; +import outExpert from './addOutExpertDialog.vue' const emit = defineEmits(["getNextStatus"]); const fTableRef = ref(null); +const outRef = ref(null); const expertsListRef = ref(null) const fLoading = ref(false); const rLoading = ref(false); @@ -155,7 +165,9 @@ id:null, step: 2, saveData: [], - delData: [] + delData: [], + saveOutData: [], + delOutData: [] }, info: {}, levelList: [ @@ -178,7 +190,7 @@ randomNum:0, isAble: true }) - +const choosedRandomList = ref([]) const userInfo = ref() onMounted(async () =>{ // localStorage.removeItem('numData') @@ -196,6 +208,12 @@ fixDataArr.forEach(item => { if(item.projectId == state.projectId){ fixedDataList.value = [item.fixedData] + const uniqueItem = fixedDataList.value.find(itemA => + !itemA.id && !state.formData.saveOutData.some(itemB => itemB.name === itemA.name) + ); + if(uniqueItem){ + state.formData.saveOutData.push(uniqueItem) + } } }) } @@ -206,7 +224,12 @@ rondomDataArr.forEach(item => { if(item.projectId == state.projectId){ randomDataList.value = item.rondomData - + const uniqueItem = randomDataList.value.find(itemA => + !itemA.id && !state.formData.saveOutData.some(itemB => itemB.name === itemA.name) + ); + if(uniqueItem){ + state.formData.saveOutData.push(uniqueItem) + } } }) } @@ -255,6 +278,7 @@ fixedData: newVal[0] } if(state.newProgress < 2){ + saveObjectToLocalStorage('fixedDataList',data) } } @@ -304,8 +328,10 @@ localStorage.setItem(key, JSON.stringify(dataArray)); } - +const typeNow = ref('') +const firstRandomList = ref([]) const riskOpen = async (type,val) => { + typeNow.value = type console.log("type",type,val) state.projectId = val await getProjectProcess() @@ -323,13 +349,17 @@ // return; // } } + + //保存按钮 if(type === 'add'){ + // choosedRandomList.value = randomDataList.value let fData = [] let rData = [] //成功后自动到下一步 项目id const {...data} = state.formData data.id = val + if(fixedDataList.value && fixedDataList.value.length > 0){ fData = fixedDataList.value.map(item => { return { @@ -341,14 +371,16 @@ }) } - - - if(randomDataList.value && randomDataList.value.length > Number(queryParams.num) - 1){ - ElMessage.warning(`仅可保留${Number(queryParams.num) - 1}名随机专家`); + if(choosedRandomList.value && choosedRandomList.value.length > Number(queryParams.num) - 1){ + ElMessage.warning(`仅可选取${Number(queryParams.num) - 1}名随机专家`); return } - if(randomDataList.value && randomDataList.value.length > 0){ - rData = randomDataList.value.map(item => { + if(choosedRandomList.value.length < Number(queryParams.num) - 1){ + ElMessage.warning(`随机专家数不能低于${Number(queryParams.num) - 1}人`) + return + } + if(choosedRandomList.value && choosedRandomList.value.length > 0){ + rData = choosedRandomList.value.map(item => { return { expertId: item.id, expertName:item.name, @@ -357,7 +389,26 @@ } }) } + fData = fData.filter(i => i.expertId) + rData = rData.filter(i => i.expertId) + const chooseIds = choosedRandomList.value.map(i => i.id) + const x = randomDataList.value.filter(i => !chooseIds.includes(i.id)) + x.forEach(i => { + if(i.expertType == 1 && i.expertId){ + data.delData.push(i.id) + }else if(i.expertType == 2 ){ + if( i.id){ + data.delOutData.push(i.id) + data.saveOutData = data.saveOutData.filter(f => f.id != i.id) + }else { + data.saveOutData = data.saveOutData.filter(f => f != i) + } + } + }) data.saveData = fData.concat(rData) + data.saveOutData.forEach(item => { + item.projectId = state.projectId + }) const res = await choose(data); if(res.code == 200){ @@ -369,28 +420,36 @@ ElMessage.warning(res.message) } }else if(type === 'clickEdit'){ + // choosedRandomList.value = randomDataList.value let fData = [] let rData = [] const {...data} = state.formData data.id = val + if(fixedDataList.value && fixedDataList.value.length > 0){ fData = fixedDataList.value.map(item => { return { + ...item, id: item.expertId ? item.id : '', expertId: item.expertId ? item.expertId : item.id, expertName:item.name, selectionMode: 1, - teamLeader: 1 + teamLeader: 1, } }) } - if(randomDataList.value && randomDataList.value.length > Number(queryParams.num) - 1){ - ElMessage.warning(`仅可保留${Number(queryParams.num) - 1}名随机专家`); + if(choosedRandomList.value && choosedRandomList.value.length > Number(queryParams.num) - 1){ + ElMessage.warning(`仅可选取${Number(queryParams.num) - 1}名随机专家`); return } - if(randomDataList.value && randomDataList.value.length > 0){ - rData = randomDataList.value.map(item => { + if(choosedRandomList.value.length < Number(queryParams.num) - 1){ + ElMessage.warning(`随机专家数不能低于${Number(queryParams.num) - 1}人`) + return + } + if(choosedRandomList.value && choosedRandomList.value.length > 0){ + rData = choosedRandomList.value.map(item => { return { + ...item, id: item.expertId ? item.id : '', expertId: item.expertId ? item.expertId : item.id, expertName:item.name, @@ -399,7 +458,30 @@ } }) } + fData = fData.filter(i => i.expertType == 1) + rData = rData.filter(i => i.expertType == 1) + console.log('randon',randomDataList.value) + console.log('choodse',choosedRandomList.value) + const chooseIds = choosedRandomList.value.map(i => i.id) + const x = randomDataList.value.filter(i => !chooseIds.includes(i.id)) + x.forEach(i => { + if(i.expertType == 1 && i.expertId){ + data.delData.push(i.id) + }else if(i.expertType == 2 ){ + if( i.id){ + data.delOutData.push(i.id) + data.saveOutData = data.saveOutData.filter(f => f.id != i.id) + }else { + data.saveOutData = data.saveOutData.filter(f => f != i) + } + } + }) + data.saveData = fData.concat(rData) + data.saveOutData.forEach(item => { + item.projectId = state.projectId + }) + const res = await choose(data); if(res.code == 200){ ElMessage.success('修改成功') @@ -415,7 +497,11 @@ if(res.code == 200){ fixedDataList.value = res.data.projectExpertCheckResp.filter(item => item.selectionMode === 1) randomDataList.value = res.data.projectExpertCheckResp.filter(item => item.selectionMode === 2) + firstRandomList.value = res.data.projectExpertCheckResp.filter(item => item.selectionMode === 2) + const fdata = fixedDataList.value.filter(i => i.expertType == 2) + const rdata = randomDataList.value.filter(i => i.expertType == 2) state.info = res.data + state.formData.saveOutData = fdata.concat(rdata) console.log('res',fixedDataList.value) queryParams.num = res.data.expertNum removeLocal() @@ -426,10 +512,10 @@ } const chooseExpert = (type) => { - // if(fixedDataList.value && fixedDataList.value.length >0){ - // ElMessage.warning('只能选择一个组长') - // return - // } + if(fixedDataList.value && fixedDataList.value.length >0){ + ElMessage.warning('仅允许选择1位组长') + return + } expertsListRef.value.openDialog(type,fixedDataList.value,domainList.value) } @@ -494,8 +580,13 @@ // } // localStorage.setItem('randomNum', JSON.stringify(rnDataArray)); } +const handleSelectionChange = (val) => { + choosedRandomList.value = val +} const getSelected = (type,data)=>{ + data[0].expertType = 1 + const selectData = JSON.parse(JSON.stringify(data)) // if(fixedDataList.value && fixedDataList.value.length > 0){ // fixedDataList.value.forEach(item => { @@ -511,13 +602,22 @@ if(fixedDataList.value && fixedDataList.value.length >0){ state.formData.delData.push(fixedDataList.value[0].id) } - fixedDataList.value = selectData } const delF = (val) => { - if(val.expertId){ - state.formData.delData.push(val.id) + //库外 + if(val.expertType == 2){ + if(val.expertId){ + state.formData.delOutData.push(val.id) + } + state.formData.saveOutData = state.formData.saveOutData.filter(i => i.idCard != val.idCard) + }else{ + //库内 + if(val.expertId){ + state.formData.delData.push(val.id) + } } + fixedDataList.value = fixedDataList.value.filter(item => item.id != val.id) } @@ -548,12 +648,12 @@ } const random = async () => { - console.log('11',randomDataList.value) - randomDataList.value.forEach(item => { - if(item.expertId){ - state.formData.delData.push(item.id) - } - }) + console.log('first',firstRandomList.value) + firstRandomList.value.forEach(item => { + if(item.expertId && item.expertType == 1){ + state.formData.delData.push(item.id) + } + }) if(fixedDataList.value && fixedDataList.value.length <= 0){ ElMessage.warning('请先选择专家组组长') return @@ -575,7 +675,19 @@ } const res = await expertRound(param) if(res.code == 200){ - randomDataList.value = res.data + randomDataList.value = [] + res.data = res.data.map(item => { + return{ + ...item, + expertType: 1 + } + }) + const outLists = state.formData.saveOutData.filter(i => i.teamLeader == 0) + if(outLists && outLists.length >0){ + randomDataList.value = outLists.concat(res.data) + }else { + randomDataList.value = res.data + } state.randomNum = state.randomNum + 1 const obj = { projectId: state.projectId, @@ -590,6 +702,36 @@ } rLoading.value = false } +const addOutExpertLeader = () => { + if(fixedDataList.value.length>0){ + ElMessage.warning('仅允许选取1名专家组长') + return; + } + outRef.value.openDialog('leader') +} +const addOutExpertLists = () => { + outRef.value.openDialog('') +} + +const getOutItem = (val) => { + console.log('val',val) + val.expertType = 2 + if(val.teamLeader == 1){ + fixedDataList.value.push(val) + const data = { + projectId :state.projectId, + fixedData: val + } + if(state.newProgress < 2){ + saveObjectToLocalStorage('fixedDataList',data) + } + }else { + // choosedRandomList.value.push(val) + randomDataList.value.push(val) + } + state.formData.saveOutData.push(val) + +} defineExpose({ riskOpen -- Gitblit v1.9.2