From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 09 十二月 2022 15:53:32 +0800 Subject: [PATCH] 2022-12-09 --- src/menu/components/search/main-search/index.jsx | 87 +++++++++++++++++-------------------------- 1 files changed, 35 insertions(+), 52 deletions(-) diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx index c44b673..8741554 100644 --- a/src/menu/components/search/main-search/index.jsx +++ b/src/menu/components/search/main-search/index.jsx @@ -7,10 +7,9 @@ import Api from '@/api' import Utils from '@/utils/utils.js' -import zhCN from '@/locales/zh-CN/model.js' -import enUS from '@/locales/en-US/model.js' import { getSearchForm } from '@/templates/zshare/formconfig' import { resetStyle } from '@/utils/utils-custom.js' +import { getTables } from '@/utils/utils-custom.js' import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' import DragElement from './dragsearch' @@ -34,7 +33,6 @@ } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, appType: sessionStorage.getItem('appType'), searchlist: null, // 鎼滅储鏉′欢闆� sqlVerifing: false, // sql楠岃瘉涓� @@ -53,8 +51,6 @@ let _card = { uuid: card.uuid, type: card.type, - tabId: card.tabId || '', - parentId: card.parentId || '', width: 24, name: card.name, subtype: card.subtype, @@ -76,7 +72,6 @@ } componentDidMount () { - MKEmitter.addListener('submitStyle', this.getStyle) MKEmitter.addListener('plusSearch', this.plusSearch) } @@ -87,7 +82,6 @@ this.setState = () => { return } - MKEmitter.removeListener('submitStyle', this.getStyle) MKEmitter.removeListener('plusSearch', this.plusSearch) } @@ -95,36 +89,34 @@ return !is(fromJS(this.state), fromJS(nextState)) } - getStyle = (comIds, style) => { - const { card } = this.state - - if (comIds.length !== 1 || comIds[0] !== card.uuid) return - - let _card = {...card, style} + getStyle = (style) => { + let _card = {...this.state.card, style} this.setState({ card: _card }) - this.props.updateConfig(_card) + this.updateComponent(_card) } changeStyle = () => { const { card } = this.state - MKEmitter.emit('changeStyle', [card.uuid], ['background', 'border', 'padding', 'margin', 'shadow'], card.style) + MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow', 'clear'], card.style, this.getStyle) } /** * @description 鍗$墖琛屽灞備俊鎭洿鏂帮紙鏁版嵁婧愶紝鏍峰紡绛夛級 */ updateComponent = (component) => { - this.setState({ - card: component - }) + component.$tables = getTables(component) component.width = component.wrap.width component.name = component.wrap.name + + this.setState({ + card: component + }) this.props.updateConfig(component) } @@ -154,9 +146,7 @@ this.setState({card: _card}) this.handleSearch(newcell) } else { - this.setState({card: _card}, ()=> { - this.props.updateConfig(_card) - }) + this.updateComponent(_card) } } @@ -168,7 +158,7 @@ let linkableFields = [] card.search.forEach(item => { - if (item.uuid === card.uuid) return + if (item.uuid === cell.uuid) return if (!['select', 'link', 'checkcard'].includes(item.type)) return if (item.type === 'checkcard' && item.multiple === 'true') return @@ -282,24 +272,24 @@ LText: res.dataSource } - param.LText = param.LText.replace(/@\$|\$@/ig, '') + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${param.timestamp}'`) + param.LText = param.LText.replace(/\n/g, ' ') param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) if (window.GLOB.mainSystemApi && res.database === 'sso') { param.rduri = window.GLOB.mainSystemApi } - Api.getLocalConfig(param).then(result => { + Api.genericInterface(param).then(result => { if (result.status) { this.setState({ - card: card, sqlVerifing: false, visible: false }, ()=> { - this.props.updateConfig(card) + this.updateComponent(card) }) } else { this.setState({sqlVerifing: false}) @@ -311,10 +301,9 @@ }) } else { this.setState({ - card: card, visible: false }, ()=> { - this.props.updateConfig(card) + this.updateComponent(card) }) } }) @@ -324,20 +313,15 @@ * @description 鎼滅储鏉′欢鍒犻櫎 */ deleteElement = (cell) => { - const { dict } = this.state let _this = this confirm({ - content: dict['model.confirm'] + dict['model.delete'] + ` - ${cell.label} 锛焋, + content: `纭畾鍒犻櫎 - ${cell.label} 锛焋, onOk() { let _card = fromJS(_this.state.card).toJS() _card.search = _card.search.filter(item => item.uuid !== cell.uuid) - _this.setState({ - card: _card - }, () => { - _this.props.updateConfig(_card) - }) + _this.updateComponent(_card) }, onCancel() {} }) @@ -379,18 +363,12 @@ if (type === 'simple') { _card.search.push(item) - this.setState({ - card: _card, - }, () => { - this.props.updateConfig(_card) - }) + + this.updateComponent(_card) } else if (type === 'multil') { _card.search.push(...item) - this.setState({ - card: _card, - }, () => { - this.props.updateConfig(_card) - }) + + this.updateComponent(_card) } } @@ -407,21 +385,26 @@ clickComponent = (e) => { if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') { e.stopPropagation() - MKEmitter.emit('clickComponent', this.state.card) + MKEmitter.emit('clickComponent', this.state.card.uuid, null, (style) => { + let _card = {...this.state.card} + _card.style = {..._card.style, ...style} + + this.updateComponent(_card) + }) } } render() { - const { dict, card, visible, sqlVerifing, showField } = this.state + const { card, visible, sqlVerifing, showField } = this.state let _style = resetStyle(card.style) return ( - <div className={`main-search-edit-list ${card.wrap.float} ${card.wrap.show || ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}> + <div className={`main-search-edit-list ${card.wrap.float} ${showField ? 'show-field' : ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}> <FieldsComponent config={card} type="search" /> - <Switch checkedChildren={dict['model.switch.open']} size="small" unCheckedChildren={dict['model.switch.close']} defaultChecked={showField} onChange={this.onFieldChange} /> + <Switch checkedChildren="寮�" size="small" unCheckedChildren="鍏�" defaultChecked={showField} onChange={this.onFieldChange} /> <DragElement list={card.search} - showField={showField} + setting={card.wrap} handleList={this.handleList} handleMenu={this.handleSearch} deleteMenu={this.deleteElement} @@ -440,6 +423,7 @@ } trigger="hover"> <ToolOutlined /> </Popover> + <div className="component-name"><div className="center">{card.name}</div></div> {/* 缂栬緫鎼滅储鏉′欢 */} <Modal title="鎼滅储鏉′欢-缂栬緫" @@ -452,7 +436,6 @@ destroyOnClose > <SearchForm - dict={dict} card={this.state.editcard} formlist={this.state.formlist} inputSubmit={this.handleSubmit} -- Gitblit v1.8.0