From 95d963192f01502227ac59d0a3c7b91c6dd78bbf Mon Sep 17 00:00:00 2001 From: huliang <1539398430@qq.com> Date: Mon, 24 Nov 2025 15:42:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=B7=A1=E6=AA=A2?= =?UTF-8?q?=E4=BB=BB=E5=8B=99=E8=88=87=E8=A8=AD=E5=AE=9A=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=9F=A5=E8=AD=89=E5=8A=9F=E8=83=BD=E8=88=87=E9=81=B8?= =?UTF-8?q?=E9=A0=85=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components.d.ts | 1 - .../PatrolMission/FillTaskDialog.vue | 116 ++++++++------- src/components/PatrolMission/PendingTasks.vue | 70 ++++++++- .../PatrolSetting/AddTemplateDialog.vue | 69 ++------- .../PatrolSetting/TemplateManager.vue | 2 - .../VerificationOptionDialog.vue | 72 ++++++++++ .../VerificationSettingDialog.vue | 134 +++++++++++++++++- src/constants/templateSchemas.js | 121 +++++----------- 8 files changed, 379 insertions(+), 206 deletions(-) create mode 100644 src/components/PatrolSetting/VerificationOptionDialog.vue diff --git a/src/components.d.ts b/src/components.d.ts index 62bf65d..2b768aa 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -26,7 +26,6 @@ declare module 'vue' { ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] - ElEmpty: typeof import('element-plus/es')['ElEmpty'] ElForm: typeof import('element-plus/es')['ElForm'] ElFormItem: typeof import('element-plus/es')['ElFormItem'] ElHeader: typeof import('element-plus/es')['ElHeader'] diff --git a/src/components/PatrolMission/FillTaskDialog.vue b/src/components/PatrolMission/FillTaskDialog.vue index c49bdf5..75ce093 100644 --- a/src/components/PatrolMission/FillTaskDialog.vue +++ b/src/components/PatrolMission/FillTaskDialog.vue @@ -56,8 +56,9 @@ {{ table.title }}

{{ table.title }}

+ + + + + + + - - - @@ -248,7 +252,6 @@ const activeSchema = computed(() => { ...schema, sections: schema.sections?.filter(s => s.showInFill !== false) || [], tables: schema.tables?.filter(t => t.showInFill !== false) || [], - verification: schema.verification, // 查證始終顯示 }; }); @@ -257,6 +260,14 @@ const dialogTitle = computed(() => { return props.taskData?.taskName || "填寫任務"; }); +// 查證欄位配置 (從樣板的 verification 表格資料中獲取) +const verificationFields = computed(() => { + if (!props.taskData || !props.taskData.tables || !props.taskData.tables.verification) { + return []; + } + return props.taskData.tables.verification || []; +}); + // 判斷是否為可輸入的數值欄位 (非系統、設備、項目、單位欄位) const isValueColumn = (prop) => { const infoColumns = ['index', 'system1', 'system2', 'deviceId', 'item', 'unit']; @@ -282,10 +293,17 @@ watch( // 如果任務已有填寫資料,載入已填寫的資料 if (newTaskData.fillData) { Object.assign(dynamicFields, newTaskData.fillData.fields || {}); - Object.assign(dynamicTableData, newTaskData.fillData.tables || initializeTableData(schema)); + Object.assign(dynamicTableData, newTaskData.fillData.tables || {}); } else { - // 否則初始化空白表格 - Object.assign(dynamicTableData, initializeTableData(schema)); + // 從樣板配置中載入巡檢表和其他表格資料 + // 優先使用 taskData.tables (從 API 返回的樣板配置) + if (newTaskData.tables) { + // 直接使用從後端獲取的表格資料 + Object.assign(dynamicTableData, JSON.parse(JSON.stringify(newTaskData.tables))); + } else { + // 如果沒有則使用 schema 的預設資料 (通常不會執行到這裡) + Object.assign(dynamicTableData, initializeTableData(schema)); + } } }, { immediate: true } diff --git a/src/components/PatrolMission/PendingTasks.vue b/src/components/PatrolMission/PendingTasks.vue index 526db47..7cbdb53 100644 --- a/src/components/PatrolMission/PendingTasks.vue +++ b/src/components/PatrolMission/PendingTasks.vue @@ -128,7 +128,7 @@ const pageSize = ref(10); // 篩選條件 const filterFactory = ref(""); const filterCategory = ref(""); -// table 資料 +// table 資料 (模擬從 API 獲取的完整樣板配置) const allTableData = ref([ { index: 1, @@ -137,6 +137,43 @@ const allTableData = ref([ templateType: "1", // 對應 templateSchemas 的 key taskName: "四磺子坪1.2MW地熱能ORC發電機", dispatchDate: "2025-11-01", + // 從後端 API 返回的樣板配置 + tables: { + inspection: [ + { + index: 1, + system1: "熱源系統", + system2: "#2生產井", + deviceId: "TE_1004", + item: "#2地熱井溫度", + unit: "°C", + lowerLimit: 80, + upperLimit: 120, + dcsValue: 100, + }, + { + index: 2, + system1: "熱源系統", + system2: "#2生產井", + deviceId: "TG_1004", + item: "#2地熱井溫度表", + unit: "°C", + lowerLimit: 80, + upperLimit: 120, + dcsValue: 98, + }, + // 更多巡檢項目... + ], + verification: [ + { index: 1, fieldName: "現場", type: "數值輸入" }, + { + index: 2, + fieldName: "比對結果", + type: "單一選擇", + options: ["符合", "不符合"], + }, + ], + }, }, { index: 2, @@ -145,6 +182,30 @@ const allTableData = ref([ templateType: "1", taskName: "四磺子坪1.2MW先導地熱能ORC發電機", dispatchDate: "2025-11-01", + tables: { + inspection: [ + { + index: 1, + system1: "熱源系統", + system2: "#3生產井", + deviceId: "TE_1005", + item: "#3地熱井溫度", + unit: "°C", + lowerLimit: 80, + upperLimit: 120, + dcsValue: 98, + }, + ], + verification: [ + { index: 1, fieldName: "現場", type: "數值輸入" }, + { + index: 2, + fieldName: "比對結果", + type: "單一選擇", + options: ["符合", "不符合"], + }, + ], + }, }, { index: 3, @@ -153,6 +214,11 @@ const allTableData = ref([ templateType: "2", taskName: "廠房01維修工程", dispatchDate: "2025-11-02", + tables: { + checkItems: [ + // 點檢項目... + ], + }, }, ]); @@ -188,6 +254,8 @@ const currentTask = ref(null); // 打開填寫對話框 const handleFillTask = (task) => { + console.log("task", task); + currentTask.value = task; fillDialogVisible.value = true; }; diff --git a/src/components/PatrolSetting/AddTemplateDialog.vue b/src/components/PatrolSetting/AddTemplateDialog.vue index 279c5da..c7fa0ea 100644 --- a/src/components/PatrolSetting/AddTemplateDialog.vue +++ b/src/components/PatrolSetting/AddTemplateDialog.vue @@ -47,14 +47,6 @@ - - - - - - - - - - - + + + + + +
@@ -191,49 +182,6 @@ - - - + - + + diff --git a/src/constants/templateSchemas.js b/src/constants/templateSchemas.js index b920d35..35172bf 100644 --- a/src/constants/templateSchemas.js +++ b/src/constants/templateSchemas.js @@ -16,6 +16,7 @@ export const templateSchemas = { { key: "shift", label: "班別", span: 12 }, { key: "weather", label: "天氣", span: 12 }, { key: "temperature", label: "環境溫度/濕度", span: 12 }, + { key: "remark", label: "備註", type: "textarea", span: 24 }, ], }, ], @@ -58,6 +59,9 @@ export const templateSchemas = { usePagination: true, showInTemplate: true, // 新增樣板時顯示 showInFill: true, // 填寫任務時顯示 + allowAdd: false, // 填寫時不顯示新增按鈕 + allowEdit: false, // 填寫時不顯示編輯按鈕 + useVerification: true, // 使用查證欄位 columns: [ { prop: "index", label: "項次", width: "60" }, { prop: "system1", label: "系統1" }, @@ -65,6 +69,9 @@ export const templateSchemas = { { prop: "deviceId", label: "設備編號" }, { prop: "item", label: "項目" }, { prop: "unit", label: "單位" }, + { prop: "lowerLimit", label: "下限" }, + { prop: "upperLimit", label: "上限" }, + { prop: "dcsValue", label: "DCS" }, ], defaultData: [ { @@ -189,20 +196,33 @@ export const templateSchemas = { }, ], }, + { + key: "verification", + title: "查證", + addButtonText: "新增查證項目", + dialogType: "verification", + usePagination: true, + showInTemplate: true, // 新增樣板時顯示 + showInFill: false, // 填寫任務時顯示 + columns: [ + { prop: "index", label: "項次", width: "60" }, + { prop: "fieldName", label: "欄位名稱" }, + { prop: "type", label: "類型" }, + ], + defaultData: [ + { + index: 1, + fieldName: "現場", + label: "數值輸入", + }, + { + index: 2, + fieldName: "比對結果", + label: "單一選擇", + }, + ], + }, ], - verification: { - enabled: true, - showInTemplate: true, // 新增樣板時顯示 - showInFill: false, // 填寫任務時不顯示 - title: "查證", - addButtonText: "新增查證設定", - dialogType: "verification", - columns: [ - { prop: "index", label: "項次", width: "60" }, - { prop: "fieldName", label: "欄位名稱" }, - { prop: "type", label: "類型" }, - ], - }, }, 2: { sections: [ @@ -226,7 +246,7 @@ export const templateSchemas = { showInTemplate: true, // 新增樣板時顯示 showInFill: true, // 填寫任務時顯示 columns: [ - { prop: "index", label: "設備"}, + { prop: "index", label: "設備" }, { prop: "item", label: "項目" }, { prop: "content", label: "內容" }, { prop: "resultMorning", label: "檢查結果 (早)" }, @@ -237,17 +257,6 @@ export const templateSchemas = { ], }, ], - verification: { - enabled: true, - title: "查證", - addButtonText: "新增查證設定", - dialogType: "verification", - columns: [ - { prop: "index", label: "項次", width: "60" }, - { prop: "fieldName", label: "欄位名稱" }, - { prop: "type", label: "類型" }, - ], - }, }, 3: { sections: [ @@ -298,17 +307,6 @@ export const templateSchemas = { ], }, ], - verification: { - enabled: true, - title: "查證", - addButtonText: "新增查證設定", - dialogType: "verification", - columns: [ - { prop: "index", label: "項次", width: "60" }, - { prop: "fieldName", label: "欄位名稱" }, - { prop: "type", label: "類型" }, - ], - }, }, 4: { sections: [ @@ -344,17 +342,6 @@ export const templateSchemas = { ], }, ], - verification: { - enabled: true, - title: "查證", - addButtonText: "新增查證設定", - dialogType: "verification", - columns: [ - { prop: "index", label: "項次", width: "60" }, - { prop: "fieldName", label: "欄位名稱" }, - { prop: "type", label: "類型" }, - ], - }, }, 5: { sections: [ @@ -402,17 +389,6 @@ export const templateSchemas = { ], }, ], - verification: { - enabled: true, - title: "查證", - addButtonText: "新增查證設定", - dialogType: "verification", - columns: [ - { prop: "index", label: "項次", width: "60" }, - { prop: "fieldName", label: "欄位名稱" }, - { prop: "type", label: "類型" }, - ], - }, }, 6: { sections: [ @@ -471,17 +447,6 @@ export const templateSchemas = { ], }, ], - verification: { - enabled: true, - title: "查證", - addButtonText: "新增查證設定", - dialogType: "verification", - columns: [ - { prop: "index", label: "項次", width: "60" }, - { prop: "fieldName", label: "欄位名稱" }, - { prop: "type", label: "類型" }, - ], - }, }, 7: { sections: [ @@ -544,17 +509,6 @@ export const templateSchemas = { ], }, ], - verification: { - enabled: true, - title: "查證", - addButtonText: "新增查證設定", - dialogType: "verification", - columns: [ - { prop: "index", label: "項次", width: "60" }, - { prop: "fieldName", label: "欄位名稱" }, - { prop: "type", label: "類型" }, - ], - }, }, }; @@ -590,13 +544,6 @@ export function initializeTableData(schema) { }); } - // 初始化驗證表格 - if (schema.verification?.enabled) { - tableData.verification = schema.verification.defaultData - ? JSON.parse(JSON.stringify(schema.verification.defaultData)) - : []; - } - return tableData; }