| | |
| | | |
| | | item.hidden = false |
| | | |
| | | if (item.forbid && item.del) return false |
| | | |
| | | if (item.forbid) { |
| | | item.hidden = true |
| | | } |
| | |
| | | if (!fieldMap.has(key)) return |
| | | |
| | | let supItem = fieldMap.get(key) |
| | | let supval = supItem.initval |
| | | |
| | | if (supItem.initval && supItem.type !== 'checkbox' && JSON.stringify(supItem.initval) === '[]') { |
| | | supval = '' |
| | | } |
| | | |
| | | let fields = [] |
| | | controlFields[key].forEach(item => { |
| | | if (!fieldMap.has(item.field)) return |
| | |
| | | } else if (supItem.hidden) { |
| | | cell.hidden = true |
| | | } else if (supItem.type === 'checkbox') { |
| | | let vals = [...supItem.initval, ...item.values] |
| | | let vals = [...supval, ...item.values] |
| | | if (vals.length === new Set(vals).size) { |
| | | cell.hidden = true |
| | | } |
| | | } else if (item.notNull) { |
| | | cell.hidden = !supItem.initval || JSON.stringify(supItem.initval) === '[]' |
| | | } else if (!item.values.includes(supItem.initval)) { |
| | | cell.hidden = !supval |
| | | } else if (!item.values.includes(supval)) { |
| | | cell.hidden = true |
| | | } |
| | | |
| | | fieldMap.set(item.field, cell) |
| | | |
| | | fields.push(item) |
| | |
| | | recordChange = (values, item) => { |
| | | this.record = {...this.record, ...values} |
| | | |
| | | if (item && item.controlFields) { |
| | | if (!item) return |
| | | |
| | | if (item.controlFields) { |
| | | let map = new Map() |
| | | this.state.formlist.forEach(cell => { |
| | | if (!cell.field) return |
| | |
| | | |
| | | let reset = (current) => { |
| | | let val = this.record[current.field] |
| | | |
| | | if (val && current.type !== 'checkbox' && JSON.stringify(val) === '[]') { |
| | | val = '' |
| | | } |
| | | |
| | | current.controlFields.forEach(cell => { |
| | | let m = map.get(cell.field) |
| | |
| | | m.hidden = true |
| | | } |
| | | } else if (cell.notNull) { |
| | | m.hidden = !val || JSON.stringify(val) === '[]' |
| | | m.hidden = !val |
| | | } else { |
| | | m.hidden = !cell.values.includes(val) |
| | | } |
| | |
| | | return item || cell |
| | | }) |
| | | }) |
| | | } else if (item.reset_source) { |
| | | let map = new Map() |
| | | this.state.formlist.forEach(cell => { |
| | | if (!cell.field) return |
| | | map.set(cell.field, cell) |
| | | }) |
| | | |
| | | item.callback(map, this.record) |
| | | |
| | | this.setState({ |
| | | formlist: this.state.formlist.map(cell => { |
| | | if (!cell.field) return cell |
| | | |
| | | let item = map.get(cell.field) |
| | | |
| | | return item || cell |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | |