From 6c16e43cd6521460c804391c042348dbb14086fc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 16 六月 2020 09:44:40 +0800 Subject: [PATCH] 2020-06-16 --- src/tabviews/zshare/mutilform/index.jsx | 45 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 063dd6d..4b6948c 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -1,5 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { fromJS } from 'immutable' import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification } from 'antd' import moment from 'moment' @@ -14,6 +15,7 @@ class MainSearch extends Component { static propTpyes = { + menuType: PropTypes.object, // 鑿滃崟绫诲瀷锛屾槸鍚︿负HS action: PropTypes.object, // 鎸夐挳淇℃伅銆佽〃鍗曞垪琛� dict: PropTypes.object, // 瀛楀吀椤� data: PropTypes.any, // 琛ㄦ牸鏁版嵁 @@ -38,7 +40,7 @@ let cols = 2 if (this.props.action.setting && this.props.action.setting.cols) { cols = parseInt(this.props.action.setting.cols) - if (cols > 3 || cols < 1) { + if (cols > 4 || cols < 1) { cols = 2 } } @@ -50,7 +52,7 @@ componentDidMount () { const { data, BData } = this.props - let action = JSON.parse(JSON.stringify(this.props.action)) + let action = fromJS(this.props.action).toJS() let datatype = {} let readtype = {} @@ -100,7 +102,7 @@ } // 鐢ㄤ簬鍙楁帶鍊肩殑琛ㄥ崟锛岄殣钘忔椂浼犻粯璁ゅ��(鏈娇鐢紵) - item.initVal = typeof(item.initval) === 'object' ? JSON.parse(JSON.stringify(item.initval)) : item.initval + item.initVal = typeof(item.initval) === 'object' ? fromJS(item.initval).toJS() : item.initval let _fieldlen = item.fieldlength || 50 if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') { @@ -124,7 +126,7 @@ } // 淇濆瓨鍒濆鍒楄〃锛岀敤浜庡叧鑱旇彍鍗曟帶鍒� - item.oriOptions = JSON.parse(JSON.stringify(item.options)) + item.oriOptions = fromJS(item.options).toJS() // 涓嬬骇琛ㄥ崟鎺у埗-瀛楁鍐欏叆 if (item.linkSubField && item.linkSubField.length > 0) { @@ -286,6 +288,10 @@ param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) + if (this.props.menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 + param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) + } + deffers.push( new Promise(resolve => { Api.getSystemCacheConfig(param, item.database === 'sso').then(res => { @@ -351,6 +357,8 @@ } else { item.options = item.oriOptions } + } else if (item.type === 'select' || item.type === 'multiselect') { + item.options = item.oriOptions } return item }) @@ -368,10 +376,13 @@ supfields.forEach(supfield => { formlist = formlist.map(item => { if (item.type === 'link' && item.linkField === supfield.field) { + item.options = item.oriOptions.filter(option => option.parentId === supfield.initval) item.initval = item.options[0] ? item.options[0].Value : '' - fieldsvalue[item.field] = item.initval + if (this.props.form.getFieldValue(item.field) !== undefined) { + fieldsvalue[item.field] = item.initval + } subfields.push(item) } @@ -388,7 +399,7 @@ selectChange = (_field, value, option) => { const { record } = this.state - let formlist = JSON.parse(JSON.stringify(this.state.formlist)) + let formlist = fromJS(this.state.formlist).toJS() let subfields = [] let fieldsvalue = {} @@ -398,7 +409,9 @@ item.options = item.oriOptions.filter(option => option.parentId === value) item.initval = item.options[0] ? item.options[0].Value : '' - fieldsvalue[item.field] = item.initval + if (this.props.form.getFieldValue(item.field) !== undefined) { + fieldsvalue[item.field] = item.initval + } subfields.push(item) } @@ -718,7 +731,7 @@ let _labelcol = cols !== 3 ? 8 / cols : 3 let _wrapcol = cols !== 3 ? 16 + (cols - 1) * 4 : 21 let _style = {} - if (cols === 2) { + if (cols === 2 || cols === 4) { _style.paddingLeft = '7px' } fields.push( @@ -748,7 +761,7 @@ handleConfirm = () => { const { record, intercepts } = this.state - let _encrypts = JSON.parse(JSON.stringify(this.state.encrypts)) + let _encrypts = fromJS(this.state.encrypts).toJS() let _format = { date: 'YYYY-MM-DD', datemonth: 'YYYY-MM', @@ -814,6 +827,20 @@ }) Object.keys(values).forEach(key => { + if (values[key] === undefined) { // 琛ㄥ崟寮傚父锛燂紵锛� + if (search.filter(s => s.key === key).length === 0) { + search.push({ + type: this.state.datatype[key], + readonly: this.state.readtype[key], + readin: this.state.readin[key], + fieldlen: this.state.fieldlen[key], + key: key, + value: '' + }) + } + return + } + let _value = '' if (this.state.datatype[key] === 'datetime') { _value = values[key] ? moment(values[key]).format('YYYY-MM-DD HH:mm:ss') : '' -- Gitblit v1.8.0