From df90c0c5cfa4de114798015b92120ad8ba8b4826 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期五, 22 十一月 2024 10:45:40 +0800
Subject: [PATCH] MEASURE_VALUE_TYPE

---
 src/views/data/ind/item/DerIndDefineForm.vue |   81 ++++++++++++++++++++++------------------
 1 files changed, 45 insertions(+), 36 deletions(-)

diff --git a/src/views/data/ind/item/DerIndDefineForm.vue b/src/views/data/ind/item/DerIndDefineForm.vue
index 2d7d1d9..3822e86 100644
--- a/src/views/data/ind/item/DerIndDefineForm.vue
+++ b/src/views/data/ind/item/DerIndDefineForm.vue
@@ -7,14 +7,14 @@
       :rules="formRules" label-width="100px">
       <el-row>
         <el-col :span="12">
-          <el-form-item label="原子指标" prop="atomItem.id">
-            <el-select v-model="selected" clearable placeholder="请选择原子指标"
+          <el-form-item label="原子指标" prop="atomItem.itemId">
+            <el-select v-model="formData.atomItem.itemId" clearable placeholder="请选择原子指标"
                        @change="handleChange($event)">
               <el-option
                 v-for="item in atomItemList"
                 :key="item.id"
                 :label="item.itemNo"
-                :value="item.id"
+                :value="item.id + ''"
               />
             </el-select>
           </el-form-item>
@@ -64,12 +64,12 @@
         </el-col>
       </el-row>
       <el-row>
-        <el-col :span="8">
+        <el-col :span="6">
           <el-form-item label="指标精度" prop="precision">
             <el-input v-model="formData.precision"/>
           </el-form-item>
         </el-col>
-        <el-col :span="8">
+        <el-col :span="6">
           <el-form-item label="转换系数" prop="coefficient">
             <el-input v-model="formData.coefficient"/>
           </el-form-item>
@@ -81,31 +81,24 @@
         </el-col>
       </el-row>
       <el-row>
-        <el-col :span="20">
-          <el-form-item label="备注" prop="remark">
-            <el-input v-model="formData.remark" type="textarea" maxlength="100"/>
-          </el-form-item>
-        </el-col>
-      </el-row>
-      <el-row>
-        <el-col :span="12">
+        <el-col :span="6">
           <el-form-item label="时间标识" prop="timeLabel">
             <el-select v-model="formData.derItem.timeLabel" clearable placeholder="请选择时间标识">
               <el-option
                 v-for="item in dataSetFieldList"
                 :key="item.id"
                 :label="item.fieldCode"
-                :value="item.id + ''"
+                :value="item.fieldCode"
               />
             </el-select>
           </el-form-item>
         </el-col>
-        <el-col :span="12">
+        <el-col :span="6">
           <el-form-item label="时间限定" prop="timeLimit">
-            <el-select v-model="formData.timeLimit" placeholder="请选择"
+            <el-select v-model="formData.derItem.timeLimit" placeholder="请选择"
                        @change="handleTimeLimitChange($event)">
               <el-option
-                v-for="dict in getStrDictOptions(DICT_TYPE.TIME_LIMIT)"
+                v-for="dict in getStrDictOptions(DICT_TYPE.IND_TIME_LIMIT)"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
@@ -115,7 +108,7 @@
         </el-col>
       </el-row>
       <el-row v-if="showTimeChange">
-        <el-col :span="12">
+        <el-col :span="6">
           <el-form-item label="开始时间" prop="timeStart">
             <el-date-picker
               v-model="formData.derItem.timeStart"
@@ -124,7 +117,7 @@
             />
           </el-form-item>
         </el-col>
-        <el-col :span="8">
+        <el-col :span="6">
           <el-form-item label="结束时间" prop="timeEnd">
             <el-date-picker
               v-model="formData.derItem.timeEnd"
@@ -135,16 +128,23 @@
         </el-col>
       </el-row>
       <el-row>
-        <el-col :span="12">
+        <el-col :span="24">
           <el-form-item label="分析维度" prop="dimension">
             <el-select v-model="formData.derItem.dimension" clearable placeholder="请选择分析维度" multiple>
               <el-option
                 v-for="item in dataSetFieldList"
                 :key="item.id"
                 :label="item.fieldCode"
-                :value="item.id + ''"
+                :value="item.fieldCode"
               />
             </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="24">
+          <el-form-item label="备注" prop="remark">
+            <el-input v-model="formData.remark" type="textarea" maxlength="100"/>
           </el-form-item>
         </el-col>
       </el-row>
@@ -180,13 +180,14 @@
     itemName: '',
     itemType: '',
     itemCategory: '',
-    coefficient: '',
-    precision: '',
+    coefficient: 1,
+    precision: 0,
     businessType: '',
     timeRange: '',
     timeGranularity: '',
     atomItem: {
       id: '',
+      itemId: '',
       itemNo: '',
       itemName: '',
     },
@@ -199,9 +200,6 @@
       dimension: ''
     }
   })
-  const queryParams = ref({
-    itemType: 'ATOM'
-  })
 
   const validateAsNumber = (rule, value, callback) => {
     const regex = /^(\-|\+)?\d+(\.\d+)?$/;
@@ -213,14 +211,12 @@
   const formRules = reactive({
     itemName: [{required: true, message: '指标名称不能为空', trigger: 'blur'}],
     itemCategory: [{required: true, message: '指标类型不能为空', trigger: 'blur'}],
-    precision: [{validator: validateAsNumber, trigger: 'blur' }],
-    coefficient: [{validator: validateAsNumber, trigger: 'blur' }],
-    "atomItem.id": [{required: true, message: '原子指标不能为空', trigger: 'blur'}]
+    /*precision: [{validator: validateAsNumber, trigger: 'blur' }],
+    coefficient: [{validator: validateAsNumber, trigger: 'blur' }],*/
+    /*"atomItem.id": [{required: true, message: '原子指标不能为空', trigger: 'blur'}]*/
   })
   const formRef = ref() // 表单 Ref
-  const dataSourceList = ref([] as DataSourceConfigApi.DataSourceConfigVO[])
   const atomItemList = ref([] as ItemApi.ItemVO[])
-  const selected = ref(null)
   const showTimeChange = ref(false)
   const dataCategoryList = ref([] as CategoryApi.IndItemCategoryVO[])
   const dataSetFieldList = ref([] as DataSetFieldApi.DataSetFieldVO[])
@@ -233,13 +229,22 @@
     resetForm()
     // 加载数据源列表
     dataCategoryList.value = await CategoryApi.getCategoryListAllSimple()
+    const queryParams = reactive({
+      itemType: 'ATOM'
+    })
     atomItemList.value = await ItemApi.getItemList(queryParams)
-    selected.value = null
     // 修改时,设置数据
     if (id) {
       formLoading.value = true
       try {
         formData.value = await ItemApi.getItem(id)
+        if(formData.value.derItem.dimension.length > 0){
+          formData.value.derItem.dimension = formData.value.derItem.dimension.split(',')
+        }else {
+          formData.value.derItem.dimension = ""
+        }
+        showTimeChange.value = formData.value.derItem.timeLimit === 'CUSTOM'
+        await handleChange(formData.value.derItem.atomItemId)
       } finally {
         formLoading.value = false
       }
@@ -258,13 +263,15 @@
     formLoading.value = true
     try {
       formData.value.itemType = 'DER'
-      formData.value.derItem.atomItemId = formData.value.atomItem.id
+      formData.value.derItem.atomItemId = formData.value.atomItem.itemId
       if(formData.value.derItem.dimension.length > 0){
         let dimension = ''
         for (let index in formData.value.derItem.dimension){
           dimension = dimension + formData.value.derItem.dimension[index] + ','
         }
         formData.value.derItem.dimension = dimension.substring(0, dimension.length - 1)
+      }else{
+        formData.value.derItem.dimension = ''
       }
       const data = formData.value as ItemApi.ItemVO
       if (formType.value === 'create') {
@@ -289,8 +296,8 @@
       itemName: '',
       itemType: '',
       itemCategory: '',
-      coefficient: '',
-      precision: '',
+      coefficient: 1,
+      precision: 0,
       businessType: '',
       timeRange: '',
       timeGranularity: '',
@@ -314,8 +321,10 @@
   async function handleChange(event) {
     if (event !== null && event !== undefined) {
       const itemData = await ItemApi.getItem(event)
+      let a = itemData.atomItem.id
+      formData.value.atomItem.id = a
       formData.value.atomItem.itemName = itemData.itemName
-      formData.value.atomItem.id = itemData.atomItem.id
+      formData.value.atomItem.itemId = itemData.atomItem.itemId
       const queryParams = reactive({
         dataSetId: itemData.atomItem.dataSet,
       })

--
Gitblit v1.9.3