jwyu 1 year ago
parent
commit
4fcfc189d9
1 changed files with 260 additions and 3 deletions
  1. 260 3
      src/views/dataEDB/calculate/components/DiffusionIndexCalcualate.vue

+ 260 - 3
src/views/dataEDB/calculate/components/DiffusionIndexCalcualate.vue

@@ -1,18 +1,20 @@
 <script setup>
 import apiDataEDB from '@/api/dataEDB'
 import { showToast } from 'vant';
-import {reactive, ref} from 'vue'
+import {computed, reactive, ref} from 'vue'
 import SelectEDB from './SelectEDB.vue'
-import EDBHistory from '@/views/dataEDB/components/EDBHistory.vue'
 import SelectEDBClassify from '../../components/SelectEDBClassify.vue'
 import SelectEDBUnit from '../../components/SelectEDBUnit.vue'
 import SelectEDBFrequency from '../../components/SelectEDBFrequency.vue'
 import {calculateTypeTipsMap} from '../../util/config'
 import { useRoute, useRouter } from 'vue-router';
+import moment from 'moment';
 
 const route=useRoute()
 const router=useRouter()
 
+const source=ref(Number(route.query.type)||0)//计算类型
+
 //公式说明
 const showTips=ref(false)
 const tipsContent=ref(calculateTypeTipsMap.get(Number(route.query.type))||'')
@@ -60,6 +62,14 @@ function handleAddEdbList(){
 	edbList.value.push(item);
 }
 function handleDeleteEDBItem(index){
+    // 检测dateContactState.list是否有改项有的话删除掉
+    const tag=edbList.value[index].tag
+    const flagIndex=dateContactState.list.indexOf(tag)
+    if(flagIndex!=-1){
+        dateContactState.list.splice(flagIndex,1)
+    }
+
+
     edbList.value.splice(index, 1)
 }
 // 选择指标
@@ -76,6 +86,101 @@ function handleConfirmSelectEDB(e){
     edbList.value[whichIndex].name=e.EdbName
 }
 
+// 日期合并类型
+const dateContactState=reactive({
+    type:1,
+    list:[],//部分日期并集选择的指标
+})
+// 显示日期
+const dateRange=computed(()=>{
+    const arr=edbList.value.filter(_=>dateContactState.list.includes(_.tag)&&_.target)
+                     .map(_=>[new Date(_.startDate),new Date(_.endDate)]).flat(Infinity)
+    const start=arr.length&&moment(Math.min(...arr)).format('YYYY-MM-DD')
+    const end=arr.length&&moment(Math.max(...arr)).format('YYYY-MM-DD')
+    if(start&&end) return start+'至'+end
+
+    return ''
+})
+
+
+// 基础信息
+const edbNameInputFocus=ref(false)
+const baseInfo=reactive({
+    name:'',
+    unit:'',
+    classify:'',
+    frequency:''
+})
+
+// 选择单位
+const showSelectUnit=ref(false)
+function onConfirmSelectUnit(value){
+    baseInfo.unit=value
+}
+
+//选择分类
+const showSelectClassify=ref(false)
+const classifyStr=ref('')
+function handleConfirmClassify({value,selectedOptions}){
+    baseInfo.classify=value
+    classifyStr.value=`${selectedOptions[0].ClassifyName}/${selectedOptions[1].ClassifyName}/${selectedOptions[2].ClassifyName}`
+}
+
+//选择频度
+const showSelectFrequency=ref(false)
+function handleConfirmFrequency(value){
+    baseInfo.frequency=value
+}
+
+// 提交计算
+const saveBtnLoading=ref(false)
+async function handleSave(){
+    const arr=edbList.value.filter(item=>item.target).map(item=>{
+        return {
+            EdbInfoId: item.target,
+            FromTag: item.tag,
+        }
+    })
+    if(!arr.length){
+        showToast('请选择指标')
+        return
+    }
+    if(!baseInfo.name){
+        showToast('指标名称不能为空')
+        return
+    }
+    if(!baseInfo.unit){
+        showToast('指标单位不能为空')
+        return
+    }
+    if(!baseInfo.classify){
+        showToast('指标目录不能为空')
+        return
+    }
+    if(!baseInfo.frequency){
+        showToast('指标频度不能为空')
+        return
+    }
+    const params={
+        Source: source.value,
+		EdbName: baseInfo.name,
+		Unit: baseInfo.unit,
+		ClassifyId: baseInfo.classify,
+		Frequency: baseInfo.frequency,
+		Formula: JSON.stringify({DateType:dateContactState.type,CheckList:dateContactState.list}),
+        EdbInfoIdArr:arr
+    }
+    saveBtnLoading.value=true
+    const res=await apiDataEDB.addCalculateEDB(params)
+    saveBtnLoading.value=false
+    if(res.Ret===200){
+        showToast(res.Msg)
+        setTimeout(() => {
+            router.back()
+        }, 1500);
+    }
+}
+
 
 </script>
 
@@ -102,16 +207,118 @@ function handleConfirmSelectEDB(e){
                     <van-button square type="danger" text="删除" @click="handleDeleteEDBItem(index)"/>
                 </template>
             </van-swipe-cell>
-            <div class="add-edb-box" @click="handleAddEdbList">
+            <div class="van-cell add-edb-box" @click="handleAddEdbList">
                 <img src="@/assets/imgs/icon01.png" alt="">
                 <span>添加更多参数</span>
             </div>
+            <van-field label="指标扩散日期">
+                <template #input>
+                    <div class="contact-date-box">
+                        <van-radio-group v-model="dateContactState.type" shape="dot" @change="dateContactState.list=[]">
+                            <van-radio :name="1">全部日期并集</van-radio>
+                            <van-radio :name="2">部分日期并集</van-radio>
+                        </van-radio-group>
+                        <van-checkbox-group 
+                            v-model="dateContactState.list"
+                            direction="horizontal"
+                            shape="square" 
+                            v-if="dateContactState.type===2"
+                        >
+                            <van-checkbox
+                                v-for="item in edbList"
+                                :key="item.tag"
+                                :name="item.tag"
+                            >{{item.tag}}</van-checkbox>
+                        </van-checkbox-group>
+                        <div class="time" v-if="dateContactState.type===2">{{dateRange}}</div>
+                    </div>
+                </template>
+            </van-field>
         </section>
+
+        <section class="section baseinfo-box">
+            <van-field 
+                v-model="baseInfo.name" 
+                label="指标名称" 
+                placeholder="指标名称"
+                input-align="right"
+                required
+                @focus="edbNameInputFocus=true"
+                @blur="edbNameInputFocus=false"
+            >
+                <template #right-icon>
+                    <svg-icon class="edit-icon" name="edit" :color="edbNameInputFocus?'#0052D9':'#333333'"/>
+                </template>
+            </van-field>
+            <van-field 
+                :modelValue="baseInfo.unit"
+                readonly
+                label="单位" 
+                placeholder="请选择单位"
+                input-align="right"
+                right-icon="arrow"
+                required
+                @click-input="showSelectUnit=true"
+            />
+            <van-field 
+                :modelValue="classifyStr"
+                readonly
+                label="指标目录" 
+                placeholder="请选择指标目录"
+                input-align="right"
+                right-icon="arrow"
+                required
+                @click-input="showSelectClassify=true"
+            />
+            <van-field 
+                :modelValue="baseInfo.frequency"
+                readonly
+                label="频度" 
+                placeholder="请选择指标频度"
+                input-align="right"
+                right-icon="arrow"
+                required
+                @click-input="showSelectFrequency=true"
+            />
+        </section>
+
+        <div class="formula-intro-btn" @click="showTips=true">
+            <svg-icon class="icon" name="warning"></svg-icon>
+            <span>公式说明</span>
+        </div>
+
+        <div class="opt-btns">
+            <van-button class="primary2" @click="$router.back()">取消</van-button>
+            <van-button 
+                type="primary" 
+                :loading="saveBtnLoading"
+                loading-text="计算中..."
+                @click="handleSave"
+            >扩散指数计算</van-button>
+        </div>
     </div>
 
     <!-- 选择指标 -->
     <SelectEDB v-model:show="showSelectEDB" @select="handleConfirmSelectEDB"/>
 
+    <!-- 选择单位 -->
+    <SelectEDBUnit v-model:show="showSelectUnit" @select="onConfirmSelectUnit"/>
+
+    <!-- 选择分类 -->
+    <SelectEDBClassify v-model:show="showSelectClassify" @select="handleConfirmClassify" />
+
+    <!-- 选择频度 -->
+    <SelectEDBFrequency v-model:show="showSelectFrequency" @select="handleConfirmFrequency"/>
+
+    <!-- 公式说明 -->
+    <van-dialog 
+        v-model:show="showTips" 
+        :title="$route.query.name"
+        confirmButtonText='知道啦'
+    >
+        <div class="edb-formula-tips-html-box" v-html="tipsContent"></div>
+    </van-dialog>
+
 </template>
 
 <style lang="scss" scoped>
@@ -164,4 +371,54 @@ function handleConfirmSelectEDB(e){
     }
 
 }
+
+.contact-date-box{
+    width: 100%;
+    .van-radio{
+        justify-content: flex-end;
+        margin-bottom: 10px;
+    }
+    .van-checkbox-group--horizontal{
+        justify-content: flex-end;
+        gap: 8px;
+    }
+    .time{
+        color: $theme-color;
+        text-align: right;
+        margin-top: 10px;
+    }
+}
+
+.formula-intro-btn{
+    width: 180px;
+    height: 60px;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    gap: 5px;
+    color: $theme-color;
+    line-height: 1;
+    background-color: #fff;
+    border-radius: 32px;
+    margin-left: auto;
+    margin-right: var(--van-cell-horizontal-padding);
+    .icon{
+        width: 24px;
+        height: 24px;
+    }
+}
+.opt-btns{
+    position: fixed;
+    left: 0;
+    right: 0;
+    bottom: 0;
+    background-color: #fff;
+    z-index: 99;
+    padding: 48px;
+    display: flex;
+    justify-content: space-between;
+    .van-button{
+        width: 48%;
+    }
+}
 </style>