Showing
8 changed files
with
106 additions
and
16 deletions
| @@ -124,8 +124,8 @@ | @@ -124,8 +124,8 @@ | ||
| 124 | v-model:value="record.checkPlanId" | 124 | v-model:value="record.checkPlanId" |
| 125 | :options="planOptions" | 125 | :options="planOptions" |
| 126 | :disabled="isViewMode" | 126 | :disabled="isViewMode" |
| 127 | - :fieldNames="{ label: 'name', value: 'id' }" | ||
| 128 | placeholder="请选择" | 127 | placeholder="请选择" |
| 128 | + @change="(value) => handleCheckPlanChange(value, record)" | ||
| 129 | /> | 129 | /> |
| 130 | </div> | 130 | </div> |
| 131 | </template> | 131 | </template> |
| @@ -264,7 +264,19 @@ const visible = ref(props.visible); | @@ -264,7 +264,19 @@ const visible = ref(props.visible); | ||
| 264 | const isViewMode = ref(props.isViewMode); | 264 | const isViewMode = ref(props.isViewMode); |
| 265 | const modalTitle = ref(props.modalTitle); | 265 | const modalTitle = ref(props.modalTitle); |
| 266 | const form = ref({ ...props.initialData.form }); | 266 | const form = ref({ ...props.initialData.form }); |
| 267 | -const tableData = ref([...props.initialData.tableData]); | 267 | +const normalizeDetailRow = (row: any) => { |
| 268 | + const deviceInfo = row?.tkDeviceAccountDTO || row?.deviceInfo; | ||
| 269 | + const checkDeviceId = row?.checkDeviceId ?? deviceInfo?.id; | ||
| 270 | + const deviceCode = row?.deviceCode ?? deviceInfo?.code; | ||
| 271 | + const deviceName = row?.deviceName ?? deviceInfo?.name; | ||
| 272 | + return { | ||
| 273 | + ...row, | ||
| 274 | + checkDeviceId, | ||
| 275 | + deviceCode, | ||
| 276 | + deviceName, | ||
| 277 | + }; | ||
| 278 | +}; | ||
| 279 | +const tableData = ref((props.initialData.tableData || []).map(normalizeDetailRow)); | ||
| 268 | const emit = defineEmits(['update:visible', 'submit']); | 280 | const emit = defineEmits(['update:visible', 'submit']); |
| 269 | const deviceVisible = ref(false); | 281 | const deviceVisible = ref(false); |
| 270 | const deviceSearchInfo = reactive<Recordable>({ code: '', name: '' }); | 282 | const deviceSearchInfo = reactive<Recordable>({ code: '', name: '' }); |
| @@ -308,6 +320,13 @@ watch( | @@ -308,6 +320,13 @@ watch( | ||
| 308 | } | 320 | } |
| 309 | ); | 321 | ); |
| 310 | 322 | ||
| 323 | +watch( | ||
| 324 | + () => props.modalTitle, | ||
| 325 | + (newVal) => { | ||
| 326 | + modalTitle.value = newVal; | ||
| 327 | + } | ||
| 328 | +); | ||
| 329 | + | ||
| 311 | // 监听 visible 的变化并通知父组件 | 330 | // 监听 visible 的变化并通知父组件 |
| 312 | watch( | 331 | watch( |
| 313 | () => visible.value, | 332 | () => visible.value, |
| @@ -321,7 +340,7 @@ watch( | @@ -321,7 +340,7 @@ watch( | ||
| 321 | () => props.initialData, | 340 | () => props.initialData, |
| 322 | (newVal) => { | 341 | (newVal) => { |
| 323 | form.value = { ...newVal.form }; | 342 | form.value = { ...newVal.form }; |
| 324 | - tableData.value = [...newVal.tableData]; | 343 | + tableData.value = (newVal.tableData || []).map(normalizeDetailRow); |
| 325 | }, | 344 | }, |
| 326 | { deep: true } | 345 | { deep: true } |
| 327 | ); | 346 | ); |
| @@ -336,12 +355,23 @@ const fetchAgeOptions = async () => { | @@ -336,12 +355,23 @@ const fetchAgeOptions = async () => { | ||
| 336 | const response = await getLedgerList({ page: 1, pageSize: 999 }); // 调用接口 | 355 | const response = await getLedgerList({ page: 1, pageSize: 999 }); // 调用接口 |
| 337 | const response1 = await getPlanList({ page: 1, pageSize: 999, type: 'INSPECTION' }); // 调用接口 | 356 | const response1 = await getPlanList({ page: 1, pageSize: 999, type: 'INSPECTION' }); // 调用接口 |
| 338 | Options.value = response.items || []; | 357 | Options.value = response.items || []; |
| 339 | - planOptions.value = response1.items || []; | 358 | + planOptions.value = |
| 359 | + response1.items?.map((item: any) => ({ | ||
| 360 | + ...item, | ||
| 361 | + label: item?.name, | ||
| 362 | + value: item?.id, | ||
| 363 | + planDetails: item?.planDetails, | ||
| 364 | + })) || []; | ||
| 340 | } catch (error) { | 365 | } catch (error) { |
| 341 | console.error('失败:', error); | 366 | console.error('失败:', error); |
| 342 | } | 367 | } |
| 343 | }; | 368 | }; |
| 344 | 369 | ||
| 370 | +const handleCheckPlanChange = (checkPlanId: any, record: any) => { | ||
| 371 | + const selected = planOptions.value?.find((item: any) => item?.value === checkPlanId); | ||
| 372 | + record.planDetails = selected?.planDetails || ''; | ||
| 373 | +}; | ||
| 374 | + | ||
| 345 | const getDeviceLabel = (record: any) => { | 375 | const getDeviceLabel = (record: any) => { |
| 346 | const code = record?.deviceCode; | 376 | const code = record?.deviceCode; |
| 347 | const name = record?.deviceName; | 377 | const name = record?.deviceName; |
| @@ -374,6 +404,12 @@ const handleDeviceOk = () => { | @@ -374,6 +404,12 @@ const handleDeviceOk = () => { | ||
| 374 | activeDeviceRecord.value.checkDeviceId = selectedDevice.value.id; | 404 | activeDeviceRecord.value.checkDeviceId = selectedDevice.value.id; |
| 375 | activeDeviceRecord.value.deviceCode = selectedDevice.value.code; | 405 | activeDeviceRecord.value.deviceCode = selectedDevice.value.code; |
| 376 | activeDeviceRecord.value.deviceName = selectedDevice.value.name; | 406 | activeDeviceRecord.value.deviceName = selectedDevice.value.name; |
| 407 | + activeDeviceRecord.value.tkDeviceAccountDTO = { | ||
| 408 | + ...(activeDeviceRecord.value.tkDeviceAccountDTO || {}), | ||
| 409 | + id: selectedDevice.value.id, | ||
| 410 | + code: selectedDevice.value.code, | ||
| 411 | + name: selectedDevice.value.name, | ||
| 412 | + }; | ||
| 377 | deviceVisible.value = false; | 413 | deviceVisible.value = false; |
| 378 | }; | 414 | }; |
| 379 | 415 |
| @@ -90,7 +90,7 @@ | @@ -90,7 +90,7 @@ | ||
| 90 | :initial-data="initialData" | 90 | :initial-data="initialData" |
| 91 | :is-view-mode="isViewMode" | 91 | :is-view-mode="isViewMode" |
| 92 | @submit="handleSubmit" | 92 | @submit="handleSubmit" |
| 93 | - :title="modalTitle" | 93 | + :modal-title="modalTitle" |
| 94 | /> | 94 | /> |
| 95 | </div> | 95 | </div> |
| 96 | </template> | 96 | </template> |
| @@ -306,6 +306,13 @@ watch( | @@ -306,6 +306,13 @@ watch( | ||
| 306 | } | 306 | } |
| 307 | ); | 307 | ); |
| 308 | 308 | ||
| 309 | +watch( | ||
| 310 | + () => props.modalTitle, | ||
| 311 | + (newVal) => { | ||
| 312 | + modalTitle.value = newVal; | ||
| 313 | + } | ||
| 314 | +); | ||
| 315 | + | ||
| 309 | // 监听 visible 的变化并通知父组件 | 316 | // 监听 visible 的变化并通知父组件 |
| 310 | watch( | 317 | watch( |
| 311 | () => visible.value, | 318 | () => visible.value, |
| @@ -46,7 +46,7 @@ | @@ -46,7 +46,7 @@ | ||
| 46 | v-model:visible="modalVisible" | 46 | v-model:visible="modalVisible" |
| 47 | :initial-data="initialData" | 47 | :initial-data="initialData" |
| 48 | :is-view-mode="isViewMode" | 48 | :is-view-mode="isViewMode" |
| 49 | - :title="modalTitle" | 49 | + :modal-title="modalTitle" |
| 50 | @submit="handleSubmit" | 50 | @submit="handleSubmit" |
| 51 | /> | 51 | /> |
| 52 | </div> | 52 | </div> |
| @@ -99,7 +99,6 @@ | @@ -99,7 +99,6 @@ | ||
| 99 | v-model:value="record.checkPlanId" | 99 | v-model:value="record.checkPlanId" |
| 100 | :options="planOptions" | 100 | :options="planOptions" |
| 101 | :disabled="isViewMode" | 101 | :disabled="isViewMode" |
| 102 | - :fieldNames="{ label: 'name', value: 'id' }" | ||
| 103 | placeholder="请选择" | 102 | placeholder="请选择" |
| 104 | @change="(value) => handleCheckPlanChange(value, record)" | 103 | @change="(value) => handleCheckPlanChange(value, record)" |
| 105 | /> | 104 | /> |
| @@ -222,7 +221,19 @@ const statusOptions = [ | @@ -222,7 +221,19 @@ const statusOptions = [ | ||
| 222 | { label: t('inspection.servicePlan.STOP'), value: 'STOP' }, | 221 | { label: t('inspection.servicePlan.STOP'), value: 'STOP' }, |
| 223 | ]; | 222 | ]; |
| 224 | const form = ref({ ...props.initialData.form }); | 223 | const form = ref({ ...props.initialData.form }); |
| 225 | -const tableData = ref([...props.initialData.tableData]); | 224 | +const normalizeDetailRow = (row: any) => { |
| 225 | + const deviceInfo = row?.deviceInfo || row?.tkDeviceAccountDTO; | ||
| 226 | + const deviceId = row?.deviceId ?? deviceInfo?.id; | ||
| 227 | + const deviceCode = row?.deviceCode ?? deviceInfo?.code; | ||
| 228 | + const deviceName = row?.deviceName ?? deviceInfo?.name; | ||
| 229 | + return { | ||
| 230 | + ...row, | ||
| 231 | + deviceId, | ||
| 232 | + deviceCode, | ||
| 233 | + deviceName, | ||
| 234 | + }; | ||
| 235 | +}; | ||
| 236 | +const tableData = ref((props.initialData.tableData || []).map(normalizeDetailRow)); | ||
| 226 | const emit = defineEmits(['update:visible', 'submit']); | 237 | const emit = defineEmits(['update:visible', 'submit']); |
| 227 | onMounted(() => { | 238 | onMounted(() => { |
| 228 | fetchAgeOptions(); | 239 | fetchAgeOptions(); |
| @@ -261,22 +272,39 @@ const fetchAgeOptions = async () => { | @@ -261,22 +272,39 @@ const fetchAgeOptions = async () => { | ||
| 261 | const response = await getLedgerList({ page: 1, pageSize: 999 }); // 调用接口 | 272 | const response = await getLedgerList({ page: 1, pageSize: 999 }); // 调用接口 |
| 262 | const response1 = await getPlanList({ page: 1, pageSize: 999, type: 'MAINTENANCE' }); // 调用接口 | 273 | const response1 = await getPlanList({ page: 1, pageSize: 999, type: 'MAINTENANCE' }); // 调用接口 |
| 263 | Options.value = response.items || []; | 274 | Options.value = response.items || []; |
| 264 | - planOptions.value = response1.items || []; | 275 | + planOptions.value = |
| 276 | + response1.items?.map((item: any) => ({ | ||
| 277 | + ...item, | ||
| 278 | + label: item?.name, | ||
| 279 | + value: item?.id, | ||
| 280 | + planDetails: item?.planDetails, | ||
| 281 | + })) || []; | ||
| 265 | } catch (error) { | 282 | } catch (error) { |
| 266 | console.error('失败:', error); | 283 | console.error('失败:', error); |
| 267 | } | 284 | } |
| 268 | }; | 285 | }; |
| 269 | 286 | ||
| 270 | const handleCheckPlanChange = (checkPlanId: any, record: any) => { | 287 | const handleCheckPlanChange = (checkPlanId: any, record: any) => { |
| 271 | - const selected = planOptions.value?.find((item: any) => item?.id === checkPlanId); | 288 | + const selected = planOptions.value?.find((item: any) => item?.value === checkPlanId); |
| 272 | record.preserveDetail = selected?.planDetails || ''; | 289 | record.preserveDetail = selected?.planDetails || ''; |
| 273 | }; | 290 | }; |
| 274 | 291 | ||
| 275 | const getDeviceLabel = (record: any) => { | 292 | const getDeviceLabel = (record: any) => { |
| 276 | const code = record?.deviceCode; | 293 | const code = record?.deviceCode; |
| 277 | const name = record?.deviceName; | 294 | const name = record?.deviceName; |
| 278 | - if (code && name) return `${code} / ${name}`; | ||
| 279 | - return name || code || ''; | 295 | + if (code || name) { |
| 296 | + if (code && name) return `${code} / ${name}`; | ||
| 297 | + return name || code || ''; | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + const deviceId = record?.deviceId; | ||
| 301 | + if (!deviceId) return ''; | ||
| 302 | + | ||
| 303 | + const matched = Options.value?.find((item: any) => item?.id === deviceId); | ||
| 304 | + const matchedCode = matched?.code; | ||
| 305 | + const matchedName = matched?.name; | ||
| 306 | + if (matchedCode && matchedName) return `${matchedCode} / ${matchedName}`; | ||
| 307 | + return matchedName || matchedCode || ''; | ||
| 280 | }; | 308 | }; |
| 281 | 309 | ||
| 282 | const goChooseDevice = (record: any) => { | 310 | const goChooseDevice = (record: any) => { |
| @@ -304,6 +332,12 @@ const handleDeviceOk = () => { | @@ -304,6 +332,12 @@ const handleDeviceOk = () => { | ||
| 304 | activeDeviceRecord.value.deviceId = selectedDevice.value.id; | 332 | activeDeviceRecord.value.deviceId = selectedDevice.value.id; |
| 305 | activeDeviceRecord.value.deviceCode = selectedDevice.value.code; | 333 | activeDeviceRecord.value.deviceCode = selectedDevice.value.code; |
| 306 | activeDeviceRecord.value.deviceName = selectedDevice.value.name; | 334 | activeDeviceRecord.value.deviceName = selectedDevice.value.name; |
| 335 | + activeDeviceRecord.value.deviceInfo = { | ||
| 336 | + ...(activeDeviceRecord.value.deviceInfo || {}), | ||
| 337 | + id: selectedDevice.value.id, | ||
| 338 | + code: selectedDevice.value.code, | ||
| 339 | + name: selectedDevice.value.name, | ||
| 340 | + }; | ||
| 307 | deviceVisible.value = false; | 341 | deviceVisible.value = false; |
| 308 | }; | 342 | }; |
| 309 | 343 | ||
| @@ -326,6 +360,13 @@ watch( | @@ -326,6 +360,13 @@ watch( | ||
| 326 | } | 360 | } |
| 327 | ); | 361 | ); |
| 328 | 362 | ||
| 363 | +watch( | ||
| 364 | + () => props.modalTitle, | ||
| 365 | + (newVal) => { | ||
| 366 | + modalTitle.value = newVal; | ||
| 367 | + } | ||
| 368 | +); | ||
| 369 | + | ||
| 329 | // 监听 visible 的变化并通知父组件 | 370 | // 监听 visible 的变化并通知父组件 |
| 330 | watch( | 371 | watch( |
| 331 | () => visible.value, | 372 | () => visible.value, |
| @@ -339,7 +380,7 @@ watch( | @@ -339,7 +380,7 @@ watch( | ||
| 339 | () => props.initialData, | 380 | () => props.initialData, |
| 340 | (newVal) => { | 381 | (newVal) => { |
| 341 | form.value = { ...newVal.form }; | 382 | form.value = { ...newVal.form }; |
| 342 | - tableData.value = [...newVal.tableData]; | 383 | + tableData.value = (newVal.tableData || []).map(normalizeDetailRow); |
| 343 | }, | 384 | }, |
| 344 | { deep: true } | 385 | { deep: true } |
| 345 | ); | 386 | ); |
| @@ -90,7 +90,7 @@ | @@ -90,7 +90,7 @@ | ||
| 90 | :initial-data="initialData" | 90 | :initial-data="initialData" |
| 91 | :is-view-mode="isViewMode" | 91 | :is-view-mode="isViewMode" |
| 92 | @submit="handleSubmit" | 92 | @submit="handleSubmit" |
| 93 | - :title="modalTitle" | 93 | + :modal-title="modalTitle" |
| 94 | /> | 94 | /> |
| 95 | </div> | 95 | </div> |
| 96 | </template> | 96 | </template> |
| @@ -97,7 +97,6 @@ | @@ -97,7 +97,6 @@ | ||
| 97 | v-model:value="record.status" | 97 | v-model:value="record.status" |
| 98 | :options="defaultOptions" | 98 | :options="defaultOptions" |
| 99 | :disabled="isViewMode" | 99 | :disabled="isViewMode" |
| 100 | - :field-names="{ label: 'name', value: 'id' }" | ||
| 101 | placeholder="请选择" | 100 | placeholder="请选择" |
| 102 | /> | 101 | /> |
| 103 | </div> | 102 | </div> |
| @@ -352,6 +351,13 @@ watch( | @@ -352,6 +351,13 @@ watch( | ||
| 352 | } | 351 | } |
| 353 | ); | 352 | ); |
| 354 | 353 | ||
| 354 | +watch( | ||
| 355 | + () => props.modalTitle, | ||
| 356 | + (newVal) => { | ||
| 357 | + modalTitle.value = newVal; | ||
| 358 | + } | ||
| 359 | +); | ||
| 360 | + | ||
| 355 | // 监听 visible 的变化并通知父组件 | 361 | // 监听 visible 的变化并通知父组件 |
| 356 | watch( | 362 | watch( |
| 357 | () => visible.value, | 363 | () => visible.value, |
| @@ -55,7 +55,7 @@ | @@ -55,7 +55,7 @@ | ||
| 55 | v-model:visible="modalVisible" | 55 | v-model:visible="modalVisible" |
| 56 | :initial-data="initialData" | 56 | :initial-data="initialData" |
| 57 | :is-view-mode="isViewMode" | 57 | :is-view-mode="isViewMode" |
| 58 | - :title="modalTitle" | 58 | + :modal-title="modalTitle" |
| 59 | @submit="handleSubmit" | 59 | @submit="handleSubmit" |
| 60 | /> | 60 | /> |
| 61 | </div> | 61 | </div> |