From 03a22ec6f9ad7303d10b4c65bb5bc6fa5cbd448a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 22 十月 2022 23:21:42 +0800 Subject: [PATCH] 2022-10-22 --- src/mob/components/tabs/antv-tabs/options.jsx | 2 src/tabviews/custom/components/tabs/antv-tabs/index.jsx | 2 src/utils/utils-custom.js | 176 +- src/menu/components/card/balcony/options.jsx | 2 src/templates/sharecomponent/fieldscomponent/editcard/index.jsx | 27 src/menu/components/share/actioncomponent/dragaction/index.jsx | 2 src/menu/datasource/index.jsx | 10 src/views/tabledesign/source.jsx | 77 src/tabviews/basetable/index.jsx | 1417 ++++++------------------- src/menu/components/form/formaction/index.jsx | 2 src/menu/tablenodes/index.jsx | 40 src/menu/tableshell/card.jsx | 4 src/menu/datasource/verifycard/index.jsx | 49 src/mob/colorsketch/index.jsx | 4 src/menu/tableshell/index.jsx | 72 src/menu/components/card/cardcellcomponent/index.jsx | 34 src/menu/components/card/data-card/options.jsx | 2 src/menu/components/share/actioncomponent/formconfig.jsx | 15 src/tabviews/custom/components/table/normal-table/index.jsx | 33 src/menu/components/tabs/antv-tabs/options.jsx | 2 src/menu/components/tabs/table-tabs/dragabletabs.jsx | 1 src/menu/components/table/base-table/columns/index.jsx | 65 + src/menu/components/table/normal-table/index.jsx | 28 src/menu/components/table/normal-table/columns/index.jsx | 9 src/views/appmanage/submutilform/index.jsx | 28 src/menu/components/table/edit-table/columns/index.jsx | 7 src/components/tabview/index.jsx | 6 src/templates/sharecomponent/settingcomponent/index.jsx | 10 src/tabviews/custom/components/table/base-table/index.jsx | 588 ++++++++++ src/tabviews/zshare/topSearch/index.jsx | 2 src/templates/zshare/unattended/index.jsx | 21 src/menu/components/table/base-table/columns/editColumn/formconfig.jsx | 7 src/menu/components/tabs/table-tabs/index.jsx | 114 - src/menu/components/form/simple-form/options.jsx | 2 src/templates/sharecomponent/fieldscomponent/index.jsx | 5 src/tabviews/custom/components/table/edit-table/index.jsx | 17 src/views/tabledesign/index.jsx | 141 + src/menu/components/form/step-form/options.jsx | 2 src/menu/components/table/edit-table/index.jsx | 21 src/menu/components/module/voucher/options.jsx | 2 src/menu/components/table/base-table/columns/index.scss | 18 src/tabviews/custom/components/table/base-table/index.scss | 48 src/tabviews/custom/components/share/tabtransfer/index.jsx | 7 src/menu/datasource/verifycard/settingform/index.jsx | 36 src/templates/zshare/verifycard/index.jsx | 4 src/menu/components/share/actioncomponent/index.jsx | 40 src/menu/components/card/cardcellcomponent/formconfig.jsx | 16 src/menu/components/table/base-table/index.jsx | 69 + src/templates/zshare/verifycard/baseform/index.jsx | 13 49 files changed, 1,859 insertions(+), 1,440 deletions(-) diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx index ffb0f08..2828134 100644 --- a/src/components/tabview/index.jsx +++ b/src/components/tabview/index.jsx @@ -17,7 +17,7 @@ const Home = asyncComponent(() => import('@/tabviews/home')) const CustomPage = asyncComponent(() => import('@/tabviews/custom')) const CommonTable = asyncComponent(() => import('@/tabviews/commontable')) -// const BaseTable = asyncComponent(() => import('@/tabviews/basetable')) +const BaseTable = asyncComponent(() => import('@/tabviews/basetable')) const CalendarPage = asyncComponent(() => import('@/tabviews/calendar')) const TreePage = asyncComponent(() => import('@/tabviews/treepage')) const TabManage = asyncComponent(() => import('@/tabviews/tabmanage')) @@ -191,8 +191,8 @@ return (<Home MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>) } else if (view.type === 'CommonTable') { return (<CommonTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param}/>) - // } else if (view.type === 'BaseTable') { - // return (<BaseTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param}/>) + } else if (view.type === 'BaseTable') { + return (<BaseTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param}/>) } else if (view.type === 'CustomPage') { return (<CustomPage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param}/>) } else if (view.type === 'TreePage') { diff --git a/src/menu/components/card/balcony/options.jsx b/src/menu/components/card/balcony/options.jsx index c39fa7b..1946423 100644 --- a/src/menu/components/card/balcony/options.jsx +++ b/src/menu/components/card/balcony/options.jsx @@ -9,7 +9,7 @@ let menu = fromJS(window.GLOB.customMenu).toJS() let modules = MenuUtils.getLinkModules(menu.components) || [] - let supmodules = MenuUtils.getSupModules(menu.components, '') || [] + let supmodules = MenuUtils.getSupModules(menu.components, '') let roleList = sessionStorage.getItem('sysRoles') let appType = sessionStorage.getItem('appType') diff --git a/src/menu/components/card/cardcellcomponent/formconfig.jsx b/src/menu/components/card/cardcellcomponent/formconfig.jsx index 02e8d29..4e0739a 100644 --- a/src/menu/components/card/cardcellcomponent/formconfig.jsx +++ b/src/menu/components/card/cardcellcomponent/formconfig.jsx @@ -1,9 +1,11 @@ +import MenuUtils from '@/utils/utils-custom.js' + /** * @description 鑾峰彇鍏冪礌閰嶇疆淇℃伅 * @param {*} card * @param {*} type */ -export function getCardCellForm (card, type, subtype, cardCell, anchors) { +export function getCardCellForm (card, cards, cardCell) { let _options = [ { value: 'text', text: '鏂囨湰'}, { value: 'number', text: '鏁板��'}, @@ -18,7 +20,14 @@ { value: 'formula', text: '鍏紡'}, ] - if (type === 'table' || (type === 'card' && subtype === 'datacard')) { + let anchors = [] + if (window.GLOB.customMenu.Template === 'BaseTable') { + anchors = null + } else { + anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || [] + } + + if (cards.type === 'table' || (cards.type === 'card' && cards.subtype === 'datacard')) { _options.push({value: 'sequence', text: '搴忓彿'}) } else if (card.eleType === 'sequence') { // 鎷栨嫿娣诲姞绫诲瀷杞崲 card.eleType = 'text' @@ -364,7 +373,8 @@ initVal: card.anchors || [], tooltip: sessionStorage.getItem('appType') === 'mob' ? '娉細灏忕▼搴忎腑鏃犳晥' : '', required: false, - options: anchors + options: anchors, + forbid: !anchors }, { type: 'number', diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index 8ab612e..520b227 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -5,7 +5,7 @@ import asyncComponent from '@/utils/asyncComponent' import { getCardCellForm } from './formconfig' -import { getActionForm } from '@/menu/components/share/actioncomponent/formconfig' +import { getActionForm, getBaseTableActionForm } from '@/menu/components/share/actioncomponent/formconfig' import MKEmitter from '@/utils/events.js' import MenuUtils from '@/utils/utils-custom.js' @@ -260,12 +260,10 @@ if (card.eleType === 'button') { this.handleAction(card) } else { - let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || [] - this.setState({ visible: true, card: card, - formlist: getCardCellForm(card, cards.type, cards.subtype, cardCell, anchors) + formlist: getCardCellForm(card, cards, cardCell) }) } } @@ -303,14 +301,23 @@ } } - let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, cards.uuid, supId) || [] - let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || [] + let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, cards.uuid, supId) - this.setState({ - actvisible: true, - card: card, - formlist: getActionForm(card, functip, cards, usefulFields, modules, anchors) - }) + if (cards.subtype === 'basetable') { + this.setState({ + actvisible: true, + card: card, + formlist: getBaseTableActionForm(card, functip, cards, usefulFields, modules) + }) + } else { + let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || [] + + this.setState({ + actvisible: true, + card: card, + formlist: getActionForm(card, functip, cards, usefulFields, modules, anchors) + }) + } } /** @@ -431,13 +438,14 @@ res.style = {} } } else if (res.class !== cell.class || res.show !== cell.show || !res.style) { + let cl = res.class.replace('border-', '') let style = {} if (res.show === 'link' || res.show === 'icon') { - style.color = color[res.class] + style.color = color[cl] style.backgroundColor = 'transparent' } else { style.color = '#ffffff' - style.backgroundColor = color[res.class] + style.backgroundColor = color[cl] } res.style = {...res.style, ...style} } diff --git a/src/menu/components/card/data-card/options.jsx b/src/menu/components/card/data-card/options.jsx index 3733162..733b74d 100644 --- a/src/menu/components/card/data-card/options.jsx +++ b/src/menu/components/card/data-card/options.jsx @@ -26,7 +26,7 @@ } let modules = [] if (subtype === 'propcard' || subtype === 'datacard') { - modules = MenuUtils.getSupModules(menu.components, id) || [] + modules = MenuUtils.getSupModules(menu.components, id) } let roleList = sessionStorage.getItem('sysRoles') diff --git a/src/menu/components/form/formaction/index.jsx b/src/menu/components/form/formaction/index.jsx index f0e70b2..91ab639 100644 --- a/src/menu/components/form/formaction/index.jsx +++ b/src/menu/components/form/formaction/index.jsx @@ -96,7 +96,7 @@ supId = config.wrap.supModule[config.wrap.supModule.length - 1] } - let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, config.uuid, supId) || [] + let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, config.uuid, supId) let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, config.uuid) || [] if (card.type === 'submit' && !card.Ot) { diff --git a/src/menu/components/form/simple-form/options.jsx b/src/menu/components/form/simple-form/options.jsx index 4e25a6c..12b0542 100644 --- a/src/menu/components/form/simple-form/options.jsx +++ b/src/menu/components/form/simple-form/options.jsx @@ -37,7 +37,7 @@ let modules = [] let menu = fromJS(window.GLOB.customMenu).toJS() - modules = MenuUtils.getSupModules(menu.components, config.uuid) || [] + modules = MenuUtils.getSupModules(menu.components, config.uuid) const wrapForm = [ { diff --git a/src/menu/components/form/step-form/options.jsx b/src/menu/components/form/step-form/options.jsx index fa3eb97..403fa82 100644 --- a/src/menu/components/form/step-form/options.jsx +++ b/src/menu/components/form/step-form/options.jsx @@ -21,7 +21,7 @@ let modules = [] let menu = fromJS(window.GLOB.customMenu).toJS() - modules = MenuUtils.getSupModules(menu.components, config.uuid) || [] + modules = MenuUtils.getSupModules(menu.components, config.uuid) const wrapForm = [ { diff --git a/src/menu/components/module/voucher/options.jsx b/src/menu/components/module/voucher/options.jsx index df667c8..d8466ad 100644 --- a/src/menu/components/module/voucher/options.jsx +++ b/src/menu/components/module/voucher/options.jsx @@ -9,7 +9,7 @@ let appType = sessionStorage.getItem('appType') let menu = fromJS(window.GLOB.customMenu).toJS() - let modules = MenuUtils.getSupModules(menu.components, id) || [] + let modules = MenuUtils.getSupModules(menu.components, id) if (roleList) { try { diff --git a/src/menu/components/share/actioncomponent/dragaction/index.jsx b/src/menu/components/share/actioncomponent/dragaction/index.jsx index b4f4a65..b59ac72 100644 --- a/src/menu/components/share/actioncomponent/dragaction/index.jsx +++ b/src/menu/components/share/actioncomponent/dragaction/index.jsx @@ -122,7 +122,7 @@ if (newcard.OpenType === 'excelIn') { newcard.label = item.text - newcard.class = 'dgreen' + newcard.class = item.class || 'dgreen' newcard.Ot = 'notRequired' } else if (newcard.OpenType === 'excelOut') { newcard.label = item.text diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index 22eae11..148af17 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -1029,13 +1029,12 @@ * @param {*} setting 缁勪欢閰嶇疆 * @param {*} usefulFields 瀛樺偍杩囩▼鍙敤鐨勫紑濮嬪瓧娈� */ -export function getBaseTableActionForm (card, functip, config, usefulFields) { +export function getBaseTableActionForm (card, functip, config, usefulFields, modules) { let viewType = sessionStorage.getItem('editMenuType') // 寮圭獥 popview let printTemps = sessionStorage.getItem('printTemps') printTemps = printTemps ? JSON.parse(printTemps) : [] let setting = config.setting || {} let columns = config.columns || [] - let modules = [] let opentypes = [ { @@ -1447,6 +1446,18 @@ }] }, { + type: 'number', + key: 'width', + min: 1, + max: 24, + precision: 0, + label: '瀹藉害', + initVal: card.width || 12, + tooltip: '鏍呮牸甯冨眬锛屾瘡琛岀瓑鍒嗕负24鍒椼��', + forbid: card.eleType !== 'button', + required: true + }, + { type: 'icon', key: 'icon', label: '鍥炬爣', diff --git a/src/menu/components/share/actioncomponent/index.jsx b/src/menu/components/share/actioncomponent/index.jsx index 4a6ebd9..0f29f3c 100644 --- a/src/menu/components/share/actioncomponent/index.jsx +++ b/src/menu/components/share/actioncomponent/index.jsx @@ -169,15 +169,6 @@ functip = '' } - if (config.subtype === 'basetable') { - this.setState({ - visible: true, - card: card, - formlist: getBaseTableActionForm(card, functip, config, usefulFields) - }) - return - } - let supId = '' if (config.setting && config.setting.supModule) { let pid = config.setting.supModule[config.setting.supModule.length - 1] @@ -188,14 +179,25 @@ } } - let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, config.uuid, supId) || [] - let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, config.uuid) || [] + let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, config.uuid, supId) - this.setState({ - visible: true, - card: card, - formlist: getActionForm(card, functip, config, usefulFields, modules, anchors) - }) + if (config.subtype === 'basetable') { + delete card.eleType // 鍖哄垎鎸夐挳浣嶇疆 + + this.setState({ + visible: true, + card: card, + formlist: getBaseTableActionForm(card, functip, config, usefulFields, modules) + }) + } else { + let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, config.uuid) || [] + + this.setState({ + visible: true, + card: card, + formlist: getActionForm(card, functip, config, usefulFields, modules, anchors) + }) + } } /** @@ -243,9 +245,9 @@ if (config.subtype === 'basetable') { let _c = btn.class.replace('border-', '') if (btn.class.indexOf('border') > -1 || btn.class === 'default') { - btn.style = {color: color[_c], backgroundColor: '#fff', borderColor: color[_c]} + btn.style = {color: color[_c], backgroundColor: '#fff', borderColor: color[_c], marginRight: '15px'} } else { - btn.style = {color: '#fff', backgroundColor: color[_c], borderColor: color[_c]} + btn.style = {color: '#fff', backgroundColor: color[_c], borderColor: color[_c], marginRight: '15px'} } } else { btn.style = item.style || {} @@ -435,7 +437,7 @@ let btn = null let _col = null - if (config.subtype === 'normaltable' || config.subtype === 'editable') { + if (config.subtype === 'normaltable' || config.subtype === 'editable' || config.subtype === 'basetable') { config.cols.forEach(col => { if (col.type !== 'action') return diff --git a/src/menu/components/table/base-table/columns/editColumn/formconfig.jsx b/src/menu/components/table/base-table/columns/editColumn/formconfig.jsx index 8938741..6897370 100644 --- a/src/menu/components/table/base-table/columns/editColumn/formconfig.jsx +++ b/src/menu/components/table/base-table/columns/editColumn/formconfig.jsx @@ -194,6 +194,13 @@ }, { type: 'number', + key: 'fieldlength', + label: '瀛楁闀垮害', + initVal: card.fieldlength || 50, + required: true + }, + { + type: 'number', key: 'decimal', min: 0, max: 18, diff --git a/src/menu/components/table/base-table/columns/index.jsx b/src/menu/components/table/base-table/columns/index.jsx index 5292b18..58ed260 100644 --- a/src/menu/components/table/base-table/columns/index.jsx +++ b/src/menu/components/table/base-table/columns/index.jsx @@ -16,6 +16,7 @@ const MarkColumn = asyncIconComponent(() => import('@/menu/components/share/markcomponent')) const CardCellComponent = asyncComponent(() => import('@/menu/components/card/cardcellcomponent')) const PasteComponent = asyncIconComponent(() => import('@/components/paste')) +const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) class HeaderCol extends Component { deleteCol = () => { @@ -49,7 +50,7 @@ } render() { - const { connectDragSource, connectDropTarget, moveCol, addElement, updateCol, editColumn, pasteCell, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props + const { connectDragSource, connectDropTarget, moveCol, addElement, dropCol, updateCol, editColumn, pasteCell, changeStyle, deleteCol, index, column, align, fields, children, ...restProps } = this.props if (index !== undefined) { return connectDragSource( @@ -104,10 +105,14 @@ const ColTarget = { drop(props, monitor) { - const dragIndex = monitor.getItem().index + const item = monitor.getItem() + const dragIndex = item.index const hoverIndex = props.index - if (dragIndex === undefined || hoverIndex === undefined || dragIndex === hoverIndex) { + if (item.$init) { + props.dropCol(item, hoverIndex) + return + } else if (dragIndex === undefined || hoverIndex === undefined || dragIndex === hoverIndex) { return } @@ -145,13 +150,13 @@ if (column && column.type === 'custom') { return ( - <td style={{padding: 0, minWidth: column.Width || 100, ...(column.style || {})}} className={className}> + <td style={{padding: 0, minWidth: (column.Width || 100) / 2, ...(column.style || {})}} className={className}> <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> </td> ) } else if (column && column.type === 'action') { return ( - <td style={{padding: '0 5px', textAlign: column.Align, minWidth: column.Width || 100}} className={'action-column ' + className}> + <td style={{padding: '0 5px', textAlign: column.Align, minWidth: (column.Width || 100) / 2}} className={'action-column ' + className}> <CardCellComponent cards={config} cardCell={column} elements={column.elements} updateElement={this.updateCard}/> </td> ) @@ -167,7 +172,7 @@ } } return ( - <td style={{...style, minWidth: column.Width || 100}} className={className}> + <td style={{...style, minWidth: (column.Width || 100) / 2}} className={className}> {val} {column.Hide === 'true' ? <CloseCircleOutlined style={{marginLeft: '5px', color: 'orange', fontSize: '12px'}}/> : null} {column.marks && column.marks.length ? <AntDesignOutlined className="profile"/> : null} @@ -265,10 +270,31 @@ }) } + dropCol = (item, hoverIndex) => { + let _columns = fromJS(this.state.columns).toJS() + + let col = { focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: item.subType, elements: [] } + if (col.type === 'colspan') { + col.subcols = [] + } else if (col.type === 'action') { + col.label = '鎿嶄綔' + } else if (col.type === 'index') { + col.label = '搴忓彿' + } + + _columns.splice(hoverIndex, 0, col) + + this.setState({ + columns: _columns + }, () => { + this.editColumn(col) + }) + } + loopCol = (columns, col) => { return columns.map(column => { if (column.type === 'colspan') { - column.subcols = this.loopCol(column.subcols, col) + column.subcols = this.loopCol(column.subcols || [], col) } if (column.uuid === col.uuid) { return col @@ -467,7 +493,6 @@ title: col.label, dataIndex: col.uuid, align: col.Align, - // sorter: !isSub && col.IsSort === 'true', sorter: col.IsSort === 'true', onCell: () => ({ column: col, @@ -482,6 +507,7 @@ align: col.Align, moveCol: this.moveCol, updateCol: this.updateCol, + dropCol: this.dropCol, addElement: this.addElement, editColumn: this.editColumn, pasteCell: this.pasteCell, @@ -493,6 +519,27 @@ }) } + plusColumns = (id, items) => { + const { config } = this.props + + if (id !== config.uuid) return + + let _columns = fromJS(this.state.columns).toJS() + _columns = _columns.filter(a => !a.origin) + + _columns.push(...items) + + this.setState({ + columns: _columns + }, () => { + this.props.updatecolumn({...config, cols: _columns}) + }) + } + + componentDidMount () { + MKEmitter.addListener('plusColumns', this.plusColumns) + } + /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ @@ -500,6 +547,7 @@ this.setState = () => { return } + MKEmitter.removeListener('plusColumns', this.plusColumns) } render() { @@ -519,6 +567,7 @@ return ( <div className={`normal-table-columns ${config.setting.laypage} ${config.wrap.tableType} ${config.wrap.mode || ''}`} id={tableId}> <div className="col-control"> + <FieldsComponent config={config} type="columns" /> <CopyOutlined title="澶嶅埗鏄剧ず鍒�" onClick={this.copycolumn} /> <MarkColumn columns={fields} type="line" marks={lineMarks} onSubmit={this.updateLineMarks} /> </div> diff --git a/src/menu/components/table/base-table/columns/index.scss b/src/menu/components/table/base-table/columns/index.scss index 3d4835c..97ae93b 100644 --- a/src/menu/components/table/base-table/columns/index.scss +++ b/src/menu/components/table/base-table/columns/index.scss @@ -72,15 +72,21 @@ >.anticon-copy { color: #26C281; } - >.anticon-delete { - color: #ff4d4f; - } - >.anticon-file-sync { - color: #1890ff; - } >div >.profile { color: purple; } + .quickly-add { + display: inline-block; + margin-right: 15px; + .ant-btn { + background-color: transparent; + color: #1890ff; + border: none; + box-shadow: none !important; + height: 18px; + padding: 0px; + } + } } .ant-table-small > .ant-table-content > .ant-table-body { margin: 0; diff --git a/src/menu/components/table/base-table/index.jsx b/src/menu/components/table/base-table/index.jsx index 9620ec9..f4a90c1 100644 --- a/src/menu/components/table/base-table/index.jsx +++ b/src/menu/components/table/base-table/index.jsx @@ -6,6 +6,7 @@ import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' +import { getTables } from '@/utils/utils-custom.js' import MKEmitter from '@/utils/events.js' import getWrapForm from './options' import Utils from '@/utils/utils.js' @@ -38,6 +39,7 @@ let _card = { uuid: card.uuid, type: card.type, + name: card.name || '', format: 'array', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 pageable: true, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� switchable: true, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� @@ -53,7 +55,7 @@ subtype: card.subtype, setting: { interType: 'system' }, wrap: { bordered: 'true', tableType: 'checkbox', show: 'true' }, - style: { marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' }, + style: {}, headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, columns: [], cols: [ @@ -105,7 +107,6 @@ item.cols = item.cols.filter(a => !a.origin) delete item.isNew - this.setState({card: item}, () => { MKEmitter.emit('revert') }) } } @@ -148,6 +149,10 @@ card.errors.push({ level: 0, detail: '涓婚敭宸插け鏁堬紒'}) } else if (!card.setting.supModule) { card.errors.push({ level: 0, detail: '鏈缃笂绾х粍浠讹紒'}) + } + + if (card.errors.length === 0) { + card.$tables = getTables(card) } card.action.forEach(cell => { @@ -307,6 +312,64 @@ this.updateComponent({...card, wrap: res}) } + updatecolumn = (config) => { + config.columns = [] + config.absFields = [] + config.cols.forEach(col => { + if (!col.field) return + if (['text', 'picture', 'textarea'].includes(col.type)) { + config.columns.push({ + datatype: `Nvarchar(${col.fieldlength || 50})`, + field: col.field, + fieldlength: col.fieldlength || 50, + label: col.label, + type: 'text', + uuid: col.uuid + }) + } else if (col.type === 'link') { + config.columns.push({ + datatype: `Nvarchar(${col.fieldlength || 50})`, + field: col.field, + fieldlength: col.fieldlength || 50, + label: col.label, + type: 'text', + uuid: col.uuid + }) + if (col.nameField) { + config.columns.push({ + datatype: `Nvarchar(${col.fieldlength || 50})`, + field: col.nameField, + fieldlength: col.fieldlength || 50, + label: col.label + '(鍚嶇О)', + type: 'text', + uuid: col.uuid + 'name' + }) + } + } else if (col.type === 'number') { + config.columns.push({ + datatype: `Decimal(18,${col.decimal || 0})`, + field: col.field, + decimal: col.decimal || 0, + label: col.label, + type: 'number', + uuid: col.uuid + }) + + if (col.format === 'abs') { + config.absFields.push(col.field) + } + } + }) + + if (config.absFields.length) { + config.absFields = Array.from(new Set(config.absFields)) + } else { + config.absFields = null + } + + this.updateComponent(config) + } + render() { const { card } = this.state let options = ['action', 'search', 'form', 'cols'] @@ -328,7 +391,7 @@ </Popover> <SearchComponent config={card} updatesearch={this.updateComponent}/> <ActionComponent config={card} setSubConfig={this.setSubConfig} updateaction={this.updateComponent}/> - <ColumnComponent config={card} updatecolumn={this.updateComponent}/> + <ColumnComponent config={card} updatecolumn={this.updatecolumn}/> </div> ) } diff --git a/src/menu/components/table/edit-table/columns/index.jsx b/src/menu/components/table/edit-table/columns/index.jsx index e7a7c56..ccb4fbd 100644 --- a/src/menu/components/table/edit-table/columns/index.jsx +++ b/src/menu/components/table/edit-table/columns/index.jsx @@ -267,6 +267,13 @@ } let col = { focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: type, elements: [] } + if (col.type === 'colspan') { + col.subcols = [] + } else if (col.type === 'action') { + col.label = '鎿嶄綔' + } else if (col.type === 'index') { + col.label = '搴忓彿' + } _columns.splice(hoverIndex, 0, col) diff --git a/src/menu/components/table/edit-table/index.jsx b/src/menu/components/table/edit-table/index.jsx index d95042e..089f718 100644 --- a/src/menu/components/table/edit-table/index.jsx +++ b/src/menu/components/table/edit-table/index.jsx @@ -365,6 +365,25 @@ this.updateComponent(_card) } + updatecolumn = (config) => { + config.absFields = [] + config.cols.forEach(col => { + if (col.type === 'number') { + if (col.format === 'abs') { + config.absFields.push(col.field) + } + } + }) + + if (config.absFields.length) { + config.absFields = Array.from(new Set(config.absFields)) + } else { + config.absFields = null + } + + this.updateComponent(config) + } + clickComponent = (e) => { if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { e.stopPropagation() @@ -405,7 +424,7 @@ </Popover> <SearchComponent config={card} updatesearch={this.updateComponent}/> <ActionComponent config={card} setSubConfig={this.setSubConfig} updateaction={this.updateComponent}/> - <ColumnComponent config={card} updatecolumn={this.updateComponent}/> + <ColumnComponent config={card} updatecolumn={this.updatecolumn}/> <div className="component-name"> <div className="center"> <div className="title">{card.name}</div> diff --git a/src/menu/components/table/normal-table/columns/index.jsx b/src/menu/components/table/normal-table/columns/index.jsx index d6097f3..eb3f59e 100644 --- a/src/menu/components/table/normal-table/columns/index.jsx +++ b/src/menu/components/table/normal-table/columns/index.jsx @@ -277,6 +277,13 @@ let _columns = fromJS(this.state.columns).toJS() let col = { focus: true, uuid: Utils.getuuid(), label: 'label', field: '', type: item.subType, elements: [] } + if (col.type === 'colspan') { + col.subcols = [] + } else if (col.type === 'action') { + col.label = '鎿嶄綔' + } else if (col.type === 'index') { + col.label = '搴忓彿' + } _columns.splice(hoverIndex, 0, col) @@ -290,7 +297,7 @@ loopCol = (columns, col) => { return columns.map(column => { if (column.type === 'colspan') { - column.subcols = this.loopCol(column.subcols, col) + column.subcols = this.loopCol(column.subcols || [], col) } if (column.uuid === col.uuid) { return col diff --git a/src/menu/components/table/normal-table/index.jsx b/src/menu/components/table/normal-table/index.jsx index 4b65160..8f8f6a3 100644 --- a/src/menu/components/table/normal-table/index.jsx +++ b/src/menu/components/table/normal-table/index.jsx @@ -131,7 +131,6 @@ if (appType === 'mob') { _card.search = [] } - this.setState({ card: _card }) @@ -419,6 +418,33 @@ this.updateComponent({...card, wrap: res}) } + updatecolumn = (config) => { + config.absFields = [] + config.cols.forEach(col => { + if (col.type === 'number') { + if (col.format === 'abs') { + config.absFields.push(col.field) + } + } else if (col.type === 'colspan' && col.subcols) { + col.subcols.forEach(scol => { + if (scol.type === 'number') { + if (scol.format === 'abs') { + config.absFields.push(scol.field) + } + } + }) + } + }) + + if (config.absFields.length) { + config.absFields = Array.from(new Set(config.absFields)) + } else { + config.absFields = null + } + + this.updateComponent(config) + } + clickComponent = (e) => { if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { e.stopPropagation() diff --git a/src/menu/components/tabs/antv-tabs/options.jsx b/src/menu/components/tabs/antv-tabs/options.jsx index bc2db9d..e369a21 100644 --- a/src/menu/components/tabs/antv-tabs/options.jsx +++ b/src/menu/components/tabs/antv-tabs/options.jsx @@ -102,7 +102,7 @@ let appType = sessionStorage.getItem('appType') let roleList = sessionStorage.getItem('sysRoles') - let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, uuid) || [] + let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, uuid) modules.push({ value: 'preview', label: '涓婁竴椤碉紙url鍙傛暟锛�' diff --git a/src/menu/components/tabs/table-tabs/dragabletabs.jsx b/src/menu/components/tabs/table-tabs/dragabletabs.jsx index fe563ff..d1dc987 100644 --- a/src/menu/components/tabs/table-tabs/dragabletabs.jsx +++ b/src/menu/components/tabs/table-tabs/dragabletabs.jsx @@ -22,6 +22,7 @@ } else if (!dragKey) { monitor.getItem().added = true props.tabsDrop(hoverKey) + return } props.moveTabNode(dragKey, hoverKey) diff --git a/src/menu/components/tabs/table-tabs/index.jsx b/src/menu/components/tabs/table-tabs/index.jsx index d5cfa87..5356b0f 100644 --- a/src/menu/components/tabs/table-tabs/index.jsx +++ b/src/menu/components/tabs/table-tabs/index.jsx @@ -9,7 +9,6 @@ import asyncIconComponent from '@/utils/asyncIconComponent' import MkIcon from '@/components/mk-icon' import DraggableTabs from './dragabletabs' -import { resetStyle } from '@/utils/utils-custom.js' import MenuUtils from '@/utils/utils-custom.js' import Utils from '@/utils/utils.js' import { getTabForm } from './options' @@ -32,7 +31,8 @@ state = { tabs: null, - editab: null + editab: null, + sign: 1 } UNSAFE_componentWillMount () { @@ -42,13 +42,12 @@ let _tabs = { uuid: tabs.uuid, type: tabs.type, - subtype: tabs.subtype, + subtype: 'tabletabs', width: 24, - name: tabs.name, setting: {}, - style: { marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' }, + style: {}, subtabs: [ - { uuid: Utils.getuuid(), label: '瀛愯〃1', icon: '', components: [{uuid: Utils.getuuid(), type: 'table', subtype: 'basetable', isNew: true}] }, + { uuid: Utils.getuuid(), label: '瀛愯〃1', icon: '', components: [{uuid: Utils.getuuid(), name: '瀛愯〃1', type: 'table', subtype: 'basetable', isNew: true}] }, ] } this.setState({ @@ -66,8 +65,6 @@ return !is(fromJS(this.state), fromJS(nextState)) } - componentDidMount () {} - /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ @@ -75,47 +72,6 @@ this.setState = () => { return } - } - - changeStyle = () => { - const { tabs } = this.state - - MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow'], tabs.style, this.getStyle) - } - - getStyle = (style) => { - let _card = {...this.state.tabs, style} - - this.setState({ - tabs: _card - }) - - this.props.updateConfig(_card) - } - - updateComponent = (component) => { - component.width = component.setting.width - component.name = component.setting.name - - this.setState({ - tabs: component - }) - this.props.updateConfig(component) - } - - updateTabComponent = (tab) => { - let tabs = fromJS(this.state.tabs).toJS() - - tabs.subtabs = tabs.subtabs.map(t => { - if (t.uuid === tab.uuid) { - return tab - } else { - return t - } - }) - - this.setState({tabs}) - this.props.updateConfig(tabs) } delTab = (tab) => { @@ -161,22 +117,36 @@ } dropTable = (hoverKey, dragKey) => { - // let tabs = fromJS(this.state.tabs).toJS() - // let subtab = {} - // tabs.subtabs.forEach(item => { - // subtab[item.uuid] = item - // }) + if (dragKey) { + this.props.switchConfig(dragKey, hoverKey, () => { + this.setState({sign: this.state.sign + 1}, () => { + setTimeout(() => { + let node = document.getElementById(dragKey) + node && node.click() + }, 200) + }) + }) + } else { + let tabs = fromJS(this.state.tabs).toJS() + let name = '瀛愯〃' + (tabs.subtabs.length + 1) + let tab = { uuid: Utils.getuuid(), label: name, icon: '', components: [{uuid: Utils.getuuid(), type: 'table', name: name, subtype: 'basetable', isNew: true}]} - // tabs.subtabs = [] + const hoverIndex = tabs.subtabs.findIndex(item => item.uuid === hoverKey) - // order.forEach(item => { - // if (subtab[item]) { - // tabs.subtabs.push(subtab[item]) - // } - // }) + if (hoverIndex === -1) { + tabs.subtabs.push(tab) + } else { + tabs.subtabs.splice(hoverIndex + 1, 0, tab) + } - // this.setState({tabs}) - // this.props.updateConfig(tabs) + this.setState({tabs}, () => { + setTimeout(() => { + let node = document.getElementById(tab.uuid) + node && node.click() + }, 200) + }) + this.props.updateConfig(tabs) + } } insert = (item, tab) => { @@ -218,10 +188,8 @@ editab.label = res.label editab.icon = res.icon editab.hide = res.hide || 'false' - editab.backgroundColor = res.backgroundColor - editab.controlVal = res.controlVal || '' - editab.selectVal = res.selectVal || '' editab.blacklist = res.blacklist + editab.components[0].name = res.label if (editab.uuid) { tabs.subtabs = tabs.subtabs.map(t => { @@ -244,18 +212,22 @@ this.props.updateConfig(tabs) } - updateConfig = () => { + updateConfig = (tb, i) => { + let tabs = fromJS(this.state.tabs).toJS() + tabs.subtabs[i].components = [tb] + this.setState({ tabs }) + + this.props.updateConfig(tabs) } render() { const { tabs } = this.state - let _style = resetStyle(tabs.style) return ( - <div className={'menu-tabs-edit-box ' + (tabs.setting.display || '')} style={_style} id={tabs.uuid}> + <div className="menu-tabs-edit-box" style={tabs.style} id={tabs.uuid}> <DraggableTabs tabsMove={this.moveSwitch} tabsDrop={this.dropTable}> - {tabs.subtabs.map(tab => ( + {tabs.subtabs.map((tab, i) => ( <TabPane tab={ <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> @@ -265,10 +237,10 @@ <CloseOutlined className="close" onClick={() => this.delTab(tab)} /> </div> } trigger="hover"> - <span style={{textDecoration: tab.hide === 'true' ? 'line-through' : 'none'}}>{tab.icon ? <MkIcon type={tab.icon} /> : null}{tab.label}</span> + <span id={tab.uuid} style={{textDecoration: tab.hide === 'true' ? 'line-through' : 'none'}}>{tab.icon ? <MkIcon type={tab.icon} /> : null}{tab.label}</span> </Popover> } key={tab.uuid}> - <BaseTable card={tab.components[0]} updateConfig={this.updateConfig} /> + <BaseTable card={tab.components[0]} updateConfig={(tb) => this.updateConfig(tb, i)} /> </TabPane> ))} </DraggableTabs> diff --git a/src/menu/datasource/index.jsx b/src/menu/datasource/index.jsx index e0bb557..569dbba 100644 --- a/src/menu/datasource/index.jsx +++ b/src/menu/datasource/index.jsx @@ -187,6 +187,16 @@ } }) }) + } else { + res.scripts.forEach(item => { + if (item.status === 'false') return + + if (/exec\s/ig.test(item.sql)) { + maxScript = 1000 + } else if (item.sql.length > maxScript) { + maxScript = item.sql.length + } + }) } res.setting.maxScript = maxScript diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index 66a6a93..ec62f40 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -739,6 +739,7 @@ } pasteSubmit = () => { + const { config } = this.props const { setting } = this.state this.pasteFormRef.handleConfirm().then(res => { @@ -762,21 +763,35 @@ res.data.setting.supModule = setting.supModule } - this.setState({ - scripts: res.data.scripts.map(col => { - col.uuid = Utils.getuuid() - return col - }), - columns: res.data.columns.map(col => { - col.uuid = Utils.getuuid() - return col - }), - setting: res.data.setting, - reload: true, - pvisible: false - }, () => { - this.setState({reload: false}) - }) + if (config.subtype !== 'basetable') { + this.setState({ + scripts: res.data.scripts.map(col => { + col.uuid = Utils.getuuid() + return col + }), + columns: res.data.columns.map(col => { + col.uuid = Utils.getuuid() + return col + }), + setting: res.data.setting, + reload: true, + pvisible: false + }, () => { + this.setState({reload: false}) + }) + } else { + this.setState({ + scripts: res.data.scripts.map(col => { + col.uuid = Utils.getuuid() + return col + }), + setting: res.data.setting, + reload: true, + pvisible: false + }, () => { + this.setState({reload: false}) + }) + } }) } @@ -834,7 +849,7 @@ wrappedComponentRef={(inst) => this.settingForm = inst} /> : null} </TabPane> - <TabPane tab={ + {config.subtype !== 'basetable' ? <TabPane tab={ <span> 瀛楁闆� {columns.length ? <span className="count-tip">{columns.length}</span> : null} @@ -848,7 +863,7 @@ updatefield={this.updatefields} /> <EditTable actions={['edit', 'move', 'copy', 'del', 'clear']} type="datasourcefield" wrappedComponentRef={(inst) => this.datasource = inst} data={columns} columns={colColumns} onChange={(columns) => this.setState({columns})}/> - </TabPane> + </TabPane> : null} <TabPane tab={ <span> 鑷畾涔夎剼鏈� diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index 69041eb..3929542 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -16,7 +16,6 @@ static propTpyes = { config: PropTypes.object, // 缁勪欢閰嶇疆 setting: PropTypes.object, // 鏁版嵁婧愰厤缃� - modules: PropTypes.array, // 鍙粦瀹氱殑涓婄骇缁勪欢 columns: PropTypes.array, // 鍒楄缃� scripts: PropTypes.array, // 鑷畾涔夎剼鏈� } @@ -26,13 +25,19 @@ modules: [], innerRules: [], innertip: '', - appType: sessionStorage.getItem('appType') + appType: sessionStorage.getItem('appType'), + ismain: false } UNSAFE_componentWillMount () { const { config, setting } = this.props - let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, config.uuid) || [] + let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, config.uuid) + let ismain = false + + if (window.GLOB.customMenu.Template === 'BaseTable') { + ismain = config.name === '涓昏〃' + } modules.unshift({ value: 'empty', @@ -69,7 +74,7 @@ _setting.supModule = setting.supModule || [] _setting.execute = setting.execute || 'true' - this.setState({modules, innerRules, innertip, setting: _setting}) + this.setState({modules, innerRules, innertip, setting: _setting, ismain}) } handleConfirm = () => { @@ -416,7 +421,7 @@ </Form.Item> </Col> : null} {/* 1銆佷笉鍒嗛〉涓斾笉瀛樺湪涓婄骇妯″潡 */} - {!['navbar', 'interface'].includes(config.type) && !['editable'].includes(config.subtype) && (!config.pageable || (config.pageable && setting.laypage === 'false')) && (setting.supModule.length === 0 || setting.supModule[0] === 'empty') ? <Col span={8}> + {!['navbar', 'interface'].includes(config.type) && !['editable', 'basetable'].includes(config.subtype) && (!config.pageable || (config.pageable && setting.laypage === 'false')) && (setting.supModule.length === 0 || setting.supModule[0] === 'empty') ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細浠呭湪浣跨敤绯荤粺鍑芥暟锛屼笖鍒濆鍖栧姞杞芥暟鎹椂鏈夋晥锛屽垎椤佃姹傛椂鏃犳晥銆�'}> <QuestionCircleOutlined className="mk-form-tip" /> @@ -433,7 +438,7 @@ )} </Form.Item> </Col> : null} - {!['navbar', 'balcony', 'menubar', 'interface'].includes(config.type) ? <Col span={8}> + {!['navbar', 'balcony', 'menubar', 'interface'].includes(config.type) && !['basetable'].includes(config.subtype) ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'浼樺厛浣跨敤鍚岀骇鐨勬悳绱㈡潯浠剁粍浠讹紝鍚岀骇鎼滅储涓嶅瓨鍦ㄦ椂锛屼緷娆″悜涓婇�夊彇锛屼笌褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵竴鍚岀敤浣滄暟鎹繃婊わ紙褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵紭鍏堬級銆�'}> <QuestionCircleOutlined className="mk-form-tip" /> @@ -450,7 +455,24 @@ )} </Form.Item> </Col> : null} - {!['navbar', 'balcony', 'menubar', 'interface'].includes(config.type) && setting.useMSearch === 'true' && appType !== 'mob' ? <Col span={8}> + {config.subtype === 'basetable' && !this.state.ismain ? <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title="鏄惁浣跨敤涓昏〃鐨勬悳绱㈡潯浠�"> + <QuestionCircleOutlined className="mk-form-tip" /> + 涓昏〃鎼滅储 + </Tooltip> + }> + {getFieldDecorator('useMSearch', { + initialValue: setting.useMSearch || 'false' + })( + <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'useMSearch')}}> + <Radio value="true">浣跨敤</Radio> + <Radio value="false">涓嶄娇鐢�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} + {!['navbar', 'balcony', 'menubar', 'interface'].includes(config.type) && !['basetable'].includes(config.subtype) && setting.useMSearch === 'true' && appType !== 'mob' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'澶栧眰鎼滅储鏉′欢鏀瑰彉鏃讹紝鏄惁鍒锋柊褰撳墠缁勪欢鏁版嵁銆�'}> <QuestionCircleOutlined className="mk-form-tip" /> diff --git a/src/menu/tablenodes/index.jsx b/src/menu/tablenodes/index.jsx index 8f31c88..d9c170c 100644 --- a/src/menu/tablenodes/index.jsx +++ b/src/menu/tablenodes/index.jsx @@ -55,7 +55,39 @@ }) } - traversal(config.components) + if (config.Template === 'BaseTable') { + config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (tab.components[0].$tables) { + ptbs.push(...tab.components[0].$tables) + tab.components[0].$tables.forEach(tb => { + tbs.push({ + label: tab.label, + table: tb, + color: '#5AD8A6', + id: Utils.getuuid(), + direction: 'left' + }) + }) + } + }) + } else if (item.$tables) { + ptbs.push(...item.$tables) + item.$tables.forEach(tb => { + tbs.push({ + label: '涓昏〃', + table: tb, + color: '#5AD8A6', + id: Utils.getuuid(), + direction: 'left' + }) + }) + } + }) + } else { + traversal(config.components) + } return {tbs, ptbs} } @@ -181,6 +213,12 @@ delete _param.type _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param))) window.open(`#/menudesign/${_param}`) + } else if (menu.param.MenuType === 'BaseTable') { + let _param = {...menu.param} + delete _param.type + delete _param.MenuType + _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param))) + window.open(`#/tabledesign/${_param}`) } } else if (menu.param.type === 'app') { if (menu.param.typename !== 'pc') { diff --git a/src/menu/tableshell/card.jsx b/src/menu/tableshell/card.jsx index 55926ea..0fb151b 100644 --- a/src/menu/tableshell/card.jsx +++ b/src/menu/tableshell/card.jsx @@ -7,7 +7,7 @@ const AntvTabs = asyncComponent(() => import('@/menu/components/tabs/table-tabs')) const BaseTable = asyncComponent(() => import('@/menu/components/table/base-table')) -const Card = ({ id, card, delCard, updateConfig }) => { +const Card = ({ id, card, delCard, updateConfig, switchConfig }) => { const [, drop] = useDrop({ accept: 'menu', canDrop: () => true, @@ -20,7 +20,7 @@ if (card.type === 'table') { return (<BaseTable card={card} updateConfig={updateConfig}/>) } else if (card.type === 'tabs') { - return (<AntvTabs tabs={card} updateConfig={updateConfig} deletecomponent={delCard}/>) + return (<AntvTabs tabs={card} updateConfig={updateConfig} switchConfig={switchConfig} deletecomponent={delCard}/>) } } return ( diff --git a/src/menu/tableshell/index.jsx b/src/menu/tableshell/index.jsx index 63fefeb..2e125ea 100644 --- a/src/menu/tableshell/index.jsx +++ b/src/menu/tableshell/index.jsx @@ -1,5 +1,6 @@ import React, { useState } from 'react' import { useDrop } from 'react-dnd' +import { is, fromJS } from 'immutable' import update from 'immutability-helper' import { Modal } from 'antd' @@ -12,7 +13,7 @@ const Container = ({menu, handleList }) => { const [cards, setCards] = useState(menu.components) - if (menu.components.length > cards.length) { + if (!is(fromJS(cards), fromJS(menu.components))) { setCards(menu.components) } @@ -25,30 +26,65 @@ } const updateConfig = (element) => { - const _cards = cards.map(item => item.uuid === element.uuid ? element : item) + let _cards = cards.map(item => item.uuid === element.uuid ? element : item) + + if (element.type === 'tabs' && element.subtabs.length === 0) { + _cards = cards.filter(item => item.uuid !== element.uuid) + } + handleList({...menu, components: _cards}) - setCards(_cards) + } + + const switchConfig = (dragKey, hoverKey, callback) => { + let _tab = null + + let hoverTabsIndex = 0 + let hoverIndex = 0 + let _cards = cards.map((item, pindex) => { + if (item.type === 'tabs') { + item.subtabs = item.subtabs.filter((tab, index) => { + if (tab.uuid === dragKey) { + _tab = tab + return false + } + if (tab.uuid === hoverKey) { + hoverTabsIndex = pindex + hoverIndex = index + } + return true + }) + } + return item + }) + + if (hoverTabsIndex && _tab) { + _cards[hoverTabsIndex].subtabs.splice(hoverIndex + 1, 0, _tab) + } else { + return + } + + _cards = _cards.filter(item => { + if (item.type !== 'tabs') return true + if (item.subtabs.length === 0) return false + + return true + }) + + handleList({...menu, components: _cards}) + + setTimeout(() => { + callback() + }, 100) } const deleteCard = (id) => { const { card } = findCard(id) - let hasComponent = false - if (card.type === 'tabs') { - card.subtabs.forEach(tab => { - if (tab.components.length > 0) { - hasComponent = true - } - }) - } - confirm({ - title: `纭畾鍒犻櫎銆�${card.name}銆嬪悧锛焋, - content: hasComponent ? '褰撳墠缁勪欢涓惈鏈夊瓙缁勪欢锛�' : '', + title: `纭畾鍒犻櫎瀛愯〃缁勫悧锛焋, onOk() { const _cards = cards.filter(item => item.uuid !== card.uuid) handleList({...menu, components: _cards}) - setCards(_cards) }, onCancel() {} }) @@ -57,7 +93,7 @@ const [, drop] = useDrop({ accept: 'menu', drop(item) { - if (item.added) { + if (item.added || item.index) { delete item.added // 鍒犻櫎缁勪欢娣诲姞鏍囪 return } @@ -65,7 +101,6 @@ let newcard = { uuid: Utils.getuuid(), type: 'tabs', - subtype: 'tabs', isNew: true } @@ -81,8 +116,8 @@ const { index: overIndex } = findCard(`${targetId}`) const _cards = update(cards, { $splice: [[overIndex + 1, 0, newcard]] }) + // setCards(_cards) handleList({...menu, components: _cards}) - setCards(_cards) } }) @@ -97,6 +132,7 @@ delCard={deleteCard} findCard={findCard} updateConfig={updateConfig} + switchConfig={switchConfig} /> ))} </div> diff --git a/src/mob/colorsketch/index.jsx b/src/mob/colorsketch/index.jsx index d0190fc..2cef76f 100644 --- a/src/mob/colorsketch/index.jsx +++ b/src/mob/colorsketch/index.jsx @@ -7,8 +7,8 @@ import './index.scss' const presetColors = [ - '#f5222d', '#fa541c', '#fa8c16', '#faad14', '#fadb14', '#a0d911', '#52c41a', '#13c2c2', '#1890ff', '#2f54eb', '#722ed1', - '#eb2f96', '#595959', '#ffa39e', '#ffbb96', '#ffd591', '#ffe58f', '#fffb8f', '#eaff8f', '#b7eb8f', '#87e8de', '#91d5ff', + '#1890ff', '#f5222d', '#fa541c', '#fa8c16', '#faad14', '#fadb14', '#a0d911', '#52c41a', '#13c2c2', '#2f54eb', '#722ed1', + '#eb2f96', '#aeb303', '#c32539', '#ffbb96', '#ffd591', '#ffe58f', '#fffb8f', '#eaff8f', '#b7eb8f', '#87e8de', '#91d5ff', '#adc6ff', '#d3adf7', '#EBE9E9', '#d9d9d9', '#434343', '#000000', '#ffffff', 'transparent' ] diff --git a/src/mob/components/tabs/antv-tabs/options.jsx b/src/mob/components/tabs/antv-tabs/options.jsx index 24271c3..da3c426 100644 --- a/src/mob/components/tabs/antv-tabs/options.jsx +++ b/src/mob/components/tabs/antv-tabs/options.jsx @@ -99,7 +99,7 @@ * @description tabs琛ㄥ崟閰嶇疆淇℃伅 */ export function getTabsSetForm(setting, uuid) { - let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, uuid) || [] + let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, uuid) modules.push({ value: 'preview', label: '涓婁竴椤碉紙url鍙傛暟锛�' diff --git a/src/tabviews/basetable/index.jsx b/src/tabviews/basetable/index.jsx index a20277d..c6b9ade 100644 --- a/src/tabviews/basetable/index.jsx +++ b/src/tabviews/basetable/index.jsx @@ -1,38 +1,28 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { notification, Spin, Tabs, Switch, Row, Col } from 'antd' +import { notification, Spin, Row, Col } from 'antd' import Api from '@/api' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' -import options from '@/store/options.js' -import UtilsDM from '@/utils/utils-datamanage.js' -import { updateCommonTable } from '@/utils/utils-update.js' import asyncComponent from '@/utils/asyncComponent' -import asyncSpinComponent from '@/utils/asyncSpinComponent' -import MkIcon from '@/components/mk-icon' import MKEmitter from '@/utils/events.js' import NotFount from '@/components/404' import './index.scss' // 閫氱敤缁勪欢 -const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) -const MainAction = asyncSpinComponent(() => import('@/tabviews/zshare/actionList')) -const MainTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) +const AntvTabs = asyncComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs')) +const MkBaseTable = asyncComponent(() => import('@/tabviews/custom/components/table/base-table')) const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent')) -const SubTable = asyncSpinComponent(() => import('@/tabviews/subtable')) -const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent')) -const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent')) const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage')) -const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic')) +const DebugTable = asyncComponent(() => import('@/tabviews/debugtable')) -const { TabPane } = Tabs - -class NormalTable extends Component { +class BasePage extends Component { static propTpyes = { - param: PropTypes.any, // 鍏朵粬椤甸潰浼犻�掔殑鎼滅储鏉′欢绛夊弬鏁� + param: PropTypes.any, // 鍏朵粬椤甸潰浼犻�掔殑鍙傛暟 + Tab: PropTypes.string, // 寮圭獥鏍囩 MenuID: PropTypes.string, // 鑿滃崟Id MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 MenuName: PropTypes.string // 鑿滃崟鍚嶇О @@ -41,41 +31,24 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, ContainerId: Utils.getuuid(), // 鑿滃崟澶栧眰html Id - BID: null, // 椤甸潰璺宠浆鏃舵惡甯D + BID: '', // 椤甸潰璺宠浆鏃舵惡甯D loadingview: true, // 椤甸潰鍔犺浇涓� viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 - config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 - shortcuts: null, // 蹇嵎閿� - searchlist: null, // 鎼滅储鏉′欢 - actions: null, // 鎸夐挳闆� - columns: null, // 鏄剧ず鍒� - arr_field: '', // 鏌ヨ瀛楁闆� - setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 - data: [], // 鍒楄〃鏁版嵁闆� - selectedData: [], // 宸查�夎〃鏍兼暟鎹� - total: 0, // 鎬绘暟 + config: null, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑 + mainSearch: null, // 涓绘悳绱� + userConfig: null, // 鐢ㄦ埛鑷畾涔夎缃� + data: null, // 鍒楄〃鏁版嵁闆� loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� - pageIndex: 1, // 椤电爜 - pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 - orderBy: '', // 鎺掑簭 - search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� - BIDs: {}, // 涓婄骇琛╥d - pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 - chartId: '', // 灞曞紑鍥捐〃ID - statFields: [], // 鍚堣瀛楁 - statFValue: [], // 鍚堣鍊� - absFields: [], // 缁濆鍊煎瓧娈� - loadCustomApi: true, // 鍔犺浇澶栭儴璧勬簮 - hasReqFields: false, - autoMatic: null + visible: false, // 鏍囩椤垫帶鍒� + shortcuts: null // 蹇嵎閿� } /** * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { param, MenuName, MenuID } = this.props + const { MenuID } = this.props let _param = { func: 'sPC_Get_LongParam', @@ -88,42 +61,18 @@ let shortcuts = [] try { // 閰嶇疆淇℃伅瑙f瀽 - config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - config.MenuID = MenuID - config.MenuName = MenuName - config.setting.MenuName = MenuName - config.setting.$name = MenuName + config = window.decodeURIComponent(window.atob(result.LongParam)) + config = JSON.parse(config) } catch (e) { console.warn('Parse Failure') config = '' } - + // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆 if (result.LongParamUser && !window.GLOB.mkHS) { try { // 閰嶇疆淇℃伅瑙f瀽 let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) - if (userConfig && !userConfig.version) { - Object.keys(userConfig).forEach(key => { - let component = userConfig[key] - - if (!component.action) return - - Object.keys(component.action).forEach(uuid => { - let item = {uuid: uuid, parentId: key, shortcut: component.action[uuid].shortcut} - let printer = component.action[uuid].printer - - if (item.shortcut) { - item.$shortcut = item.shortcut.join('+') - shortcuts.push(item) - } - if (printer) { - item.printer = printer.defaultPrinter || '' - item.printerList = printer.printerList || '' - window.GLOB.UserCacheMap.set(key + uuid, item) - } - }) - }) - } else if (userConfig) { + if (userConfig) { shortcuts = userConfig.action userConfig.printers.forEach(item => { window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item) @@ -137,8 +86,8 @@ // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� if (!config) { this.setState({ - loadingview: false, - viewlost: true + viewlost: true, + loadingview: false }) return } @@ -146,296 +95,87 @@ // 椤甸潰鏈惎鐢ㄦ椂锛屾樉绀烘湭鍚敤椤甸潰 if (!config.enabled) { this.setState({ - loadingview: false, viewlost: true, + loadingview: false, lostmsg: this.state.dict['main.view.unenabled'] }) return } - // 鐗堟湰鍏煎 - config = updateCommonTable(config) - // 鏉冮檺杩囨护 - if (!window.GLOB.mkHS) { - config.action = config.action.filter(item => item.hidden !== 'true' && window.GLOB.mkActions[item.uuid]) - config.tabgroups.forEach(group => { - group.sublist = group.sublist.filter(tab => { - if (tab.supMenu === 'mainTable') { - tab.supMenu = MenuID - } - return window.GLOB.mkActions[tab.linkTab] - }) - }) - } else { - config.action = config.action.filter(item => item.hidden !== 'true') - config.tabgroups.forEach(group => { - group.sublist = group.sublist.map(tab => { - if (tab.supMenu === 'mainTable') { - tab.supMenu = MenuID - } - return tab - }) - }) - } - // 鍘婚櫎绌鸿鏍囩 - config.tabgroups = config.tabgroups.filter(group => group.sublist.length > 0) - let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID + let skip = window.GLOB.mkHS + let param = this.props.param || {} // url鍙傛暟 - let chartId = '' + window.GLOB.CacheData.set(MenuID, param) - if (config.charts) { - // 瑙嗗浘鏉冮檺 - config.charts = config.charts.filter(item => { - if (item.Hide === 'true') return false - if (!item.blacklist || item.blacklist.length === 0) return true - return item.blacklist.filter(v => roleId.indexOf(v) > -1).length === 0 - }) - - if (config.charts.length <= 1) { - config.expand = true - } - chartId = config.charts[0] ? config.charts[0].uuid : '' + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' } - config.search = Utils.initSearchVal(config.search) - - // 瀛楁閫忚鍙婂繀濉爣蹇� - let hasReqFields = false - config.search = config.search.map(item => { - if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) { - item.initval = param.$searchval - } - - if (item.required) { - hasReqFields = true - } - - return item - }) - - config.columns = config.columns.map(col => { - if (!col.field || !col.blacklist || col.blacklist.length === 0) return col - if (col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { - col.Hide = 'true' - } - - return col - }) - - // 鏍囪涓婚〉闈紝鐢ㄤ簬鎸夐挳鍥哄畾鍙婅〃鍗曟寕杞借缃� - config.setting.tabType = 'main' - - // 鏁版嵁婧愪俊鎭澶勭悊 - config.setting.laypage = config.setting.laypage !== 'false' // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡 - config.setting.execute = config.setting.default !== 'false' // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡 - config.setting.customScript = '' // 鑷畾涔夎剼鏈� - config.setting.dataresource = config.setting.dataresource || '' - - if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) { - if (config.setting.scripts && config.setting.scripts.length > 0) { - let _customScript = '' - config.setting.scripts.forEach(item => { - if (item.status === 'false') return - _customScript += ` - ${item.sql} - ` - }) - config.setting.customScript = _customScript - } - - if (!config.setting.execute) { // 榛樿sql 涓嶆墽琛屾椂 缃┖ - config.setting.dataresource = '' - } else if (/\s/.test(config.setting.dataresource)) { - config.setting.dataresource = '(' + config.setting.dataresource + ') tb' - } - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') - config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') - config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*') - config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/') - } else { - config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') - config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') - } - - let userName = sessionStorage.getItem('User_Name') || '' - let fullName = sessionStorage.getItem('Full_Name') || '' - - if (sessionStorage.getItem('isEditState') === 'true') { - userName = sessionStorage.getItem('CloudUserName') || '' - fullName = sessionStorage.getItem('CloudFullName') || '' - } - - let regs = [ - { reg: /@userName@/ig, value: `'${userName}'` }, - { reg: /@fullName@/ig, value: `'${fullName}'` } - ] - - regs.forEach(cell => { - config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value) - config.setting.customScript = config.setting.customScript.replace(cell.reg, cell.value) - }) - - if (config.urlFields) { - let _param = param || {} - config.urlFields.forEach(field => { - let reg = new RegExp('@' + field + '@', 'ig') - let val = `'${_param[field] || ''}'` - config.setting.dataresource = config.setting.dataresource.replace(reg, val) - config.setting.customScript = config.setting.customScript.replace(reg, val) - }) - } - } - - let _arrField = [] // 瀛楁闆� - let _columns = [] // 鏄剧ず鍒� - let _hideCol = [] // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆� - let colMap = new Map() // 鐢ㄤ簬瀛楁杩囨护 - let statFields = [] // 鍚堣瀛楁淇℃伅 - let absFields = [] // 缁濆鍊煎瓧娈� - - let _actions = [] // 宸ュ叿鏍忔寜閽� - let _operations = [] // 鎿嶄綔鍒楁寜閽紙瀛樺湪鏃讹級 - - config.action.forEach(item => { - item.logLabel = MenuName + '-' + item.label // 鐢ㄤ簬sPC_TableData_InUpDe璁板綍鎿嶄綔鎸夐挳 - item.$menuId = this.props.MenuID - - if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify) { // 鎵撳嵃鏈鸿缃� - let _item = window.GLOB.UserCacheMap.get(this.props.MenuID + item.uuid) - - if (_item) { - item.printer = _item.printer || '' - item.verify.defaultPrinter = _item.printer || '' - if (item.verify.printerTypeList && _item.printerList) { - item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { - cell.printer = _item.printerList[cell.Value] || '' - - return cell - }) - } - } - } - - if (item.position === 'toolbar') { - item.$toolbtn = true - _actions.push(item) - } else if (item.position === 'grid') { - _operations.push(item) - } - }) - - // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid - config.columns.forEach(col => { - if (col.field) { - _arrField.push(col.field) - - if (col.linkmenu && col.linkmenu.length > 0) { - let menu_id = col.linkmenu.slice(-1)[0] - col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' - } else { - col.linkThdMenu = '' - } - - col.nameField && _arrField.push(col.nameField) // 閾炬帴鍚嶅瓧娈� - if (col.Hide !== 'true' && col.type === 'number' && col.sum === 'true') { - statFields.push(col) - } - if (col.format === 'abs') { - absFields.push(col.field) - } - } - if (col.type === 'colspan' && col.sublist) { // 绛涢�夐殣钘忓垪 - _hideCol = _hideCol.concat(col.sublist) - } - colMap.set(col.uuid, col) - }) - - // 鐢熸垚鏄剧ず鍒楋紝澶勭悊鍚堝苟鍒椾腑鐨勫瓧娈� - config.columns.forEach((col, index) => { - if (_hideCol.includes(col.uuid)) return - - col.sort = index - - if (col.type === 'colspan') { - if (col.unfold !== 'true') { // 涓嶅睍寮�涓烘棫鐗堝悎骞跺垪 - col.type = 'old_colspan' - } - - let _col = fromJS(col).toJS() - let subcols = [] - _col.sublist && _col.sublist.forEach(sub => { - if (colMap.has(sub)) { - subcols.push(colMap.get(sub)) - } - }) - if (subcols.length > 0) { - _col.subcols = subcols - _columns.push(_col) - } - } else { - _columns.push(col) - } - }) + let regs = [ + { reg: /@userName@/ig, value: `'${userName}'` }, + { reg: /@fullName@/ig, value: `'${fullName}'` } + ] - if (config.gridBtn && config.gridBtn.display && _operations.length > 0) { - config.gridBtn.operations = _operations - _columns.push(config.gridBtn) + if (window.GLOB.externalDatabase !== null) { + regs.push({ + reg: /@db@/ig, + value: window.GLOB.externalDatabase + }) } - - if (config.setting.selected !== 'init' && config.setting.selected !== 'always') { - config.setting.selected = 'false' - } else if (config.setting.selected === 'init' && config.setting.onload === 'false') { - config.setting.selected = 'false' - } else { - config.setting.orisel = true - } - - let autoMatic = null - if (config.autoMatic && config.autoMatic.enable === 'true') { - _actions.forEach(item => { - if (item.uuid === config.autoMatic.action && (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print'))) { - autoMatic = config.autoMatic - autoMatic.OpenType = item.execMode || item.OpenType - config.setting.selected = 'false' - item.autoMatic = true - } + if (config.urlFields) { + config.urlFields.forEach(field => { + let val = `'${param[field] || ''}'` + regs.push({ + reg: new RegExp('@' + field + '@', 'ig'), + value: val + }) }) } - if (config.setting.controlField) { - if (config.setting.controlVal) { - config.setting.controlVal = config.setting.controlVal.split(',') - } else { - config.setting.controlVal = [''] - } - } + config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, param, MenuID) + + // 鑾峰彇涓绘悳绱㈡潯浠� + let mainSearch = [] + config.components.forEach(component => { + if (component.type === 'tabs') return + + component.search = component.search.map(item => { + item.oriInitval = item.initval + if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { + item.initval = param.$searchval + } + + return item + }) + + mainSearch = Utils.initMainSearch(component.search) + }) + + let BID = param.$BID || '' + + config.components = this.formatSetting(config.components, mainSearch, regs) this.setState({ - pageSize: config.setting.pageSize || 10, - loadingview: false, - absFields, - autoMatic, - chartId, + BID: BID, + shortcuts: shortcuts.length > 0 ? shortcuts : null, config, - statFields, - shortcuts, - setting: config.setting, - searchlist: config.search, - actions: _actions, - columns: _columns, - arr_field: _arrField.join(','), - BID: param && param.$BID ? param.$BID : '', - search: Utils.initMainSearch(config.search), - hasReqFields + mainSearch }, () => { - if (config.setting.onload !== 'false') { // 鍒濆鍖栧彲鍔犺浇 - this.loadData() + setTimeout(() => { // 寤舵椂鍔犺浇鐘舵�� + this.setState({ + loadingview: false + }) + }, 1000) + + if (!this.props.Tab) { + this.setShortcut() } - this.setShortcut() }) } else { this.setState({ @@ -453,11 +193,6 @@ setShortcut = () => { const { shortcuts } = this.state - if (!shortcuts || shortcuts.length === 0) { - document.onkeydown = () => {} - return - } - document.onkeydown = (event) => { let e = event || window.event let keyCode = e.keyCode || e.which || e.charCode @@ -472,18 +207,22 @@ } if (!preKey || !keyCode) return - + let _shortcut = `${preKey}+${keyCode}` + + if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') { + window.debugger = false + window.GLOB.breakpoint = false + sessionStorage.removeItem('breakpoint') + + MKEmitter.emit('debugChange') + } + + if (!shortcuts) return shortcuts.some(item => { if (item.$shortcut === _shortcut) { MKEmitter.emit('triggerBtnId', item.uuid) - - let element = item.parentId && item.parentId !== this.props.MenuID ? document.getElementById(item.parentId) : '' // 鏍囩鍒囨崲 - if (element && element.click) { - element.click() - } - return true } return false @@ -491,593 +230,259 @@ } } - loadData = (id) => { - const { MenuID } = this.props - const { setting, search, loadCustomApi, hasReqFields, ContainerId } = this.state + filterComponent = (components, roleId, permAction, skip, urlparam, pageId) => { + return components.filter(item => { + item.$pageId = pageId - this.setState({ - selectedData: [] - }) - MKEmitter.emit('changeTableLine', ContainerId, MenuID, '', '') + item.$menuname = (this.props.MenuName || '') + '-' + (item.name || '涓昏〃') - if (hasReqFields) { - let requireFields = search.filter(item => item.required && item.value === '') - - if (requireFields.length > 0) { - this.setState({ - loading: false + if (item.type === 'tabs') { + item.subtabs = item.subtabs.filter(tab => { + if ( + tab.blacklist && tab.blacklist.length > 0 && + tab.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0 + ) { + return false + } else if (tab.hide === 'true') { + return false + } + return true }) - return - } - } - if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { - notification.warning({ - top: 92, - message: '鏈缃寮忕郴缁熷湴鍧�!', - duration: 3 - }) - return - } + if (item.subtabs.length === 0) return false - if (setting.interType === 'custom' && loadCustomApi) { - if (setting.execTime === 'once') { - this.setState({loadCustomApi: false}) + item.subtabs = item.subtabs.map(tab => { + tab.components[0].name = tab.label + tab.components = this.filterComponent(tab.components, roleId, permAction, skip, urlparam, pageId) + return tab + }) + + return true } - this.loadOutResource() - if (setting.execType === 'async') { - this.loadmaindata(id) + // 鎼滅储鏉′欢鍒濆鍖� + if (item.search && item.search.length > 0) { + item.search = Utils.initSearchVal(item.search) } - } else { - this.loadmaindata(id) - } - } - loadOutResource = () => { - const { setting, search, BID } = this.state - - let param = UtilsDM.getPrevQueryParams(setting, search, BID) - - if (setting.execType === 'sync') { - this.setState({ - loading: true - }) - } - - Api.genericInterface(param).then(res => { - if (res.status) { - if (res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) { - this.loadmaindata() + if (item.setting.supModule) { + let pid = item.setting.supModule.pop() + if (pid && pid !== 'empty') { + item.setting.supModule = pid } else { - this.customOuterRequest(res) - } - } else { - this.setState({ - loading: false - }) - notification.error({ - top: 92, - message: res.message, - duration: 10 - }) - } - }, () => { - this.setState({ - loading: false - }) - }) - } - - customOuterRequest = (result) => { - const { setting } = this.state - let url = '' - - if (window.GLOB.systemType === 'production') { - url = setting.proInterface - } else { - url = setting.interface - } - - let mkey = result.mk_api_key || '' - - delete result.mk_ex_invoke // 鏄惁缁х画鎵ц - delete result.status - delete result.message - delete result.ErrCode - delete result.ErrMesg - delete result.mk_api_key // 褰撳墠璇锋眰鐨刱ey鍊硷紝鐢ㄤ簬鍥炶皟 - - let param = {} - - Object.keys(result).forEach(key => { - key = key.replace(/^mk_/ig, '') - param[key] = result[key] - }) - - Api.directRequest(url, setting.method, param, setting.cross).then(res => { - if (typeof(res) !== 'object') { - let error = '鏈煡鐨勮繑鍥炵粨鏋滐紒' - - if (typeof(res) === 'string') { - error = res.replace(/'/ig, '"') - } - - let _result = { - mk_api_key: mkey, - $ErrCode: 'E', - $ErrMesg: error - } - - this.customCallbackRequest(_result) - } else { - if (Array.isArray(res)) { - res = { data: res } - } - res.mk_api_key = mkey - this.customCallbackRequest(res) - } - }, (e) => { - let _result = { - mk_api_key: mkey, - $ErrCode: 'E', - $ErrMesg: e && e.statusText ? e.statusText : '' - } - - this.customCallbackRequest(_result) - }) - } - - customCallbackRequest = (result) => { - const { setting, BID } = this.state - let errSql = '' - if (result.$ErrCode === 'E') { - errSql = ` - set @ErrorCode='E' - set @retmsg='${result.$ErrMesg}' - ` - delete result.$ErrCode - delete result.$ErrMesg - } - - let lines = UtilsDM.getCallBackSql(setting, result) - let param = {} - - if (setting.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈� - let sql = lines.map(item => (` - ${item.insert} - ${item.selects.join(` union all - `)} - `)) - sql = sql.join('') - - param = UtilsDM.getCallBackQueryParams(setting, sql, errSql, BID) - } else { - param.func = 's_ex_result_back' - param.s_ex_result = lines.map((item, index) => ({ - MenuID: this.state.config.MenuID, - MenuName: this.state.config.MenuName, - TableName: item.table, - LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), - Sort: index + 1 - })) - - if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { - let sql = lines.map(item => (` - ${item.insert} - ${item.selects.join(` union all - `)} - `)) - sql = sql.join('') - console.info(sql.replace(/\n\s{10}/ig, '\n')) - } - } - - Api.genericInterface(param).then(res => { - if (res.status) { - this.loadmaindata() - } else { - this.setState({ - loading: false - }) - notification.error({ - top: 92, - message: res.message, - duration: 10 - }) - } - }, () => { - this.setState({ - loading: false - }) - }) - } - - /** - * @description 涓昏〃鏁版嵁鍔犺浇 - */ - async loadmaindata (id) { - const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields, autoMatic } = this.state - - this.setState({ - loading: true - }) - - let _orderBy = orderBy || setting.order - let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID) - - let result = await Api.genericInterface(param) - - this.getStatFieldsValue() - - if (result.status) { - let start = 1 - if (setting.laypage) { - start = pageSize * (pageIndex - 1) + 1 - } - - if (setting.selected !== 'false' || (setting.orisel && id)) { - setTimeout(() => { - MKEmitter.emit('mkTableCheckTopLine', this.props.MenuID, id) - }, 200) - if (setting.selected === 'init') { - this.setState({setting: {...setting, selected: 'false'}}) + item.setting.supModule = '' } } - this.setState({ - data: result.data.map((item, index) => { - if (absFields.length) { - absFields.forEach(field => { - if (!item[field]) return - if (isNaN(Math.abs(item[field]))) return - - item[field] = Math.abs(item[field]) + let statFields = [] + let getCols = (cols) => { + return cols.filter(col => { + if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { + return false + } else if (col.Hide === 'true') { + return false + } + + if (col.type === 'number') { + if (col.sum === 'true') { + statFields.push(col) + } + if (typeof(col.decimal) === 'number') { + col.round = Math.pow(10, col.decimal) + if (col.format === 'percent') { + col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 + } + } + } else if (col.type === 'colspan') { + col.subcols = getCols(col.subcols || []) + if (col.subcols.length === 0) { + return false + } + } else if (col.type === 'custom') { + col.elements = col.elements.map(cell => { + if (['text', 'number', 'formula'].includes(cell.eleType)) { + if (!cell.height) { + cell.innerHeight = 'auto' + } + if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { + cell.round = Math.pow(10, cell.decimal) + if (cell.format === 'percent') { + cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 + } + } + } + return cell }) } - - item.key = index - item.$$uuid = item[setting.primaryKey] || '' - item.$$key = '' + item.key + item.$$uuid - item.$$BID = BID || '' - item.$Index = start + index + '' - - if (setting.controlField) { - if (setting.controlVal.includes(item[setting.controlField])) { - item.$disabled = true - } + + if (col.linkmenu && col.linkmenu.length > 0) { + let menu_id = col.linkmenu.pop() + col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' + } else { + col.linkThdMenu = '' } - return item - }), - total: result.total, - loading: false, - pickup: false - }) - - if (autoMatic) { - if (result.data && result.data.length > 0) { - MKEmitter.emit('autoGetData', this.props.MenuID) - } else { - MKEmitter.emit('autoMaticOver', this.props.MenuID) - } - } - } else { - this.setState({ - loading: false - }) - if (autoMatic) { - MKEmitter.emit('autoMaticError', this.props.MenuID) - } - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } - } - - /** - * @description 鑾峰彇鍗曡鏁版嵁 - */ - async loadmainLinedata (id) { - const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state - - this.setState({ - loading: true - }) - - let _orderBy = orderBy || setting.order - let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, id) - - let result = await Api.genericInterface(param) - if (result.status) { - let data = fromJS(this.state.data).toJS() - let selectedData = fromJS(this.state.selectedData).toJS() - if (result.data && result.data[0]) { - let _data = result.data[0] || {} - - if (absFields.length) { - absFields.forEach(field => { - if (!_data[field]) return - if (isNaN(Math.abs(_data[field]))) return - - _data[field] = Math.abs(_data[field]) - }) - } - _data.$$uuid = _data[setting.primaryKey] || '' - _data.$$BID = BID || '' - - try { - data = data.map(item => { - if (item.$$uuid === _data.$$uuid) { - _data.key = item.key - _data.$$key = '' + item.key + item.$$uuid - _data.$Index = item.$Index - return _data - } else { - return item - } - }) - selectedData = selectedData.map(item => { - if (_data.$$uuid === item.$$uuid) { - return _data - } - return item - }) - } catch (e) { - console.warn('鏁版嵁鏌ヨ閿欒') - } - } - - this.setState({ - data, - selectedData, - loading: false - }) - } else { - this.setState({ - loading: false - }) - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } - } - - /** - * @description 鑾峰彇鍚堣瀛楁鍊� - */ - getStatFieldsValue = () => { - const { setting, search, BID, orderBy, statFields } = this.state - - if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return - - let _orderBy = orderBy || setting.order - let param = UtilsDM.getStatQueryDataParams(setting, statFields, search, _orderBy, BID) - - Api.genericInterface(param).then(res => { - if (res.status) { - let _data = res.data[0] - let values = [] - - if (_data) { - statFields.forEach(item => { - if (_data[item.field] || _data[item.field] === 0) { - let val = +_data[item.field] - if (isNaN(val)) { - val = 0 - } - val = val.toFixed(item.decimal) - values.push({label: item.label, value: val}) - } - }) - } - this.setState({ - statFValue: values - }) - } else { - this.setState({ - statFValue: [] - }) - notification.error({ - top: 92, - message: res.message, - duration: 10 + return true }) } - }) - } + + item.cols = getCols(item.cols) + item.statFields = Array.from(new Set(statFields)) - /** - * @description 鎼滅储鏉′欢鏀瑰彉鏃讹紝閲嶇疆琛ㄦ牸鏁版嵁 - * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� - */ - refreshbysearch = (searches) => { - const { setting } = this.state + // 鏉冮檺杩囨护 + let tabId = this.props.Tab ? this.props.Tab.uuid : '' // 寮圭獥鏍囩鎸夐挳Id + if (item.action && item.action.length > 0) { + item.action = item.action.filter(cell => { + if (item.hidden === 'true') return false - if (setting.onload === 'false') { - this.setState({ - pageIndex: 1, - search: searches, - setting: {...setting, onload: 'true'} - }, () => { - this.loadData() - }) - } else { - MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 - this.setState({ - pageIndex: 1, - search: searches - }, () => { - this.loadData() - }) - } - } + cell.logLabel = item.$menuname + '-' + cell.label + cell.ContainerId = this.state.ContainerId + cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' + cell.$menuId = item.uuid + cell.$MenuID = this.props.MenuID + cell.$tabId = tabId + cell.$view = 'BasePage' + cell.$toolbtn = true - /** - * @description 琛ㄦ牸鏉′欢鏀瑰彉鏃堕噸缃暟鎹紙鍒嗛〉鎴栨帓搴忥級 - */ - refreshbytable = (pagination, filters, sorter) => { - if (!sorter) { - this.setState({ - pageIndex: pagination.pageIndex - }, () => { - this.loadData() - }) - return - } + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + } - if (sorter.order) { - let _chg = { - ascend: 'asc', - descend: 'desc' + if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� + cell = this.getPrinter(cell, item.uuid) + } + + return skip || permAction[cell.uuid] + }) } - sorter.order = _chg[sorter.order] - } - this.setState({ - pageIndex: pagination.current, - pageSize: pagination.pageSize, - orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' - }, () => { - this.loadData() - }) - } + item.cols = item.cols.filter(col => { + if (col.type !== 'action') return true + col.elements = col.elements.filter(cell => { + if (cell.hidden === 'true') return false + + cell.logLabel = item.$menuname + '-' + cell.label + cell.Ot = cell.Ot || 'requiredSgl' + cell.ContainerId = this.state.ContainerId + cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' + cell.$menuId = item.uuid + cell.$MenuID = this.props.MenuID + cell.$tabId = tabId + cell.$view = 'BasePage' - /** - * @description 琛ㄦ牸鍒锋柊 - */ - reloadtable = (btn, id = '') => { - if (!btn || btn.resetPageIndex !== 'false') { - MKEmitter.emit('resetTable', this.props.MenuID) // 鍒楄〃閲嶇疆 - this.setState({ - pageIndex: 1 - }, () => { - this.loadData(id) + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + } + + if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� + cell = this.getPrinter(cell, item.uuid) + } + + return skip || permAction[cell.uuid] + }) + return col.elements.length !== 0 }) - } else { - MKEmitter.emit('resetTable', this.props.MenuID, 'false') // 鍒楄〃閲嶇疆 - this.loadData(id) + + return true + }) + } + + getPrinter = (item, parentId) => { + let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid) + + if (_item) { + item.printer = _item.printer || '' + item.verify.defaultPrinter = _item.printer || '' + if (item.verify.printerTypeList && _item.printerList) { + item.verify.printerTypeList = item.verify.printerTypeList.map(cell => { + cell.printer = _item.printerList[cell.Value] || '' + + return cell + }) + } } + + return item } - /** - * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� - */ - reloadview = () => { - this.setState({ loadingview: true, viewlost: false, config: {}, setting: null, - data: null, total: 0, loading: false, pageIndex: 1, shortcuts: null, - pageSize: 10, orderBy: '', search: '', BIDs: {}, pickup: false, searchlist: null - }, () => { - this.loadconfig() - }) - } + // 鏍煎紡鍖栭粯璁よ缃� + formatSetting = (components, regs) => { + let delay = 20 + return components.map(component => { + if (component.type === 'tabs') { + component.subtabs = component.subtabs.map(tab => { + tab.components = this.formatSetting(tab.components, regs) + return tab + }) + return component + } - /** - * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁� - */ - queryModuleParam = (menuId, callback) => { - const { MenuName, MenuID } = this.props - const { arr_field, orderBy, search, setting} = this.state + component.setting.useMSearch = component.setting.useMSearch === 'true' - if (MenuID !== menuId) return + if (component.setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 + component.setting.sync = 'false' + component.setting.laypage = component.setting.laypage === 'true' + return component + } - callback({ - arr_field: arr_field, - orderBy: orderBy || setting.order, - search: search, - menuName: MenuName - }) - } + let _customScript = '' + component.scripts && component.scripts.forEach(script => { + if (script.status !== 'false') { + _customScript += ` + ${script.sql} + ` + } + }) + delete component.scripts + component.setting.$name = component.$menuname || '' + component.setting.execute = component.setting.execute !== 'false' // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡 + component.setting.laypage = component.setting.laypage === 'true' // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡 - /** - * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹� - */ - changeSelectedData = (selectedData) => { - this.setState({selectedData}) - } + if (!component.setting.execute) { + component.setting.dataresource = '' + } + if (/\s/.test(component.setting.dataresource)) { + component.setting.dataresource = '(' + component.setting.dataresource + ') tb' + } - /** - * @description 鏁版嵁灞曞紑鍚堝苟鍒囨崲 - */ - pickupChange = () => { - const { pickup } = this.state - this.setState({ - pickup: !pickup + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') + component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') + _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') + _customScript = _customScript.replace(/@\$/ig, '*/') + } else { + component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + } + + regs.forEach(cell => { + component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value) + _customScript = _customScript.replace(cell.reg, cell.value) + }) + + component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 + + component.setting.delay = delay + delay += 20 + + return component }) } - /** - * @description 鍥捐〃瑙嗗浘鍒囨崲 - */ - changeChart = (uuid) => { - this.setState({chartId: uuid}) - } - - reloadData = (menuId, id, btn) => { + reloadMenuView = (menuId) => { const { MenuID } = this.props if (MenuID !== menuId) return - if (id === 'formtab') { // 琛ㄥ崟鏍囩椤靛埛鏂� - this.reloadtable(btn) - return - } - - if (!id) { - this.reloadtable() - } else { - this.loadmainLinedata(id) - } - } - - reloadMenuView = (menuId, position) => { - const { MenuID } = this.props - - if (MenuID !== menuId) return - - if (position === 'table') { - this.reloadtable() - } else { - this.reloadview() - } + this.reloadview() } resetActiveMenu = (menuId) => { - const { MenuID } = this.props + const { MenuID, Tab } = this.props - if (MenuID !== menuId) return + if (MenuID !== menuId || Tab) return this.setShortcut() - } - - changeTableLine = (ContainerId, tableId, id, data) => { - if (this.state.ContainerId !== ContainerId) return - - this.setState({ - BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} - }) - } - - /** - * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� - * @param {*} menuId // 鑿滃崟Id - * @param {*} position // 鍒锋柊浣嶇疆 - * @param {*} btn // 鎵ц鐨勬寜閽� - */ - refreshByButtonResult = (menuId, position, btn, id, lines) => { - const { MenuID } = this.props - - if (MenuID !== menuId) return - - if (position === 'line' && lines && lines.length === 1) { - this.loadmainLinedata(lines[0].$$uuid) - } else { - this.reloadtable(btn, id) - } } UNSAFE_componentWillMount () { @@ -1090,12 +495,9 @@ } componentDidMount () { - MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('debugChange', this.debugChange) MKEmitter.addListener('reloadMenuView', this.reloadMenuView) - MKEmitter.addListener('changeTableLine', this.changeTableLine) MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) - MKEmitter.addListener('queryModuleParam', this.queryModuleParam) - MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) } /** @@ -1105,171 +507,88 @@ this.setState = () => { return } - document.onkeydown = () => {} - MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('debugChange', this.debugChange) MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) - MKEmitter.removeListener('changeTableLine', this.changeTableLine) MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) - MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) - MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + + window.GLOB.CacheData.delete(this.props.MenuID) + if (this.state.config) { + this.deleteCache(this.state.config.components) + } + } + + debugChange = () => { + this.setState({visible: !this.state.visible}) + } + + deleteCache = (components) => { + components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + this.deleteCache(tab.components) + }) + } else { + window.GLOB.CacheData.delete(item.uuid) + } + }) + } + + reloadview = () => { + this.setState({ + BID: '', // 椤甸潰璺宠浆鏃舵惡甯D + loadingview: true, // 椤甸潰鍔犺浇涓� + viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 + config: null, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑 + loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� + shortcuts: null, + data: '' + }, () => { + this.loadconfig() + }) + } + + resetSearch = (search) => { + this.setState({mainSearch: null}, () => { + this.setState({mainSearch: search}) + }) + } + + getComponents = () => { + const { config, data, mainSearch } = this.state + + if (!config || !config.components) return + + return config.components.map(item => { + if (item.type === 'tabs') { + return ( + <Col span={item.width} key={item.uuid}> + <AntvTabs config={item} mainSearch={mainSearch} /> + </Col> + ) + } else { + return ( + <Col span={item.width} key={item.uuid}> + <MkBaseTable config={item} data={data}/> + </Col> + ) + } + }) } render() { - const { MenuID } = this.props - const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts, autoMatic } = this.state + const { loadingview, viewlost, config, loading, shortcuts } = this.state return ( - <div className="commontable" id={this.state.ContainerId}> - {loadingview ? <Spin size="large" /> : null} - {searchlist && searchlist.length ? - <MainSearch BID={BID} searchlist={searchlist} setting={setting} refreshdata={this.refreshbysearch}/> : null - } - {setting && config.charts ? <Row className="chart-view" gutter={16}> - {/* 瑙嗗浘缁� */} - {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> - {config.charts.map(item => ( - <TabPane tab={<MkIcon type={item.icon} />} key={item.uuid}></TabPane> - ))} - </Tabs> : null} - {config.charts.map(item => { - if (!config.expand && chartId !== item.uuid) return null - - if (item.chartType === 'table') { - return ( - <Col span={item.width || 24} key={item.uuid}> - {config.charts.length > 1 && item.title ? <p className="chart-table chart-title">{item.title}</p> : null} - <div className="commontable-main-action"> - <MainAction - BID={BID} - setting={setting} - actions={actions} - columns={columns} - dict={this.state.dict} - MenuID={MenuID} - selectedData={selectedData} - ContainerId={this.state.ContainerId} - /> - </div> - <div className="main-table-box"> - {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ? - <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" checked={pickup} onChange={this.pickupChange} /> : null - } - <MainTable - MenuID={MenuID} - tableId={MenuID} - pickup={pickup} - setting={setting} - columns={columns} - pageSize={pageSize} - dict={this.state.dict} - data={this.state.data} - total={this.state.total} - loading={this.state.loading} - statFValue={this.state.statFValue} - ContainerId={this.state.ContainerId} - refreshdata={this.refreshbytable} - chgSelectData={this.changeSelectedData} - /> - </div> - </Col> - ) - } else if (item.chartType === 'card') { - return ( - <Col className="card-view" span={item.width} key={item.uuid}> - <CardComponent - BID={BID} - plot={item} - MenuID={MenuID} - config={config} - tableId={MenuID} - columns={columns} - data={this.state.data} - loading={this.state.loading} - ContainerId={this.state.ContainerId} - /> - </Col> - ) - } else { - return ( - <Col span={item.width} key={item.uuid}> - <ChartComponent - BID={BID} - plot={item} - config={config} - data={this.state.data} - loading={this.state.loading} - /> - </Col> - ) - } - })} - </Row> : null } - {setting && !config.charts ? <div className="chart-view"> - <div className="commontable-main-action"> - <MainAction - BID={BID} - setting={setting} - actions={actions} - columns={columns} - dict={this.state.dict} - MenuID={MenuID} - selectedData={selectedData} - ContainerId={this.state.ContainerId} - /> - </div> - <div className="main-table-box"> - {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ? - <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" checked={pickup} onChange={this.pickupChange} /> : null - } - <MainTable - MenuID={MenuID} - tableId={MenuID} - pickup={pickup} - setting={setting} - columns={columns} - pageSize={pageSize} - dict={this.state.dict} - data={this.state.data} - total={this.state.total} - loading={this.state.loading} - statFValue={this.state.statFValue} - ContainerId={this.state.ContainerId} - refreshdata={this.refreshbytable} - chgSelectData={this.changeSelectedData} - /> - </div> - </div> : null } - {setting && config.tabgroups.map(group => ( - <Tabs key={group.uuid}> - {group.sublist.map(_tab => { - return ( - <TabPane tab={ - <span id={_tab.uuid}> - {_tab.icon ? <MkIcon type={_tab.icon} /> : null} - {_tab.label} - </span> - } key={_tab.uuid}> - <SubTable - Tab={_tab} - SupMenuID={MenuID} - MenuID={_tab.linkTab} - mainSearch={_tab.searchPass === 'true' ? search : null} - ContainerId={this.state.ContainerId} - BID={this.state.BIDs[_tab.supMenu] || ''} - BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} - /> - </TabPane> - ) - })} - </Tabs>)) - } - {!window.GLOB.mkHS && autoMatic ? <AutoMatic autoMatic={autoMatic} config={config} /> : null} + <div className={'custom-page-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}> + {(loadingview || loading) ? <Spin className="view-spin" size="large" /> : null} + <Row className="component-wrap">{this.getComponents()}</Row> + {config && window.GLOB.breakpoint ? <DebugTable /> : null} {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} - {!window.GLOB.mkHS && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts}/> : null} + {!window.GLOB.mkHS && config ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts || []}/> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) } } -export default NormalTable \ No newline at end of file +export default BasePage \ No newline at end of file diff --git a/src/tabviews/custom/components/share/tabtransfer/index.jsx b/src/tabviews/custom/components/share/tabtransfer/index.jsx index cf08b7d..8035acb 100644 --- a/src/tabviews/custom/components/share/tabtransfer/index.jsx +++ b/src/tabviews/custom/components/share/tabtransfer/index.jsx @@ -36,6 +36,7 @@ const Balcony = asyncComponent(() => import('@/tabviews/custom/components/card/balcony')) const TimeLine = asyncComponent(() => import('@/tabviews/custom/components/timeline/normal-timeline')) const CustomChart = asyncComponent(() => import('@/tabviews/custom/components/chart/custom-chart')) +const MkBaseTable = asyncComponent(() => import('@/tabviews/custom/components/table/base-table')) class TabTransfer extends Component { static propTpyes = { @@ -244,6 +245,12 @@ <NormalTable config={item} data={data} mainSearch={mainSearch}/> </Col> ) + } else if (item.type === 'table' && item.subtype === 'basetable') { + return ( + <Col span={item.width} key={item.uuid}> + <MkBaseTable config={item} data={data} mainSearch={mainSearch}/> + </Col> + ) } else if (item.type === 'table' && item.subtype === 'editable') { return ( <Col span={item.width} key={item.uuid}> diff --git a/src/tabviews/custom/components/table/base-table/index.jsx b/src/tabviews/custom/components/table/base-table/index.jsx new file mode 100644 index 0000000..58a66c5 --- /dev/null +++ b/src/tabviews/custom/components/table/base-table/index.jsx @@ -0,0 +1,588 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' +import { notification } from 'antd' + +import Api from '@/api' +import Utils from '@/utils/utils.js' +import UtilsDM from '@/utils/utils-datamanage.js' +import asyncComponent from '@/utils/asyncComponent' +import MKEmitter from '@/utils/events.js' +import './index.scss' + +// 閫氱敤缁勪欢 +const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) +const MainAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) +const MainTable = asyncComponent(() => import('@/tabviews/custom/components/share/normalTable')) + +class MkBaseTable extends Component { + static propTpyes = { + data: PropTypes.array, // 缁熶竴鏌ヨ鏁版嵁 + config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 + mainSearch: PropTypes.any, // 澶栧眰鎼滅储鏉′欢 + } + + state = { + BID: '', // 涓婄骇ID + BData: '', // 涓婄骇缁勪欢琛屾暟鎹� + config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 + actions: null, // 鎸夐挳闆� + columns: null, // 鏄剧ず鍒� + arr_field: '', // 鏌ヨ瀛楁闆� + setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 + data: [], // 鍒楄〃鏁版嵁闆� + selectedData: [], // 宸查�夎〃鏍兼暟鎹� + total: 0, // 鎬绘暟 + loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� + pageIndex: 1, // 椤电爜 + pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 + orderBy: '', // 鎺掑簭 + search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� + statFValue: [] // 鍚堣鍊� + } + + /** + * @description 鍒濆鍖栧鐞� + */ + UNSAFE_componentWillMount () { + let _config = fromJS(this.props.config).toJS() + let _cols = new Map() + + let BID = '' + let BData = '' + + if (_config.setting.supModule) { + BData = window.GLOB.CacheData.get(_config.setting.supModule) + } else { + BData = window.GLOB.CacheData.get(_config.$pageId) + } + if (BData) { + BID = BData.$BID || '' + } + + if (_config.wrap.controlField) { + if (_config.wrap.controlVal) { + _config.wrap.controlVal = _config.wrap.controlVal.split(',') + } else { + _config.wrap.controlVal = [''] + } + } + + let setting = {..._config.setting, ..._config.wrap} + + if (setting.selected !== 'always' && setting.selected !== 'init') { + setting.selected = 'false' + } else { + setting.orisel = true + } + + _config.columns.forEach(item => { + if (item.type !== 'number') return + _cols.set(item.field, item) + }) + + _config.cols.forEach(column => { + if (column.type === 'action') { + column.operations = column.elements + } + }) + + _config.style = _config.style || {} + + this.setState({ + pageSize: setting.pageSize || 10, + BID: BID || '', + BData: BData || '', + config: _config, + setting: setting, + actions: _config.action, + columns: _config.cols, + arr_field: _config.columns.map(col => col.field).join(','), + search: Utils.initMainSearch(_config.search) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 + }, () => { + if (_config.setting.onload === 'true') { + setTimeout(() => { + this.loadmaindata() + this.getStatFieldsValue() + }, _config.setting.delay || 0) + } + }) + } + + /** + * @description 涓昏〃鏁版嵁鍔犺浇 + * @param { Boolean } reset 琛ㄦ牸鏄惁閲嶇疆 + * @param { String } repage 琛ㄦ牸鏄惁閲嶇疆椤电爜 + */ + async loadmaindata (reset, repage, id) { + const { mainSearch } = this.props + const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state + + if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� + this.setState({ + data: [], + selectedData: [], + total: 0 + }) + + MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 + reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆 + if (setting.$hasSyncModule) { + MKEmitter.emit('syncBalconyData', config.uuid, [], false) + } + return + } + + let searches = fromJS(search).toJS() + if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 + let keys = searches.map(item => item.key.toLowerCase()) + mainSearch.forEach(item => { + if (!keys.includes(item.key.toLowerCase())) { + searches.push(item) + } + }) + } + + let requireFields = searches.filter(item => item.required && item.value === '') + if (requireFields.length > 0) { + return + } + + this.setState({ + loading: true + }) + + let _orderBy = orderBy || setting.order + let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID) + + let result = await Api.genericInterface(param) + if (result.status) { + if ((setting.selected !== 'false' || (setting.orisel && id)) && result.data && result.data.length > 0) { + setTimeout(() => { + MKEmitter.emit('mkCheckTopLine', config.uuid, id) + }, 200) + if (setting.selected === 'init') { + this.setState({setting: {...setting, selected: 'false'}}) + } + } else { + MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲 + if (setting.$hasSyncModule) { + MKEmitter.emit('syncBalconyData', config.uuid, [], false) + } + } + + reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆 + + let start = 1 + if (setting.laypage) { + start = pageSize * (pageIndex - 1) + 1 + } + + this.setState({ + data: result.data.map((item, index) => { + item.key = index + item.$$uuid = item[setting.primaryKey] || '' + item.$$key = '' + item.key + item.$$uuid + item.$$BID = BID || '' + item.$$BData = BData || '' + item.$Index = start + index + '' + + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + if (setting.controlField) { + if (setting.controlVal.includes(item[setting.controlField])) { + item.$disabled = true + } + } + + return item + }), + selectedData: [], + total: result.total, + loading: false + }) + } else { + this.setState({ + loading: false + }) + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } + } + + /** + * @description 鑾峰彇鍗曡鏁版嵁 + */ + async loadmainLinedata (id) { + const { mainSearch } = this.props + const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state + + let searches = fromJS(search).toJS() + if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 + let keys = searches.map(item => item.key.toLowerCase()) + mainSearch.forEach(item => { + if (!keys.includes(item.key.toLowerCase())) { + searches.push(item) + } + }) + } + + this.setState({ + loading: true + }) + + let _orderBy = orderBy || setting.order + let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, id) + + let result = await Api.genericInterface(param) + if (result.status) { + let data = fromJS(this.state.data).toJS() + let selectedData = fromJS(this.state.selectedData).toJS() + if (result.data && result.data[0]) { + let _data = result.data[0] || {} + _data.$$uuid = _data[setting.primaryKey] || '' + _data.$$BID = BID || '' + _data.$$BData = BData || '' + + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(_data[f])) { + _data[f] = Math.abs(_data[f]) + } + }) + } + + try { + data = data.map(item => { + if (item.$$uuid === _data.$$uuid) { + _data.key = item.key + _data.$$key = '' + item.key + item.$$uuid + _data.$Index = item.$Index + return _data + } else { + return item + } + }) + selectedData = selectedData.map(item => { + if (_data.$$uuid === item.$$uuid) { + return _data + } + return item + }) + } catch (e) { + console.warn('鏁版嵁鏌ヨ閿欒') + } + + MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid || '', _data) + } + + this.setState({ + data, + selectedData, + loading: false + }) + } else { + this.setState({ + loading: false + }) + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } + } + + /** + * @description 鑾峰彇鍚堣瀛楁鍊� + */ + getStatFieldsValue = () => { + const { mainSearch } = this.props + const { setting, config, search, BID, orderBy } = this.state + + if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇� + this.setState({ + statFValue: [] + }) + return + } + + if (config.statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return + + let searches = fromJS(search).toJS() + if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 + let keys = searches.map(item => item.key.toLowerCase()) + mainSearch.forEach(item => { + if (!keys.includes(item.key.toLowerCase())) { + searches.push(item) + } + }) + } + let requireFields = searches.filter(item => item.required && item.value === '') + if (requireFields.length > 0) { + return + } + + let _orderBy = orderBy || setting.order + let param = UtilsDM.getStatQueryDataParams(setting, config.statFields, searches, _orderBy, BID) + + Api.genericInterface(param).then(res => { + if (res.status) { + let _data = res.data[0] + let values = [] + + if (_data) { + config.statFields.forEach(item => { + if (_data[item.field] || _data[item.field] === 0) { + let val = +_data[item.field] + if (isNaN(val)) { + val = 0 + } + val = val.toFixed(item.decimal) + values.push({label: item.label, value: val}) + } + }) + } + this.setState({ + statFValue: values + }) + } else { + this.setState({ + statFValue: [] + }) + notification.error({ + top: 92, + message: res.message, + duration: 10 + }) + } + }) + } + + /** + * @description 鎼滅储鏉′欢鏀瑰彉鏃讹紝閲嶇疆琛ㄦ牸鏁版嵁 + * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� + */ + refreshbysearch = (searches) => { + const { setting } = this.state + + if (setting.onload === 'false') { + this.setState({ + pageIndex: 1, + search: searches, + setting: {...setting, onload: 'true'} + }, () => { + this.loadmaindata() + this.getStatFieldsValue() + }) + } else { + this.setState({ + pageIndex: 1, + search: searches + }, () => { + this.loadmaindata(true, 'true') + this.getStatFieldsValue() + }) + } + } + + /** + * @description 琛ㄦ牸鏉′欢鏀瑰彉鏃堕噸缃暟鎹紙鍒嗛〉鎴栨帓搴忥級 + */ + refreshbytable = (pagination, filters, sorter) => { + if (sorter.order) { + let _chg = { + ascend: 'asc', + descend: 'desc' + } + sorter.order = _chg[sorter.order] + } + + this.setState({ + pageIndex: pagination.current, + pageSize: pagination.pageSize, + orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' + }, () => { + this.loadmaindata() + }) + } + + /** + * @description 琛ㄦ牸鍒锋柊 + */ + reloadtable = (btn, id) => { + if (!btn || btn.resetPageIndex !== 'false') { + this.setState({ + pageIndex: 1 + }, () => { + this.loadmaindata(true, 'true', id) + this.getStatFieldsValue() + }) + } else { + this.loadmaindata(true, 'false', id) + this.getStatFieldsValue() + } + } + + /** + * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁� + */ + queryModuleParam = (menuId, callback) => { + const { mainSearch } = this.props + const { arr_field, config, orderBy, search, setting} = this.state + + if (config.uuid !== menuId) return + + let searches = search ? fromJS(search).toJS() : [] + if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 + let keys = searches.map(item => item.key.toLowerCase()) + mainSearch.forEach(item => { + if (!keys.includes(item.key.toLowerCase())) { + searches.push(item) + } + }) + } + + callback({ + arr_field: arr_field, + orderBy: orderBy || setting.order, + search: searches, + menuName: config.name + }) + } + + reloadData = (menuId, id) => { + const { config } = this.state + + if (config.uuid !== menuId) return + + if (!id) { + this.reloadtable() + } else { + this.loadmainLinedata(id) + } + } + + resetParentParam = (MenuID, id, data) => { + const { setting } = this.state + + if (!setting.supModule || setting.supModule !== MenuID) return + if (id !== this.state.BID || id !== '') { + this.setState({ + pageIndex: 1, + BID: id, + BData: data + }, () => { + this.loadmaindata(true, 'true') + this.getStatFieldsValue() + }) + } + } + + /** + * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� + * @param {*} menuId // 鑿滃崟Id + * @param {*} position // 鍒锋柊浣嶇疆 + * @param {*} btn // 鎵ц鐨勬寜閽� + */ + refreshByButtonResult = (menuId, position, btn, id, lines) => { + const { config, BID } = this.state + + if (config.uuid !== menuId) return + + if (position === 'line') { + if (lines && lines.length === 1) { + this.loadmainLinedata(lines[0].$$uuid) + } else { + this.reloadtable(btn, id) + } + } else if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠� + MKEmitter.emit('reloadData', config.setting.supModule, BID) + } else { + this.reloadtable(btn, id) + } + + if (position === 'popclose') { // 鎵ц鍚姩寮圭獥鐨勬寜閽墍閫夋嫨鐨勫埛鏂伴」 + btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId) + } + } + + UNSAFE_componentWillReceiveProps(nextProps) { + const { config } = this.state + + if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { + this.setState({pageIndex: 1}, () => { + this.reloadtable() + }) + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + componentDidMount () { + MKEmitter.addListener('reloadData', this.reloadData) + MKEmitter.addListener('resetSelectLine', this.resetParentParam) + MKEmitter.addListener('queryModuleParam', this.queryModuleParam) + MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 + */ + componentWillUnmount () { + this.setState = () => { + return + } + MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('resetSelectLine', this.resetParentParam) + MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) + MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + } + + render() { + const { BID, setting, actions, config, columns, selectedData, BData, data } = this.state + + return ( + <div className="custom-base-table" style={config.style}> + {config.search.length ? + <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null + } + {actions.length ? <MainAction + BID={BID} + setting={setting} + actions={actions} + BData={BData} + columns={config.columns} + selectedData={selectedData} + /> : <div style={{height: '15px'}}></div>} + <div className="main-table-box"> + <MainTable + data={data} + setting={setting} + columns={columns} + MenuID={config.uuid} + fields={config.columns} + total={this.state.total} + lineMarks={config.lineMarks} + loading={this.state.loading} + refreshdata={this.refreshbytable} + statFValue={this.state.statFValue} + chgSelectData={(selects) => this.setState({selectedData: selects})} + /> + </div> + </div> + ) + } +} + +export default MkBaseTable \ No newline at end of file diff --git a/src/tabviews/custom/components/table/base-table/index.scss b/src/tabviews/custom/components/table/base-table/index.scss new file mode 100644 index 0000000..718e8a7 --- /dev/null +++ b/src/tabviews/custom/components/table/base-table/index.scss @@ -0,0 +1,48 @@ +.custom-base-table { + position: relative; + background-color: #fff; + + .normal-header { + margin-bottom: 10px; + } + .top-search { + border-bottom: 1px solid #efefef; + } + >.button-list.toolbar-button { + padding: 5px 0px; + line-height: 45px; + padding-right: 60px; + button { + margin-right: 0px; + margin-bottom: 0px; + min-height: 28px; + height: auto; + } + } + .ant-modal-mask { + position: absolute; + } + .ant-modal-wrap { + position: absolute; + } + .action-modal .ant-modal { + top: 40px; + max-width: 95%; + .ant-modal-body { + max-height: calc(100vh - 265px); + } + } + .main-table-box { + position: relative; + min-height: 150px; + .main-pickup { + position: absolute; + right: 5px; + top: -22px; + z-index: 2; + } + >.async-spin { + line-height: 150px!important; + } + } +} \ No newline at end of file diff --git a/src/tabviews/custom/components/table/edit-table/index.jsx b/src/tabviews/custom/components/table/edit-table/index.jsx index 631fd32..51a6a06 100644 --- a/src/tabviews/custom/components/table/edit-table/index.jsx +++ b/src/tabviews/custom/components/table/edit-table/index.jsx @@ -228,6 +228,15 @@ item.$Index = start + index + '' item.$type = 'upt' item.$origin = true + + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + return item }) @@ -287,6 +296,14 @@ _data.$type = 'upt' _data.$origin = true + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(_data[f])) { + _data[f] = Math.abs(_data[f]) + } + }) + } + try { data = data.map(item => { if (item.$$uuid === _data.$$uuid) { diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx index 8f7ea2a..bf7d655 100644 --- a/src/tabviews/custom/components/table/normal-table/index.jsx +++ b/src/tabviews/custom/components/table/normal-table/index.jsx @@ -101,6 +101,14 @@ item.$$BData = BData || '' item.$Index = index + 1 + '' + if (_config.absFields) { + _config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + if (setting.controlField) { if (setting.controlVal.includes(item[setting.controlField])) { item.$disabled = true @@ -256,6 +264,14 @@ item.$$BData = BData || '' item.$Index = start + index + '' + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + if (setting.controlField) { if (setting.controlVal.includes(item[setting.controlField])) { item.$disabled = true @@ -314,6 +330,15 @@ _data.$$uuid = _data[setting.primaryKey] || '' _data.$$BID = BID || '' _data.$$BData = BData || '' + + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(_data[f])) { + _data[f] = Math.abs(_data[f]) + } + }) + } + try { data = data.map(item => { if (item.$$uuid === _data.$$uuid) { @@ -584,6 +609,14 @@ item.$$BData = BData || '' item.$Index = index + 1 + '' + if (config.absFields) { + config.absFields.forEach(f => { + if (!isNaN(item[f])) { + item[f] = Math.abs(item[f]) + } + }) + } + if (setting.controlField) { if (setting.controlVal.includes(item[setting.controlField])) { item.$disabled = true diff --git a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx index 483549b..9b46381 100644 --- a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx +++ b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx @@ -144,7 +144,7 @@ if (!tabs.subtabs.length) return null return ( - <div className={'menu-antv-tabs-wrap ' + tabs.setting.tabLabel} style={tabs.style}> + <div className={'menu-antv-tabs-wrap ' + (tabs.setting.tabLabel || '')} style={tabs.style}> <Tabs defaultActiveKey="1" tabBarStyle={{background: tabs.setting.backgroundColor || 'transparent'}} tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}> {tabs.subtabs.map(tab => ( <TabPane tab={<span id={'tab' + tab.uuid}>{tab.icon ? <MkIcon type={tab.icon} /> : null}{tab.label}</span>} style={{backgroundColor: tab.backgroundColor || 'transparent'}} key={tab.uuid}> diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index 857e9f1..8037251 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -81,7 +81,7 @@ if (config.type === 'search') { _setting.float = config.wrap.float || 'left' _setting.style = config.style - } else if (config.type === 'table' && (config.subtype === 'normaltable' || config.subtype === 'editable')) { + } else if (config.type === 'table' && config.subtype !== 'tablecard') { _setting.float = 'left' } else { _setting.float = 'right' diff --git a/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx b/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx index c6d82e3..f39eecc 100644 --- a/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx +++ b/src/templates/sharecomponent/fieldscomponent/editcard/index.jsx @@ -11,18 +11,21 @@ super(props) let _type = props.card.type - if (props.type === 'columns') { - if (_type === 'date' || _type === 'datetime') { - _type = 'text' + + if (!props.card.origin) { + if (props.type === 'columns') { + if (_type !== 'number') { + _type = 'text' + } + } else if (props.type === 'search') { + if (_type !== 'select') { + _type = 'text' + } + } else if (props.type === 'form') { + if (_type !== 'number') { + _type = 'text' + } } - } else if (props.type === 'search') { - if (_type === 'number') { - _type = 'text' - } else if (_type === 'datetime') { - _type = 'daterange' - } - } else if (props.type === 'form') { - } this.state = { @@ -78,14 +81,12 @@ <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected || card.origin}> <Radio value="text">text</Radio> <Radio value="select">select</Radio> - <Radio value="daterange">dateRange</Radio> </Radio.Group> : null } {type === 'columns' ? <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected || card.origin}> <Radio value="text">text</Radio> <Radio value="number">number</Radio> - <Radio value="picture">picture</Radio> </Radio.Group> : null } {type === 'form' ? diff --git a/src/templates/sharecomponent/fieldscomponent/index.jsx b/src/templates/sharecomponent/fieldscomponent/index.jsx index 53642ec..41a9a0a 100644 --- a/src/templates/sharecomponent/fieldscomponent/index.jsx +++ b/src/templates/sharecomponent/fieldscomponent/index.jsx @@ -108,9 +108,6 @@ let initval = '' if (item.type === 'select') { _match = '=' - } else if (item.type === 'daterange') { - initval = '[30, 0]' - _match = 'between' } else { item.type = 'text' _match = 'like' @@ -140,7 +137,7 @@ label: item.label, field: item.field, Hide: 'false', - IsSort: item.type === 'picture' ? 'false' : 'true', + IsSort: 'true', type: item.type, Width: item.type === 'number' ? 80 : 120 } diff --git a/src/templates/sharecomponent/settingcomponent/index.jsx b/src/templates/sharecomponent/settingcomponent/index.jsx index 85be0a7..72e3a09 100644 --- a/src/templates/sharecomponent/settingcomponent/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/index.jsx @@ -152,6 +152,16 @@ setting.dataresource = setting.dataresource.replace(reg, `/*$ex@${m.func_code}-begin*/\n${m.key_sql}\n/*@ex$-end*/`) } }) + } else { + setting.scripts.forEach(item => { + if (item.status === 'false') return + + if (/exec\s/ig.test(item.sql)) { + maxScript = 1000 + } else if (item.sql.length > maxScript) { + maxScript = item.sql.length + } + }) } setting.maxScript = maxScript diff --git a/src/templates/zshare/unattended/index.jsx b/src/templates/zshare/unattended/index.jsx index 4b6b8f5..abb8018 100644 --- a/src/templates/zshare/unattended/index.jsx +++ b/src/templates/zshare/unattended/index.jsx @@ -27,12 +27,20 @@ const { config } = this.props let actions = [] - config.action.forEach(item => { - if (item.position !== 'toolbar') return - if (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print')) { - actions.push(item) - } - }) + if (config.components) { + config.components[0].action.forEach(item => { + if (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print')) { + actions.push(item) + } + }) + } else { + config.action.forEach(item => { + if (item.position !== 'toolbar') return + if (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print')) { + actions.push(item) + } + }) + } this.setState({ actions, @@ -48,6 +56,7 @@ this.setState({ visible: false }) + this.props.updateConfig({...config, autoMatic: res}) }) } diff --git a/src/templates/zshare/verifycard/baseform/index.jsx b/src/templates/zshare/verifycard/baseform/index.jsx index 19fdbf9..a0f5892 100644 --- a/src/templates/zshare/verifycard/baseform/index.jsx +++ b/src/templates/zshare/verifycard/baseform/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Row, Col, Select, Radio, Tooltip, Input } from 'antd' +import { Form, Row, Col, Select, Radio, Tooltip, Input, notification } from 'antd' import { QuestionCircleOutlined } from '@ant-design/icons' import Api from '@/api' @@ -107,7 +107,7 @@ } onOptionChange = (value, key) => { - const { verify } = this.props + const { verify, setting } = this.props let _verify = {...verify, [key]: value} @@ -131,6 +131,15 @@ } } + if (verify.invalid !== 'true' && _verify.invalid === 'true' && setting.maxScript && setting.maxScript >= 300) { + notification.warning({ + top: 92, + message: '鏁版嵁婧愪腑鑷畾涔夎剼鏈繃浜庡鏉傦紝涓嶈兘浣跨敤澶辨晥楠岃瘉锛�', + duration: 5 + }) + return + } + this.props.onChange(_verify) } diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index 86ece6e..e331b3a 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -1501,7 +1501,7 @@ render() { const { card } = this.props - const { activeKey, verifyInter, verify, fields, visible, uniqueFields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, cbScriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes, appType } = this.state + const { activeKey, verifyInter, setting, verify, fields, visible, uniqueFields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, cbScriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes, appType } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -1523,7 +1523,7 @@ {verify.default === 'false' ? <span className="count-tip"><ExclamationOutlined style={{color: 'orange'}}/></span> : null} </span> } key="base"> - <BaseForm card={card} unionFields={unionFields} verify={verify} notes={notes} onChange={(verify) => this.setState({verify})} wrappedComponentRef={(inst) => this.baseForm = inst}/> + <BaseForm card={card} unionFields={unionFields} setting={setting} verify={verify} notes={notes} onChange={(verify) => this.setState({verify})} wrappedComponentRef={(inst) => this.baseForm = inst}/> </TabPane> : null} {verifyInter === 'system' ? <TabPane tab={ <span> diff --git a/src/utils/utils-custom.js b/src/utils/utils-custom.js index cbd1923..b783fc3 100644 --- a/src/utils/utils-custom.js +++ b/src/utils/utils-custom.js @@ -4,44 +4,51 @@ * @return {String} selfId 褰撳墠缁勪欢id */ static getSubModules (components, selfId, supId) { - let modules = components.map(item => { + let modules = [] + components.forEach(item => { if (item.uuid === selfId || item.type === 'navbar') { - return { - children: null - } + return } else if (item.format) { // 鏁版嵁鏍煎紡锛屽瓨鍦ㄦ暟鎹簮 - return { + modules.push({ value: item.uuid, label: item.name, disabled: supId === item.uuid - } + }) } else if (item.type === 'tabs') { - let _item = { - type: 'tabs', - value: item.uuid, - label: item.name, - children: item.subtabs.map(f_tab => { - let subItem = { - type: 'tab', - value: f_tab.uuid, - label: f_tab.label, - children: this.getSubModules(f_tab.components, selfId) - } - - if (!subItem.children || subItem.children.length === 0) { - return {children: null} - } - return subItem + if (item.subtype === 'tabletabs') { + item.subtabs.forEach(tab => { + modules.push({ + value: tab.components[0].uuid, + label: tab.label, + disabled: supId === tab.components[0].uuid + }) }) + } else { + let _item = { + type: 'tabs', + value: item.uuid, + label: item.name, + children: item.subtabs.map(f_tab => { + let subItem = { + type: 'tab', + value: f_tab.uuid, + label: f_tab.label, + children: this.getSubModules(f_tab.components, selfId, supId) + } + + if (subItem.children.length === 0) { + return {children: null} + } + return subItem + }) + } + + _item.children = _item.children.filter(t => t.children !== null) + + if (_item.children.length > 0) { + modules.push(_item) + } } - - _item.children = _item.children.filter(t => t.children !== null) - - if (_item.children.length === 0) { - return {children: null} - } - - return _item } else if (item.type === 'group') { let _item = { value: item.uuid, @@ -54,7 +61,8 @@ } else if (f_tab.format) { return { value: f_tab.uuid, - label: f_tab.name + label: f_tab.name, + disabled: supId === f_tab.uuid } } return { @@ -65,23 +73,12 @@ _item.children = _item.children.filter(t => t.children !== null) - if (_item.children.length === 0) { - return {children: null} - } - - return _item - } else { - return { - children: null + if (_item.children.length > 0) { + modules.push(_item) } } }) - modules = modules.filter(mod => mod.children !== null) - - if (modules.length === 0) { - return null - } return modules } @@ -175,11 +172,10 @@ * @return {String} selfId 褰撳墠缁勪欢id */ static getSupModules (components, selfId) { - let modules = components.map(item => { + let modules = [] + components.forEach(item => { if (item.uuid === selfId) { - return { - children: null - } + } else if (item.switchable) { // 鏁版嵁鍙垏鎹� let disabled = false if (item.type === 'card') { @@ -187,41 +183,51 @@ } else if (item.type === 'table') { disabled = item.wrap.tableType === '' } - return { + modules.push({ value: item.uuid, label: item.name, disabled: disabled - } + }) } else if (item.type === 'form') { // 鏁版嵁鏍煎紡锛屽瓨鍦ㄦ暟鎹簮 - return { + modules.push({ value: item.uuid, label: item.name - } + }) } else if (item.type === 'tabs') { - let _item = { - value: item.uuid, - label: item.name, - children: item.subtabs.map(f_tab => { - let subItem = { - value: f_tab.uuid, - label: f_tab.label, - children: this.getSupModules(f_tab.components, selfId) - } + if (item.subtype === 'tabletabs') { + item.subtabs.forEach(tab => { + if (tab.components[0].uuid === selfId) return - if (!subItem.children || subItem.children.length === 0) { - return {children: null} - } - return subItem + modules.push({ + value: tab.components[0].uuid, + label: tab.label, + disabled: tab.components[0].wrap.tableType === '' + }) }) + } else { + let _item = { + value: item.uuid, + label: item.name, + children: item.subtabs.map(f_tab => { + let subItem = { + value: f_tab.uuid, + label: f_tab.label, + children: this.getSupModules(f_tab.components, selfId) + } + + if (subItem.children.length === 0) { + return {children: null} + } + return subItem + }) + } + + _item.children = _item.children.filter(t => t.children !== null) + + if (_item.children.length > 0) { + modules.push(_item) + } } - - _item.children = _item.children.filter(t => t.children !== null) - - if (_item.children.length === 0) { - return {children: null} - } - - return _item } else if (item.type === 'group') { let _item = { value: item.uuid, @@ -232,9 +238,16 @@ children: null } } else if (f_tab.switchable) { + let disabled = false + if (f_tab.type === 'card') { + disabled = f_tab.wrap.cardType === '' + } else if (f_tab.type === 'table') { + disabled = f_tab.wrap.tableType === '' + } return { value: f_tab.uuid, - label: f_tab.name + label: f_tab.name, + disabled: disabled } } return { @@ -245,23 +258,12 @@ _item.children = _item.children.filter(t => t.children !== null) - if (_item.children.length === 0) { - return {children: null} - } - - return _item - } else { - return { - children: null + if (_item.children.length > 0) { + modules.push(_item) } } }) - modules = modules.filter(mod => mod.children !== null) - - if (modules.length === 0) { - return null - } return modules } diff --git a/src/views/appmanage/submutilform/index.jsx b/src/views/appmanage/submutilform/index.jsx index 59809f0..18265b2 100644 --- a/src/views/appmanage/submutilform/index.jsx +++ b/src/views/appmanage/submutilform/index.jsx @@ -138,20 +138,20 @@ initialValue: card ? card.css : 'bg_black_style_blue' })( <Select> - <Select.Option value="bg_black_style_blue"><span className="color-block" style={{background: '#1890ff'}}></span>钃濊壊</Select.Option> - <Select.Option value="bg_black_style_red"><span className="color-block" style={{background: '#f5222d'}}></span>绾㈣壊</Select.Option> - <Select.Option value="bg_black_style_orange_red"><span className="color-block" style={{background: '#fa541c'}}></span>姗欑孩鑹�</Select.Option> - <Select.Option value="bg_black_style_orange"><span className="color-block" style={{background: '#fa8c16'}}></span>姗欒壊</Select.Option> - <Select.Option value="bg_black_style_orange_yellow"><span className="color-block" style={{background: '#faad14'}}></span>姗欓粍鑹�</Select.Option> - <Select.Option value="bg_black_style_yellow"><span className="color-block" style={{background: '#fadb14'}}></span>榛勮壊</Select.Option> - <Select.Option value="bg_black_style_yellow_green"><span className="color-block" style={{background: '#a0d911'}}></span>榛勭豢鑹�</Select.Option> - <Select.Option value="bg_black_style_green"><span className="color-block" style={{background: '#52c41a'}}></span>缁胯壊</Select.Option> - <Select.Option value="bg_black_style_cyan"><span className="color-block" style={{background: '#13c2c2'}}></span>闈掕壊</Select.Option> - <Select.Option value="bg_black_style_blue_purple"><span className="color-block" style={{background: '#2f54eb'}}></span>钃濈传鑹�</Select.Option> - <Select.Option value="bg_black_style_purple"><span className="color-block" style={{background: '#722ed1'}}></span>绱壊</Select.Option> - <Select.Option value="bg_black_style_magenta"><span className="color-block" style={{background: '#eb2f96'}}></span>娲嬬孩鑹�</Select.Option> - <Select.Option value="bg_black_style_grass_green"><span className="color-block" style={{background: '#aeb303'}}></span>鑽夌豢鑹�</Select.Option> - <Select.Option value="bg_black_style_deep_red"><span className="color-block" style={{background: '#c32539'}}></span>娣辩孩鑹�</Select.Option> + <Select.Option value="bg_black_style_blue"><span className="color-block" style={{background: '#1890ff'}}></span>钃濊壊锛�#1890ff锛�</Select.Option> + <Select.Option value="bg_black_style_red"><span className="color-block" style={{background: '#f5222d'}}></span>绾㈣壊锛�#f5222d锛�</Select.Option> + <Select.Option value="bg_black_style_orange_red"><span className="color-block" style={{background: '#fa541c'}}></span>姗欑孩鑹诧紙#fa541c锛�</Select.Option> + <Select.Option value="bg_black_style_orange"><span className="color-block" style={{background: '#fa8c16'}}></span>姗欒壊锛�#fa8c16锛�</Select.Option> + <Select.Option value="bg_black_style_orange_yellow"><span className="color-block" style={{background: '#faad14'}}></span>姗欓粍鑹诧紙#faad14锛�</Select.Option> + <Select.Option value="bg_black_style_yellow"><span className="color-block" style={{background: '#fadb14'}}></span>榛勮壊锛�#fadb14锛�</Select.Option> + <Select.Option value="bg_black_style_yellow_green"><span className="color-block" style={{background: '#a0d911'}}></span>榛勭豢鑹诧紙#a0d911锛�</Select.Option> + <Select.Option value="bg_black_style_green"><span className="color-block" style={{background: '#52c41a'}}></span>缁胯壊锛�#52c41a锛�</Select.Option> + <Select.Option value="bg_black_style_cyan"><span className="color-block" style={{background: '#13c2c2'}}></span>闈掕壊锛�#13c2c2锛�</Select.Option> + <Select.Option value="bg_black_style_blue_purple"><span className="color-block" style={{background: '#2f54eb'}}></span>钃濈传鑹诧紙#2f54eb锛�</Select.Option> + <Select.Option value="bg_black_style_purple"><span className="color-block" style={{background: '#722ed1'}}></span>绱壊锛�#722ed1锛�</Select.Option> + <Select.Option value="bg_black_style_magenta"><span className="color-block" style={{background: '#eb2f96'}}></span>娲嬬孩鑹诧紙#eb2f96锛�</Select.Option> + <Select.Option value="bg_black_style_grass_green"><span className="color-block" style={{background: '#aeb303'}}></span>鑽夌豢鑹诧紙#aeb303锛�</Select.Option> + <Select.Option value="bg_black_style_deep_red"><span className="color-block" style={{background: '#c32539'}}></span>娣辩孩鑹诧紙#c32539锛�</Select.Option> </Select> )} </Form.Item> diff --git a/src/views/tabledesign/index.jsx b/src/views/tabledesign/index.jsx index 3ebbafb..f57afa6 100644 --- a/src/views/tabledesign/index.jsx +++ b/src/views/tabledesign/index.jsx @@ -6,6 +6,7 @@ import HTML5Backend from 'react-dnd-html5-backend' import { ConfigProvider, notification, Modal, Collapse, Card, Switch, Button, Typography } from 'antd' import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons' +import md5 from 'md5' import Api from '@/api' import Utils, { setGLOBFuncs } from '@/utils/utils.js' @@ -24,6 +25,7 @@ const _locale = antdZhCN const MenuForm = asyncComponent(() => import('./menuform')) +const TableNodes = asyncComponent(() => import('@/menu/tablenodes')) const TableSource = asyncComponent(() => import('./tablesource')) const Header = asyncComponent(() => import('@/menu/header')) const MenuShell = asyncComponent(() => import('@/menu/tableshell')) @@ -31,6 +33,7 @@ const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) const ReplaceField = asyncComponent(() => import('@/menu/replaceField')) const Versions = asyncComponent(() => import('@/menu/versions')) +const Unattended = asyncComponent(() => import('@/templates/zshare/unattended')) const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) @@ -392,6 +395,15 @@ config.uuid = MenuId config.MenuID = MenuId config.Template = 'BaseTable' + config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components[0].name = tab.label + }) + } else { + item.name = '涓昏〃' + } + }) } config.open_edition = result.open_edition || '' @@ -412,42 +424,62 @@ }) } - getMenuMessage = (delButtons) => { + getMenuMessage = (delButtons, tbs) => { const { config } = this.state let buttons = [] let _sort = 1 - let traversal = (components) => { - components.forEach(item => { - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - traversal(tab.components) - }) - } else { - item.action && item.action.forEach(btn => { + config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (tab.components[0].$tables) { + tbs.push(...tab.components[0].$tables) + } + tab.components[0].action.forEach(btn => { if (btn.hidden === 'true') { delButtons.push(btn.uuid) return } - buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) + buttons.push(`select '${btn.uuid}' as menuid, '${tab.label + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) _sort++ }) - item.cols && item.cols.forEach(col => { + tab.components[0].cols.forEach(col => { if (col.type !== 'action') return col.elements.forEach(btn => { if (btn.hidden === 'true') { delButtons.push(btn.uuid) return } - buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) + buttons.push(`select '${btn.uuid}' as menuid, '${tab.label + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) _sort++ }) }) + }) + } else { + if (item.$tables) { + tbs.push(...item.$tables) } - }) - } - - traversal(config.components) + item.action.forEach(btn => { + if (btn.hidden === 'true') { + delButtons.push(btn.uuid) + return + } + buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ + }) + item.cols.forEach(col => { + if (col.type !== 'action') return + col.elements.forEach(btn => { + if (btn.hidden === 'true') { + delButtons.push(btn.uuid) + return + } + buttons.push(`select '${btn.uuid}' as menuid, '${btn.label}' as menuname, '${_sort * 10}' as Sort`) + _sort++ + }) + }) + } + }) return buttons } @@ -473,6 +505,38 @@ config.enabled = false } + let tbs = [] + let delButtons = [] + let btns = this.getMenuMessage(delButtons, tbs) + let arr = [] + tbs = tbs.filter(tb => { + let _tb = tb.toLowerCase() + + if (arr.includes(_tb)) return false + arr.push(_tb) + + return true + }) + tbs.sort() + if (tbs.length && sessionStorage.getItem('mk_tb_names')) { + let names = sessionStorage.getItem('mk_tb_names') + tbs = tbs.filter(tb => names.indexOf(',' + tb.toLowerCase() + ',') > -1) + } + tbs = tbs.map(tb => `'${tb}'`).join(';') + + let key = md5(config.uuid + tbs.toLowerCase()) + let url = '' + + if (config.tbkey === key) { + key = '' + } else { + let urlparam = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) + urlparam.type = 'admin' + urlparam.MenuType = 'BaseTable' + url = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) + config.tbkey = key + } + let param = { func: 'sPC_TrdMenu_AddUpt', FstID: config.fstMenuId || '', @@ -484,10 +548,13 @@ Template: 'BaseTable', MenuName: config.MenuName || '', PageParam: JSON.stringify({Template: 'BaseTable', OpenType: config.OpenType || 'newtab', hidden: config.hidden || 'false'}), - LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))), open_edition: config.open_edition, LText: '', - LTexttb: '' + LTexttb: '', + debug_md5: key, + debug_url: url, + debug_list: window.btoa(tbs), + LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))) } param.LText = Utils.formatOptions(param.LText) @@ -505,9 +572,7 @@ LText: [] } - let delButtons = [] - - btnParam.LText = this.getMenuMessage(delButtons) + btnParam.LText = btns btnParam.LText = btnParam.LText.join(' union all ') btnParam.LText = Utils.formatOptions(btnParam.LText) @@ -648,30 +713,24 @@ const { config } = this.state let error = '' - let check = (components) => { - components.forEach(item => { - if (error) return + config.components.forEach(item => { + if (error) return - if (item.type === 'tabs') { - item.subtabs.forEach(tab => { - check(tab.components) + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (!tab.components[0].errors || tab.components[0].errors.length === 0 || error) return + tab.components[0].errors.forEach(err => { + if (err.level !== 0 || error) return + error = `瀛愯〃銆�${tab.label}銆�${err.detail}` }) - return - } else if (item.type === 'group') { - check(item.components) - return - } else if (!item.errors || item.errors.length === 0) { - return - } - + }) + } else { item.errors.forEach(err => { if (err.level !== 0 || error) return - error = `缁勪欢銆�${item.name}銆�${err.detail}` + error = `涓昏〃 ${err.detail}` }) - }) - } - - check(config.components) + } + }) if (show && error) { notification.warning({ @@ -778,7 +837,9 @@ <div style={{paddingLeft: '15px'}}> {config && config.MenuName} </div> } bordered={false} extra={ <div> + {config ? <Unattended config={config} updateConfig={this.updateConfig}/> : null} <Versions MenuId={MenuId} open_edition={config ? config.open_edition : ''}/> + <TableNodes config={config} /> <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/> <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={config && config.enabled} onChange={this.onEnabledChange} /> <Button type="primary" id="save-config" onClick={this.submitConfig} loading={menuloading}>淇濆瓨</Button> diff --git a/src/views/tabledesign/source.jsx b/src/views/tabledesign/source.jsx index 8d9b629..eb8691e 100644 --- a/src/views/tabledesign/source.jsx +++ b/src/views/tabledesign/source.jsx @@ -5,62 +5,52 @@ { type: 'search', label: '鏂囨湰', - subType: 'text', - url: '' + subType: 'text' }, { type: 'search', label: '涓嬫媺閫夋嫨', - subType: 'select', - url: '' + subType: 'select' }, { type: 'search', label: '涓嬫媺澶氶��', - subType: 'multiselect', - url: '' + subType: 'multiselect' }, { type: 'search', label: '鑱斿姩鑿滃崟', - subType: 'link', - url: '' + subType: 'link' }, { type: 'search', label: '閫夐」鍗�', - subType: 'checkcard', - url: '' + subType: 'checkcard' }, { type: 'search', label: '鏃ユ湡锛堝ぉ锛�', - subType: 'date', - url: '' + subType: 'date' }, { type: 'search', label: '鏃ユ湡锛堝懆锛�', - subType: 'dateweek', - url: '' + subType: 'dateweek' }, { type: 'search', label: '鏃ユ湡锛堟湀锛�', - subType: 'datemonth', - url: '' + subType: 'datemonth' }, { type: 'search', label: '鏃ユ湡锛堝尯闂达級', - subType: 'daterange', - url: '' + subType: 'daterange' }, { type: 'search', label: '鏃ユ湡锛堢粍鍚堬級', - subType: 'group', - url: '' + subType: 'group' } ], actionItems: [ @@ -90,6 +80,7 @@ label: '瀵煎叆Excel', text: '瀵煎叆Excel', value: 'excelIn', + class: 'border-dgreen', $init: true }, { @@ -130,46 +121,64 @@ ], columnItems: [ { - type: 'columns', + type: 'col', label: '鏂囨湰', subType: 'text', - url: '' + $init: true }, { - type: 'columns', + type: 'col', label: '鏁板瓧', subType: 'number', - url: '' + $init: true }, { - type: 'columns', + type: 'col', label: '鍥剧墖', subType: 'picture', - url: '' + $init: true }, { - type: 'columns', + type: 'col', label: '閾炬帴', subType: 'link', - url: '' + $init: true }, { - type: 'columns', + type: 'col', label: '澶氳鏂囨湰', subType: 'textarea', - url: '' + $init: true }, { - type: 'columns', + type: 'col', + label: '鑷畾涔夊垪', + subType: 'custom', + $init: true + }, + { + type: 'col', label: '鍚堝苟鍒�', subType: 'colspan', - url: '' + $init: true }, { - type: 'columns', + type: 'col', + label: '鍏紡', + subType: 'formula', + $init: true + }, + { + type: 'col', label: '搴忓彿', subType: 'index', - url: '' + $init: true + }, + { + type: 'col', + label: '鎿嶄綔', + subType: 'action', + $init: true } ], tabItems: [ -- Gitblit v1.8.0