Bläddra i källkod

[Wip 0000] 算法模型编辑表单改版

Co-authored-by: Copilot <copilot@github.com>
houzekong 1 vecka sedan
förälder
incheckning
88234e02ee

+ 45 - 12
src/views/system/algorithm/algorithm.api.ts

@@ -1,6 +1,7 @@
 import { defHttp } from '/@/utils/http/axios';
 import { forEach, isNil, map } from 'lodash-es';
 import { isObject } from '/@/utils/is';
+import { limitationModel } from './algorithm.data';
 // import { getEnfMineTree } from '/@/api/sys/menu';
 
 enum Api {
@@ -55,28 +56,60 @@ export function deleteGoafDataLimit(params: any) {
   return defHttp.post({ url: Api.deleteGoafDataLimit, params }, { joinParamsToUrl: true });
 }
 
-export function patchGoafDataLimit(params: Record<string, any>) {
-  const normalParams: any = {};
+function processLimitParams(params: Record<string, any>, add, edit) {
   const objectParams: any = {};
 
   forEach(params, (item, key) => {
     if (isObject(item)) {
       objectParams[key] = item;
-    } else {
-      normalParams[key] = item;
     }
   });
-  console.log('debug rrr', normalParams);
-  return Promise.all([
-    ...map(objectParams, (item) => {
+
+  return Promise.all(
+    map(objectParams, (item) => {
       if (item.id) {
-        return updateGoafDataLimit(item);
+        return edit(item);
       }
       if (!isNil(item.lowerLimit) || !isNil(item.upperLimit)) {
-        return addGoafDataLimit(item);
+        return add(item);
       }
       return Promise.resolve();
-    }),
-    updateGoaf(normalParams),
-  ]);
+    })
+  );
+}
+
+export function patchGoafLimit(params: Record<string, any>) {
+  return processLimitParams(params, addGoafDataLimit, updateGoafDataLimit);
+}
+
+export function patchCoalLimit(params: Record<string, any>) {
+  return processLimitParams(params, addGoafDataLimit, updateGoafDataLimit);
+}
+
+function processLimitation(extra: Record<string, any>, data: any[]) {
+  const result: any = {};
+  forEach(limitationModel, (item, key) => {
+    result[key] = { ...extra, ...item };
+  });
+  forEach(data, (item) => {
+    result[item.alarmField] = item;
+  });
+
+  return result;
+}
+
+export function fetchGoafLimit(goafId: string, mineCode?: string) {
+  return getGoafDataLimit({ goafId, mineCode }).then((r) => {
+    return processLimitation({ goafId, mineCode }, r);
+  });
+}
+
+export function fetchCoalLimit(goafId: string, mineCode?: string) {
+  return getGoafDataLimit({ goafId, mineCode }).then((r) => {
+    return processLimitation({ goafId, mineCode }, r);
+  });
+}
+
+export function patchCoalSeamAlarmRule(params) {
+  return params.id ? updateCoalSeamAlarmRule(params) : addCoalSeamAlarmRule(params);
 }

+ 125 - 458
src/views/system/algorithm/algorithm.data.ts

@@ -75,433 +75,7 @@ export const searchFormSchema: FormSchema[] = [
   },
 ];
 
-export const schemasCoalAlarm: FormSchema[] = [
-  // "mineCode": null,
-  // "coalSeamId": null,
-  {
-    label: 'ID',
-    field: 'id',
-    show: false,
-    component: 'Input',
-  },
-  {
-    label: '规则名称:',
-    field: 'ruleName',
-    labelWidth: 118,
-    component: 'Input',
-
-    colProps: { span: 24 },
-  },
-  {
-    field: 'm1',
-    label: '老空区永久密闭内外压差变化风险提示模型',
-    // labelWidth: 110,
-    component: 'Divider',
-  },
-  {
-    field: 'ycWarn1',
-    label: '预警等级(Ⅰ):',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputRangeNumber',
-    /** 借用 */
-    groupName: '<= 绝对压差变化(%) <=',
-    colProps: { span: 12 },
-  },
-  { field: 'ycWarn1Start', label: '', show: false, component: 'Input' },
-  { field: 'ycWarn1End', label: '', show: false, component: 'Input' },
-  {
-    field: 'ycWarn2',
-    label: '预警等级(Ⅱ):',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputRangeNumber',
-    /** 借用 */
-    groupName: '<= 绝对压差变化(%) <=',
-    colProps: { span: 12 },
-  },
-  { field: 'ycWarn2Start', label: '', show: false, component: 'Input' },
-  { field: 'ycWarn2End', label: '', show: false, component: 'Input' },
-  {
-    field: 'ycWarn3',
-    label: '预警等级(Ⅲ):',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputRangeNumber',
-    /** 借用 */
-    groupName: '<= 绝对压差变化(%) <=',
-    colProps: { span: 12 },
-  },
-  { field: 'ycWarn3Start', label: '', show: false, component: 'Input' },
-  { field: 'ycWarn3End', label: '', show: false, component: 'Input' },
-  {
-    field: 'ycWarn4',
-    label: '预警等级(Ⅳ):',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputGreaterNumber',
-    /** 借用 */
-    groupName: '  绝对压差变化(%) <=',
-    colProps: { span: 12 },
-  },
-  // { field: 'ycWarn4', label: '', show: false, component: 'Input' },
-  {
-    field: 'm2',
-    label: '煤自燃发火隐患分级预警模型',
-    // labelWidth: 110,
-    component: 'Divider',
-  },
-  // {
-  //   field: 'fireWarn1CoRzl',
-  //   label: '预警等级(Ⅰ):',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputGreaterNumber',
-  //   /** 借用 */
-  //   groupName: '  CO日增率(%) <=',
-  //   colProps: { span: 12 },
-  // },
-  // // { field: 'fireWarn1CoRzl', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn1CoZf',
-  //   label: ' ',
-  //   suffix: '',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputGreaterNumber',
-  //   /** 借用 */
-  //   groupName: '  CO增幅(μ) <=',
-  //   colProps: { span: 12 },
-  // },
-  // // { field: 'fireWarn1CoZf', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn1CoNd',
-    label: '预警等级(Ⅰ):',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputGreaterNumber',
-    /** 借用 */
-    groupName: '  CO浓度(ppm) <=',
-    colProps: { span: 12 },
-  },
-  // { field: 'fireWarn1CoNd', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn1O2',
-    label: ' ',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputGreaterNumber',
-    /** 借用 */
-    groupName: '  O2(%) <=',
-    colProps: { span: 12 },
-  },
-  // { field: 'fireWarn1O2', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn1T',
-    label: ' ',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputGreaterNumber',
-    /** 借用 */
-    groupName: '  T-μT(℃) <',
-    colProps: { span: 12, style: 'margin-right: 1px' },
-  },
-  // { field: 'fireWarn1T', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn2CoRzl',
-  //   label: '预警等级(Ⅱ):',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputRangeNumber',
-  //   /** 借用 */
-  //   groupName: '< CO日增率(%) <=',
-  //   colProps: { span: 12 },
-  // },
-  // { field: 'fireWarn2CoRzlStart', label: '', show: false, component: 'Input' },
-  // { field: 'fireWarn2CoRzlEnd', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn2CoZf',
-  //   label: ' ',
-  //   suffix: '',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputRangeNumber',
-  //   /** 借用 */
-  //   groupName: '< CO增幅(μ) <=',
-  //   colProps: { span: 12 },
-  // },
-  // { field: 'fireWarn2CoZfStart', label: '', show: false, component: 'Input' },
-  // { field: 'fireWarn2CoZfEnd', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn2CoNd',
-    label: '预警等级(Ⅱ):',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputRangeNumber',
-    /** 借用 */
-    groupName: '< CO浓度(ppm) <=',
-    colProps: { span: 12 },
-  },
-  { field: 'fireWarn2CoNdStart', label: '', show: false, component: 'Input' },
-  { field: 'fireWarn2CoNdEnd', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn2T',
-    label: ' ',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputRangeNumber',
-    /** 借用 */
-    groupName: '<= T-μT(℃) <=',
-    colProps: { span: 12 },
-  },
-  { field: 'fireWarn2TStart', label: '', show: false, component: 'Input' },
-  { field: 'fireWarn2TEnd', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn2CoO2Ratio',
-  //   label: ' ',
-  //   suffix: '',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputRangeNumber',
-  //   /** 借用 */
-  //   groupName: '<  100 x ΔCO / ΔO2  =',
-  //   colProps: { span: 12, style: 'margin-right: 1px' },
-  // },
-  // { field: 'fireWarn2CoO2RatioStart', label: '', show: false, component: 'Input' },
-  // { field: 'fireWarn2CoO2RatioEnd', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn3CoRzl',
-  //   label: '预警等级(Ⅲ):',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputRangeNumber',
-  //   /** 借用 */
-  //   groupName: '< CO日增率(%) <=',
-  //   colProps: { span: 12 },
-  // },
-  // { field: 'fireWarn3CoRzlStart', label: '', show: false, component: 'Input' },
-  // { field: 'fireWarn3CoRzlEnd', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn3CoZf',
-  //   label: ' ',
-  //   suffix: '',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputRangeNumber',
-  //   /** 借用 */
-  //   groupName: '< CO增幅(μ) <=',
-  //   colProps: { span: 12 },
-  // },
-  // { field: 'fireWarn3CoZfStart', label: '', show: false, component: 'Input' },
-  // { field: 'fireWarn3CoZfEnd', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn3CoNd',
-    label: '预警等级(Ⅲ):',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputRangeNumber',
-    /** 借用 */
-    groupName: '< CO浓度(ppm) <=',
-    colProps: { span: 12 },
-  },
-  { field: 'fireWarn3CoNdStart', label: '', show: false, component: 'Input' },
-  { field: 'fireWarn3CoNdEnd', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn3T',
-    label: ' ',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputRangeNumber',
-    /** 借用 */
-    groupName: '< T-μT(℃) <=',
-    colProps: { span: 12 },
-  },
-  { field: 'fireWarn3TStart', label: '', show: false, component: 'Input' },
-  { field: 'fireWarn3TEnd', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn3CoO2Ratio',
-  //   label: ' ',
-  //   suffix: '',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputRangeNumber',
-  //   /** 借用 */
-  //   groupName: '<  100 x ΔCO / ΔO2  =',
-  //   colProps: { span: 12 },
-  // },
-  // { field: 'fireWarn3CoO2RatioStart', label: '', show: false, component: 'Input' },
-  // { field: 'fireWarn3CoO2RatioEnd', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn3C2h4',
-    label: ' ',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputLowerNumber',
-    /** 借用 */
-    groupName: '< C2H4(ppm)  ',
-    colProps: { span: 12 },
-  },
-  {
-    field: 'fireWarn3C2h2',
-    label: ' ',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputLowerNumber',
-    /** 借用 */
-    groupName: '= C2H2(ppm)  ',
-    colProps: { span: 12 },
-  },
-  // {
-  //   field: 'fireWarn4CoRzl',
-  //   label: '预警等级(Ⅳ):',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputLowerNumber',
-  //   /** 借用 */
-  //   groupName: '< CO日增率(%)  ',
-  //   colProps: { span: 12 },
-  // },
-  // // { field: 'fireWarn4CoRzl', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn4CoZf',
-  //   label: ' ',
-  //   suffix: '',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputLowerNumber',
-  //   /** 借用 */
-  //   groupName: '< CO增幅(μ)  ',
-  //   colProps: { span: 12 },
-  // },
-  // { field: 'fireWarn4CoZf', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn4CoNd',
-    label: '预警等级(Ⅳ):',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputLowerNumber',
-    /** 借用 */
-    groupName: '< CO浓度(ppm)  ',
-    colProps: { span: 12 },
-  },
-  // { field: 'fireWarn4CoNd', label: '', show: false, component: 'Input' },
-  {
-    field: 'fireWarn4T',
-    label: ' ',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputLowerNumber',
-    /** 借用 */
-    groupName: '< T-μT(℃)  ',
-    colProps: { span: 12 },
-  },
-  // { field: 'fireWarn4T', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn4CoO2Ratio',
-  //   label: ' ',
-  //   suffix: '',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputRangeNumber',
-  //   /** 借用 */
-  //   groupName: '<  100 x ΔCO / ΔO2  =',
-  //   colProps: { span: 12 },
-  // },
-  // { field: 'fireWarn4CoO2RatioStart', label: '', show: false, component: 'Input' },
-  // { field: 'fireWarn4CoO2RatioEnd', label: '', show: false, component: 'Input' },
-  // {
-  //   field: 'fireWarn4C2h4',
-  //   label: ' ',
-  //   suffix: '',
-  //   labelWidth: 118,
-  //   component: 'Input',
-  //   slot: 'InputLowerNumber',
-  //   /** 借用 */
-  //   groupName: '< C2H4(ppm)  ',
-  //   colProps: { span: 12 },
-  // },
-  {
-    field: 'fireWarn4C2h2',
-    label: ' ',
-    suffix: '',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputLowerNumber',
-    /** 借用 */
-    groupName: '< C2H2(ppm)  ',
-    colProps: { span: 12 },
-  },
-  {
-    field: 'm3',
-    label: '火区密闭启封判定模型',
-    // labelWidth: 110,
-    component: 'Divider',
-  },
-  // { field: 'ycWarn4', label: '', show: false, component: 'Input' },
-  {
-    field: 'openWarn1',
-    label: '预警等级(Ⅰ):',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputGreaterNumber',
-    /** 借用 */
-    groupName: '  空气温度(℃) <',
-    colProps: { span: 12 },
-  },
-  {
-    field: 'openWarn2',
-    label: '预警等级(Ⅱ):',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputGreaterNumber',
-    /** 借用 */
-    groupName: '  氧气浓度(%) <',
-    colProps: { span: 12 },
-  },
-  {
-    field: 'openWarn3',
-    label: '预警等级(Ⅲ):',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputGreaterNumber',
-    /** 借用 */
-    groupName: '不含甲烷,乙烯,CO浓度(%) <',
-    colProps: { span: 12 },
-  },
-  {
-    field: 'openWarn4',
-    label: '预警等级(Ⅳ):',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputGreaterNumber',
-    /** 借用 */
-    groupName: '  出水温度(℃) <',
-    colProps: { span: 12 },
-  },
-  {
-    field: 'openWarn5',
-    label: '预警等级(Ⅴ):',
-    labelWidth: 118,
-    component: 'Input',
-    slot: 'InputLowerNumber',
-    /** 借用 */
-    groupName: '< 指标稳定时长(天)  ',
-    colProps: { span: 12 },
-  },
-];
-
-export const goafAlarmModel = {
+export const limitationModel = {
   ch4Val: {
     alarmField: 'ch4Val',
     lowerLimit: undefined,
@@ -544,7 +118,7 @@ export const goafAlarmModel = {
   },
 };
 
-export const schemasGoafLimit: FormSchema[] = [
+export const schemasGoafInfo: FormSchema[] = [
   {
     field: 'id',
     label: 'ID',
@@ -557,14 +131,14 @@ export const schemasGoafLimit: FormSchema[] = [
     field: 'fireAirTemperature',
     label: '气温',
     labelWidth: 118,
-    component: 'InputNumber',
+    component: 'Input',
     // colProps: { span: 12 },
   },
   {
     field: 'fireWaterTemperature',
     label: '水温',
     labelWidth: 118,
-    component: 'InputNumber',
+    component: 'Input',
     // colProps: { span: 12 },
   },
   {
@@ -602,13 +176,9 @@ export const schemasGoafLimit: FormSchema[] = [
     component: 'Input',
     // colProps: { span: 12 },
   },
-  {
-    field: '',
-    label: '参数设置',
-    labelWidth: 118,
-    component: 'Divider',
-    // colProps: { span: 12 },
-  },
+];
+
+export const schemasGoafLimit: FormSchema[] = [
   {
     // 甲烷
     field: 'ch4Val',
@@ -616,7 +186,7 @@ export const schemasGoafLimit: FormSchema[] = [
     labelWidth: 118,
     component: 'Input',
     slot: 'InputRangeGoaf',
-    defaultValue: goafAlarmModel.ch4Val,
+    defaultValue: limitationModel.ch4Val,
     /** 借用 */
     groupName: '下限 - 上限',
     colProps: { span: 12 },
@@ -628,7 +198,7 @@ export const schemasGoafLimit: FormSchema[] = [
     labelWidth: 118,
     component: 'Input',
     slot: 'InputRangeGoaf',
-    defaultValue: goafAlarmModel.o2Val,
+    defaultValue: limitationModel.o2Val,
     /** 借用 */
     groupName: '下限 - 上限',
     colProps: { span: 12 },
@@ -640,7 +210,7 @@ export const schemasGoafLimit: FormSchema[] = [
     labelWidth: 118,
     component: 'Input',
     slot: 'InputRangeGoaf',
-    defaultValue: goafAlarmModel.coVal,
+    defaultValue: limitationModel.coVal,
     /** 借用 */
     groupName: '下限 - 上限',
     colProps: { span: 12 },
@@ -652,7 +222,7 @@ export const schemasGoafLimit: FormSchema[] = [
     labelWidth: 118,
     component: 'Input',
     slot: 'InputRangeGoaf',
-    defaultValue: goafAlarmModel.co2Val,
+    defaultValue: limitationModel.co2Val,
     /** 借用 */
     groupName: '下限 - 上限',
     colProps: { span: 12 },
@@ -664,7 +234,7 @@ export const schemasGoafLimit: FormSchema[] = [
     labelWidth: 118,
     component: 'Input',
     slot: 'InputRangeGoaf',
-    defaultValue: goafAlarmModel.c2h4Val,
+    defaultValue: limitationModel.c2h4Val,
     /** 借用 */
     groupName: '下限 - 上限',
     colProps: { span: 12 },
@@ -676,7 +246,7 @@ export const schemasGoafLimit: FormSchema[] = [
     labelWidth: 118,
     component: 'Input',
     slot: 'InputRangeGoaf',
-    defaultValue: goafAlarmModel.c2h2Val,
+    defaultValue: limitationModel.c2h2Val,
     /** 借用 */
     groupName: '下限 - 上限',
     colProps: { span: 12 },
@@ -687,7 +257,7 @@ export const schemasGoafLimit: FormSchema[] = [
     labelWidth: 118,
     component: 'Input',
     slot: 'InputRangeGoaf',
-    defaultValue: goafAlarmModel.sourcePressure,
+    defaultValue: limitationModel.sourcePressure,
     /** 借用 */
     groupName: '下限 - 上限',
     colProps: { span: 12 },
@@ -698,7 +268,7 @@ export const schemasGoafLimit: FormSchema[] = [
     labelWidth: 118,
     component: 'Input',
     slot: 'InputRangeGoaf',
-    defaultValue: goafAlarmModel.temperature,
+    defaultValue: limitationModel.temperature,
     /** 借用 */
     groupName: '下限 - 上限',
     colProps: { span: 12 },
@@ -729,7 +299,7 @@ export const schemasCoalExpression: FormSchema[] = [
     component: 'Divider',
   },
   {
-    field: 'yc_warn1',
+    field: 'ycWarn1',
     label: '预警等级(Ⅰ):',
     labelWidth: 118,
     component: 'Input',
@@ -737,21 +307,21 @@ export const schemasCoalExpression: FormSchema[] = [
     // required: true,
   },
   {
-    field: 'yc_warn2',
+    field: 'ycWarn2',
     label: '预警等级(Ⅱ):',
     labelWidth: 118,
     component: 'Input',
     slot: 'relation',
   },
   {
-    field: 'yc_warn3',
+    field: 'ycWarn3',
     label: '预警等级(Ⅲ):',
     labelWidth: 118,
     component: 'Input',
     slot: 'relation',
   },
   {
-    field: 'yc_warn4',
+    field: 'ycWarn4',
     label: '预警等级(Ⅳ):',
     labelWidth: 118,
     component: 'Input',
@@ -764,7 +334,7 @@ export const schemasCoalExpression: FormSchema[] = [
     component: 'Divider',
   },
   {
-    field: 'fire_warn1',
+    field: 'fireWarn1',
     label: '预警等级(Ⅰ):',
     suffix: '',
     labelWidth: 118,
@@ -772,7 +342,7 @@ export const schemasCoalExpression: FormSchema[] = [
     slot: 'relation',
   },
   {
-    field: 'fire_warn2',
+    field: 'fireWarn2',
     label: '预警等级(Ⅱ):',
     suffix: '',
     labelWidth: 118,
@@ -780,7 +350,7 @@ export const schemasCoalExpression: FormSchema[] = [
     slot: 'relation',
   },
   {
-    field: 'fire_warn3',
+    field: 'fireWarn3',
     label: '预警等级(Ⅲ):',
     suffix: '',
     labelWidth: 118,
@@ -788,7 +358,7 @@ export const schemasCoalExpression: FormSchema[] = [
     slot: 'relation',
   },
   {
-    field: 'fire_warn4',
+    field: 'fireWarn4',
     label: '预警等级(Ⅳ):',
     suffix: '',
     labelWidth: 118,
@@ -802,38 +372,135 @@ export const schemasCoalExpression: FormSchema[] = [
     component: 'Divider',
   },
   {
-    field: 'fire_out_warn1',
+    field: 'fireOutWarn1',
     label: '预警等级(Ⅰ):',
     labelWidth: 118,
     component: 'Input',
     slot: 'relation',
   },
   {
-    field: 'fire_out_warn2',
+    field: 'fireOutWarn2',
     label: '预警等级(Ⅱ):',
     labelWidth: 118,
     component: 'Input',
     slot: 'relation',
   },
   {
-    field: 'fire_out_warn3',
+    field: 'fireOutWarn3',
     label: '预警等级(Ⅲ):',
     labelWidth: 118,
     component: 'Input',
     slot: 'relation',
   },
   {
-    field: 'fire_out_warn4',
+    field: 'fireOutWarn4',
     label: '预警等级(Ⅳ):',
     labelWidth: 118,
     component: 'Input',
     slot: 'relation',
   },
   {
-    field: 'open_warn',
+    field: 'openWarn',
     label: '火区密闭启封判定:',
     labelWidth: 118,
     component: 'Input',
     slot: 'relation',
   },
 ];
+
+export const schemasCoalLimit: FormSchema[] = [
+  {
+    // 甲烷
+    field: 'ch4Val',
+    label: 'CH4(%)',
+    labelWidth: 118,
+    component: 'Input',
+    slot: 'InputRangeGoaf',
+    defaultValue: limitationModel.ch4Val,
+    /** 借用 */
+    groupName: '下限 - 上限',
+    colProps: { span: 12 },
+  },
+  {
+    // 氧气
+    field: 'o2Val',
+    label: 'O2(%)',
+    labelWidth: 118,
+    component: 'Input',
+    slot: 'InputRangeGoaf',
+    defaultValue: limitationModel.o2Val,
+    /** 借用 */
+    groupName: '下限 - 上限',
+    colProps: { span: 12 },
+  },
+  {
+    // 一氧化碳
+    field: 'coVal',
+    label: 'CO(ppm)',
+    labelWidth: 118,
+    component: 'Input',
+    slot: 'InputRangeGoaf',
+    defaultValue: limitationModel.coVal,
+    /** 借用 */
+    groupName: '下限 - 上限',
+    colProps: { span: 12 },
+  },
+  {
+    // 二氧化碳
+    field: 'co2Val',
+    label: 'CO2(%)',
+    labelWidth: 118,
+    component: 'Input',
+    slot: 'InputRangeGoaf',
+    defaultValue: limitationModel.co2Val,
+    /** 借用 */
+    groupName: '下限 - 上限',
+    colProps: { span: 12 },
+  },
+  {
+    // 乙烯
+    field: 'c2h4Val',
+    label: 'C2H4(ppm)',
+    labelWidth: 118,
+    component: 'Input',
+    slot: 'InputRangeGoaf',
+    defaultValue: limitationModel.c2h4Val,
+    /** 借用 */
+    groupName: '下限 - 上限',
+    colProps: { span: 12 },
+  },
+  {
+    // 乙炔
+    field: 'c2h2Val',
+    label: 'C2H2(ppm)',
+    labelWidth: 118,
+    component: 'Input',
+    slot: 'InputRangeGoaf',
+    defaultValue: limitationModel.c2h2Val,
+    /** 借用 */
+    groupName: '下限 - 上限',
+    colProps: { span: 12 },
+  },
+  {
+    field: 'sourcePressure',
+    label: '压差(Pa)',
+    labelWidth: 118,
+    component: 'Input',
+    slot: 'InputRangeGoaf',
+    defaultValue: limitationModel.sourcePressure,
+    /** 借用 */
+    groupName: '下限 - 上限',
+    colProps: { span: 12 },
+  },
+  {
+    field: 'temperature',
+    label: '温度(℃)',
+    labelWidth: 118,
+    component: 'Input',
+    slot: 'InputRangeGoaf',
+    defaultValue: limitationModel.temperature,
+    /** 借用 */
+    groupName: '下限 - 上限',
+    colProps: { span: 12 },
+  },
+];

+ 135 - 116
src/views/system/algorithm/RelationBuilder.vue → src/views/system/algorithm/components/RelationBuilder.vue

@@ -1,16 +1,16 @@
 <template>
   <div class="relation-builder">
-    <a-input-group v-if="compact" compact>
-      <a-textarea
-        :value="modelValue"
-        style="width: calc(100% - 100px)"
-        placeholder="例如: CO > 0 && CO2 > 0"
-        allow-clear
-        auto-size
-        @update:value="emit('update:modelValue', $event)"
-      />
+    <div class="w-full flex justify-between mb-10px" v-if="compact">
+      <a-space style="width: calc(100% - 100px)" wrap>
+        <template v-for="(item, index) in items" :key="index">
+          <a-input-number v-if="item.type === 'number'" v-model:value="item.value" style="width: 30px" placeholder="-" @blur="confirm" />
+          <a-tag v-if="item.type === 'operand' || item.type === 'logic' || item.type === 'operator'" :color="tagColors[item.type]" class="expr-tag">
+            {{ formatDisplay(item) }}
+          </a-tag>
+        </template>
+      </a-space>
       <a-button class="w-100px" type="primary" @click="enterAdvancedMode"> 高级编辑 </a-button>
-    </a-input-group>
+    </div>
     <a-row v-else :gutter="8">
       <!-- 左侧:元素库 -->
       <a-col :span="12">
@@ -18,6 +18,7 @@
           <a-collapse class="relation-card" v-model:activeKey="activeKey" :bordered="false">
             <a-collapse-panel v-for="group in elementGroups" :key="group.key" :header="group.header">
               <div class="chip-container">
+                <!-- @dragstart="onDragStart($event, item)" -->
                 <div
                   v-for="item in group.items"
                   :key="item.value"
@@ -25,7 +26,6 @@
                   :class="`chip-${group.type}`"
                   draggable="true"
                   @click="appendItem(item)"
-                  @dragstart="onDragStart($event, item)"
                 >
                   {{ item.label }}
                 </div>
@@ -34,9 +34,8 @@
                 <div v-for="item in group.extra" :key="item.type" class="mt-8px">
                   <a-input-number v-model:value="item.value" :defaultValue="0">
                     <template #addonAfter>
-                      <span style="cursor: pointer" draggable="true" @click="appendItem(item)" @dragstart="onDragStart($event, item)">
-                        追加 | 插入
-                      </span>
+                      <!-- @dragstart="onDragStart($event, item)" -->
+                      <span style="cursor: pointer" draggable="true" @click="appendItem(item)"> 追加 </span>
                     </template>
                   </a-input-number>
                 </div>
@@ -45,7 +44,7 @@
           </a-collapse>
           <template #actions>
             <div class="relation-card-footer">
-              <a-typography-text class="pt-6px pb-6px" type="secondary"> <InfoCircleOutlined /> 点击追加 | 拖拽插入 </a-typography-text>
+              <a-typography-text class="pt-6px pb-6px" type="secondary"> <InfoCircleOutlined /> 点击追加元素 </a-typography-text>
             </div>
           </template>
         </a-card>
@@ -63,7 +62,8 @@
           </template>
 
           <div class="relation-card">
-            <div class="canvas-container" :class="{ 'drag-over': isDragOver }" @dragover.prevent="onDragOver" @dragleave="onDragLeave" @drop="onDrop">
+            <!-- :class="{ 'drag-over': isDragOver }" @dragover.prevent="onDragOver" @dragleave="onDragLeave"  @drop="onDrop"-->
+            <div class="canvas-container">
               <a-empty v-if="!items.length" description="从左侧点击或拖拽元素" />
               <div v-else class="expression-list">
                 <a-tag v-for="(item, index) in items" :key="index" :color="tagColors[item.type]" class="expr-tag" closable @close="removeItem(index)">
@@ -113,6 +113,7 @@
   import { ref, computed, watch, h } from 'vue';
   import { cloneDeep } from 'lodash-es';
   import { message, Modal } from 'ant-design-vue';
+  import { DeleteOutlined } from '@ant-design/icons-vue';
 
   // 类型定义
   interface Item {
@@ -129,29 +130,9 @@
     extra: Item[];
   }
 
-  const props = defineProps<{ modelValue: string }>();
-  const emit = defineEmits<{
-    (e: 'update:modelValue', value: string): void;
-    (e: 'change', value: string): void;
-    (e: 'confirm', value: string): void;
-  }>();
-
-  // 模式状态
-  const compact = ref<boolean>(true);
-  // 表达式字符串,配合画布显示
-  const inputString = ref<string>('');
-  // 高级模式画布数据
-  const items = ref<Item[]>([]);
-  // 手动输入区域绑定
-  const manualInput = ref<string>('');
-  // 错误信息
-  const errorMessage = ref<string>('');
-  // 模板选择值
-  const selectedTemplate = ref<string>('');
-
+  // 常量配置
   const activeKey = ref<string[]>(['gas', 'operator', 'logic', 'number', 'paren']);
 
-  // 模板配置
   const templateOptions = ref([
     { label: '压差预警1', value: '20<=sourcePressureChange && sourcePressureChange<=40' },
     { label: '压差预警2', value: '40<sourcePressureChange && sourcePressureChange<=60' },
@@ -183,7 +164,6 @@
     },
   ]);
 
-  // 元素库配置
   const elementGroups: ElementGroup[] = [
     {
       key: 'gas',
@@ -267,7 +247,6 @@
     },
   ];
 
-  // 标签颜色映射(供模板使用)
   const tagColors: Record<string, string> = {
     operand: 'blue',
     operator: 'green',
@@ -276,6 +255,7 @@
     leftParen: 'default',
     rightParen: 'default',
   };
+
   const displayMap: Record<string, string> = {
     '&&': '且',
     '||': '或',
@@ -300,15 +280,26 @@
     stableDays: '稳定天数',
   };
 
-  // 当前画布表达式字符串
-  const expressionString = computed(() => items.value.map((i) => i.value).join(' '));
+  // Props 和 Emits
+  const props = defineProps<{ modelValue: string }>();
+  const emit = defineEmits<{
+    (e: 'update:modelValue', value: string): void;
+    (e: 'change', value: string): void;
+    (e: 'confirm', value: string): void;
+  }>();
 
-  // 格式化显示
-  const formatDisplay = (item: Item): string => {
-    if (item.type === 'number') return item.value;
-    return displayMap[item.value] || item.value;
-  };
+  // Reactive 状态
+  const compact = ref<boolean>(true);
+  const inputString = ref<string>('');
+  const items = ref<Item[]>([]);
+  const manualInput = ref<string>('');
+  const errorMessage = ref<string>('');
+  const selectedTemplate = ref<string>('');
 
+  // Computed
+  const expressionString = computed(() => items.value.map((i) => i.value).join(' '));
+
+  // 工具函数
   const buildOperandSet = (): Set<string> => {
     const set = new Set<string>();
     elementGroups.forEach((group) => {
@@ -317,23 +308,52 @@
     return set;
   };
 
+  const formatDisplay = (item: Item): string => {
+    if (item.type === 'number') return item.value;
+    if (compact.value) {
+      return item.type === 'operand' || item.type === 'operator' ? displayMap[item.value] || item.value : '|';
+    } else {
+      return displayMap[item.value] || item.value;
+    }
+  };
+
   const parseExpression = (str: string): Item[] => {
     if (!str?.trim()) return [];
     const operandSet = buildOperandSet();
     const operandPattern = [...operandSet].map((v) => v.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
-    const regex = new RegExp(`(${operandPattern}|\\d+(?:\\.\\d+)?|==|>=|<=|[>+\\-*/<]|&&|\\|\\||[()])`, 'g');
-    const tokens = str.match(regex) || [];
-    return tokens
-      .map((t) => {
-        if (t === '(') return { type: 'leftParen', value: '(' } as Item;
-        if (t === ')') return { type: 'rightParen', value: ')' } as Item;
-        if (t === '&&' || t === '||') return { type: 'logic', value: t } as Item;
-        if (['>', '>=', '<', '<=', '==', '+', '-', '*', '/'].includes(t)) return { type: 'operator', value: t } as Item;
-        if (operandSet.has(t)) return { type: 'operand', value: t } as Item;
-        if (/^\d+(\.\d+)?$/.test(t)) return { type: 'number', value: t } as Item;
-        return null;
-      })
-      .filter((item): item is Item => item !== null);
+    const regex = new RegExp(`(${operandPattern}|==|>=|<=|&&|\\|\\||-?\\d+(?:\\.\\d+)?|[>+\\-*/<()])`, 'g');
+    const rawTokens = str.match(regex) || [];
+    const tokens = rawTokens.map((t) => t.trim()).filter((t) => t !== '');
+
+    const items: Item[] = [];
+    for (const token of tokens) {
+      if (token === '(') {
+        items.push({ type: 'leftParen', value: '(' });
+        continue;
+      }
+      if (token === ')') {
+        items.push({ type: 'rightParen', value: ')' });
+        continue;
+      }
+      if (token === '&&' || token === '||') {
+        items.push({ type: 'logic', value: token });
+        continue;
+      }
+      if (['>', '>=', '<', '<=', '==', '+', '-', '*', '/'].includes(token)) {
+        items.push({ type: 'operator', value: token });
+        continue;
+      }
+      if (operandSet.has(token)) {
+        items.push({ type: 'operand', value: token });
+        continue;
+      }
+      if (/^-?\d+(?:\.\d+)?$/.test(token)) {
+        items.push({ type: 'number', value: token });
+        continue;
+      }
+    }
+
+    return items;
   };
 
   // 初始化:将表达式字符串同步到画布与内部状态
@@ -369,42 +389,42 @@
   };
 
   // 拖拽逻辑
-  const isDragOver = ref<boolean>(false);
-  const onDragStart = (e: DragEvent, item: Item): void => {
-    e.dataTransfer?.setData('text/plain', JSON.stringify(item));
-  };
-  const onDragOver = (e: DragEvent): void => {
-    e.preventDefault();
-    isDragOver.value = true;
-  };
-  const onDragLeave = (): void => {
-    isDragOver.value = false;
-  };
-  const onDrop = (e: DragEvent): void => {
-    e.preventDefault();
-    isDragOver.value = false;
-    try {
-      const data = e.dataTransfer?.getData('text/plain');
-      if (!data) return;
-      const item: Item = JSON.parse(data);
-      let droppedItem = cloneDeep(item);
-      const container = e.currentTarget as HTMLElement;
-      const tags = [...container.querySelectorAll('.expr-tag')] as HTMLElement[];
-      let index = tags.length;
-      const mouseX = e.clientX;
-      for (let i = 0; i < tags.length; i++) {
-        const rect = tags[i].getBoundingClientRect();
-        if (mouseX < rect.left + rect.width / 2) {
-          index = i;
-          break;
-        }
-      }
-      items.value.splice(index, 0, droppedItem);
-      syncAfterChange();
-    } catch {
-      message.error('拖拽失败');
-    }
-  };
+  // const isDragOver = ref<boolean>(false);
+  // const onDragStart = (e: DragEvent, item: Item): void => {
+  //   e.dataTransfer?.setData('text/plain', JSON.stringify(item));
+  // };
+  // const onDragOver = (e: DragEvent): void => {
+  //   e.preventDefault();
+  //   isDragOver.value = true;
+  // };
+  // const onDragLeave = (): void => {
+  //   isDragOver.value = false;
+  // };
+  // const onDrop = (e: DragEvent): void => {
+  //   e.preventDefault();
+  //   isDragOver.value = false;
+  //   try {
+  //     const data = e.dataTransfer?.getData('text/plain');
+  //     if (!data) return;
+  //     const item: Item = JSON.parse(data);
+  //     let droppedItem = cloneDeep(item);
+  //     const container = e.currentTarget as HTMLElement;
+  //     const tags = [...container.querySelectorAll('.expr-tag')] as HTMLElement[];
+  //     let index = tags.length;
+  //     const mouseX = e.clientX;
+  //     for (let i = 0; i < tags.length; i++) {
+  //       const rect = tags[i].getBoundingClientRect();
+  //       if (mouseX < rect.left + rect.width / 2) {
+  //         index = i;
+  //         break;
+  //       }
+  //     }
+  //     items.value.splice(index, 0, droppedItem);
+  //     syncAfterChange();
+  //   } catch {
+  //     message.error('拖拽失败');
+  //   }
+  // };
 
   // 校验与优先级处理
   const validateExpression = (expr: string): { valid: boolean; message?: string } => {
@@ -532,7 +552,7 @@
     return hasAnd && hasOr;
   };
 
-  // ---------- 提交逻辑 ----------
+  // 提交逻辑
   const confirm = async (): Promise<void> => {
     const expr = expressionString.value;
     const validation = validateExpression(expr);
@@ -587,7 +607,7 @@
     message.success('已提交');
   };
 
-  // ---------- 重置 ----------
+  // 重置
   const reset = (): void => {
     items.value = [];
     inputString.value = '';
@@ -597,14 +617,14 @@
     emit('change', '');
   };
 
-  // ---------- 进入高级模式 ----------
+  // 进入高级模式
   const enterAdvancedMode = (): void => {
     // 将当前 modelValue 初始化到画布
     initializeFromExpression(props.modelValue);
     compact.value = false;
   };
 
-  // ---------- 返回简易模式 ----------
+  // 返回简易模式
   const backToCompact = async (): Promise<void> => {
     const currentExpr = expressionString.value;
     if (currentExpr === props.modelValue) {
@@ -628,7 +648,6 @@
     });
   };
 
-  // ---------- 模板应用 / 手动输入应用 ----------
   const applyTemplate = (): void => {
     if (!selectedTemplate.value) return;
     initializeFromExpression(selectedTemplate.value);
@@ -649,17 +668,16 @@
     message.success('已应用');
   };
 
-  // ---------- 初始化:监听 modelValue 变化(用于外部控制) ----------
   watch(
     () => props.modelValue,
     (newVal) => {
       if (newVal !== undefined) {
         inputString.value = newVal;
         // 如果当前处于高级模式,也同步画布
-        if (!compact.value) {
-          const parsed = parseExpression(newVal);
-          items.value = parsed.length ? parsed : [];
-        }
+        // if (!compact.value) {
+        const parsed = parseExpression(newVal);
+        items.value = parsed.length ? parsed : [];
+        // }
       }
     },
     { immediate: true }
@@ -754,17 +772,18 @@
         align-items: center;
         gap: 8px;
       }
-      .expr-tag {
-        font-size: 14px;
-        padding: 6px 12px;
-        margin: 0;
-        // :deep(.anticon-close) {
-        //   margin-left: 6px;
-        //   &:hover {
-        //     color: #ff4d4f;
-        //   }
-        // }
-      }
+    }
+
+    .expr-tag {
+      font-size: 14px;
+      padding: 6px 12px;
+      margin: 0;
+      // :deep(.anticon-close) {
+      //   margin-left: 6px;
+      //   &:hover {
+      //     color: #ff4d4f;
+      //   }
+      // }
     }
   }
 </style>

+ 0 - 0
src/views/system/algorithm/index copy.vue → src/views/system/algorithm/index copy.txt


+ 135 - 67
src/views/system/algorithm/index.vue

@@ -17,6 +17,9 @@
             <button @click="handleEdit(record, 'goaf')" class="action-btn" title="编辑">
               <SvgIcon name="edit" />
             </button>
+            <button @click="handleEdit(record, 'goaf-limit')" class="action-btn" title="详细参数">
+              <SvgIcon name="data" />
+            </button>
             <!-- <button @click="handleAdd({ goafId: record.id, mineCode: last(expandedRowKeys) }, 'goaf')" class="action-btn ml-1">
               <PlusOutlined />
             </button> -->
@@ -33,6 +36,9 @@
         <button @click="handleEdit({ coalSeamId: record.id, mineCode: record.mineCode }, 'coal')" class="action-btn" title="编辑">
           <SvgIcon name="edit" />
         </button>
+        <button @click="handleEdit(record, 'coal-limit')" class="action-btn" title="详细参数">
+          <SvgIcon name="data" />
+        </button>
         <!-- <button @click="handleAdd({ coalSeamId: record.id, mineCode: record.mineCode }, 'coal')" class="action-btn ml-1">
           <PlusOutlined />
         </button> -->
@@ -44,8 +50,8 @@
       </template>
     </BasicTable>
   </Flex>
-  <BasicModal width="60%" :height="700" @register="registerModal" @ok="handleSubmit" title="预警参数设置">
-    <BasicForm @register="registerForm">
+  <BasicModal width="60%" @register="registerModal" @ok="handleSubmit" title="预警参数设置">
+    <BasicForm v-if="modalSign === 'coal'" @register="registerCoalForm">
       <template #InputRangeNumber="{ model, field, schema }">
         <a-form-item>
           <a-input-group>
@@ -86,6 +92,29 @@
         <RelationBuilder class="h-full" v-model="model[field]" />
       </template>
     </BasicForm>
+    <BasicForm v-else-if="modalSign === 'coal-limit'" @register="registerCoalLimitForm">
+      <template #InputRangeGoaf="{ model, field, schema }">
+        <a-form-item v-if="model[field]">
+          <a-input-group>
+            <a-input-number v-model:value="model[field][`lowerLimit`]" style="width: calc(50% - 100px)" placeholder="-" />
+            <a-input style="width: 200px; border-left: 0; pointer-events: none; color: inherit" :value="schema.groupName" disabled />
+            <a-input-number v-model:value="model[field][`upperLimit`]" style="width: calc(50% - 100px); border-left: 0" placeholder="-" />
+          </a-input-group>
+        </a-form-item>
+      </template>
+    </BasicForm>
+    <BasicForm v-else-if="modalSign === 'goaf'" @register="registerGoafForm"> </BasicForm>
+    <BasicForm v-else-if="modalSign === 'goaf-limit'" @register="registerGoafLimitForm">
+      <template #InputRangeGoaf="{ model, field, schema }">
+        <a-form-item v-if="model[field]">
+          <a-input-group>
+            <a-input-number v-model:value="model[field][`lowerLimit`]" style="width: calc(50% - 100px)" placeholder="-" />
+            <a-input style="width: 200px; border-left: 0; pointer-events: none; color: inherit" :value="schema.groupName" disabled />
+            <a-input-number v-model:value="model[field][`upperLimit`]" style="width: calc(50% - 100px); border-left: 0" placeholder="-" />
+          </a-input-group>
+        </a-form-item>
+      </template>
+    </BasicForm>
   </BasicModal>
 </template>
 
@@ -97,7 +126,15 @@
   import { useForm, BasicForm } from '/@/components/Form';
   import { BasicTable, useTable } from '/@/components/Table';
   import { useListPage } from '/@/hooks/system/useListPage';
-  import { columnsCoalAlarm, columnsGoafLimit, schemasCoalExpression, schemasGoafLimit, searchFormSchema, goafAlarmModel } from './algorithm.data';
+  import {
+    columnsCoalAlarm,
+    columnsGoafLimit,
+    schemasCoalExpression,
+    schemasGoafLimit,
+    searchFormSchema,
+    limitationModel,
+    schemasGoafInfo,
+  } from './algorithm.data';
   import {
     addCoalSeamAlarmRule,
     deleteCoalSeamAlarmRule,
@@ -108,13 +145,21 @@
     getCoalSeamAlarmRule,
     getGoafDataLimit,
     patchGoafDataLimit,
+    patchCoalSeamAlarmRule,
+    patchCoalLimit,
+    patchGoafLimit,
+    updateGoaf,
+    fetchGoafLimit,
+    fetchCoalLimit,
   } from './algorithm.api';
   import { Flex } from 'ant-design-vue';
   // import { PlusOutlined } from '@ant-design/icons-vue';
   import { forEach, last, isString } from 'lodash-es';
   import { message } from 'ant-design-vue';
   import { SvgIcon } from '/@/components/Icon';
-  import RelationBuilder from './RelationBuilder.vue';
+  import RelationBuilder from './components/RelationBuilder.vue';
+
+  type ModalSign = 'coal' | 'coal-limit' | 'goaf' | 'goaf-limit';
 
   const { prefixCls } = useDesign('algorithm-list');
   provide('prefixCls', prefixCls);
@@ -164,66 +209,103 @@
     },
   });
 
-  const formPropsMap = new Map([
+  const [registerCoalForm, coalFormContext] = useForm({
+    model: {},
+    schemas: schemasCoalExpression,
+    showResetButton: false,
+    showSubmitButton: false,
+    colon: false,
+    compact: true,
+  });
+  const [registerCoalLimitForm, coalLimitContext] = useForm({
+    model: {},
+    schemas: schemasGoafLimit,
+    showResetButton: false,
+    showSubmitButton: false,
+    colon: false,
+    compact: true,
+  });
+  const [registerGoafForm, goafFormContext] = useForm({
+    model: {},
+    schemas: schemasGoafInfo,
+    showResetButton: false,
+    showSubmitButton: false,
+    colon: false,
+    compact: true,
+  });
+  const [registerGoafLimitForm, goafLimitContext] = useForm({
+    model: {},
+    schemas: schemasGoafLimit,
+    showResetButton: false,
+    showSubmitButton: false,
+    colon: false,
+    compact: true,
+  });
+
+  const modalSign = ref<ModalSign>('coal');
+
+  const editionPropsMap = new Map([
     [
       'coal',
       {
-        schemas: schemasCoalExpression,
-        submitFunc: (res) => (res.id ? updateCoalSeamAlarmRule(res) : addCoalSeamAlarmRule(res)),
-        fetchRecord: (params) => getCoalSeamAlarmRule(params).then((r) => last(r)),
+        submitFunc: (record) => coalFormContext.validate().then((res) => patchCoalSeamAlarmRule(Object.assign(record, res))),
+        fieldFunc: (params) => getCoalSeamAlarmRule(params).then((r) => coalFormContext.setFieldsValue(last(r))),
+      },
+    ],
+    [
+      'coal-limit',
+      {
+        submitFunc: (record) => coalLimitContext.validate().then((res) => patchCoalLimit(Object.assign(record, res))),
+        fieldFunc: (params) => fetchCoalLimit(params.id, last(expandedRowKeys.value)).then((r) => coalLimitContext.setFieldsValue(r)),
       },
     ],
     [
       'goaf',
       {
-        schemas: schemasGoafLimit,
-        submitFunc: (res) => patchGoafDataLimit(res),
-        fetchRecord: (params) =>
-          getGoafDataLimit({ goafId: params.id, mineCode: last(expandedRowKeys.value) }).then((r) => {
-            const result: any = params;
-            forEach(goafAlarmModel, (item, key) => {
-              result[key] = { goafId: params.id, mineCode: last(expandedRowKeys.value), ...item };
-            });
-            forEach(r, (item) => {
-              result[item.alarmField] = item;
-            });
-
-            return result;
-          }),
+        submitFunc: (record) => goafFormContext.validate().then((res) => updateGoaf(Object.assign(record, res))),
+        fieldFunc: (params) => goafFormContext.setFieldsValue(params),
+      },
+    ],
+    [
+      'goaf-limit',
+      {
+        submitFunc: (record) => goafLimitContext.validate().then((res) => patchGoafLimit(Object.assign(record, res))),
+        fieldFunc: (params) => fetchCoalLimit(params.id, last(expandedRowKeys.value)).then((r) => goafLimitContext.setFieldsValue(r)),
       },
     ],
   ]);
-  const modalPropsMap = new Map<string, Partial<ModalProps>>([
-    ['coal', { title: '预警参数设置', visible: true, loading: true }],
-    ['goaf', { title: '超限预警设置', visible: true, loading: true }],
+
+  const deletionPropsMap = new Map<string, { api: (id: string) => Promise<void> }>([
+    ['coal', { api: (id) => deleteCoalSeamAlarmRule({ id }) }],
+    ['goaf', { api: (id) => deleteGoafDataLimit({ id }) }],
+  ]);
+
+  const modalPropsMap = new Map<ModalSign, Partial<ModalProps>>([
+    ['coal', { title: '预警参数设置', loading: true, visible: true, height: 600 }],
+    ['coal-limit', { title: '预警参数设置', loading: true, visible: true, height: 300 }],
+    ['goaf', { title: '超限预警设置', loading: true, visible: true, height: 300 }],
+    ['goaf-limit', { title: '超限预警设置', loading: true, visible: true, height: 300 }],
   ]);
-  const submitResolver = ref<(res: any) => Promise<unknown>>();
-  // 点击编辑后,获取对应的表单和弹窗配置
-  async function handleEdit(record, sign: string) {
-    if (!modalPropsMap.has(sign)) return;
-    if (!formPropsMap.has(sign)) return;
-    setModalProps(modalPropsMap.get(sign) as ModalProps);
-    const { schemas, fetchRecord, submitFunc } = formPropsMap.get(sign)!;
-    const res = await fetchRecord(record);
-    await resetSchema(schemas);
 
-    await nextTick();
+  const submitResolver = ref<() => Promise<unknown>>();
 
-    await setFieldsValue(res);
+  // 点击编辑后,获取对应的表单和弹窗配置
+  async function handleEdit(record, sign: ModalSign) {
+    modalSign.value = sign;
+    setModalProps(modalPropsMap.get(sign) as ModalProps);
+    const { fieldFunc, submitFunc } = editionPropsMap.get(sign)!;
+    submitResolver.value = () => submitFunc(record);
 
     await nextTick();
-
-    // 不要使用setFormProps因为它会错误的触发submit方法
-    // await setFormProps({ submitFunc });
-    submitResolver.value = (res) => submitFunc(Object.assign(record, res));
+    await fieldFunc(record);
 
     setModalProps({ loading: false });
   }
   // async function handleAdd(record, sign: string) {
   //   if (!modalPropsMap.has(sign)) return;
-  //   if (!formPropsMap.has(sign)) return;
+  //   if (!editionPropsMap.has(sign)) return;
   //   setModalProps(modalPropsMap.get(sign) as ModalProps);
-  //   const { schemas, submitFunc } = formPropsMap.get(sign)!;
+  //   const { schemas, submitFunc } = editionPropsMap.get(sign)!;
   //   await nextTick();
   //   await resetSchema(schemas);
 
@@ -240,39 +322,25 @@
   //   setModalProps({ loading: false });
   // }
 
-  const deletionPropsMap = new Map<string, { api: (id: string) => Promise<void> }>([
-    ['coal', { api: (id) => deleteCoalSeamAlarmRule({ id }) }],
-    ['goaf', { api: (id) => deleteGoafDataLimit({ id }) }],
-  ]);
-
   function handleDelete(record, sign: string) {
     if (!deletionPropsMap.has(sign)) return;
     deletionPropsMap.get(sign)?.api(record.id);
   }
 
   const [registerModal, { setModalProps }] = useModal();
-  const [registerForm, { setFieldsValue, validate, resetSchema }] = useForm({
-    model: {},
-    schemas: schemasCoalExpression,
-    showResetButton: false,
-    showSubmitButton: false,
-    colon: false,
-    compact: true,
-  });
 
   function handleSubmit() {
-    return validate().then((res) => {
-      submitResolver.value &&
-        submitResolver
-          .value(res)
-          .then(() => {
-            message.success('操作成功');
-            setModalProps({ visible: false });
-          })
-          .catch((e) => {
-            message.error(isString(e) ? e : '操作失败');
-          });
-    });
+    if (submitResolver.value) {
+      submitResolver
+        .value()
+        .then(() => {
+          message.success('操作成功');
+          setModalProps({ visible: false });
+        })
+        .catch((e) => {
+          message.error(isString(e) ? e : '操作失败');
+        });
+    }
   }
 </script>