|
@@ -202,7 +202,10 @@ import {
|
|
|
resetRelationStyle,
|
|
|
resetDialogCellStyle,
|
|
|
extractFactorsFromFormula,
|
|
|
- findCellByFactor
|
|
|
+ findCellByFactor,
|
|
|
+ splitString,
|
|
|
+ toUpperCase,
|
|
|
+ findCellKeyByFactor
|
|
|
} from "../common/customTable";
|
|
|
import * as sheetInterface from "@/api/modules/sheetApi.js";
|
|
|
import { dataBaseInterface } from '@/api/api.js';
|
|
@@ -275,11 +278,11 @@ export default {
|
|
|
|
|
|
insertTargetCell: {},//选择右键插入时的单元格 可和右键单元格不一样 key c r
|
|
|
|
|
|
- insertRelationArr: [],
|
|
|
+ insertRelationArr: [], //表格单元格依赖关系数组
|
|
|
|
|
|
isSelectTargetValueDialog: false,
|
|
|
|
|
|
- cellrelationEdbInfo: {},
|
|
|
+ cellrelationEdbInfo: {}, //指标浮窗信息
|
|
|
|
|
|
copyCellItem: {},//复制时的单元格信息 用于粘贴赋值
|
|
|
|
|
@@ -290,14 +293,15 @@ export default {
|
|
|
key: '',
|
|
|
},
|
|
|
|
|
|
- isInsertCalculate: false,//插入指标计算值
|
|
|
- insertCalculateInfo: {
|
|
|
+ calculateChainList: [],//公式链 key数组 后端需要
|
|
|
|
|
|
- },
|
|
|
+ isInsertCalculate: false,//插入指标计算值
|
|
|
+ insertCalculateInfo: {},//指标计算单元格info
|
|
|
|
|
|
formulaTip,
|
|
|
|
|
|
hasInit:false,
|
|
|
+
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
@@ -312,7 +316,7 @@ export default {
|
|
|
if(!query
|
|
|
||checkDateFormat(query)
|
|
|
||dateOtherRegex.test(query)
|
|
|
- ||query.includes('=')
|
|
|
+ ||query.startsWith('=')
|
|
|
) return cb([])
|
|
|
|
|
|
const { DataType,EdbInfoId } = this.selectCell;
|
|
@@ -340,14 +344,14 @@ export default {
|
|
|
setFocus(e);
|
|
|
|
|
|
/* 如果当前有公式单元格在编辑就拼接当前单元格进公式 */
|
|
|
- // if(this.calculateClickCell && this.calculateClickCell.Uid!==cell.Uid) {
|
|
|
- // console.log(this.calculateClickCell)
|
|
|
- // const { cindex,rindex } = e.target.dataset;
|
|
|
- // this.calculateClickCell.Value += `${cindex}${rindex}`
|
|
|
- // }
|
|
|
+ if(this.calculateClickCell && this.calculateClickCell.Uid!==cell.Uid) {
|
|
|
+ console.log(this.calculateClickCell)
|
|
|
+ const { cindex,rindex } = e.target.dataset;
|
|
|
+ this.calculateClickCell.Value += `${cindex}${rindex}`
|
|
|
+ }
|
|
|
|
|
|
//是插值单元格时寻找关联依赖的单元格 设置选框
|
|
|
- if([4,5].includes(cell.DataType)) {
|
|
|
+ if([4,5,7].includes(cell.DataType)) {
|
|
|
const { key } = e.target.dataset;
|
|
|
if(!this.insertRelationArr.find(_ => _.key===key)) return
|
|
|
let { relation_date,relation_edb } = this.insertRelationArr.find(_ => _.key===key)
|
|
@@ -360,7 +364,7 @@ export default {
|
|
|
this.isSelectTargetValueDialog&&this.$refs.selectTargetValueRef.chooseEdb(this.$refs.selectTargetValueRef.edbInfo)
|
|
|
|
|
|
//计算指标弹窗打开时选择日期更新弹窗数据
|
|
|
- this.isInsertCalculate&&this.$refs.calculateEdbDiaRef.setChooseDate(cell)
|
|
|
+ this.isInsertCalculate&&this.$refs.calculateEdbDiaRef.showResult&&this.$refs.calculateEdbDiaRef.calculateHandle()
|
|
|
},
|
|
|
|
|
|
/* 插入值 往左往上寻找同行同列是否有符合条件的一指标一日期 */
|
|
@@ -512,6 +516,7 @@ export default {
|
|
|
cell.Value = value;
|
|
|
cell.EdbInfoId = 0;
|
|
|
cell.DataTime = '';
|
|
|
+ cell.Extra=''
|
|
|
}else {
|
|
|
//指标类型不做格式处理
|
|
|
if(cell.DataType===2) return
|
|
@@ -519,14 +524,17 @@ export default {
|
|
|
console.log(checkDateFormat(value))
|
|
|
if(checkDateFormat(value)) { //是日期格式
|
|
|
cell.DataType = 1;
|
|
|
-
|
|
|
+ cell.Extra='';
|
|
|
cell.ShowValue = checkDateFormat(value);
|
|
|
cell.Value = checkDateFormat(value);
|
|
|
- }else if(value.includes('=')) { //公式单元格
|
|
|
+ }else if(value.startsWith('=')) { //公式单元格
|
|
|
cell.DataType = 6;
|
|
|
let calculateVal = await this.getValueByFormula(value);
|
|
|
cell.ShowValue = calculateVal;
|
|
|
- // this.calculateClickCell = cell;
|
|
|
+ //处理公式关系
|
|
|
+ this.$set(cell,'Extra',this.dealFormulaConstruction(value))
|
|
|
+
|
|
|
+ console.log(cell)
|
|
|
|
|
|
}else {//自定义值
|
|
|
cell.DataType = 3;
|
|
@@ -534,6 +542,7 @@ export default {
|
|
|
cell.Value = value;
|
|
|
cell.EdbInfoId = 0;
|
|
|
cell.DataTime = '';
|
|
|
+ cell.Extra=''
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -712,7 +721,7 @@ export default {
|
|
|
'insert-sys-date': this.insertDateOpen,//导入系统日期
|
|
|
'insert-edb-date': this.insertDateOpen,//导入指标日期
|
|
|
'reset': this.clearCell, //清空
|
|
|
- 'cell-edit': editHandlesMap[this.selectCell.DataType]
|
|
|
+ 'cell-edit': this.selectCell ? editHandlesMap[this.selectCell.DataType] : null
|
|
|
}
|
|
|
keyMap[key] && keyMap[key](key)
|
|
|
|
|
@@ -729,27 +738,29 @@ export default {
|
|
|
},
|
|
|
|
|
|
/* 插入选择指标的值 */
|
|
|
- insertSelectData({ edbId,value }) {
|
|
|
+ insertSelectData({ edbId,value,date }) {
|
|
|
|
|
|
this.insertTargetCell.DataType = 5;
|
|
|
this.insertTargetCell.ShowValue = value;
|
|
|
this.insertTargetCell.Value = value;
|
|
|
this.insertTargetCell.EdbInfoId = edbId;
|
|
|
- this.insertTargetCell.DataTime = this.selectCell.ShowValue;
|
|
|
+ this.insertTargetCell.DataTime = date;
|
|
|
|
|
|
this.$message.success('插入成功')
|
|
|
|
|
|
- //建立新的关联关系
|
|
|
- let relation = {
|
|
|
- insert_cell: {
|
|
|
- key: this.insertTargetCell.Uid,
|
|
|
- relation_date: this.selectCell.Uid,
|
|
|
- relation_edb: '',
|
|
|
+ //如果有关联表格日期就建立新的关联关系
|
|
|
+ if(date) {
|
|
|
+ let relation = {
|
|
|
+ insert_cell: {
|
|
|
+ key: this.insertTargetCell.Uid,
|
|
|
+ relation_date: this.selectCell.Uid,
|
|
|
+ relation_edb: '',
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ this.setRelation(relation,5);
|
|
|
}
|
|
|
|
|
|
- this.setRelation(relation,5);
|
|
|
-
|
|
|
},
|
|
|
|
|
|
/* 清除单元格内容 格式 关联关系 */
|
|
@@ -906,15 +917,14 @@ export default {
|
|
|
setRelationStyle({ key:this.insertTargetCell.Uid },'td-choose-insert-target');
|
|
|
|
|
|
if(item === 'cell-edit') { //编辑
|
|
|
- const { Value,EdbInfoId } = this.insertTargetCell;
|
|
|
+ const { Value } = this.insertTargetCell;
|
|
|
|
|
|
let menuInfo = this.config.contextMenuOption
|
|
|
.find(_ => _.key==='insert-edb-calculate').children
|
|
|
- .find(menu => menu.source === JSON.parse(Value).source);
|
|
|
+ .find(menu => menu.source === JSON.parse(Value).Source);
|
|
|
|
|
|
this.insertCalculateInfo = {
|
|
|
...menuInfo,
|
|
|
- EdbInfoId,
|
|
|
formStr: Value,
|
|
|
}
|
|
|
}else {
|
|
@@ -929,16 +939,16 @@ export default {
|
|
|
/* 导入指标计算值 */
|
|
|
insertCalculateData(item) {
|
|
|
console.log(item)
|
|
|
- const { insertValue,EdbInfoId,str,Date } = item;
|
|
|
+ const { InsertValue,EdbInfoId,Str,Date } = item;
|
|
|
this.insertTargetCell.DataType = 7;
|
|
|
- this.insertTargetCell.ShowValue = insertValue;
|
|
|
- this.insertTargetCell.Value = str;
|
|
|
+ this.insertTargetCell.ShowValue = InsertValue;
|
|
|
+ this.insertTargetCell.Value = Str;
|
|
|
this.insertTargetCell.EdbInfoId = EdbInfoId;
|
|
|
this.insertTargetCell.DataTime = Date;
|
|
|
|
|
|
this.$message.success('插入成功')
|
|
|
|
|
|
- //如果日期有关联表格日期就建立新的关联关系
|
|
|
+ //如果有关联表格日期就建立新的关联关系
|
|
|
if(Date) {
|
|
|
let relation = {
|
|
|
insert_cell: {
|
|
@@ -979,6 +989,18 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ /* 处理因数结构 =a1+b1 => [{ Tag: a,Row:1,Key:'' }] */
|
|
|
+ dealFormulaConstruction(val) {
|
|
|
+ // 提取因数数组
|
|
|
+ let factors = extractFactorsFromFormula(val)
|
|
|
+ let arr = factors.map(str => ({
|
|
|
+ Tag: splitString(toUpperCase(str))[0],
|
|
|
+ Row: splitString(toUpperCase(str))[1],
|
|
|
+ Key: findCellKeyByFactor(str)
|
|
|
+ }))
|
|
|
+ return arr
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
/* 要支持复制粘贴把公式也带过去 公式单元格类型为6 其余就正常复制文本 */
|
|
|
copyCellHandle(e,cell) {
|
|
@@ -1008,6 +1030,7 @@ export default {
|
|
|
/* 公式单元格enter时切换编辑状态 */
|
|
|
keyEnterHandle(e,cell) {
|
|
|
e.keyCode===13 && cell.DataType===6 && this.$set(cell,'CanEdit',false)
|
|
|
+ console.log(cell)
|
|
|
this.calculateClickCell = null
|
|
|
resetDialogCellStyle()
|
|
|
},
|
|
@@ -1020,11 +1043,23 @@ export default {
|
|
|
|
|
|
this.calculateClickCell = cell;
|
|
|
|
|
|
- // setRelationStyle({ key:cell.Uid },'td-choose-insert-target')
|
|
|
+ setRelationStyle({ key:cell.Uid },'td-choose-insert-target')
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
if(e.target.childNodes[0].childNodes[0].childNodes[1].nodeName==='INPUT') e.target.childNodes[0].childNodes[0].childNodes[1].focus();
|
|
|
})
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 处理保存的参数 */
|
|
|
+ getSaveParams() {
|
|
|
+ const { data } = this.config;
|
|
|
+
|
|
|
+ let params = {
|
|
|
+ CellRelation: JSON.stringify(this.insertRelationArr),
|
|
|
+ Data: data
|
|
|
+ }
|
|
|
+
|
|
|
+ return params
|
|
|
}
|
|
|
},
|
|
|
};
|