From 2f54651464414059b224181d713af2980e76d095 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 09 十月 2022 19:35:39 +0800 Subject: [PATCH] 2020-10-09 --- src/tabviews/custom/components/interfaces/index.scss | 0 src/templates/zshare/modalform/index.jsx | 11 src/menu/components/card/balcony/index.jsx | 52 ++ src/tabviews/custom/components/card/prop-card/index.jsx | 36 ++ src/tabviews/debugtable/index.jsx | 8 src/menu/components/card/data-card/options.jsx | 17 src/templates/zshare/formconfig.jsx | 47 +- src/menu/components/card/cardcellcomponent/index.scss | 3 src/tabviews/custom/components/interfaces/interItem/index.scss | 0 src/tabviews/custom/components/interfaces/interItem/index.jsx | 73 ++++ src/menu/components/card/balcony/options.jsx | 30 + src/templates/zshare/verifycard/customscript/index.jsx | 2 src/tabviews/zshare/mutilform/index.jsx | 84 +--- src/menu/components/table/edit-table/columns/index.scss | 6 src/tabviews/custom/index.jsx | 319 ++++++------------ src/tabviews/custom/components/card/balcony/index.jsx | 42 + src/menu/components/table/normal-table/columns/index.scss | 5 src/tabviews/custom/components/interfaces/index.jsx | 37 ++ src/menu/components/card/prop-card/index.jsx | 50 ++ src/assets/css/design.scss | 1 src/tabviews/zshare/actionList/normalbutton/index.jsx | 147 ++++--- src/menu/sysinterface/index.jsx | 6 src/utils/utils.js | 35 - 23 files changed, 586 insertions(+), 425 deletions(-) diff --git a/src/assets/css/design.scss b/src/assets/css/design.scss index 75dd933..5d11010 100644 --- a/src/assets/css/design.scss +++ b/src/assets/css/design.scss @@ -4,6 +4,7 @@ } .ant-modal-body { padding: 0; + min-height: 150px; .mk-com-name { position: absolute; diff --git a/src/menu/components/card/balcony/index.jsx b/src/menu/components/card/balcony/index.jsx index 10dd11e..0fc9a44 100644 --- a/src/menu/components/card/balcony/index.jsx +++ b/src/menu/components/card/balcony/index.jsx @@ -85,12 +85,31 @@ return !is(fromJS(this.state), fromJS(nextState)) } + componentDidMount () { + MKEmitter.addListener('mkUpdateInter', this.mkUpdateInter) + } + /** * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 */ componentWillUnmount () { this.setState = () => { return + } + MKEmitter.removeListener('mkUpdateInter', this.mkUpdateInter) + } + + mkUpdateInter = (inter, split) => { + const { card } = this.state + + if (card.wrap.datatype === 'public' && card.wrap.publicId === inter.uuid) { + let _card = {...card, columns: fromJS(inter.columns).toJS()} + + split.delay = split.delay + 10 + + setTimeout(() => { + this.updateComponent(_card) + }, split.delay) } } @@ -128,14 +147,16 @@ } else { 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: '涓婚敭宸插け鏁堬紒'}) + 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) { @@ -234,7 +255,20 @@ updateWrap = (res) => { delete res.quick - this.updateComponent({...this.state.card, wrap: res}) + + let _card = {...this.state.card, wrap: res} + + if (res.datatype === 'public') { + let interfaces = window.GLOB.customMenu.interfaces || [] + + let d = interfaces.filter(m => m.uuid === res.publicId && m.status === 'true')[0] + + if (d) { + _card.columns = fromJS(d.columns).toJS() + } + } + + this.updateComponent(_card) } render() { diff --git a/src/menu/components/card/balcony/options.jsx b/src/menu/components/card/balcony/options.jsx index aab6ad8..c39fa7b 100644 --- a/src/menu/components/card/balcony/options.jsx +++ b/src/menu/components/card/balcony/options.jsx @@ -6,10 +6,24 @@ * @description Wrap琛ㄥ崟閰嶇疆淇℃伅 */ export default function (wrap) { - let modules = MenuUtils.getLinkModules(fromJS(window.GLOB.customMenu).toJS().components) || [] - let supmodules = MenuUtils.getSupModules(fromJS(window.GLOB.customMenu).toJS().components, '') || [] + let menu = fromJS(window.GLOB.customMenu).toJS() + + let modules = MenuUtils.getLinkModules(menu.components) || [] + let supmodules = MenuUtils.getSupModules(menu.components, '') || [] let roleList = sessionStorage.getItem('sysRoles') let appType = sessionStorage.getItem('appType') + + let interfaces = [] + if (menu.interfaces) { + menu.interfaces.forEach(item => { + if (item.status === 'true') { + interfaces.push({ + value: item.uuid, + label: item.name + }) + } + }) + } if (roleList) { try { @@ -51,12 +65,22 @@ options: [ {value: 'dynamic', label: '鍔ㄦ��'}, {value: 'static', label: '闈欐��'}, + {value: 'public', label: '鍏叡鏁版嵁婧�'}, ], controlFields: [ - {field: 'empty', values: ['dynamic']} + {field: 'empty', values: ['dynamic']}, + {field: 'publicId', values: ['public']}, ] }, { + type: 'select', + field: 'publicId', + label: '鏁版嵁婧�', + initval: wrap.publicId || '', + required: true, + options: interfaces + }, + { type: 'radio', field: 'linkType', label: '鍙楁帶绫诲瀷', diff --git a/src/menu/components/card/cardcellcomponent/index.scss b/src/menu/components/card/cardcellcomponent/index.scss index 30af64f..e97d0e2 100644 --- a/src/menu/components/card/cardcellcomponent/index.scss +++ b/src/menu/components/card/cardcellcomponent/index.scss @@ -3,6 +3,9 @@ .ant-btn { padding: 0; } + .card-detail-row { + min-height: 16px; + } .card-button-cell { float: left; diff --git a/src/menu/components/card/data-card/options.jsx b/src/menu/components/card/data-card/options.jsx index 7297108..3733162 100644 --- a/src/menu/components/card/data-card/options.jsx +++ b/src/menu/components/card/data-card/options.jsx @@ -9,12 +9,17 @@ let MenuType = '' let menu = fromJS(window.GLOB.customMenu).toJS() let laypage = setting && setting.laypage !== 'false' - let interfaces = (menu.interfaces || []).map(item => { - return { - value: item.uuid, - label: item.name - } - }) + let interfaces = [] + if (subtype === 'propcard' && menu.interfaces) { + menu.interfaces.forEach(item => { + if (item.status === 'true') { + interfaces.push({ + value: item.uuid, + label: item.name + }) + } + }) + } if (menu.parentId === 'BillPrintTemp') { MenuType = 'billPrint' diff --git a/src/menu/components/card/prop-card/index.jsx b/src/menu/components/card/prop-card/index.jsx index 2876dc8..e79cbe6 100644 --- a/src/menu/components/card/prop-card/index.jsx +++ b/src/menu/components/card/prop-card/index.jsx @@ -107,6 +107,7 @@ } componentDidMount () { + MKEmitter.addListener('mkUpdateInter', this.mkUpdateInter) MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) } @@ -121,6 +122,7 @@ this.setState = () => { return } + MKEmitter.removeListener('mkUpdateInter', this.mkUpdateInter) MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) } @@ -139,6 +141,20 @@ this.setState({card: {...card, subcards: []}}, () => { this.updateComponent({...card, subcards: subcards}) }) + } + + mkUpdateInter = (inter, split) => { + const { card } = this.state + + if (card.wrap.datatype === 'public' && card.wrap.publicId === inter.uuid) { + let _card = {...card, columns: fromJS(inter.columns).toJS()} + + split.delay = split.delay + 10 + + setTimeout(() => { + this.updateComponent(_card) + }, split.delay) + } } /** @@ -208,22 +224,20 @@ } }) } else { - // if (card.wrap.datatype === 'dynamic') { - - // } - 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: '鏈缃笂绾х粍浠讹紒'}) + 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: '涓婚敭宸插け鏁堬紒'}) + } else if (!card.setting.supModule) { + card.errors.push({ level: 0, detail: '鏈缃笂绾х粍浠讹紒'}) + } } if (card.errors.length === 0) { @@ -489,7 +503,13 @@ _card.setting.supModule = '' } } else if (res.datatype === 'public') { - // let interfaces = window.GLOB.customMenu.interfaces || [] + let interfaces = window.GLOB.customMenu.interfaces || [] + + let d = interfaces.filter(m => m.uuid === res.publicId && m.status === 'true')[0] + + if (d) { + _card.columns = fromJS(d.columns).toJS() + } } if (res.layout === 'flex') { diff --git a/src/menu/components/table/edit-table/columns/index.scss b/src/menu/components/table/edit-table/columns/index.scss index 3426cb2..6ca33c7 100644 --- a/src/menu/components/table/edit-table/columns/index.scss +++ b/src/menu/components/table/edit-table/columns/index.scss @@ -75,12 +75,6 @@ } } - .model-menu-card-cell-list { - .card-detail-row { - min-height: 21px; - } - } - .ant-table-thead { th { position: relative; diff --git a/src/menu/components/table/normal-table/columns/index.scss b/src/menu/components/table/normal-table/columns/index.scss index 9e88629..db07412 100644 --- a/src/menu/components/table/normal-table/columns/index.scss +++ b/src/menu/components/table/normal-table/columns/index.scss @@ -65,11 +65,6 @@ background: #ffffff!important; } } - .model-menu-card-cell-list { - .card-detail-row { - min-height: 21px; - } - } .ant-table-thead { th { diff --git a/src/menu/sysinterface/index.jsx b/src/menu/sysinterface/index.jsx index 797dc2c..c24c4b0 100644 --- a/src/menu/sysinterface/index.jsx +++ b/src/menu/sysinterface/index.jsx @@ -6,6 +6,7 @@ import Utils from '@/utils/utils.js' import asyncComponent from '@/utils/asyncComponent' +import MKEmitter from '@/utils/events.js' import './index.scss' const DataSource = asyncComponent(() => import('@/menu/datasource')) @@ -180,8 +181,13 @@ return record }) + this.setState({ interfaces }) this.props.updateConfig({...config, interfaces}) + + setTimeout(() => { + MKEmitter.emit('mkUpdateInter', record, {delay: 0}) + }, 10) } addInterface = () => { diff --git a/src/tabviews/custom/components/card/balcony/index.jsx b/src/tabviews/custom/components/card/balcony/index.jsx index 19ec765..e9aa506 100644 --- a/src/tabviews/custom/components/card/balcony/index.jsx +++ b/src/tabviews/custom/components/card/balcony/index.jsx @@ -54,9 +54,9 @@ _sync = _config.setting.sync === 'true' if (_sync && data) { - _data = data[_config.dataName] || {} + _data = data[_config.dataName] || {$$empty: true} if (_data && Array.isArray(_data)) { - _data = _data[0] || {} + _data = _data[0] || {$$empty: true} } _sync = false } else if (_sync && initdata) { @@ -66,10 +66,15 @@ } _sync = false } + } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { + _data = window.GLOB.CacheData.get(_config.wrap.publicId) + _data = fromJS(_data).toJS() } - if (_data) { - _data.$$BID = BID || '' + _data.$$BID = BID || '' + _data.$$BData = BData || '' + if (_config.setting.primaryKey) { + _data.$$uuid = _data[_config.setting.primaryKey] || '' } if (_config.wrap.position === 'fixed' || _config.wrap.position === 'absolute') { @@ -129,6 +134,10 @@ MKEmitter.addListener('resetSelectLine', this.resetParentParam) MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + + if (config.wrap.datatype === 'public') { + MKEmitter.addListener('mkPublicData', this.mkPublicData) + } if (config.timer && config.wrap.datatype === 'dynamic') { this.timer = new TimerTask() @@ -145,6 +154,7 @@ return } MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('mkPublicData', this.mkPublicData) MKEmitter.removeListener('syncBalconyData', this.syncBalconyData) MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) @@ -157,25 +167,39 @@ * @description 鍥捐〃鏁版嵁鏇存柊锛屽埛鏂板唴瀹� */ UNSAFE_componentWillReceiveProps (nextProps) { - const { sync, config, BID } = this.state + const { sync, config, BID, BData } = this.state if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) { let _data = {$$empty: true} if (nextProps.data && nextProps.data[config.dataName]) { _data = nextProps.data[config.dataName] if (_data && Array.isArray(_data)) { - _data = _data[0] + _data = _data[0] || {$$empty: true} } } - if (_data) { - _data.$$BID = BID || '' - } + _data.$$BID = BID || '' + _data.$$BData = BData || '' + _data.$$uuid = _data[config.setting.primaryKey] || '' this.setState({sync: false, data: _data}) } } + mkPublicData = (publicId, data) => { + const { config, BID, BData } = this.state + + if (config.wrap.datatype === 'public' && config.wrap.publicId === publicId) { + let _data = fromJS(data).toJS() + + _data.$$BID = BID || '' + _data.$$BData = BData || '' + _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.setState({data: _data}) + } + } + /** * @description 鎸夐挳鎵ц瀹屾垚鍚庨〉闈㈠埛鏂� * @param {*} menuId // 鑿滃崟Id diff --git a/src/tabviews/custom/components/card/prop-card/index.jsx b/src/tabviews/custom/components/card/prop-card/index.jsx index b40f01e..4f4c46c 100644 --- a/src/tabviews/custom/components/card/prop-card/index.jsx +++ b/src/tabviews/custom/components/card/prop-card/index.jsx @@ -67,6 +67,9 @@ } _sync = false } + } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) { + _data = window.GLOB.CacheData.get(_config.wrap.publicId) + _data = fromJS(_data).toJS() } _data.$$BID = BID || '' @@ -126,6 +129,12 @@ setTimeout(() => { this.loadData() }, _config.setting.delay || 0) + } else if (_config.wrap.datatype === 'public') { + if (_data.$$loaded && selected !== 'false') { + setTimeout(() => { + this.checkTopLine() + }, 200) + } } else if (!_sync && selected !== 'false') { setTimeout(() => { this.checkTopLine() @@ -142,6 +151,10 @@ MKEmitter.addListener('queryModuleParam', this.queryModuleParam) MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + if (config.wrap.datatype === 'public') { + MKEmitter.addListener('mkPublicData', this.mkPublicData) + } + if (config.timer && config.wrap.datatype === 'dynamic') { this.timer = new TimerTask() this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)}) @@ -157,6 +170,7 @@ return } MKEmitter.removeListener('reloadData', this.reloadData) + MKEmitter.removeListener('mkPublicData', this.mkPublicData) MKEmitter.removeListener('resetSelectLine', this.resetParentParam) MKEmitter.removeListener('queryModuleParam', this.queryModuleParam) MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) @@ -190,13 +204,33 @@ }, 200) } }) - } else if ( config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { + } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) { this.setState({}, () => { this.loadData() }) } } + mkPublicData = (publicId, data) => { + const { config, selected, BID, BData } = this.state + + if (config.wrap.datatype === 'public' && config.wrap.publicId === publicId) { + let _data = fromJS(data).toJS() + + _data.$$BID = BID || '' + _data.$$BData = BData || '' + _data.$$uuid = _data[config.setting.primaryKey] || '' + + this.setState({data: _data}, () => { + if (selected !== 'false') { + setTimeout(() => { + this.checkTopLine() + }, 200) + } + }) + } + } + checkTopLine = () => { const { config, data, selected } = this.state diff --git a/src/tabviews/custom/components/interfaces/index.jsx b/src/tabviews/custom/components/interfaces/index.jsx new file mode 100644 index 0000000..166f72b --- /dev/null +++ b/src/tabviews/custom/components/interfaces/index.jsx @@ -0,0 +1,37 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' + +import MkInterItem from './interItem' +// import './index.scss' + +class MkInterfaces extends Component { + static propTpyes = { + BID: PropTypes.any, + interfaces: PropTypes.array + } + + state = {} + + shouldComponentUpdate (nextProps, nextState) { return false } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + + render() { + const { interfaces, BID } = this.props + + return ( + <> + {interfaces.map(m => <MkInterItem key={m.uuid} config={m} BID={BID}/>)} + </> + ) + } +} + +export default MkInterfaces \ No newline at end of file diff --git a/src/tabviews/custom/components/interfaces/index.scss b/src/tabviews/custom/components/interfaces/index.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/tabviews/custom/components/interfaces/index.scss diff --git a/src/tabviews/custom/components/interfaces/interItem/index.jsx b/src/tabviews/custom/components/interfaces/interItem/index.jsx new file mode 100644 index 0000000..1cf8c19 --- /dev/null +++ b/src/tabviews/custom/components/interfaces/interItem/index.jsx @@ -0,0 +1,73 @@ +import {Component} from 'react' +import PropTypes from 'prop-types' +import { notification } from 'antd' + +import Api from '@/api' +import UtilsDM from '@/utils/utils-datamanage.js' +import MKEmitter from '@/utils/events.js' +import TimerTask from '@/utils/timer-task.js' + +// import './index.scss' + +class MkInterItem extends Component { + static propTpyes = { + BID: PropTypes.any, // 涓婄骇涓婚敭鍊� + config: PropTypes.object, // 閰嶇疆淇℃伅 + } + + state = {} + + componentDidMount () { + const { config } = this.props + + if (config.setting.timer) { + this.timer = new TimerTask() + this.timer.init(config.uuid, config.setting.timer, config.setting.timerRepeats, () => {this.loadData()}) + } + setTimeout(() => { + this.loadData() + }, config.setting.delay) + } + + shouldComponentUpdate (nextProps, nextState) { return false } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 + */ + componentWillUnmount () { + this.setState = () => { + return + } + this.timer && this.timer.stop() + } + + async loadData () { + const { config, BID } = this.props + + let param = UtilsDM.getQueryDataParams(config.setting, config.columns.map(col => col.field).join(','), [], config.setting.order, 1, 1, BID) + + let result = await Api.genericInterface(param) + if (result.status) { + let _data = { $$empty: true } + + if (result.data && result.data[0]) { + _data = result.data[0] + } + + _data.$$loaded = true + + MKEmitter.emit('mkPublicData', config.uuid, _data) + } else { + this.timer && this.timer.stop() + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } + } + + render() {return null} +} + +export default MkInterItem \ No newline at end of file diff --git a/src/tabviews/custom/components/interfaces/interItem/index.scss b/src/tabviews/custom/components/interfaces/interItem/index.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/tabviews/custom/components/interfaces/interItem/index.scss diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 4e1324e..2f6eafe 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -4,11 +4,10 @@ import { notification, Spin, Row, Col } from 'antd' import Api from '@/api' -import options from '@/store/options.js' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' -import UtilsDM, { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js' +import { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' import NotFount from '@/components/404' @@ -42,6 +41,7 @@ const TimeLine = asyncComponent(() => import('./components/timeline/normal-timeline')) const Voucher = asyncComponent(() => import('./components/module/voucher')) const DebugTable = asyncComponent(() => import('@/tabviews/debugtable')) +const MkInterfaces = asyncComponent(() => import('@/tabviews/custom/components/interfaces')) class CustomPage extends Component { static propTpyes = { @@ -143,35 +143,6 @@ window.GLOB.CacheData.set(MenuID, param) - config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID) - - // 鑾峰彇涓绘悳绱㈡潯浠� - let mainSearch = [] - config.components.forEach(component => { - if (component.type !== 'search') 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 params = [] - let BID = param.$BID || '' - let inherit = {} - - if (config.cacheUseful === 'true') { // 缂撳瓨缁ф壙 - inherit.cacheUseful = config.cacheUseful - inherit.timeUnit = config.timeUnit - inherit.cacheTime = config.cacheTime - } - let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' @@ -201,6 +172,37 @@ }) } + config.interfaces = this.formatInterSetting(config.interfaces, regs) + + config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces) + + // 鑾峰彇涓绘悳绱㈡潯浠� + let mainSearch = [] + config.components.forEach(component => { + if (component.type !== 'search') 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 params = [] + let BID = param.$BID || '' + let inherit = {} + + if (config.cacheUseful === 'true') { // 缂撳瓨缁ф壙 + inherit.cacheUseful = config.cacheUseful + inherit.timeUnit = config.timeUnit + inherit.cacheTime = config.cacheTime + } + config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap) if ([...balMap.keys()].length > 0) { @@ -213,7 +215,7 @@ config, mainSearch }, () => { - if (!params || params.length === 0) { + if (params.length === 0) { setTimeout(() => { // 寤舵椂鍔犺浇鐘舵�� this.setState({ loadingview: false @@ -226,8 +228,6 @@ if (!this.props.Tab) { this.setShortcut() } - - this.loadData() }) } else { this.setState({ @@ -282,176 +282,7 @@ } } - loadData = () => { - const { config } = this.state - - if (!config.interfaces || config.interfaces.length === 0) return - - let inters = [] - - config.interfaces.forEach(item => { - if (item.status !== 'true') return - - if (window.GLOB.systemType === 'production' && !item.proInterface) { - notification.warning({ - top: 92, - message: `銆�${item.name}銆嬫湭璁剧疆姝e紡绯荤粺鍦板潃!`, - duration: 3 - }) - return - } - - item.MenuName = config.MenuName || '' - - inters.push(item) - }) - - // if (inters.length > 0) { - // this.loadOutResource(inters) - // } - } - - loadOutResource = (inters) => { - let setting = inters.shift() - let param = UtilsDM.getPrevQueryParams(setting, [], this.state.BID) - - Api.genericInterface(param).then(res => { - if (res.status) { - if (res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) { - if (inters.length > 0) { - this.loadOutResource(inters) - } - } else { - this.customOuterRequest(res, setting, inters) - } - } else { - notification.error({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) - } - - customOuterRequest = (result, setting, inters) => { - 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 - - 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, setting, inters) - } else { - if (Array.isArray(res)) { - res = { data: res } - } - res.mk_api_key = mkey - this.customCallbackRequest(res, setting, inters) - } - }, (e) => { - let _result = { - mk_api_key: mkey, - $ErrCode: 'E', - $ErrMesg: e && e.statusText ? e.statusText : '' - } - - this.customCallbackRequest(_result, setting, inters) - }) - } - - customCallbackRequest = (result, setting, inters) => { - 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, this.state.BID) - } else { - param.func = 's_ex_result_back' - param.s_ex_result = lines.map((item, index) => ({ - MenuID: this.props.MenuID || '', - MenuName: this.props.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) { - if (inters.length > 0) { - this.loadOutResource(inters) - } - } else { - notification.error({ - top: 92, - message: res.message, - duration: 10 - }) - } - }) - } - - filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId) => { + filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces) => { return components.filter(item => { item.$pageId = pageId @@ -537,7 +368,7 @@ item.subtabs = item.subtabs.map(tab => { tab.$pageId = pageId - tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId) + tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces) return tab }) @@ -550,7 +381,7 @@ return false } - item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId) + item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces) return true } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) { @@ -566,6 +397,15 @@ item.wrap.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0 ) { return false + } + + if (item.wrap.datatype === 'public') { + let inter = interfaces.filter(int => item.wrap.publicId === int.uuid)[0] + if (!inter) { + item.wrap.datatype = 'static' + } else { + item.setting = inter.setting + } } } @@ -1000,6 +840,8 @@ component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap) component = {...component, ...inherit} return component + } else if (component.wrap && component.wrap.datatype === 'public') { + return component } if (component.setting) { @@ -1096,6 +938,61 @@ }) } + // 鏍煎紡鍖栭粯璁よ缃� + formatInterSetting = (inters, regs) => { + if (!inters) return [] + + let interfaces = inters.filter(m => m.status === 'true') + + let delay = 15 + return interfaces.map(inter => { + inter.setting.delay = delay + delay += 15 + + if (inter.setting.interType !== 'system') return inter + + let _customScript = '' + inter.scripts.forEach(script => { + if (script.status !== 'false') { + _customScript += ` + ${script.sql} + ` + } + }) + delete inter.scripts + + inter.setting.$name = '鍏叡鏁版嵁婧�-' + inter.setting.name + inter.setting.execute = inter.setting.execute !== 'false' + inter.setting.laypage = true + + if (!inter.setting.execute) { + inter.setting.dataresource = '' + } + if (/\s/.test(inter.setting.dataresource)) { + inter.setting.dataresource = '(' + inter.setting.dataresource + ') tb' + } + + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + inter.setting.dataresource = inter.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') + inter.setting.dataresource = inter.setting.dataresource.replace(/@\$/ig, '*/') + _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') + _customScript = _customScript.replace(/@\$/ig, '*/') + } else { + inter.setting.dataresource = inter.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + } + + regs.forEach(cell => { + inter.setting.dataresource = inter.setting.dataresource.replace(cell.reg, cell.value) + _customScript = _customScript.replace(cell.reg, cell.value) + }) + + inter.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 + + return inter + }) + } + /** * @description 涓昏〃鏁版嵁鍔犺浇 */ @@ -1172,7 +1069,12 @@ MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) window.GLOB.CacheData.delete(this.props.MenuID) - this.deleteCache(this.state.config.components) + if (this.state.config) { + this.deleteCache(this.state.config.components) + this.state.config.interfaces.forEach(m => { + window.GLOB.CacheData.delete(m.uuid) + }) + } } debugChange = () => { @@ -1370,12 +1272,13 @@ } render() { - const { loadingview, viewlost, config, loading, shortcuts } = this.state + const { loadingview, viewlost, config, loading, shortcuts, BID } = this.state return ( <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 && config.interfaces.length > 0 ? <MkInterfaces BID={BID} interfaces={config.interfaces}/> : null} {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 && config ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts || []}/> : null} diff --git a/src/tabviews/debugtable/index.jsx b/src/tabviews/debugtable/index.jsx index 7b76927..b6833f5 100644 --- a/src/tabviews/debugtable/index.jsx +++ b/src/tabviews/debugtable/index.jsx @@ -71,7 +71,7 @@ } } - refreshByButtonResult = () => { + refreshDebugTable = () => { const { loading } = this.state if (!loading) { @@ -85,7 +85,7 @@ } componentDidMount() { - MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult) + MKEmitter.addListener('refreshDebugTable', this.refreshDebugTable) } shouldComponentUpdate (nextProps, nextState) { @@ -99,7 +99,7 @@ this.setState = () => { return } - MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult) + MKEmitter.removeListener('refreshDebugTable', this.refreshDebugTable) } render() { @@ -108,7 +108,7 @@ return ( <div className="debugtable"> <RedoOutlined className="mk-debug-reload" onClick={() => this.loadmaindata()}/> - <Table size="middle" columns={columns} dataSource={data} loading={loading} scroll={{ x: '100%', y: false }}/> + <Table size="middle" columns={columns} dataSource={data} pagination={false} loading={loading} scroll={{ x: '100%', y: false }}/> </div> ) } diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 2df4e43..c5ca987 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -376,7 +376,6 @@ let item = { type: type, - readonly: false, readin: true, writein: true, fieldlen: fieldlen, @@ -806,14 +805,11 @@ if (form.type === 'number' || form.type === 'rate') { let val = form.value - if (typeof(val) !== 'number') { - val = parseFloat(val) - if (isNaN(val)) { - val = 0 - } + if (isNaN(val)) { + val = 0 } _initFormfields.push(`@${_key}=${val}`) - } else if (['date', 'datemonth', 'datetime'].includes(form.type)) { + } else if (['date', 'datemonth'].includes(form.type)) { _initFormfields.push(`@${_key}='${form.value || '1949-10-01'}'`) } else { _initFormfields.push(`@${_key}='${form.value}'`) @@ -848,7 +844,7 @@ } // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃) - if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce') { + if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce' && columns && columns.length > 0) { datavars = {...data, ...datavars} const setField = (col) => { @@ -890,17 +886,15 @@ } } - if (columns && columns.length > 0) { - columns.forEach(col => { - if (col.type === 'colspan' || col.type === 'old_colspan') { - col.subcols.forEach(cell => { - setField(cell) - }) - } else { - setField(col) - } - }) - } + columns.forEach(col => { + if (col.type === 'colspan' || col.type === 'old_colspan') { + col.subcols.forEach(cell => { + setField(cell) + }) + } else { + setField(col) + } + }) } // 鍙橀噺澹版槑 @@ -1890,6 +1884,10 @@ } else if (btn.execSuccess !== 'never') { MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines) } + + if (window.GLOB.breakpoint) { + MKEmitter.emit('refreshDebugTable') + } btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId) @@ -2279,6 +2277,10 @@ let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null this.setState({check: data && data[btn.field] === btn.openVal}) } + + if (window.GLOB.breakpoint) { + MKEmitter.emit('refreshDebugTable') + } } handleModelConfig = (config) => { @@ -2415,73 +2417,86 @@ btnconfig.fields.forEach(item => { if (!item.field) return - let _readin = item.readin !== 'false' - let _initval = item.initval + let _item = { + key: item.field, + readin: item.readin !== 'false' && item.readin !== 'top', + fieldlen: item.fieldlength || 50, + writein: item.writein !== 'false', + type: item.type + } - if (item.type === 'linkMain' || item.type === 'funcvar') { + let _initval = item.initval + let _readin = item.readin !== 'false' + let _format = item.precision || 'day' // 鏃堕棿鏍煎紡鍖� + + if (item.type === 'funcvar') { + _initval = '' _readin = false + _item.readin = false + } else if (item.type === 'linkMain') { + _readin = false + _item.readin = false + } else if (item.type === 'date') { + if (_format !== 'day') { + _format = 'YYYY-MM-DD HH:mm:ss' + } else { + _format = 'YYYY-MM-DD' + } + } else if (item.type === 'datetime') { + _item.type = 'date' + _format = 'YYYY-MM-DD HH:mm:ss' } let key = item.field.toLowerCase() - if (item.type === 'linkMain' && BData.hasOwnProperty(key)) { + if (_item.type === 'linkMain' && BData.hasOwnProperty(key)) { _initval = BData[key] } else if (_readin && _data.hasOwnProperty(key)) { _initval = _data[key] - } else if (item.type === 'date' && _initval) { - _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD') - } else if (item.type === 'datemonth' && _initval) { + } else if (_item.type === 'date' && _initval) { + _initval = moment().subtract(_initval, 'days').format(_format) + } else if (_item.type === 'datemonth' && _initval) { _initval = moment().subtract(_initval, 'month').format('YYYY-MM') - } else if (item.type === 'datetime' && _initval) { - _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD HH:mm:ss') } - if (_initval === undefined) { - _initval = '' - } + _item.value = _initval === undefined ? '' : _initval - let _fieldlen = item.fieldlength || 50 - if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') { - _fieldlen = item.fieldlength || 512 - } else if (item.type === 'number') { - _fieldlen = item.decimal ? item.decimal : 0 - } else if (item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_initval)) { // 鐗规畩瀛楁鏇挎崲 - _initval = _initval.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (BID || '')) - } + if (_item.type === 'number' || item.declare === 'decimal') { + _item.type = 'number' + _item.fieldlen = item.decimal || 0 + } else if (['text', 'textarea', 'linkMain'].includes(_item.type)) { + _item.value = _item.value + '' + _item.value = _item.value.replace(/\t*|\v*/g, '') // 鍘婚櫎鍒惰〃绗� - let _type = item.type - - if (['date', 'datemonth', 'datetime'].includes(_type) && item.declareType === 'nvarchar(50)') { - _type = 'text' - } else if (item.type === 'rate') { - item.rateCount = item.rateCount || 5 - let allowHalf = item.allowHalf === 'true' - - if (allowHalf) { - _initval = parseFloat(_initval) - if (_initval % 0.5 !== 0) { - _initval = parseInt(_initval) + if (item.interception !== 'false') { // 鍘婚櫎棣栧熬绌烘牸 + _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') + } + if (_item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 鐗规畩瀛楁鏇挎崲 + _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (BID || '')) + } + if (_item.type === 'text' && item.lenControl && item.lenControl !== 'limit') { + if (item.lenControl === 'left') { + _item.value = _item.value.substr(0, item.fieldlength) + } else { + _item.value = _item.value.slice(-item.fieldlength) } - } else { - _initval = parseInt(_initval) } + } else if (_item.type.indexOf('date') > -1) { + if (item.declareType === 'nvarchar(50)') { + _item.type = 'text' + } + } else if (_item.type === 'rate') { + let count = item.rateCount || 5 + _item.value = parseInt(_item.value) - if (isNaN(_initval) || _initval < 0) { - _initval = 0 - } else if (_initval > item.rateCount) { - _initval = item.rateCount + if (isNaN(_item.value) || _item.value < 0) { + _item.value = 0 + } else if (_item.value > count) { + _item.value = count } } - result.push({ - key: item.field, - readonly: item.readonly === 'true', - readin: item.readin !== 'false' && item.readin !== 'top', - fieldlen: _fieldlen, - writein: item.writein !== 'false', - type: _type, - value: _initval - }) + result.push(_item) }) if (btnconfig.setting.display === 'exec') { diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 81536d8..daa91b3 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -133,6 +133,9 @@ readin = false item.readin = false item.hidden = true + } else if (item.type === 'linkMain') { + readin = false + item.readin = false } else if (item.type === 'number') { item.decimal = item.decimal || 0 item.fieldlength = item.decimal @@ -163,23 +166,16 @@ if (readin && data.hasOwnProperty(key)) { newval = data[key] } - if (item.type === 'linkMain') { - newval = BData[key] || '$empty' - } else if (item.type === 'date') { // 鏃堕棿鎼滅储 - let format = 'YYYY-MM-DD' + if (item.type === 'linkMain' && BData.hasOwnProperty(key)) { + newval = BData[key] + } else if (item.type === 'date') { // 鏃堕棿琛ㄥ崟锛屾彁浜ゅ�间负澶╂垨绉� let _format = 'YYYY-MM-DD HH:mm:ss' if (item.precision === 'day') { _format = 'YYYY-MM-DD' - } else if (item.precision === 'hour') { - format = 'YYYY-MM-DD HH' - } else if (item.precision === 'minute') { - format = 'YYYY-MM-DD HH:mm' - } else if (item.precision === 'second') { - format = 'YYYY-MM-DD HH:mm:ss' } if (newval !== '$empty') { - newval = moment(newval, format).format(_format) + newval = moment(newval, 'YYYY-MM-DD HH:mm:ss').format(_format) newval = newval === 'Invalid date' ? '$empty' : newval } if (newval === '$empty' && item.initval) { @@ -193,18 +189,6 @@ if (newval === '$empty' && item.initval) { newval = moment().subtract(item.initval, 'month').format('YYYY-MM') } - // } else if (item.type === 'datetime') { - // if (newval !== '$empty') { - // newval = moment(newval, 'YYYY-MM-DD HH:mm:ss').format('YYYY-MM-DD HH:mm:ss') - // newval = newval === 'Invalid date' ? '$empty' : newval - // } - // if (newval === '$empty' && item.initval) { - // if (item.initval === '0') { - // newval = moment().format('YYYY-MM-DD HH:mm:ss') - // } else { - // newval = moment().subtract(item.initval, 'days').format('YYYY-MM-DD') + ' 00:00:00' - // } - // } } else if (item.type === 'switch') { // 寮�鍏冲彧鎺ユ敹鍥哄畾鍊� if (newval !== '$empty' && (newval === item.closeVal || newval === item.openVal)) { @@ -221,7 +205,11 @@ item.initval = '' } - if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect', 'cascader'].includes(item.type) && item.resourceType === '1') { + if (item.type === 'number') { + if (isNaN(item.initval)) { + item.initval = 0 + } + } else if (['select', 'link', 'radio', 'checkbox', 'checkcard', 'multiselect', 'cascader'].includes(item.type) && item.resourceType === '1') { deForms.push(item) } else if (item.type === 'rate') { item.rateCount = item.rateCount || 5 @@ -244,9 +232,7 @@ } if (item.type === 'text') { - if (typeof(item.initval) === 'number') { - item.initval = item.initval + '' - } + item.initval = item.initval + '' let _rules = [{ pattern: /^[^']*$/ig, message: '涓嶅彲浣跨敤鑻辨枃鐘舵�佺殑鍗曞紩鍙凤紒' @@ -274,37 +260,32 @@ if (item.regular === 'number') { _rules.push({ pattern: /^[0-9.-]*$/, - message: formRule.input.numbermsg + message: item.regularText || formRule.input.numbermsg }) } else if (item.regular === 'letter') { _rules.push({ pattern: /^[a-zA-Z]*$/, - message: formRule.input.lettermsg + message: item.regularText || formRule.input.lettermsg }) } else if (item.regular === 'letter_number') { _rules.push({ pattern: /^[a-zA-Z0-9]*$/, - message: '璇疯緭鍏ユ暟瀛楁垨瀛楁瘝' + message: item.regularText || '璇疯緭鍏ユ暟瀛楁垨瀛楁瘝' }) } else if (item.regular === 'letter&number') { _rules.push({ pattern: /^[a-zA-Z0-9@_.]*$/, - message: '璇疯緭鍏ユ暟瀛椼�佸瓧姣嶄互鍙夽_.' + message: item.regularText || '璇疯緭鍏ユ暟瀛椼�佸瓧姣嶄互鍙夽_.' }) } else if (item.regular === 'phone') { _rules.push({ pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/, - message: '璇锋纭緭鍏ユ墜鏈哄彿' + message: item.regularText || '璇锋纭緭鍏ユ墜鏈哄彿' }) } else if (item.regular === 'email') { _rules.push({ pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/, - message: '璇锋纭緭鍏ラ偖绠卞湴鍧�' - }) - } else if (item.regular === 'funcname') { - _rules.push({ - pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/, - message: formRule.input.funcname + message: item.regularText || '璇锋纭緭鍏ラ偖绠卞湴鍧�' }) } } @@ -962,7 +943,6 @@ let _item = { type: item.type, - readonly: item.readonly, readin: item.readin, writein: item.writein, fieldlen: item.fieldlength, @@ -973,29 +953,29 @@ if (item.type === 'funcvar') { _item.value = '' - } else if (_item.value && (item.type === 'text' || item.type === 'textarea' || item.type === 'linkMain') && typeof(_item.value) === 'string') { + } else if (item.declare === 'decimal') { + _item.type = 'number' + _item.fieldlen = item.decimal || 0 + } else if (['text', 'textarea', 'linkMain'].includes(item.type)) { + _item.value = _item.value + '' _item.value = _item.value.replace(/\t*|\v*/g, '') // 鍘婚櫎鍒惰〃绗� - if (item.interception !== 'false') { // 鍘婚櫎棣栧熬绌烘牸 + if (item.interception !== 'false') { // 鍘婚櫎棣栧熬绌烘牸 _item.value = _item.value.replace(/(^\s*|\s*$)/g, '') } if (item.type === 'text' && /@appkey@|@SessionUid@|@bid@/ig.test(_item.value)) { // 鐗规畩瀛楁鏇挎崲 _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey).replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')).replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || '')) } + if (item.type === 'text' && item.lenControl && item.lenControl !== 'limit') { + if (item.lenControl === 'left') { + _item.value = _item.value.substr(0, item.fieldlength) + } else { + _item.value = _item.value.slice(-item.fieldlength) + } + } } else if (item.type.indexOf('date') > -1) { if (item.declareType === 'nvarchar(50)') { _item.type = 'text' - } - } else if (item.declare === 'decimal' && ['select', 'link', 'radio', 'checkcard'].includes(item.type)) { - _item.type = 'number' - _item.fieldlen = item.decimal || 0 - } - - if (item.type === 'text' && item.lenControl && item.lenControl !== 'limit') { - if (item.lenControl === 'left') { - _item.value = _item.value.substr(0, item.fieldlength) - } else { - _item.value = _item.value.slice(-item.fieldlength) } } diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 0195364..eeb7fbc 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -3571,6 +3571,24 @@ required: false }, { + type: 'radio', + key: 'lenControl', + label: '闀垮害鎺у埗', + initVal: card.lenControl || 'limit', + tooltip: '鍦ㄨ缃瓧娈甸暱搴﹀悗锛屽闀垮害鐨勬帶鍒舵柟寮忋��', + required: false, + options: [{ + value: 'limit', + text: '闄愬埗杈撳叆' + }, { + value: 'left', + text: '宸︽埅' + }, { + value: 'right', + text: '鍙虫埅' + }] + }, + { type: 'number', key: 'span', min: 1, @@ -3602,24 +3620,6 @@ }, { value: 6, text: 6 - }] - }, - { - type: 'radio', - key: 'lenControl', - label: '闀垮害鎺у埗', - initVal: card.lenControl || 'limit', - tooltip: '鍦ㄨ缃瓧娈甸暱搴﹀悗锛屽闀垮害鐨勬帶鍒舵柟寮忋��', - required: false, - options: [{ - value: 'limit', - text: '闄愬埗杈撳叆' - }, { - value: 'left', - text: '宸︽埅' - }, { - value: 'right', - text: '鍙虫埅' }] }, { @@ -3687,6 +3687,15 @@ }, { type: 'text', + key: 'regularText', + label: '姝e垯鎻愮ず', + initVal: card.regularText || '', + tooltip: '姝e垯楠岃瘉鏃剁殑鎻愮ず淇℃伅銆�', + required: false, + readonly: false + }, + { + type: 'text', key: 'tooltip', label: '鎮诞鎻愮ず', tooltip: '榧犳爣鎮诞浜庢彁绀烘枃瀛椾笂鏂规椂锛屾樉绀烘彁绀轰俊鎭��', @@ -3722,7 +3731,7 @@ { type: 'text', key: 'placeholder', - label: '鎻愮ず淇℃伅', + label: '杈撳叆鎻愮ず', tooltip: '瀛楁棰勬湡鍊肩殑鎻愮ず淇℃伅銆�', initVal: card.placeholder || '', required: false diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx index 6a9fba9..9be8093 100644 --- a/src/templates/zshare/modalform/index.jsx +++ b/src/templates/zshare/modalform/index.jsx @@ -41,7 +41,7 @@ formula: ['label', 'type', 'marginTop', 'marginBottom', 'splitline', 'span', 'labelwidth', 'formula', 'eval', 'postfix'], brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption', 'marginTop', 'marginBottom'], funcvar: ['span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'], - linkMain: ['readonly', 'required', 'hidden', 'fieldlength', 'span', 'labelwidth', 'tooltip', 'interception', 'extra', 'marginTop', 'marginBottom'] + linkMain: ['readonly', 'required', 'hidden','declare', 'span', 'labelwidth', 'tooltip', 'interception', 'extra', 'marginTop', 'marginBottom'] } class MainSearch extends Component { @@ -140,6 +140,9 @@ if (this.record.enter === 'tab' || this.record.enter === 'sub') { shows.push('tabField') } + if (this.record.regular !== '') { + shows.push('regularText') + } } else if (type === 'number') { reTypes.initval = 'number' reRequired.initval = true @@ -149,6 +152,12 @@ if (sessionStorage.getItem('appType') === 'mob') { // 绉诲姩绔彸渚ф墿灞曚俊鎭� shows.push('placeholder') } + } else if (type === 'linkMain') { + if (this.record.declare === 'nvarchar') { + shows.push('fieldlength') + } else if (this.record.declare === 'decimal') { + shows.push('decimal') + } } else if (['multiselect', 'select', 'link', 'radio', 'checkbox'].includes(type)) { if (this.record.resourceType === '0') { // 鑷畾涔夎祫婧� shows.push('options') diff --git a/src/templates/zshare/verifycard/customscript/index.jsx b/src/templates/zshare/verifycard/customscript/index.jsx index e9df195..e5542bd 100644 --- a/src/templates/zshare/verifycard/customscript/index.jsx +++ b/src/templates/zshare/verifycard/customscript/index.jsx @@ -325,7 +325,7 @@ </Col> <Col span={24} className="sql"> <Form.Item label={ - <Tooltip placement="topLeft" overlayStyle={{width: '320px', maxWidth: '320px'}} title={<><div>{'璋冭瘯鏇挎崲绗� /*$breakpoint_begin_xxxx@ 銆丂breakpoint_end_xxxx$*/锛屽湪鎺у埗鍙颁腑杈撳叆 window.debug = \'xxxx\' 浼氬惎鐢ㄥ搴旂殑璋冭瘯璇彞锛屽揩鎹烽敭 ctrl+c 鎴栧湪鎺у埗鍙颁腑杈撳叆 window.debug = false 鍏抽棴璋冭瘯銆�'}</div><div style={{height: '5px'}}></div><div>{'鏁版嵁妫�鏌ユ浛鎹㈢ $check@ -> \'\'銆� @check$ -> \'\'锛孍rrorCode绛変簬C鏃� $check@ -> /*銆� @check$ -> */銆傛敞锛�1銆侀渶浣跨敤绯荤粺鎺ュ彛 2銆佽璁剧疆涓衡�滈�夋嫨澶氳鈥濇椂鏃犳晥銆�'}</div></>}> + <Tooltip placement="topLeft" overlayStyle={{width: '320px', maxWidth: '320px'}} title={<><div>{'璋冭瘯鏇挎崲绗� /*$breakpoint_begin_xxxx@ 銆丂breakpoint_end_xxxx$*/锛屽湪鎺у埗鍙颁腑杈撳叆 window.debug = \'xxxx\' 浼氬惎鐢ㄥ搴旂殑璋冭瘯璇彞锛屽揩鎹烽敭 ctrl+c 鎴栧湪鎺у埗鍙颁腑杈撳叆 window.debug = false 鍏抽棴璋冭瘯銆傛敞锛氳皟璇曟椂瀛楃 $breakpoint_proc@ 灏嗚鏇挎崲銆�'}</div><div style={{height: '5px'}}></div><div>{'鏁版嵁妫�鏌ユ浛鎹㈢ $check@ -> \'\'銆� @check$ -> \'\'锛孍rrorCode绛変簬C鏃� $check@ -> /*銆� @check$ -> */銆傛敞锛�1銆侀渶浣跨敤绯荤粺鎺ュ彛 2銆佽璁剧疆涓衡�滈�夋嫨澶氳鈥濇椂鏃犳晥銆�'}</div></>}> <QuestionCircleOutlined className="mk-form-tip" /> sql </Tooltip> diff --git a/src/utils/utils.js b/src/utils/utils.js index 2ac3152..746d8ad 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -158,7 +158,7 @@ let error = '' - sql = sql.replace(/sys\.fn_sqlvarbasetostr\(HashBytes\('MD5'/ig, '') // 璺宠繃MD5鍔犲瘑 + sql = sql.replace(/sys\.fn_/ig, '') // 璺宠繃sys.fn_楠岃瘉 chars.forEach(char => { if (!error && char.reg.test(sql)) { @@ -1434,14 +1434,11 @@ if (form.type === 'number' || form.type === 'rate') { let val = form.value - if (typeof(val) !== 'number') { - val = parseFloat(val) - if (isNaN(val)) { - val = 0 - } + if (isNaN(val)) { + val = 0 } _initFormfields.push(`@${_key}=${val}`) - } else if (['date', 'datemonth', 'datetime'].includes(form.type)) { + } else if (['date', 'datemonth'].includes(form.type)) { _initFormfields.push(`@${_key}='${form.value || '1949-10-01'}'`) } else { _initFormfields.push(`@${_key}='${form.value}'`) @@ -1476,7 +1473,7 @@ } // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�(鎸夐挳涓嶉�夎鎴栧琛屾嫾鎺ユ椂璺宠繃) - if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce') { + if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce' && columns && columns.length > 0) { datavars = {...data, ...datavars} const setField = (col) => { @@ -1518,17 +1515,15 @@ } } - if (columns && columns.length > 0) { - columns.forEach(col => { - if (col.type === 'colspan' || col.type === 'old_colspan') { - col.subcols.forEach(cell => { - setField(cell) - }) - } else { - setField(col) - } - }) - } + columns.forEach(col => { + if (col.type === 'colspan' || col.type === 'old_colspan') { + col.subcols.forEach(cell => { + setField(cell) + }) + } else { + setField(col) + } + }) } // 鍙橀噺澹版槑 @@ -2078,7 +2073,7 @@ end = /@breakpoint_end_[0-9a-z_]+\$\*\//ig } - _sql = _sql.replace(start, '').replace(end, '') + _sql = _sql.replace(start, '').replace(end, '').replace(/\$breakpoint_proc@/ig, window.GLOB.breakpoint) _sql += ` z_debug_end: select @ErrorCode='E',@retmsg='debug_end' goto aaa` } -- Gitblit v1.8.0