| | |
| | | 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' |
| | |
| | | action: PropTypes.object, // 按钮信息、表单列表 |
| | | dict: PropTypes.object, // 字典项 |
| | | data: PropTypes.any, // 表格数据 |
| | | BID: PropTypes.any, // 主表ID |
| | | BData: PropTypes.any, // 主表数据 |
| | | configMap: PropTypes.object, // 按钮及下拉表单配置信息集 |
| | | inputSubmit: PropTypes.func // input回车提交 |
| | | } |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | 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)) |
| | | |
| | |
| | | message: '未查询到表单《' + item.label + '》关联字段!', |
| | | duration: 5 |
| | | }) |
| | | item.supInitVal = '' |
| | | } else { |
| | | item.supInitVal = supItem.initval |
| | | item.options = item.oriOptions.filter(option => option.parentId === supItem.initval) |
| | | } |
| | | } |
| | |
| | | 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 |
| | | }) |
| | | }) |
| | | } |
| | | |