| | |
| | | import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification, Collapse } from 'antd' |
| | | import moment from 'moment' |
| | | import { formRule } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import FileUpload from '@/tabviews/zshare/fileupload' |
| | | import './index.scss' |
| | | |
| | |
| | | _fieldsvalue[key] = _val |
| | | } else if (datatype[key] === 'fileupload') { |
| | | let _val = nextProps.data[key] ? nextProps.data[key] : '' |
| | | |
| | | if (_val) { |
| | | try { |
| | | _val = _val.split(',').map((url, index) => { |
| | | return { |
| | | uid: `${index}`, |
| | | name: url.slice(url.lastIndexOf('/') + 1), |
| | | status: 'done', |
| | | url: url, |
| | | origin: true |
| | | } |
| | | }) |
| | | } catch { |
| | | _val = [] |
| | | } |
| | | } else { |
| | | _val = [] |
| | | } |
| | | |
| | | _fieldsvalue[key] = _val |
| | | } else if (datatype[key] === 'text' || datatype[key] === 'textarea') { |
| | |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'fileupload') { |
| | | let filelist = this.props.data ? this.props.data[item.field] : item.initval |
| | | if (filelist && this.state.readin[item.field]) { |
| | | try { |
| | | filelist = filelist.split(',').map((url, index) => { |
| | | return { |
| | | uid: `${index}`, |
| | | name: url.slice(url.lastIndexOf('/') + 1), |
| | | status: 'done', |
| | | url: url, |
| | | origin: true |
| | | } |
| | | }) |
| | | } catch { |
| | | filelist = [] |
| | | } |
| | | } else { |
| | | filelist = [] |
| | | } |
| | | |
| | | fields.push( |
| | | <Col span={24 / cols} key={index}> |
| | | <Form.Item label={item.label}> |
| | | {getFieldDecorator(item.field, { |
| | | initialValue: filelist, |
| | | initialValue: item.initval, |
| | | rules: [ |
| | | { |
| | | required: item.required === 'true', |
| | |
| | | } |
| | | ] |
| | | })( |
| | | <FileUpload /> |
| | | <FileUpload config={item}/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | |
| | | _value = values[key] ? values[key].join(',') : '' |
| | | |
| | | } else if (this.state.datatype[key] === 'fileupload') { |
| | | let vals = [] |
| | | _value = values[key] |
| | | |
| | | if (values[key] && values[key].length > 0) { |
| | | values[key].forEach(_val => { |
| | | if (_val.origin && _val.url) { |
| | | vals.push(_val.url) |
| | | } else if (!_val.origin && _val.status === 'done' && _val.response) { |
| | | vals.push(Utils.getrealurl(_val.response)) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | _value = vals.join(',') |
| | | } else if (this.state.datatype[key] === 'text' || this.state.datatype[key] === 'textarea') { |
| | | _value = values[key].replace(/\t*|\v*/g, '') // 去除制表符 |
| | | |