Эх сурвалжийг харах

插值的编辑需要遍历查找获取最新的数据

Karsa 1 жил өмнө
parent
commit
2dae2f1796

+ 14 - 12
src/views/datasheet_manage/components/MixedTable.vue

@@ -327,8 +327,6 @@ export default {
       isInsertDateDialog: false,//导入日期弹窗
       insertDateInfo: {},
 
-      calculateChainList: [],//公式链 key数组 后端需要
-
       isInsertCalculate: false,//插入指标计算值
       insertCalculateInfo: {},//指标计算单元格info
 
@@ -570,7 +568,10 @@ export default {
       }
 
       /* 不是数字类型,清除原来设置的格式 */
-      if(!isNumberVal(value)) cell.ShowStyle = '';
+      if(!isNumberVal(value)){
+        cell.ShowStyle = '';
+        cell.ShowStyle = '';
+      } ;
 
       //判断是否是有插入值的依赖单元格 更新值或重置关系
       this.checkCellRelation(cell)
@@ -793,22 +794,23 @@ export default {
     },
 
     /* 插入选择指标的值 */
-    insertSelectData({ edbId,value,relationDate,str }) {
+    insertSelectData({ edbId,value,relationDate,relationUid,str }) {
 
       this.insertTargetCell.DataType = 5;
       this.insertTargetCell.ShowValue = value;
       this.insertTargetCell.Value = str;
       this.insertTargetCell.EdbInfoId = edbId;
       this.insertTargetCell.DataTime = relationDate;
+      this.insertTargetCell.ShowFormatValue = this.insertTargetCell.ShowStyle ? transDecimalPlace(value,JSON.parse(this.insertTargetCell.ShowStyle)) : '';
 
       value ? this.$message.success('插入成功') : this.$message.warning('该日期当前无值')
 
       //如果有关联表格日期就建立新的关联关系
-      if(relationDate) {
+      if(relationDate&&relationUid) {
         let relation = {
           insert_cell: {
             key: this.insertTargetCell.Uid,
-            relation_date: this.selectCell.Uid,
+            relation_date: relationUid,
             relation_edb: '',
           }
         }
@@ -946,9 +948,7 @@ export default {
       resetDialogCellStyle();
 
       if(type === 'cell-edit') { //编辑日期
-        // const { DataTimeType } = this.insertTargetCell;
         this.insertDateInfo = {
-          // key: DataTimeType===1? 'insert-sys-date' : 'insert-edb-date',
           ...this.insertTargetCell
         }
       }else {
@@ -1017,21 +1017,22 @@ export default {
     /* 导入指标计算值 */
     insertCalculateData(item) {
       // console.log(item)
-      const { InsertValue,EdbInfoId,Str,Date } = item;
+      const { InsertValue,EdbInfoId,Str,relationDate,relationUid } = item;
       this.insertTargetCell.DataType = 7;
       this.insertTargetCell.ShowValue = InsertValue;
       this.insertTargetCell.Value = Str;
       this.insertTargetCell.EdbInfoId = EdbInfoId;
-      this.insertTargetCell.DataTime = Date;
+      this.insertTargetCell.DataTime = relationDate;
+      this.insertTargetCell.ShowFormatValue = this.insertTargetCell.ShowStyle ? transDecimalPlace(InsertValue,JSON.parse(this.insertTargetCell.ShowStyle)) : '';
 
       InsertValue ? this.$message.success('插入成功') : this.$message.warning('该日期当前无值')
 
       //如果有关联表格日期就建立新的关联关系
-      if(Date) {
+      if(relationDate&&relationUid) {
         let relation = {
           insert_cell: {
             key: this.insertTargetCell.Uid,
-            relation_date: this.selectCell.Uid,
+            relation_date: relationUid,
             relation_edb: '',
           }
         }
@@ -1069,6 +1070,7 @@ export default {
       this.insertTargetCell.Value = str;
       this.insertTargetCell.EdbInfoId = 0;
       this.insertTargetCell.DataTime = '';
+      this.insertTargetCell.ShowFormatValue = this.insertTargetCell.ShowStyle ? transDecimalPlace(insertValue,JSON.parse(this.insertTargetCell.ShowStyle)) : '';
 
       this.$message.success('插入成功')
     },

+ 16 - 7
src/views/datasheet_manage/components/calculateDateDia.vue

@@ -12,7 +12,8 @@
           <el-input
 						v-model="list.Date"
 						placeholder="选择日期"
-						style="width: 250px" 
+						style="width: 240px"
+						readonly
 						@focus="selectIndex=index+1"
 						@keyup.native="e => { e.keyCode===13 && initSelect}" 
 						:class="{'select': selectIndex===index+1}"
@@ -25,13 +26,13 @@
 					/>
 				</li>
 			</ul>
-			<span class="add-icon" @click="addTargetHandle">
+			<div class="add-icon" @click="addTargetHandle">
 				<i
 					class="el-icon-circle-plus-outline"
 					style="color: #5882ef; font-size: 16px"
 				/>
 				添加更多日期
-			</span>
+			</div>
 			<div class="computed-min">
 				<div class="computed-section">
 					<label class="label">计算公式</label>
@@ -56,7 +57,7 @@
 
 <script>
 import * as sheetInterface from "@/api/modules/sheetApi.js";
-import { resetDialogCellStyle } from "../common/customTable";
+import { resetDialogCellStyle,findCellByKey } from "../common/customTable";
 const tag_arr = [];
 for(let i=0;i<26;i++) tag_arr.push(String.fromCharCode(65+i));
 export default {
@@ -78,7 +79,11 @@ export default {
 				let valueObj = JSON.parse(this.info.Value);
 
 				this.formula = valueObj.Formula;
-				this.addList = valueObj.RelationCellList;
+				//日期有动态日期更新的问题 需要每次找单元格信息重新赋值最新的日期
+				this.addList = valueObj.RelationCellList.map(_ => ({
+					..._,
+					Date: findCellByKey(this.$parent.config.data,_.Uid).ShowValue
+				}));
 			}
 			
 		},
@@ -209,8 +214,7 @@ export default {
   }
 	.dialog-main {
 		padding: 25px 42px 25px 25px;
-		max-height: 500px;
-		overflow-y: auto;
+		
 		@media screen and (max-height:850px){
 			box-sizing: border-box;
 			height: 65vh;
@@ -223,6 +227,10 @@ export default {
 			display: flex;
 			flex-wrap: wrap;
 			justify-content: space-between;
+			max-height: 300px;
+			overflow: hidden;
+			overflow-y: auto;
+			padding-right: 40px;
 			.add-li {
 				position: relative;
 				margin-bottom: 48px;
@@ -240,6 +248,7 @@ export default {
 			}
 		}
 		.add-icon {
+			margin:10px 0;
 			font-size: 16px;
 			color: #5882ef;
 			cursor: pointer;

+ 31 - 29
src/views/datasheet_manage/components/calculateEdbDia.vue

@@ -228,7 +228,7 @@
 import { dataBaseInterface } from '@/api/api.js';
 import * as sheetInterface from "@/api/modules/sheetApi.js";
 import * as preDictEdbInterface from '@/api/modules/predictEdbApi.js';
-import { resetDialogCellStyle } from "../common/customTable";
+import { resetDialogCellStyle,findCellByKey } from "../common/customTable";
 import selectTarget from '@/views/chartRelevance_manage/components/selectTarget.vue';
 import edbDetailSection from './edbDetailSection.vue';
 import dateMoveWaySec from './dateMoveWaySection.vue'
@@ -246,7 +246,7 @@ export default {
   watch: {
     isShow(nval) {
       if(!nval) return
-      console.log(this.info)
+      
       this.getTableEdbList()
       const { source } = this.info;
 
@@ -281,7 +281,8 @@ export default {
         this.dateSelectForm = {
           Type: DataTime ? 2 : 1,
           MoveForward: MoveForward || 0,
-          relationDate: this.info.DataTime
+          relationUid: this.info.DataTime ? this.getRelationCellKey() : '',
+          relationDate: this.info.DataTime ? this.getNewCellDate() : '',//日期会动态更新 需要找关联单元格最新的数据
         }
         this.selectTableEdbHandle({EdbInfoId})
 
@@ -340,6 +341,7 @@ export default {
         Type:1,
         MoveForward: 0,
         relationDate: '',//关联的表格日期
+        relationUid: '',//关联格子的uid
       }
     }
   },
@@ -360,9 +362,28 @@ export default {
         this.edbArrFromTable = res.Data.List;
     },
 
-    // 在选择表格中日期的话在弹窗中显示所选日期 无实际作用 显示用一下
+    // 在选择表格中日期的话在弹窗中显示所选日期 关联uid
     changeRleationDate(cell) {
-      this.dateSelectForm.relationDate=cell.DataType===1?cell.ShowValue:'';
+      this.dateSelectForm.relationDate=cell.DataType===1 ? cell.ShowValue : '';
+      this.dateSelectForm.relationUid=this.dateSelectForm.relationDate ? cell.Uid : '';
+    },
+
+    /* 找日期关联的key 本来想存在单元格内部后端不想动原来结构 还是自己根据关联关系找吧 */
+    getRelationCellKey() {
+      let relationObj = this.$parent.insertRelationArr.find(_=> _.key === this.info.Uid)
+      if(!relationObj) return ''
+
+      return relationObj.relation_date.key
+    },
+
+    /* 先找关联日期的key  再根据key找单元格数据取到最新的日期 */
+    getNewCellDate() {
+      let relationKey = this.getRelationCellKey();
+      if(!relationKey) return '';
+
+      let relationDateCell = findCellByKey(this.$parent.config.data,relationKey)
+      
+      return relationDateCell.ShowValue
     },
 
     /* 计算结果 */
@@ -386,7 +407,7 @@ export default {
 
       let DataTime = '';
       if(this.dateSelectForm.Type===2) { //选框为表格日期再去取Date
-        DataTime = this.$parent.selectCell.DataType === 1 ? this.$parent.selectCell.ShowValue : ''
+        DataTime = this.dateSelectForm.relationDate
       }
 
       let params = {
@@ -406,13 +427,10 @@ export default {
       if(res.Ret!==200) return 
 
       this.showResult = true;
-      // this.calculateShowData = res.Data.List || [];
-
-      // let InsertValue = this.calculateShowData.length 
-      //   ? (this.calculateShowData.find(_ => _.DataTime===res.Data.Date) ? this.calculateShowData.find(_ => _.DataTime===res.Data.Date).Value.toString() : '') 
-      //   : ''
+      
       this.chooseItem = {
-        Date:DataTime,
+        relationDate: DataTime,
+        relationUid: this.dateSelectForm.Type===2 ? this.dateSelectForm.relationUid : '',
         EdbInfoId: this.selectEdbInfo.EdbInfoId,
         InsertValue: res.Data.ShowValue||"",
         Str: JSON.stringify(params)
@@ -425,22 +443,6 @@ export default {
       
     },
 
-    /* 已计算过改参数重新计算 */
-    // changeParams() {
-    //   this.showResult && this.calculateHandle()
-    // },
-
-    // /* 插入值 */
-    // insertData() {
-
-    //   // if(this.$parent.selectCell.DataType !== 1) return this.$message.warning('请在表格中选择日期')
-        
-    //   if(!this.calculateShowData.length) return this.$message.warning('该日期无数据')
-      
-    //   this.$emit('insert',this.chooseItem)
-    //   this.cancelHandle();
-    // },
-
     /* 选择指标 */
     async selectTargetHandle(e) {
       this.changeSource();
@@ -502,7 +504,7 @@ export default {
 				calendarType: '公历',
 				valueType: '期末值'
       }
-      this.dateSelectForm = {Type:1,MoveForward: 0}
+      this.dateSelectForm = {Type:1,MoveForward: 0,relationDate: '',relationUid: ''}
       this.$refs.dateMoveWayRef&&this.$refs.dateMoveWayRef.initData();
     },
 

+ 28 - 8
src/views/datasheet_manage/components/selectTargetValueDia.vue

@@ -68,7 +68,7 @@
 import * as sheetInterface from "@/api/modules/sheetApi.js";
 import { dataBaseInterface } from '@/api/api.js';
 import selectTarget from '@/views/chartRelevance_manage/components/selectTarget.vue';
-import { resetDialogCellStyle } from "../common/customTable";
+import { resetDialogCellStyle,findCellByKey } from "../common/customTable";
 import dateMoveWaySec from './dateMoveWaySection.vue'
 export default {
   props: {
@@ -89,7 +89,8 @@ export default {
         this.dateSelectForm = {
           Type: this.info.DataTime ? 2 : 1,
           MoveForward: valueObj.MoveForward || 0,
-          relationDate: this.info.DataTime
+          relationDate: this.info.DataTime ? this.getNewCellDate() : '',//日期会动态更新 需要找关联单元格最新的数据
+          relationUid: this.info.DataTime ? this.getRelationCellKey() : ''
         }
 
         this.getEdbInfo(this.info.EdbInfoId);
@@ -112,6 +113,7 @@ export default {
         Type:1,
         MoveForward: 0,
         relationDate: '',//关联的表格日期
+        relationUid: '',//关联格子的uid
       }
     }
   },
@@ -126,9 +128,10 @@ export default {
       this.edbInfo = edb;
     },
 
-    // 在选择表格中日期的话在弹窗中显示所选日期 无实际作用 显示用一下
+    // 在选择表格中日期的话在弹窗中显示所选日期 关联uid
     changeRleationDate(cell) {
-      this.dateSelectForm.relationDate=cell.DataType===1?cell.ShowValue:'';
+      this.dateSelectForm.relationDate=cell.DataType===1 ? cell.ShowValue : '';
+      this.dateSelectForm.relationUid=this.dateSelectForm.relationDate ? cell.Uid : '';
     },
 
     /* 获取指标信息回显 */
@@ -140,6 +143,24 @@ export default {
       this.$refs.selectRef.search_txt = EdbName;
     },
 
+    /* 找日期关联的key 本来想存在单元格内部后端不想动原来结构 还是自己根据关联关系找吧 */
+    getRelationCellKey() {
+      let relationObj = this.$parent.insertRelationArr.find(_=> _.key === this.info.Uid)
+      if(!relationObj) return ''
+
+      return relationObj.relation_date.key
+    },
+
+    /* 先找关联日期的key  再根据key找单元格数据取到最新的日期 */
+    getNewCellDate() {
+      let relationKey = this.getRelationCellKey();
+      if(!relationKey) return '';
+
+      let relationDateCell = findCellByKey(this.$parent.config.data,relationKey)
+      
+      return relationDateCell.ShowValue
+    },
+
 
     //插入值的时候再去计算结果
     async insertData() {
@@ -147,7 +168,7 @@ export default {
 
       let Date='';
       if(this.dateSelectForm.Type===2) { //选框为表格日期再去取Date
-        Date = this.$parent.selectCell.DataType === 1 ? this.$parent.selectCell.ShowValue : '';
+        Date = this.dateSelectForm.relationDate;
       }
 
       const res = await sheetInterface.getDateLatelyData({ 
@@ -166,6 +187,7 @@ export default {
 
       this.chooseItem = {
         relationDate: Date,
+        relationUid: this.dateSelectForm.Type===2 ? this.dateSelectForm.relationUid : '',
         edbId: this.edbInfo.EdbInfoId,
         value,
         str: JSON.stringify({
@@ -174,8 +196,6 @@ export default {
         })
       }
 
-      console.log( this.chooseItem)
-
       this.$emit('insert',this.chooseItem)
       this.cancelHandle();
     },
@@ -185,7 +205,7 @@ export default {
       this.result = {};
       this.edbInfo=null;
       this.chooseItem = { edbId: 0,value: '',date: '' }
-      this.dateSelectForm = {Type:1,MoveForward: 0}
+      this.dateSelectForm = {Type:1,MoveForward: 0,relationDate: '',relationUid: '',}
       this.$refs.dateMoveWayRef&&this.$refs.dateMoveWayRef.initData();
     },
 

+ 6 - 3
src/views/datasheet_manage/mixedSheetEdit.vue

@@ -6,7 +6,7 @@
           <el-input
             v-model="sheetForm.name"
             placeholder="请输入表格名称"
-            style="width:240px"
+            style="width:220px"
             clearable>
           </el-input>
         </li>
@@ -14,7 +14,7 @@
           <el-cascader
             v-model="sheetForm.classify"
             :options="classifyArr"
-            style="width:240px;"
+            style="width:220px;"
             :props="{
               label: 'ExcelClassifyName',
               value: 'ExcelClassifyId',
@@ -42,6 +42,7 @@
       </ul>
       <div>
         <span v-if="updateTime" style="color:#999999 ;">最近保存时间:{{updateTime}}</span>
+        <el-button type="primary" size="medium" @click="()=>{ sheetInit=false;getDetail('refresh')}" style="margin-left:10px" icon="el-icon-refresh-right">更新</el-button>
         <el-button type="primary" size="medium" @click="saveSheetHandle" style="margin-left:10px" v-if="hasPermission">保存</el-button>
         <el-button type="primary" size="medium" plain @click="backHandle">返回</el-button>
       </div>
@@ -127,7 +128,7 @@ export default {
     },
 
     /* 获取表格详情 */
-    async getDetail() {
+    async getDetail(type='init') {
       if(!this.sheetId) return
 
       const res = await sheetInterface.sheetDetail({
@@ -156,6 +157,8 @@ export default {
       this.updateTime =  this.$moment(ModifyTime).format('YYYY-MM-DD HH:mm:ss')
 
       this.$refs.mixedTableRef.initData(TableData);
+      
+      type==='refresh' && this.$message.success('表格数据已更新')
     },
 
     /* 获取分类 */