From 27d6ff04382d95f360e4dc18769a9bd36dfca4b4 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 03 六月 2024 15:08:16 +0800 Subject: [PATCH] 2024-06-03 --- src/menu/components/search/main-search/index.jsx | 133 ++++++++++++++++++++------------------------ 1 files changed, 60 insertions(+), 73 deletions(-) diff --git a/src/menu/components/search/main-search/index.jsx b/src/menu/components/search/main-search/index.jsx index d6250e4..07a0c93 100644 --- a/src/menu/components/search/main-search/index.jsx +++ b/src/menu/components/search/main-search/index.jsx @@ -1,14 +1,14 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Modal, notification, Popover, Switch } from 'antd' +import { Modal, notification, Popover, Switch, message } from 'antd' import { PlusOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons' -import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.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' @@ -50,8 +50,6 @@ let _card = { uuid: card.uuid, type: card.type, - tabId: card.tabId || '', - parentId: card.parentId || '', width: 24, name: card.name, subtype: card.subtype, @@ -97,42 +95,44 @@ card: _card }) - this.props.updateConfig(_card) + this.updateComponent(_card) } changeStyle = () => { const { card } = this.state - MKEmitter.emit('changeStyle', ['background', 'border', 'padding', 'margin', 'shadow'], card.style, this.getStyle) + 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) } - checkComponent = (component) => { - this.updateComponent(component) + // checkComponent = (component) => { + // this.updateComponent(component) - let _item = null - component.search.forEach(item => { - if (!_item && item.focus) { - _item = item - } - }) - if (_item) { - this.handleSearch(_item) - } - } + // let _item = null + // component.search.forEach(item => { + // if (!_item && item.focus) { + // _item = item + // } + // }) + // if (_item) { + // this.handleSearch(_item) + // } + // } /** * @description 鎼滅储鏉′欢椤哄簭璋冩暣锛屾垨鎷栨嫿娣诲姞 @@ -145,9 +145,7 @@ this.setState({card: _card}) this.handleSearch(newcell) } else { - this.setState({card: _card}, ()=> { - this.props.updateConfig(_card) - }) + this.updateComponent(_card) } } @@ -208,7 +206,6 @@ this.searchFormRef.handleConfirm().then(res => { let fieldrepet = false // 瀛楁閲嶅 - let labelrepet = false // 鎻愮ず鏂囧瓧閲嶅 card.search = card.search.map(item => { // 鏁版嵁鏇存柊鍙婇噸澶嶆娴� if (item.uuid !== res.uuid && res.field && item.field) { @@ -234,8 +231,6 @@ if (setFields.length < itemFields.length + resFields.length && (res.type !== 'date' || item.type !== 'date')) { fieldrepet = true - } else if (item.label === res.label) { - labelrepet = true } } @@ -253,13 +248,6 @@ duration: 5 }) return - } else if (labelrepet) { - notification.warning({ - top: 92, - message: '鍚嶇О宸插瓨鍦�!', - duration: 5 - }) - return } if (['select', 'multiselect', 'link', 'checkcard'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) { @@ -267,30 +255,22 @@ sqlVerifing: true }) - let param = { - func: 's_debug_sql', - exec_type: 'y', - LText: res.dataSource - } + let sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20) + ${res.dataSource}` + sql = sql.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 = Utils.formatOptions(param.LText) - param.secretkey = Utils.encrypt('', param.timestamp) - + let rduri = '' if (window.GLOB.mainSystemApi && res.database === 'sso') { - param.rduri = window.GLOB.mainSystemApi + rduri = window.GLOB.mainSystemApi } - Api.genericInterface(param).then(result => { - if (result.status) { + Api.sDebug(sql, rduri).then(result => { + if (result.status || result.ErrCode === '-2') { this.setState({ - card: card, sqlVerifing: false, visible: false }, ()=> { - this.props.updateConfig(card) + this.updateComponent(card) }) } else { this.setState({sqlVerifing: false}) @@ -302,10 +282,9 @@ }) } else { this.setState({ - card: card, visible: false }, ()=> { - this.props.updateConfig(card) + this.updateComponent(card) }) } }) @@ -323,11 +302,7 @@ 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() {} }) @@ -369,25 +344,20 @@ if (type === 'simple') { _card.search.push(item) - this.setState({ - card: _card, - }, () => { - this.props.updateConfig(_card) - }) + + this.updateComponent(_card) + this.handleSearch(item) } else if (type === 'multil') { _card.search.push(...item) - this.setState({ - card: _card, - }, () => { - this.props.updateConfig(_card) - }) + + this.updateComponent(_card) } } getWrapForms = () => { - const { wrap, action } = this.state.card + const { card } = this.state - return getWrapForm(wrap, action) + return getWrapForm(card.wrap, card.uuid) } updateWrap = (res) => { @@ -397,7 +367,12 @@ 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) + }) } } @@ -406,7 +381,7 @@ let _style = resetStyle(card.style) return ( - <div className={`main-search-edit-list ${card.wrap.float} ${showField ? 'show-field' : ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}> + <div className={`main-search-edit-list ${card.wrap.float} ${showField ? 'show-field' : ''} mk-size-${card.wrap.searchSize || ''}`} onClick={this.clickComponent} id={card.uuid} style={_style}> <FieldsComponent config={card} type="search" /> <Switch checkedChildren="寮�" size="small" unCheckedChildren="鍏�" defaultChecked={showField} onChange={this.onFieldChange} /> <DragElement @@ -423,17 +398,29 @@ <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/> </NormalForm> <CopyComponent type="mainsearch" card={card}/> - <PasteComponent config={card} options={['search', 'form']} updateConfig={this.checkComponent} /> + {/* <PasteComponent config={card} options={['search', 'form']} updateConfig={this.checkComponent} /> */} + <PasteComponent config={card} options={['search', 'form']} /> <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> <DeleteOutlined className="close" onClick={() => this.props.deletecomponent(card.uuid)} /> </div> } trigger="hover"> <ToolOutlined /> </Popover> - <div className="component-name"><div className="center">{card.name}</div></div> + <div className="component-name"> + <div className="center" onDoubleClick={() => { + let oInput = document.createElement('input') + oInput.value = 'anchor' + card.uuid + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + document.body.removeChild(oInput) + message.success('澶嶅埗鎴愬姛銆�') + }}>{card.name}</div> + </div> {/* 缂栬緫鎼滅储鏉′欢 */} <Modal title="鎼滅储鏉′欢-缂栬緫" + wrapClassName="mk-scroll-modal" visible={visible} width={850} maskClosable={false} -- Gitblit v1.8.0