Procházet zdrojové kódy

fix: 问题类型-人工上报更新为二级类型,同步修改违规问题模块问题类型相关内容

bxy před 1 rokem
rodič
revize
4c5c1e21e4

+ 9 - 22
src/api/datamanagement/alert.ts

@@ -1,38 +1,25 @@
 import { http } from '@/utils/http/axios';
 
-// 问题类型接口1:AI检测
-export const getAIList = () => {
+// 地点获取接口:获取问题单地点列表(现为从公司-车间-工位-相机树中提取)
+export const getWorkLocationList = () => {
   return http.request({
-    url: '/admin/algo/queryAlgoInfo',
+    url: '/admin/cameraPreview/queryCameraTree',
     method: 'get',
   });
 };
 
-// 问题类型接口2:人工上报
-export const getManualList = () => {
+// 获取问题类型及对应算法列表(此接口已根据问题一级分类进行汇总归类)
+export const getIssueTypeListWithMainType = (query: number) => {
   return http.request({
-    url: '/admin/issueManage/getIssueTypeList',
+    url: `/issue/queryIssueTypeListWithMainType?source=${query}`,
     method: 'get',
   });
 };
 
-// 地点获取接口:获取问题单地点列表(现为从公司-车间-工位-相机树中提取
-export const getWorkLocationList = () => {
+// 获取问题单二级分类列表(此接口枚举当前source下所有算法的全部参数,未根据问题issueMainType进行汇总归类
+export const getIssueSubTypeList = (query: number) => {
   return http.request({
-    url: '/admin/cameraPreview/queryCameraTree',
+    url: `/issue/getIssueSubTypeList?source=${query}`,
     method: 'get',
   });
 };
-
-// AI问题类型(issueMainType-issueType)
-export const getAIMainList = () => {
-  return http.request(
-    {
-      url: '/issue/getIssueSubTypeList',
-      method: 'get',
-    },
-    {
-      isShowErrorMessage: false,
-    },
-  );
-};

+ 1 - 1
src/views/cameras/overview/components/BatchImportCamera.vue

@@ -237,7 +237,7 @@
       cardVisible.value = false;
     } catch (error) {
       ElMessage({
-        message: '系统错误',
+        message: response.message,
         type: 'error',
       });
       emits('update');

+ 5 - 8
src/views/datamanager/alertformdata/components/common/AlertTable.vue

@@ -21,7 +21,7 @@
       </el-table-column>
       <el-table-column label="类型" prop="issueType" width="150">
         <template #default="{ row }">
-          {{ getNameByType(row.source, row.issueType) }}
+          {{ getNameByType(row.source, row.issueMainType, row.issueType) }}
         </template>
       </el-table-column>
       <el-table-column label="问题描述" prop="description" width="280" show-overflow-tooltip>
@@ -122,7 +122,7 @@
   import { ElTable } from 'element-plus';
   import { onBeforeMount, onMounted, ref } from 'vue';
   import { getNameBySource, getNameByState } from './constant.question';
-  import { useIssueType } from '../../hooks/useIssueType';
+  import { useIssueMainType } from '../../hooks/useIssueMainType';
   import { useWorkLocation } from '../../hooks/useWorkLocation';
   import { useUserStore } from '@/store/modules/user';
   import { PERM_DATA } from '@/types/permission/constants';
@@ -135,10 +135,7 @@
     else return userStore.checkPermission(PERM_DATA.VIOLATION_DELETE);
   };
 
-  const { aiOptions, manualOptions, getAIOptions, getManualOptions, getNameByType } =
-    useIssueType();
-  console.log(aiOptions.value, manualOptions.value);
-
+  const { getAIMainOptions, getManualMainOptions, getNameByType } = useIssueMainType();
   const { locationOptions, getLocationOptions, getNameByWorkid } = useWorkLocation();
 
   const multipleTableRef = ref<InstanceType<typeof ElTable>>();
@@ -286,8 +283,8 @@
   defineExpose({ clearAll, updateCurRowChosen });
 
   onBeforeMount(() => {
-    getAIOptions();
-    getManualOptions();
+    getAIMainOptions();
+    getManualMainOptions();
     getLocationOptions();
   });
 

+ 5 - 5
src/views/datamanager/alertformdata/components/common/AlertTableSimple.vue

@@ -16,7 +16,7 @@
       <el-table-column type="selection" width="55"></el-table-column>
       <el-table-column label="类型" prop="issueType" width="180">
         <template #default="{ row }">
-          {{ getNameByType(row.source, row.issueType) }}
+          {{ getNameByType(row.source, row.issueMainType, row.issueType) }}
         </template>
       </el-table-column>
       <el-table-column label="问题描述" prop="description" width="280" show-overflow-tooltip>
@@ -72,10 +72,10 @@
   import { ElTable } from 'element-plus';
   import { onBeforeMount, onMounted, ref } from 'vue';
   import { getNameByStateZJC } from './constant.question';
-  import { useIssueType } from '../../hooks/useIssueType';
+  import { useIssueMainType } from '../../hooks/useIssueMainType';
   import { useWorkLocation } from '../../hooks/useWorkLocation';
 
-  const { getAIOptions, getManualOptions, getNameByType } = useIssueType();
+  const { getAIMainOptions, getManualMainOptions, getNameByType } = useIssueMainType();
   const { locationOptions, getLocationOptions, getNameByWorkid } = useWorkLocation();
 
   const multipleTableRef = ref<InstanceType<typeof ElTable>>();
@@ -208,8 +208,8 @@
   defineExpose({ clearAll, updateCurRowChosen });
 
   onBeforeMount(() => {
-    getAIOptions();
-    getManualOptions();
+    getAIMainOptions();
+    getManualMainOptions();
     getLocationOptions();
   });
 

+ 17 - 16
src/views/datamanager/alertformdata/components/common/QueryFormSimple.vue

@@ -75,6 +75,7 @@
   const queryForm = reactive<TableQueryForm>({
     pageNumber: 1,
     pageSize: 10,
+    queryParam: {},
   });
 
   const issueTypeValue = ref([]);
@@ -97,10 +98,10 @@
     workLocation.value = [];
     tempState.value = '';
     dateRange.value = [];
-    Reflect.deleteProperty(queryForm, 'startTime');
-    Reflect.deleteProperty(queryForm, 'endTime');
-    Reflect.deleteProperty(queryForm, 'issueMainTypeList');
-    Reflect.deleteProperty(queryForm, 'issueTypeList');
+    Reflect.deleteProperty(queryForm.queryParam, 'startTime');
+    Reflect.deleteProperty(queryForm.queryParam, 'endTime');
+    Reflect.deleteProperty(queryForm.queryParam, 'issueMainTypeList');
+    Reflect.deleteProperty(queryForm.queryParam, 'issueTypeList');
     formRef.value?.resetFields();
     emits('onReset', queryForm);
   };
@@ -113,11 +114,11 @@
         arrMain.push(item[0]);
         arrSub.push(item[1]);
       });
-      queryForm.issueMainTypeList = [...new Set(arrMain)];
-      queryForm.issueTypeList = arrSub;
+      queryForm.queryParam.issueMainTypeList = [...new Set(arrMain)];
+      queryForm.queryParam.issueTypeList = arrSub;
     } else {
-      Reflect.deleteProperty(queryForm, 'issueMainTypeList');
-      Reflect.deleteProperty(queryForm, 'issueTypeList');
+      Reflect.deleteProperty(queryForm.queryParam, 'issueMainTypeList');
+      Reflect.deleteProperty(queryForm.queryParam, 'issueTypeList');
     }
   };
 
@@ -127,24 +128,24 @@
       workLocation.value.forEach((item) => {
         arr.push(item[1]);
       });
-      queryForm.workspaceId = arr;
+      queryForm.queryParam.workspaceId = arr;
     } else {
-      Reflect.deleteProperty(queryForm, 'workspaceId');
+      Reflect.deleteProperty(queryForm.queryParam, 'workspaceId');
     }
   };
 
   const handleIssueStateChange = () => {
-    if (tempState.value) queryForm.issueState = JSON.parse(tempState.value);
-    else Reflect.deleteProperty(queryForm, 'issueState');
+    if (tempState.value) queryForm.queryParam.issueState = JSON.parse(tempState.value);
+    else Reflect.deleteProperty(queryForm.queryParam, 'issueState');
   };
 
   const handleDateChange = () => {
     if (dateRange.value != null) {
-      queryForm.startTime = dateRange.value[0];
-      queryForm.endTime = dateRange.value[1];
+      queryForm.queryParam.startTime = dateRange.value[0];
+      queryForm.queryParam.endTime = dateRange.value[1];
     } else {
-      Reflect.deleteProperty(queryForm, 'startTime');
-      Reflect.deleteProperty(queryForm, 'endTime');
+      Reflect.deleteProperty(queryForm.queryParam, 'startTime');
+      Reflect.deleteProperty(queryForm.queryParam, 'endTime');
     }
   };
 </script>

+ 0 - 2
src/views/datamanager/alertformdata/components/default-simple/Default.vue

@@ -59,7 +59,6 @@
   import AlertTableSimple, { DataSourceItem } from '../common/AlertTableSimple.vue';
   import DetailDialog from '../common/DetailDialog.vue';
   import Pagination from '../common/Pagination.vue';
-  // import { useIssueType } from '../../hooks/useIssueType';
   import { useWorkLocation } from '../../hooks/useWorkLocation';
   import { useIssueMainType } from '../../hooks/useIssueMainType';
   import Prequalification from '../common/Prequalification.vue';
@@ -69,7 +68,6 @@
     deleteDefaultTableData,
   } from '@/api/datamanagement/alert-default';
 
-  // const { aiOptions, manualOptions, getAIOptions, getManualOptions } = useIssueType();
   const { locationOptions, getLocationOptions } = useWorkLocation();
   const { aiMainOptions, getAIMainOptions } = useIssueMainType();
 

+ 1 - 1
src/views/datamanager/alertformdata/components/default/Default.vue

@@ -485,9 +485,9 @@
   });
 
   onBeforeMount(() => {
-    getLocationOptions();
     getAIMainOptions();
     getManualMainOptions();
+    getLocationOptions();
   });
 </script>
 

+ 0 - 1
src/views/datamanager/alertformdata/components/show/Show.vue

@@ -77,7 +77,6 @@
   import Pagination from '../common/Pagination.vue';
   import AddDrawer from '../common/AddDrawer.vue';
   import EditDrawer from '../common/EditDrawer.vue';
-  // import { useIssueType } from '../../hooks/useIssueType';
   import { useWorkLocation } from '../../hooks/useWorkLocation';
   import { useIssueMainType } from '../../hooks/useIssueMainType';
   import {

+ 41 - 57
src/views/datamanager/alertformdata/hooks/useIssueMainType.ts

@@ -1,17 +1,8 @@
 import { ref } from 'vue';
-import { getAIMainList, getManualList } from '@/api/datamanagement/alert';
-import { questionMainTypeNameMap } from '@/views/datamanager/alertformdata/components/common/constant.question';
+import { getIssueTypeListWithMainType } from '@/api/datamanagement/alert';
+import { Source } from '@/views/datamanager/alertformdata/components/common/constant.question';
 
-type AIMainOption = {
-  value: number;
-  label: string;
-  children: {
-    value: number;
-    label: string;
-  }[];
-};
-
-type ManualMainOption = {
+type IssueMainTypeOption = {
   value: number;
   label: string;
   children: {
@@ -21,63 +12,56 @@ type ManualMainOption = {
 };
 
 export function useIssueMainType() {
-  // AI检测
-  const aiMainOptions = ref<AIMainOption[]>([]);
-  // 人工上报
-  const manualMainOptions = ref<ManualMainOption[]>([]);
+  const aiMainOptions = ref<IssueMainTypeOption[]>([]); // AI检测
+  const manualMainOptions = ref<IssueMainTypeOption[]>([]); // 人工上报
+
+  const processBackendData = (data): IssueMainTypeOption[] => {
+    return data.map((item) => ({
+      value: item.issueMainTypeId,
+      label: item.issueMainTypeName,
+      children: item.issueTypeList.map((child) => ({
+        value: child.issueTypeId,
+        label: child.issueTypeName,
+      })),
+    }));
+  };
 
   const getAIMainOptions = async () => {
-    await getAIMainList().then((res) => {
-      res.forEach((item) => {
-        // 找不到当前issueMainType,新建一个
-        if (
-          !aiMainOptions.value.find((x) => x.value === item.issueMainTypeId) &&
-          questionMainTypeNameMap[item.issueMainTypeId]
-        ) {
-          aiMainOptions.value.push({
-            value: item.issueMainTypeId,
-            label: questionMainTypeNameMap[item.issueMainTypeId],
-            children: [
-              {
-                value: item.issueTypeId,
-                label: item.issueTypeName,
-              },
-            ],
-          });
-        } else if (aiMainOptions.value.find((x) => x.value === item.issueMainTypeId)) {
-          const existingMainType = aiMainOptions.value.find(
-            (x) => x.value === item.issueMainTypeId,
-          )!;
-          existingMainType.children.push({
-            value: item.issueTypeId,
-            label: item.issueTypeName,
-          });
-        }
-      });
+    await getIssueTypeListWithMainType(Source.ai).then((res) => {
+      aiMainOptions.value = processBackendData(res);
     });
   };
 
-  const getManualMainOptions = () => {
-    getManualList().then((res) => {
-      res.forEach((item) => {
-        manualMainOptions.value.push({
-          value: item.id,
-          label: item.name,
-          children: [
-            {
-              value: item.id,
-              label: item.name,
-            },
-          ],
-        });
-      });
+  const getManualMainOptions = async () => {
+    await getIssueTypeListWithMainType(Source.manual).then((res) => {
+      manualMainOptions.value = processBackendData(res);
     });
   };
 
+  // 根据 问题来源id + 问题类型id 决定表格类型栏展示文字
+  const getNameByType = (source, mainType, subType) => {
+    const sourceTypeMap = {
+      [Source.ai]: aiMainOptions,
+      [Source.manual]: manualMainOptions,
+    };
+    const targetArray = sourceTypeMap[source];
+    if (targetArray) {
+      const foundObject = targetArray.value.find((obj) => obj.value === mainType);
+      if (foundObject) {
+        const subObj = foundObject.children.find((sub) => sub.value === subType);
+        if (subObj) return subObj.label;
+        return '-';
+      }
+      return '-';
+    }
+    return '-';
+  };
+
   return {
     aiMainOptions,
     manualMainOptions,
     getAIMainOptions,
     getManualMainOptions,
+    getNameByType,
   };
 }

+ 21 - 41
src/views/datamanager/alertformdata/hooks/useIssueType.ts

@@ -1,58 +1,39 @@
+/**
+ * @description: 用于展示数据-添加-问题类型选择-可选项
+ */
 import { ref } from 'vue';
-import { getAIList, getManualList } from '@/api/datamanagement/alert'
+import { getIssueSubTypeList } from '@/api/datamanagement/alert';
 import { Source } from '../components/common/constant.question';
 
-type AIOption = {
-  id: number
-  name: string
-};
-
-type ManualOption = {
-  id: number
-  name: string
+type IssueOptionType = {
+  id: number;
+  name: string;
 };
 
 export function useIssueType() {
-  // AI检测
-  const aiOptions = ref<AIOption[]>([]);
-  // 人工上报
-  const manualOptions = ref<ManualOption[]>([]);
+  const aiOptions = ref<IssueOptionType[]>([]); // AI检测
+  const manualOptions = ref<IssueOptionType[]>([]); // 人工上报
 
   const getAIOptions = () => {
-    getAIList().then((res) => {
+    getIssueSubTypeList(Source.ai).then((res) => {
       res.forEach((item) => {
         aiOptions.value.push({
-          id: item.id,
-          name: item.name
-        })
+          id: item.issueTypeId,
+          name: item.issueTypeName,
+        });
       });
-    })
+    });
   };
 
   const getManualOptions = () => {
-    getManualList().then((res) => {
+    getIssueSubTypeList(Source.manual).then((res) => {
       res.forEach((item) => {
         manualOptions.value.push({
-          id: item.id,
-          name: item.name
-        })
-      })
-    })
-  };
-
-  // 根据 问题来源id + 问题类型id 决定表格类型栏展示文字
-  const getNameByType = (source, type) => {
-    const sourceTypeMap = {
-      [Source.ai]: aiOptions,
-      [Source.manual]: manualOptions,
-    }
-    const targetArray = sourceTypeMap[source];
-    if (targetArray) {
-      const foundObject = targetArray.value.find(obj => obj.id === type);
-      if (foundObject) return foundObject.name;
-      return '-'
-    }
-    return '-'
+          id: item.issueTypeId,
+          name: item.issueTypeName,
+        });
+      });
+    });
   };
 
   return {
@@ -60,6 +41,5 @@ export function useIssueType() {
     manualOptions,
     getAIOptions,
     getManualOptions,
-    getNameByType
   };
-}
+}