Explorar el Código

[Feat 0000]测风设备管理设备编辑基本信息新增规程值选择

bobo04052021@163.com hace 1 día
padre
commit
2c86822c71
Se han modificado 1 ficheros con 63 adiciones y 47 borrados
  1. 63 47
      src/views/vent/deviceManager/comment/FormModal.vue

+ 63 - 47
src/views/vent/deviceManager/comment/FormModal.vue

@@ -10,58 +10,74 @@
   </div>
 </template>
 <script lang="ts" setup>
-  import { inject, nextTick, watch, unref } from 'vue';
-  import { BasicForm, useForm } from '/@/components/Form/index';
-  // 声明Emits
-  const emit = defineEmits(['saveOrUpdate']);
-  const testData = inject('formData') as any;
-  //表单配置
-  const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
-    schemas: unref(inject('formSchema')),
-    showActionButtonGroup: false,
-  });
+import { inject, nextTick, watch, unref, onMounted } from 'vue';
+import { BasicForm, useForm } from '/@/components/Form/index';
+import { getRegulation as getRegulationList } from '/@/views/vent/deviceManager/substationTabel/substation.api';
 
-  watch(
-    testData,
-    (newV) => {
-      nextTick(() => {
-        setFieldsValue({ ...newV });
-      });
-    },
-    { immediate: true }
-  );
+// 声明Emits
+const emit = defineEmits(['saveOrUpdate']);
+const testData = inject('formData') as any;
 
-  // 重置表单
-  async function onReset() {
-    await resetFields();
-    await setFieldsValue({ ...testData });
-  }
-  //表单提交事件
-  async function handleSubmit(v) {
-    try {
-      let values = await validate();
-      emit('saveOrUpdate', values);
-    } finally {
-      // setModalProps({ confirmLoading: false });
-    }
+const existingSchemas = unref(inject('formSchema')) || [];
+const newSchema = {
+  label: '规程值',
+  field: 'regulation',
+  component: 'ApiSelect',
+  componentProps: {
+    api: getRegulationList,
+    labelField: 'name',
+    valueField: 'id',
+  },
+};
+// 在索引位置1处插入规程值配置
+const insertPosition = 3;
+const mergedSchemas = [...existingSchemas.slice(0, insertPosition), newSchema, ...existingSchemas.slice(insertPosition)];
+//表单配置
+const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
+  schemas: mergedSchemas,
+  showActionButtonGroup: false,
+});
+watch(
+  testData,
+  (newV) => {
+    nextTick(() => {
+      setFieldsValue({ ...newV });
+    });
+  },
+  { immediate: true }
+);
+
+// 重置表单
+async function onReset() {
+  await resetFields();
+  await setFieldsValue({ ...testData });
+}
+//表单提交事件
+async function handleSubmit(v) {
+  try {
+    let values = await validate();
+    emit('saveOrUpdate', values);
+  } finally {
+    // setModalProps({ confirmLoading: false });
   }
+}
 </script>
 <style lang="less" scoped>
-  @ventSpace: zxm;
-  .j-box-bottom-button-float {
-    border: none !important;
-    padding-bottom: 30px;
-    left: 0px !important;
-    right: 0px !important;
-    bottom: 0px !important;
-  }
-  .vent-form {
-    // width: 100%;
-    max-height: 700px;
-    overflow-y: auto;
+@ventSpace: zxm;
+.j-box-bottom-button-float {
+  border: none !important;
+  padding-bottom: 30px;
+  left: 0px !important;
+  right: 0px !important;
+  bottom: 0px !important;
+}
+.vent-form {
+  // width: 100%;
+  max-height: 700px;
+  overflow-y: auto;
 
-    .@{ventSpace}-select-selection-item {
-      color: rgba(255, 255, 255, 1) !important;
-    }
+  .@{ventSpace}-select-selection-item {
+    color: rgba(255, 255, 255, 1) !important;
   }
+}
 </style>