Bladeren bron

equipment_type结构调整

zengy 1 maand geleden
bovenliggende
commit
b13154bf92

+ 3 - 2
src/api/drainage.js

@@ -73,10 +73,11 @@ async function getDrainageEquipmentTypeId() {
     drainageEquipmentTypeIdPromise = getEquipmentTypeList()
       .then(res => {
         const list = (res && res.code !== undefined ? res.data : res) || []
+        // 设备类别主键:2=排水设备(EquipmentTypeEnum.ROOT_DRAINAGE_DEVICE)
         const drainageParent = Array.isArray(list)
-          ? list.find(item => item.typeId === 'drainage' && String(item.parentTypeId) === '0')
+          ? list.find(item => Number(item.id) === 2 && String(item.parentId) === '0')
           : null
-        return drainageParent && drainageParent.id ? String(drainageParent.id) : 'drainage'
+        return drainageParent && drainageParent.id ? String(drainageParent.id) : '2'
       })
       .catch(error => {
         drainageEquipmentTypeIdPromise = null

+ 1 - 1
src/views/subSystem/basic/Equipment.vue

@@ -365,7 +365,7 @@ async function loadEquipmentTypes() {
   try {
     const res = await getEquipmentTypeList()
     const all = res.data || []
-    equipmentTypeOptions.value = all.filter(t => t.parentTypeId === '3')
+    equipmentTypeOptions.value = all.filter(t => Number(t.parentId) === 3)
   } catch (e) { console.error(e) }
 }
 async function loadNetworkOptions() {

+ 9 - 9
src/views/subSystem/drainage/jcsj/sbjcgl.vue

@@ -316,18 +316,18 @@ import {
 // ==================== 选项配置 ====================
 const typeList = ref([])
 const typeOptions = computed(() => {
-  return typeList.value.map(item => ({ label: item.typeName, value: item.typeId }))
+  return typeList.value.map(item => ({ label: item.typeName, value: item.id }))
 })
 
 const drainageTypeOptions = computed(() => {
-  // 找到排水父类记录(typeId为'drainage'且parentTypeId为'0')
-  const drainageParent = typeList.value.find(item => item.typeId === 'drainage' && item.parentTypeId === '0')
+  // 找到排水父类记录(主键 id=2 且 parentId 为 0)
+  const drainageParent = typeList.value.find(item => Number(item.id) === 2 && String(item.parentId) === '0')
   if (!drainageParent) {
     // 如果找不到父类,返回所有非顶级的类型
-    return typeList.value.filter(item => item.parentTypeId !== '0' && item.parentTypeId !== null).map(item => ({ label: item.typeName, value: item.id }))
+    return typeList.value.filter(item => item.parentId !== null && String(item.parentId) !== '0').map(item => ({ label: item.typeName, value: item.id }))
   }
-  // 返回parentTypeId等于drainage父类id的子类型
-  return typeList.value.filter(item => String(item.parentTypeId) === String(drainageParent.id)).map(item => ({ label: item.typeName, value: item.id }))
+  // 返回parentId等于drainage父类id的子类型
+  return typeList.value.filter(item => String(item.parentId) === String(drainageParent.id)).map(item => ({ label: item.typeName, value: item.id }))
 })
 
 const statusOptions = [
@@ -339,7 +339,7 @@ const statusOptions = [
 ]
 
 function typeText(val) {
-  const item = typeList.value.find(t => t.typeId === val)
+  const item = typeList.value.find(t => String(t.id) === String(val))
   return item ? item.typeName : '-'
 }
 
@@ -409,9 +409,9 @@ async function loadTypeList() {
   try {
     const res = await getEquipmentTypeList()
     typeList.value = (res.code !== undefined ? res.data : res) || []
-    // 分页接口要求传 equipment_type.id,不能传业务编码 drainage。
+    // 分页接口要求传 equipment_type.id(2=排水设备)
     const drainageParent = typeList.value.find(item =>
-      item.typeId === 'drainage' && String(item.parentTypeId) === '0'
+      Number(item.id) === 2 && String(item.parentId) === '0'
     )
     queryParams.value.equipmentTypeId = drainageParent ? String(drainageParent.id) : ''
   } catch (error) {

+ 1 - 1
src/views/subSystem/drainage/jcyj/dqyjgl.vue

@@ -237,7 +237,7 @@ async function loadEquipmentTypes() {
     const map = new Map()
     if (Array.isArray(list)) {
       list.forEach(item => {
-        if (item.typeId) map.set(String(item.typeId), item.typeName)
+        if (item.id !== undefined && item.id !== null) map.set(String(item.id), item.typeName)
       })
     }
     equipmentTypeMap.value = map

+ 1 - 1
src/views/subSystem/drainage/jcyj/lsyjgl.vue

@@ -158,7 +158,7 @@ async function loadEquipmentTypes() {
     const map = new Map()
     if (Array.isArray(list)) {
       list.forEach(item => {
-        if (item.typeId) map.set(String(item.typeId), item.typeName)
+        if (item.id !== undefined && item.id !== null) map.set(String(item.id), item.typeName)
       })
     }
     equipmentTypeMap.value = map

+ 1 - 1
src/views/subSystem/manholeCover/device/index.vue

@@ -243,7 +243,7 @@ async function loadTypeOptions() {
 const getTypeText = (row) => {
   const t = typeIdMap.value[row.equipmentTypeId]
   if (!t) return row.typeName || '—'
-  return MANHOLE_CATEGORY_MAP[t.parentTypeId] || MANHOLE_CATEGORY_MAP[row.equipmentTypeId] || t.typeName || '—'
+  return MANHOLE_CATEGORY_MAP[String(t.parentId)] || MANHOLE_CATEGORY_MAP[row.equipmentTypeId] || t.typeName || '—'
 }
 
 // 加载设备列表(后端已按窨井设备类型过滤)

+ 1 - 1
src/views/subSystem/manholeCover/home/index.vue

@@ -132,7 +132,7 @@ const priorityText = (l) => ({ 0: '紧急', 1: '一般', 2: '低' }[l] || '-')
 const priorityClass = (l) => ({ 0: 'high', 1: 'medium', 2: 'low' }[l] || 'low')
 /** 待办工单口径:待派单/待接单/已接单/处理中/延期中(枚举派生,见 workOrderDict.js) */
 const TODO_ORDER_STATUS = ORDER_STATUS_GROUP.todo.join(',')
-/** 设备父类别ID(equipment_type.parent_type_id),与工单列表页保持同一口径 */
+/** 设备父类别ID(equipment_type.parent_id),与工单列表页保持同一口径 */
 const DEVICE_TYPE_PARENT_ID = '4'
 const typeText = (id) => TYPE_MAP[id] || '-'
 const statusText = (s) => ({ normal: '在线', alert: '告警', offline: '离线' }[s] || s)

+ 2 - 2
src/views/subSystem/pipeNetwork/ops/workOrder/list.vue

@@ -109,7 +109,7 @@ const route = useRoute()
  * 本组件服务于「案件管理」下两个列表菜单,展示与运维工单列表一致,仅查询口径不同:
  * - 经办工单:未办结状态(待派单 / 待接单 / 已接单 / 处理中 / 待验收 / 延期中)
  * - 办结工单:已结案
- * 两者都只查 equipment_type.parent_type_id = 4(案件类设备)下的工单。
+ * 两者都只查 equipment_type.parent_id = 4(案件类设备)下的工单。
  *
  * 判定方式:同一组件由后台 sys_menu.component 指向本文件,菜单的 path 与菜单名会分别体现在
  * 路由 path、route.meta.title 中,因此按关键字区分来源;两者都未命中时走默认(不限状态),
@@ -134,7 +134,7 @@ const MENU_SCOPES = [
   }
 ]
 
-/** 案件类设备的父类别ID(equipment_type.parent_type_id),本列表仅查询该类设备产生的工单 */
+/** 案件类设备的父类别ID(equipment_type.parent_id),本列表仅查询该类设备产生的工单 */
 const CASE_DEVICE_TYPE_PARENT_ID = '4'
 
 const menuScope = computed(() => {

+ 9 - 12
src/views/subSystem/pipeNetwork/pdeviceInform/PequipmentLed.vue

@@ -415,44 +415,41 @@ const typeNameMap = computed(() => {
   }, {});
 });
 
-// parentTypeId 为 0(或空)表示父类
+// parentId 为 0(或空)表示父类
 function isTopLevelType(item) {
-  const parentTypeId = item?.parentTypeId;
-  return parentTypeId === 0 || parentTypeId === "0" || parentTypeId === null || parentTypeId === undefined || parentTypeId === "";
+  const parentId = item?.parentId;
+  return parentId === 0 || parentId === "0" || parentId === null || parentId === undefined || parentId === "";
 }
 
 const equipmentTypeTree = computed(() => {
   const list = equipmentTypeOptions.value || [];
   const entries = [];
-  // 同时按 typeId / id 建索引,兼容 parentTypeId 指向不同主键字段的情况
+  // 设备类别主键已统一为整数 id,parentId 指向父记录的 id
   const nodeIndex = {};
 
   list.forEach((item) => {
     const node = {
       id: item.id,
-      typeId: item.typeId,
       typeName: item.typeName,
       disabled: isTopLevelType(item),
       children: []
     };
     entries.push({ item, node });
-    [item.typeId, item.id].forEach((key) => {
-      if (key !== undefined && key !== null) {
-        nodeIndex[String(key)] = node;
-      }
-    });
+    if (item.id !== undefined && item.id !== null) {
+      nodeIndex[String(item.id)] = node;
+    }
   });
 
   const roots = [];
   // 父节点不在返回列表中时兜底归类,避免子类型在下拉中丢失
-  const fallbackNode = { id: "__other__", typeId: "__other__", typeName: "未分类", disabled: true, children: [] };
+  const fallbackNode = { id: "__other__", typeName: "未分类", disabled: true, children: [] };
 
   entries.forEach(({ item, node }) => {
     if (isTopLevelType(item)) {
       roots.push(node);
       return;
     }
-    const parent = nodeIndex[String(item.parentTypeId)];
+    const parent = nodeIndex[String(item.parentId)];
     if (parent && parent !== node) {
       parent.children.push(node);
     } else {

+ 3 - 3
src/views/subSystem/waterSupply/components/WaterDevicePage.vue

@@ -782,12 +782,12 @@
     }
 
     function isWaterDeviceType(type, typesById) {
-        if (!type || (type.typeName === '供水' && type.parentTypeId === '0')) return false
+        if (!type || (type.typeName === '供水' && String(type.parentId) === '0')) return false
         let cursor = type
         let guard = 0
         while (cursor && guard++ <= typesById.size) {
-            if (cursor.typeName === '供水' && cursor.parentTypeId === '0') return true
-            cursor = typesById.get(cursor.parentTypeId)
+            if (cursor.typeName === '供水' && String(cursor.parentId) === '0') return true
+            cursor = typesById.get(cursor.parentId)
         }
         return false
     }