From c2580fb8de3bdaabb4179b0ce0fcd2fbac802441 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 01 三月 2023 00:49:14 +0800 Subject: [PATCH] 2023-03-01 --- src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 146 +++++++++++++++++++++++++++--------------------- 1 files changed, 82 insertions(+), 64 deletions(-) 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 bcf4ee3..8c85c47 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -916,7 +916,7 @@ pageIndex: 1, // 鍒濆椤甸潰绱㈠紩 pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 columns: null, // 鏄剧ず鍒� - fields: [], + forms: [], pickup: false, // 鏀惰捣鏈�夋嫨椤� orderfields: {}, // 鎺掑簭id涓巉ield杞崲 loading: false, @@ -932,51 +932,81 @@ let _columns = [] let deForms = [] - columns.forEach(item => { - if (!initEditLine && item.editable === 'true') { - initEditLine = item - } + let _forms = {} - if (item.type === 'text' && item.editable === 'true' && item.editType === 'select' && item.resourceType === '1') { - let _option = Utils.getSelectQueryOptions(item) + let getColumns = (cols) => { + return cols.map(item => { + let cell = null + + if (item.type === 'colspan') { + cell = { title: item.label, align: item.Align } + cell.children = getColumns(item.subcols) + } else { + if (item.editable === 'true') { + _forms[item.field] = item + if (!initEditLine) { + initEditLine = item + } + } + + if (item.type === 'text' && item.editable === 'true' && item.editType === 'select' && item.resourceType === '1') { + let _option = Utils.getSelectQueryOptions(item) + + if (window.GLOB.debugger === true || window.debugger === true) { + console.info(_option.sql) + } + + item.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) + item.arr_field = _option.field + + deForms.push(item) + } + + if (item.field) { + orderfields[item.uuid] = item.field + } - if (window.GLOB.debugger === true || window.debugger === true) { - console.info(_option.sql) + cell = { + align: item.Align, + dataIndex: item.uuid, + title: item.label, + sorter: !!(item.field && item.IsSort === 'true'), + width: item.Width || 120, + $type: item.type, + onCell: record => ({ + record, + col: item, + config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null, + }) + } } + + return cell + }) + } + _columns = getColumns(columns) - item.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) - item.arr_field = _option.field + let forms = [] + fields.forEach(item => { + if (item.field === setting.primaryKey) return - deForms.push(item) + if (_forms[item.field]) { + forms.push({..._forms[item.field], datatype: item.datatype}) + } else { + forms.push(item) } + }) - if (item.field) { - orderfields[item.uuid] = item.field + _columns.forEach(item => { + if (item.$type === 'action') return + + let _copy = fromJS(item).toJS() + _copy.sorter = false + + if (item.editable === 'true') { + _copy.title = <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span> } - - let _item = { - align: item.Align, - dataIndex: item.uuid, - title: item.label, - sorter: item.field && item.IsSort === 'true', - width: item.Width || 120, - onCell: record => ({ - record, - col: item, - config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null, - }) - } - - if (item.type !== 'action') { - let _copy = fromJS(_item).toJS() - _copy.sorter = false - - if (item.editable === 'true') { - _copy.title = <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span> - } - edColumns.push(_copy) - } - _columns.push(_item) + edColumns.push(_copy) }) if (setting.delable !== 'false' && setting.operType !== 'buoyMode') { @@ -993,13 +1023,6 @@ }) } - // if (setting.borderColor) { // 杈规棰滆壊 - // let style = `#${setting.tableId} table, #${setting.tableId} tr, #${setting.tableId} th, #${setting.tableId} td {border-color: ${setting.borderColor}}` - // let ele = document.createElement('style') - // ele.innerHTML = style - // document.getElementsByTagName('head')[0].appendChild(ele) - // } - let size = (setting.pageSize || 10) + '' let pageOptions = ['10', '25', '50', '100', '500', '1000'] @@ -1009,6 +1032,7 @@ } this.setState({ + forms, pageSize: setting.pageSize || 10, pageOptions, columns: _columns, @@ -1035,12 +1059,6 @@ } componentDidMount () { - const { fields, setting } = this.props - - this.setState({ - fields: fields.filter(item => item.field !== setting.primaryKey), - }) - MKEmitter.addListener('subLine', this.subLine) MKEmitter.addListener('nextLine', this.nextLine) MKEmitter.addListener('addRecord', this.addLine) @@ -1286,7 +1304,7 @@ } subLine = (col, record) => { - const { tableId, fields, edData } = this.state + const { tableId, forms, edData } = this.state if (col && col.tableId !== tableId) return @@ -1300,7 +1318,7 @@ setTimeout(() => { let item = fromJS(record).toJS() let line = [] - fields.forEach(col => { + forms.forEach(col => { if (col.editable !== 'true' || item.$deleted) { if (col.type === 'number') { item[col.field] = +item[col.field] @@ -1357,7 +1375,7 @@ } plusLine = () => { - const { edData, fields, initEditLine } = this.state + const { edData, forms, initEditLine } = this.state let item = {...edData[edData.length - 1]} @@ -1365,7 +1383,7 @@ item.$type = 'add' item.$Index = '' - fields.forEach(col => { + forms.forEach(col => { if (col.initval !== '$copy') { item[col.field] = col.initval } @@ -1434,7 +1452,7 @@ addLine = (id, record) => { const { BID } = this.props - const { edData, fields, tableId } = this.state + const { edData, forms, tableId } = this.state if (id) { if (id !== tableId) return @@ -1448,7 +1466,7 @@ item.$Index = '' item.$$BID = BID || '' - fields.forEach(col => { + forms.forEach(col => { if (col.initval !== '$copy') { item[col.field] = col.initval } @@ -1481,7 +1499,7 @@ item.$$BID = BID || '' } - fields.forEach(col => { + forms.forEach(col => { if (col.initval !== '$copy') { item[col.field] = col.initval } @@ -1502,7 +1520,7 @@ } checkData = () => { - const { edData, fields } = this.state + const { edData, forms } = this.state if (edData.length === 0) { notification.warning({ @@ -1516,7 +1534,7 @@ let Index = 1 let data = fromJS(edData).toJS().map(item => { let line = [] - fields.forEach(col => { + forms.forEach(col => { if (col.editable !== 'true' || item.$deleted) { if (col.type === 'number') { item[col.field] = +item[col.field] @@ -1581,7 +1599,7 @@ submit = (data, type) => { const { submit, BID, setting } = this.props - const { fields } = this.state + const { forms } = this.state if (type !== 'simple' && (setting.commit === 'change' || setting.commit === 'simple')) { data = data.filter(item => !item.$origin) @@ -1596,7 +1614,7 @@ return } - let result = getEditTableSql(submit, data, fields) + let result = getEditTableSql(submit, data, forms) let param = { excel_in: result.lines, @@ -1996,9 +2014,9 @@ </div> : null} <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> {!submit.hasAction && pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">鎻愪氦</Button> : null} - <Switch title="缂栬緫" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} /> + {setting.switchable !== 'false' ? <Switch title="缂栬緫" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} /> : null} </div> - <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''}`} id={tableId}> + <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} id={tableId}> <Table rowKey="$$uuid" components={components} -- Gitblit v1.8.0