From 3258739c06566445a410d3d69db8cd1b34539f4d Mon Sep 17 00:00:00 2001 From: zhangdi <1104545947@qq.com> Date: Thu, 9 Apr 2026 14:11:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=AE=A1=E7=90=86=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/jh-select/index.vue | 55 ++-- src/views/flowManagement/addDialog.vue | 246 ++++++++++++------ src/views/flowManagement/milestoneDialog.vue | 43 ++- .../components/addTestDialog.vue | 1 + 4 files changed, 238 insertions(+), 107 deletions(-) diff --git a/src/components/jh-select/index.vue b/src/components/jh-select/index.vue index 48c358f..d65b7c0 100644 --- a/src/components/jh-select/index.vue +++ b/src/components/jh-select/index.vue @@ -11,7 +11,7 @@ @clear="handleClear" @change="handleChange" class="paged-select" - :teleported="false" + :teleported="true" :popper-options="{ modifiers: [{ name: 'eventListeners', options: { scroll: false, resize: false } }], }" @@ -48,6 +48,10 @@ export default { debounceTime: { type: Number, default: 500 }, echoApi: { type: String, default: '' }, echoMethod: { type: String, default: 'get' }, + echoParamsKey: { + type: String, + default: 'id', // 默认查询字段是 id,可自定义 + }, }, data() { return { @@ -66,6 +70,7 @@ export default { watch: { value(val) { this.localValue = val; + console.log('value', val); this.initEcho(); }, localValue(val) { @@ -182,17 +187,12 @@ export default { // 关键修改:选中后返回完整 item handleChange(val) { - console.log('选中值:', val); - // 从当前列表查找 let selectedItem = this.optionList.find(item => item[this.valueKey] === val); - console.log('从列表找到:', selectedItem); - + // 如果没找到且有回显接口,通过接口获取 if (!selectedItem && this.echoApi) { - console.log('列表未找到,通过接口获取'); this.getEchoData(val).then(item => { - console.log('接口返回:', item); this.$emit('change', val, item); }); } else { @@ -206,16 +206,20 @@ export default { // 新增:通过接口获取完整数据 async getEchoData(val) { try { - const params = { [this.valueKey]: val }; + const params = { [this.echoParamsKey]: val }; let res; if (this.echoMethod.toLowerCase() === 'post') { res = await axios.post(this.echoApi, params); } else { res = await axios.get(this.echoApi, { params }); } - return res.data.data || {}; + + const detail = res.data.data || res.data; + if (!detail) { + return null; + } + return detail; } catch (e) { - console.error('获取选中项详情失败', e); return null; } }, @@ -223,13 +227,30 @@ export default { async initEcho() { const val = this.localValue; if (!val || !this.echoApi) return; - const has = this.optionList.some(item => item[this.valueKey] === val); - if (has) return; - - const info = await this.getEchoData(val); - if (info[this.labelKey] && info[this.valueKey]) { - const exist = this.optionList.some(i => i[this.valueKey] === info[this.valueKey]); - if (!exist) this.optionList.unshift(info); + + // 处理多选(数组) + if (this.multiple && Array.isArray(val)) { + const list = await this.getEchoData(this.multiple); + if (list && list.length) { + this.optionList.unshift(...list); + this.$forceUpdate(); + } + return; + } + + // 原有单选逻辑 + const hasItem = this.optionList.some(item => item[this.valueKey] === val); + if (hasItem) return; + + try { + const info = await this.getEchoData(val); + + if (info.records.length > 0) { + this.optionList = info.records; + this.$forceUpdate(); + } + } catch (e) { + console.error('回显失败', e); } }, diff --git a/src/views/flowManagement/addDialog.vue b/src/views/flowManagement/addDialog.vue index 7f4a602..2e036c5 100644 --- a/src/views/flowManagement/addDialog.vue +++ b/src/views/flowManagement/addDialog.vue @@ -1,6 +1,6 @@ @@ -307,7 +358,6 @@ :width="isDetail ? '120' : ''" > @@ -368,12 +418,6 @@ 附件 - - @@ -390,9 +434,10 @@ import { addProcess, getProcessDetail, getDeplList } from '@/api/flowManagement/index'; import { getRoleUserList } from '@/api/processManagement/taskDispatch'; import { getDictionary } from '@/api/system/dict'; - +import jhSelect from '@/components/jh-select/index.vue'; export default { name: 'AddDialog', + components: { jhSelect }, props: { title: { type: String, @@ -411,7 +456,7 @@ export default { }, data() { return { - loadingShow:false, + loadingShow: false, formError: '', addRules: { projectName: [{ required: true, message: '请填写项目名称', trigger: ['blur', 'submit'] }], @@ -476,6 +521,7 @@ export default { openShow: false, addForm: { stoneList: [], + projectHeadId: null, }, executeResultList: [], // 执行类型 }; @@ -488,7 +534,7 @@ export default { }, mounted() { this.openShow = this.visible; - this.getRoleUserList(); + // this.getRoleUserList(); this.getDictionary(); this.getDeplList(); if (this.title === '详情' || this.title === '修改') { @@ -503,28 +549,50 @@ export default { }, getExecuteTypeText(type) { const item = this.executeResultList.find(item => item.dictKey === type); - console.log('item', item); return item ? item.dictValue : ''; }, - handleStoneListChange(index, row, type) { - if (type === 'milestoneMemo') { - let sel = this.memberList.filter(item => item.id == row.milestoneMemo)[0]; - this.addForm.stoneList[index].milestoneMan = sel.realName; + handleStoneListChange(val, item, index, row) { + if (item) { + // 假设你需要将姓名存到 milestoneMan 字段用于提交或展示 + row.milestoneMan = item.realName; + } else { + // 如果 val 为空,说明是清除操作 + if (!val) { + row.milestoneMan = ''; + } + // 如果 val 有值但 item 为空,说明是远程分页导致的匹配失败 + // 此时 jhSelect 内部应该已经显示了 label (姓名),所以 UI 上用户能看到姓名 + // 如果提交需要 milestoneMan,建议在 submit 时处理,或者接受此时 milestoneMan 为空/旧值 } + // if (type === 'milestoneMemo') { + // let sel = this.memberList.filter(item => item.id == row.milestoneMemo)[0]; + // row.milestoneMan = item.realName; + // } }, - handleChange(type) { - // 制单部门 - if (type == 'touchingDeptId') { - let sel = this.deplList.filter(item => item.id == this.addForm.touchingDeptId)[0]; - this.addForm.touchingDept = sel.deptName; - } - // 项目负责人 - if (type == 'projectHeadId') { - let sel = this.memberList.filter(item => item.id == this.addForm.projectHeadId)[0]; - this.addForm.projectHead = sel.realName; + // 制单部门名称 + deptChange() { + let sel = this.deplList.filter(item => item.id == this.addForm.touchingDeptId)[0]; + this.addForm.touchingDept = sel.deptName; + }, + // 项目负责人 + projectHeadChange(value, item) { + if (item != undefined) { + this.addForm.projectHead = item.realName; } }, + handleChange(value, item) { + // // 制单部门 + // if (type == 'touchingDeptId') { + // let sel = this.deplList.filter(item => item.id == this.addForm.touchingDeptId)[0]; + // this.addForm.touchingDept = sel.deptName; + // } + // // 项目负责人 + // if (type == 'projectHeadId') { + // let sel = this.memberList.filter(item => item.id == this.addForm.projectHeadId)[0]; + // this.addForm.projectHead = sel.realName; + // } + }, // 获取部门列表 getDeplList() { getDeplList().then(res => { @@ -553,22 +621,26 @@ export default { // 获取详情数据 getDetails() { getProcessDetail(this.rowItem.id).then(res => { - console.log(res.data.data, 'res'); - this.addForm = res.data.data; - const records = res.data.data; - this.addForm.stoneList = records.stoneList.map(item => { - item.executeTypeText = this.getExecuteTypeText(item.executeType); - return item; + this.$nextTick(() => { + let data = res.data.data; + Object.assign(this.addForm, data); + + const records = res.data.data; + this.addForm.stoneList = records.stoneList.map(item => { + item.executeTypeText = this.getExecuteTypeText(item.executeType); + return item; + }); + // 安全地处理 memberName 回显 + if (res.data.data.memberName) { + this.addForm.memberName = String(res.data.data.memberName) + .split(',') + .map(id => id.trim()) + .filter(Boolean); + } else { + this.addForm.memberName = []; + } + this.$forceUpdate(); }); - // 安全地处理 memberName 回显 - if (res.data.data.memberName) { - this.addForm.memberName = String(res.data.data.memberName) - .split(',') - .map(id => id.trim()) - .filter(Boolean); - } else { - this.addForm.memberName = []; - } }); }, handleClose(type) { @@ -594,10 +666,10 @@ export default { milestonePlan: '', outputMaterial: '', milestoneNode: '', - milestoneMemo: '', + milestoneMemo: null, evolve: '', lastPlan: '', - grade: -32768, + grade: null, score: 0, executeResult: 0, executeType: '', @@ -658,27 +730,31 @@ export default { }); return; } - this.loadingShow = true + this.loadingShow = true; const submitData = this.formatSubmitData(this.addForm); submitData.projectStartTime = submitData.projectStartTime + ' 00:00:00'; submitData.projectDesiredEnd = submitData.projectDesiredEnd + ' 00:00:00'; if (this.title === '详情') { - updateProcess({ ...submitDat, approvalStatus: 1 }).then(res => { - this.$message.success('修改成功'); - this.handleClose(true); - this.loadingShow = false - }).catch(err=>{ - this.loadingShow = false - }) + updateProcess({ ...submitDat, approvalStatus: 1 }) + .then(res => { + this.$message.success('修改成功'); + this.handleClose(true); + this.loadingShow = false; + }) + .catch(err => { + this.loadingShow = false; + }); return; } else { - addProcess({ ...submitData, approvalStatus: 1 }).then(res => { - this.$message.success('提交成功'); - this.handleClose(true); - this.loadingShow = false - }).catch(err=>{ - this.loadingShow = false - }) + addProcess({ ...submitData, approvalStatus: 1 }) + .then(res => { + this.$message.success('提交成功'); + this.handleClose(true); + this.loadingShow = false; + }) + .catch(err => { + this.loadingShow = false; + }); } }); }, @@ -715,7 +791,7 @@ export default { font-size: 14px; line-height: 1.5; } -:deep(.el-table .el-table__cell) { +:deep(.el-table .el-table__body .el-table__cell) { height: 50px !important; padding: 0 !important; line-height: 50px !important; diff --git a/src/views/flowManagement/milestoneDialog.vue b/src/views/flowManagement/milestoneDialog.vue index c5ed603..2460c59 100644 --- a/src/views/flowManagement/milestoneDialog.vue +++ b/src/views/flowManagement/milestoneDialog.vue @@ -131,13 +131,29 @@ - + + @@ -150,13 +166,29 @@ - + +
@@ -201,8 +233,9 @@ import { getRoleUserList } from '@/api/processManagement/taskDispatch'; import { projectExecute, projectCheck, projectApprove } from '@/api/flowManagement/index'; import { getDictionary } from '@/api/system/dict'; - +import jhSelect from '@/components/jh-select/index.vue'; export default { + components: { jhSelect }, props: { showDialog: { type: Boolean, diff --git a/src/views/processManagement/components/addTestDialog.vue b/src/views/processManagement/components/addTestDialog.vue index bb3d4ef..ff55732 100644 --- a/src/views/processManagement/components/addTestDialog.vue +++ b/src/views/processManagement/components/addTestDialog.vue @@ -85,6 +85,7 @@ import { getPartList, getVersion, saveTask } from '@/api/processManagement/taskProcessing'; import { getRoleUserList } from '@/api/processManagement/taskDispatch'; import jhSelect from '@/components/jh-select/index.vue'; + export default { props: { showDialog: {