Przeglądaj źródła

[Feat 0000] 算法模型页面对接采空区编辑接口

houzekong 3 miesięcy temu
rodzic
commit
47f87894a4

+ 22 - 5
src/views/system/algorithm/algorithm.api.ts

@@ -1,5 +1,6 @@
 import { defHttp } from '/@/utils/http/axios';
-import { isNil, map } from 'lodash-es';
+import { forEach, isNil, map } from 'lodash-es';
+import { isObject } from '/@/utils/is';
 // import { getEnfMineTree } from '/@/api/sys/menu';
 
 enum Api {
@@ -14,6 +15,7 @@ enum Api {
   addGoafDataLimit = '/province/alarm/addGoafDataLimit',
   updateGoafDataLimit = '/province/alarm/updateGoafDataLimit',
   deleteGoafDataLimit = '/province/alarm/deleteGoafDataLimit',
+  updateGoaf = '/province/device/updateGoaf',
 }
 
 export function getMineData(params: any) {
@@ -46,13 +48,27 @@ export function addGoafDataLimit(params: any) {
 export function updateGoafDataLimit(params: any) {
   return defHttp.post({ url: Api.updateGoafDataLimit, params });
 }
+export function updateGoaf(params: any) {
+  return defHttp.post({ url: Api.updateGoaf, params });
+}
 export function deleteGoafDataLimit(params: any) {
   return defHttp.post({ url: Api.deleteGoafDataLimit, params }, { joinParamsToUrl: true });
 }
 
 export function patchGoafDataLimit(params: Record<string, any>) {
-  return Promise.all(
-    map(params, (item) => {
+  const normalParams: any = {};
+  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) => {
       if (item.id) {
         return updateGoafDataLimit(item);
       }
@@ -60,6 +76,7 @@ export function patchGoafDataLimit(params: Record<string, any>) {
         return addGoafDataLimit(item);
       }
       return Promise.resolve();
-    })
-  );
+    }),
+    updateGoaf(normalParams),
+  ]);
 }

+ 64 - 0
src/views/system/algorithm/algorithm.data.ts

@@ -545,6 +545,70 @@ export const goafAlarmModel = {
 };
 
 export const schemasGoafLimit: FormSchema[] = [
+  {
+    field: 'id',
+    label: 'ID',
+    labelWidth: 118,
+    component: 'Input',
+    show: false,
+    // colProps: { span: 12 },
+  },
+  {
+    field: 'fireAirTemperature',
+    label: '气温',
+    labelWidth: 118,
+    component: 'InputNumber',
+    // colProps: { span: 12 },
+  },
+  {
+    field: 'fireWaterTemperature',
+    label: '水温',
+    labelWidth: 118,
+    component: 'InputNumber',
+    // colProps: { span: 12 },
+  },
+  {
+    field: 'size',
+    label: '尺寸',
+    labelWidth: 118,
+    component: 'Input',
+    // colProps: { span: 12 },
+  },
+  {
+    field: 'material',
+    label: '材质',
+    labelWidth: 118,
+    component: 'Input',
+    // colProps: { span: 12 },
+  },
+  {
+    field: 'strucure',
+    label: '结构',
+    labelWidth: 118,
+    component: 'Input',
+    // colProps: { span: 12 },
+  },
+  {
+    field: 'area',
+    label: '采区',
+    labelWidth: 118,
+    component: 'Input',
+    // colProps: { span: 12 },
+  },
+  {
+    field: 'person',
+    label: '负责人',
+    labelWidth: 118,
+    component: 'Input',
+    // colProps: { span: 12 },
+  },
+  {
+    field: '',
+    label: '参数设置',
+    labelWidth: 118,
+    component: 'Divider',
+    // colProps: { span: 12 },
+  },
   {
     // 甲烷
     field: 'ch4Val',

+ 5 - 5
src/views/system/algorithm/index.vue

@@ -14,7 +14,7 @@
       <template #expandedRowRender>
         <BasicTable @register="registerInnerTable">
           <template #action="{ record }">
-            <button @click="handleEdit({ goafId: record.id, mineCode: last(expandedRowKeys) }, 'goaf')" class="action-btn" title="编辑">
+            <button @click="handleEdit(record, 'goaf')" class="action-btn" title="编辑">
               <SvgIcon name="edit" />
             </button>
             <!-- <button @click="handleAdd({ goafId: record.id, mineCode: last(expandedRowKeys) }, 'goaf')" class="action-btn ml-1">
@@ -175,10 +175,10 @@
         schemas: schemasGoafLimit,
         submitFunc: (res) => patchGoafDataLimit(res),
         fetchRecord: (params) =>
-          getGoafDataLimit(params).then((r) => {
-            const result: any = {};
+          getGoafDataLimit({ goafId: params.id, mineCode: last(expandedRowKeys.value) }).then((r) => {
+            const result: any = params;
             forEach(goafAlarmModel, (item, key) => {
-              result[key] = { ...params, ...item };
+              result[key] = { goafId: params.id, mineCode: last(expandedRowKeys.value), ...item };
             });
             forEach(r, (item) => {
               result[item.alarmField] = item;
@@ -211,7 +211,7 @@
 
     // 不要使用setFormProps因为它会错误的触发submit方法
     // await setFormProps({ submitFunc });
-    submitResolver.value = (res) => submitFunc(Object.assign(res, record));
+    submitResolver.value = (res) => submitFunc(Object.assign(record, res));
 
     setModalProps({ loading: false });
   }