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 | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 156 insertions(+), 23 deletions(-) diff --git a/src/views/safetyReview/projectManage/components/chooseExpert.vue b/src/views/safetyReview/projectManage/components/chooseExpert.vue index 2b8af6e..0e8a5e9 100644 --- a/src/views/safetyReview/projectManage/components/chooseExpert.vue +++ b/src/views/safetyReview/projectManage/components/chooseExpert.vue @@ -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" /> @@ -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"> @@ -122,6 +128,7 @@ </el-table> </div> <experts-list ref="expertsListRef" @getName="getSelected"></experts-list> + <out-expert ref="outRef" @getList="getOutItem"></out-expert> </div> </template> @@ -132,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); @@ -156,7 +165,9 @@ id:null, step: 2, saveData: [], - delData: [] + delData: [], + saveOutData: [], + delOutData: [] }, info: {}, levelList: [ @@ -197,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) + } } }) } @@ -207,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) + } } }) } @@ -256,6 +278,7 @@ fixedData: newVal[0] } if(state.newProgress < 2){ + saveObjectToLocalStorage('fixedDataList',data) } } @@ -305,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() @@ -324,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 { @@ -360,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){ @@ -372,18 +420,21 @@ 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, } }) } @@ -398,14 +449,39 @@ if(choosedRandomList.value && choosedRandomList.value.length > 0){ rData = choosedRandomList.value.map(item => { return { - expertId: item.id, + ...item, + id: item.expertId ? item.id : '', + expertId: item.expertId ? item.expertId : item.id, expertName:item.name, selectionMode: 2, teamLeader: 0 } }) } + 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('修改成功') @@ -421,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() @@ -432,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) } @@ -505,6 +585,8 @@ } 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 => { @@ -520,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) } @@ -557,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 @@ -584,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, @@ -599,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