Răsfoiți Sursa

混合表格公式计算找数逻辑

Karsa 1 an în urmă
părinte
comite
0d6509ca57

+ 10 - 0
src/views/datasheet_manage/common/customTable.js

@@ -46,6 +46,16 @@ export function findCellByFactor (str) {
   return el ? (el.innerText||el.value||'') : null;
 }
 
+//根据因数找元素值 混合表版 显示值不能作为数据值了
+export function findCellByFactorMixed(arr,str) {
+  //先找key 根据key找到数据单元格的数据值
+  let cellKey = findCellKeyByFactor(str)
+  if(!cellKey) return null
+
+  let cellData = findCellByKey(arr,cellKey)
+  return cellData.ShowValue
+}
+
 //转大写
 export function toUpperCase(str) {
   let uppercaseStr = str.toUpperCase();

+ 3 - 3
src/views/datasheet_manage/components/MixedTable.vue

@@ -247,7 +247,7 @@ import {
   resetRelationStyle,
   resetDialogCellStyle,
   extractFactorsFromFormula,
-  findCellByFactor,
+  findCellByFactorMixed,
   splitString,
   toUpperCase,
   findCellKeyByFactor,
@@ -690,7 +690,7 @@ export default {
       console.log(factors)
       
       //根据因数找单元格
-      let isAllCell = factors.some(_ => findCellByFactor(_)===null||isNaN(findCellByFactor(_)))
+      let isAllCell = factors.some(_ => findCellByFactorMixed(this.config.data,_)===null||isNaN(findCellByFactorMixed(this.config.data,_)))
       if(isAllCell) {
         this.$message.warning(this.$t('OnlineExcelPage.formula_val_error_msg') )
         return '';
@@ -699,7 +699,7 @@ export default {
       let TagMap = {};
       factors.forEach(_ => {
         if(!TagMap[_]) {
-          TagMap[_] = Number(findCellByFactor(_))
+          TagMap[_] = Number(findCellByFactorMixed(this.config.data,_))
         }
       });