|
|
@@ -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,
|
|
|
};
|
|
|
}
|