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

先百分比再处理小数点

Karsa 1 жил өмнө
parent
commit
4b5ed25cd3

+ 7 - 3
src/views/datasheet_manage/common/customTable.js

@@ -286,6 +286,9 @@ export function transDecimalPlace(str,decimalNum) {
       : `${s}${suffix}`;
   }
 
+  let integerStr = str.split('.')[0],
+  decimalStr = str.split('.')[1];
+
   if(decimalNum>0) {
     return `${s}${'0'.repeat(decimalNum)}${suffix}`
   } else {
@@ -336,10 +339,11 @@ export function transNumPercentType(str,type) {
 }
 
 export function transValueFormat(str,{nt,pn}) {
-  let str1 = str,str2 = '';
-  if(pn !== 0) str1 = transDecimalPlace(str,pn)
+  let str1 = '',str2 = '';
+  
+  str1 = nt ? transNumPercentType(str,nt) : str;
   
-  str2 = nt ? transNumPercentType(str1,nt) : str1;
+  str2 = pn!==0 ? transDecimalPlace(str1,pn) : str1;
 
   return str2;
 }

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

@@ -100,7 +100,7 @@
                   :data-rindex="rowHeader[index]"
                   :data-cindex="columnHeader[cell_index]"
                   :data-key="cell.Uid"
-                >{{ cell.ShowStyle?cell.ShowFormatValue:cell.ShowValue }}</span>
+                >{{ cell.ShowStyle?cell.RealValue:cell.ShowValue }}</span>
               </el-popover>
 
               <!-- 数字格式化显示 -->
@@ -110,7 +110,7 @@
                 :data-cindex="columnHeader[cell_index]"
                 :data-key="cell.Uid"
               >
-                {{cell.ShowFormatValue}}
+                {{cell.RealValue}}
               </span>
 
               <span
@@ -1158,10 +1158,10 @@ export default {
     },
 
     /* 改变单元格显示文本 */
-    updateCellStyle({ShowStyle,ShowFormatValue}) {
+    updateCellStyle({ShowStyle,RealValue}) {
       
       this.$set(this.selectCell,'ShowStyle',ShowStyle)
-      this.$set(this.selectCell,'ShowFormatValue',ShowFormatValue)
+      this.$set(this.selectCell,'RealValue',RealValue)
       console.log(this.selectCell)
     }
   },

+ 5 - 4
src/views/datasheet_manage/components/toolBarSection.vue

@@ -134,27 +134,28 @@ export default {
         this.option.pn = parseInt(`-${getDecimalPlaces(value)}`)
       }
 
-      let nval = transDecimalPlace(value,this.option.pn)
+      let nval = transValueFormat(value,this.option)
+      // let nval = transDecimalPlace(value,this.option.pn)
       // console.log(nval)
 
       this.$emit('updateCell',{
         ShowStyle: JSON.stringify(this.option),
-        ShowFormatValue: nval
+        RealValue: nval
       })
     },
 
     /* 处理百分位或数字格式 */
     changeCellType() {
       if(!isNumberVal(this.cell.ShowValue)) return
+      this.option.pn = 0
 
       let value = _.cloneDeep(this.cell.ShowValue)
 
       let nval = transNumPercentType(value,this.option.nt)
-      console.log(nval)
 
       this.$emit('updateCell',{
         ShowStyle: JSON.stringify(this.option),
-        ShowFormatValue: nval
+        RealValue: nval
       })
     }
   },