From 0c9972b68aaee5ce0d536bb418ebcd2887012a28 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 29 六月 2020 14:35:47 +0800 Subject: [PATCH] 2020-06-29 --- src/index.js | 5 src/store/options.js | 8 src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 65 ++++++++++ src/templates/menuconfig/editsecmenu/index.scss | 2 src/templates/menuconfig/editthdmenu/index.scss | 2 src/tabviews/zshare/mutilform/index.jsx | 6 src/templates/sharecomponent/actioncomponent/index.jsx | 2 src/api/index.js | 2 src/templates/sharecomponent/settingcomponent/settingform/index.jsx | 4 src/tabviews/zshare/fileupload/index.jsx | 5 src/tabviews/zshare/actionList/excelInbutton/index.jsx | 1 src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx | 207 ++++++++++++++++++++++++++++++++-- 12 files changed, 284 insertions(+), 25 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 76b3ce9..56fdc9c 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -13,7 +13,7 @@ config.method = 'post' if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult')) { config.data = qs.stringify(config.data) - } else if (config.url.includes('Upload') || config.url.includes('doupload')) { + } else if (config.url.includes('Upload') || config.url.includes('doupload') || config.url.includes('dopreload')) { config.headers = { 'Content-Type': 'multipart/form-data' } } else { // config.headers.token = sessionStorage.getItem('TOKEN') || '' diff --git a/src/index.js b/src/index.js index ad77622..d6e1e0f 100644 --- a/src/index.js +++ b/src/index.js @@ -14,6 +14,11 @@ window.location.replace(window.location.href.split(/(index.html)+/ig)[0] + 'mob/index.html') } +options.sysType = window.atob(options.sysType.replace('$mk', '')) +options.caId = window.atob(options.caId.replace('$mk', '')) +options.cakey = window.atob(options.cakey.replace('$mk', '')) +options.cdomain = window.atob(options.cdomain.replace('$mk', '')) + if (options.cdomain) { options.cloudServiceApi = options.cdomain + '/webapi/dostars' } diff --git a/src/store/options.js b/src/store/options.js index dca9c52..0b368da 100644 --- a/src/store/options.js +++ b/src/store/options.js @@ -1,7 +1,7 @@ // 绯荤粺閰嶇疆 export default { - sysType: 'local', // cloud 銆� SSO 銆� local - caId: '', - cakey: '2020011612400464367D38162115B417895C1', - cdomain: 'http://cloud.mk9h.cn' + sysType: 'bG9j$mkYWw=', // yun ( Y2xvdWQ= ) 銆� dandian ( U1NP ) 銆� yewu ( bG9jYWw= ) + caId: 'MjAyMDAxMTYxMjMzMzU1MDd$mkGQzkyMzI1Rjk4MDY0QUNGQjQ2Mg==', // mk + cakey: 'MjAyMDAxMTYxMjQwMDQ2NDM$mk2N0QzODE2MjExNUI0MTc4OTVDMQ==', // mk + cdomain: 'aHR0cDovL2Nsb3V$mkkLm1rOWguY24=' // mk } \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index bfcaa33..08cbf54 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -261,6 +261,7 @@ result.bottom = result.bottom.replace(/@\$|\$@/ig, '') } + param.excel_in = 'true' param.LText_insert = Utils.formatOptions(result.insert) param.LText_bottom = Utils.formatOptions(result.bottom) param.LText = Utils.formatOptions(result.sql) diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index c6cf2a8..1129358 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -31,6 +31,7 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, excelName: '', + search: '', // 鎼滅储鏉′欢 loading: false } @@ -131,6 +132,8 @@ duration: 5 }) return + } else if (btn.intertype === 'inner' && !btn.innerFunc && btn.verify && btn.verify.enable === 'true') { + this.setState({search: fromJS(viewParam.search).toJS()}) } this.updateStatus('start', name) @@ -312,8 +315,6 @@ } param = this.getExcelDefaultParam(viewParam.arr_field, viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) - - } else if (btn.intertype === 'inner' && btn.innerFunc) { // 浣跨敤鍐呴儴鍑芥暟 param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) param.func = btn.innerFunc @@ -456,7 +457,11 @@ XLSX.writeFile(wb, this.state.excelName) - this.execSuccess({ErrCode: 'S', ErrMesg: '瀵煎嚭鎴愬姛锛�'}) + if (btn.verify && btn.verify.enable === 'true' && btn.verify.script) { + this.execCustomScript() + } else { + this.execSuccess({ErrCode: 'S', ErrMesg: '瀵煎嚭鎴愬姛锛�'}) + } } catch { this.execError({ErrCode: 'N', message: 'Excel鐢熸垚澶辫触锛�'}) } @@ -466,6 +471,60 @@ } /** + * @description 鎵ц鑷畾涔夎剼鏈� + */ + execCustomScript = () => { + const { btn } = this.props + const { search } = this.state + let script = btn.verify.script + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + script = script.replace(/\$@/ig, '/*') + script = script.replace(/@\$/ig, '*/') + } else { + script = script.replace(/@\$|\$@/ig, '') + } + + let allSearch = Utils.getAllSearchOptions(search) + let regoptions = allSearch.map(item => { + return { + reg: new RegExp('@' + item.key + '@', 'ig'), + value: `'${item.value}'` + } + }) + + regoptions.forEach(item => { + script = script.replace(item.reg, item.value) + }) + + let param = { + func: 'sPC_TableData_InUpDe' + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + param.LText = Utils.formatOptions(script) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) + } + + Api.genericInterface(param).then((res) => { + if (res.status) { + this.execSuccess({ErrCode: 'S', ErrMesg: '瀵煎嚭鎴愬姛锛�'}) + } else { + this.execError(res) + } + }, () => { + this.updateStatus('over') + }) + } + + /** * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� */ getExcelCustomParam = (orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { diff --git a/src/tabviews/zshare/fileupload/index.jsx b/src/tabviews/zshare/fileupload/index.jsx index df7e480..23bf614 100644 --- a/src/tabviews/zshare/fileupload/index.jsx +++ b/src/tabviews/zshare/fileupload/index.jsx @@ -157,7 +157,10 @@ spark.append(e.target.result) params.file.fileMd5 = spark.end() // 璁$畻鏁翠釜鏂囦欢鐨刦ileMd5 - Api.getFilePreUpload({fileMd5: params.file.fileMd5}).then(res => { + let _param = new FormData() + _param.append('fileMd5', params.file.fileMd5) + + Api.getFilePreUpload(_param).then(res => { if (res.status && res.urlPath) { this.onUpdate(res.urlPath) this.setState({ diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 6bf0af9..42b2724 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -137,9 +137,9 @@ let newval = '' - if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) { - newval = BData[item.field] - } else if (item.type !== 'linkMain' && _readin && !/^date/.test(item.type) && this.props.data && this.props.data.hasOwnProperty(item.field)) { + if (item.type === 'linkMain') { + newval = BData && BData[item.field] ? BData[item.field] : '' + } else if (_readin && !/^date/.test(item.type) && this.props.data && this.props.data.hasOwnProperty(item.field)) { newval = this.props.data[item.field] } else if (item.type === 'date') { // 鏃堕棿鎼滅储 if (_readin && this.props.data && this.props.data.hasOwnProperty(item.field)) { diff --git a/src/templates/menuconfig/editsecmenu/index.scss b/src/templates/menuconfig/editsecmenu/index.scss index c5ba6b3..43866ca 100644 --- a/src/templates/menuconfig/editsecmenu/index.scss +++ b/src/templates/menuconfig/editsecmenu/index.scss @@ -1,4 +1,6 @@ .second-edit-box { + position: relative; + z-index: 1060; .mask { position: fixed; top: 0px; diff --git a/src/templates/menuconfig/editthdmenu/index.scss b/src/templates/menuconfig/editthdmenu/index.scss index edb9084..1172444 100644 --- a/src/templates/menuconfig/editthdmenu/index.scss +++ b/src/templates/menuconfig/editthdmenu/index.scss @@ -1,4 +1,6 @@ .third-edit-box { + position: relative; + z-index: 1060; .mask { position: fixed; top: 0px; diff --git a/src/templates/sharecomponent/actioncomponent/index.jsx b/src/templates/sharecomponent/actioncomponent/index.jsx index d9a0583..69892b4 100644 --- a/src/templates/sharecomponent/actioncomponent/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/index.jsx @@ -606,7 +606,6 @@ this.verifyRef.handleConfirm().then(res => { let _actionlist = fromJS(this.state.actionlist).toJS() - _actionlist = _actionlist.filter(item => !item.origin || item.uuid === card.uuid) _actionlist = _actionlist.map(item => { @@ -949,6 +948,7 @@ <VerifyExcelOut card={card} dict={dict} + config={config} wrappedComponentRef={(inst) => this.verifyRef = inst} /> : null } diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx index 5cb21ad..6621ff3 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx @@ -1,22 +1,28 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Tabs, Row, Col, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber } from 'antd' +import { fromJS } from 'immutable' +import { Form, Tabs, Row, Col, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber, Radio, Input } from 'antd' +import moment from 'moment' +import Api from '@/api' import Utils from '@/utils/utils.js' import ColumnForm from './columnform' import './index.scss' const { TabPane } = Tabs +const { TextArea } = Input class VerifyCard extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� + config: PropTypes.object, card: PropTypes.object, } state = { verify: {}, + defaultscript: '', // 鑷畾涔夎剼鏈� excelColumns: [ { title: this.props.dict['model.form.field'], @@ -65,21 +71,84 @@ } UNSAFE_componentWillMount() { - let _verify = this.props.card.verify || {} + const { config, card } = this.props + let _verify = {} - let _columns = _verify.columns || [] - _columns = _columns.map(col => { + if (card.verify) { + _verify = fromJS(card.verify).toJS() + } + + _verify.enable = _verify.enable || 'false' + _verify.columns = _verify.columns || [] + _verify.columns = _verify.columns.map(col => { col.Width = col.Width || 20 - return col }) + if (card.intertype !== 'inner' || card.innerFunc) { + _verify.enable = 'false' + } + + let defaultscript = '' + if (!_verify.script && card.intertype === 'inner' && !card.innerFunc) { + let search = this.formatSearch(config.search) + search = Utils.joinMainSearchkey(search) + search = search ? 'where ' + search : '' + + defaultscript = `update ${config.setting.tableName || ''} set idefine5= idefine5+1 ,modifydate=getdate(),cdefine5='宸插鍑�',modifyuserid=@userid@ ${search}` + } + + this.setState({ - verify: { - ..._verify, - columns: _columns, - } + verify: _verify, + defaultscript: defaultscript }) + } + + /** + * @description 鑾峰彇鍏ㄩ儴鎼滅储鏉′欢 + * @param {Array} searches 鎼滅储鏉′欢鏁扮粍 + */ + formatSearch (searches) { + if (!searches || searches.length === 0) return [] + + let newsearches = [] + searches.forEach(search => { + let item = { + key: search.field, + match: search.match, + type: search.type, + label: search.label, + value: `@${search.field}@`, + required: search.required === 'true' + } + if (item.type === 'group') { + let copy = fromJS(item).toJS() + copy.key = search.datefield + + item.value = `@${search.field}@` + item.match = '=' + + copy.type = 'daterange' + copy.match = 'between' + copy.value = [`@${search.datefield}@`, `@${search.datefield}1@`] + + if (search.transfer === 'true') { + newsearches.push(item) + } + newsearches.push(copy) + return + } else if (item.type === 'dateweek') { + item.value = [`@${search.field}@`, `@${search.field}1@`] + } else if (item.type === 'daterange') { + item.value = [`@${search.field}@`, `@${search.field}1@`] + } else if (item.type === 'multiselect') { + item.value = [`@${search.field}@`] + } + newsearches.push(item) + }) + + return newsearches } columnChange = (values) => { @@ -198,7 +267,7 @@ } handleConfirm = () => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + let verify = fromJS(this.state.verify).toJS() // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { @@ -215,12 +284,99 @@ return } - resolve(verify) + if (verify.enable === 'true') { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + values.sql = values.sql || '' + + let _quot = values.sql.match(/'{1}/g) + let _lparen = values.sql.match(/\({1}/g) + let _rparen = values.sql.match(/\){1}/g) + + _quot = _quot ? _quot.length : 0 + _lparen = _lparen ? _lparen.length : 0 + _rparen = _rparen ? _rparen.length : 0 + + if (_quot % 2 !== 0) { + notification.warning({ + top: 92, + message: 'sql涓璡'蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + return + } else if (_lparen !== _rparen) { + notification.warning({ + top: 92, + message: 'sql涓�()蹇呴』鎴愬鍑虹幇', + duration: 5 + }) + return + } else if (/--/ig.test(values.sql)) { + notification.warning({ + top: 92, + message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', + duration: 5 + }) + return + } + + let error = Utils.verifySql(values.sql, 'customscript') + + if (error) { + notification.warning({ + top: 92, + message: 'sql涓笉鍙娇鐢�' + error, + duration: 5 + }) + return + } + + let param = { + func: 's_debug_sql', + LText: values.sql + } + + param.LText = param.LText.replace(/@\$|\$@/ig, '') + + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + Api.getLocalConfig(param).then(res => { + if (res.status) { + resolve({...verify, script: values.sql}) + } else { + Modal.error({ + title: res.message + }) + } + }) + } else { + notification.warning({ + top: 92, + message: '鑷畾涔夎剼鏈笉鍙负绌猴紒', + duration: 5 + }) + } + }) + } else { + resolve(verify) + } + }) + } + + changeEnable = (e) => { + const { verify } = this.state + + this.setState({ + verify: {...verify, enable: e.target.value} }) } render() { - const { verify, excelColumns } = this.state + const { card } = this.props + const { verify, excelColumns, defaultscript } = this.state + const { getFieldDecorator } = this.props.form const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -250,6 +406,33 @@ pagination={false} /> </TabPane> + {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="鑷畾涔夎剼鏈�" key="6"> + <Form {...formItemLayout} className="verify-form"> + <Row gutter={24}> + <Col span={8}> + <Form.Item style={{marginBottom: 10}} label={'鍚敤'}> + <Radio.Group defaultValue={verify.enable || 'false'} onChange={this.changeEnable}> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> + </Radio.Group> + </Form.Item> + </Col> + <Col span={24} className="sql"> + <Form.Item label={'sql'}> + {getFieldDecorator('sql', { + initialValue: verify.script || defaultscript, + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + 'sql!' + } + ] + })(<TextArea rows={15} />)} + </Form.Item> + </Col> + </Row> + </Form> + </TabPane> : null} <TabPane tab="淇℃伅鎻愮ず" key="7"> <Form {...formItemLayout}> <Row gutter={24}> diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx index b8b9762..55ac79d 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx @@ -421,6 +421,10 @@ } } + /** + * @description 鑾峰彇鍏ㄩ儴鎼滅储鏉′欢 + * @param {Array} searches 鎼滅储鏉′欢鏁扮粍 + */ formatSearch (searches) { if (!searches || searches.length === 0) return [] -- Gitblit v1.8.0