Commit c57c7061 authored by zhangwenshuai's avatar zhangwenshuai

数字上送时格式化

parent fe0c58fa
......@@ -84,11 +84,12 @@ export const SetFormatter = {
},
NUMBER: (val, config) => {
if (!isNumber(val)) return emptyModel;
const { unit = {} } = config || {}; // 设置单位
const { unit = {}, precision } = config || {}; // 设置单位
if (unit && unit.code === 'wan') {
const newVal = val ? val * 10000 : val;
return [{ value: newVal, text: newVal }];
}
val = Number(val).toFixed(precision);
return [{ value: val, text: val }];
},
PERCENTAGE: (val) => {
......
......@@ -3,7 +3,7 @@ import React from 'react';
import { transferAttr } from './_utils/transferAttr';
import { BaseComponentProps, BaseComponentState } from '../interface';
export const setFormat = (config, columnConfig: any, value: any, option?: any) => {
export const setFormat = (config:any, columnConfig: any, value: any, option?: any) => {
const { columnAttrObj, columnType } = columnConfig || {};
const transferColumn = transferAttr(columnType, {
...(config.componentAttr || {}),
......@@ -13,7 +13,7 @@ export const setFormat = (config, columnConfig: any, value: any, option?: any) =
return value;
};
export const getFormat = (config, columnConfig: any, value: any) => {
export const getFormat = (config:any, columnConfig: any, value: any) => {
const { columnAttrObj, columnType } = columnConfig || {};
if (!value || !Array.isArray(value) || value.length <= 0) return undefined;
const transferColumn = transferAttr(columnType, {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment