From 98a2d914162cacee45be1639d13a90df68d24765 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 25 十月 2023 10:57:02 +0800 Subject: [PATCH] 2023-10-25 --- src/tabviews/custom/components/table/edit-table/index.jsx | 8 ++-- src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 91 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 87 insertions(+), 12 deletions(-) diff --git a/src/tabviews/custom/components/table/edit-table/index.jsx b/src/tabviews/custom/components/table/edit-table/index.jsx index 9d5d2cb..359886a 100644 --- a/src/tabviews/custom/components/table/edit-table/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/index.jsx @@ -86,10 +86,6 @@ item.tableId = setting.tableId - if (setting.commit === 'blur') { - item.blur = true - } - if (item.type === 'colspan') { item.subcols = getColumns(item.subcols) @@ -180,6 +176,10 @@ _config.colsCtrls = null } + if (setting.commit === 'blur') { + setting.hasSubmit = false + } + this.setState({ pageSize: setting.pageSize || 10, BID: BID || '', diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx index 15760a7..bd322ed 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -747,10 +747,6 @@ 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) => { @@ -1384,7 +1380,7 @@ 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 = '' @@ -1774,6 +1770,8 @@ this.setState({edData: _data}, () => { if (setting.commit === 'simple') { this.submit() + } else if (setting.commit === 'blur') { + this.submit(record) } }) } @@ -1785,7 +1783,9 @@ if (id !== tableId) return - if (!record.$sign) { + if (setting.commit === 'blur') { + + } else if (!record.$sign) { record.$origin = false record.$lock = true delete record.$forbid @@ -1816,7 +1816,11 @@ 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) => { @@ -1974,7 +1978,71 @@ 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 @@ -1990,7 +2058,14 @@ 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 -- Gitblit v1.8.0