Browse Source

fix:指标拼接显示日期常住

Karsa 8 months ago
parent
commit
7b4b63bc6a
1 changed files with 26 additions and 8 deletions
  1. 26 8
      src/views/dataEntry_manage/databaseComponents/jointTargetDia.vue

+ 26 - 8
src/views/dataEntry_manage/databaseComponents/jointTargetDia.vue

@@ -54,6 +54,7 @@
 						:remote-method="query=>{searchHandle(query)}"
 						@click.native="inputFocusHandle"
 						@blur="search_have_more = false"
+						@change="chooseTarget(formData.pre_edb,'pre_edb')"
 					>
 						<i slot="prefix" class="el-input__icon el-icon-search"></i>
 						<el-option
@@ -64,7 +65,7 @@
 						>
 						</el-option>
 					</el-select>
-					<span v-if="formData.pre_edb">(起始日期:{{ searchOptions.find(item => item.EdbInfoId === formData.pre_edb) ? searchOptions.find(item => item.EdbInfoId === formData.pre_edb).StartDate : ''}})</span>
+					<span v-if="formData.pre_date">(起始日期:{{ formData.pre_date}})</span>
 				</el-form-item>
 				<el-form-item label="拼接日期之后" prop="after_edb">
 					<el-select
@@ -79,7 +80,7 @@
 							:remote-method="query=>{searchHandle(query)}"
 							@click.native="inputFocusHandle"
 							@blur="search_have_more = false"
-							@change="chooseTarget(formData.after_edb,'searchOptions')"
+							@change="chooseTarget(formData.after_edb,'after_edb')"
 						>
 							<i slot="prefix" class="el-input__icon el-icon-search"></i>
 							<el-option
@@ -90,7 +91,7 @@
 							>
 							</el-option>
 						</el-select>
-						<span v-if="formData.after_edb">(最新日期:{{ searchOptions.find(item => item.EdbInfoId === formData.after_edb) ? searchOptions.find(item => item.EdbInfoId === formData.after_edb).EndDate : ''}})</span>
+						<span v-if="formData.after_date">(最新日期:{{ formData.after_date }})</span>
 				</el-form-item>
 			</template>
 			<template v-else>
@@ -107,7 +108,7 @@
 						:remote-method="query=>{searchHandle(query,'month')}"
 						@click.native="e => {inputFocusHandle(e,'month')} "
 						@blur="search_have_more = false"
-						@change="chooseTarget(formData.old_stay_edb,'searchMonthOptions')"
+						@change="chooseTarget(formData.old_stay_edb,'old_stay_edb')"
 						>
 							<i slot="prefix" class="el-input__icon el-icon-search"></i>
 							<el-option
@@ -118,7 +119,7 @@
 							>
 							</el-option>
 						</el-select>
-					<span v-if="formData.old_stay_edb">(截止日期:{{searchMonthOptions.find(item => item.EdbInfoId === formData.old_stay_edb) ? searchMonthOptions.find(item => item.EdbInfoId === formData.old_stay_edb).EndDate : ''}})</span>
+					<span v-if="formData.old_stay_date">(截止日期:{{ formData.old_stay_date }})</span>
 				</el-form-item>
 				<el-form-item label="同比值指标" prop="concat_edb">
 					<el-select
@@ -227,7 +228,7 @@ export default {
 
 				// this.searchHandle();
 				const backData = _.cloneDeep(this.params);
-				this.default_type = backData.source === 23||backData.source === 47 ? 1 : 2;
+				this.default_type = [23,47].includes(backData.source) ? 1 : 2;
 
 				this.formData = {
 					date: backData.date,
@@ -242,13 +243,16 @@ export default {
 				}
 
 				//options 回显
-				if(backData.source === 23||backData.source === 47) {
+				if([23,47].includes(backData.source)) {
 					this.searchOptions = backData.from_arr.map(item => ({
 						EdbInfoId: item.FromEdbInfoId,
 						EdbName: item.FromEdbName,
 						StartDate: item.StartDate,
 						EndDate: item.EndDate,
 					}))
+
+					this.formData.pre_date = backData.from_arr[0].StartDate
+					this.formData.after_date = backData.from_arr[0].EndDate
 				}else {
 					this.searchMonthOptions = backData.from_arr.filter(obj => obj.FromTag === 'A').map(item => ({
 						EdbInfoId: item.FromEdbInfoId,
@@ -256,6 +260,8 @@ export default {
 						StartDate: item.StartDate,
 						EndDate: item.EndDate,
 					}));
+					
+					this.formData.old_stay_date = backData.from_arr.find(obj => obj.FromTag === 'A').EndDate
 
 					this.searchMonthConcatOptions = backData.from_arr.filter(obj => obj.FromTag === 'B').map(item => ({
 						EdbInfoId: item.FromEdbInfoId,
@@ -286,8 +292,11 @@ export default {
 			formData: {
 				date: '',
 				pre_edb: '',
+				pre_date: '',
 				after_edb: '',
+				after_date: '',
 				old_stay_edb: '',
+				old_stay_date: '',
 				concat_edb: '',
 				edb_name: '',
 				menu: '',
@@ -359,13 +368,22 @@ export default {
 		// 选中指标更新默认值
 		chooseTarget(val,key){
 			if(!val) return
-			const arr=key==='searchMonthOptions'?this.searchMonthOptions:this.searchOptions
+			const arr=key==='old_stay_edb'?this.searchMonthOptions:this.searchOptions
+			
 			let obj = arr.find(item => item.EdbInfoId === val);
 			console.log(obj);
 			this.formData.edb_name=`${obj.EdbName}/拼接`
 			this.formData.menu=obj.ClassifyId||''
 			this.formData.frequency=obj.Frequency
 			this.formData.unit=obj.Unit
+
+			//日期也要常驻显示 加字段存了
+			const showDateMap = {
+				'old_stay_edb': { key:'old_stay_date',valKey:'EndDate' },
+				'after_edb': { key:'after_date',valKey:'EndDate' },
+				'pre_edb': { key:'pre_date',valKey:'StartDate' }
+			}
+			this.formData[showDateMap[key].key] = obj[showDateMap[key].valKey]
 		},
 
 		/* 搜索 */