Prechádzať zdrojové kódy

fix(pressure2): 修复多个前端问题并优化检验性质展示

1. 移除上传接口多余的VITE_BASE_URL拼接
2. 可选链修复createUser为空时报错问题
3. 将检验性质映射抽离到全局常量并支持动态切换
4. 实现检验性质搜索选项随设备类型动态更新
xuzhancheng 10 hodín pred
rodič
commit
f9aad1af3c

+ 37 - 13
yudao-ui-admin-vue3/src/views/pressure/acceptorder/index.vue

@@ -85,7 +85,7 @@
   import { usePageLoading } from '@/hooks/web/usePageLoading'
   import { SmartInstanceExpose, SmartTableColumn, SmartSearchFormOptionItem } from '@/types/table'
   import { getDeptList } from '@/api/laboratory/dept'
-import { PressureEquipMainTypeMap } from '@/utils/constants'
+import { PressureEquipMainTypeMap, allCheckTypeMap } from '@/utils/constants'
   const dictStore = useDictStore()
   const userStore = useUserStore()
   const getCurrentUserRoles = computed(() => userStore.getRoles)
@@ -131,12 +131,6 @@ import { PressureEquipMainTypeMap } from '@/utils/constants'
     200: '合同收费'
   }
 
-  // 检验性质映射
-  const checkTypeMap = {
-    100: '定期检验',
-    200: '年度检查',
-    300: '超年限检验'
-  }
   const columns = ref<SmartTableColumn[]>([
     {
       type: 'selection',
@@ -207,14 +201,13 @@ import { PressureEquipMainTypeMap } from '@/utils/constants'
       prop: 'checkType',
       width: 100,
       search: {
-        type: 'select',  // 改为select类型
-        options: Object.entries(checkTypeMap).map(([value, label]) => ({
-          label,
-          value: parseInt(value)  // 确保值是数字类型
-        }))
+        type: 'custom-select',  // 使用custom-select支持动态options
+        fieldProps: {
+          placeholder: '请选择检验性质'
+        }
       },
       render: (row, value) => {
-        return !value ? '-' : checkTypeMap[value]
+        return !value ? '-' : (allCheckTypeMap[row.equipMainType]?.[value] || '-')
       }
     },
     {
@@ -439,6 +432,37 @@ import { PressureEquipMainTypeMap } from '@/utils/constants'
     status: ['100'],
     deptId: userStore.user.deptId
   })
+  // 监听设备类型变化,动态更新检验性质搜索选项
+  watch(
+    () => searchFormData.value.equipMainType,
+    (newType) => {
+      let newOptions: SmartSearchFormOptionItem[] = []
+      if (newType && allCheckTypeMap[newType]) {
+        newOptions = Object.entries(allCheckTypeMap[newType]).map(([value, label]) => ({
+          label,
+          value: parseInt(value)
+        }))
+      }
+      // 通过替换列对象触发 SmartTable 重新渲染
+      columns.value = columns.value.map(col => {
+        if (col.prop === 'checkType' && col.search) {
+          return {
+            ...col,
+            search: {
+              ...col.search,
+              fieldProps: {
+                ...col.search.fieldProps,
+                options: newOptions
+              }
+            }
+          }
+        }
+        return col
+      })
+      // 设备类型变化时清除已选的检验性质
+      delete searchFormData.value.checkType
+    }
+  )
   const loading = ref(false)
   const dataList = ref([])
   const SmartTableRef = ref<SmartInstanceExpose>()

+ 1 - 1
yudao-ui-admin-vue3/src/views/pressure2/boilerchecker/components/StatusOperationPanel.vue

@@ -245,7 +245,7 @@
                         }}</div>
                       <div class="record-item-inner">
                         <div class="content">
-                          <span>{{ record.createUser.nickname }}</span>
+                          <span>{{ record.createUser?.nickname }}</span>
                           <el-button
                             :type="
                               OAApprovalResultType[record.result] ||

+ 1 - 1
yudao-ui-admin-vue3/src/views/pressure2/components/RectificationUpload.vue

@@ -199,7 +199,7 @@ const handlePostFile = async (options) => {
     const formData = new FormData()
     formData.append('file', file)
     const result = await request.post({
-      url: VITE_BASE_URL + props.apiUrl,
+      url: props.apiUrl,
       data: formData,
       headers: {
         authorization: 'Bearer ' + getAccessToken(),

+ 1 - 1
yudao-ui-admin-vue3/src/views/pressure2/pipechecker/components/StatusOperationPanel.vue

@@ -245,7 +245,7 @@
                         }}</div>
                       <div class="record-item-inner">
                         <div class="content">
-                          <span>{{ record.createUser.nickname }}</span>
+                          <span>{{ record.createUser?.nickname }}</span>
                           <el-button
                             :type="
                               OAApprovalResultType[record.result] ||