Commit 333803de authored by 田翔's avatar 田翔

fix: 列表显示数值配置问题

parent 87d7da63
{
"name": "panda-xform",
"version": "6.7.3",
"description": "6.7.3 区域任务优化",
"version": "6.7.5",
"description": "6.7.5 列表显示数值配置问题",
"keywords": [
"panda-xform"
],
......
import React from 'react'
function formatMoney(number, places, symbol, thousand, decimal) {
number = number || 0;
places = !isNaN(places = Math.abs(places)) ? places : 2;
symbol = symbol !== undefined ? symbol : "¥";
thousand = thousand || ",";
decimal = decimal || ".";
var negative = number < 0 ? "-" : "",
i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
}
const NumberView = (props) => {
const { value, formatter } = props
if (formatter === '${整数}') {
return <div>{Number(value)}</div>
const { value, formatter, decimalDigits } = props
const formatterFn = (value) => {
if (value) {
if (formatter === '${百分比}') {
return `${value}%`
} else if (formatter === '${货币}') {
return formatMoney(Number(value), Number(decimalDigits))
} else if (formatter === '${整数}') {
return `${parseInt(value)}`
} else if (formatter === '${小数}') {
return Number(value).toFixed(Number(decimalDigits))
} else if (formatter === '${科学计数法}') {
return Number(value).toExponential()
} else if (formatter) {
return `${value}${formatter}`
}
}
return value
}
return (
<div>{value}</div>
<div>{formatterFn(value)}</div>
)
}
export default NumberView
\ No newline at end of file
......@@ -32,6 +32,7 @@ const Coordinate = (props) => {
const mapConfig = window.globalConfig.mapsettings?.layers || null
return { layers: mapConfig };
});
const [screenShotShow, setScreenShotShow] = useState(false)
const [visible, setVisible] = useState(false)
const [initCoordinate, setInitCoordinate] = useState([])
const [currentPointerCoordinate, setCurrentPointerCoordinate] = useState([])
......@@ -237,6 +238,12 @@ const Coordinate = (props) => {
if (disabled && screenShot) {
addons?.setSchemaByPath(addons.dataPath, { ...schema, width: '67%' })
}
if (screenShot && disabled) {
let time = Math.round(Math.random() * 1000)
setTimeout(() => {
setScreenShotShow(true)
}, time)
}
}, [disabled, screenShot])
const getCityName = () => {
......@@ -253,7 +260,7 @@ const Coordinate = (props) => {
return cityName;
}
if (screenShot && disabled && addons) {
if (screenShotShow && addons) {
return (
<div className={styles.coordinateShot}>
<div className={styles.content}>
......
......@@ -59,8 +59,7 @@ const NumberInput = (props) => {
} else if (formatter === '${整数}') {
return `${parseInt(value)}`
} else if (formatter === '${小数}') {
// return Number(value).toFixed(Number(decimalDigits))
return value
return Number(value).toFixed(Number(decimalDigits))
} else if (formatter === '${科学计数法}') {
return Number(value).toExponential()
} else if (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