From 5e10a7ee4a5ef882d6b0d92b19b1a888ffcc6f7f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 四月 2020 11:55:03 +0800 Subject: [PATCH] 2020-04-14 --- src/templates/zshare/modalform/index.jsx | 2 src/tabviews/managetable/secretKeyTable/actionList/index.jsx | 361 +++++++++++++++ src/tabviews/managetable/secretKeyTable/index.scss | 47 ++ src/tabviews/formtab/formgroup/index.jsx | 12 src/tabviews/verupmanage/subtabtable/index.jsx | 2 src/tabviews/zshare/normalTable/index.jsx | 33 src/templates/formtabconfig/index.jsx | 9 src/templates/zshare/verifycard/index.jsx | 8 src/tabviews/managetable/index.jsx | 28 + src/tabviews/verupmanage/config.jsx | 0 src/templates/comtableconfig/index.jsx | 9 src/templates/formtabconfig/actionform/index.jsx | 3 src/templates/zshare/verifycard/customscript/index.jsx | 6 src/templates/zshare/tabform/index.jsx | 24 src/tabviews/managetable/secretKeyTable/config.jsx | 296 ++++++++++++ src/tabviews/managetable/secretKeyTable/index.jsx | 384 ++++++++++++++++ src/tabviews/managetable/secretKeyTable/actionList/index.scss | 44 + src/templates/zshare/verifycardexcelin/customscript/index.jsx | 9 src/tabviews/zshare/actionList/index.jsx | 12 src/locales/zh-CN/comtable.js | 1 src/tabviews/verupmanage/index.jsx | 2 src/locales/en-US/comtable.js | 1 src/utils/utils.js | 42 + 23 files changed, 1,290 insertions(+), 45 deletions(-) diff --git a/src/locales/en-US/comtable.js b/src/locales/en-US/comtable.js index 864c45a..7a12562 100644 --- a/src/locales/en-US/comtable.js +++ b/src/locales/en-US/comtable.js @@ -165,6 +165,7 @@ 'header.form.action.type': '鎿嶄綔绫诲瀷', 'header.form.action.insert': '娣诲姞', 'header.form.action.update': '淇敼', + 'header.form.action.insertOrUpdate': '娣诲姞鎴栦慨鏀�', 'header.form.action.LogicDelete': '閫昏緫鍒犻櫎', 'header.form.action.delete': '鐗╃悊鍒犻櫎', 'header.form.valueField': '鍊悸峰瓧娈�', diff --git a/src/locales/zh-CN/comtable.js b/src/locales/zh-CN/comtable.js index e706c06..df7f890 100644 --- a/src/locales/zh-CN/comtable.js +++ b/src/locales/zh-CN/comtable.js @@ -165,6 +165,7 @@ 'header.form.action.type': '鎿嶄綔绫诲瀷', 'header.form.action.insert': '娣诲姞', 'header.form.action.update': '淇敼', + 'header.form.action.insertOrUpdate': '娣诲姞鎴栦慨鏀�', 'header.form.action.LogicDelete': '閫昏緫鍒犻櫎', 'header.form.action.delete': '鐗╃悊鍒犻櫎', 'header.form.valueField': '鍊悸峰瓧娈�', diff --git a/src/tabviews/formtab/formgroup/index.jsx b/src/tabviews/formtab/formgroup/index.jsx index 3fbd83c..515d800 100644 --- a/src/tabviews/formtab/formgroup/index.jsx +++ b/src/tabviews/formtab/formgroup/index.jsx @@ -514,7 +514,15 @@ </Col> ) } else if (item.type === 'funcvar') { - + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: '绯荤粺鑷姩鐢熸垚', + })(<Input placeholder="" autoComplete="off" disabled={true} />)} + </Form.Item> + </Col> + ) } else if (item.type === 'textarea') { let _labelcol = cols !== 3 ? 8 / cols : 3 let _wrapcol = cols !== 3 ? 16 + (cols - 1) * 4 : 21 @@ -584,6 +592,8 @@ }) Object.keys(values).forEach(key => { + if (this.state.datatype[key] === 'funcvar') return + let _value = '' if (this.state.datatype[key] === 'datetime') { if (values[key]) { diff --git a/src/tabviews/managetable/index.jsx b/src/tabviews/managetable/index.jsx index 344f72c..c3a3a16 100644 --- a/src/tabviews/managetable/index.jsx +++ b/src/tabviews/managetable/index.jsx @@ -19,6 +19,7 @@ import NotFount from '@/components/404' import './index.scss' +const SecretKeyTable = asyncLoadComponent(() => import('./secretKeyTable')) const SubTable = asyncLoadComponent(() => import('@/tabviews/subtable')) const MainAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) const SubTabTable = asyncComponent(() => import('@/tabviews/subtabtable')) @@ -72,8 +73,6 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - // const { permAction } = this.props - let param = { func: 'sPC_Get_LongParam', MenuID: this.props.MenuID @@ -159,6 +158,18 @@ operations: _operations }) } + + let custabs = ['1586577325055l2ng7t75g7i4ek2ng8o'] + config.tabgroups.forEach(group => { + if (!config[group]) return + + config[group] = config[group].map(tab => { + if (custabs.includes(tab.linkTab)) { + tab.type = 'SecretKeyTable' + } + return tab + }) + }) this.setState({ loadingview: false, @@ -908,6 +919,19 @@ handleTableId={this.handleTableId} handleMainTable={(type) => this.handleMainTable(type, _tab)} /> : null} + {_tab.type === 'SecretKeyTable' ? + <SecretKeyTable + menuType="HS" + Tab={_tab} + MenuID={_tab.linkTab} + SupMenuID={this.props.MenuID} + refreshtabs={this.state.refreshtabs} + ContainerId={this.state.ContainerId} + BID={this.state.BIDs[_tab.supMenu] || ''} + BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} + handleTableId={this.handleTableId} + handleMainTable={(type) => this.handleMainTable(type, _tab)} + /> : null} </TabPane> ) })} diff --git a/src/tabviews/managetable/secretKeyTable/actionList/index.jsx b/src/tabviews/managetable/secretKeyTable/actionList/index.jsx new file mode 100644 index 0000000..7b14a7a --- /dev/null +++ b/src/tabviews/managetable/secretKeyTable/actionList/index.jsx @@ -0,0 +1,361 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +// import moment from 'moment' +import { Button, Modal, notification, message } from 'antd' +import MutilForm from '@/tabviews/zshare/mutilform' +import Utils from '@/utils/utils.js' +import { refCodes } from '../config' +// import options from '@/store/options.js' +// import Api from '@/api' +import './index.scss' + +const { confirm } = Modal + +class MainAction extends Component { + static propTpyes = { + BID: PropTypes.string, // 涓昏〃ID + datalist: PropTypes.any, // 鍒楄〃鏁版嵁 + Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� + type: PropTypes.string, // 鍒ゆ柇褰撳墠涓轰富琛紙main锛夈�佸瓙琛紙sub锛夈�佸瓙琛ㄦ爣绛撅紙subtab锛� + MenuID: PropTypes.string, // 鑿滃崟ID + actions: PropTypes.array, // 鎸夐挳缁� + logcolumns: PropTypes.array, // 鏄剧ず鍒� + dict: PropTypes.object, // 瀛楀吀椤� + setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� + refreshdata: PropTypes.func, // 鎵ц瀹屾垚鍚庢暟鎹埛鏂� + gettableselected: PropTypes.func // 鑾峰彇琛ㄦ牸涓暟鎹� + } + + state = { + visible: false, + formdata: null, + tabledata: null, + confirmLoading: false, + execAction: null, + configMap: {}, + loadingNumber: '' + } + + refreshdata = (item, type) => { + this.props.refreshdata(item, type) + } + + /** + * @description 瑙﹀彂鎸夐挳鎿嶄綔 + */ + actionTrigger = (item) => { + const { setting, BID } = this.props + + if (!BID) { + notification.warning({ + top: 92, + message: '闇�瑕佷笂绾т富閿�硷紒', + duration: 10 + }) + return + } + + let _this = this + let data = this.props.gettableselected() || [] + + if (item.Ot !== 'notRequired' && data.length === 0) { + // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� + notification.warning({ + top: 92, + message: this.props.dict['main.action.confirm.selectline'], + duration: 10 + }) + return + } else if (item.Ot === 'requiredSgl' && data.length !== 1) { + // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 + notification.warning({ + top: 92, + message: this.props.dict['main.action.confirm.selectSingleLine'], + duration: 10 + }) + return + } else if (item.Ot !== 'notRequired' && !setting.primaryKey) { + // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� + notification.warning({ + top: 92, + message: '鏈缃富閿紒', + duration: 10 + }) + return + } + + if (item.sqlType === 'delete') { + let sysKeys = data.filter(cell => cell.uuid === 'sso_system' || cell.uuid === 'local_system') + if (sysKeys.length > 0) { + notification.warning({ + top: 92, + message: '绯荤粺瀵嗛挜涓嶅彲鍒犻櫎锛�', + duration: 10 + }) + return + } + } + + if (item.OpenType === 'prompt') { + confirm({ + title: this.props.dict['main.action.confirm.tip'], + onOk() { + return new Promise(resolve => { + _this.execSubmit(item, data, resolve) + }) + }, + onCancel() {} + }) + } else if (item.OpenType === 'pop') { + this.setState({ + visible: true, + execAction: item, + tabledata: data + }) + } + } + + /** + * @description 鎸夐挳鎻愪氦鎵ц + */ + execSubmit = (btn, data, _resolve, formdata) => { + let datalist = JSON.parse(JSON.stringify(this.props.datalist)) + + let cell = {} + if (formdata) { + formdata.forEach(_cell => { + cell[_cell.key] = _cell.value + }) + } + + if (btn.sqlType === 'insert') { + let newkey = { + uuid: Utils.getuuid(), + keyType: 'other', + ...cell + } + datalist.push(newkey) + } else if (btn.sqlType === 'update') { + let newkey = { + ...data[0], + ...cell + } + + datalist = datalist.map(item => { + if (item.uuid === newkey.uuid) { + return newkey + } else { + return item + } + }) + } else if (btn.sqlType === 'update') { + let keys = data.map(item => item.uuid) + + datalist = datalist.filter(item => !keys.includes(item.uuid)) + } else if (btn.sqlType === 'revert') { + datalist = [ + {uuid: 'sso_system', public: 'a', private: 'apple', keyType: 'sso'}, + {uuid: 'local_system', public: 'b', private: 'banana', keyType: 'local'}, + {uuid: 'other_system1', public: 'c', private: 'cherry', keyType: 'other'}, + {uuid: 'other_system2', public: 'd', private: 'damson', keyType: 'other'} + ] + } + console.log(datalist) + let _number = Math.floor(Math.random() * 10) + console.log(_number) + let keyString = window.btoa(window.encodeURIComponent(JSON.stringify(datalist))) + console.log(keyString) + let regular = refCodes[_number] + console.log(regular) + keyString = keyString.replace(new RegExp(regular.char,'g'), regular.md5str) + console.log(keyString) + // window.btoa(window.encodeURIComponent(JSON.stringify(val))) + + // for (let i = 0; i < a.length; i++) { + // if (a[i] !== b[i]) { + // console.log(i) + // console.log(src.substring(i- 10, i+ 10)) + // } + // } + // let param = { refCodes + // func: 'sPC_TableData_InUpDe', + // BID: this.props.BID + // } + // Api.genericInterface(param).then((res) => { + // if (res.status) { + // this.execSuccess(btn, res) + // } else { + // this.execError(res, btn) + // } + // _resolve() + // }) + } + + + /** + * @description 鎿嶄綔鎴愬姛鍚庡鐞� + * 1銆乪xcel瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� + * 2銆佺姸鎬佺爜涓� S 鏃讹紝鏄剧ず鎴愬姛淇℃伅鍚庣郴缁熼粯璁や俊鎭� + * 3銆佺姸鎬佺爜涓� -1 鏃讹紝涓嶆樉绀轰换浣曚俊鎭� + * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� + * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� + */ + execSuccess = (btn, res) => { + if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 + notification.success({ + top: 92, + message: res.ErrMesg || this.props.dict['main.action.confirm.success'], + duration: btn.verify && btn.verify.stime ? btn.verify.stime : 2 + }) + } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛 + Modal.success({ + title: res.ErrMesg || this.props.dict['main.action.confirm.success'] + }) + } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず + + } + + if (btn.OpenType === 'pop' && btn.setting && btn.setting.finish !== 'unclose') { + this.setState({ + visible: false + }) + } + + this.refreshdata(btn, 'success') + } + + /** + * @description 鎿嶄綔澶辫触鍚庡鐞� + * 1銆佺姸鎬佺爜涓� E銆丯銆丗銆丯M 鏃讹紝鏄剧ず鐩稿簲鎻愮ず淇℃伅 + * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� + * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂� + */ + execError = (res, btn) => { + if (res.ErrCode === 'E') { + Modal.error({ + title: res.message || res.ErrMesg, + }) + } else if (res.ErrCode === 'N') { + notification.error({ + top: 92, + message: res.message || res.ErrMesg, + duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 15 + }) + } else if (res.ErrCode === 'F') { + notification.error({ + className: 'notification-custom-error', + top: 92, + message: res.message || res.ErrMesg, + duration: btn.verify && btn.verify.ftime ? btn.verify.ftime : 15 + }) + } else if (res.ErrCode === 'NM') { + message.error(res.message || res.ErrMesg) + } + + this.refreshdata(btn, 'error') + } + + /** + * @description 妯℃�佹锛堣〃鍗曪級锛岀‘璁� + */ + handleOk = () => { + this.formRef.handleConfirm().then(res => { + this.setState({ + confirmLoading: true + }) + + this.execSubmit(this.state.execAction, this.state.tabledata, () => { + this.setState({ + confirmLoading: false + }) + }, res) + }, () => {}) + } + + /** + * @description 妯℃�佹锛堣〃鍗曪級锛屽彇娑� + */ + handleCancel = () => { + this.setState({ + visible: false + }) + } + + /** + * @description 鏄剧ず妯℃�佹 + */ + getModels = () => { + const { execAction } = this.state + + if (!execAction || !this.state.visible) return + + let title = '' + let width = '62vw' + let clickouter = false + let container = document.body + + if (execAction && execAction.setting) { + title = execAction.setting.title + width = execAction.setting.width + 'vw' + + if (execAction.setting.container === 'tab' && this.props.ContainerId) { + width = execAction.setting.width + '%' + container = () => document.getElementById(this.props.ContainerId) + } + + if (execAction.setting.clickouter === 'close') { + clickouter = true + } + } + + if (this.props.type === 'subtab') { + container = document.body + } + + return ( + <Modal + title={title} + maskClosable={clickouter} + getContainer={container} + wrapClassName='action-modal' + visible={this.state.visible} + width={width} + onOk={this.handleOk} + confirmLoading={this.state.confirmLoading} + onCancel={this.handleCancel} + destroyOnClose + > + <MutilForm + dict={this.props.dict} + action={execAction} + inputSubmit={this.handleOk} + configMap={this.state.configMap} + data={this.state.tabledata[0]} + BData={this.props.BData} + wrappedComponentRef={(inst) => this.formRef = inst} + /> + </Modal> + ) + } + + render() { + return ( + <div className="button-list toolbar-button"> + {this.props.actions.map((item, index) => { + return ( + <Button + className={'mk-btn mk-' + item.class} + icon={item.icon} + key={'action' + index} + onClick={() => {this.actionTrigger(item)}} + >{item.label}</Button> + ) + })} + {this.getModels()} + </div> + ) + } +} + +export default MainAction \ No newline at end of file diff --git a/src/tabviews/managetable/secretKeyTable/actionList/index.scss b/src/tabviews/managetable/secretKeyTable/actionList/index.scss new file mode 100644 index 0000000..9dd1f19 --- /dev/null +++ b/src/tabviews/managetable/secretKeyTable/actionList/index.scss @@ -0,0 +1,44 @@ +.button-list.toolbar-button { + position: relative; + padding: 10px 20px 5px; + background: #ffffff; + button { + min-width: 65px; + margin-right: 15px; + margin-bottom: 10px; + overflow: hidden; + } + .ant-spin { + position: fixed; + z-index: 1010; + left: calc(50vw - 22px); + top: calc(50vh - 70px); + } +} +// 璁剧疆妯℃�佹鏍峰紡锛岃瀹氭渶澶ф渶灏忛珮搴︼紝閲嶇疆婊氬姩鏉� +.action-modal { + .ant-modal { + max-width: 95vw; + } + .ant-modal-body { + max-height: calc(100vh - 235px); + min-height: 150px; + overflow-y: auto; + padding-bottom: 35px; + } + .ant-modal-body::-webkit-scrollbar { + width: 10px; + height: 10px; + } + .ant-modal-body::-webkit-scrollbar-thumb { + border-radius: 5px; + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); + background: rgba(0, 0, 0, 0.13); + } + .ant-modal-body::-webkit-scrollbar-track { + box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); + border-radius: 3px; + border: 1px solid rgba(0, 0, 0, 0.07); + background: rgba(0, 0, 0, 0); + } +} \ No newline at end of file diff --git a/src/tabviews/managetable/secretKeyTable/config.jsx b/src/tabviews/managetable/secretKeyTable/config.jsx new file mode 100644 index 0000000..9de92b3 --- /dev/null +++ b/src/tabviews/managetable/secretKeyTable/config.jsx @@ -0,0 +1,296 @@ +// HS椤甸潰閰嶇疆 +export const verupMainTable = {} + +export const buttonConfig = { + '1586616122586986g400tf610dc3rhcd': { + "type":"Modal", + "setting":{ + "title":"娣诲姞", + "width":45, + "focus":"p", + "cols":"1", + "finish":"close", + "clickouter":"unclose", + "display":"modal", + "container":"view" + }, + "tables":[], + "groups":[], + "fields":[{ + "label":"鍏挜", + "field":"public", + "type":"text", + "initval":"", + "readonly":"false", + "required":"true", + "hidden":"false", + "readin":"true", + "fieldlength":50, + "regular":"", + "supField":"", + "blacklist":[], + "uuid":"1586616164754mshqhn0dqulorb4k2ot" + }, { + "label":"绉侀挜", + "field":"private", + "type":"text", + "initval":"", + "readonly":"false", + "required":"true", + "hidden":"false", + "readin":"true", + "fieldlength":50, + "regular":"", + "supField":"", + "blacklist":[], + "uuid":"1586616188792q2m9km3k8lqbtabf8og" + }] + }, + '1586616351568k8rb0fvp3t7g6h7qso0': { + "type":"Modal", + "setting":{ + "title":"淇敼", + "width":45, + "focus":"p", + "cols":"1", + "finish":"close", + "clickouter":"unclose", + "display":"modal", + "container":"view" + }, + "tables":[], + "groups":[], + "fields":[{ + "label":"鍏挜", + "field":"public", + "type":"text", + "initval":"", + "readonly":"false", + "required":"true", + "hidden":"false", + "readin":"true", + "fieldlength":50, + "regular":"", + "supField":"", + "blacklist":[], + "uuid":"1586616164754mshqhn0dqulorb4k2ot" + },{ + "label":"绉侀挜", + "field":"private", + "type":"text", + "initval":"", + "readonly":"false", + "required":"true", + "hidden":"false", + "readin":"true", + "fieldlength":50, + "regular":"", + "supField":"", + "blacklist":[], + "uuid":"1586616188792q2m9km3k8lqbtabf8og" + }] + } +} + +export const tabConfig = { + '1586577325055l2ng7t75g7i4ek2ng8o': { + tabName:"瀵嗛挜绠$悊鏍囩椤�", + tabNo:"secret_paramM", + Remark:"", + uuid:"1586577325055l2ng7t75g7i4ek2ng8o", + setting:{ + "tableName":"sApp", + "tableType":"checkbox", + "interType":"inner", + "innerFunc":"s_get_app_secret_param", + "dataresource":"select 'a' as p,'apple' as s,'sso' as st,10 as ID union all\nselect 'b' as p,'banana' as s,'local' as st,20 as ID union all\nselect 'c' as p,'cherry' as s,'other' as st,30 as ID union all\nselect 'd' as p,'damson' as s,'other' as st,40 as ID", + "queryType":"query", + "primaryKey":"key", + "order":"key", + "onload":"true", + "actionfixed":false,"columnfixed":false + }, + search:[], + action:[ + { + "label":"娣诲姞", + "OpenType":"pop", + "intertype":"inner", + "innerFunc":"", + "position":"toolbar", + "Ot":"notRequired", + "execSuccess":"grid", + "execError":"never", + "icon":"", + "class":"green", + "sql":"sApp", + "sqlType":"insert", + "uuid":"1586616122586986g400tf610dc3rhcd", + "verify": { + "default":"true", + "invalid":"false", + "uniques":[ + { + "field":"BID,p", + "errorCode":"E", + "verifyType":"physical", + "uuid":"15866162339252q7vs9qvp83bdomkk93", + "fieldlabel":"BID,鍏挜" + } + ], + "contrasts":[], + "accountdate":"false", + "customverifys":[ + { + "sql":"select ID from sApp where id=@BID@", + "result":"false", + "errmsg":"椤甸潰鏁版嵁宸插け鏁堬紝璇峰埛鏂板悗閲嶈瘯", + "errorCode":"E", + "uuid":"1586616302289f8ic4pl2mn6so2ns3be", + "resultName":"涓嶅瓨鍦�" + } + ], + "billcodes":[], + "voucher":{"enabled":false}, + "scripts":[] + } + }, + { + "label":"淇敼", + "OpenType":"pop", + "intertype":"inner", + "innerFunc":"", + "position":"toolbar", + "Ot":"requiredSgl", + "execSuccess":"grid", + "execError":"never", + "icon":"", + "class":"purple", + "sql":"sApp", + "sqlType":"update", + "uuid":"1586616351568k8rb0fvp3t7g6h7qso0", + "verify":{ + "default":"true", + "invalid":"false", + "uniques":[{"field":"BID,p","errorCode":"E","verifyType":"physical","uuid":"15866162339252q7vs9qvp83bdomkk93","fieldlabel":"BID,鍏挜"}], + "contrasts":[], + "accountdate":"false", + "customverifys":[{"sql":"select ID from sApp where id=@BID@","result":"false","errmsg":"椤甸潰鏁版嵁宸插け鏁堬紝璇峰埛鏂板悗閲嶈瘯","errorCode":"E","uuid":"1586616302289f8ic4pl2mn6so2ns3be","resultName":"涓嶅瓨鍦�"}], + "billcodes":[], + "voucher":{"enabled":false}, + "scripts":[] + } + }, + { + "label":"鍒犻櫎", + "OpenType":"prompt", + "intertype":"inner", + "innerFunc":"", + "position":"toolbar", + "execSuccess":"grid", + "execError":"never", + "icon":"", + "class":"danger", + "sql":"sApp", + "Ot":"required", + "sqlType":"delete", + "uuid":"158661662660590kra03kb4su0t108rt", + "verify":{ + "default":"true", + "invalid":"true", + "uniques":[], + "contrasts":[{"frontfield":"@st","operator":"!=","backfield":"'other'","errmsg":"sso涓巐ocal涓虹郴缁熼粯璁ゅ彛浠や笉鍙垹闄�","errorCode":"E","uuid":"15866167196190he7utt2vbsmqu2gips"}], + "accountdate":"false", + "customverifys":[{"sql":"select ID from sApp where id=@BID@","result":"false","errmsg":"椤甸潰鏁版嵁宸插け鏁堬紝璇峰埛鏂板悗閲嶈瘯","errorCode":"E","uuid":"1586616302289f8ic4pl2mn6so2ns3be","resultName":"涓嶅瓨鍦�"}], + "billcodes":[], + "voucher":{"enabled":false}, + "scripts":[] + } + }, + { + "label":"鎭㈠榛樿璁剧疆", + "OpenType":"prompt", + "intertype":"inner", + "innerFunc":"", + "position":"toolbar", + "execSuccess":"grid", + "execError":"never", + "icon":"", + "class":"primary", + "sql":"sApp", + "Ot":"notRequired", + "sqlType":"revert", + "uuid":"158661672660590kra03kb4su0t108rt" + } + ], + columns:[ + {"label":"鍏挜","field":"public","type":"text","Align":"left","Hide":"false","IsSort":"true","Width":120,"prefix":"","postfix":"","matchVal":"","color":"","fieldlength":50,"blacklist":[],"linkmenu":[],"uuid":"15866156221702kced0rmbsnekd82s6d"}, + {"label":"绉侀挜","field":"private","type":"text","Align":"left","Hide":"false","IsSort":"true","Width":120,"prefix":"","postfix":"","matchVal":"","color":"","fieldlength":50,"blacklist":[],"linkmenu":[],"uuid":"1586615651169h67un3tmhuc8pf7kehs"}, + {"label":"绫诲瀷","field":"keyType","type":"text","Align":"left","Hide":"false","IsSort":"true","Width":120,"prefix":"","postfix":"","matchVal":"","color":"","fieldlength":50,"blacklist":[],"linkmenu":[],"uuid":"15866156745953m73rhs9c0nmu6mmbo6"} + ], + gridBtn:{"display":false,"Align":"center","IsSort":"false","uuid":"1586577404115eudahgc9nn0gam1saho","label":"鎿嶄綔","type":"action","style":"button","show":"horizontal","Width":120}, + } +} + +export const refCodes = [ + { + index: 0, + char: 'a', + sqlstr: 'b6831c399e269772661', + md5str: '526a465ab0fa6f6df28ca459d50b2622' + }, + { + index: 1, + char: 'b', + sqlstr: '2fec3ad71c777531578f', + md5str: '5d941f8268e5e5ba47a93fa2b4ed960e' + }, + { + index: 2, + char: 'd', + sqlstr: '0195b448797616e091a', + md5str: 'ed65250fa9757c60f9acc9f3e977fb17' + }, + { + index: 3, + char: 'g', + sqlstr: '71b6e533d8dc3614845d', + md5str: '6609c8e4f10ed61fea96a747cb54d00e' + }, + { + index: 4, + char: 'k', + sqlstr: '8894aa86c421e8759df3', + md5str: '759ecadb8eaf10ec9daeefe6e8928b18' + }, + { + index: 5, + char: 'p', + sqlstr: '38902e0fe0fb97a8c47a', + md5str: 'b7679fa01bd435f407746351a6aecf2b' + }, + { + index: 6, + char: 'v', + sqlstr: '5bd57058fd4664205d2a', + md5str: 'c1761cd95acb804220e0429cd63a9e9a' + }, + { + index: 7, + char: 'x', + sqlstr: '8034f5c8564e155c67a6', + md5str: '8d844d9007aa9ea9e2f2a822e432edbe' + }, + { + index: 8, + char: 'y', + sqlstr: '460e2e485922904f345d', + md5str: '6dfbe93c0570998a740ba410a6ec0f49' + }, + { + index: 9, + char: '0', + sqlstr: '65ef66e7dff9f98764da', + md5str: '3340c8dc496c953865d920d06ff8c4c9' + } +] diff --git a/src/tabviews/managetable/secretKeyTable/index.jsx b/src/tabviews/managetable/secretKeyTable/index.jsx new file mode 100644 index 0000000..7141cc7 --- /dev/null +++ b/src/tabviews/managetable/secretKeyTable/index.jsx @@ -0,0 +1,384 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' +import { notification, Switch} from 'antd' + +import Api from '@/api' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import options from '@/store/options.js' +import { buttonConfig, tabConfig } from './config' + +import SubTable from '@/tabviews/zshare/normalTable' +import SubAction from './actionList' + +import './index.scss' + +class VerupSubTabViewTable extends Component { + static propTpyes = { + menuType: PropTypes.any, // 鑿滃崟绫诲瀷锛屾櫘閫氳彍鍗曟垨HS + Tab: PropTypes.object, // 鏍囩淇℃伅 + BID: PropTypes.string, // 涓婄骇鏁版嵁ID + BData: PropTypes.any, // 涓婄骇鏁版嵁 + MenuID: PropTypes.string, // 鑿滃崟Id + SupMenuID: PropTypes.string, // 涓婄骇鑿滃崟Id + ContainerId: PropTypes.any, // 涓夌骇鑿滃崟Container(html) ID + handleTableId: PropTypes.func, // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d + handleMainTable: PropTypes.func, // 鍒锋柊涓昏〃 + refreshtabs:PropTypes.any + } + + state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + config: null, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 + actions: null, // 鎸夐挳闆� + columns: null, // 鏄剧ず鍒� + setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 + data: null, // 鍒楄〃鏁版嵁闆� + loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� + visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 + pickup: false, // 瀛愯〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 + } + + /** + * @description 涓婄骇鑿滃崟id鍙樺寲鏃讹紝鍒锋柊鏁版嵁 + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { + this.refs.subTable.resetTable() + this.loadmaindata(nextProps.BID, 'refresh') + } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { + + this.reloadtable() + } + } + + /** + * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 + */ + async loadconfig () { + const { Tab, BID } = this.props + + let config = tabConfig[this.props.MenuID] + + let _arrField = [] // 瀛楁闆� + let _columns = [] // 鏄剧ず鍒� + let _hideCol = [] // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆� + let colMap = new Map() + + // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid + config.columns.forEach(col => { + if (col.field) { + _arrField.push(col.field) + + } + if (col.type === 'colspan' && col.sublist) { // 绛涢�夐殣钘忓垪 + _hideCol = _hideCol.concat(col.sublist) + } else if (col.Hide === 'true') { + _hideCol.push(col.uuid) + } + colMap.set(col.uuid, col) + }) + + // 鐢熸垚鏄剧ず鍒楋紝澶勭悊鍚堝苟鍒椾腑鐨勫瓧娈� + config.columns.forEach(col => { + if (_hideCol.includes(col.uuid)) return + + if (col.type === 'colspan' && col.sublist) { + let _col = JSON.parse(JSON.stringify(col)) + let subColumn = [] + _col.sublist.forEach(sub => { + if (colMap.has(sub)) { + subColumn.push(colMap.get(sub)) + } + }) + _col.subColumn = subColumn + _columns.push(_col) + } else { + _columns.push(col) + } + }) + + this.setState({ + config: config, + setting: config.setting, + actions: config.action.map(item => { + if (buttonConfig[item.uuid]) { + item = {...buttonConfig[item.uuid], ...item} + } + return item + }), + columns: _columns + }, () => { + if (config.setting.onload !== 'false' && (!Tab.supMenu || BID)) { // 鍒濆鍖栧彲鍔犺浇 + this.setState({ + loading: true + }) + this.loadmaindata() + } + }) + } + + /** + * @description 瀛愯〃鏁版嵁鍔犺浇 + */ + async loadmaindata (bid, type) { + const { setting } = this.state + let param = '' + let _BID = this.props.BID + + if (type === 'refresh') { + _BID = bid + if (!bid) { // 涓昏〃ID涓嶅瓨鍦ㄦ椂锛屼笉鏌ヨ瀛愯〃 + this.setState({ + data: [], + loading: false + }) + + return + } + } + + if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { + param = this.getCustomParam(_BID) + } else { + param = this.getDefaultParam(_BID) + } + + this.handleTableId() + + let result = await Api.getLocalConfig(param) + + if (result.status) { + // let _data = result.secret_param + + let _data = [ + {uuid: 'sso_system', public: 'a', private: 'apple', keyType: 'sso'}, + {uuid: 'local_system', public: 'b', private: 'banana', keyType: 'local'}, + {uuid: 'other_system1', public: 'c', private: 'cherry', keyType: 'other'}, + {uuid: 'other_system2', public: 'd', private: 'damson', keyType: 'other'} + ] + _data = _data.map((item, index) => { + item.key = index + return item + }) + // Math.floor(Math.random()*10) + try { + + } catch { + this.setState({ + loading: false + }) + notification.error({ + top: 92, + message: '瀵嗛挜缁勬暟鎹牸寮忛敊璇紝璇锋仮澶嶉粯璁よ缃悗锛岄噸鏂版坊鍔狅紒', + duration: 15 + }) + return + } + this.setState({ + data: _data, + pickup: false, + loading: false + }) + } else { + this.setState({ + loading: false + }) + notification.error({ + top: 92, + message: result.message, + duration: 15 + }) + } + } + + /** + * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� + */ + getCustomParam = (BID) => { + const { setting } = this.state + + let param = { + BID: BID + } + + if (setting.interType === 'inner') { + param.func = setting.innerFunc + } else { + if (setting.sysInterface === 'true' && options.cloudServiceApi) { + param.rduri = options.cloudServiceApi + } else if (setting.sysInterface !== 'true') { + param.rduri = setting.interface + } + + param.appkey = window.GLOB.appkey || '' // 璋冪敤澶栭儴鎺ュ彛澧炲姞appkey + + if (setting.outerFunc) { + param.func = setting.outerFunc + } + } + + return param + } + + /** + * @description 琛ㄦ牸鏉′欢鏀瑰彉鏃堕噸缃暟鎹紙鍒嗛〉鎴栨帓搴忥級 + */ + refreshbytable = (pagination, filters, sorter) => { + let { data } = this.state + + if (!data || data.length === 0 || !sorter.columnKey) return + + if (sorter.order === 'asc' || sorter.order === 'ascend') { + data.sort((a, b) => { + return a[sorter.columnKey].localeCompare(b[sorter.columnKey]) + }) + } else if (sorter.order === 'desc' || sorter.order === 'descend') { + data.sort((a, b) => { + return b[sorter.columnKey].localeCompare(a[sorter.columnKey]) + }) + } + + this.setState({data}) + } + + /** + * @description 琛ㄦ牸鍒锋柊 + */ + reloadtable = () => { + this.refs.subTable.resetTable() + this.setState({ + loading: true, + }, () => { + this.loadmaindata() + }) + } + + /** + * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� + */ + reloadview = () => { + this.setState({ + config: null, + actions: null, + columns: null, + setting: null, + data: null, + loading: false, + }, () => { + this.loadconfig() + }) + } + + /** + * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� + */ + refreshbyaction = (btn, type) => { + if (btn.execSuccess === 'grid' && type === 'success') { + this.reloadtable() + } else if (btn.execError === 'grid' && type === 'error') { + this.reloadtable() + } else if (btn.execSuccess === 'view' && type === 'success') { + this.reloadview() + } else if (btn.execError === 'view' && type === 'error') { + this.reloadview() + } + } + + /** + * @description 鑾峰彇琛ㄦ牸閫夋嫨椤� + */ + gettableselected = () => { + let data = [] + this.refs.subTable.state.selectedRowKeys.forEach(item => { + data.push(this.refs.subTable.props.data[item]) + }) + return data + } + + /** + * @description 琛ㄦ牸Id鍙樺寲 + */ + handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => { + this.props.handleTableId(type, id, data) + } + + /** + * @description 鏁版嵁灞曞紑鍚堝苟鍒囨崲 + */ + pickupChange = () => { + const { pickup } = this.state + + this.setState({ + pickup: !pickup + }) + } + + UNSAFE_componentWillMount() { + // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 + this.loadconfig() + } + + shouldComponentUpdate (nextProps, nextState) { // handleMainTable 鍑芥暟鍒ゆ柇鏃朵笉鐩哥瓑 + return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + + render() { + const { setting, actions, columns, pickup } = this.state + + return ( + <div className="subtable" id={'subtable' + this.props.MenuID}> + <div className="sub-action"> + <SubAction + ref="subButton" + type="sub" + setting={setting} + actions={actions} + Tab={this.props.Tab} + BID={this.props.BID} + datalist={this.state.data} + dict={this.state.dict} + MenuID={this.props.SupMenuID} + logcolumns={[]} + refreshdata={this.refreshbyaction} + ContainerId={this.props.ContainerId} + getexceloutparam={this.getexceloutparam} + gettableselected={this.gettableselected} + /> + </div> + <div className="subtable-box"> + {this.state.data && this.state.data.length > 0 ? + <Switch title="鏀惰捣" className="subtable-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null + } + <SubTable + ref="subTable" + tableId={this.props.Tab.uuid} + pickup={pickup} + setting={setting} + columns={columns} + pagination={false} + dict={this.state.dict} + data={this.state.data} + MenuID={this.props.MenuID} + loading={this.state.loading} + refreshdata={this.refreshbytable} + buttonTrigger={() => {}} + handleTableId={this.handleTableId} + /> + </div> + </div> + ) + } +} + +export default VerupSubTabViewTable \ No newline at end of file diff --git a/src/tabviews/managetable/secretKeyTable/index.scss b/src/tabviews/managetable/secretKeyTable/index.scss new file mode 100644 index 0000000..7203900 --- /dev/null +++ b/src/tabviews/managetable/secretKeyTable/index.scss @@ -0,0 +1,47 @@ +.subtable { + position: relative; + min-height: 200px; + + > .top-search { + padding: 0 0px 20px; + } + >.sub-action { + min-height: 25px; + .button-list { + padding: 10px 0px 5px; + } + } + .normal-data-table { + padding: 0px; + } + .box404 { + padding-top: 30px; + } + .ant-modal-mask { + position: absolute; + } + .ant-modal-wrap { + position: absolute; + } + .action-modal .ant-modal { + top: 40px; + max-width: 95%; + .ant-modal-body { + max-height: calc(100vh - 265px); + } + } + > .ant-spin { + position: absolute; + left: calc(50% - 22px); + top: 100px; + } + .subtable-box { + position: relative; + .subtable-pickup { + position: absolute; + right: 5px; + top: -22px; + z-index: 10; + } + } +} diff --git a/src/tabviews/verupmanage/config.js b/src/tabviews/verupmanage/config.jsx similarity index 100% rename from src/tabviews/verupmanage/config.js rename to src/tabviews/verupmanage/config.jsx diff --git a/src/tabviews/verupmanage/index.jsx b/src/tabviews/verupmanage/index.jsx index 54c6ea7..1f2d0b9 100644 --- a/src/tabviews/verupmanage/index.jsx +++ b/src/tabviews/verupmanage/index.jsx @@ -10,7 +10,7 @@ import Utils from '@/utils/utils.js' import options from '@/store/options.js' import asyncLoadComponent from '@/utils/asyncLoadComponent' -import { verupMainTable, buttonConfig } from './config.js' +import { verupMainTable, buttonConfig } from './config' import MainTable from '@/tabviews/zshare/normalTable' import TopSearch from './topSearch' diff --git a/src/tabviews/verupmanage/subtabtable/index.jsx b/src/tabviews/verupmanage/subtabtable/index.jsx index fb03998..685ad1c 100644 --- a/src/tabviews/verupmanage/subtabtable/index.jsx +++ b/src/tabviews/verupmanage/subtabtable/index.jsx @@ -9,7 +9,7 @@ import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' import options from '@/store/options.js' -import { buttonConfig, tabConfig } from '../config.js' +import { buttonConfig, tabConfig } from '../config' import SubTable from '@/tabviews/zshare/normalTable' import SubAction from '../actionList' diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 78abe49..ab71c63 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -1133,7 +1133,7 @@ } } else if (btn.sql) { param.ID = primaryId - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, '', param, data[0], logcolumns)) // 鏁版嵁婧� + param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, '', param, data[0], logcolumns, this.props.Tab)) // 鏁版嵁婧� param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) } @@ -1160,12 +1160,12 @@ } param.ID = primaryId || Utils.getguid() - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns)) // 鏁版嵁婧� + param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns, this.props.Tab)) // 鏁版嵁婧� param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) } else if (btn.sql) { param.ID = primaryId - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns)) // 鏁版嵁婧� + param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns, this.props.Tab)) // 鏁版嵁婧� param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) } @@ -1204,7 +1204,7 @@ } } else if (btn.sql) { param.ID = primaryId - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, '', param, cell, logcolumns)) // 鏁版嵁婧� + param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, '', param, cell, logcolumns, this.props.Tab)) // 鏁版嵁婧� param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) } @@ -1225,7 +1225,7 @@ } } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid param.ID = _formPrimaryId || Utils.getguid() - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, cell, logcolumns)) // 鏁版嵁婧� + param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, cell, logcolumns, this.props.Tab)) // 鏁版嵁婧� param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) } else if (btn.sql) { @@ -1239,7 +1239,7 @@ } param.ID = primaryId - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, cell, logcolumns)) // 鏁版嵁婧� + param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, cell, logcolumns, this.props.Tab)) // 鏁版嵁婧� param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) } diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index ab5a446..ddbbaac 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -6,6 +6,11 @@ const { Paragraph } = Typography export default class MainTable extends Component { + static defaultProps = { + pagination: true, + total: 0 + } + static propTpyes = { tableId: PropTypes.string, // 鍒楄〃Id dict: PropTypes.object, // 瀛楀吀椤� @@ -14,12 +19,13 @@ pickup: PropTypes.any, // 鏁版嵁鏀惰捣 columns: PropTypes.array, // 琛ㄦ牸鍒� data: PropTypes.any, // 琛ㄦ牸鏁版嵁 - total: PropTypes.number, // 鎬绘暟 + total: PropTypes.any, // 鎬绘暟 loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� buttonTrigger: PropTypes.func, // 琛ㄦ牸涓寜閽Е鍙戞搷浣� linkTrigger: PropTypes.func, // 瀛楁閫忚 - handleTableId: PropTypes.func // 鏁版嵁鍒囨崲 + handleTableId: PropTypes.func, // 鏁版嵁鍒囨崲 + pagination: PropTypes.any // 鏁版嵁鍒囨崲 } state = { @@ -468,7 +474,7 @@ } render() { - const { setting, pickup } = this.props + const { setting, pickup, pagination } = this.props let { selectedRowKeys } = this.state // 璁剧疆琛ㄦ牸閫夋嫨灞炴�э細鍗曢�夈�佸閫夈�佷笉鍙�� @@ -503,6 +509,18 @@ _data = _data.filter((item, index) => selectedRowKeys.includes(index)) } + let _pagination = false + if (pagination) { + _pagination = { + current: this.state.pageIndex, + pageSize: this.state.pageSize, + pageSizeOptions: ['10', '25', '50', '100', '500', '1000'], + showSizeChanger: true, + total: this.props.total, + showTotal: (total, range) => `${range[0]}-${range[1]} ${this.props.dict['main.pagination.of']} ${total} ${this.props.dict['main.pagination.items']}` + } + } + return ( <div className="normal-data-table"> {offset && <Affix offsetTop={offset} className="fix-header"> @@ -534,14 +552,7 @@ } }} onChange={this.changeTable} - pagination={{ - current: this.state.pageIndex, - pageSize: this.state.pageSize, - pageSizeOptions: ['10', '25', '50', '100', '500', '1000'], - showSizeChanger: true, - total: this.props.total, - showTotal: (total, range) => `${range[0]}-${range[1]} ${this.props.dict['main.pagination.of']} ${total} ${this.props.dict['main.pagination.items']}` - }} + pagination={_pagination} /> <Modal className="image-scale-modal" diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 832bea2..12db490 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -663,9 +663,18 @@ type: 'mutilselect', key: 'equalTab', label: this.state.dict['header.form.equalTab'], + tooltip: '濡傛灉瀛愭爣绛句腑鍚湁鍒锋柊鍚岀骇鏍囩鐨勬寜閽紝鍦ㄦ澶勬坊鍔犻渶瑕佸埛鏂扮殑鏍囩銆�', initVal: equalTab, required: false, options: equalTabs + }, + { + type: 'text', + key: 'foreignKey', + label: '澶栭敭', + tooltip: '澶栭敭鏃ㄥ湪鏍囩椤典腑鎵ц榛樿鍑芥暟锛堟坊鍔狅級鏃讹紝鏇挎崲BID瀛楁', + initVal: card.foreignKey || '', + required: false } ] }) diff --git a/src/templates/formtabconfig/actionform/index.jsx b/src/templates/formtabconfig/actionform/index.jsx index c1ed1b0..1b9bdc0 100644 --- a/src/templates/formtabconfig/actionform/index.jsx +++ b/src/templates/formtabconfig/actionform/index.jsx @@ -29,6 +29,9 @@ }, { value: 'update', text: this.props.dict['header.form.action.update'] + }, { + value: 'insertOrUpdate', + text: this.props.dict['header.form.action.insertOrUpdate'] }], returnoptions: [{ // 杩斿洖鍚�-涓嶅埛鏂般�佸埛鏂伴〉闈€�佸埛鏂拌〃鏍� value: 'never', diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index d577483..23a97f2 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -614,9 +614,18 @@ type: 'mutilselect', key: 'equalTab', label: this.state.dict['header.form.equalTab'], + tooltip: '濡傛灉瀛愭爣绛句腑鍚湁鍒锋柊鍚岀骇鏍囩鐨勬寜閽紝鍦ㄦ澶勬坊鍔犻渶瑕佸埛鏂扮殑鏍囩銆�', initVal: equalTab, required: false, options: equalTabs + }, + { + type: 'text', + key: 'foreignKey', + label: '澶栭敭', + tooltip: '澶栭敭鏃ㄥ湪鏍囩椤典腑鎵ц榛樿鍑芥暟锛堟坊鍔狅級鏃讹紝鏇挎崲BID瀛楁', + initVal: card.foreignKey || '', + required: false } ] }) diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx index f8396a3..e79277d 100644 --- a/src/templates/zshare/modalform/index.jsx +++ b/src/templates/zshare/modalform/index.jsx @@ -19,7 +19,7 @@ datemonth: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist'], datetime: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist'], textarea: ['label', 'field', 'initval', 'type', 'readonly', 'required', 'hidden', 'readin', 'blacklist', 'fieldlength', 'maxRows'], - funcvar: ['label', 'field', 'type', 'blacklist'], + funcvar: ['label', 'field', 'type', 'blacklist', 'hidden'], linkMain: ['label', 'field', 'type', 'readonly', 'required', 'hidden', 'fieldlength', 'blacklist'] } diff --git a/src/templates/zshare/tabform/index.jsx b/src/templates/zshare/tabform/index.jsx index 64b356a..98d21c0 100644 --- a/src/templates/zshare/tabform/index.jsx +++ b/src/templates/zshare/tabform/index.jsx @@ -113,9 +113,23 @@ if (item.hidden) return if (item.type === 'text') { // 鏂囨湰鎼滅储 + let rules = [] + + if (item.key === 'foreignKey') { + rules.push({ + pattern: /^[a-zA-Z_]*$/ig, + message: item.label + '瀛楁鍙厑璁稿寘鍚瓧姣嶅強涓嬪垝绾匡紒' + }) + } fields.push( <Col span={12} key={index}> - <Form.Item label={item.label}> + <Form.Item label={ + item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.key, { initialValue: item.initVal, rules: [ @@ -126,7 +140,8 @@ { max: formRule.input.max, message: formRule.input.message - } + }, + ...rules ] })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} </Form.Item> @@ -164,10 +179,11 @@ fields.push( <Col span={12} key={index}> <Form.Item label={ - <Tooltip placement="topLeft" title="鏍囩娣诲姞鍚岀骇鏍囩鍚庯紝鏍囩涓寜閽埛鏂颁富琛ㄦ椂锛屾坊鍔犵殑鍚岀骇鏍囩浼氬埛鏂般��"> + item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> <Icon type="question-circle" /> {item.label} - </Tooltip> + </Tooltip> : item.label }> {getFieldDecorator(item.key, { initialValue: item.initVal diff --git a/src/templates/zshare/verifycard/customscript/index.jsx b/src/templates/zshare/verifycard/customscript/index.jsx index 52f237b..73cff36 100644 --- a/src/templates/zshare/verifycard/customscript/index.jsx +++ b/src/templates/zshare/verifycard/customscript/index.jsx @@ -70,9 +70,13 @@ return } + let tail = ` + aaa: + ` + let param = { func: 's_debug_sql', - LText: this.props.initsql + values.sql + LText: this.props.initsql + values.sql + tail } param.LText = Utils.formatOptions(param.LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index 452686b..ce85f97 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -458,8 +458,8 @@ } let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName'] - let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)'] - let _select = ['@UserName=\'\'', '@FullName=\'\''] + let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)'] + let _select = ['@UserName=\'\'', '@FullName=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\''] let hasBid = false let fieldArr = _usefulfields.map(_f => _f.toLowerCase()) @@ -552,8 +552,8 @@ }) } else { let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName'] - let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)'] - let _select = ['@UserName=\'\'', '@FullName=\'\''] + let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)'] + let _select = ['@UserName=\'\'', '@FullName=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\''] let fieldArr = _usefulfields.map(_f => _f.toLowerCase()) if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired') { diff --git a/src/templates/zshare/verifycardexcelin/customscript/index.jsx b/src/templates/zshare/verifycardexcelin/customscript/index.jsx index 51513c3..c1fa819 100644 --- a/src/templates/zshare/verifycardexcelin/customscript/index.jsx +++ b/src/templates/zshare/verifycardexcelin/customscript/index.jsx @@ -38,7 +38,8 @@ } let _sql = `Declare @${btn.sheet} table (${usefulfields.map(item => item.Column + ' ' + item.type).join(',')},jskey nvarchar(50) ) - Declare @UserName nvarchar(50),@FullName nvarchar(50) + Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50), @retmsg nvarchar(4000) + Select @ErrorCode='', @retmsg='' ` this.setState({ @@ -121,9 +122,13 @@ return } + let tail = ` + aaa: + ` + let param = { func: 's_debug_sql', - LText: this.state.verifySql + values.sql + LText: this.state.verifySql + values.sql + tail } param.LText = Utils.formatOptions(param.LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' diff --git a/src/utils/utils.js b/src/utils/utils.js index 506e85e..b59e5a2 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -164,8 +164,8 @@ }) // 1銆佹浛鎹�%绗︼紙鏁版嵁搴撲腑瑙f瀽鍚巗ql鎶ラ敊锛夛紝2銆佸幓闄ゆ敹灏惧浣欑┖鏍� - value = value.replace(/%/ig, 'mpercent') - value = value.replace(/(^\s|\s$)/ig, '') + value = value.replace(/%/ig, ' mpercent ') + // value = value.replace(/(^\s|\s$)/ig, '') // 1銆乪ncode缂栫爜锛堜腑鏂囧瓧绗﹁秴鍑篵ase64鍔犲瘑鑼冨洿锛夛紝2銆乥ase64鍔犲瘑 value = window.btoa(window.encodeURIComponent(value)) @@ -505,7 +505,7 @@ }) } } else if (/^int/ig.test(col.type)) { - if (!val) { + if (!val && val !== 0) { let _error = _position + dict['main.excel.content.emptyerror'] errors.push(_error) } else { @@ -523,7 +523,7 @@ } } } else if (/^Decimal/ig.test(col.type)) { - if (!val) { + if (!val && val !== 0) { let _error = _position + dict['main.excel.content.emptyerror'] errors.push(_error) } else { @@ -667,7 +667,7 @@ * @return {String} type 鎵ц绫诲瀷 * @return {String} table 琛ㄥ悕 */ - static getSysDefaultSql (btn, setting, formdata, param, data, logcolumns) { + static getSysDefaultSql (btn, setting, formdata, param, data, logcolumns, tab) { let primaryId = param.ID let BID = param.BID let verify = btn.verify || {} @@ -985,8 +985,9 @@ _actionType = btn.sqlType } - // 娣诲姞銆佷慨鏀广�侀�昏緫鍒犻櫎銆佺墿鐞嗗垹闄� - if (_actionType === 'insert') { + let _insertsql = '' + let _updatesql = '' + if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { // 娣诲姞璇彞 let keys = [] let values = [] @@ -1020,14 +1021,18 @@ values.push('@fullname') } if (!keys.includes('bid')) { - keys.push('bid') + if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) { + keys.push(tab.foreignKey) + } else { + keys.push('bid') + } values.push('@BID@') } keys = keys.join(',') values = values.join(',') - _sql += `insert into ${btn.sql} (${keys}) select ${values};` - } else if (_actionType === 'update') { + _insertsql = `insert into ${btn.sql} (${keys}) select ${values};` + } else if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { // 淇敼璇彞 let _form = [] let _arr = [] @@ -1062,7 +1067,14 @@ } _form = _form.join(',') - _sql += `update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKeyName};` + _updatesql = `update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKeyName};` + } + + // 娣诲姞銆佷慨鏀广�侀�昏緫鍒犻櫎銆佺墿鐞嗗垹闄� + if (_actionType === 'insert') { + _sql += _insertsql + } else if (_actionType === 'update') { + _sql += _updatesql } else if (_actionType === 'LogicDelete') { // 閫昏緫鍒犻櫎 _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKeyName};` @@ -1078,6 +1090,14 @@ }) } _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select '鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${_msg}${primaryKey}='+@${primaryKeyName},@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKeyName};` + } else if (_actionType === 'insertOrUpdate') { + _sql += `select @tbid='' + select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@ + if @tbid='' + ${_insertsql} + else + ${_updatesql} + ` } // 鎷兼帴鑷畾涔夎剼鏈� -- Gitblit v1.8.0