Commit e1dbab74 authored by 程恺文's avatar 程恺文

数字转科学计数法

parent 21415009
/*
* @Author: 634665781 634665781@qq.com
* @Date: 2023-12-06 09:16:37
* @LastEditors: 634665781 634665781@qq.com
* @LastEditTime: 2023-12-11 16:46:25
* @FilePath: \xform\src\core\widgets\settings\groupStyle\Formatting\index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import React from 'react' import React from 'react'
import { Input, Dropdown, Menu, Select } from 'antd' import { Input, Dropdown, Menu, Select } from 'antd'
import { PlusOutlined } from '@ant-design/icons' import { PlusOutlined } from '@ant-design/icons'
...@@ -8,6 +16,7 @@ const options = [ ...@@ -8,6 +16,7 @@ const options = [
{ label: '小数', value: '${小数}' }, { label: '小数', value: '${小数}' },
{ label: '货币', value: '${货币}' }, { label: '货币', value: '${货币}' },
{ label: '百分比', value: '${百分比}' }, { label: '百分比', value: '${百分比}' },
{ label: '科学计数法', value: '${科学计数法}' }
] ]
const Formatting = (props) => { const Formatting = (props) => {
......
/*
* @Author: 634665781 634665781@qq.com
* @Date: 2023-12-06 09:16:37
* @LastEditors: 634665781 634665781@qq.com
* @LastEditTime: 2023-12-11 17:07:06
* @FilePath: \xform\src\core\widgets\text\NumberInput\index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import React, { useEffect, useMemo, useState } from 'react' import React, { useEffect, useMemo, useState } from 'react'
import { InputNumber } from 'antd' import { InputNumber } from 'antd'
import styles from './index.less' import styles from './index.less'
...@@ -48,7 +56,11 @@ const NumberInput = (props) => { ...@@ -48,7 +56,11 @@ const NumberInput = (props) => {
return `${parseInt(value)}` return `${parseInt(value)}`
} else if (formatter === '${小数}') { } else if (formatter === '${小数}') {
return Number(value).toFixed(Number(decimalDigits)) return Number(value).toFixed(Number(decimalDigits))
} else if (formatter) { }
else if(formatter === '${科学计数法}'){
return Number(value).toExponential()
}
else if (formatter) {
return `${value}${formatter}` return `${value}${formatter}`
} }
} }
......
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