From e8edfdadb561cd83bf6e1c3e00d55b8cc2aee6d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 17 十月 2022 17:57:34 +0800 Subject: [PATCH] 2022-10-17 --- src/menu/components/table/edit-table/index.jsx | 51 +++++++++++++-------------------------------------- 1 files changed, 13 insertions(+), 38 deletions(-) diff --git a/src/menu/components/table/edit-table/index.jsx b/src/menu/components/table/edit-table/index.jsx index 8e5ee1d..029fcd2 100644 --- a/src/menu/components/table/edit-table/index.jsx +++ b/src/menu/components/table/edit-table/index.jsx @@ -6,12 +6,10 @@ import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' -import { resetStyle } from '@/utils/utils-custom.js' +import { resetStyle, getTables } from '@/utils/utils-custom.js' import MKEmitter from '@/utils/events.js' import getWrapForm from './options' import Utils from '@/utils/utils.js' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' import './index.scss' @@ -33,7 +31,6 @@ } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, appType: sessionStorage.getItem('appType'), card: null, back: false @@ -51,7 +48,6 @@ format: 'array', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 pageable: true, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� switchable: false, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� - dataName: card.dataName || '', width: card.width || 24, search: [], action: [], @@ -68,7 +64,6 @@ { origin: true, uuid: Utils.getuuid(), Align: 'left', label: 'label3', field: '', Hide: 'false', IsSort: 'true', type: 'text', Width: 120 }, ], scripts: [], - btnlog: [], submit: {intertype: 'system', default: 'true', innerFunc: '', execSuccess: 'grid', execError: 'never', scripts: [], uniques: []}, isNew: true } @@ -126,7 +121,6 @@ } componentDidMount () { - MKEmitter.addListener('submitStyle', this.getStyle) MKEmitter.addListener('submitModal', this.handleSave) MKEmitter.addListener('completeSave', this.completeSave) } @@ -142,7 +136,6 @@ this.setState = () => { return } - MKEmitter.removeListener('submitStyle', this.getStyle) MKEmitter.removeListener('submitModal', this.handleSave) MKEmitter.removeListener('completeSave', this.completeSave) } @@ -169,37 +162,29 @@ if (!window.GLOB.styling || !card.errors) { // 鏍峰紡淇敼鏃朵笉鍋氱瓫鏌� card.errors = [] - + + let columns = card.columns.map(c => c.field) + if (card.setting.interType === 'system' && card.setting.execute !== 'false' && !card.setting.dataresource) { card.errors.push({ level: 0, detail: '鏈缃暟鎹簮锛�'}) } else if (card.setting.interType === 'system' && card.setting.execute === 'false' && card.scripts.filter(script => script.status !== 'false').length === 0) { card.errors.push({ level: 0, detail: '鏁版嵁婧愪腑鏃犲彲鐢ㄨ剼鏈紒'}) } else if (!card.setting.primaryKey) { card.errors.push({ level: 0, detail: '鏈缃富閿紒'}) + } else if (!columns.includes(card.setting.primaryKey)) { + card.errors.push({ level: 0, detail: '涓婚敭宸插け鏁堬紒'}) } else if (!card.setting.supModule) { card.errors.push({ level: 0, detail: '鏈缃笂绾х粍浠讹紒'}) } - - let supModule = card.setting.supModule ? card.setting.supModule[card.setting.supModule.length - 1] || '' : '' - if (supModule === 'empty') { - supModule = '' + + if (card.errors.length === 0) { + card.$tables = getTables(card) } - - let columns = card.columns.map(c => c.field) - let lowcols = card.columns.map(c => c.field.toLowerCase()) card.action.forEach(cell => { if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { if (!cell.modal || cell.modal.fields.length === 0) { card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`}) - } else { - cell.modal.fields.forEach(m => { - if (m.type === 'linkMain' && !supModule) { - card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑鍏宠仈涓昏〃琛ㄥ崟鈥�${m.label}鈥濇棤鏁坄}) - } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) { - card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟鈥�${m.label}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻}) - } - }) } } }) @@ -210,14 +195,6 @@ if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { if (!cell.modal || cell.modal.fields.length === 0) { card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`}) - } else { - cell.modal.fields.forEach(m => { - if (m.type === 'linkMain' && !supModule) { - card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑鍏宠仈涓昏〃琛ㄥ崟鈥�${m.label}鈥濇棤鏁坄}) - } else if (m.field && !columns.includes(m.field) && lowcols.includes(m.field.toLowerCase())) { - card.errors.push({ level: 1, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟鈥�${m.label}鈥濆ぇ灏忓啓涓庡瓧娈甸泦涓嶄竴鑷碻}) - } - }) } } }) @@ -255,13 +232,11 @@ style.fontSize = card.wrap.fontSize || 14 style.fontWeight = card.wrap.fontWeight || 'normal' - MKEmitter.emit('changeStyle', [card.uuid], ['font1', 'background', 'border', 'padding', 'margin', 'shadow'], style) + MKEmitter.emit('changeStyle', ['font1', 'background', 'border', 'padding', 'margin', 'shadow'], style, this.getStyle) } - getStyle = (comIds, style) => { + getStyle = (style) => { const { card } = this.state - - if (comIds[0] !== card.uuid || comIds.length !== 1) return let _card = fromJS(card).toJS() let _style = fromJS(style).toJS() @@ -404,7 +379,7 @@ let _style = resetStyle(card.style) return ( - <div className="menu-normal-table-edit-box" style={_style} onClick={this.clickComponent} id={card.uuid}> + <div className="menu-editable-table-edit-box" style={_style} onClick={this.clickComponent} id={card.uuid}> <NormalHeader hideSearch="true" config={card} updateComponent={this.updateComponent}/> <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ <div className="mk-popover-control"> @@ -425,7 +400,7 @@ <ToolOutlined /> </Popover> <SearchComponent config={card} updatesearch={this.updateComponent}/> - <ActionComponent type="editable" config={card} setSubConfig={this.setSubConfig} updateaction={this.updateComponent}/> + <ActionComponent config={card} setSubConfig={this.setSubConfig} updateaction={this.updateComponent}/> <ColumnComponent config={card} updatecolumn={this.updateComponent}/> <div className="component-name"> <div className="center"> -- Gitblit v1.8.0