| | |
| | | if (value !== record[col.field]) { |
| | | MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val}) |
| | | } |
| | | |
| | | // if (col.blur) { |
| | | // MKEmitter.emit('subLine', col, record) |
| | | // } |
| | | } |
| | | |
| | | onSwitchChange = (val, label) => { |
| | |
| | | |
| | | if (menuid !== MenuID) return |
| | | |
| | | if (setting.commit !== 'all' && setting.standard !== 'change') { |
| | | if (setting.commit !== 'all' && setting.commit !== 'blur' && setting.standard !== 'change') { |
| | | if (type !== 'line') { |
| | | data.forEach(item => { |
| | | let value = '' |
| | |
| | | this.setState({edData: _data}, () => { |
| | | if (setting.commit === 'simple') { |
| | | this.submit() |
| | | } else if (setting.commit === 'blur') { |
| | | this.submit(record) |
| | | } |
| | | }) |
| | | } |
| | |
| | | |
| | | if (id !== tableId) return |
| | | |
| | | if (!record.$sign) { |
| | | if (setting.commit === 'blur') { |
| | | |
| | | } else if (!record.$sign) { |
| | | record.$origin = false |
| | | record.$lock = true |
| | | delete record.$forbid |
| | |
| | | if (setting.tableType && setting.hasAction && this.state.selectedRowKeys.includes(record.$$uuid)) { |
| | | this.selectdata(this.state.selectedRowKeys) |
| | | } |
| | | if (setting.commit === 'blur') { |
| | | this.submit(record) |
| | | } |
| | | }) |
| | | |
| | | } |
| | | |
| | | addRecord = (id, record) => { |
| | |
| | | return data |
| | | } |
| | | |
| | | submit = () => { |
| | | checkLineData = (item) => { |
| | | const { forms } = this.state |
| | | |
| | | let record = fromJS(item).toJS() |
| | | let err = '' |
| | | forms.forEach(col => { |
| | | if (col.editable !== 'true' || record.$deleted) { |
| | | if (col.type === 'number') { |
| | | record[col.field] = +record[col.field] |
| | | if (isNaN(record[col.field])) { |
| | | record[col.field] = 0 |
| | | } |
| | | } else { |
| | | record[col.field] = record[col.field] !== undefined ? (record[col.field] + '') : '' |
| | | } |
| | | return |
| | | } |
| | | if (col.type === 'text') { |
| | | let val = record[col.field] !== undefined ? (record[col.field] + '') : '' |
| | | if (col.required === 'true' && !val) { |
| | | err = `${col.label}不可为空` |
| | | } else if (col.datatype === 'datetime' && !val) { |
| | | val = '1949-10-01' |
| | | } |
| | | record[col.field] = val |
| | | } else if (col.type === 'number') { |
| | | let val = record[col.field] |
| | | if (col.noValue === 'hide' && !val) { |
| | | val = 0 |
| | | } else if (!val && val !== 0) { |
| | | err = `${col.label}不可为空` |
| | | return |
| | | } |
| | | val = +val |
| | | if (isNaN(val)) { |
| | | err = `${col.label}数据格式错误` |
| | | return |
| | | } |
| | | |
| | | val = +val.toFixed(col.decimal || 0) |
| | | |
| | | if (typeof(col.max) === 'number' && val > col.max) { |
| | | err = `${col.label}不可大于${col.max}` |
| | | } else if (typeof(col.min) === 'number' && val < col.min) { |
| | | err = `${col.label}不可小于${col.min}` |
| | | } |
| | | |
| | | record[col.field] = val |
| | | } |
| | | }) |
| | | |
| | | if (err) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: err, |
| | | duration: 5 |
| | | }) |
| | | |
| | | return null |
| | | } |
| | | |
| | | return [record] |
| | | } |
| | | |
| | | submit = (record) => { |
| | | const { submit, BID, setting } = this.props |
| | | const { forms } = this.state |
| | | |
| | |
| | | return |
| | | } |
| | | |
| | | let data = this.checkData() |
| | | if (setting.commit === 'blur' && !record) return |
| | | |
| | | let data = null |
| | | if (setting.commit === 'blur') { |
| | | data = this.checkLineData(record) |
| | | } else { |
| | | data = this.checkData() |
| | | } |
| | | |
| | | if (!data) return |
| | | |