From f155ee9b2db0f4eee687b53fd2f09bd3ebb02677 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 10 六月 2023 00:14:05 +0800 Subject: [PATCH] 2023-06-10 --- src/menu/components/card/balcony/index.jsx | 1 src/menu/modalconfig/tablecomponent/index.jsx | 163 +++++++++++++++++++++++++++ src/utils/utils-custom.js | 16 ++ src/menu/components/card/cardcomponent/index.jsx | 1 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 25 ++- src/menu/components/card/cardsimplecomponent/index.jsx | 1 src/tabviews/custom/components/table/edit-table/normalTable/index.scss | 22 +- src/menu/modalconfig/tablecomponent/index.scss | 36 ++++++ src/tabviews/custom/components/table/edit-table/index.jsx | 4 src/templates/sharecomponent/tablecomponent/index.jsx | 29 ++++ src/menu/modalconfig/index.jsx | 4 src/mob/modalconfig/index.jsx | 4 src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx | 40 ++++-- src/tabviews/custom/components/table/edit-table/index.scss | 12 + 14 files changed, 307 insertions(+), 51 deletions(-) diff --git a/src/menu/components/card/balcony/index.jsx b/src/menu/components/card/balcony/index.jsx index b883cf9..691e7f3 100644 --- a/src/menu/components/card/balcony/index.jsx +++ b/src/menu/components/card/balcony/index.jsx @@ -207,6 +207,7 @@ MKEmitter.emit('cardAddElement', card.uuid, res) } else { res.eleType = 'button' + res.width = res.width || 12 MKEmitter.emit('cardAddElement', card.uuid, res) } resolve({status: true}) diff --git a/src/menu/components/card/cardcomponent/index.jsx b/src/menu/components/card/cardcomponent/index.jsx index fe9bfc9..0d6a97d 100644 --- a/src/menu/components/card/cardcomponent/index.jsx +++ b/src/menu/components/card/cardcomponent/index.jsx @@ -286,6 +286,7 @@ if (element.copyType === 'action') { element.eleType = 'button' + element.width = element.width || 12 } element.uuid = _uuid diff --git a/src/menu/components/card/cardsimplecomponent/index.jsx b/src/menu/components/card/cardsimplecomponent/index.jsx index cf6e1d3..2eb816e 100644 --- a/src/menu/components/card/cardsimplecomponent/index.jsx +++ b/src/menu/components/card/cardsimplecomponent/index.jsx @@ -194,6 +194,7 @@ if (element.copyType === 'action') { element.eleType = 'button' + element.width = element.width || 12 } element.uuid = _uuid diff --git a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx index 14981f8..ae3c8f1 100644 --- a/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx +++ b/src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx @@ -55,22 +55,30 @@ label: '鏃犲姩浣�' } ] - columns.forEach(col => { - if (col.editable === 'true' && col.uuid !== card.uuid) { - editCols.push({ - field: col.uuid, - label: col.label - }) - } else if (col.type === 'colspan') { - col.subcols.forEach(subcol => { - if (subcol.editable === 'true' && subcol.uuid !== card.uuid) { - editCols.push({ - field: subcol.uuid, - label: col.label + '-' + subcol.label - }) - } - }) - } + + let cols = [] + let getcols = (columns, suplabel = '') => { + columns.forEach(col => { + if (col.editable === 'true' && col.uuid !== card.uuid) { + cols.push({ + field: col.uuid, + label: suplabel + col.label + }) + } else if (col.type === 'colspan') { + getcols(col.subcols, col.label + '-') + } + }) + } + + getcols(columns) + + editCols.push(...cols) + + cols.forEach(col => { + editCols.push({ + field: '$next_' + col.field, + label: col.label + '锛堜笅涓�琛岋級' + }) }) return [ diff --git a/src/menu/modalconfig/index.jsx b/src/menu/modalconfig/index.jsx index a0409b1..a6741f2 100644 --- a/src/menu/modalconfig/index.jsx +++ b/src/menu/modalconfig/index.jsx @@ -20,6 +20,7 @@ const { Panel } = Collapse const { confirm } = Modal +const TableComponent = asyncComponent(() => import('./tablecomponent')) const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform')) const PasteForms = asyncComponent(() => import('@/menu/components/share/pasteforms')) const DragElement = asyncComponent(() => import('@/templates/modalconfig/dragelement')) @@ -525,6 +526,9 @@ <DndProvider backend={HTML5Backend}> <div className="tools"> <Collapse accordion defaultActiveKey="1" bordered={false}> + <Panel header="鍩烘湰淇℃伅" key="0"> + <TableComponent /> + </Panel> <Panel header="琛ㄥ崟" key="1"> <div className="search-element"> {SearchItems.map((item, index) => { diff --git a/src/menu/modalconfig/tablecomponent/index.jsx b/src/menu/modalconfig/tablecomponent/index.jsx new file mode 100644 index 0000000..01fd0f2 --- /dev/null +++ b/src/menu/modalconfig/tablecomponent/index.jsx @@ -0,0 +1,163 @@ +import React, {Component} from 'react' +import { fromJS } from 'immutable' +import { Tooltip, Select, List, notification } from 'antd' +import { QuestionCircleOutlined, CloseOutlined } from '@ant-design/icons' +import moment from 'moment' + +import Api from '@/api' +import options from '@/store/options.js' +import Utils from '@/utils/utils.js' +import MKEmitter from '@/utils/events.js' +import { queryTableSql } from '@/utils/option.js' + +import './index.scss' + +const { Option } = Select + +class TablesComponent extends Component { + state = { + tables: [], // 绯荤粺琛� + selectedTables: [], // 宸查�夎〃 + } + + /** + * @description 鎼滅储鏉′欢鍒濆鍖� + */ + UNSAFE_componentWillMount () { + this.setState({ + selectedTables: window.GLOB.publicTables ? fromJS(window.GLOB.publicTables).toJS() : [] + }) + } + + componentDidMount () { + this.gettables() + } + + /** + * @description 鑾峰彇绯荤粺琛� + */ + gettables = () => { + let param = { + func: 'sPC_Get_SelectedList', + LText: queryTableSql, + obj_name: 'data', + arr_field: 'TbName,Remark' + } + + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉 + + if (options.cloudServiceApi) { // 涓斿瓨鍦ㄤ簯绔湴鍧� + param.rduri = options.cloudServiceApi + param.userid = sessionStorage.getItem('CloudUserID') || '' + param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' + } + + Api.getSystemCacheConfig(param).then(res => { + if (res.status) { + this.setState({ + tables: res.data + }) + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + } + }) + } + + /** + * @description 娣诲姞琛ㄥ悕 + */ + onTableChange = (value) => { + const { tables, selectedTables } = this.state + + let _table = tables.filter(item => item.TbName === value)[0] + let isSelected = !!selectedTables.filter(cell => cell.TbName === value)[0] + if (!isSelected) { + let _tables = [...selectedTables, _table] + + MKEmitter.emit('publicTableChange', value, 'plus') + + this.setState({ + selectedTables: _tables + }) + } + } + + /** + * @description 鍒犻櫎琛ㄥ悕 + */ + deleteTable = (table) => { + const { selectedTables } = this.state + + let _tables = selectedTables.filter(item => item.TbName !== table.TbName) + + MKEmitter.emit('publicTableChange', table, 'del') + + this.setState({ + selectedTables: _tables + }) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + + render() { + const { tables, selectedTables } = this.state + + return ( + <div className="model-tablename-manage-view"> + {/* 琛ㄥ悕娣诲姞 */} + <div className="ant-col ant-form-item-label"> + <label> + <Tooltip placement="topLeft" title="姝ゅ鍙互娣诲姞椤甸潰閰嶇疆鐩稿叧鐨勫父鐢ㄨ〃銆�"> + <QuestionCircleOutlined className="mk-form-tip" /> + 琛ㄥ悕 + </Tooltip> + </label> + </div> + <Select + showSearch + className="tables" + style={{ width: '100%' }} + optionFilterProp="children" + value="璇烽�夋嫨琛ㄥ悕" + onSelect={this.onTableChange} + dropdownClassName="mk-tables" + dropdownMatchSelectWidth={false} + showArrow={false} + filterOption={(input, option) => { + return option.props.children[0].toLowerCase().indexOf(input.toLowerCase()) >= 0 || + option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0 + }} + > + {tables.map((table, index) => ( + <Option key={index} title={table.TbName} value={table.TbName}>{table.Remark}<br/>{table.TbName}</Option> + ))} + </Select> + {selectedTables.length > 0 && <List + size="small" + bordered + dataSource={selectedTables} + renderItem={(item, index) => <List.Item key={index} title={item.Remark + ' (' + item.TbName + ')'}> + {item.Remark + ' (' + item.TbName + ')'} + <CloseOutlined onClick={() => this.deleteTable(item)}/> + </List.Item>} + />} + </div> + ) + } +} + +export default TablesComponent \ No newline at end of file diff --git a/src/menu/modalconfig/tablecomponent/index.scss b/src/menu/modalconfig/tablecomponent/index.scss new file mode 100644 index 0000000..92d6c69 --- /dev/null +++ b/src/menu/modalconfig/tablecomponent/index.scss @@ -0,0 +1,36 @@ +.model-tablename-manage-view { + >.ant-list { + margin-top: 20px; + .ant-list-item { + display: -webkit-box; + padding-right: 20px; + position: relative; + padding-left: 5px; + overflow: hidden; + text-overflow: ellipsis; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + min-height: 55px; + width: 100%; + .anticon { + position: absolute; + top: 0px; + right: 0px; + padding: 3px 3px 10px 10px; + cursor: pointer; + } + } + } + .tables { + width: 66.66666667%!important; + .ant-select-selection-selected-value { + opacity: 0.4!important; + } + } + >.ant-form-item-label { + width: 33.33333333%; + } +} +.mk-tables { + max-width: 300px; +} \ No newline at end of file diff --git a/src/mob/modalconfig/index.jsx b/src/mob/modalconfig/index.jsx index baa3cb9..285307a 100644 --- a/src/mob/modalconfig/index.jsx +++ b/src/mob/modalconfig/index.jsx @@ -20,6 +20,7 @@ const { Panel } = Collapse const { confirm } = Modal +const TableComponent = asyncComponent(() => import('@/menu/modalconfig/tablecomponent')) const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform')) const PasteForms = asyncComponent(() => import('@/menu/components/share/pasteforms')) const DragElement = asyncComponent(() => import('@/mob/components/formdragelement')) @@ -478,6 +479,9 @@ <DndProvider backend={HTML5Backend}> <div className="tools"> <Collapse accordion defaultActiveKey="1" bordered={false}> + <Panel header="鍩烘湰淇℃伅" key="0"> + <TableComponent /> + </Panel> <Panel header="琛ㄥ崟" key="1"> <div className="search-element"> {SearchItems.map((item, index) => { diff --git a/src/tabviews/custom/components/table/edit-table/index.jsx b/src/tabviews/custom/components/table/edit-table/index.jsx index b2d83f8..d1281be 100644 --- a/src/tabviews/custom/components/table/edit-table/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/index.jsx @@ -79,6 +79,7 @@ let _columns = [] setting.initId = '' let triMap = new Map() + setting.hasSubmit = false let getColumns = (cols) => { return cols.filter(item => { @@ -115,6 +116,7 @@ } if (item.editable === 'true') { + setting.hasSubmit = true if (!setting.initId) { setting.initId = item.uuid } @@ -543,7 +545,7 @@ } return ( - <div className="custom-edit-table" id={'anchor' + config.uuid} style={style}> + <div className={'custom-edit-table' + (setting.hasSubmit ? '' : ' withnot-submit')} id={'anchor' + config.uuid} style={style}> <NormalHeader config={config}/> {config.search && config.search.length ? <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null diff --git a/src/tabviews/custom/components/table/edit-table/index.scss b/src/tabviews/custom/components/table/edit-table/index.scss index 18e3dda..ed1aecb 100644 --- a/src/tabviews/custom/components/table/edit-table/index.scss +++ b/src/tabviews/custom/components/table/edit-table/index.scss @@ -9,15 +9,17 @@ border-bottom: 1px solid #efefef; padding-top: 10px; } + .toolbar-button + .edit-custom-table-btn-wrap { + position: absolute; + right: 0px; + margin-top: 15px; + } +} +.custom-edit-table:not(.withnot-submit) { .button-list.toolbar-button { float: right; margin-right: 80px; position: relative; z-index: 2; - } - .toolbar-button + .edit-custom-table-btn-wrap { - position: absolute; - right: 0px; - margin-top: 15px; } } \ No newline at end of file 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 47fb9f2..ec88944 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx @@ -119,7 +119,7 @@ this.setState({editing: false}) setTimeout(() => { - if (col.enter === '$next') { + if (/\$next/.test(col.enter)) { MKEmitter.emit('nextLine', col, record.$$uuid) } else if (col.enter === '$sub') { MKEmitter.emit('subLine', col, record) @@ -208,7 +208,7 @@ this.setState({editing: false}) setTimeout(() => { - if (col.enter === '$next') { + if (/\$next/.test(col.enter)) { MKEmitter.emit('nextLine', col, record.$$uuid) } else if (col.enter === '$sub') { MKEmitter.emit('subLine', col, record) @@ -240,7 +240,7 @@ this.setState({editing: false}) setTimeout(() => { - if (col.enter === '$next') { + if (/\$next/.test(col.enter)) { MKEmitter.emit('nextLine', col, record.$$uuid) } else if (col.enter === '$sub') { MKEmitter.emit('subLine', col, record) @@ -542,7 +542,7 @@ this.onBlur() setTimeout(() => { - if (col.enter === '$next') { + if (/\$next/.test(col.enter)) { MKEmitter.emit('nextLine', col, record.$$uuid) } else if (col.enter === '$sub') { MKEmitter.emit('subLine', col, record) @@ -602,7 +602,7 @@ const { col, record } = this.props setTimeout(() => { - if (col.enter === '$next') { + if (/\$next/.test(col.enter)) { MKEmitter.emit('nextLine', col, record.$$uuid) } else if (col.enter === '$sub') { MKEmitter.emit('subLine', col, record) @@ -638,7 +638,7 @@ } setTimeout(() => { - if (col.enter === '$next') { + if (/\$next/.test(col.enter)) { MKEmitter.emit('nextLine', col, record.$$uuid) } else if (col.enter === '$sub') { MKEmitter.emit('subLine', col, record) @@ -1297,7 +1297,12 @@ let next = edData[index + 1] || null if (next) { - let node = document.getElementById(setting.initId + next.$$uuid) + let nextId = setting.initId + next.$$uuid + if (/^\$next_/.test(col.enter)) { + nextId = col.enter.split('_')[1] + next.$$uuid + } + + let node = document.getElementById(nextId) if (node) { if (setting.editType === 'multi') { if (setting.triType === 'click') { @@ -1894,9 +1899,9 @@ return ( <> - <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> + {setting.hasSubmit ? <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}> <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-table" type="link">鎻愪氦</Button> - </div> + </div> : null} <div className={`edit-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} id={tableId}> <Table rowKey="$$uuid" @@ -1919,7 +1924,7 @@ onChange={this.changeTable} pagination={_pagination} /> - {_data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-footer-table" type="link">鎻愪氦</Button> : null} + {setting.hasSubmit && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-footer-table" type="link">鎻愪氦</Button> : null} </div> </> ) diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.scss b/src/tabviews/custom/components/table/edit-table/normalTable/index.scss index eea792f..3bdf335 100644 --- a/src/tabviews/custom/components/table/edit-table/normalTable/index.scss +++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.scss @@ -270,17 +270,17 @@ table tbody tr { color: var(--mk-table-color); } - .ant-table-bordered { - table { - tbody { - tr:last-child { - td { - border-bottom: none; - } - } - } - } - } + // .ant-table-bordered { + // table { + // tbody { + // tr:last-child { + // td { + // border-bottom: none; + // } + // } + // } + // } + // } } .edit-custom-table.mk-edit-simple { table tbody tr td { diff --git a/src/templates/sharecomponent/tablecomponent/index.jsx b/src/templates/sharecomponent/tablecomponent/index.jsx index 540dee1..15954e3 100644 --- a/src/templates/sharecomponent/tablecomponent/index.jsx +++ b/src/templates/sharecomponent/tablecomponent/index.jsx @@ -8,6 +8,7 @@ import Api from '@/api' import options from '@/store/options.js' import Utils from '@/utils/utils.js' +import MKEmitter from '@/utils/events.js' import { queryTableSql } from '@/utils/option.js' import './index.scss' @@ -33,15 +34,28 @@ UNSAFE_componentWillMount () { const { config } = this.props + let tables = config.tables ? fromJS(config.tables).toJS() : [] + + window.GLOB.publicTables = tables + this.setState({ - selectedTables: config.tables ? fromJS(config.tables).toJS() : [] + selectedTables: tables }, () => { this.gettableFields() }) } componentDidMount () { + MKEmitter.addListener('publicTableChange', this.publicTableChange) this.gettables() + } + + publicTableChange = (table, type) => { + if (type === 'plus') { + this.onTableChange(table) + } else if (type === 'del') { + this.deleteTable(table) + } } /** @@ -170,11 +184,15 @@ let _table = tables.filter(item => item.TbName === value)[0] let isSelected = !!selectedTables.filter(cell => cell.TbName === value)[0] if (!isSelected) { + let _tables = [...selectedTables, _table] + + window.GLOB.publicTables = _tables + this.setState({ - selectedTables: [...selectedTables, _table] + selectedTables: _tables }) - let _config = {...config, tables: [...selectedTables, _table]} + let _config = {...config, tables: _tables} Api.getSystemConfig({func: 'sPC_Get_FieldName', TBName: value}).then(res => { if (res.status) { @@ -248,6 +266,8 @@ let _tables = selectedTables.filter(item => item.TbName !== table.TbName) let _fields = tableFields.filter(item => item.tableName !== table.TbName) + window.GLOB.publicTables = _tables + this.setState({ selectedTables: _tables, tableFields: _fields @@ -265,6 +285,7 @@ this.setState = () => { return } + MKEmitter.removeListener('publicTableChange', this.publicTableChange) } render() { @@ -276,7 +297,7 @@ {/* 琛ㄥ悕娣诲姞 */} <div className="ant-col ant-form-item-label"> <label> - <Tooltip placement="topLeft" title="姝ゅ鍙互娣诲姞椤甸潰閰嶇疆鐩稿叧鐨勫父鐢ㄨ〃锛屽彲閫氳繃宸ュ叿鏍忎腑鐨勬坊鍔犳寜閽紝鍙壒閲忔坊鍔犺〃鏍肩浉鍏冲瓧娈点��"> + <Tooltip placement="topLeft" title="姝ゅ鍙互娣诲姞椤甸潰閰嶇疆鐩稿叧鐨勫父鐢ㄨ〃銆�"> <QuestionCircleOutlined className="mk-form-tip" /> 琛ㄥ悕 </Tooltip> diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index 6cb5386..be4f888 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -544,8 +544,12 @@ return cell }) - } else if (col.editable === 'true' && col.enter) { - col.enter = md5(commonId + col.enter) + } else if (col.editable === 'true' && col.enter && col.enter !== '$next' && col.enter !== '$sub') { + if (/\$next_/.test(col.enter)) { + col.enter = '$next_' + md5(commonId + col.enter.split('_')[1]) + } else { + col.enter = md5(commonId + col.enter) + } } return col @@ -833,8 +837,12 @@ } return cell }) - } else if (col.editable === 'true' && col.enter) { // 鍙紪杈戣〃 - col.enter = md5(commonId + col.enter) + } else if (col.editable === 'true' && col.enter && col.enter !== '$next' && col.enter !== '$sub') { // 鍙紪杈戣〃 + if (/\$next_/.test(col.enter)) { + col.enter = '$next_' + md5(commonId + col.enter.split('_')[1]) + } else { + col.enter = md5(commonId + col.enter) + } } return col -- Gitblit v1.8.0