Selaa lähdekoodia

ETA1.0.7 init

cxmo 1 vuosi sitten
vanhempi
commit
33744eecad

+ 469 - 0
src/views/dataEntry_manage/databaseComponents/smoothEdbDialog.vue

@@ -0,0 +1,469 @@
+<template>
+    <!-- 指数修匀计算弹窗 -->
+    <el-dialog
+        :visible.sync="isOpenSmooth"
+        :close-on-click-modal="false"
+        :modal-append-to-body="false"
+        @close="cancelHandle"
+        center
+        width="1200px"
+        top="3vh"
+        v-dialogDrag
+    >
+        <div slot="title" style="display: flex; align-items: center">
+            <img
+                :src="$icons.computed"
+                style="color: #fff; width: 16px; height: 16px; margin-right: 5px"
+            />
+            <span style="font-size: 16px">指数修匀</span>
+        </div>
+        <div class="smooth-edb-dialog-wrap">
+            <!-- 常规计算 -->
+            <div class="normal-wrap" v-if="computedSource===1">
+                <div class="min-top">
+                    <label >选择指标:</label>
+                    <el-select
+                        v-model="select_target"
+                        v-loadMore="searchLoad"
+                        :filterable="!select_target"
+                        clearable
+                        placeholder="请输入指标名称"
+                        style="width: 85%"
+                        remote
+                        :remote-method="getTarget"
+                        @click.native="inputFocusHandle"
+                        @change="chooseTarget"
+                        @blur="search_have_more = false"
+                    >
+                        <i slot="prefix" class="el-input__icon el-icon-search"></i>
+                        <el-option
+                            v-for="item in searchOptions"
+                            :key="item.EdbInfoId"
+                            :label="$parent.currentLang==='en'?(item.EdbNameEn||item.EdbName):item.EdbName"
+                            :value="item.EdbInfoId"
+                        >
+                        </el-option>
+                    </el-select>
+                    <i class="el-icon-tickets" style="color:#409EFF;font-size:18px" @click="handleSelectBtnClick" v-if="select_target"/>
+                    
+                </div>
+                <div class="middle">
+                    <label>已选指标:</label>
+                    <el-table
+                        :data="tableData"
+                        style="box-shadow: 0px 3px 6px rgba(155, 170, 219, 0.2);margin-top:10px;"
+                        border>
+                        <el-table-column
+                            v-for="item in tableColums"
+                            :key="item.label"
+                            :label="item.label"
+                            :width="item.widthsty"
+                            :min-width="item.minwidthsty"
+                            align="center"
+                        >
+                            <template slot-scope="scope">
+                                <span>{{ scope.row[item.key] }}</span>
+                            </template>
+                        </el-table-column>
+                        <el-table-column
+                            width="110"
+                            align="center"
+                            label="操作"
+                        >
+                            <template slot-scope="scope">
+                                <span class="deletesty" @click="delTarget">删除</span>
+                            </template>
+                        </el-table-column>
+                        <div slot="empty" style="padding:20px 0 30px;">
+                            <tableNoData text="暂无指标" size="mini"/>
+                        </div>
+                    </el-table>
+                    <ul 
+                        class="data-ul" 
+                        ref="dataUl" 
+                        @scroll="scrollHandle"
+                        v-if="dataList.length">
+                        <li
+                            class="value-item"
+                            v-for="(item, index) in dataList"
+                            :key="item.EdbDataId"
+                        >
+                            <span class="value-label">
+                                <i class="new-tag" v-if="index === 0"></i>
+                                {{item.DataTime}}
+                            </span>
+                            <span class="value-label" style="min-width:200px;text-align:center;">{{item.Value}}</span>
+                        </li>
+                    </ul>
+                    <div class="form-cont">
+                        <el-form
+                            ref="form"
+                            label-position="right"
+                            inline
+                            label-width="80px"
+                            :model="formData"
+                            :rules="formRules"
+                        >
+                            <el-form-item label="指标名称" prop="targetName">
+                                <el-input
+                                    v-model="formData.targetName"
+                                    style="width: 340px"
+                                    placeholder="请输入指标名称"
+                                />
+                            </el-form-item>
+                            <el-form-item label="单位" prop="unit">
+                                <selectUnit 
+                                    v-model="formData.unit" 
+                                    style="width: 340px" 
+                                />
+                            </el-form-item>
+                            <el-form-item label="指标目录" prop="menu">
+                                <el-cascader
+                                    v-model="formData.menu"
+                                    :options="catalogArr"
+                                    :props="levelProps"
+                                    clearable
+                                    :emitPath="false"
+                                    placeholder="请选择指标目录"
+                                />
+                            </el-form-item>
+                            <el-form-item label="频度" prop="frequency">
+                                <el-select
+                                    v-model="formData.frequency"
+                                    placeholder="请选择频度"
+                                    style="width: 340px"
+                                    clearable
+                                >
+                                    <el-option
+                                        v-for="item in frequencyArr"
+                                        :key="item"
+                                        :label="item"
+                                        :value="item"
+                                    >
+                                    </el-option>
+                                </el-select>
+                            </el-form-item>
+                            <el-form-item label="alpha值" prop="alphaValue">
+                                <el-input
+                                    v-model.trim="formData.alphaValue"
+                                    style="width: 340px"
+                                    placeholder="请输入alpha值"
+                                />
+                            </el-form-item>
+                        </el-form>
+                    </div>
+                </div>
+            </div>
+            <!-- 批量计算 -->
+            <div class="batch-wrap" v-else></div>
+            <div class="dia-bot">
+                <el-button
+                    type="primary"
+                    style="margin-right: 20px"
+                    @click="saveHandle"
+                    :loading="loading"
+                    >指数修匀计算</el-button
+                >
+                <el-button type="primary" plain @click="cancelHandle('cancel')">取消</el-button>
+            </div>
+            <el-popover
+                placement="top-start"
+                width="500"
+                trigger="click">
+                <p style="padding:30px;line-height:25px;" v-html="$parent.tips.get('alpha')"/>
+                <span slot="reference" class="tip-label">公式说明</span>
+            </el-popover>
+        </div>
+    </el-dialog>
+</template>
+
+<script>
+import { dataBaseInterface } from '@/api/api.js';
+import { formRules } from './util';
+export default {
+    props:{
+        isOpenSmooth:{
+            type:Boolean,
+            default:false
+        },
+        computedSource:{ //常规 or 批量
+            type:Number,
+            default:1
+        },
+        operationForm:{
+            type:Object,
+            default:()=>{return{
+                edb_id:'',
+                oldedb_id:''
+            }}
+        }
+    },
+    data() {
+        return {
+            formData:{
+                targetName:'',
+                unit:'',
+                menu:'',
+                frequency:'',
+                alphaValue:''
+            },
+            formRules,
+            frequencyArr: ['日度', '周度','旬度', '月度', '季度', '年度'],
+            catalogArr:[],
+            levelProps: {
+                label: 'ClassifyName',
+                value: 'ClassifyId',
+                children: 'Children',
+            },
+
+            select_target:'',
+            search_page:1,
+            search_have_more:false,
+            searchOptions:[],
+            current_search:'',
+
+            tableData:[],
+            page_no:1,
+            tableColums:[
+                    {
+                    label: '指标ID',
+                    key: 'EdbCode',
+                },
+                {
+                    label: '指标名称',
+                    key: 'EdbName',
+                },
+                {
+                    label: '频度',
+                    key: 'Frequency',
+                },
+                {
+                    label: '单位',
+                    key: 'Unit',
+                },
+                {
+                    label: '起始时间',
+                    key: 'StartDate',
+                    minwidthsty: '100px'
+                },
+                {
+                    label: '更新时间',
+                    key: 'ModifyTime',
+                    minwidthsty: '110px'
+                },
+                {
+                    label: '来源',
+                    key: 'SourceName',
+                },
+            ],
+            dataList:[],
+
+            loading:false,
+        };
+    },
+    watch:{
+        isOpenSmooth(newVal){
+            if(newVal){
+                this.getMenu()
+                if(this.operationForm.edb_id){
+                    this.select_target = this.operationForm.oldedb_id
+                    this.getDataList()
+                    this.setDefaultOption(this.operationForm)
+                }
+            }else{
+                this.init()
+            }
+        }
+    },
+    methods: {
+        init(){
+
+        },
+        searchLoad() {
+            if(!this.search_have_more) return;
+            this.searchApi(this.current_search,++this.search_page)
+        },
+        searchApi(query,page=1){
+            dataBaseInterface.targetSearchByPage({
+                KeyWord:query,
+                CurrentIndex: page,
+            }).then(res => {
+                if(res.Ret !== 200) return
+                const { List,Paging } = res.Data;
+                this.search_have_more = page < Paging.Pages;
+                let arr = page === 1 ? List : this.searchOptions.concat(List);
+                this.searchOptions = arr;
+            })
+        },
+        /* 指标列表 */
+        getTarget(query) {
+            this.search_page = 1;
+            this.current_search = query;
+            this.searchApi(this.current_search);
+        },
+        /* 聚焦获取当前检索 */
+        inputFocusHandle(e) {
+            this.search_page = 1;
+            this.current_search = e.target.value;
+            this.searchApi(this.current_search);
+        },
+        /* 获取目录结构 */
+        getMenu() {
+            dataBaseInterface.menuListV3().then((res) => {
+                if (res.Ret === 200) {
+                    this.catalogArr = res.Data.AllNodes || [];
+                }
+            });
+        },
+        /* 选择指标 */
+        chooseTarget(val) {
+            if(val) {
+                let obj = this.searchOptions.find(item => item.EdbInfoId === val);
+                //同步指标信息
+                this.setDefaultOption(obj);
+                this.page_no = 1;
+                this.dataList.length ? this.$refs.dataUl.scrollTop = 0 : null;
+                this.getDataList()
+            }else {
+                this.tableData = [];
+                this.dataList = [];
+            }
+        },
+        setDefaultOption(obj){
+            this.formData = {
+                targetName:obj.EdbName+'指数修匀',
+                unit:obj.Unit,
+                frequency:obj.Frequency,
+                menu:obj.ClassifyId||'',
+                alphaValue:obj.Formula||''
+            }
+        },
+        getDataList(){
+            dataBaseInterface.targetList({
+                PageSize: 10,
+                CurrentIndex: this.page_no,
+                EdbInfoId: this.select_target,
+            }).then(res => {
+                if(res.Ret === 200) {
+                    if(res.Data) {
+                        res.Data.Item.ModifyTime = res.Data.Item.ModifyTime.substr(0,10);
+                        this.tableData = [res.Data.Item] || [];
+                        this.haveMore =  this.page_no < res.Data.Paging.Pages ? true : false;
+                        this.dataList = this.page_no === 1 ? (res.Data.Item.DataList || []) : this.dataList.concat(res.Data.Item.DataList);
+                    }else {
+                        this.tableData = [];
+                        this.dataList = [];
+                    }
+                }
+            })
+        },
+        handleSelectBtnClick(){},
+        delTarget(){},
+        scrollHandle(){},
+        async saveHandle(){
+            console.log('aaa?')
+            if(!this.select_target){
+                this.$message.warning('指标不能为空')
+                return
+            }
+            await this.$refs.form.validate();
+            this.loading = true;
+
+            const {targetName,unit,menu,frequency,alphaValue} = this.formData
+            let params = {
+                Source:this.$route.path==='/database'?72:73,
+                EdbName:targetName,
+                Unit:unit,
+                ClassifyId:menu,
+                Frequency:frequency,
+                Formula:alphaValue,
+                FromEdbInfoId:this.select_target
+            }
+            const res = this.operationForm.edb_id 
+            ? await dataBaseInterface.calculateTargetEdit({ ...params,EdbInfoId: this.operationForm.edb_id })
+            : await dataBaseInterface.calculateTargetSave(params)
+            if(res.Ret!==200) return 
+            this.$message.success(res.Msg)
+            this.operationForm.edb_id 
+                ? this.$emit('addCallBack','edit') 
+                : this.$emit('addCallBack','add',{ code:res.Data.UniqueCode,id:res.Data.EdbInfoId,classifyId:params.ClassifyId });
+            this.init();
+
+        },
+        cancelHandle(type) {
+            this.init();
+            this.$emit('cancel');
+            type==='cancel' && this.$emit('openPrev');
+        },
+    },
+};
+</script>
+
+<style lang="scss">
+.smooth-edb-dialog-wrap{
+    .el-cascader .el-input {
+        width: 340px;
+    }
+    .min-top {
+        padding: 20px 30px;
+        border: 1px solid #ECECEC;
+        box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
+        border-radius:4px;
+    }
+    .middle {
+        margin-top: 20px;
+        .data-ul {
+            margin-top: 5px;
+            border-bottom: 1px solid #dcdfe6;
+            max-height: 140px;
+            overflow-y: auto;
+            .value-item {
+                padding: 14px 0;
+                border: 1px solid #dcdfe6;
+                border-bottom: none;
+                display: flex;
+                justify-content: space-around;
+                .value-label {
+                    position: relative;
+                    color: #666;
+                }
+                .new-tag {
+                    width: 6px;
+                    height: 6px;
+                    display: inline-block;
+                    position: absolute;
+                    left: -12px;
+                    top: 50%;
+                    transform: translateY(-50%);
+                    border-radius: 50%;
+                    background: #f00;
+                }
+            }
+        }
+        .form-cont {
+            padding-top: 30px;
+            margin-top: 30px;
+            border-top: 1px dashed #AAB4CC;
+            input::-webkit-outer-spin-button,
+            input::-webkit-inner-spin-button {
+                    -webkit-appearance: none;
+            }
+            input[type="number"]{
+                -moz-appearance: textfield;
+            }
+        }
+    }
+    .dia-bot {
+        padding: 20px 0 30px;
+        display: flex;
+        justify-content: center;
+    }
+    .tip-label {
+        position: absolute;
+        bottom: 30px;
+        right: 30px;
+        color: #409EFF;
+        cursor: pointer;
+    }
+}
+</style>

+ 23 - 1
src/views/dataEntry_manage/databaseComponents/util.js

@@ -20,6 +20,16 @@ export const formRules= {
 	],
 	],
 	calendar_type: [
 	calendar_type: [
 		{ required: true, message: '日历不能为空',trigger: 'blur' }
 		{ required: true, message: '日历不能为空',trigger: 'blur' }
+	],
+	alphaValue:[
+		{ validator:(rule,value,callback)=>{
+			if(Number(value)<0||Number(value)>1){
+				callback(new Error("请输入>0,<1的数值"))
+			}else{
+				callback()
+			}
+		},trigger:'change'},
+		{ required:true,message:'alpha值不能为空',trigger:'blur'},
 	]
 	]
 }
 }
 
 
@@ -88,6 +98,10 @@ export const computedTypes = [
 	{
 	{
 		name: '累计值',
 		name: '累计值',
 		type: 'accumulate'
 		type: 'accumulate'
+	},
+	{
+		name:'指数修匀计算',
+		type:'alpha'
 	}
 	}
 ]
 ]
 
 
@@ -124,6 +138,10 @@ export const computedBatchTypes = [
 	{
 	{
 		name: '累计值',
 		name: '累计值',
 		type: 'accumulate'
 		type: 'accumulate'
+	},
+	{
+		name:'指数修匀计算',
+		type:'alpha'
 	}
 	}
 ]
 ]
 
 
@@ -396,5 +414,9 @@ export const formulaTip = new Map([
 	日度数据年初至今:日期同原日度数据。将每年1月1日(含)到日度数据所在日期(含)之间的日度值,进行加总。<br>
 	日度数据年初至今:日期同原日度数据。将每年1月1日(含)到日度数据所在日期(含)之间的日度值,进行加总。<br>
 	周度数据年初至今:日期同原周度数据。将周度值转成日度频率,空值用插值法插值,然后算法同日度年度至今,再除以7<br>
 	周度数据年初至今:日期同原周度数据。将周度值转成日度频率,空值用插值法插值,然后算法同日度年度至今,再除以7<br>
 	月度/季度数据年初至今:日期同原月度/季度数据,将每年1月1日(含)到月度数据所在日期(含)之间的月度/季度值,进行加总<br>
 	月度/季度数据年初至今:日期同原月度/季度数据,将每年1月1日(含)到月度数据所在日期(含)之间的月度/季度值,进行加总<br>
-	以此类推`]
+	以此类推`],
+	['alpha',`指数修匀计算公式:<br>
+	1、设定指数修匀值序列的初始值=原来时间序列的初始值 <br>
+	2、选择平滑系数alpha值:在0-1之间,开区间 <br>
+	3、本期指数修匀值=alpha*本期实际值+(1-alpha)*上期指数修匀值`]
 ])
 ])

+ 25 - 5
src/views/dataEntry_manage/databaseList.vue

@@ -443,7 +443,15 @@
       :isOpenDialog.sync="isLookHistory"
       :isOpenDialog.sync="isLookHistory"
       :edbId="lookEdbId"
       :edbId="lookEdbId"
     />
     />
-
+		<!-- 指数修匀弹窗 -->
+		<SmoothEdbDialog 
+			:is-open-smooth="computed_type==='alpha'"
+			:computed-source="computed_source"
+			:operationForm="operationForm"
+			@cancel="computed_type=0"
+			@openPrev="isOpenComputed=true"
+			@addCallBack="addComputedCallBack"
+		/>
 	</div>
 	</div>
 </template>
 </template>
 
 
@@ -469,10 +477,11 @@ import batchComputedDialog from './databaseComponents/batchComptedDialog.vue';
 import diffusionIndexDialog from './databaseComponents/diffusionIndexDia.vue';
 import diffusionIndexDialog from './databaseComponents/diffusionIndexDia.vue';
 import updateNewestDataDia from './databaseComponents/updateNewestDia.vue';
 import updateNewestDataDia from './databaseComponents/updateNewestDia.vue';
 import EdbLabelList from '@/components/edbLabelList.vue';
 import EdbLabelList from '@/components/edbLabelList.vue';
+import SmoothEdbDialog from './databaseComponents/smoothEdbDialog.vue';
 export default {
 export default {
 	name: '',
 	name: '',
-	components: { 
-		openDialog, 
+	components: {
+		openDialog,
 		addTargetDiaBase,
 		addTargetDiaBase,
 		completeTargetDia,
 		completeTargetDia,
 		computedDialog,
 		computedDialog,
@@ -489,8 +498,9 @@ export default {
 		batchComputedDialog,
 		batchComputedDialog,
 		diffusionIndexDialog,
 		diffusionIndexDialog,
 		updateNewestDataDia,
 		updateNewestDataDia,
-		EdbLabelList
-	},
+		EdbLabelList,
+		SmoothEdbDialog
+},
 	directives: {
 	directives: {
     drag(el, bindings) {
     drag(el, bindings) {
       el.onmousedown = function(e) {
       el.onmousedown = function(e) {
@@ -1103,6 +1113,7 @@ export default {
 					if(res.Ret === 200) {
 					if(res.Ret === 200) {
 						this.setComputedDialogForm(data.Source,node,data,res.Data);
 						this.setComputedDialogForm(data.Source,node,data,res.Data);
 						this.computed_type = [23,24].includes(data.Source) ? 'joint' : data.Source;
 						this.computed_type = [23,24].includes(data.Source) ? 'joint' : data.Source;
+						this.computed_type = [72,73].includes(data.Source)? 'alpha': data.Source;
 					}
 					}
 				})
 				})
 
 
@@ -1654,6 +1665,15 @@ export default {
 							moveVal: type === 22 ? dataInfo.CalculateFormula : '',
 							moveVal: type === 22 ? dataInfo.CalculateFormula : '',
 							calendar_type: type === 35 ? dataInfo.Calendar : '',
 							calendar_type: type === 35 ? dataInfo.Calendar : '',
 					}
 					}
+
+				if([72,73].includes(type)){
+					const {EdbName,EdbInfoId,Frequency,Unit,ClassifyId,Formula} = dataInfo
+					this.operationForm = {
+						edb_id: EdbInfoId,
+						oldedb_id: old_edb[0].FromEdbInfoId,
+						EdbName,Frequency,Unit,ClassifyId,Formula
+					}
+				}
 			}
 			}
 		},
 		},