检测计划列表编辑

This commit is contained in:
sjl
2025-07-29 18:35:46 +08:00
parent 6e22c01dd8
commit 0079f7415e
3 changed files with 56 additions and 26 deletions

View File

@@ -31,8 +31,6 @@
</el-form-item> </el-form-item>
<el-divider >参数信息</el-divider> <el-divider >参数信息</el-divider>
<el-form-item label='通讯协议' prop='protocol'> <el-form-item label='通讯协议' prop='protocol'>
<el-select v-model="formContent.protocol" clearable placeholder="请选择通讯协议"> <el-select v-model="formContent.protocol" clearable placeholder="请选择通讯协议">
<el-option <el-option
@@ -40,7 +38,6 @@
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="item.id" :value="item.id"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@@ -212,6 +209,8 @@ const pqChannelArray = ref([
formContent.devKey = null formContent.devKey = null
} }
// 可检通道转为字符串逗号分隔(保存前临时转换)
let originalInspectChannel = formContent.inspectChannel; // 保存原始值
//可检通道转为字符串逗号分隔 //可检通道转为字符串逗号分隔
// 确保 inspectChannel 是数组再执行 join // 确保 inspectChannel 是数组再执行 join
if (Array.isArray(formContent.inspectChannel)) { if (Array.isArray(formContent.inspectChannel)) {
@@ -222,11 +221,11 @@ const pqChannelArray = ref([
.join(','); .join(',');
} }
try {
if (formContent.id) { if (formContent.id) {
await updatePqStandardDev(formContent); await updatePqStandardDev(formContent);
ElMessage.success({ message: `${dialogTitle.value}成功!` }) ElMessage.success({ message: `${dialogTitle.value}成功!` })
} else { } else {
// 新增需要把通讯协议转成字典ID // 新增需要把通讯协议转成字典ID
const protocolItem = dictStore.getDictData('Protocol').find(item => item.name === formContent.protocol); const protocolItem = dictStore.getDictData('Protocol').find(item => item.name === formContent.protocol);
if (protocolItem) { if (protocolItem) {
@@ -239,6 +238,16 @@ const pqChannelArray = ref([
close() close()
// 刷新表格 // 刷新表格
await props.refreshTable!() await props.refreshTable!()
} catch (error) {
// 如果保存失败,恢复原始的 inspectChannel 值
formContent.inspectChannel = originalInspectChannel;
throw error;
}
} else {
// 验证失败也需要恢复原始 inspectChannel 格式(如果之前被转换过)
if (typeof formContent.inspectChannel === 'string' && formContent.inspectChannel.includes(',')) {
formContent.inspectChannel = formContent.inspectChannel.split(',').filter(Boolean);
}
} }
}) })
@@ -270,6 +279,7 @@ const open = async (sign: string, data: StandardDevice.ResPqStandardDevice,devTy
const handleDevTypeChange = (value: string) => { const handleDevTypeChange = (value: string) => {
console.log('handleDevTypeChange', value)
// 在这里处理选中事件的逻辑 // 在这里处理选中事件的逻辑
const dev = devTypeOptions.value.find(t =>t.id === value) const dev = devTypeOptions.value.find(t =>t.id === value)
if (dev) { if (dev) {
@@ -282,8 +292,6 @@ const handleDevTypeChange = (value: string) => {
//if(titleType.value == 'add') // 默认全选所有通道 //if(titleType.value == 'add') // 默认全选所有通道
formContent.inspectChannel = pqChannelArray.value.map(channel => channel.value) formContent.inspectChannel = pqChannelArray.value.map(channel => channel.value)
// 过滤掉超出新通道数范围的选项 // 过滤掉超出新通道数范围的选项
if (Array.isArray(formContent.inspectChannel)) { if (Array.isArray(formContent.inspectChannel)) {
formContent.inspectChannel = formContent.inspectChannel.filter( formContent.inspectChannel = formContent.inspectChannel.filter(

View File

@@ -383,6 +383,11 @@ const open = async (textTitle: string,data: Plan.ReqPlan,pattern: string) => {
proTable.value?.getTableList() proTable.value?.getTableList()
isTabPlanFather.value = false//子计划页面按钮默认展示主计划的 isTabPlanFather.value = false//子计划页面按钮默认展示主计划的
patternId.value = pattern patternId.value = pattern
columns.forEach(item => {//刚进去子计划页面隐藏主计划的操作列
if (item.prop === 'operation') {
item.isShow = false;
}
});
console.log('弹窗打开方法',planFormContent.value) console.log('弹窗打开方法',planFormContent.value)
} }
@@ -393,6 +398,9 @@ const handleTabClick = (tab:any) => {
if (item.prop === 'boundPlanName') { if (item.prop === 'boundPlanName') {
item.isShow = false; item.isShow = false;
} }
if (item.prop === 'operation') {
item.isShow = true;
}
}); });
isTabPlanFather.value = true isTabPlanFather.value = true
}else{ }else{
@@ -400,6 +408,9 @@ const handleTabClick = (tab:any) => {
if (item.prop === 'boundPlanName') { if (item.prop === 'boundPlanName') {
item.isShow = true; item.isShow = true;
} }
if (item.prop === 'operation') {
item.isShow = false;
}
}); });
isTabPlanFather.value = false isTabPlanFather.value = false
} }

View File

@@ -487,17 +487,28 @@ const exportClick = () => {
// 打开 drawer(新增、编辑) // 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<Plan.ReqPlan> = {}) => { const openDialog = (titleType: string, row: Partial<Plan.ReqPlan> = {}) => {
if(modeStore.currentMode == '比对式'){ let planType = 0; // 0主计划 1子计划 2修改子计划
if(row.children?.length > 0){
planPopup.value?.open(titleType, row,modeStore.currentMode,0)//0主计划 1子计划 2修改子计划 if (modeStore.currentMode === '比对式') {
}else{ if (titleType === 'add') {
planPopup.value?.open(titleType, row,modeStore.currentMode,2)//0主计划 1子计划 2修改子计划 // 新增只能是主计划
planType = 0;
} else {
// 编辑情况
if (row.children?.length > 0) {
// 有子计划 -> 主计划
planType = 0;
} else if (row.origin == null) {
// 没有来源 -> 主计划
planType = 0;
} else {
// 其他 -> 修改子计划
planType = 2;
}
} }
}else{
planPopup.value?.open(titleType, row,modeStore.currentMode,0)//0主计划 1子计划 2修改子计划
} }
planPopup.value?.open(titleType, row, modeStore.currentMode, planType);
} }