周兴 пре 3 година
родитељ
комит
260682f26e

+ 22 - 11
src/components/base/dk-perspective/dk-pivot.vue

@@ -154,6 +154,7 @@
                                        :key="cIndex"
                                        :field="itemTop + '_' + getField(groupCols,index) + cItem.key"
                                        width="auto" :filter="false"
+                                       :digits="cItem.params?cItem.params.digits:0"
                                        :title="cItem.label"></DkTableColumn>
                       </div>
                     </vxe-colgroup>
@@ -176,6 +177,7 @@
                                    :key="cIndex"
                                    :field="itemTop + '_' + cItem.key"
                                    width="auto" :filter="false"
+                                   :digits="cItem.params?cItem.params.digits:0"
                                    :title="cItem.label"></DkTableColumn>
                   </div>
                 </div>
@@ -199,6 +201,7 @@
                            :key="cIndex"
                            :field="cItem.key"
                            width="auto" :filter="false"
+                           :digits="cItem.params?cItem.params.digits:0"
                            :title="cItem.label"></DkTableColumn>
           </div>
         </div>
@@ -289,7 +292,7 @@ export default {
     })
     const vm = Window.vm
     return {
-      vm:vm,
+      vm: vm,
       internal: {
         availableFieldKeys: this.availableFieldKeys,
         rowFieldKeys: this.rowFieldKeys,
@@ -343,7 +346,7 @@ export default {
           let value = field.getter(item);
           if (typeof value === 'boolean') {
             fieldsWithValues[field.key].valuesSet.add(value)
-          }else{
+          } else {
             if (value) {
               fieldsWithValues[field.key].valuesSet.add(value)
             }
@@ -360,7 +363,7 @@ export default {
 
       // Creates values sorted from valuesSet
       valueFilterableFields.forEach(field => {
-        console.log('bb',field.sort)
+        console.log('bb', field.sort)
         fieldsWithValues[field.key].values = Array.from(fieldsWithValues[field.key].valuesSet).sort(field.sort || naturalSort)
         // 给optionsValue赋值
         fieldsWithValues[field.key].optionValues = fieldsWithValues[field.key].values.map(it => {
@@ -449,6 +452,7 @@ export default {
 
       // 更新数据
       this.$nextTick(() => {
+        console.log('rrr', this.tableData, this.dataFields)
         this.updateValues();
       })
       return colFields
@@ -550,11 +554,11 @@ export default {
      * @author : 周兴
      * @date   : 2023/4/6 15:36
      */
-    getTitle(value){
-      console.log('vv',value)
-      if(typeof value === 'boolean'){
-        return value? vm.$t('yes'):vm.$t('no')
-      }else{
+    getTitle(value) {
+      console.log('vv', value)
+      if (typeof value === 'boolean') {
+        return value ? vm.$t('yes') : vm.$t('no')
+      } else {
         return value + '';
       }
     },
@@ -649,6 +653,8 @@ export default {
         })
 
         this.$nextTick(() => {
+          // 是否包括值域
+          let hasData = this.dataFields.length > 0 ? true : false;
           // 把数据装入table
           if (this.tableData && this.$refs.col && this.$refs.col.length > 0) {
             this.tableData.forEach(item => {
@@ -668,9 +674,14 @@ export default {
                   }
                 }
                 let key = [...rowKeys, ...headerFields]
-                let value = valuesHashTable.get(key);
-                item[col.field] = value ? value.toThousandth() : null;
-                console.log('col.field',col.field,headerFields,valuesHashTable,key)
+                if(hasData){
+                  let digits = col.digits;
+                  let value = valuesHashTable.get(key);
+                  item[col.field] = value ? value.toThousandth(digits) : null;
+                  // console.log('col.field', this.dataFields, headerFields, valuesHashTable, key,col)
+                }else{
+                  item[col.field] = null;
+                }
               })
             })
           }

+ 1 - 0
src/components/base/dk-table/dk-table-column.vue

@@ -150,6 +150,7 @@
               class-name="freeze-column-class" show-header-overflow show-footer-overflow
               show-overflow="title" :min-width="(typeData=='checkbox' || typeData=='radio')?'50': minWidthData"
               :title="titleData"
+              :params="{type:typeData,digits:digits}"
               :fixed="fixedData" :radioRight="radioRight"
               :width="(typeData=='checkbox' || typeData=='radio')?'50': widthData" :field="field" align="center"
               :tree-node="treeNode">

+ 2 - 1
src/components/base/dk-table/dk-table.vue

@@ -1176,7 +1176,8 @@ export default {
       const tableColumns = this.$refs[this.name].getTableColumn()
       if (tableColumns && tableColumns.visibleColumn && data && data.length > 0) {
         let columns = [...tableColumns.visibleColumn];
-        columns = columns.filter(it => it.type != 'seq' && it.type != 'checkbox' && it.type != 'radio').filterColumns(['field', 'title','type'])
+        console.log('44',columns)
+        columns = columns.filter(it => it.type != 'seq' && it.type != 'checkbox' && it.type != 'radio').filterColumns(['field', 'title','type','params'])
         this.$Perspective({
             component: this.$refs[this.name],
             columns: columns,

+ 1 - 1
src/components/base/edit-table/edit-table.vue

@@ -266,7 +266,7 @@
               <div slot="content">
                 <div style="display: flex;align-items: center;justify-content: center;">
                   <!--                {{ colItem.options() }}-->
-                  <Select size="small" v-model="inputDownValue" style="width:200px" :multiple="colItem.selectType==='M'"
+                  <Select size="small" v-model="inputDownValue" style="width:200px" :multiple="colItem.multiple"
                           clearable>
                     <Option v-for="item in (typeof colItem.options === 'function'?colItem.options():colItem.options)"
                             :key="item[colItem.valueKey]"

+ 6 - 2
src/libs/tools/string-tools.js

@@ -19,7 +19,9 @@ String.prototype.handleStr = function () {
  * @date   : 2022/11/21 13:35
  */
 String.prototype.toNum = function (digits) {
-  digits = digits?digits:0
+  if(digits == undefined){
+    digits = 0;
+  }
   return XEUtils.round(this, digits);
 }
 
@@ -39,7 +41,9 @@ String.prototype.isNumber = function (){
  * @date   : 2022/11/21 13:35
  */
 String.prototype.toThousandth = function (digits) {
-  digits = digits?digits:2
+  if(digits == undefined){
+    digits = 0;
+  }
   return XEUtils.commafy(XEUtils.round(this, digits), {digits});
 }
 

+ 3 - 1
src/libs/tools/tools.js

@@ -8,7 +8,9 @@ import Vue from "vue";
  * @date   : 2022/11/16 10:44
  */
 Number.prototype.toThousandth = function (digits) {
-  digits = digits ? digits : 2
+  if(digits == undefined){
+    digits = 0;
+  }
   return XEUtils.commafy(this, {digits});
 }