From 8a6ce370f1aa1c061b76fa3e9d2d4d1df53ca4c5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 21 五月 2024 16:38:09 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/components/card/balcony/index.jsx | 130 ++++++++++++++++++++----------------------- 1 files changed, 61 insertions(+), 69 deletions(-) diff --git a/src/menu/components/card/balcony/index.jsx b/src/menu/components/card/balcony/index.jsx index d495918..516c514 100644 --- a/src/menu/components/card/balcony/index.jsx +++ b/src/menu/components/card/balcony/index.jsx @@ -6,7 +6,7 @@ import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' -import { resetStyle, getTables } from '@/utils/utils-custom.js' +import { resetStyle, getTables, checkComponent } from '@/utils/utils-custom.js' import MKEmitter from '@/utils/events.js' import Utils from '@/utils/utils.js' import getWrapForm from './options' @@ -17,7 +17,6 @@ const CardCellComponent = asyncComponent(() => import('../cardcellcomponent')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) const PasteComponent = asyncIconComponent(() => import('@/components/paste')) -const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) const ClockComponent = asyncIconComponent(() => import('@/menu/components/share/clockcomponent')) class BalconyEditComponent extends Component { @@ -46,34 +45,41 @@ name: card.name, subtype: card.subtype, setting: { interType: 'system' }, - wrap: { name: card.name, width: card.width || 24, linkType: 'static', position: 'relative', datatype: 'static' }, - style: { marginLeft: '0px', marginRight: '0px', marginTop: '0px', marginBottom: '0px' }, + wrap: { name: card.name, width: card.width || 24, linkType: 'static', datatype: 'static' }, + style: { marginLeft: '0px', marginRight: '0px', marginTop: '0px', marginBottom: '0px', position: 'unset' }, columns: [], scripts: [], elements: [], } - if (card.config) { - let config = fromJS(card.config).toJS() - - _card.wrap = config.wrap - _card.wrap.name = card.name - _card.style = config.style - - _card.setting = config.setting - _card.columns = config.columns - _card.scripts = config.scripts - - _card.elements = _card.elements.map(elem => { - elem.uuid = Utils.getuuid() - return elem - }) - } - this.updateComponent(_card) } else { + let _card = fromJS(card).toJS() + + if (!_card.style.position) { // 鍏煎 + if (_card.wrap.position === 'fixed' || _card.wrap.position === 'absolute') { + _card.style.position = _card.wrap.position + _card.style.zIndex = _card.wrap.position === 'fixed' ? 3 : 2 + _card.style.left = _card.wrap.left || '' + _card.style.right = _card.wrap.right || '' + _card.style.top = _card.wrap.top || '' + _card.style.bottom = _card.wrap.bottom || '' + _card.style.transform = _card.wrap.transform || '' + _card.style.width = _card.wrap.realwidth || '' + } else if (_card.wrap.left || _card.wrap.right || _card.wrap.top || _card.wrap.bottom) { + _card.style.position = 'relative' + _card.style.zIndex = 1 + _card.style.left = _card.wrap.left || '' + _card.style.right = _card.wrap.right || '' + _card.style.top = _card.wrap.top || '' + _card.style.bottom = _card.wrap.bottom || '' + } else { + _card.style.position = 'unset' + } + } + this.setState({ - card: fromJS(card).toJS() + card: _card }) } } @@ -126,51 +132,15 @@ return } - card.errors = [] + card.$c_ds = card.wrap.datatype === 'dynamic' + card.$c_ac = false + card.$c_sc = false + card.$c_el = true + + card.errors = checkComponent(card) - if (card.wrap.datatype === 'static') { - card.elements.forEach(cell => { - if (cell.eleType === 'button') { - 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 if (cell.datatype === 'dynamic' && cell.field) { - card.errors.push({ level: 1, detail: `鍗$墖涓姩鎬佸瓧娈碘��${cell.field}鈥濇棤鏁坄}) - } - }) + if (card.errors.length === 0) { card.$tables = getTables(card) - } else { - let columns = card.columns.map(c => c.field) - - if (card.wrap.datatype === 'dynamic') { - 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: '涓婚敭宸插け鏁堬紒'}) - } - } - - if (card.errors.length === 0) { - card.$tables = getTables(card) - } - - card.elements.forEach(cell => { - if (cell.eleType === 'button') { - 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 if (cell.datatype === 'dynamic' && cell.field && !columns.includes(cell.field)) { - card.errors.push({ level: 1, detail: `鍗$墖涓姩鎬佸瓧娈碘��${cell.field}鈥濇棤鏁坄}) - } - }) } this.setState({ @@ -191,7 +161,7 @@ changeStyle = () => { const { card } = this.state - MKEmitter.emit('changeStyle', ['height', 'background', 'border', 'padding', 'margin', 'shadow', 'clear', 'minHeight'], card.style, this.getStyle) + MKEmitter.emit('changeStyle', ['width', 'height', 'background', 'border', 'padding', 'margin', 'shadow', 'clear', 'minHeight', 'position', 'transform'], card.style, this.getStyle) } getStyle = (style) => { @@ -210,6 +180,10 @@ newcard.eleType = 'text' newcard.datatype = 'dynamic' newcard.height = 1 + + if (card.wrap.datatype === 'static') { + newcard.datatype = 'static' + } // 娉ㄥ唽浜嬩欢-娣诲姞鍏冪礌 MKEmitter.emit('cardAddElement', card.uuid, newcard) @@ -239,6 +213,7 @@ MKEmitter.emit('cardAddElement', card.uuid, res) } else { res.eleType = 'button' + res.width = res.width || 12 MKEmitter.emit('cardAddElement', card.uuid, res) } resolve({status: true}) @@ -263,6 +238,8 @@ updateWrap = (res) => { delete res.quick + res.linkType = res.linkType || 'static' + let _card = {...this.state.card, wrap: res} if (res.datatype === 'public') { @@ -272,6 +249,22 @@ if (d) { _card.columns = fromJS(d.columns).toJS() + + _card.setting = { interType: 'system' } + _card.scripts = [] + } + } + + if (_card.wrap.position === 'fixed') { + if (_card.wrap.top && _card.wrap.bottom && _card.wrap.top.indexOf('vh') > -1 && _card.wrap.bottom.indexOf('vh') > -1) { + if (parseFloat(_card.wrap.top) + parseFloat(_card.wrap.bottom) >= 100) { + message.warning('鍏冪礌璺濅笂璺濅笅涔嬪拰瓒呭嚭100%锛屽彲鑳藉鑷村厓绱犳棤娉曟樉绀恒��') + } + } + if (_card.wrap.left && _card.wrap.right && _card.wrap.left.indexOf('vw') > -1 && _card.wrap.right.indexOf('vw') > -1) { + if (parseFloat(_card.wrap.left) + parseFloat(_card.wrap.right) >= 100) { + message.warning('鍏冪礌璺濆乏璺濆彸涔嬪拰瓒呭嚭100%锛屽彲鑳藉鑷村厓绱犳棤娉曟樉绀恒��') + } } } @@ -290,14 +283,13 @@ <div className="mk-popover-control"> <PlusOutlined className="plus" title="娣诲姞鍏冪礌" onClick={this.addElement} /> <PlusSquareOutlined className="plus" title="娣诲姞鎸夐挳" onClick={this.addButton} /> - <NormalForm title="娴姩鍗¤缃�" width={850} update={this.updateWrap} getForms={this.getWrapForms}> + <NormalForm title="娴姩鍗¤缃�" width={900} update={this.updateWrap} getForms={this.getWrapForms}> <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/> </NormalForm> <CopyComponent type="balcony" card={card}/> <PasteComponent options={['action', 'customCardElement']} updateConfig={this.pasteComponent} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} /> {card.wrap.datatype === 'dynamic' ? <ClockComponent config={card} updateConfig={this.updateComponent}/> : <ClockCircleOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}}/>} - <UserComponent config={card}/> <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> {card.wrap.datatype === 'dynamic' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : <SettingOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}}/>} </div> @@ -310,7 +302,7 @@ <div className="center"> <div className="title" onDoubleClick={() => { let oInput = document.createElement('input') - oInput.value = card.uuid + oInput.value = 'anchor' + card.uuid document.body.appendChild(oInput) oInput.select() document.execCommand('Copy') -- Gitblit v1.8.0