From 89e7167a83e0d8409ca87698e4c08651a37cc26e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 12 六月 2020 18:19:35 +0800 Subject: [PATCH] 2020-06-12 --- src/tabviews/zshare/mutilform/index.jsx | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 106 insertions(+), 5 deletions(-) diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index bf40107..063dd6d 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -2,6 +2,8 @@ import PropTypes from 'prop-types' import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification } from 'antd' import moment from 'moment' + +import Api from '@/api' import { formRule } from '@/utils/option.js' import Utils from '@/utils/utils.js' import FileUpload from '../fileupload' @@ -15,8 +17,8 @@ action: PropTypes.object, // 鎸夐挳淇℃伅銆佽〃鍗曞垪琛� dict: PropTypes.object, // 瀛楀吀椤� data: PropTypes.any, // 琛ㄦ牸鏁版嵁 + BID: PropTypes.any, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 - configMap: PropTypes.object, // 鎸夐挳鍙婁笅鎷夎〃鍗曢厤缃俊鎭泦 inputSubmit: PropTypes.func // input鍥炶溅鎻愪氦 } @@ -121,10 +123,6 @@ }) } - if (item.resourceType === '1' && this.props.configMap.hasOwnProperty(item.uuid)) { - item.options = [...item.options, ...this.props.configMap[item.uuid]] - } - // 淇濆瓨鍒濆鍒楄〃锛岀敤浜庡叧鑱旇彍鍗曟帶鍒� item.oriOptions = JSON.parse(JSON.stringify(item.options)) @@ -224,7 +222,9 @@ message: '鏈煡璇㈠埌琛ㄥ崟銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', duration: 5 }) + item.supInitVal = '' } else { + item.supInitVal = supItem.initval item.options = item.oriOptions.filter(option => option.parentId === supItem.initval) } } @@ -254,9 +254,110 @@ console.warn('focus error锛�') } } + // 鐢ㄦ潵鏇存柊state锛岄槻姝㈠彈鎺ц〃鍗曞垵濮嬫椂涓嶆樉绀� this.setState({ loaded: true }) + this.improveActionForm() + }) + } + + /** + * @description 鑾峰彇涓嬫媺琛ㄥ崟閫夐」淇℃伅 + */ + improveActionForm = () => { + const { formlist } = this.state + let deffers = [] + + formlist.forEach(item => { + if (!['select', 'link', 'multiselect'].includes(item.type) || item.resourceType !== '1') return + + let param = { + func: 'sPC_Get_SelectedList', + LText: item.data_sql, + obj_name: 'data', + arr_field: item.arr_field + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + deffers.push( + new Promise(resolve => { + Api.getSystemCacheConfig(param, item.database === 'sso').then(res => { + res.$search = item + resolve(res) + }) + }) + ) + }) + + if (deffers.length === 0) return + + let _field = {} + let error = '' + Promise.all(deffers).then(result => { + result.forEach(res => { + if (res.status) { + let options = res.data.map(cell => { + let item = { + key: Utils.getuuid(), + Value: cell[res.$search.valueField], + Text: cell[res.$search.valueText] + } + + if (res.$search.type === 'link') { + item.parentId = cell[res.$search.linkField] + } else if (res.$search.type === 'select' && res.$search.linkSubField && res.$search.linkSubField.length > 0) { + res.$search.linkSubField.forEach(_field => { + item[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' + }) + } + + return item + }) + + _field[res.$search.uuid] = options + } else { + error = res + } + }) + + if (error) { + notification.warning({ + top: 92, + message: error.message, + duration: 5 + }) + } + + let _formlist = formlist.map(item => { + if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') { + if (item.resourceType === '1' && _field.hasOwnProperty(item.uuid)) { + item.oriOptions = [...item.oriOptions, ..._field[item.uuid]] + } + } + return item + }) + + _formlist = _formlist.map(item => { + if (item.type === 'link') { + if (item.supInitVal) { + item.options = item.oriOptions.filter(option => option.parentId === item.supInitVal) + } else { + item.options = item.oriOptions + } + } + return item + }) + + this.setState({ + formlist: _formlist + }) }) } -- Gitblit v1.8.0