From 04b5222fcf0c8f24b3a577cf3a05fb57462982a5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 11 八月 2020 09:18:27 +0800 Subject: [PATCH] 2020-08-11 --- src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 67 +++++++++++++++++++++++++-------- 1 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index a8626b0..c13f4a2 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -1,5 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { fromJS } from 'immutable' import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, Icon, Tooltip, notification, Modal, message, InputNumber, Radio, Typography } from 'antd' import moment from 'moment' @@ -218,24 +219,58 @@ } UNSAFE_componentWillMount() { - let _verify = this.props.card.verify || {} - _verify = JSON.parse(JSON.stringify(_verify)) - + const { columns, card } = this.props + let _verify = fromJS(card.verify || {}).toJS() let _columns = _verify.columns || [] - _columns = _columns.map(col => { - col.required = col.required || 'true' - col.type = col.type || 'Nvarchar(50)' - - if (/^Nvarchar/ig.test(col.type)) { - col.limit = col.type.match(/\d+/)[0] - } else if (/^Decimal/ig.test(col.type)) { - col.limit = col.type.match(/\d+/ig)[1] - } else { - col.limit = '' - } - return col - }) + // 鍚屾鏄剧ず鍒� + if (_columns.length === 0) { + columns.forEach(col => { + if (!col.field) return + let _type = 'Nvarchar(50)' + let _limit = '50' + if (col.type === 'number' && !col.decimal) { + _type = 'Int' + _limit = '' + } else if (col.type === 'number') { + _type = 'Decimal(18,' + col.decimal + ')' + _limit = col.decimal + } + + let _cell = { + uuid: col.uuid, + Column: col.field, + Text: col.label, + type: _type, + limit: _limit, + import: 'true', + required: 'true' + } + + if (_type !== 'Nvarchar(50)') { + _cell.min = 0 + _cell.max = 999999 + } + + _columns.push(_cell) + }) + } else { + // 鏃ф暟鎹吋瀹� + _columns = _columns.map(col => { + col.required = col.required || 'true' + col.type = col.type || 'Nvarchar(50)' + + if (/^Nvarchar/ig.test(col.type)) { + col.limit = col.type.match(/\d+/)[0] + } else if (/^Decimal/ig.test(col.type)) { + col.limit = col.type.match(/\d+/ig)[1] + } else { + col.limit = '' + } + + return col + }) + } this.setState({ verify: { -- Gitblit v1.8.0