| | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import MKEInput from './mkInput' |
| | | import MKNumberInput from './mkNumberInput' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import MKSelect from './mkSelect' |
| | | import './index.scss' |
| | | |
| | |
| | | const MKCheckbox = asyncComponent(() => import('./mkCheckbox')) |
| | | const StyleInput = asyncComponent(() => import('./styleInput')) |
| | | const MKFileUpload = asyncComponent(() => import('@/tabviews/zshare/fileupload')) |
| | | const MKColor = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkColor')) |
| | | const MKColor = asyncComponent(() => import('@/mob/colorsketch')) |
| | | // const MKColor = asyncComponent(() => import('@/tabviews/zshare/mutilform/mkColor')) |
| | | const MkEditIcon = asyncComponent(() => import('@/components/mkIcon')) |
| | | const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent')) |
| | | |
| | | class ModalForm extends Component { |
| | | static propTpyes = { |
| | | formlist: PropTypes.array, // 表单列表 |
| | | inputSubmit: PropTypes.func // input回车提交 |
| | | formlist: PropTypes.array, |
| | | inputSubmit: PropTypes.func, |
| | | transVals: PropTypes.func, |
| | | } |
| | | |
| | | state = { |
| | |
| | | required: item.required, |
| | | message: item.label + '不可为空!' |
| | | }, { |
| | | validator: (rule, value, callback) => this.handleConfirmPassword(rule, value, callback, item) |
| | | validator: (rule, value, callback) => this.checkNumber(rule, value, callback, item) |
| | | }] |
| | | } else if (item.type === 'textarea') { |
| | | item.rules = [ |
| | |
| | | let supItem = fieldMap.get(key) |
| | | let supval = supItem.initval |
| | | |
| | | if (supItem.initval && supItem.type !== 'checkbox' && JSON.stringify(supItem.initval) === '[]') { |
| | | if (supval && JSON.stringify(supval) === '[]') { |
| | | supval = '' |
| | | } |
| | | |
| | |
| | | |
| | | } else if (supItem.hidden) { |
| | | cell.hidden = true |
| | | } else if (supItem.type === 'checkbox') { |
| | | let vals = [...supval, ...item.values] |
| | | } else if (item.notNull) { |
| | | cell.hidden = !supval |
| | | } else if (supItem.type === 'checkbox' || supItem.type === 'multiselect') { |
| | | let vals = [...(supval || []), ...item.values] |
| | | if (vals.length === new Set(vals).size) { |
| | | cell.hidden = true |
| | | } |
| | | } else if (item.notNull) { |
| | | cell.hidden = !supval |
| | | } else if (!item.values.includes(supval)) { |
| | | cell.hidden = true |
| | | } |
| | |
| | | this.setState({ formlist }) |
| | | } |
| | | |
| | | handleConfirmPassword = (rule, value, callback, item) => { |
| | | checkNumber = (rule, value, callback, item) => { |
| | | let val = parseFloat(value) |
| | | |
| | | if (!isNaN(val)) { |
| | |
| | | this.record = {...this.record, ...values} |
| | | |
| | | if (!item) return |
| | | |
| | | if (item.$trans) { |
| | | this.props.transVals && this.props.transVals(values, item.field) |
| | | } |
| | | |
| | | if (item.controlFields) { |
| | | let map = new Map() |
| | |
| | | let reset = (current) => { |
| | | let val = this.record[current.field] |
| | | |
| | | if (val && current.type !== 'checkbox' && JSON.stringify(val) === '[]') { |
| | | if (val && JSON.stringify(val) === '[]') { |
| | | val = '' |
| | | } |
| | | |
| | |
| | | |
| | | if (current.hidden) { |
| | | m.hidden = true |
| | | } else if (current.type === 'checkbox') { |
| | | let vals = [...val, ...cell.values] |
| | | } else if (cell.notNull) { |
| | | m.hidden = !val |
| | | } else if (current.type === 'checkbox' || current.type === 'multiselect') { |
| | | let vals = [...(val || []), ...cell.values] |
| | | if (vals.length !== new Set(vals).size) { |
| | | m.hidden = false |
| | | } else { |
| | | m.hidden = true |
| | | } |
| | | } else if (cell.notNull) { |
| | | m.hidden = !val |
| | | } else { |
| | | m.hidden = !cell.values.includes(val) |
| | | } |
| | |
| | | map.set(cell.field, cell) |
| | | }) |
| | | |
| | | item.callback(map, this.record) |
| | | item.callback(map, this.record, MKEmitter) |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(cell => { |
| | |
| | | } else if (item.type === 'select' || item.type === 'multiselect') { |
| | | content = (<MKSelect config={item} onChange={(val, other) => this.recordChange({[item.field]: val, ...other}, item)} />) |
| | | } else if (item.type === 'color') { |
| | | content = (<MKColor config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>) |
| | | content = (<MKColor config={item} allowClear={item.allowClear} onChange={(val) => this.recordChange({[item.field]: val})}/>) |
| | | } else if (item.type === 'styleInput') { |
| | | content = (<StyleInput config={item} onChange={(val) => this.recordChange({[item.field]: val})}/>) |
| | | } else if (item.type === 'radio') { |