From 89e7167a83e0d8409ca87698e4c08651a37cc26e Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 12 六月 2020 18:19:35 +0800 Subject: [PATCH] 2020-06-12 --- src/tabviews/formtab/index.jsx | 8 src/tabviews/verupmanage/actionList/index.jsx | 6 src/tabviews/zshare/actionList/popupbutton/index.jsx | 183 src/tabviews/zshare/actionList/tabbutton/index.scss | 10 src/tabviews/zshare/normalTable/index.jsx | 113 src/templates/sharecomponent/cardcomponent/index.scss | 4 src/tabviews/zshare/settingcomponent/index.jsx | 170 src/templates/zshare/verifycard/customscript/index.jsx | 2 src/tabviews/commontable/secretKeyTable/index.jsx | 85 src/tabviews/zshare/actionList/excelInbutton/index.jsx | 400 ++ src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx | 31 src/tabviews/home/index.jsx | 29 src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx | 2 src/tabviews/zshare/actionList/newpagebutton/index.jsx | 112 src/tabviews/subtabtable/index.jsx | 116 src/tabviews/zshare/actionList/excelInbutton/excelin/index.scss | 0 src/templates/sharecomponent/cardcomponent/carddetailform/index.jsx | 8 src/tabviews/commontable/index.jsx | 742 +-- src/tabviews/zshare/actionList/normalbutton/index.jsx | 1022 +++++ src/tabviews/zshare/actionList/changeuserbutton/index.jsx | 153 src/templates/zshare/verifycard/voucherform/index.jsx | 12 src/store/reducer.js | 2 src/templates/sharecomponent/actioncomponent/actionform/index.jsx | 45 src/tabviews/zshare/mutilform/index.1.jsx | 845 ++++ src/tabviews/commontable/secretKeyTable/actionList/index.scss | 0 src/tabviews/commontable/secretKeyTable/config.jsx | 4 src/tabviews/zshare/mutilform/index.jsx | 111 src/tabviews/commontable/index.scss | 3 src/tabviews/verupmanage/index.jsx | 36 src/tabviews/zshare/cardcomponent/index.jsx | 250 + src/tabviews/zshare/actionList/asyncButtonComponent.jsx | 32 src/components/tabview/index.jsx | 5 src/tabviews/treepage/index.jsx | 1 src/tabviews/zshare/actionList/index.scss | 19 src/tabviews/commontable/secretKeyTable/index.scss | 0 src/tabviews/zshare/actionList/changeuserbutton/index.scss | 10 src/views/login/loginform.jsx | 2 src/components/header/index.jsx | 14 src/tabviews/verupmanage/subtabtable/index.jsx | 54 src/tabviews/zshare/actionList/normalbutton/index.scss | 10 src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 691 +++ src/tabviews/zshare/actionList/index.jsx | 2859 -------------- src/tabviews/zshare/actionList/excelInbutton/index.scss | 3 src/tabviews/zshare/actionList/newpagebutton/index.scss | 10 src/tabviews/zshare/actionList/exceloutbutton/index.scss | 3 src/tabviews/subtable/index.jsx | 215 src/tabviews/zshare/actionList/printbutton/index.scss | 232 - src/utils/asyncSpinComponent.jsx | 2 src/templates/sharecomponent/cardcomponent/index.jsx | 23 src/tabviews/zshare/actionList/tabbutton/index.jsx | 143 src/tabviews/scriptmanage/actionList/index.jsx | 11 src/templates/zshare/formconfig.jsx | 42 src/templates/comtableconfig/source.jsx | 14 src/tabviews/zshare/settingcomponent/index.scss | 0 src/tabviews/zshare/actionList/printbutton/index.jsx | 1945 +--------- src/tabviews/zshare/cardcomponent/index.scss | 38 /dev/null | 105 src/tabviews/scriptmanage/index.jsx | 53 src/components/sidemenu/index.jsx | 4 src/tabviews/commontable/secretKeyTable/actionList/index.jsx | 22 src/tabviews/zshare/actionList/popupbutton/index.scss | 10 src/views/login/index.jsx | 22 62 files changed, 5,224 insertions(+), 5,874 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 447c585..52532fa 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -348,7 +348,7 @@ } if (window.GLOB.systemType === 'official' && state) { - this.props.resetEditLevel('level4') + this.props.resetEditLevel('HS') this.props.modifyMainMenu({ MenuID: 'systemManageView' }) @@ -435,7 +435,7 @@ } if (window.GLOB.systemType === 'official') { - this.props.resetEditLevel('level4') + this.props.resetEditLevel('HS') this.props.modifyMainMenu({ MenuID: 'systemManageView' }) @@ -483,9 +483,9 @@ enterEditManage = () => { const { editLevel } = this.props - if (editLevel === 'level4') return + if (editLevel === 'HS') return - this.props.resetEditLevel('level4') + this.props.resetEditLevel('HS') this.props.modifyMainMenu({ MenuID: 'systemManageView' }) @@ -668,14 +668,14 @@ </li> ) })} - {this.props.editState && (!this.props.editLevel || this.props.editLevel === 'level4') ? - <li key="HS" onClick={this.enterEditManage} className={this.props.editLevel === 'level4' ? 'active' : ''}> + {this.props.editState && (!this.props.editLevel || this.props.editLevel === 'HS') ? + <li key="HS" onClick={this.enterEditManage} className={this.props.editLevel === 'HS' ? 'active' : ''}> <span>HS</span> </li> : null } </ul> : null } - {this.props.editLevel === 'level4' ? <Button className="level4-close" type="primary" onClick={this.exitManage}>閫�鍑�</Button> : null} + {this.props.editLevel === 'HS' ? <Button className="level4-close" type="primary" onClick={this.exitManage}>閫�鍑�</Button> : null} {/* 杩涘叆缂栬緫鎸夐挳 */} {this.props.editState && !this.props.editLevel ? <Icon onClick={this.enterEdit} className="edit-check" type="edit" /> : null} {this.props.editState && !this.props.editLevel ? <a href="#/mobile" target="_blank" className="mobile" type="edit"> 绉诲姩绔� <Icon type="arrow-right" /></a> : null} diff --git a/src/components/sidemenu/index.jsx b/src/components/sidemenu/index.jsx index 4929b7e..28b9c07 100644 --- a/src/components/sidemenu/index.jsx +++ b/src/components/sidemenu/index.jsx @@ -57,7 +57,7 @@ let result = await Api.getSystemConfig(_param) if (result.status) { - if (this.props.editState && this.props.editLevel === 'level4') return + if (this.props.editState && this.props.editLevel === 'HS') return if (result.data.length === 0) { // 鏌ヨ鑿滃崟涓虹┖ this.setState({ @@ -194,7 +194,7 @@ } changemenu(e) { - if (this.props.editState && this.props.editLevel !== 'level4') { + if (this.props.editState && this.props.editLevel !== 'HS') { e.preventDefault() return } diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx index 587c42a..0ca4444 100644 --- a/src/components/tabview/index.jsx +++ b/src/components/tabview/index.jsx @@ -22,7 +22,6 @@ const VerupTable = asyncComponent(() => import('@/tabviews/verupmanage')) const ScriptTable = asyncComponent(() => import('@/tabviews/scriptmanage')) const TabManage = asyncComponent(() => import('@/tabviews/tabmanage')) -const ManageTable = asyncComponent(() => import('@/tabviews/managetable')) const Iframe = asyncComponent(() => import('@/tabviews/iframe')) const DataManage = asyncComponent(() => import('@/tabviews/datamanage')) const RoleManage = asyncComponent(() => import('@/tabviews/rolemanage')) @@ -101,7 +100,7 @@ // 鏍规嵁tab椤典腑鑿滃崟淇℃伅锛岄�夋嫨鎵�闇�鐨勭粍浠� if (view.type === 'Home') { return (<Home MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>) - } else if (view.type === 'CommonTable') { + } else if (view.type === 'CommonTable' || view.type === 'ManageTable') { return (<CommonTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID} param={view.param}/>) } else if (view.type === 'TreePage') { return (<TreePage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>) @@ -111,8 +110,6 @@ return (<ScriptTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>) } else if (view.type === 'TabManage') { return (<TabManage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>) - } else if (view.type === 'ManageTable') { - return (<ManageTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>) } else if (view.type === 'DataManage') { return (<DataManage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} key={view.MenuID}/>) } else if (view.type === 'RolePermission') { diff --git a/src/store/reducer.js b/src/store/reducer.js index efaacbe..397dba2 100644 --- a/src/store/reducer.js +++ b/src/store/reducer.js @@ -23,7 +23,7 @@ isiframe: false, // 鏄惁涓篿frame绐楀彛 debug: false, // 鐭ュ惁鍙互澶嶅埗鑿滃崟鍙傛暟, 鏄惁鍙繘鍏ョ紪杈戞ā寮� editState: false, // 鏄惁涓虹紪杈戠姸鎬侊紝鍊间负false銆乼rue - editLevel: null, // 缂栬緫鑿滃崟绾у埆锛屽�间负level1銆乴evel2銆乴evel3銆傘�傘�� + editLevel: null, // 缂栬緫鑿滃崟绾у埆锛屽�间负level1銆乴evel2銆乴evel3銆丠S refreshTab: null, // 鍒锋柊tabview椤甸潰淇℃伅 permRoles: [], // 鐢ㄦ埛瑙掕壊鍒楄〃 permAction: {}, // 鐢ㄦ埛鎸夐挳鏉冮檺 diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 37488e6..b378b02 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -11,20 +11,22 @@ import Utils from '@/utils/utils.js' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' -import {refreshTabView, modifyTabview} from '@/store/action' +import { refreshTabView } from '@/store/action' -import MainTable from '@/tabviews/zshare/normalTable' import MainSearch from '@/tabviews/zshare/topSearch' import NotFount from '@/components/404' import './index.scss' +// 閫氱敤缁勪欢 const MainAction = asyncSpinComponent(() => import('@/tabviews/zshare/actionList')) -const VerifyCard = asyncComponent(() => import('@/tabviews/zshare/verifycard')) +const MainTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) +const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent')) const SubTable = asyncSpinComponent(() => import('@/tabviews/subtable')) -const SubTabTable = asyncComponent(() => import('@/tabviews/subtabtable')) -const FormTab = asyncComponent(() => import('@/tabviews/formtab')) const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent')) const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent')) + +// 鑷畾涔夋爣绛� +const SecretKeyTable = asyncSpinComponent(() => import('./secretKeyTable')) const { TabPane } = Tabs const { TreeNode } = Tree @@ -41,13 +43,11 @@ state = { dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, ContainerId: Utils.getuuid(), // 鑿滃崟澶栧眰html Id - view: 'commontable', // 褰撳墠椤甸潰榛樿涓轰富琛� loadingview: true, // 椤甸潰鍔犺浇涓� viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 userConfig: null, // 鐢ㄦ埛鑷畾涔夎缃� - userParam: null, // 淇濆瓨鐢ㄦ埛缂栬緫涓殑閰嶇疆 searchlist: null, // 鎼滅储鏉′欢 actions: null, // 鎸夐挳闆� columns: null, // 鏄剧ず鍒� @@ -55,6 +55,8 @@ arr_field: '', // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: null, // 鍒楄〃鏁版嵁闆� + selectedData: [], // 宸查�夎〃鏍兼暟鎹� + resetTable: false, // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆 total: 0, // 鎬绘暟 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 @@ -63,16 +65,8 @@ search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� BIDs: {}, // 涓婄骇琛╥d pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 - popAction: false, // 寮规椤甸潰锛屾寜閽俊鎭� - popData: null, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 - visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 treevisible: false, // 鑿滃崟缁撴瀯鏍戝脊妗嗘樉绀洪殣钘忔帶鍒� - tabBtn: null, // 琛ㄥ崟鏍囩鎸夐挳 - tabParam: null, // 琛ㄥ崟鏍囩鍙傛暟 refreshtabs: null, // 闇�瑕佸埛鏂扮殑鏍囩闆� - confirmLoading: false,// 鑷畾涔夎缃ā鎬佹鍔犺浇涓� - revertLoading: false, // 鎭㈠榛樿璁剧疆 - settingVisible: false,// 鑷畾涔夎缃ā鎬佹 triggerBtn: null, // 鐐瑰嚮琛ㄦ牸涓垨蹇嵎閿Е鍙戠殑鎸夐挳 tabActive: null, // 鏍囩椤靛睍寮�鎺у埗 chartId: '' // 灞曞紑鍥捐〃ID @@ -102,7 +96,8 @@ config = '' } - if (result.LongParamUser) { + // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆 + if (result.LongParamUser && this.props.menuType !== 'HS') { try { // 閰嶇疆淇℃伅瑙f瀽 userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) _curUserConfig = userConfig[this.props.MenuID] @@ -154,27 +149,33 @@ let chartId = '' if (!config.charts) { config.expand = true - config.charts = [{ - uuid: Utils.getuuid(), - label: '', - title: '', - chartType: 'table', - icon: 'table', - Hide: 'false', - blacklist: [] - }] + config.charts = [{ uuid: Utils.getuuid(), label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }] } else if (config.charts.length === 1) { config.expand = true } chartId = config.charts[0].uuid // 鏉冮檺杩囨护 - config.action = config.action.filter(item => permAction[item.uuid]) - config.tabgroups.forEach(group => { - group.sublist = group.sublist.filter(tab => permAction[tab.linkTab]) - }) + if (this.props.menuType !== 'HS') { + config.action = config.action.filter(item => permAction[item.uuid]) + config.tabgroups.forEach(group => { + group.sublist = group.sublist.filter(tab => permAction[tab.linkTab]) + }) + } // 鍘婚櫎绌鸿鏍囩 config.tabgroups = config.tabgroups.filter(group => group.sublist.length > 0) + + // HS涓嬭嚜瀹氫箟澶勭悊鐨勬爣绛� + if (this.props.menuType === 'HS') { + config.tabgroups.forEach(group => { + group.sublist = group.sublist.map(tab => { + if (tab.linkTab === '1586577325055l2ng7t75g7i4ek2ng8o') { + tab.type = 'SecretKeyTable' + } + return tab + }) + }) + } // 瑙嗗浘鏉冮檺 config.charts = config.charts.filter(item => { @@ -224,6 +225,9 @@ return true } }) + + // 鏍囪涓婚〉闈紝鐢ㄤ簬鎸夐挳鍥哄畾鍙婅〃鍗曟寕杞借缃� + config.setting.tabType = 'main' if (_curUserConfig) { config.setting = {...config.setting, ..._curUserConfig.setting} @@ -285,7 +289,6 @@ config.columns.forEach(col => { if (col.field) { _arrField.push(col.field) - _logcolumns.push(col) } if (col.type === 'colspan' && col.sublist) { // 绛涢�夐殣钘忓垪 @@ -320,15 +323,13 @@ _columns.push(col) } }) - + if (config.gridBtn && config.gridBtn.display && _operations.length > 0) { - _columns.push({ - ...config.gridBtn, - operations: _operations - }) + config.gridBtn.operations = _operations + _columns.push(config.gridBtn) } - let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉, 鍒濆鎼滅储鏉′欢 + let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉, 鍒濆鎼滅储鏉′欢, 濡傞�氳繃涓婄骇閫忚锛屽啓鍏ユ悳绱㈡潯浠� let initSearch = config.search.map(item => { let _item = JSON.parse(JSON.stringify(item)) if (_item.type === 'text' && param && param.searchkey === _item.field) { @@ -807,9 +808,9 @@ this.loadmaindata() }) } else { - this.refs.mainTable && this.refs.mainTable.resetTable() - this.setState({ + resetTable: !this.state.resetTable, + selectedData: [], pageIndex: 1, search: searches }, () => { @@ -831,6 +832,7 @@ } this.setState({ + selectedData: [], pageIndex: pagination.current, pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' @@ -843,8 +845,9 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - this.refs.mainTable && this.refs.mainTable.resetTable() this.setState({ + resetTable: !this.state.resetTable, + selectedData: [], pageIndex: 1 }, () => { this.loadmaindata() @@ -855,28 +858,9 @@ * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� */ reloadview = () => { - this.setState({ - view: 'commontable', - loadingview: true, - viewlost: false, - lostmsg: '', - config: {}, - userConfig: null, - userParam: null, - searchlist: null, - actions: null, - columns: null, - arr_field: '', - setting: null, - data: null, - total: 0, - loading: false, - pageIndex: 1, - pageSize: 10, - orderBy: '', - search: '', - BIDs: {}, - pickup: false + this.setState({ loadingview: true, viewlost: false, lostmsg: '', config: {}, userConfig: null, searchlist: null, + actions: null, columns: null, arr_field: '', setting: null, data: null, total: 0, loading: false, pageIndex: 1, + pageSize: 10, orderBy: '', search: '', BIDs: {}, pickup: false }, () => { this.loadconfig() }) @@ -885,37 +869,12 @@ /** * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� */ - refreshbyaction = (btn, type) => { - if (btn.execSuccess === 'grid' && type === 'success') { + refreshbyaction = (position) => { + if (position === 'grid') { this.reloadtable() - } else if (btn.execError === 'grid' && type === 'error') { - this.reloadtable() - } else if (btn.execSuccess === 'view' && type === 'success') { + } else if (position === 'view') { this.reloadview() - } else if (btn.execError === 'view' && type === 'error') { - this.reloadview() - } else if (btn.popClose === 'view' && type === 'pop') { - this.reloadview() - } else if (btn.popClose === 'grid' && type === 'pop') { - this.reloadtable() } - } - - /** - * @description 琛ㄥ崟鎿嶄綔瀹屾垚鍚庡埛鏂颁富椤甸潰 - */ - refreshbyformtab = (type) => { - this.setState({ - view: 'commontable', - tabBtn: null, - tabParam: null - }, () => { - if (type === 'grid') { - this.reloadtable() - } else if (type === 'view') { - this.reloadview() - } - }) } /** @@ -961,14 +920,10 @@ } /** - * @description 鑾峰彇琛ㄦ牸閫夋嫨椤� + * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹� */ - gettableselected = () => { - let data = [] - this.refs.mainTable && this.refs.mainTable.state.selectedRowKeys.forEach(item => { - data.push(this.refs.mainTable.props.data[item]) - }) - return data + changeSelectedData = (selectedData) => { + this.setState({selectedData}) } /** @@ -1008,84 +963,6 @@ this.setState({ pickup: !pickup }) - } - - /** - * @description 瑙﹀彂鎸夐挳寮圭獥锛堟爣绛鹃〉锛� - */ - triggerPopview = (btn, data) => { - const { setting } = this.state - - let _primaryId = '' - - if (data && data[0] && setting.primaryKey) { - _primaryId = data[0][setting.primaryKey] || '' - } - - if (btn.OpenType === 'popview') { - this.setState({ - popAction: btn, - popData: data[0] || null, - visible: true - }) - } else if (btn.OpenType === 'tab') { - const { tabviews, MenuNo, MenuID } = this.props - let newtab = { - MenuNo: MenuNo, - MenuID: btn.uuid, - MenuName: btn.label, - type: btn.tabTemplate, - selected: true, - param: { - menuType: 'main', - parentId: this.props.MenuID, - btn: btn, - data: data[0] || null, - primaryId: btn.Ot !== 'notRequired' ? _primaryId : '', - arr_field: this.state.arr_field - } - } - - let index = 0 - let isexit = false - let tabs = tabviews.map((tab, i) => { - tab.selected = false - - if (tab.MenuID === MenuID) { - index = i - } else if (tab.MenuID === btn.uuid) { - tab.selected = true - isexit = true - } - - return tab - }) - - if (!isexit) { - tabs.splice(index + 1, 0, newtab) - } - - this.props.modifyTabview(tabs) - } else if (btn.OpenType === 'blank') { - this.setState({ - view: 'formtab', - tabBtn: btn, - tabParam: { - menuType: 'main', - btn: btn, - data: data[0] || null, - primaryId: btn.Ot !== 'notRequired' ? _primaryId : '', - arr_field: this.state.arr_field - } - }) - } - } - - popclose = () => { - this.setState({ - visible: false - }) - this.refreshbyaction(this.state.popAction, 'pop') } handleviewconfig = (e) => { @@ -1147,127 +1024,6 @@ }) } - controlCustomSetting = () => { - this.setState({ - settingVisible: true, - confirmLoading: false, - revertLoading: false - }) - } - - changeMenuParam = (param) => { - this.setState({userParam: param}) - } - - linkTrigger = (menu) => { - const { tabviews, MenuID } = this.props - - menu.selected = true - - let index = 0 - let isexit = false - let tabs = tabviews.map((tab, i) => { - tab.selected = false - - if (tab.MenuID === MenuID) { - index = i - } else if (tab.MenuID === menu.MenuID) { - tab.param = menu.param - tab.selected = true - isexit = true - } - - return tab - }) - - if (!isexit) { - tabs.splice(index + 1, 0, menu) - } - - this.props.modifyTabview(tabs) - } - - settingRevert = () => { - let param = { - func: 's_TrdMenu_UserParam_del', - MenuID: this.props.MenuID - } - this.setState({ - revertLoading: true - }) - - Api.getSystemConfig(param).then(result => { - if (!result.status) { - this.setState({ - revertLoading: false - }) - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } - this.setState({ - settingVisible: false, - revertLoading: false - }, () => { - window.GLOB.CacheMap = new Map() - this.reloadview() - }) - }) - } - - settingSubmit = () => { - const { userParam } = this.state - let _LongParam = '' - - try { - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(userParam))) - } catch (e) { - notification.warning({ - top: 92, - message: '缂栬瘧閿欒', - duration: 5 - }) - return - } - - let easyCode = userParam[this.props.MenuID] ? userParam[this.props.MenuID].easyCode : '' - - let param = { - func: 'sPC_TrdMenu_UserParam', - MenuID: this.props.MenuID, - EasyCode: easyCode || '', - LongParam: _LongParam - } - - this.setState({ - confirmLoading: true - }) - - Api.getSystemConfig(param).then(result => { - if (!result.status) { - this.setState({ - confirmLoading: false - }) - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - return - } - this.setState({ - settingVisible: false, - confirmLoading: false - }, () => { - window.GLOB.CacheMap = new Map() - this.reloadview() - }) - }) - } - /** * @description 鍥捐〃瑙嗗浘鍒囨崲 */ @@ -1298,7 +1054,6 @@ if (item.type === 'text' && item.key === nextProps.param.searchkey) { item.value = nextProps.param.searchval } - return item }) this.refreshbysearch(search) @@ -1320,238 +1075,184 @@ } render() { - const { view, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig, tabActive, chartId, search } = this.state + const { setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig, tabActive, chartId, search, selectedData } = this.state return ( - <div> - {view === 'commontable' ? <div className="commontable pick-control" id={this.state.ContainerId}> - {loadingview && <Spin size="large" />} - {searchlist && searchlist.length > 0 ? - <MainSearch - ref="mainSearch" - dict={this.state.dict} - searchlist={searchlist} - refreshdata={this.refreshbysearch} - /> : null - } - {setting && setting.onload !== 'false' ? <div className="chart-view"> - {/* 瑙嗗浘缁� */} - {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> - {config.charts.map(item => ( - <TabPane tab={<Icon type={item.icon} />} key={item.uuid}></TabPane> - ))} - </Tabs> : null} - {config.charts.map(item => { - if (!config.expand && chartId !== item.uuid) return null + <div className="commontable pick-control" id={this.state.ContainerId}> + {loadingview && <Spin size="large" />} + {searchlist && searchlist.length > 0 ? + <MainSearch + dict={this.state.dict} + searchlist={searchlist} + refreshdata={this.refreshbysearch} + /> : null + } + {setting && setting.onload !== 'false' ? <div className="chart-view"> + {/* 瑙嗗浘缁� */} + {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> + {config.charts.map(item => ( + <TabPane tab={<Icon type={item.icon} />} key={item.uuid}></TabPane> + ))} + </Tabs> : null} + {config.charts.map(item => { + if (!config.expand && chartId !== item.uuid) return null - if (item.chartType === 'table') { - return ( - <Col span={item.width || 24} key={item.uuid}> - {config.charts.length > 1 && item.title ? <p className="chart-table chart-title">{item.title}</p> : null} - <div style={{minHeight: '25px'}}> - <MainAction - type="main" - menuType="main" - setting={setting} - actions={actions} - triggerBtn={triggerBtn} - dict={this.state.dict} - MenuID={this.props.MenuID} - logcolumns={this.state.logcolumns} - ContainerId={this.state.ContainerId} - refreshdata={this.refreshbyaction} - triggerPopview={this.triggerPopview} - getexceloutparam={this.getexceloutparam} - gettableselected={this.gettableselected} - /> - </div> - <div className="main-table-box"> - <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} /> - {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ? - <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null - } - <MainTable - ref="mainTable" - tableId="mainTable" - pickup={pickup} - config={config} - setting={setting} - columns={columns} - pageSize={pageSize} - dict={this.state.dict} - data={this.state.data} - total={this.state.total} - MenuID={this.props.MenuID} - memberLevel={this.props.memberLevel} - loading={this.state.loading} - pagination={setting.laypage !== 'false'} - refreshdata={this.refreshbytable} - buttonTrigger={this.buttonTrigger} - linkTrigger={this.linkTrigger} - handleTableId={this.handleTableId} - /> - </div> - </Col> - ) - } else if (item.chartType === 'card') { - return ( - <Col span={item.width} key={item.uuid}> - <CardComponent - plot={item} + if (item.chartType === 'table') { + return ( + <Col span={item.width || 24} key={item.uuid}> + {config.charts.length > 1 && item.title ? <p className="chart-table chart-title">{item.title}</p> : null} + <div style={{minHeight: '25px'}}> + <MainAction + setting={setting} + actions={actions} + dict={this.state.dict} + triggerBtn={triggerBtn} + MenuID={this.props.MenuID} + selectedData={selectedData} + logcolumns={this.state.logcolumns} + ContainerId={this.state.ContainerId} + operations={config.gridBtn.operations || []} + refreshdata={this.refreshbyaction} + getexceloutparam={this.getexceloutparam} + /> + </div> + <div className="main-table-box"> + {this.props.menuType !== 'HS' ? <SettingComponent config={config} + columns={columns} + dict={this.state.dict} + MenuID={this.props.MenuID} + MenuName={this.props.MenuName} + permAction={this.props.permAction} + permRoles={this.props.permRoles} + userConfig={this.state.userConfig} + reloadview={this.reloadview} + /> : null} + {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ? + <Switch title="鏀惰捣" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null + } + <MainTable tableId="mainTable" - loading={this.state.loading} + pickup={pickup} + config={config} + setting={setting} + columns={columns} + pageSize={pageSize} + dict={this.state.dict} data={this.state.data} + total={this.state.total} + MenuID={this.props.MenuID} + loading={this.state.loading} + refreshdata={this.refreshbytable} buttonTrigger={this.buttonTrigger} handleTableId={this.handleTableId} + resetTable={this.state.resetTable} + chgSelectData={this.changeSelectedData} /> - <div style={{display: 'none'}}> - <MainAction - type="main" - menuType="main" - setting={setting} - actions={actions} - triggerBtn={triggerBtn} - dict={this.state.dict} - MenuID={this.props.MenuID} - permRoles={this.props.permRoles} - dataManager={this.props.dataManager} - logcolumns={this.state.logcolumns} - ContainerId={this.state.ContainerId} - refreshdata={this.refreshbyaction} - triggerPopview={this.triggerPopview} - getexceloutparam={this.getexceloutparam} - gettableselected={this.gettableselected} - /> - </div> - </Col> - ) - } else { - return ( - <Col span={item.width} key={item.uuid}> - <ChartComponent - plot={item} - config={config} - data={this.state.data} - loading={this.state.loading} - /> - </Col> - ) - } - })} - </div> : null } - {setting && setting.onload !== 'false' && - config.tabgroups.map(group => ( - <Tabs activeKey={tabActive[group.uuid]} key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}> - {group.sublist.map(_tab => { - return ( - <TabPane tab={ - <span> - {_tab.icon ? <Icon type={_tab.icon} /> : null} - {_tab.label} - </span> - } key={_tab.uuid}> - {_tab.type === 'SubTable' ? - <SubTable - Tab={_tab} - menuType="main" - MenuID={_tab.linkTab} - mainSearch={_tab.searchPass === 'true' ? search : null} - userConfig={userConfig ? userConfig[_tab.uuid] : null} - triggerBtn={triggerBtn} - 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> - ) - })} - </Tabs>) - ) - } - <Button - icon="copy" - shape="circle" - className="common-table-copy" - onClick={this.handleviewconfig} - /> - <Modal - className="popview-modal" - title={this.state.popAction.label} - width={'80vw'} - maskClosable={false} - visible={this.state.visible} - onCancel={this.popclose} - footer={[ - <Button key="close" onClick={this.popclose}>{this.state.dict['main.close']}</Button> - ]} - destroyOnClose - > - {<SubTabTable - BID={this.state.popData ? this.state.popData[setting.primaryKey] : ''} - menuType="main" - SupMenuID={this.props.MenuID} - MenuID={this.state.popAction.linkTab} - BData={this.state.popData || ''} - ContainerId={this.state.ContainerId} - refreshSupView={this.reloadtable} - />} - </Modal> - <Modal - className="menu-tree-modal" - title={'鑿滃崟缁撴瀯鏍�'} - width={'650px'} - maskClosable={false} - visible={this.state.treevisible} - onCancel={() => this.setState({treevisible: false})} - footer={[ - <Button key="close" onClick={() => this.setState({treevisible: false})}>{this.state.dict['main.close']}</Button> - ]} - destroyOnClose - > - <div className="menu-header"> - <span>鑿滃崟鍚嶇О锛歿this.props.MenuName}</span> - <span>鑿滃崟鍙傛暟锛歿<Paragraph copyable>{this.props.MenuNo}</Paragraph>}</span> - </div> - {this.state.treevisible ? <Tree defaultExpandAll showLine={true}> - {this.getTreeNode(config.funcs)} - </Tree> : null} - </Modal> - {/* 鎸夐挳浣跨敤绯荤粺瀛樺偍杩囩▼鏃讹紝楠岃瘉淇℃伅妯℃�佹 */} - <Modal - wrapClassName="common-table-custom-modal" - title={'鑷畾涔夎缃�'} - maskClosable={false} - width={950} - visible={this.state.settingVisible} - onCancel={() => { this.setState({ settingVisible: false }) }} - footer={[ - <Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>{this.state.dict['main.revert.default']}</Button>, - <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['main.cancel']}</Button>, - <Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>{this.state.dict['main.submit']}</Button> - ]} - destroyOnClose - > - {this.state.settingVisible ? - <VerifyCard - MenuID={this.props.MenuID} - MenuName={this.props.MenuName} - permAction={this.props.permAction} - permRoles={this.props.permRoles} - config={this.state.config} - userConfig={this.state.userConfig} - columns={this.state.columns} - handleParam={this.changeMenuParam} - /> : null + </div> + </Col> + ) + } else if (item.chartType === 'card') { + return ( + <Col span={item.width} key={item.uuid}> + <CardComponent + plot={item} + config={config} + tableId="mainTable" + data={this.state.data} + MenuID={this.props.MenuID} + loading={this.state.loading} + logcolumns={this.state.logcolumns} + ContainerId={this.state.ContainerId} + refreshdata={this.refreshbyaction} + handleTableId={this.handleTableId} + /> + </Col> + ) + } else { + return ( + <Col span={item.width} key={item.uuid}> + <ChartComponent + plot={item} + config={config} + data={this.state.data} + loading={this.state.loading} + /> + </Col> + ) } - </Modal> - {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} - </div> : null} - {view === 'formtab' ? <FormTab MenuID={this.state.tabBtn.uuid} param={this.state.tabParam} refresh={this.refreshbyformtab}/> : null} + })} + </div> : null } + {setting && setting.onload !== 'false' && + config.tabgroups.map(group => ( + <Tabs activeKey={tabActive[group.uuid]} key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}> + {group.sublist.map(_tab => { + return ( + <TabPane tab={ + <span> + {_tab.icon ? <Icon type={_tab.icon} /> : null} + {_tab.label} + </span> + } key={_tab.uuid}> + {_tab.type === 'SubTable' ? + <SubTable + Tab={_tab} + MenuID={_tab.linkTab} + mainSearch={_tab.searchPass === 'true' ? search : null} + userConfig={userConfig ? userConfig[_tab.uuid] : null} + triggerBtn={triggerBtn} + 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} + {_tab.type === 'SecretKeyTable' ? + <SecretKeyTable + 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'] || ''} + handleMainTable={(type) => this.handleMainTable(type, _tab)} + /> : null} + </TabPane> + ) + })} + </Tabs>) + ) + } + <Button + icon="copy" + shape="circle" + className="common-table-copy" + onClick={this.handleviewconfig} + /> + <Modal + className="menu-tree-modal" + title={'鑿滃崟缁撴瀯鏍�'} + width={'650px'} + maskClosable={false} + visible={this.state.treevisible} + onCancel={() => this.setState({treevisible: false})} + footer={[ + <Button key="close" onClick={() => this.setState({treevisible: false})}>{this.state.dict['main.close']}</Button> + ]} + destroyOnClose + > + <div className="menu-header"> + <span>鑿滃崟鍚嶇О锛歿this.props.MenuName}</span> + <span>鑿滃崟鍙傛暟锛歿<Paragraph copyable>{this.props.MenuNo}</Paragraph>}</span> + </div> + {this.state.treevisible ? <Tree defaultExpandAll showLine={true}> + {this.getTreeNode(config.funcs)} + </Tree> : null} + </Modal> + {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) } @@ -1559,20 +1260,19 @@ const mapStateToProps = (state) => { return { + menuType: state.editLevel, tabviews: state.tabviews, refreshTab: state.refreshTab, permAction: state.permAction, permMenus: state.permMenus, permRoles: state.permRoles, - memberLevel: state.memberLevel, dataManager: state.dataManager } } const mapDispatchToProps = (dispatch) => { return { - refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)), - modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) + refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)) } } diff --git a/src/tabviews/commontable/index.scss b/src/tabviews/commontable/index.scss index 6ee9a17..eec1211 100644 --- a/src/tabviews/commontable/index.scss +++ b/src/tabviews/commontable/index.scss @@ -66,6 +66,9 @@ padding: 3px; cursor: pointer; } + >.async-spin { + line-height: 150px!important; + } } > .ant-tabs { padding: 0px 20px; diff --git a/src/tabviews/managetable/secretKeyTable/actionList/index.jsx b/src/tabviews/commontable/secretKeyTable/actionList/index.jsx similarity index 93% rename from src/tabviews/managetable/secretKeyTable/actionList/index.jsx rename to src/tabviews/commontable/secretKeyTable/actionList/index.jsx index bb45944..5c86eaa 100644 --- a/src/tabviews/managetable/secretKeyTable/actionList/index.jsx +++ b/src/tabviews/commontable/secretKeyTable/actionList/index.jsx @@ -13,17 +13,15 @@ class MainAction extends Component { static propTpyes = { BID: PropTypes.string, // 涓昏〃ID - datalist: PropTypes.any, // 鍒楄〃鏁版嵁 + datalist: PropTypes.any, // 鍒楄〃鏁版嵁 Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� - type: PropTypes.string, // 鍒ゆ柇褰撳墠涓轰富琛紙main锛夈�佸瓙琛紙sub锛夈�佸瓙琛ㄦ爣绛撅紙subtab锛� MenuID: PropTypes.string, // 鑿滃崟ID actions: PropTypes.array, // 鎸夐挳缁� - logcolumns: PropTypes.array, // 鏄剧ず鍒� + selectedData: PropTypes.array, // 閫変腑鏁版嵁 dict: PropTypes.object, // 瀛楀吀椤� setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� refreshdata: PropTypes.func, // 鎵ц瀹屾垚鍚庢暟鎹埛鏂� - gettableselected: PropTypes.func // 鑾峰彇琛ㄦ牸涓暟鎹� } state = { @@ -35,16 +33,12 @@ configMap: {}, loadingNumber: '' } - - refreshdata = (item, type) => { - this.props.refreshdata(item, type) - } /** * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ actionTrigger = (item) => { - const { setting, BID, datalist } = this.props + const { setting, BID, datalist, selectedData } = this.props if (!BID) { notification.warning({ @@ -56,7 +50,7 @@ } let _this = this - let data = this.props.gettableselected() || [] + let data = selectedData || [] if (item.Ot !== 'notRequired' && data.length === 0) { // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� @@ -225,7 +219,7 @@ }) } - this.refreshdata(btn, 'success') + this.props.refreshdata(btn.execSuccess) } /** @@ -256,7 +250,7 @@ message.error(res.message || res.ErrMesg) } - this.refreshdata(btn, 'error') + this.props.refreshdata(btn.execError) } /** @@ -310,10 +304,6 @@ if (execAction.setting.clickouter === 'close') { clickouter = true } - } - - if (this.props.type === 'subtab') { - container = document.body } return ( diff --git a/src/tabviews/managetable/secretKeyTable/actionList/index.scss b/src/tabviews/commontable/secretKeyTable/actionList/index.scss similarity index 100% rename from src/tabviews/managetable/secretKeyTable/actionList/index.scss rename to src/tabviews/commontable/secretKeyTable/actionList/index.scss diff --git a/src/tabviews/managetable/secretKeyTable/config.jsx b/src/tabviews/commontable/secretKeyTable/config.jsx similarity index 98% rename from src/tabviews/managetable/secretKeyTable/config.jsx rename to src/tabviews/commontable/secretKeyTable/config.jsx index 9de92b3..f60d550 100644 --- a/src/tabviews/managetable/secretKeyTable/config.jsx +++ b/src/tabviews/commontable/secretKeyTable/config.jsx @@ -108,7 +108,9 @@ "primaryKey":"key", "order":"key", "onload":"true", - "actionfixed":false,"columnfixed":false + "laypage": "false", + "actionfixed":false, + "columnfixed":false }, search:[], action:[ diff --git a/src/tabviews/managetable/secretKeyTable/index.jsx b/src/tabviews/commontable/secretKeyTable/index.jsx similarity index 81% rename from src/tabviews/managetable/secretKeyTable/index.jsx rename to src/tabviews/commontable/secretKeyTable/index.jsx index 02183ae..89cef32 100644 --- a/src/tabviews/managetable/secretKeyTable/index.jsx +++ b/src/tabviews/commontable/secretKeyTable/index.jsx @@ -9,10 +9,12 @@ import options from '@/store/options.js' import { buttonConfig, tabConfig, refCodes } from './config' -import SubTable from '@/tabviews/zshare/normalTable' +import asyncSpinComponent from '@/utils/asyncSpinComponent' import SubAction from './actionList' import './index.scss' + +const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) class VerupSubTabViewTable extends Component { static propTpyes = { @@ -23,7 +25,6 @@ MenuID: PropTypes.string, // 鑿滃崟Id SupMenuID: PropTypes.string, // 涓婄骇鑿滃崟Id ContainerId: PropTypes.any, // 涓夌骇鑿滃崟Container(html) ID - handleTableId: PropTypes.func, // 鎺у埗琛ㄦ牸鏁版嵁鍒囨崲鏃讹紝鏇存柊鍦ㄤ富琛ㄤ腑鐨刬d handleMainTable: PropTypes.func, // 鍒锋柊涓昏〃 refreshtabs:PropTypes.any } @@ -35,6 +36,8 @@ columns: null, // 鏄剧ず鍒� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: null, // 鍒楄〃鏁版嵁闆� + selectedData: [], // 宸查�夎〃鏍兼暟鎹� + resetTable: false, // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 pickup: false, // 瀛愯〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 @@ -45,8 +48,13 @@ */ 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') + this.setState({ + pageIndex: 1, + selectedData: [], + resetTable: !this.state.resetTable, + }, () => { + this.loadmaindata(nextProps.BID, 'refresh') + }) } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { this.reloadtable() @@ -99,6 +107,8 @@ } }) + config.setting.tabType = 'sub' + this.setState({ config: config, setting: config.setting, @@ -123,8 +133,6 @@ * @description 瀛愯〃鏁版嵁鍔犺浇 */ async loadmaindata (bid, type) { - const { setting } = this.state - let param = '' let _BID = this.props.BID if (type === 'refresh') { @@ -134,19 +142,11 @@ 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 param = this.getCustomParam(_BID) let result = await Api.getLocalConfig(param) if (result.status) { @@ -246,16 +246,17 @@ }) } - this.setState({data}) + this.setState({data: data, selectedData: []}) } /** * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - this.refs.subTable.resetTable() this.setState({ loading: true, + selectedData: [], + resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) @@ -266,12 +267,7 @@ */ reloadview = () => { this.setState({ - config: null, - actions: null, - columns: null, - setting: null, - data: null, - loading: false, + config: null, actions: null, columns: null, setting: null, data: null, loading: false, selectedData: [] }, () => { this.loadconfig() }) @@ -280,34 +276,19 @@ /** * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� */ - refreshbyaction = (btn, type) => { - if (btn.execSuccess === 'grid' && type === 'success') { + refreshbyaction = (position) => { + if (position === 'grid') { 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') { + } else if (position === 'view') { this.reloadview() } } /** - * @description 鑾峰彇琛ㄦ牸閫夋嫨椤� + * @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) + changeSelectedData = (selectedData) => { + this.setState({selectedData}) } /** @@ -327,7 +308,7 @@ } shouldComponentUpdate (nextProps, nextState) { // handleMainTable 鍑芥暟鍒ゆ柇鏃朵笉鐩哥瓑 - return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState)) + return !is(fromJS({...this.props, handleMainTable: ''}), fromJS({...nextProps, handleMainTable: ''})) || !is(fromJS(this.state), fromJS(nextState)) } /** @@ -340,26 +321,22 @@ } render() { - const { setting, actions, columns, pickup, config } = this.state + const { setting, actions, columns, pickup, config, selectedData } = 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} + selectedData={selectedData} MenuID={this.props.SupMenuID} - logcolumns={[]} refreshdata={this.refreshbyaction} ContainerId={this.props.ContainerId} - getexceloutparam={this.getexceloutparam} - gettableselected={this.gettableselected} /> </div> <div className="subtable-box"> @@ -367,21 +344,19 @@ <Switch title="鏀惰捣" className="subtable-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null } <SubTable - ref="subTable" - menuType="HS" tableId={this.props.Tab.uuid} pickup={pickup} config={config} 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} + handleTableId={() => {}} + chgSelectData={this.changeSelectedData} /> </div> </div> diff --git a/src/tabviews/managetable/secretKeyTable/index.scss b/src/tabviews/commontable/secretKeyTable/index.scss similarity index 100% rename from src/tabviews/managetable/secretKeyTable/index.scss rename to src/tabviews/commontable/secretKeyTable/index.scss diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx index 4bf485d..c50d011 100644 --- a/src/tabviews/formtab/index.jsx +++ b/src/tabviews/formtab/index.jsx @@ -110,7 +110,7 @@ } // 鏉冮檺杩囨护 - if (this.props.param.menuType !== 'HS') { + if (this.props.menuType !== 'HS') { config.action = config.action.filter(item => permAction[item.uuid]) config.tabgroups.forEach(group => { group.sublist = group.sublist.filter(tab => permAction[tab.linkTab]) @@ -444,7 +444,7 @@ if (setting.interType === 'inner') { param.func = setting.innerFunc } else { - if (this.props.param.menuType === 'HS') { + if (this.props.menuType === 'HS') { if (setting.sysInterface === 'true' && options.cloudServiceApi) { param.rduri = options.cloudServiceApi } else if (setting.sysInterface !== 'true') { @@ -669,7 +669,7 @@ } {hasform ? <FormAction - menuType={this.props.param.menuType} + menuType={this.props.menuType} logcolumns={[]} setting={setting} actions={actions} @@ -697,7 +697,6 @@ {_tab.type === 'SubTable' ? <SubTable Tab={_tab} - menuType={this.props.param.menuType} MenuID={_tab.linkTab} SupMenuID={this.props.MenuID} refreshtabs={this.state.refreshtabs} @@ -722,6 +721,7 @@ const mapStateToProps = (state) => { return { + menuType: state.editLevel, tabviews: state.tabviews, refreshTab: state.refreshTab, permAction: state.permAction, diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx index 63af809..b1ef4b1 100644 --- a/src/tabviews/home/index.jsx +++ b/src/tabviews/home/index.jsx @@ -1,18 +1,15 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import {connect} from 'react-redux' import echarts from 'echarts/lib/echarts' import 'echarts/lib/chart/bar' -import 'echarts/lib/chart/line' import 'echarts/lib/component/tooltip' -import 'echarts/lib/component/title' -import 'echarts/lib/component/legend' -import 'echarts/lib/component/toolbox' -import 'echarts/lib/component/markPoint' -import 'echarts/lib/component/markLine' +// import 'echarts/lib/chart/line' +// import 'echarts/lib/component/title' +// import 'echarts/lib/component/legend' +// import 'echarts/lib/component/toolbox' +// import 'echarts/lib/component/markPoint' +// import 'echarts/lib/component/markLine' import { Icon, Tabs, Slider } from 'antd' -// import {refreshTabView, modifyTabview} from '@/store/action' -// import Api from '@/api' import './index.scss' const { TabPane } = Tabs @@ -24,9 +21,7 @@ param: PropTypes.object // 鑿滃崟鍙傛暟 } - state = { - - } + state = {} componentDidMount () { let myChart = echarts.init(document.getElementById('home')) @@ -315,12 +310,4 @@ } } -const mapStateToProps = (state) => { - return {} -} - -const mapDispatchToProps = (dispatch) => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(Home) \ No newline at end of file +export default Home \ No newline at end of file diff --git a/src/tabviews/managetable/index.jsx b/src/tabviews/managetable/index.jsx deleted file mode 100644 index f45fec6..0000000 --- a/src/tabviews/managetable/index.jsx +++ /dev/null @@ -1,1077 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import {connect} from 'react-redux' -import { is, fromJS } from 'immutable' -import { notification, Spin, Tabs, Icon, Switch, Modal, Button, message, Tree, Typography } from 'antd' -import moment from 'moment' - -import Api from '@/api' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' -import Utils from '@/utils/utils.js' -import options from '@/store/options.js' -import asyncComponent from '@/utils/asyncComponent' -import asyncLoadComponent from '@/utils/asyncLoadComponent' -import {refreshTabView, modifyTabview} from '@/store/action' - -import MainTable from '@/tabviews/zshare/normalTable' -import MainSearch from '@/tabviews/zshare/topSearch' -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')) -const FormTab = asyncComponent(() => import('@/tabviews/formtab')) - -const { TabPane } = Tabs -const { TreeNode } = Tree -const { Paragraph } = Typography - -class NormalTable extends Component { - static propTpyes = { - MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 - MenuName: PropTypes.string, // 鑿滃崟鍙傛暟 - MenuID: PropTypes.string // 鑿滃崟Id - } - - state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - ContainerId: Utils.getuuid(), // 鑿滃崟澶栧眰html Id - view: 'commontable', // 褰撳墠椤甸潰榛樿涓轰富琛� - loadingview: true, // 椤甸潰鍔犺浇涓� - viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 - lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 - config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 - searchlist: null, // 鎼滅储鏉′欢 - actions: null, // 鎸夐挳闆� - columns: null, // 鏄剧ず鍒� - logcolumns: null, // 鏃ュ織涓樉绀虹殑鍒椾俊鎭� (澧炲姞鑷冲叏閮ㄥ垪锛岄櫎鍘诲悎骞跺垪) - arr_field: '', // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆� - setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 - data: null, // 鍒楄〃鏁版嵁闆� - total: 0, // 鎬绘暟 - loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� - pageIndex: 1, // 椤电爜 - pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 - orderBy: '', // 鎺掑簭 - search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� - BIDs: {}, // 涓婄骇琛╥d - pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 - popAction: false, // 寮规椤甸潰锛屾寜閽俊鎭� - popData: false, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 - visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 - treevisible: false, // 鑿滃崟缁撴瀯鏍戝脊妗嗘樉绀洪殣钘忔帶鍒� - tabBtn: null, // 琛ㄥ崟鏍囩鎸夐挳 - tabParam: null, // 琛ㄥ崟鏍囩鍙傛暟 - refreshtabs: null, // 闇�瑕佸埛鏂扮殑鏍囩闆� - triggerBtn: null // 鎸夐挳瑙﹀彂 - } - - /** - * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 - */ - async loadconfig () { - let param = { - func: 'sPC_Get_LongParam', - MenuID: this.props.MenuID - } - let result = await Api.getSystemCacheConfig(param) - if (result.status) { - let config = '' - - try { // 閰嶇疆淇℃伅瑙f瀽 - config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - } catch (e) { - console.warn('Parse Failure') - config = '' - } - - // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� - if (!config) { - this.setState({ - loadingview: false, - viewlost: true - }) - return - } - - // 椤甸潰鏈惎鐢ㄦ椂锛屾樉绀烘湭鍚敤椤甸潰 - if (!config.enabled) { - this.setState({ - loadingview: false, - viewlost: true, - lostmsg: this.state.dict['main.view.unenabled'] - }) - return - } - - let _arrField = [] // 瀛楁闆� - let _columns = [] // 鏄剧ず鍒� - let _logcolumns = [] // 鏃ュ織鏄剧ず鍒� - let _hideCol = [] // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆� - let colMap = new Map() // 鐢ㄤ簬瀛楁杩囨护 - - // 鏉冮檺杩囨护 - - // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid - config.columns.forEach(col => { - if (col.field) { - _arrField.push(col.field) - - _logcolumns.push(col) - } - 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) - } - }) - - let _actions = config.action.filter(item => item.position === 'toolbar') // 杩囨护宸ュ叿鏍忔寜閽� - let _operations = config.action.filter(item => item.position === 'grid') // 娣诲姞鎿嶄綔鍒楋紙瀛樺湪鏃讹級 - - if (config.gridBtn && config.gridBtn.display && _operations.length > 0) { - _columns.push({ - ...config.gridBtn, - operations: _operations - }) - } - - // 鍏煎鏍囩 - if (!config.tabgroups) { - config.tabgroups = [{ uuid: 'tabs', sublist: [] }] - } else if (typeof(config.tabgroups[0]) === 'string') { - let _tabgroups = [] - config.tabgroups.forEach(groupId => { - let _group = { - uuid: groupId, - sublist: fromJS(config[groupId]).toJS() - } - - delete config[groupId] - - _tabgroups.push(_group) - }) - - config.tabgroups = _tabgroups - } - - let custabs = ['1586577325055l2ng7t75g7i4ek2ng8o'] - config.tabgroups.forEach(group => { - group.sublist = group.sublist.map(tab => { - if (custabs.includes(tab.linkTab)) { - tab.type = 'SecretKeyTable' - } - return tab - }) - }) - - this.setState({ - loadingview: false, - config: config, - setting: config.setting, - searchlist: config.search, - actions: _actions, - columns: _columns, - logcolumns: _logcolumns, - arr_field: _arrField.join(','), - search: Utils.initMainSearch(config.search) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 - }, () => { - this.improveSearch() - - if (config.setting.onload !== 'false') { // 鍒濆鍖栧彲鍔犺浇 - this.setState({ - loading: true - }) - this.loadmaindata() - } - }) - } else { - this.setState({ - loadingview: false, - viewlost: true - }) - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - } - - /** - * @description 鎼滅储鏉′欢涓嬫媺閫夐」棰勫姞杞� - */ - improveSearch = () => { - let searchlist = JSON.parse(JSON.stringify(this.state.searchlist)) - let deffers = [] - searchlist.forEach(item => { - if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return - if (item.setAll === 'true') { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: this.state.dict['main.all'] - }) - } - - if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - let _sql = Utils.formatOptions(_option.sql) - let isSSO = item.database === 'sso' - - let param = { - func: 'sPC_Get_SelectedList', - LText: _sql, - obj_name: 'data', - arr_field: _option.field - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - let defer = new Promise(resolve => { - Api.getSystemCacheConfig(param, isSSO).then(res => { - res.search = item - resolve(res) - }) - }) - deffers.push(defer) - } else if (item.resourceType === '1' && !item.dataSource) { - notification.warning({ - top: 92, - message: item.label + ': ' + this.state.dict['main.datasource.settingerror'], - duration: 5 - }) - } - }) - - if (deffers.length === 0) { - this.setState({searchlist: JSON.parse(JSON.stringify(searchlist))}) - return - } - - Promise.all(deffers).then(result => { - result.forEach(res => { - if (res.status) { - searchlist = searchlist.map(item => { - if (item.uuid === res.search.uuid) { - res.data.forEach(cell => { - let _item = { - key: Utils.getuuid(), - Value: cell[res.search.valueField], - Text: cell[res.search.valueText] - } - - if (res.search.type === 'link') { - _item.parentId = cell[res.search.linkField] - } - - item.options.push(_item) - }) - } - return item - }) - } else { - notification.warning({ - top: 92, - message: res.search.label + ':' + res.message, - duration: 5 - }) - } - }) - - this.setState({searchlist}) - }) - } - - /** - * @description 涓昏〃鏁版嵁鍔犺浇 - */ - async loadmaindata () { - const { setting, BIDs } = this.state - let param = '' - - if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { - param = this.getCustomParam() - } else { - param = this.getDefaultParam() - } - - this.setState({ - pickup: false - }) - - this.handleTableId('mainTable', '', '') - - if (!param) { // 鏈幏鍙栧弬鏁版椂锛屼笉鍙戣姹� - return - } - - let result = await Api.genericInterface(param) - if (result.status) { - this.setState({ - data: result.data.map((item, index) => { - item.key = index - return item - }), - total: result.total, - loading: false, - BIDs: { - ...BIDs, - mainTable: '' - } - }) - } else { - this.setState({ - loading: false - }) - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } - } - - /** - * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� - */ - getCustomParam = () => { - const { pageIndex, pageSize, orderBy, search, setting } = this.state - - let _search = Utils.formatCustomMainSearch(search) - - let param = { - OrderCol: orderBy || setting.order, - dataM: this.props.dataManager ? 'Y' : '', - ..._search - } - - if (setting.laypage !== 'false') { - param.PageIndex = pageIndex - param.PageSize = pageSize - } - - 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 - } - - if (setting.outerFunc) { - param.func = setting.outerFunc - } - } - - return param - } - - /** - * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� - */ - getDefaultParam = () => { - const { arr_field, pageIndex, pageSize, orderBy, search, setting } = this.state - - if (!arr_field) { - notification.warning({ - top: 92, - message: '鏈缃樉绀哄垪锛�', - duration: 5 - }) - return null - } - - let _search = Utils.joinMainSearchkey(search) - - _search = _search ? 'where ' + _search : '' - - let param = { - func: 'sPC_Get_TableData', - obj_name: 'data', - arr_field: arr_field, - custom_script: setting.customScript || '', - default_sql: setting.default || 'true', - dataM: this.props.dataManager ? 'Y' : '' - } - - let _orderBy = orderBy || setting.order - let _dataresource = setting.dataresource - - if (/\s/.test(_dataresource)) { - _dataresource = '(' + _dataresource + ') tb' - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - _dataresource = _dataresource.replace(/\$@/ig, '/*') - _dataresource = _dataresource.replace(/@\$/ig, '*/') - param.custom_script = param.custom_script.replace(/\$@/ig, '/*') - param.custom_script = param.custom_script.replace(/@\$/ig, '*/') - } else { - _dataresource = _dataresource.replace(/@\$|\$@/ig, '') - param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '') - } - - let regoptions = null - if (setting.queryType === 'statistics' || param.custom_script) { - let allSearch = Utils.getAllSearchOptions(search) - - regoptions = allSearch.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` - } - }) - } - - if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 - regoptions.forEach(item => { - _dataresource = _dataresource.replace(item.reg, item.value) - }) - _search = '' - } - - let LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` - let DateCount = `select count(1) as total from ${_dataresource} ${_search}` - - if (setting.laypage === 'false') { - LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` - DateCount = '' - } - - if (param.custom_script) { - regoptions.push({ - reg: new RegExp('@orderBy@', 'ig'), - value: _orderBy - }) - if (setting.laypage !== 'false') { - regoptions.push({ - reg: new RegExp('@pageSize@', 'ig'), - value: pageSize - }, { - reg: new RegExp('@pageIndex@', 'ig'), - value: pageIndex - }) - } - - regoptions.forEach(item => { - param.custom_script = param.custom_script.replace(item.reg, item.value) - }) - - param.custom_script = Utils.formatOptions(param.custom_script) - } - - param.LText = Utils.formatOptions(LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - param.DateCount = Utils.formatOptions(DateCount) - - return param - } - - /** - * @description 鎼滅储鏉′欢鏀瑰彉鏃讹紝閲嶇疆琛ㄦ牸鏁版嵁 - * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� - */ - refreshbysearch = (searches) => { - const { setting } = this.state - - if (setting.onload === 'false') { - this.setState({ - loading: true, - pageIndex: 1, - search: searches, - setting: {...setting, onload: 'true'} - }, () => { - this.loadmaindata() - }) - } else { - this.refs.mainTable.resetTable() - - this.setState({ - loading: true, - pageIndex: 1, - search: searches - }, () => { - this.loadmaindata() - }) - } - } - - /** - * @description 琛ㄦ牸鏉′欢鏀瑰彉鏃堕噸缃暟鎹紙鍒嗛〉鎴栨帓搴忥級 - */ - refreshbytable = (pagination, filters, sorter) => { - if (sorter.order) { - let _chg = { - ascend: 'asc', - descend: 'desc' - } - sorter.order = _chg[sorter.order] - } - - this.setState({ - loading: true, - pageIndex: pagination.current, - pageSize: pagination.pageSize, - orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' - }, () => { - this.loadmaindata() - }) - } - - /** - * @description 琛ㄦ牸鍒锋柊 - */ - reloadtable = () => { - this.refs.mainTable.resetTable() - this.setState({ - loading: true, - pageIndex: 1 - }, () => { - this.loadmaindata() - }) - } - - /** - * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� - */ - reloadview = () => { - this.setState({ - view: 'commontable', - loadingview: true, - viewlost: false, - lostmsg: '', - config: {}, - searchlist: null, - actions: null, - columns: null, - arr_field: '', - setting: null, - data: null, - total: 0, - loading: false, - pageIndex: 1, - pageSize: 10, - orderBy: '', - search: '', - BIDs: {}, - pickup: false, - popAction: false, - popData: false, - visible: false, - treevisible: false, - tabBtn: null, - tabParam: null, - refreshtabs: null, - triggerBtn: null - }, () => { - 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() - } else if (btn.popClose === 'view' && type === 'pop') { - this.reloadview() - } else if (btn.popClose === 'grid' && type === 'pop') { - this.reloadtable() - } - } - - /** - * @description 琛ㄥ崟鎿嶄綔瀹屾垚鍚庡埛鏂颁富椤甸潰 - */ - refreshbyformtab = (type) => { - this.setState({ - view: 'commontable', - tabBtn: null, - tabParam: null - }, () => { - if (type === 'grid') { - this.reloadtable() - } else if (type === 'view') { - this.reloadview() - } - }) - } - - /** - * @description 瀛愯〃鎿嶄綔瀹屾垚鍚庡埛鏂颁富琛� - */ - handleMainTable = (type, tab) => { - if (type === 'maingrid' && tab.supMenu === 'mainTable') { - this.reloadtable() - } else if (type === 'mainline' && tab.supMenu === 'mainTable') { - this.reloadtable() - } else if ((type === 'maingrid' || type === 'mainline') && tab.supMenu) { - this.setState({ - refreshtabs: [type, tab.supMenu] - }, () => { - this.setState({ - refreshtabs: null - }) - }) - } else if (type === 'equaltab' && tab.equalTab && tab.equalTab.length > 0) { - this.setState({ - refreshtabs: tab.equalTab - }, () => { - this.setState({ - refreshtabs: null - }) - }) - } - } - - /** - * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁� - */ - getexceloutparam = () => { - const { MenuName } = this.props - const { arr_field, orderBy, search, setting} = this.state - - return { - arr_field: arr_field, - orderBy: orderBy || setting.order, - search: search, - menuName: MenuName - } - } - - /** - * @description 鑾峰彇琛ㄦ牸閫夋嫨椤� - */ - gettableselected = () => { - let data = [] - this.refs.mainTable.state.selectedRowKeys.forEach(item => { - data.push(this.refs.mainTable.props.data[item]) - }) - return data - } - - /** - * @description 琛ㄦ牸涓紝鎸夐挳瑙﹀彂浜嬩欢浼犻�� - */ - buttonTrigger = (btn, record) => { - this.setState({ - triggerBtn: { - uuid: new Date().getTime(), - parentId: this.props.MenuID, - button: btn, - data: record - } - }) - } - - /** - * @description 琛ㄦ牸Id鍙樺寲 - */ - handleTableId = (type, id, data) => { - const { BIDs } = this.state - - this.setState({ - BIDs: { - ...BIDs, - [type]: id, - [type + 'data']: data - } - }) - } - - /** - * @description 鏁版嵁灞曞紑鍚堝苟鍒囨崲 - */ - pickupChange = () => { - const { pickup } = this.state - this.setState({ - pickup: !pickup - }) - } - - /** - * @description 瑙﹀彂鎸夐挳寮圭獥锛堟爣绛鹃〉锛� - */ - triggerPopview = (btn, data) => { - const { setting } = this.state - - let _primaryId = '' - - if (data && data[0] && setting.primaryKey) { - _primaryId = data[0][setting.primaryKey] || '' - } - - if (btn.OpenType === 'popview') { - this.setState({ - popAction: btn, - popData: data[0] || null, - visible: true - }) - } else if (btn.OpenType === 'tab') { - const { tabviews, MenuNo, MenuID } = this.props - let newtab = { - MenuNo: MenuNo, - MenuID: btn.uuid, - MenuName: btn.label, - type: btn.tabTemplate, - selected: true, - param: { - menuType: 'HS', - parentId: this.props.MenuID, - btn: btn, - data: data[0] || null, - primaryId: btn.Ot !== 'notRequired' ? _primaryId : '', - arr_field: this.state.arr_field - } - } - - let index = 0 - let isexit = false - let tabs = tabviews.map((tab, i) => { - tab.selected = false - - if (tab.MenuID === MenuID) { - index = i - } else if (tab.MenuID === btn.uuid) { - tab.selected = true - isexit = true - } - - return tab - }) - - if (!isexit) { - tabs.splice(index + 1, 0, newtab) - } - - this.props.modifyTabview(tabs) - } else if (btn.OpenType === 'blank') { - this.setState({ - view: 'formtab', - tabBtn: btn, - tabParam: { - menuType: 'HS', - btn: btn, - data: data[0] || null, - primaryId: btn.Ot !== 'notRequired' ? _primaryId : '', - arr_field: this.state.arr_field - } - }) - } - } - - popclose = () => { - this.setState({ - visible: false - }) - this.refreshbyaction(this.state.popAction, 'pop') - } - - handleviewconfig = (e) => { - e.stopPropagation() - - const { MenuNo } = this.props - const { config } = this.state - - if (config && config.funcs && config.funcs.length > 0) { - this.setState({ - treevisible: true - }) - } else { - let oInput = document.createElement('input') - oInput.value = MenuNo || '' - document.body.appendChild(oInput) - oInput.select() - document.execCommand('Copy') - document.body.removeChild(oInput) - message.success(this.state.dict['main.copy.success']) - } - } - - getTreeNode = (data) => { - let _type = { - view: '椤甸潰', - btn: '鎸夐挳', - tab: '鏍囩' - } - - return data.map(item => { - let _title = _type[item.subtype] - let _others = [] - - _others.push( - (item.menuNo ? item.menuNo + '(鑿滃崟鍙傛暟)' : ''), - (item.tableName ? item.tableName + '(琛ㄥ悕) ' : ''), - (item.innerFunc ? item.innerFunc + '(鍐呴儴鍑芥暟) ' : ''), - (item.outerFunc ? item.outerFunc + '(澶栭儴鍑芥暟)' : '') - ) - _others = _others.filter(Boolean) - _others = _others.join('銆�') - - if (item.label) { - _title = _title + '(' + item.label + ')' - } - if (_others) { - _title = _title + ': ' + _others - } - - if (item.subfuncs && item.subfuncs.length > 0) { - return ( - <TreeNode title={_title} key={item.uuid} dataRef={item} selectable={false}> - {this.getTreeNode(item.subfuncs)} - </TreeNode> - ) - } - return <TreeNode key={item.uuid} title={_title} isLeaf selectable={false} /> - }) - } - - UNSAFE_componentWillMount () { - // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 - this.loadconfig() - } - - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.refreshTab && nextProps.refreshTab.MenuID === this.props.MenuID) { - if (nextProps.refreshTab.position === 'grid') { - this.reloadtable() - } else if (nextProps.refreshTab.position === 'view') { - this.reloadview() - } - this.props.refreshTabView('') - } - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 - */ - componentWillUnmount () { - this.setState = () => { - return - } - } - - render() { - const { view, setting, searchlist, actions, columns, loadingview, viewlost, pickup, config, triggerBtn } = this.state - - return ( - <div> - {view === 'commontable' ? <div className="commontable pick-control" id={this.state.ContainerId}> - {loadingview && <Spin size="large" />} - {searchlist && searchlist.length > 0 ? - <MainSearch - dict={this.state.dict} - searchlist={searchlist} - refreshdata={this.refreshbysearch} - /> : null - } - {actions && setting.onload !== 'false' ? - <MainAction - BID="" - type="main" - menuType="HS" - setting={setting} - actions={actions} - dict={this.state.dict} - triggerBtn={triggerBtn} - MenuID={this.props.MenuID} - logcolumns={this.state.logcolumns} - ContainerId={this.state.ContainerId} - refreshdata={this.refreshbyaction} - triggerPopview={this.triggerPopview} - getexceloutparam={this.getexceloutparam} - gettableselected={this.gettableselected} - /> : null - } - {columns && setting.onload !== 'false' ? - <div className="main-table-box"> - {this.state.data && this.state.data.length > 0 ? - <div className="pickchange"> - <Switch title="鏀惰捣" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> - </div> : null - } - <MainTable - ref="mainTable" - menuType="HS" - tableId="mainTable" - pickup={pickup} - config={config} - setting={setting} - columns={columns} - dict={this.state.dict} - data={this.state.data} - total={this.state.total} - MenuID={this.props.MenuID} - loading={this.state.loading} - refreshdata={this.refreshbytable} - buttonTrigger={this.buttonTrigger} - handleTableId={this.handleTableId} - /> - </div> : null - } - {setting && setting.onload !== 'false' && - config.tabgroups.map(group => { - if (group.sublist.length === 0) return null - - return ( - <Tabs defaultActiveKey="0" key={group.uuid}> - {group.sublist.map((_tab, index) => { - return ( - <TabPane tab={ - <span> - {_tab.icon ? <Icon type={_tab.icon} /> : null} - {_tab.label} - </span> - } key={`${index}`}> - {_tab.type === 'SubTable' ? - <SubTable - 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} - {_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> - ) - })} - </Tabs> - ) - }) - } - <Button - icon="copy" - shape="circle" - className="common-table-copy" - onClick={this.handleviewconfig} - /> - <Modal - className="popview-modal" - title={this.state.popAction.label} - width={'80vw'} - maskClosable={false} - visible={this.state.visible} - onCancel={this.popclose} - footer={[ - <Button key="close" onClick={this.popclose}>{this.state.dict['main.close']}</Button> - ]} - destroyOnClose - > - {<SubTabTable - BID={''} - menuType="HS" - SupMenuID={this.props.MenuID} - MenuID={this.state.popAction.linkTab} - BData={this.state.BIDs['mainTabledata'] || ''} - ContainerId={this.state.ContainerId} - ID={this.state.popData ? this.state.popData[setting.primaryKey] : ''} - refreshSupView={this.reloadtable} - />} - </Modal> - <Modal - className="menu-tree-modal" - title={'鑿滃崟缁撴瀯鏍�'} - width={'650px'} - maskClosable={false} - visible={this.state.treevisible} - onCancel={() => this.setState({treevisible: false})} - footer={[ - <Button key="close" onClick={() => this.setState({treevisible: false})}>{this.state.dict['main.close']}</Button> - ]} - destroyOnClose - > - <div className="menu-header"> - <span>鑿滃崟鍚嶇О锛歿this.props.MenuName}</span> - <span>鑿滃崟鍙傛暟锛歿<Paragraph copyable>{this.props.MenuNo}</Paragraph>}</span> - </div> - {this.state.treevisible ? <Tree defaultExpandAll showLine={true}> - {this.getTreeNode(config.funcs)} - </Tree> : null} - </Modal> - {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} - </div> : null} - {view === 'formtab' ? <FormTab MenuID={this.state.tabBtn.uuid} param={this.state.tabParam} refresh={this.refreshbyformtab}/> : null} - </div> - ) - } -} - -const mapStateToProps = (state) => { - return { - tabviews: state.tabviews, - refreshTab: state.refreshTab, - dataManager: state.dataManager, - permAction: state.permAction - } -} - -const mapDispatchToProps = (dispatch) => { - return { - refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)), - modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) - } -} - -export default connect(mapStateToProps, mapDispatchToProps)(NormalTable) \ No newline at end of file diff --git a/src/tabviews/managetable/index.scss b/src/tabviews/managetable/index.scss deleted file mode 100644 index f323721..0000000 --- a/src/tabviews/managetable/index.scss +++ /dev/null @@ -1,105 +0,0 @@ -.commontable { - position: relative; - min-height: calc(100vh - 94px); - padding-top: 16px; - padding-bottom: 80px; - .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: fixed; - left: calc(50vw - 22px); - top: calc(50vh - 70px); - } - > .ant-card { - margin: 0 20px 20px; - > .ant-card-head { - border: 0; - padding: 0; - min-height: 30px; - .ant-card-head-title { - padding: 10px 0 0; - span { - color: #1890ff; - display: inline-block; - padding: 0 10px; - font-size: 15px; - border-bottom: 1px solid #1890ff; - i { - margin-right: 10px; - } - } - } - } - > .ant-card-body { - padding: 0; - } - } - .main-table-box { - position: relative; - .pickchange { - position: absolute; - right: 0px; - top: -25px; - .ant-switch { - z-index: 1; - float: right; - margin-right: 20px; - margin-bottom: 5px; - } - } - } - > .ant-tabs { - padding: 0px 20px; - margin-bottom: 20px; - .ant-tabs-tab:not(.ant-tabs-tab-active) { - cursor: pointer; - } - } - .common-table-copy { - position: fixed; - z-index: 2; - bottom: 65px; - right: 30px; - width: 40px; - height: 40px; - } -} -.commontable.pick-control { - >.button-list { - padding-right: 140px; - } -} - -.menu-tree-modal { - .ant-modal-body { - min-height: 300px; - .menu-header { - text-align: center; - span { - font-weight: 600; - margin-right: 20px; - } - .ant-typography { - font-weight: 600; - display: inline-block; - } - } - .ant-tree li .ant-tree-node-content-wrapper { - cursor: default; - } - } -} \ No newline at end of file diff --git a/src/tabviews/scriptmanage/actionList/index.jsx b/src/tabviews/scriptmanage/actionList/index.jsx index c91c5e1..26df1ce 100644 --- a/src/tabviews/scriptmanage/actionList/index.jsx +++ b/src/tabviews/scriptmanage/actionList/index.jsx @@ -15,7 +15,6 @@ BID: PropTypes.string, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� - type: PropTypes.string, // 鍒ゆ柇褰撳墠涓轰富琛紙main锛夈�佸瓙琛紙sub锛夈�佸瓙琛ㄦ爣绛撅紙subtab锛� MenuID: PropTypes.string, // 鑿滃崟ID actions: PropTypes.array, // 鎸夐挳缁� logcolumns: PropTypes.array, // 鏄剧ず鍒� @@ -23,7 +22,7 @@ setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� refreshdata: PropTypes.func, // 鎵ц瀹屾垚鍚庢暟鎹埛鏂� - gettableselected: PropTypes.func // 鑾峰彇琛ㄦ牸涓暟鎹� + selectedData: PropTypes.array // 琛ㄦ牸閫変腑鏁版嵁 } state = { @@ -43,10 +42,10 @@ * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ actionTrigger = (item, record) => { - const { setting } = this.props + const { setting, selectedData } = this.props let _this = this - let data = this.props.gettableselected() || [] + let data = selectedData || [] if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� data = [record] @@ -267,10 +266,6 @@ if (execAction.setting.clickouter === 'close') { clickouter = true } - } - - if (this.props.type === 'subtab') { - container = document.body } return ( diff --git a/src/tabviews/scriptmanage/index.jsx b/src/tabviews/scriptmanage/index.jsx index 22912bf..dd31ec9 100644 --- a/src/tabviews/scriptmanage/index.jsx +++ b/src/tabviews/scriptmanage/index.jsx @@ -11,10 +11,12 @@ import options from '@/store/options.js' import { scriptMainTable, buttonConfig } from './config' -import MainTable from '@/tabviews/zshare/normalTable' +import asyncSpinComponent from '@/utils/asyncSpinComponent' import TopSearch from './topSearch' import MainAction from './actionList' import './index.scss' + +const MainTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) class ScriptTable extends Component { static propTpyes = { @@ -34,6 +36,8 @@ logcolumns: null, // 鏃ュ織涓樉绀虹殑鍒椾俊鎭� (澧炲姞鑷冲叏閮ㄥ垪锛岄櫎鍘诲悎骞跺垪) setting: {}, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: [], // 鍒楄〃鏁版嵁闆� + selectedData: [], // 宸查�夎〃鏍兼暟鎹� + resetTable: false, // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆 total: 0, // 鎬绘暟 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 @@ -188,12 +192,12 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - this.refs.mainTable.resetTable() - this.setState({ loading: true, pageIndex: 1, - search: searches + selectedData: [], + search: searches, + resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) @@ -213,6 +217,7 @@ this.setState({ loading: true, + selectedData: [], pageIndex: pagination.current, pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' @@ -225,10 +230,11 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - this.refs.mainTable.resetTable() this.setState({ loading: true, - pageIndex: 1 + pageIndex: 1, + selectedData: [], + resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) @@ -238,21 +244,8 @@ * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� */ reloadview = () => { - this.setState({ - config: {}, - searchlist: [], - actions: [], - columns: [], - arr_field: '', - setting: {}, - data: [], - total: 0, - loading: false, - pageIndex: 1, - pageSize: 10, - orderBy: '', - search: '', - pickup: false + this.setState({ config: {}, searchlist: [], actions: [], columns: [], arr_field: '', setting: {}, data: [], total: 0, + loading: false, pageIndex: 1, pageSize: 10, orderBy: '', search: '', pickup: false, selectedData: [] }, () => { this.loadconfig() }) @@ -274,14 +267,10 @@ } /** - * @description 鑾峰彇琛ㄦ牸閫夋嫨椤� + * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹� */ - gettableselected = () => { - let data = [] - this.refs.mainTable.state.selectedRowKeys.forEach(item => { - data.push(this.refs.mainTable.props.data[item]) - }) - return data + changeSelectedData = (selectedData) => { + this.setState({selectedData}) } /** @@ -313,7 +302,7 @@ } render() { - const { dict, searchlist, config, setting, actions, columns, pickup } = this.state + const { dict, searchlist, config, setting, actions, columns, pickup, selectedData } = this.state return ( <div className="veruptable pick-control" id={this.state.ContainerId}> @@ -329,10 +318,10 @@ actions={actions} dict={this.state.dict} MenuID={this.props.MenuID} + selectedData={selectedData} logcolumns={this.state.logcolumns} ContainerId={this.state.ContainerId} refreshdata={this.refreshbyaction} - gettableselected={this.gettableselected} /> <div className="main-table-box"> {this.state.data && this.state.data.length > 0 ? @@ -341,8 +330,6 @@ </div> : null } <MainTable - ref="mainTable" - menuType="HS" tableId="mainTable" pickup={pickup} config={config} @@ -356,6 +343,8 @@ refreshdata={this.refreshbytable} buttonTrigger={() => {}} handleTableId={() => {}} + resetTable={this.state.resetTable} + chgSelectData={this.changeSelectedData} /> </div> </div> diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index 539c284..b40d2df 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { notification, Spin, Modal, Button, Switch, Col, Icon, Tabs} from 'antd' +import { notification, Spin, Switch, Col, Icon, Tabs} from 'antd' import moment from 'moment' import Api from '@/api' @@ -12,7 +12,6 @@ import options from '@/store/options.js' import { modifyTabview } from '@/store/action' -import SubTable from '@/tabviews/zshare/normalTable' import SubSearch from '@/tabviews/zshare/topSearch' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' @@ -22,13 +21,12 @@ const { TabPane } = Tabs const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) -const CardComponent = asyncComponent(() => import('@/tabviews/zshare/cardcomponent')) +const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) +const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent')) const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent')) -const SubTabTable = asyncSpinComponent(() => import('@/tabviews/subtabtable')) class SubTabViewTable extends Component { static propTpyes = { - menuType: PropTypes.any, // 鑿滃崟绫诲瀷锛屾櫘閫氳彍鍗曟垨HS Tab: PropTypes.object, // 鏍囩淇℃伅 BID: PropTypes.string, // 涓婄骇鏁版嵁ID BData: PropTypes.any, // 涓婄骇鏁版嵁 @@ -56,15 +54,14 @@ arr_field: '', // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: null, // 鍒楄〃鏁版嵁闆� + selectedData: [], // 宸查�夎〃鏍兼暟鎹� + resetTable: false, // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆 total: 0, // 鎬绘暟 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� - popAction: false, // 寮规椤甸潰锛屾寜閽俊鎭� - popData: null, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 - visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 pickup: false, // 瀛愯〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 triggerBtn: null, // 鎸夐挳瑙﹀彂 chartId: '' // 灞曞紑鍥捐〃ID @@ -75,8 +72,13 @@ */ UNSAFE_componentWillReceiveProps(nextProps) { if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) { - this.refs.subTable && this.refs.subTable.resetTable() - this.loadmaindata(nextProps.BID, 'refresh') + this.setState({ + pageIndex: 1, + selectedData: [], + resetTable: !this.state.resetTable, + }, () => { + this.loadmaindata(nextProps.BID, 'refresh') + }) } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { this.reloadtable() } else if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.parentId === this.props.Tab.uuid) { @@ -299,10 +301,8 @@ }) if (config.gridBtn && config.gridBtn.display && _operations.length > 0) { - _columns.push({ - ...config.gridBtn, - operations: _operations - }) + config.gridBtn.operations = _operations + _columns.push(config.gridBtn) } let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉 @@ -327,6 +327,8 @@ return pre.sort - next.sort }) } + + config.setting.tabType = 'sub' this.setState({ loadingview: false, @@ -703,11 +705,11 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - this.refs.subTable && this.refs.subTable.resetTable() - this.setState({ pageIndex: 1, - search: searches + search: searches, + resetTable: !this.state.resetTable, + selectedData: [], }, () => { this.loadmaindata() }) @@ -726,6 +728,7 @@ } this.setState({ + selectedData: [], pageIndex: pagination.current, pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' @@ -738,9 +741,10 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - this.refs.subTable && this.refs.subTable.resetTable() this.setState({ - pageIndex: 1 + pageIndex: 1, + selectedData: [], + resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) @@ -750,24 +754,9 @@ * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� */ reloadview = () => { - this.setState({ - loadingview: true, - viewlost: false, - lostmsg: '', - config: null, - searchlist: null, - actions: null, - columns: null, - arr_field: '', - setting: null, - data: null, - total: 0, - loading: false, - pageIndex: 1, - pageSize: 10, - orderBy: '', - search: '', - triggerBtn: null + this.setState({ loadingview: true, viewlost: false, lostmsg: '', config: null, searchlist: null, actions: null, + columns: null, arr_field: '', setting: null, data: null, total: 0, loading: false, pageIndex: 1, pageSize: 10, + orderBy: '', search: '', triggerBtn: null }, () => { this.loadconfig() }) @@ -776,35 +765,22 @@ /** * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� */ - refreshbyaction = (btn, type) => { + refreshbyaction = (position) => { const { Tab } = this.props - if (btn.execSuccess === 'grid' && type === 'success') { + if (position === 'grid') { this.reloadtable() - } else if (btn.execError === 'grid' && type === 'error') { - this.reloadtable() - } else if (btn.execSuccess === 'view' && type === 'success') { + } else if (position === 'view') { this.reloadview() - } else if (btn.execError === 'view' && type === 'error') { - this.reloadview() - } else if (btn.popClose === 'grid' && type === 'pop') { - this.reloadtable() - } else if (btn.popClose === 'view' && type === 'pop') { - this.reloadview() - } else if (btn.popClose === 'maingrid' && type === 'pop') { - this.props.handleMainTable('maingrid') - } else if (btn.popClose === 'equaltab' && type === 'pop') { - this.reloadtable() - this.props.handleMainTable('equaltab') - } else if (btn.execSuccess === 'maingrid' && type === 'success') { + } else if (position === 'maingrid') { if (Tab.isTreeNode) { this.reloadtable() } this.props.handleMainTable('maingrid') - } else if (btn.execSuccess === 'equaltab' && type === 'success') { + } else if (position === 'equaltab') { this.reloadtable() this.props.handleMainTable('equaltab') - }else if (btn.execSuccess === 'mainline' && type === 'success') { + } else if (position === 'mainline') { this.reloadtable() this.props.handleMainTable('mainline') } @@ -831,14 +807,10 @@ } /** - * @description 鑾峰彇琛ㄦ牸閫夋嫨椤� + * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹� */ - gettableselected = () => { - let data = [] - this.refs.subTable && this.refs.subTable.state.selectedRowKeys.forEach(item => { - data.push(this.refs.subTable.props.data[item]) - }) - return data + changeSelectedData = (selectedData) => { + this.setState({selectedData}) } /** @@ -863,17 +835,6 @@ } /** - * @description 瑙﹀彂鎸夐挳寮圭獥锛堟爣绛鹃〉锛� - */ - triggerPopview = (btn, data) => { - this.setState({ - popAction: btn, - popData: data[0] ? data[0] : null, - visible: true - }) - } - - /** * @description 鏁版嵁灞曞紑鍚堝苟鍒囨崲 */ pickupChange = () => { @@ -882,41 +843,6 @@ this.setState({ pickup: !pickup }) - } - - linkTrigger = (menu) => { - const { tabviews, SupMenuID } = this.props - - menu.selected = true - - let index = 0 - let isexit = false - let tabs = tabviews.map((tab, i) => { - tab.selected = false - - if (tab.MenuID === SupMenuID) { - index = i - } else if (tab.MenuID === menu.MenuID) { - tab.param = menu.param - tab.selected = true - isexit = true - } - - return tab - }) - - if (!isexit) { - tabs.splice(index + 1, 0, menu) - } - - this.props.modifyTabview(tabs) - } - - popclose = () => { - this.setState({ - visible: false - }) - this.refreshbyaction(this.state.popAction, 'pop') } /** @@ -945,7 +871,7 @@ } render() { - const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, triggerBtn, chartId } = this.state + const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, triggerBtn, chartId, selectedData } = this.state return ( <div className="subtable" id={'subtable' + this.props.MenuID}> @@ -972,22 +898,19 @@ {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} <div className="sub-action"> <SubAction - type="sub" - menuType={this.props.menuType} - triggerBtn={triggerBtn} setting={setting} actions={actions} Tab={this.props.Tab} BID={this.props.BID} + triggerBtn={triggerBtn} BData={this.props.BData} - dict={this.state.dict} MenuID={this.props.MenuID} + selectedData={selectedData} logcolumns={this.state.logcolumns} refreshdata={this.refreshbyaction} ContainerId={this.props.ContainerId} - triggerPopview={this.triggerPopview} + operations={config.gridBtn.operations || []} getexceloutparam={this.getexceloutparam} - gettableselected={this.gettableselected} /> </div> <div className="subtable-box"> @@ -995,8 +918,6 @@ <Switch title="鏀惰捣" className="subtable-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null } <SubTable - ref="subTable" - menuType={this.props.menuType} tableId={this.props.Tab.uuid} pickup={pickup} config={config} @@ -1007,13 +928,12 @@ data={this.state.data} total={this.state.total} MenuID={this.props.MenuID} - memberLevel={this.props.memberLevel} loading={this.state.loading} - pagination={setting.laypage !== 'false'} refreshdata={this.refreshbytable} buttonTrigger={this.buttonTrigger} - linkTrigger={this.linkTrigger} handleTableId={this.handleTableId} + resetTable={this.state.resetTable} + chgSelectData={this.changeSelectedData} /> </div> </Col> @@ -1024,34 +944,17 @@ <CardComponent plot={item} config={config} + Tab={this.props.Tab} + BID={this.props.BID} + BData={this.props.BData} data={this.state.data} + MenuID={this.props.MenuID} loading={this.state.loading} tableId={this.props.Tab.uuid} - buttonTrigger={this.buttonTrigger} + logcolumns={this.state.logcolumns} + refreshdata={this.refreshbyaction} handleTableId={this.handleTableId} /> - <div style={{display: 'none'}}> - <SubAction - type="sub" - menuType={this.props.menuType} - triggerBtn={triggerBtn} - setting={setting} - actions={actions} - Tab={this.props.Tab} - BID={this.props.BID} - BData={this.props.BData} - dict={this.state.dict} - MenuID={this.props.MenuID} - dataManager={this.props.dataManager} - permRoles={this.props.permRoles} - logcolumns={this.state.logcolumns} - refreshdata={this.refreshbyaction} - ContainerId={this.props.ContainerId} - triggerPopview={this.triggerPopview} - getexceloutparam={this.getexceloutparam} - gettableselected={this.gettableselected} - /> - </div> </Col> ) } else { @@ -1068,28 +971,6 @@ } })} </div> : null } - <Modal - className="popview-modal" - title={this.state.popAction.label} - width={'80vw'} - maskClosable={false} - visible={this.state.visible} - onCancel={this.popclose} - footer={[ - <Button key="close" onClick={this.popclose}>{this.state.dict['main.close']}</Button> - ]} - destroyOnClose - > - {<SubTabTable - BID={this.state.popData ? this.state.popData[setting.primaryKey] : this.props.BID} - menuType={this.props.menuType} - BData={this.state.popData || this.props.BData} - SupMenuID={this.props.MenuID} - ContainerId={this.props.ContainerId} - MenuID={this.state.popAction.linkTab} - refreshSupView={this.reloadtable} - />} - </Modal> {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) @@ -1099,11 +980,11 @@ const mapStateToProps = (state) => { return { tabviews: state.tabviews, + menuType: state.editLevel, permAction: state.permAction, permRoles: state.permRoles, permMenus: state.permMenus, dataManager: state.dataManager, - memberLevel: state.memberLevel } } diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx index e059907..5d7d64f 100644 --- a/src/tabviews/subtabtable/index.jsx +++ b/src/tabviews/subtabtable/index.jsx @@ -13,7 +13,6 @@ import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' -import SubTable from '@/tabviews/zshare/normalTable' import SubSearch from '@/tabviews/zshare/topSearch' import NotFount from '@/components/404' @@ -21,17 +20,16 @@ const { TabPane } = Tabs const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList')) -const CardComponent = asyncComponent(() => import('@/tabviews/zshare/cardcomponent')) +const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) +const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent')) const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent')) class SubTabModalTable extends Component { static propTpyes = { - menuType: PropTypes.any, // 鑿滃崟绫诲瀷锛屾櫘閫氳彍鍗曟垨HS BID: PropTypes.string, // 涓婄骇鏁版嵁ID BData: PropTypes.any, // 涓婄骇鏁版嵁 MenuID: PropTypes.string, // 鑿滃崟Id SupMenuID: PropTypes.string, // 涓婄骇鑿滃崟Id - ContainerId: PropTypes.any, // 涓夌骇鑿滃崟Container(html) ID refreshSupView: PropTypes.any // 鍒锋柊涓婄骇鑿滃崟 } @@ -48,6 +46,8 @@ arr_field: '', // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: null, // 鍒楄〃鏁版嵁闆� + selectedData: [], // 宸查�夎〃鏍兼暟鎹� + resetTable: false, // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆 total: 0, // 鎬绘暟 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 @@ -236,10 +236,8 @@ }) if (config.gridBtn && config.gridBtn.display && _operations.length > 0) { - _columns.push({ - ...config.gridBtn, - operations: _operations - }) + config.gridBtn.operations = _operations + _columns.push(config.gridBtn) } let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉 @@ -248,6 +246,8 @@ valid = false } }) + + config.setting.tabType = 'subtab' this.setState({ loadingview: false, @@ -580,11 +580,11 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - this.refs.subTable && this.refs.subTable.resetTable() - this.setState({ pageIndex: 1, - search: searches + search: searches, + selectedData: [], + resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) @@ -603,6 +603,7 @@ } this.setState({ + selectedData: [], pageIndex: pagination.current, pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' @@ -615,35 +616,28 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - this.refs.subTable && this.refs.subTable.resetTable() this.setState({ - pageIndex: 1 + pageIndex: 1, + selectedData: [], + resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) } /** + * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹� + */ + changeSelectedData = (selectedData) => { + this.setState({selectedData}) + } + + /** * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� */ reloadview = () => { - this.setState({ - loadingview: true, - viewlost: false, - lostmsg: '', - config: null, - searchlist: null, - actions: null, - columns: null, - arr_field: '', - setting: null, - data: null, - total: 0, - loading: false, - pageIndex: 1, - pageSize: 10, - orderBy: '', - search: '', + this.setState({ loadingview: true, viewlost: false, lostmsg: '', config: null, searchlist: null, actions: null, columns: null, + arr_field: '', setting: null, data: null, total: 0, loading: false, pageIndex: 1, pageSize: 10, orderBy: '', search: '', triggerBtn: null }, () => { this.loadconfig() @@ -653,30 +647,14 @@ /** * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� */ - refreshbyaction = (btn, type) => { - if (btn.execSuccess === 'grid' && type === 'success') { + refreshbyaction = (position) => { + if (position === 'grid') { this.reloadtable() - } else if (btn.execError === 'grid' && type === 'error') { + this.props.refreshSupView() + } else if (position === 'view') { this.reloadview() - } else if (btn.execSuccess === 'view' && type === 'success') { - this.reloadtable() - } else if (btn.execError === 'view' && type === 'error') { - this.reloadview() - } - if (type === 'success') { this.props.refreshSupView() } - } - - /** - * @description 鑾峰彇琛ㄦ牸閫夋嫨椤� - */ - gettableselected = () => { - let data = [] - this.refs.subTable && this.refs.subTable.state.selectedRowKeys.forEach(item => { - data.push(this.refs.subTable.props.data[item]) - }) - return data } /** @@ -719,7 +697,7 @@ } render() { - const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, triggerBtn, chartId } = this.state + const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, triggerBtn, chartId, selectedData } = this.state return ( <div className="subtabtable" id={'subtabtable' + this.props.MenuID}> @@ -747,38 +725,34 @@ {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null} <div style={{minHeight: '25px'}}> <SubAction - type="subtab" triggerBtn={triggerBtn} - menuType={this.props.menuType} setting={setting} actions={actions} BID={this.props.BID} dict={this.state.dict} BData={this.props.BData} + selectedData={selectedData} MenuID={this.props.SupMenuID} logcolumns={this.state.logcolumns} + operations={config.gridBtn.operations || []} refreshdata={this.refreshbyaction} - ContainerId={this.props.ContainerId} - gettableselected={this.gettableselected} /> </div> <SubTable - ref="subTable" - menuType={this.props.menuType} tableId="" - dict={this.state.dict} - MenuID={this.props.MenuID} config={config} setting={setting} columns={columns} pageSize={pageSize} data={this.state.data} + dict={this.state.dict} total={this.state.total} - memberLevel={this.props.memberLevel} + MenuID={this.props.MenuID} loading={this.state.loading} - pagination={setting.laypage !== 'false'} refreshdata={this.refreshbytable} buttonTrigger={this.buttonTrigger} + resetTable={this.state.resetTable} + chgSelectData={this.changeSelectedData} handleTableId={() => {}} /> </Col> @@ -795,25 +769,6 @@ buttonTrigger={this.buttonTrigger} handleTableId={() => {}} /> - <div style={{display: 'none'}}> - <SubAction - type="subtab" - triggerBtn={triggerBtn} - menuType={this.props.menuType} - setting={setting} - actions={actions} - BID={this.props.BID} - dict={this.state.dict} - BData={this.props.BData} - MenuID={this.props.SupMenuID} - permRoles={this.props.permRoles} - dataManager={this.props.dataManager} - logcolumns={this.state.logcolumns} - refreshdata={this.refreshbyaction} - ContainerId={this.props.ContainerId} - gettableselected={() => {}} - /> - </div> </Col> ) } else { @@ -838,6 +793,7 @@ const mapStateToProps = (state) => { return { + menuType: state.editLevel, permAction: state.permAction, permRoles: state.permRoles, dataManager: state.dataManager, diff --git a/src/tabviews/treepage/index.jsx b/src/tabviews/treepage/index.jsx index 243fe32..99c21f8 100644 --- a/src/tabviews/treepage/index.jsx +++ b/src/tabviews/treepage/index.jsx @@ -856,7 +856,6 @@ {_tab.type === 'SubTable' ? <SubTable Tab={_tab} - menuType="main" MenuID={_tab.linkTab} mainSearch={null} userConfig={userConfig ? userConfig[_tab.uuid] : null} diff --git a/src/tabviews/verupmanage/actionList/index.jsx b/src/tabviews/verupmanage/actionList/index.jsx index 7746b01..733f45c 100644 --- a/src/tabviews/verupmanage/actionList/index.jsx +++ b/src/tabviews/verupmanage/actionList/index.jsx @@ -23,7 +23,7 @@ setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� refreshdata: PropTypes.func, // 鎵ц瀹屾垚鍚庢暟鎹埛鏂� - gettableselected: PropTypes.func // 鑾峰彇琛ㄦ牸涓暟鎹� + selectedData: PropTypes.array // 琛ㄦ牸閫変腑鏁版嵁 } state = { @@ -45,7 +45,7 @@ * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ actionTrigger = (item, record) => { - const { setting, type, Tab, BID } = this.props + const { setting, type, Tab, BID, selectedData } = this.props if (type === 'sub' && Tab && Tab.supMenu && !BID) { notification.warning({ @@ -57,7 +57,7 @@ } let _this = this - let data = this.props.gettableselected() || [] + let data = selectedData || [] if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� data = [record] diff --git a/src/tabviews/verupmanage/index.jsx b/src/tabviews/verupmanage/index.jsx index bc2f11f..373bd50 100644 --- a/src/tabviews/verupmanage/index.jsx +++ b/src/tabviews/verupmanage/index.jsx @@ -9,15 +9,15 @@ import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' import options from '@/store/options.js' -import asyncLoadComponent from '@/utils/asyncLoadComponent' +import asyncSpinComponent from '@/utils/asyncSpinComponent' import { verupMainTable, buttonConfig } from './config' -import MainTable from '@/tabviews/zshare/normalTable' import TopSearch from './topSearch' import MainAction from './actionList' import './index.scss' -const SubTable = asyncLoadComponent(() => import('./subtabtable')) +const SubTable = asyncSpinComponent(() => import('./subtabtable')) +const MainTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) const { TabPane } = Tabs @@ -39,6 +39,8 @@ logcolumns: null, // 鏃ュ織涓樉绀虹殑鍒椾俊鎭� (澧炲姞鑷冲叏閮ㄥ垪锛岄櫎鍘诲悎骞跺垪) setting: {}, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: [], // 鍒楄〃鏁版嵁闆� + selectedData: [], // 宸查�夎〃鏍兼暟鎹� + resetTable: false, // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆 total: 0, // 鎬绘暟 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 @@ -274,11 +276,11 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - this.refs.mainTable.resetTable() - this.setState({ loading: true, pageIndex: 1, + selectedData: [], + resetTable: !this.state.resetTable, search: searches }, () => { this.loadmaindata() @@ -299,6 +301,7 @@ this.setState({ loading: true, + selectedData: [], pageIndex: pagination.current, pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' @@ -311,10 +314,11 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - this.refs.mainTable.resetTable() this.setState({ + pageIndex: 1, loading: true, - pageIndex: 1 + selectedData: [], + resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) @@ -386,14 +390,10 @@ } /** - * @description 鑾峰彇琛ㄦ牸閫夋嫨椤� + * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹� */ - gettableselected = () => { - let data = [] - this.refs.mainTable.state.selectedRowKeys.forEach(item => { - data.push(this.refs.mainTable.props.data[item]) - }) - return data + changeSelectedData = (selectedData) => { + this.setState({selectedData}) } /** @@ -440,7 +440,7 @@ } render() { - const { dict, searchlist, setting, actions, columns, pickup, config } = this.state + const { dict, searchlist, setting, actions, columns, pickup, config, selectedData } = this.state return ( <div className="veruptable pick-control" id={this.state.ContainerId}> @@ -456,10 +456,10 @@ actions={actions} dict={this.state.dict} MenuID={this.props.MenuID} + selectedData={selectedData} logcolumns={this.state.logcolumns} ContainerId={this.state.ContainerId} refreshdata={this.refreshbyaction} - gettableselected={this.gettableselected} /> <div className="main-table-box"> {this.state.data && this.state.data.length > 0 ? @@ -468,8 +468,6 @@ </div> : null } <MainTable - ref="mainTable" - menuType="HS" tableId="mainTable" pickup={pickup} config={config} @@ -483,6 +481,8 @@ refreshdata={this.refreshbytable} buttonTrigger={() => {}} handleTableId={this.handleTableId} + resetTable={this.state.resetTable} + chgSelectData={this.changeSelectedData} /> </div> <Tabs defaultActiveKey="0"> diff --git a/src/tabviews/verupmanage/subtabtable/index.jsx b/src/tabviews/verupmanage/subtabtable/index.jsx index 8073ec4..cb309f1 100644 --- a/src/tabviews/verupmanage/subtabtable/index.jsx +++ b/src/tabviews/verupmanage/subtabtable/index.jsx @@ -11,11 +11,13 @@ import options from '@/store/options.js' import { buttonConfig, tabConfig } from '../config' -import SubTable from '@/tabviews/zshare/normalTable' +import asyncSpinComponent from '@/utils/asyncSpinComponent' import SubAction from '../actionList' import SubSearch from '../topSearch' import './index.scss' + +const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable')) class VerupSubTabViewTable extends Component { static propTpyes = { @@ -41,6 +43,8 @@ arr_field: '', // 浣跨敤 sPC_Get_TableData 鏃剁殑鏌ヨ瀛楁闆� setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 data: null, // 鍒楄〃鏁版嵁闆� + selectedData: [], // 宸查�夎〃鏍兼暟鎹� + resetTable: false, // 琛ㄦ牸閲嶇疆锛屽�煎湪true涓巉alse涔嬮棿鍒囨崲锛屽垏鎹㈡椂琛ㄦ牸閲嶇疆 total: 0, // 鎬绘暟 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 @@ -58,8 +62,13 @@ */ 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') + this.setState({ + pageIndex: 1, + selectedData: [], + resetTable: !this.state.resetTable, + }, () => { + this.loadmaindata(nextProps.BID, 'refresh') + }) } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) { this.reloadtable() @@ -288,12 +297,12 @@ * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� */ refreshbysearch = (searches) => { - this.refs.subTable.resetTable() - this.setState({ loading: true, pageIndex: 1, - search: searches + selectedData: [], + search: searches, + resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) @@ -313,6 +322,7 @@ this.setState({ loading: true, + selectedData: [], pageIndex: pagination.current, pageSize: pagination.pageSize, orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' @@ -325,13 +335,21 @@ * @description 琛ㄦ牸鍒锋柊 */ reloadtable = () => { - this.refs.subTable.resetTable() this.setState({ loading: true, - pageIndex: 1 + pageIndex: 1, + selectedData: [], + resetTable: !this.state.resetTable }, () => { this.loadmaindata() }) + } + + /** + * @description 琛ㄦ牸閫夋嫨椤瑰垏鎹� + */ + changeSelectedData = (selectedData) => { + this.setState({selectedData}) } /** @@ -379,17 +397,6 @@ } /** - * @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 = '') => { @@ -426,7 +433,7 @@ } render() { - const { config, setting, searchlist, actions, columns, pickup } = this.state + const { config, setting, searchlist, actions, columns, pickup, selectedData } = this.state return ( <div className="subtable" id={'subtable' + this.props.MenuID}> @@ -440,7 +447,6 @@ {actions ? <div className="sub-action"> <SubAction - ref="subButton" type="sub" setting={setting} actions={actions} @@ -448,12 +454,12 @@ BID={this.props.BID} BData={this.props.BData} dict={this.state.dict} + selectedData={selectedData} MenuID={this.props.SupMenuID} logcolumns={this.state.logcolumns} refreshdata={this.refreshbyaction} ContainerId={this.props.ContainerId} getexceloutparam={this.getexceloutparam} - gettableselected={this.gettableselected} /> </div> : null } @@ -463,8 +469,6 @@ <Switch title="鏀惰捣" className="subtable-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={pickup} onChange={this.pickupChange} /> : null } <SubTable - ref="subTable" - menuType="HS" tableId={this.props.Tab.uuid} pickup={pickup} config={config} @@ -478,6 +482,8 @@ refreshdata={this.refreshbytable} buttonTrigger={() => {}} handleTableId={this.handleTableId} + resetTable={this.state.resetTable} + chgSelectData={this.changeSelectedData} /> </div> : null } diff --git a/src/tabviews/zshare/actionList/asyncButtonComponent.jsx b/src/tabviews/zshare/actionList/asyncButtonComponent.jsx new file mode 100644 index 0000000..695f378 --- /dev/null +++ b/src/tabviews/zshare/actionList/asyncButtonComponent.jsx @@ -0,0 +1,32 @@ +import React, {Component} from 'react' +import { Button } from 'antd' + +/** + * @description 寮傛鍔犺浇妯″潡 + * @param {*} importComponent + */ +export default function asyncComponent(importComponent) { + return class extends Component { + constructor(props) { + super(props) + + this.state = { + component: null + } + } + + async componentDidMount() { + const {default: component} = await importComponent() + + this.setState({component}) + } + + render() { + const C = this.state.component + + return C ? + <C {...this.props} /> : + <Button className="loading-skeleton" disabled={true}></Button> + } + } +} \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/changeuserbutton/index.jsx b/src/tabviews/zshare/actionList/changeuserbutton/index.jsx new file mode 100644 index 0000000..787555e --- /dev/null +++ b/src/tabviews/zshare/actionList/changeuserbutton/index.jsx @@ -0,0 +1,153 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' +import { Button, notification, Modal } from 'antd' + +import Api from '@/api' +import Utils from '@/utils/utils.js' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import './index.scss' + +const { confirm } = Modal + +class NewPageButton extends Component { + static propTpyes = { + show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 + BID: PropTypes.string, // 涓昏〃ID + btn: PropTypes.object, // 鎸夐挳 + selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 + setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� + triggerBtn: PropTypes.any + } + + state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS + } + + /** + * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { + this.actionTrigger(nextProps.triggerBtn.data) + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 瑙﹀彂鎸夐挳鎿嶄綔 + */ + actionTrigger = (record) => { + const { setting, selectedData } = this.props + let data = [] + + if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� + data = [record] + } else { + data = selectedData || [] + } + + if (data.length !== 1) { + // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 + notification.warning({ + top: 92, + message: this.state.dict['main.action.confirm.selectSingleLine'], + duration: 5 + }) + return + } else if (!setting.primaryKey) { + // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� + notification.warning({ + top: 92, + message: '鏈缃富閿紒', + duration: 5 + }) + return + } + + let primaryId = data[0][setting.primaryKey] || '' + + this.props.updateStatus('start') + this.changeUser(primaryId) + } + + /** + * @description 鍒囨崲鐢ㄦ埛 + */ + changeUser = (primaryId) => { + const { setting, btn } = this.props + let _this = this + + let param = { + func: 'webapi_ChangeUser' + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + if (window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } + + param[setting.primaryKey] = primaryId + + confirm({ + title: this.state.dict['main.action.confirm.tip'], + onOk() { + return new Promise(resolve => { + Api.genericInterface(param).then(res => { + resolve() + if (res.status) { + sessionStorage.setItem('avatar', res.icon || '') + sessionStorage.setItem('UserID', res.UserID) + sessionStorage.setItem('SessionUid', Utils.getuuid()) + sessionStorage.setItem('LoginUID', res.LoginUID) + sessionStorage.setItem('User_Name', res.UserName) + sessionStorage.setItem('Full_Name', res.FullName) + + window.location.reload() + } else { + notification.error({ + top: 92, + message: res.message || res.ErrMesg, + duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10 + }) + _this.props.updateStatus('over') + } + }, () => { + resolve() + _this.props.updateStatus('over') + }) + }) + }, + onCancel() { + _this.props.updateStatus('over') + } + }) + } + + render() { + const { btn, show } = this.props + + return ( + <div className="mk-btn-wrap"> + {!show ? <Button + className={'mk-btn mk-' + btn.class} + icon={btn.icon} + onClick={() => {this.actionTrigger()}} + >{btn.label}</Button> : null} + {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} onClick={() => {this.actionTrigger()}}></Button> : null} + {show === 'text' ? <Button className="action-cell" onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + </div> + ) + } +} + +export default NewPageButton \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/changeuserbutton/index.scss b/src/tabviews/zshare/actionList/changeuserbutton/index.scss new file mode 100644 index 0000000..e9a2a7d --- /dev/null +++ b/src/tabviews/zshare/actionList/changeuserbutton/index.scss @@ -0,0 +1,10 @@ +.mk-btn-wrap { + display: inline-block; + .action-cell { + border: 0; + background: transparent !important; + } + .action-cell[ant-click-animating-without-extra-node="true"]::after { + display: none!important; + } +} diff --git a/src/tabviews/zshare/actionList/excelin/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx similarity index 75% rename from src/tabviews/zshare/actionList/excelin/index.jsx rename to src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx index 937043a..1e36bfa 100644 --- a/src/tabviews/zshare/actionList/excelin/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/excelin/index.jsx @@ -7,23 +7,17 @@ class ExcelIn extends Component { static propTpyes = { + btn: PropTypes.object, // 鎸夐挳淇℃伅 MenuID: PropTypes.string, // 鑿滃崟ID - returndata: PropTypes.func // 鑿滃崟ID + returndata: PropTypes.func // 鑾峰彇杩斿洖鏁版嵁 } state = { - excelbtn: null, - primaryId: '', // 琛孖d excelId: Utils.getuuid() } - exceltrigger = (item, primaryId) => { + exceltrigger = () => { const { excelId } = this.state - this.setState({ - excelbtn: item, - primaryId: primaryId - }) - let _excelInput = document.getElementById(excelId + this.props.MenuID) if (_excelInput) { @@ -31,10 +25,10 @@ } } onImportExcel = file => { - const { excelbtn, primaryId } = this.state + const { btn } = this.props - let columns = excelbtn.verify.columns.map(option => option.Column) - let range = excelbtn.verify.range || 0 + let columns = btn.verify.columns.map(option => option.Column) + let range = btn.verify.range || 0 // excel鏁版嵁澶勭悊 const { files } = file.target @@ -48,16 +42,16 @@ let errors = null - if (!workbook.Sheets.hasOwnProperty(excelbtn.verify.sheet)) { + if (!workbook.Sheets.hasOwnProperty(btn.verify.sheet)) { errors = 'notexit' } else if (range === 1) { - let header = XLSX.utils.sheet_to_json(workbook.Sheets[excelbtn.verify.sheet], {header: columns})[0] + let header = XLSX.utils.sheet_to_json(workbook.Sheets[btn.verify.sheet], {header: columns})[0] if (!header) { errors = 'empty' } else { let iserror = false - excelbtn.verify.columns.forEach(op => { + btn.verify.columns.forEach(op => { if (header[op.Column] !== op.Text) { iserror = true } @@ -72,14 +66,13 @@ let data = [] if (!errors) { - data = XLSX.utils.sheet_to_json(workbook.Sheets[excelbtn.verify.sheet], {header: columns, range: (range)}) + data = XLSX.utils.sheet_to_json(workbook.Sheets[btn.verify.sheet], {header: columns, range: (range)}) } // 鏈�缁堣幏鍙栧埌骞朵笖鏍煎紡鍖栧悗鐨� json 鏁版嵁 - this.props.returndata(data, excelbtn, errors, primaryId) + this.props.returndata(data, errors) this.setState({ excelId: '', - primaryId: '' }, () => { this.setState({ excelId: Utils.getuuid() @@ -98,6 +91,8 @@ message: '鏂囦欢瑙f瀽閿欒锛岃妫�鏌ユ枃浠舵牸寮忥紒', duration: 5 }) + // 閿欒浼犻�� + this.props.returndata([], 'other') } } diff --git a/src/tabviews/zshare/actionList/excelin/index.scss b/src/tabviews/zshare/actionList/excelInbutton/excelin/index.scss similarity index 100% rename from src/tabviews/zshare/actionList/excelin/index.scss rename to src/tabviews/zshare/actionList/excelInbutton/excelin/index.scss diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx new file mode 100644 index 0000000..3376583 --- /dev/null +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -0,0 +1,400 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import moment from 'moment' +import {connect} from 'react-redux' +import { is, fromJS } from 'immutable' +import { Button, Modal, notification, message } from 'antd' + +import ExcelIn from './excelin' +import Utils from '@/utils/utils.js' +import options from '@/store/options.js' +import Api from '@/api' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import './index.scss' + +class ExcelInButton extends Component { + static propTpyes = { + BID: PropTypes.string, // 涓昏〃ID + BData: PropTypes.any, // 涓昏〃鏁版嵁 + selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 + Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� + MenuID: PropTypes.string, // 鑿滃崟ID + btn: PropTypes.object, // 鎸夐挳 + columns: PropTypes.array, // 瀛楁鍒� + setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� + updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� + triggerBtn: PropTypes.any, + } + + state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + loading: false, + primaryId: '', + } + + /** + * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { + this.actionTrigger(nextProps.triggerBtn.data) + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 鎸夐挳鐘舵�佹敼鍙� + */ + updateStatus = (type) => { + if (type === 'start') { + this.setState({ + loading: true + }) + this.props.updateStatus('start') + } else if (type === 'over') { + this.setState({ + loading: false + }) + this.props.updateStatus('over') + } + } + + /** + * @description 瑙﹀彂鎸夐挳鎿嶄綔 + */ + actionTrigger = (record) => { + const { setting, Tab, BID, btn, selectedData } = this.props + + if (Tab && Tab.supMenu && !BID) { + notification.warning({ + top: 92, + message: '闇�瑕佷笂绾т富閿�硷紒', + duration: 5 + }) + return + } + + let data = [] + + if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� + data = [record] + } else { + data = selectedData || [] + } + + if (btn.Ot === 'requiredSgl' && data.length !== 1) { + // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 + notification.warning({ + top: 92, + message: this.state.dict['main.action.confirm.selectSingleLine'], + duration: 5 + }) + return + } + + if (btn.verify && btn.verify.sheet && btn.verify.columns && btn.verify.columns.length > 0) { + let primaryId = '' // 瀵煎叆鏃惰Id + if (btn.Ot === 'requiredSgl') { + primaryId = data[0][setting.primaryKey] || '' + } + + this.setState({ + primaryId: primaryId + }, () => { + this.updateStatus('start') + this.refs.excelIn.exceltrigger() + }) + } else { + notification.warning({ + top: 92, + message: 'excel瀵煎叆楠岃瘉淇℃伅鏈缃紒', + duration: 5 + }) + } + } + + /** + * @description 鎿嶄綔鎴愬姛鍚庡鐞� + * 1銆乪xcel瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� + * 2銆佺姸鎬佺爜涓� S 鏃讹紝鏄剧ず鎴愬姛淇℃伅鍚庣郴缁熼粯璁や俊鎭� + * 3銆佺姸鎬佺爜涓� -1 鏃讹紝涓嶆樉绀轰换浣曚俊鎭� + * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� + * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� + */ + execSuccess = (res) => { + const { btn } = this.props + + if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 + notification.success({ + top: 92, + message: res.ErrMesg || this.state.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.state.dict['main.action.confirm.success'] + }) + } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず + + } + + this.setState({ + loading: false + }) + + this.props.updateStatus('refresh', btn.execSuccess) + } + + /** + * @description 鎿嶄綔澶辫触鍚庡鐞� + * 1銆佺姸鎬佺爜涓� E銆丯銆丗銆丯M 鏃讹紝鏄剧ず鐩稿簲鎻愮ず淇℃伅 + * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� + * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂� + */ + execError = (res) => { + const { btn } = this.props + + 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 : 10 + }) + } 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 : 10 + }) + } else if (res.ErrCode === 'NM') { + message.error(res.message || res.ErrMesg) + } + + this.setState({ + loading: false + }) + + this.props.updateStatus('refresh', btn.execError) + } + + /** + * @description Excel 瀵煎叆 + */ + getexceldata = (data, errors) => { + const { btn } = this.props + + if (errors) { + if (errors === 'notexit') { + notification.warning({ + top: 92, + message: '宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬩笉瀛樺湪锛�', + duration: 5 + }) + } else if (errors === 'empty') { + notification.warning({ + top: 92, + message: '宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬩负绌猴紒', + duration: 5 + }) + } else if (errors === 'headerError') { + notification.warning({ + top: 92, + message: '宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬭〃澶磋缃敊璇紒', + duration: 5 + }) + } + + this.updateStatus('over') + return + } + + if (!data || data.length === 0) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬫暟鎹紒', + duration: 5 + }) + this.updateStatus('over') + return + } + + let result = Utils.getExcelInSql(btn, data, this.state.dict) + if (result.errors) { + notification.warning({ + top: 92, + message: result.errors, + duration: 5 + }) + this.updateStatus('over') + return + } + + let param = { + ID: this.state.primaryId + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + result.sql = result.sql.replace(/\$@/ig, '/*') + result.sql = result.sql.replace(/@\$/ig, '*/') + } else { + result.sql = result.sql.replace(/@\$|\$@/ig, '') + } + + param.LText = Utils.formatOptions(result.sql) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + if (btn.intertype === 'inner' && !btn.innerFunc) { // 绯荤粺瀛樺偍杩囩▼ + param.func = 'sPC_TableData_InUpDe' + + Api.genericInterface(param).then((res) => { + if (res.status) { + this.execSuccess(res) + } else { + this.execError(res) + } + }, () => { + this.execError({}) + }) + } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋� + param.func = btn.innerFunc + + Api.genericInterface(param).then((res) => { + if (res.status) { + this.execSuccess(res) + } else { + this.execError(res) + } + }, () => { + this.execError({}) + }) + } else if (btn.intertype === 'outer') { // 澶栭儴鎺ュ彛 + let _outParam = null + + new Promise(resolve => { + // 鍐呴儴璇锋眰 + if (btn.innerFunc) { + param.func = btn.innerFunc + // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� + Api.genericInterface(param).then(res => { + if (res.status) { + delete res.ErrCode + delete res.ErrMesg + delete res.message + delete res.status + + // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 + let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID + if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { + res.BID = this.props.BID + } + resolve(res) + } else { + this.execError(res) + resolve(false) + } + }, () => { + this.execError({}) + }) + } else { + resolve(param) + } + }).then(res => { + if (!res) return + // 澶栭儴璇锋眰 + _outParam = JSON.parse(JSON.stringify(res)) + + if (this.props.menuType === 'HS') { + if (btn.sysInterface === 'true' && options.cloudServiceApi) { + param.rduri = options.cloudServiceApi + } else if (btn.sysInterface !== 'true') { + param.rduri = btn.interface + } + } else { + if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } else if (btn.sysInterface !== 'true') { + param.rduri = btn.interface + } + } + + if (btn.outerFunc) { + res.func = btn.outerFunc + } + + return Api.genericInterface(res) + }).then(response => { + if (!response) return + // 鍥炶皟璇锋眰 + if (btn.callbackFunc) { + // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 + delete response.message + delete response.status + + response.func = btn.callbackFunc + + let _callbackparam = {..._outParam, ...response} + return Api.genericInterface(_callbackparam) + } else { + if (response.status) { + this.execSuccess(response) + } else { + this.execError(response) + } + } + }).then(res => { + if (!res) return + + if (res.status) { + this.execSuccess(res) + } else { + this.execError(res) + } + }) + } + } + + render() { + const { btn } = this.props + const { loading } = this.state + + return ( + <div className="mk-btn-wrap"> + <Button + className={'mk-btn mk-' + btn.class} + icon={btn.icon} + onClick={() => {this.actionTrigger()}} + loading={loading} + >{btn.label}</Button> + <ExcelIn MenuID={this.props.MenuID} btn={btn} returndata={this.getexceldata} ref="excelIn" /> + </div> + ) + } +} + +const mapStateToProps = (state) => { + return { + menuType: state.editLevel, + dataManager: state.dataManager + } +} + +const mapDispatchToProps = () => { + return {} +} + +export default connect(mapStateToProps, mapDispatchToProps)(ExcelInButton) \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.scss b/src/tabviews/zshare/actionList/excelInbutton/index.scss new file mode 100644 index 0000000..fe21ce9 --- /dev/null +++ b/src/tabviews/zshare/actionList/excelInbutton/index.scss @@ -0,0 +1,3 @@ +.mk-btn-wrap { + display: inline-block; +} diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx new file mode 100644 index 0000000..0a6adf7 --- /dev/null +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -0,0 +1,691 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import moment from 'moment' +import {connect} from 'react-redux' +import { is, fromJS } from 'immutable' +import { Button, Modal, notification, message } from 'antd' +import * as XLSX from 'xlsx' + +import Utils from '@/utils/utils.js' +import options from '@/store/options.js' +import Api from '@/api' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import './index.scss' + +class ExcelOutButton extends Component { + static propTpyes = { + BID: PropTypes.string, // 涓昏〃ID + BData: PropTypes.any, // 涓昏〃鏁版嵁 + Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� + MenuID: PropTypes.string, // 鑿滃崟ID + btn: PropTypes.object, // 鎸夐挳 + columns: PropTypes.array, // 瀛楁鍒� + setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� + updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� + getexceloutparam: PropTypes.func, // 鑾峰彇琛ㄦ牸涓弬鏁� + triggerBtn: PropTypes.any, + } + + state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + excelName: '', + loading: false + } + + /** + * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { + this.actionTrigger() + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 鎸夐挳鐘舵�佹敼鍙� + */ + updateStatus = (type, name) => { + if (type === 'start') { + this.setState({ + loading: true, + excelName: name + }) + this.props.updateStatus('start') + } else if (type === 'over') { + this.setState({ + loading: false + }) + this.props.updateStatus('over') + } + } + + /** + * @description 瑙﹀彂鎸夐挳鎿嶄綔 + */ + actionTrigger = () => { + const { setting, Tab, BID, btn } = this.props + + if (Tab && Tab.supMenu && !BID) { + notification.warning({ + top: 92, + message: '闇�瑕佷笂绾т富閿�硷紒', + duration: 5 + }) + return + } + + if ( + btn.intertype === 'inner' && !btn.innerFunc && + ((setting.interType === 'inner' && setting.innerFunc) || setting.interType === 'outer') + ) { + notification.warning({ + top: 92, + message: '瀵煎嚭鎸夐挳閰嶇疆閿欒锛�', + duration: 5 + }) + return + } + + this.triggerExcelout() + } + + /** + * @description Excel 瀵煎嚭 + */ + triggerExcelout = () => { + const { btn } = this.props + let viewParam = this.props.getexceloutparam() + let name = `${viewParam.menuName}${moment().format('YYYYMMDDHHmmss')}.xlsx` + let pageSize = 1000 + + if (btn.search === 'true' && viewParam.search && viewParam.search.length > 0) { + let valid = false + viewParam.search.forEach(item => { + if (Array.isArray(item.value) && item.value.length > 0) { + valid = true + } else if (item.value || item.value === 0) { + valid = true + } + }) + + if (!valid) { + notification.warning({ + top: 92, + message: '鎼滅储鏉′欢涓嶅彲涓虹┖锛�', + duration: 5 + }) + return + } + } + + if (btn.intertype === 'inner' && !btn.innerFunc && !viewParam.arr_field) { // 浣跨敤绯荤粺鍑芥暟 + notification.warning({ + top: 92, + message: '鏈缃樉绀哄垪锛�', + duration: 5 + }) + return + } + + this.updateStatus('start', name) + + if (btn.pagination !== 'true') { + if (btn.intertype === 'inner' && !btn.innerFunc) { // 浣跨敤绯荤粺鍑芥暟 + let param = this.getExcelDefaultParam(viewParam.arr_field, viewParam.orderBy, viewParam.search) + + Api.genericInterface(param).then(result => { + if (result.status) { + this.exportExcel(result.data) + } else { + this.execError(result) + } + }, () => { + this.execError({}) + }) + } else if (btn.intertype === 'inner' && btn.innerFunc) { // 浣跨敤鍐呴儴鍑芥暟 + let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) + param.func = btn.innerFunc + + Api.genericInterface(param).then(result => { + if (result.status) { + this.exportExcel(result.data) + } else { + this.execError(result) + } + }, () => { + this.execError({}) + }) + } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟 + let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) + + if (this.props.menuType === 'HS') { + if (btn.sysInterface === 'true' && options.cloudServiceApi) { + param.rduri = options.cloudServiceApi + } else if (btn.sysInterface !== 'true') { + param.rduri = btn.interface + } + } else { + if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } else if (btn.sysInterface !== 'true') { + param.rduri = btn.interface + } + } + + if (btn.outerFunc) { + param.func = btn.outerFunc + } + + Api.genericInterface(param).then(result => { + if (result.status) { + this.exportExcel(result.data) + } else { + this.execError(result) + } + }, () => { + this.execError({}) + }) + } else if (btn.intertype === 'outer' && btn.innerFunc) { + let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) + param.func = btn.innerFunc + + Api.genericInterface(param).then(res => { + if (res.status) { + delete res.ErrCode + delete res.ErrMesg + delete res.message + delete res.status + + if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { + res.rduri = window.GLOB.mainSystemApi + } else if (btn.sysInterface !== 'true') { + res.rduri = btn.interface + } + + if (btn.outerFunc) { + res.func = btn.outerFunc + } + + Api.genericInterface(res).then(result => { + if (result.status) { + this.exportExcel(result.data) + } else { + this.execError(result) + } + }) + } else { + this.execError(res) + } + }, () => { + this.execError({}) + }) + } else { + notification.warning({ + top: 92, + message: '瀵煎嚭鎸夐挳璁剧疆閿欒锛�', + duration: 5 + }) + this.updateStatus('over') + } + } else if (btn.intertype === 'outer' && btn.innerFunc) { // 鍒嗛〉锛屼笖涓ゆ璇锋眰 + this.getExcelOutDoubleData(viewParam, 1, pageSize, []) + } else { // 鍒嗛〉锛屼竴姝ヨ姹� + this.getExcelOutData(viewParam, 1, pageSize, []) + } + } + + /** + * @description 涓ゆ鍒嗛〉璇锋眰 + */ + getExcelOutDoubleData = (viewParam, pageIndex, pageSize, data) => { + const { btn } = this.props + let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) + param.func = btn.innerFunc + + Api.genericInterface(param).then(res => { + if (res.status) { + delete res.ErrCode + delete res.ErrMesg + delete res.message + delete res.status + + if (this.props.menuType === 'HS') { + if (btn.sysInterface === 'true' && options.cloudServiceApi) { + param.rduri = options.cloudServiceApi + } else if (btn.sysInterface !== 'true') { + param.rduri = btn.interface + } + } else { + if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } else if (btn.sysInterface !== 'true') { + param.rduri = btn.interface + } + } + + if (btn.outerFunc) { + res.func = btn.outerFunc + } + + Api.genericInterface(res).then(result => { + if (result.status) { + if (!result.data) { + this.execError({ErrCode: 'N', message: '鏈幏鍙栧埌鏁版嵁淇℃伅锛�'}) + } else if (result.data.length >= pageSize) { + data = data.concat(result.data) + pageIndex++ + this.getExcelOutDoubleData(viewParam, pageIndex, pageSize, data) + } else { + data = data.concat(result.data) + this.exportExcel(data) + } + } else { + this.execError(result) + } + }, () => { + this.execError({}) + }) + } else { + this.execError(res) + } + }, () => { + this.execError({}) + }) + } + + /** + * @description 涓�姝ュ垎椤佃姹� + */ + getExcelOutData = (viewParam, pageIndex, pageSize, data) => { + const { btn } = this.props + let param = null + if (btn.intertype === 'inner' && !btn.innerFunc) { // 浣跨敤绯荤粺鍑芥暟 + if (!viewParam.arr_field) { + this.execError({ErrCode: 'N', message: '鏈缃樉绀哄垪锛�'}) + return + } + + 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 + + } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟 + param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) + + if (this.props.menuType === 'HS') { + if (btn.sysInterface === 'true' && options.cloudServiceApi) { + param.rduri = options.cloudServiceApi + } else if (btn.sysInterface !== 'true') { + param.rduri = btn.interface + } + } else { + if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } else if (btn.sysInterface !== 'true') { + param.rduri = btn.interface + } + } + + if (btn.outerFunc) { + param.func = btn.outerFunc + } + } + + Api.genericInterface(param).then(result => { + if (result.status) { + if (!result.data) { + this.execError({ErrCode: 'N', message: '鏈幏鍙栧埌鏁版嵁淇℃伅锛�'}) + } else if (result.data.length >= pageSize) { + data = data.concat(result.data) + pageIndex++ + this.getExcelOutData(viewParam, pageIndex, pageSize, data) + } else { + data = data.concat(result.data) + this.exportExcel(data) + } + } else { + this.execError(result) + } + }, () => { + this.execError({}) + }) + } + + /** + * @description Excel 鐢熸垚 + */ + exportExcel = (data) => { + const { columns, btn } = this.props + if (data && data.length > 0) { + try { + let _header = [] + let _topRow = {} + let colwidth = [] + + let hidecolumns = [] + + let verifyColumn = {} // 璁板綍楠岃瘉淇℃伅涓殑Excel鍒楅厤缃� + if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) { + btn.verify.columns.forEach(col => { + verifyColumn[col.Column] = col + }) + } + + columns.forEach(col => { + if (col.Hide === 'true') { + hidecolumns.push(col.field) + return + } + if (!data[0].hasOwnProperty(col.field)) return + if (_topRow[col.field]) return + + if (verifyColumn[col.field]) { // 浼樺厛浣跨敤楠岃瘉淇℃伅涓殑鍒楄缃� + _header.push(col.field) + _topRow[col.field] = verifyColumn[col.field].Text + + colwidth.push({width: verifyColumn[col.field].Width}) + } else { + _header.push(col.field) + _topRow[col.field] = col.label + + let _colwidth = Math.floor(col.Width / 6) + + if (!_colwidth || _colwidth < 5) { + _colwidth = 5 + } + + colwidth.push({width: _colwidth}) + } + }) + + if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) { + btn.verify.columns.forEach(col => { + if (hidecolumns.includes(col.Column)) return + if (!data[0].hasOwnProperty(col.Column)) return + if (_topRow[col.Column]) return + + _header.push(col.Column) + _topRow[col.Column] = col.Text + + colwidth.push({width: col.Width}) + }) + } + + Object.keys(data[0]).forEach(key => { + if (hidecolumns.includes(key)) return + if (_topRow[key]) return + + _header.push(key) + _topRow[key] = key + + colwidth.push({width: 12}) + }) + + let table = [] + + table.push(_topRow) + + data.forEach(item => { + let _row = {} + _header.forEach(field => { + _row[field] = item[field] + }) + + table.push(_row) + }) + + const ws = XLSX.utils.json_to_sheet(table, {header: _header, skipHeader: true}) + + ws['!cols'] = colwidth + + const wb = XLSX.utils.book_new() + XLSX.utils.book_append_sheet(wb, ws, 'Sheet1') + + XLSX.writeFile(wb, this.state.excelName) + + this.execSuccess({ErrCode: 'S', ErrMesg: '瀵煎嚭鎴愬姛锛�'}) + } catch { + this.execError({ErrCode: 'N', message: 'Excel鐢熸垚澶辫触锛�'}) + } + } else { + this.execError({ErrCode: 'N', message: '鏈煡璇㈠埌瀵煎嚭鏁版嵁锛�'}) + } + } + + /** + * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� + */ + getExcelCustomParam = (orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { + let _search = Utils.formatCustomMainSearch(search) + + let param = { + OrderCol: orderBy, + ..._search + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + if (pagination) { + param.PageIndex = pageIndex + param.PageSize = pageSize + } + + return param + } + + /** + * @description 鑾峰彇榛樿瀛樺偍杩囩▼璇锋眰鍙傛暟 + */ + getExcelDefaultParam = (arr_field, orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { + const { setting } = this.props + + let _search = Utils.joinMainSearchkey(search) + + _search = _search ? 'where ' + _search : '' + + let param = { + func: 'sPC_Get_TableData', + obj_name: 'data', + arr_field: arr_field, + custom_script: setting.customScript || '', + default_sql: setting.default || 'true', + dataM: this.props.dataManager ? 'Y' : '' + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + let _dataresource = setting.dataresource + + if (/\s/.test(_dataresource)) { + _dataresource = '(' + _dataresource + ') tb' + } + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + _dataresource = _dataresource.replace(/\$@/ig, '/*') + _dataresource = _dataresource.replace(/@\$/ig, '*/') + param.custom_script = param.custom_script.replace(/\$@/ig, '/*') + param.custom_script = param.custom_script.replace(/@\$/ig, '*/') + } else { + _dataresource = _dataresource.replace(/@\$|\$@/ig, '') + param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '') + } + + let regoptions = null + if (setting.queryType === 'statistics' || param.custom_script) { + let allSearch = Utils.getAllSearchOptions(search) + + regoptions = allSearch.map(item => { + return { + reg: new RegExp('@' + item.key + '@', 'ig'), + value: `'${item.value}'` + } + }) + + regoptions.push({ + reg: new RegExp('@orderBy@', 'ig'), + value: orderBy + }, { + reg: new RegExp('@pageSize@', 'ig'), + value: pageSize + }, { + reg: new RegExp('@pageIndex@', 'ig'), + value: pageIndex + }) + } + + if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 + regoptions.forEach(item => { + _dataresource = _dataresource.replace(item.reg, item.value) + }) + _search = '' + } + + let LText = '' + + if (setting.default !== 'false' && !pagination) { + LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` + } else if (setting.default !== 'false') { + LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` + } + + if (param.custom_script) { + regoptions.forEach(item => { + param.custom_script = param.custom_script.replace(item.reg, item.value) + }) + + if (LText) { + LText += ` + aaa: + if @ErrorCode!='' + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + ` + } else { + param.custom_script += ` + aaa: + if @ErrorCode!='' + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + ` + } + + param.custom_script = Utils.formatOptions(param.custom_script) + } + + param.LText = Utils.formatOptions(LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.DateCount = '' + + return param + } + + /** + * @description 鎿嶄綔鎴愬姛鍚庡鐞� + * 1銆乪xcel瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� + * 2銆佺姸鎬佺爜涓� S 鏃讹紝鏄剧ず鎴愬姛淇℃伅鍚庣郴缁熼粯璁や俊鎭� + * 3銆佺姸鎬佺爜涓� -1 鏃讹紝涓嶆樉绀轰换浣曚俊鎭� + * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� + * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� + */ + execSuccess = (res) => { + const { btn } = this.props + + if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 + notification.success({ + top: 92, + message: res.ErrMesg || this.state.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.state.dict['main.action.confirm.success'] + }) + } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず + + } + + this.setState({ + loading: false + }) + + this.props.updateStatus('refresh', btn.execSuccess) + } + + /** + * @description 鎿嶄綔澶辫触鍚庡鐞� + * 1銆佺姸鎬佺爜涓� E銆丯銆丗銆丯M 鏃讹紝鏄剧ず鐩稿簲鎻愮ず淇℃伅 + * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� + * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂� + */ + execError = (res) => { + const { btn } = this.props + + 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 : 10 + }) + } 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 : 10 + }) + } else if (res.ErrCode === 'NM') { + message.error(res.message || res.ErrMesg) + } + + this.setState({ + loading: false + }) + + this.props.updateStatus('refresh', btn.execError) + } + + render() { + const { btn } = this.props + const { loading } = this.state + + return ( + <div className="mk-btn-wrap"> + <Button + className={'mk-btn mk-' + btn.class} + icon={btn.icon} + onClick={() => {this.actionTrigger()}} + loading={loading} + >{btn.label}</Button> + </div> + ) + } +} + +const mapStateToProps = (state) => { + return { + menuType: state.editLevel, + dataManager: state.dataManager + } +} + +const mapDispatchToProps = () => { + return {} +} + +export default connect(mapStateToProps, mapDispatchToProps)(ExcelOutButton) \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.scss b/src/tabviews/zshare/actionList/exceloutbutton/index.scss new file mode 100644 index 0000000..fe21ce9 --- /dev/null +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.scss @@ -0,0 +1,3 @@ +.mk-btn-wrap { + display: inline-block; +} diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 3db42cd..4fd5296 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -1,52 +1,43 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import moment from 'moment' -import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { Button, Affix, Modal, notification, Spin, message } from 'antd' -import * as XLSX from 'xlsx' -import ExcelIn from './excelin' -import asyncSpinComponent from '@/utils/asyncSpinComponent' -import Utils from '@/utils/utils.js' -import options from '@/store/options.js' -import Api from '@/api' +import { Affix } from 'antd' + +import asyncComponent from './asyncButtonComponent' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' import './index.scss' -const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) -const { confirm } = Modal -let socket = null +const NormalButton = asyncComponent(() => import('./normalbutton')) +const ExcelInButton = asyncComponent(() => import('./excelInbutton')) +const ExcelOutButton = asyncComponent(() => import('./exceloutbutton')) +const PopupButton = asyncComponent(() => import('./popupbutton')) +const TabButton = asyncComponent(() => import('./tabbutton')) +const NewPageButton = asyncComponent(() => import('./newpagebutton')) +const ChangeUserButton = asyncComponent(() => import('./changeuserbutton')) +const PrintButton = asyncComponent(() => import('./printbutton')) -class MainAction extends Component { +class ActionList extends Component { static propTpyes = { - menuType: PropTypes.any, // 鑿滃崟绫诲瀷锛屾櫘閫氳彍鍗曟垨HS - BID: PropTypes.string, // 涓昏〃ID + BID: PropTypes.any, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 + selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� - type: PropTypes.string, // 鍒ゆ柇褰撳墠涓轰富琛紙main锛夈�佸瓙琛紙sub锛夈�佸瓙琛ㄦ爣绛撅紙subtab锛� MenuID: PropTypes.string, // 鑿滃崟ID actions: PropTypes.array, // 鎸夐挳缁� + operations: PropTypes.array, // 琛ㄦ牸涓寜閽粍 logcolumns: PropTypes.array, // 鏄剧ず鍒� - dict: PropTypes.object, // 瀛楀吀椤� setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� refreshdata: PropTypes.func, // 鎵ц瀹屾垚鍚庢暟鎹埛鏂� - triggerPopview: PropTypes.func, // 寮圭獥鏍囩椤佃Е鍙� getexceloutparam: PropTypes.func, // 鑾峰彇excel瀵煎嚭鏁版嵁 - gettableselected: PropTypes.func, // 鑾峰彇琛ㄦ牸涓暟鎹� - triggerBtn: PropTypes.any, + triggerBtn: PropTypes.any, // 蹇嵎閿Е鍙戠殑鎸夐挳 } state = { - visible: false, - formdata: null, - tabledata: null, - confirmLoading: false, - execAction: null, - loadingUuid: '', - btnloading: false, - configMap: {}, + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, running: false, - loadingNumber: '' + triggerBtn: null } /** @@ -54,2684 +45,174 @@ */ UNSAFE_componentWillReceiveProps(nextProps) { if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.parentId === this.props.MenuID) { - if (!this.state.loadingUuid && !this.state.visible && !this.state.running) { - let _btn = nextProps.triggerBtn.button - if (!_btn.OpenType) { - _btn = this.props.actions.filter(item => item.uuid === _btn.uuid)[0] - } - if (_btn) { - this.actionTrigger(_btn, nextProps.triggerBtn.data) - } - } - } - } - - refreshdata = (item, type) => { - this.props.refreshdata(item, type) - } - - /** - * @description 瑙﹀彂鎸夐挳鎿嶄綔 - */ - actionTrigger = (item, record) => { - const { setting, type, Tab, BID } = this.props - - if (this.state.loadingUuid || this.state.visible || this.state.running) { - notification.warning({ - top: 92, - message: '浠诲姟鎵ц涓紝璇风◢鍚庯紒', - duration: 5 - }) - return - } - - if (type === 'sub' && Tab && Tab.supMenu && !BID) { - notification.warning({ - top: 92, - message: '闇�瑕佷笂绾т富閿�硷紒', - duration: 5 - }) - return - } - - let _this = this - let data = this.props.gettableselected() || [] - - if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� - data = [record] - } - - if (item.Ot !== 'notRequired' && data.length === 0) { - // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� - notification.warning({ - top: 92, - message: this.props.dict['main.action.confirm.selectline'], - duration: 5 - }) - return - } else if (item.Ot === 'requiredSgl' && data.length !== 1) { - // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 - notification.warning({ - top: 92, - message: this.props.dict['main.action.confirm.selectSingleLine'], - duration: 5 - }) - return - } else if (item.Ot !== 'notRequired' && !setting.primaryKey) { - // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� - notification.warning({ - top: 92, - message: '鏈缃富閿紒', - duration: 5 - }) - return - } - - if (item.OpenType === 'prompt') { - this.setState({ - running: true - }) - confirm({ - title: this.props.dict['main.action.confirm.tip'], - onOk() { - _this.setState({ - loadingUuid: item.uuid - }) - - return new Promise(resolve => { - _this.execSubmit(item, data, resolve) - }) - }, - onCancel() { - _this.setState({ - running: false - }) - } - }) - } else if (item.OpenType === 'exec') { - this.setState({loadingUuid: item.uuid}) - this.execSubmit(item, data, () => { - this.setState({loadingUuid: ''}) - }) - } else if (item.OpenType === 'pop') { - this.setState({ - execAction: item, - tabledata: data, - btnloading: true - }, () => { - this.improveAction(item) - }) - } else if (item.OpenType === 'excelOut') { - if ( - item.intertype === 'inner' && !item.innerFunc && - ((setting.interType === 'inner' && setting.innerFunc) || setting.interType === 'outer') - ) { - notification.warning({ - top: 92, - message: '瀵煎嚭鎸夐挳閰嶇疆閿欒锛�', - duration: 5 - }) - return - } - - this.triggerExcelout(item) - - } else if (item.OpenType === 'excelIn') { - if (item.verify && item.verify.sheet && item.verify.columns && item.verify.columns.length > 0) { - let primaryId = '' // 瀵煎叆鏃惰Id - if (item.Ot === 'requiredSgl') { - primaryId = data[0][setting.primaryKey] || '' - } - - this.refs.excelIn.exceltrigger(item, primaryId) - } else { - notification.warning({ - top: 92, - message: 'excel瀵煎叆楠岃瘉淇℃伅鏈缃紒', - duration: 5 - }) - } - } else if (item.OpenType === 'popview' && this.props.type !== 'subtab') { - // 寮圭獥鏍囩璁剧疆涓轰笉閫夊垯琛屾椂锛屼笉浼犻�掓暟鎹� - this.props.triggerPopview(item, item.Ot === 'notRequired' ? [] : data) - } else if (item.OpenType === 'popview' && this.props.type === 'subtab') { - notification.warning({ - top: 92, - message: '寮圭獥椤甸潰涓嶆敮鎸佹璁剧疆锛�', - duration: 5 - }) - } else if (item.OpenType === 'innerpage') { - let Id = data[0][setting.primaryKey] - - if (item.pageTemplate === 'print') { - let cloudmsg = '&cuid=' + (sessionStorage.getItem('CloudUserID') || '') + '&csid=' + (sessionStorage.getItem('CloudSessionUid') || '') + '&clid=' + (sessionStorage.getItem('CloudLoginUID') || '') + '&cun=' + (sessionStorage.getItem('CloudUserName') || '') - let msg = '&uid=' + sessionStorage.getItem('UserID') + '&sid=' + sessionStorage.getItem('SessionUid') + '&lid=' + sessionStorage.getItem('LoginUID') + '&un=' + sessionStorage.getItem('User_Name') - let src = '#/print/' + window.btoa('ID=' + Id + msg + cloudmsg) - window.open(src) - } else { - notification.warning({ - top: 92, - message: '椤甸潰绫诲瀷璁剧疆閿欒锛�', - duration: 5 - }) - } - } else if (item.OpenType === 'outerpage') { - let url = item.url - if (item.Ot === 'requiredSgl' && setting.primaryKey) { - url = url + '?ID=' + data[0][setting.primaryKey] - } else if (item.Ot !== 'notRequired' && !setting.primaryKey) { - let ids = data.map(_data => _data[setting.primaryKey]).join(',') - url = url + '?ID=' + ids - } - window.open(url) - } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { - this.props.triggerPopview(item, data) - } else if (item.OpenType === 'funcbutton') { - if (item.funcType === 'changeuser') { - this.changeUser(item, data) - } else if (item.funcType === 'print') { - if (item.execMode === 'pop') { - this.setState({ - execAction: item, - tabledata: data, - btnloading: true - }, () => { - this.improveAction(item) - }) - } else if (item.execMode === 'prompt') { - this.setState({ - running: true - }) - confirm({ - title: this.props.dict['main.action.confirm.tip'], - onOk() { - _this.triggerPrint(item, data) - }, - onCancel() { - _this.setState({ - running: false - }) - } - }) - } else { - this.triggerPrint(item, data) - } - } - } else { - notification.warning({ - top: 92, - message: '瀹屽杽涓�傘�傘��', - duration: 5 - }) - } - } - - /** - * @description 瑙﹀彂鎵撳嵃 - */ - triggerPrint = (btn, data, formlist = []) => { - let formdata = {} - formlist.forEach(_data => { - formdata[_data.key] = _data.value - }) - - if ( - !btn.verify || - (btn.verify.printMode === 'normal' && (!btn.verify.Template || !btn.verify.linkUrl)) || - (btn.verify.printMode === 'custom' && (!btn.verify.printFunc || !btn.verify.linkUrl)) - ) { - notification.warning({ - top: 92, - message: '璇峰畬鍠勬墦鍗伴獙璇佷俊鎭紒', - duration: 5 - }) - return - } - - let printlist = [] - let templates = [] - let printCount = 1 - - if (formdata.printCount && typeof(formdata.printCount) === 'number' && formdata.printCount >= 1) { - printCount = formdata.printCount - } - - this.setState({loadingUuid: btn.uuid}) - - new Promise(resolve => { - if (btn.intertype === 'inner' && !btn.innerFunc) { - let printcell = {} - - printcell.printType = formdata.printType || '' - printcell.printCount = printCount - printcell.templateID = btn.verify.Template || '' - - if (btn.Ot === 'notRequired') { - printcell.data = [formdata] - } else { - printcell.data = data.map(cell => { - return {...cell, ...formdata} - }) - } - - templates.push(printcell.templateID) - - printlist.push(printcell) - - resolve(true) - } else { - this.getprintdata(btn, data, formdata, formlist).then(result => { - if (result.next) { - printlist = result.list.map(cell => { - cell.templateID = cell.templateID || btn.verify.Template - cell.printType = cell.printType || formdata.printType || '' - - let _printCount = printCount - if (cell.printCount && typeof(cell.printCount) === 'number' && cell.printCount >= 1) { - _printCount = cell.printCount - } - - cell.printCount = _printCount - - templates.push(cell.templateID) - - return cell - }) - } - - resolve(result.next) - }) - } - }).then(res => { - // 鑾峰彇鎵撳嵃妯℃澘 getTemp - if (!res) return false - - if (btn.verify.printMode === 'custom') { - this.execCustomPrint(btn, printlist, formdata) - - return false - } - - templates = Array.from(new Set(templates)) // 鍘婚噸 - - let deffers = templates.map(tempId => { - return new Promise(resolve => { - let param = { - func: 's_PrintTemplateMGetData', - Type: 'Y', - // ID: tempId, // 娣诲姞妯℃澘鏃讹紝淇濆瓨鍙婃煡璇娇鐢ㄦā鏉垮弬鏁� - PrintTempNO: tempId - } - - if (window.GLOB.mainSystemApi) { // 浠庡崟鐐圭櫥褰曟湇鍔″櫒鍙栨墦鍗伴厤缃俊鎭� - param.rduri = window.GLOB.mainSystemApi - } - - Api.getLocalConfig(param).then(result => { - result.tempId = tempId - resolve(result) - }) - }) - }) - - return Promise.all(deffers) - }).then(result => { - if (!result) return - - let errorMsg = '' - let _temps = {} - - result.forEach(res => { - if (res.status && !errorMsg) { - let _temp = this.getPrintConfigParam(res) - - if (_temp.error) { - errorMsg = { - ErrCode: 'N', - message: _temp.error, - ErrMesg: _temp.error, - status: false - } - } else { - _temps[res.tempId] = _temp - } - } else if (!errorMsg) { - errorMsg = res - } - }) - - if (!errorMsg) { - this.execPrint(btn, printlist, _temps, formdata) - } else { - this.execError(errorMsg, btn) - } - }) - } - - execCustomPrint = (item, printlist, formdata) => { - this.setState({loadingUuid: ''}) - this.execSuccess(item, { - ErrCode: '-1', - message: '', - ErrMesg: '', - status: true - }) - - try { - // eslint-disable-next-line - let func = new Function('data', 'form', 'printer', 'notification', item.verify.printFunc) - func(printlist, formdata, item.verify, notification) - } catch (e) { - console.warn(e) - - try { - // eslint-disable-next-line - let evalfunc = eval('(true && function (data, form, printer, notification) {' + item.verify.printFunc + '})') - evalfunc(printlist, formdata, item.verify, notification) - } catch (error) { - console.warn(error) - notification.warning({ - top: 92, - message: '鑷畾涔夊嚱鏁版墽琛岄敊璇紒', - duration: 5 - }) - } - } - } - - /** - * @description 鑾峰彇鎵撳嵃鏁版嵁 - */ - getprintdata = (btn, data, formdata, formlist) => { - const { setting } = this.props - - let _list = [] - return new Promise(resolve => { - let params = [] - let param = {} - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (btn.Ot === 'notRequired') { - let _param = { ...param, ...formdata } - params.push(_param) - } else if (btn.Ot === 'requiredSgl') { - param[setting.primaryKey] = data[0][setting.primaryKey] - - let _param = { ...param, ...formdata } - - params.push(_param) - } else if (btn.Ot === 'requiredOnce') { - let ids = data.map(d => { return d[setting.primaryKey]}) - ids = ids.filter(Boolean) - ids = ids.join(',') - - param[setting.primaryKey] = ids - - let _param = { ...param, ...formdata } - - params.push(_param) - } else if (btn.Ot === 'required') { - params = data.map((cell, index) => { - let _param = { ...param } - _param[setting.primaryKey] = cell[setting.primaryKey] - - formlist.forEach(_data => { - if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) { - _param[_data.key] = cell[_data.key] - } else { - _param[_data.key] = _data.value - } - }) - return _param - }) - } - - if (btn.intertype === 'inner') { - params = params.map(_param => { - _param.func = btn.innerFunc - - return _param - }) - - if (params.length <= 20) { - let deffers = params.map(par => { - return new Promise(resolve => { - Api.genericInterface(par).then(res => { - resolve(res) - }) - }) - }) - Promise.all(deffers).then(result => { - let errorMsg = '' - result.forEach(res => { - if (!res.status) { - errorMsg = res - } - }) - if (!errorMsg) { - resolve({next: true, list: result}) - } else { - this.execError(errorMsg, btn) - resolve({next: false, list: []}) - } - }) - } else { - this.printInnerLoopRequest(params, btn, _list, resolve) - } - } else { - this.printOuterLoopRequest(params, btn, _list, resolve) - } - }) - } - - /** - * @description 澶栭儴璇锋眰寰幆鎵ц - */ - printOuterLoopRequest = (params, btn, _list, _resolve) => { - let param = params.shift() - let _outParam = null - - new Promise(resolve => { - // 鍐呴儴璇锋眰 - if (btn.innerFunc) { - param.func = btn.innerFunc - // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 - let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID - if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { - res.BID = this.props.BID - } - - resolve(res) - } else { - this.execError(res, btn) - resolve(false) - _resolve({next: false, list: []}) - } - }) - } else { - resolve(param) - } - }).then(res => { - if (!res) return - // 澶栭儴璇锋眰 - _outParam = JSON.parse(JSON.stringify(res)) - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - res.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - res.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - return Api.genericInterface(res) - }).then(response => { - if (!response) return - - if (btn.callbackFunc) { - // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 - delete response.message - delete response.status - - response.func = btn.callbackFunc - - let _callbackparam = {..._outParam, ...response} - - return Api.genericInterface(_callbackparam) - } else if (response.status) { - - _list.push(response) - - // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹� - if (params.length === 0) { - _resolve({next: true, list: _list}) - } else { - this.printOuterLoopRequest(params, btn, _list, _resolve) - } - } else { - this.execError(response, btn) - _resolve({next: false, list: []}) - } - }).then(response => { - if (!response) return - - if (response.status) { - _list.push(response) - - // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹� - if (params.length === 0) { - _resolve({next: true, list: _list}) - } else { - this.printOuterLoopRequest(params, btn, _list, _resolve) - } - } else { - this.execError(response, btn) - _resolve({next: false, list: []}) - } - }) - } - - /** - * @description 鍐呴儴璇锋眰寰幆鎵ц - */ - printInnerLoopRequest = (params, btn, _list, _resolve) => { - let param = params.shift() - - Api.genericInterface(param).then(res => { - if (res.status) { - _list.push(res) - - if (params.length === 0) { - _resolve({next: true, list: _list}) - } else { - this.printInnerLoopRequest(params, btn, _list, _resolve) - } - } else { - this.execError(res, btn) - _resolve({next: false, list: []}) - } - }) - } - - getPrintConfigParam = (res) => { - let error = '' // 閿欒淇℃伅 - let configParam = '' // 妯℃澘閰嶇疆淇℃伅 - let _configparam = '' // 鎵撳嵃閰嶇疆淇℃伅 - let fields = [] // 妯℃澘涓墍闇�瀛楁 - let nonEFields = [] // 闈炵┖瀛楁 - - if (!res.ConfigParam) { - error = '鏈幏鍙栧埌鎵撳嵃妯℃澘淇℃伅锛�' - } else { - try { - configParam = JSON.parse(window.decodeURIComponent(window.atob(res.ConfigParam))) - } catch (e) { - configParam = '' - } - - if (!configParam) { - error = '鎵撳嵃妯℃澘瑙f瀽閿欒锛�' - } else { - - let control = configParam.elements.map(element => { - let _field = element.field - - if (_field === 'other_field') { - _field = element.cusfield || '' - } - - let item = { - Name: element.name || '', - Type: element.type, - Value: element.value || '', - Field: _field, - Left: element.left, - Top: element.top, - Width: element.width, - Height: element.height, - Rotate: element.rotate, - BorderSize: element.borderSize / 10, - BorderColor: element.borderColor, - Align: element.align, - VerticalAlign: element.vertialAlign, - BackColor: element.background, - ForeColor: 'black' - } - - if (!item.Width || !item.Height) { - item.Type = 'line' - item.Value = '' - item.Field = '' - item.FontFamily = element.fontFamily || '' - item.FontSize = element.fontSize || '' - item.FontStyle = (!element.fontWeight || element.fontWeight === 'normal') ? 'regular' : element.fontWeight - item.Padding = 0 - item.Trimming = '' - } else if (item.Type === 'image') { - item.ImageWidth = element.imgWidth - item.ImageHeight = element.imgHeight - item.Trimming = '' - } else if (item.Type === 'text') { - item.FontFamily = element.fontFamily - item.FontSize = element.fontSize - item.FontStyle = element.fontWeight === 'normal' ? 'regular' : element.fontWeight - item.Padding = element.padding / 2 - item.Trimming = '' - } else if (item.Type === 'barcode') { - item.BarcodeType = element.barcodeType - item.BarcodeWidth = element.barcodeWidth - item.BarcodeHeight = element.barcodeHeight - item.BarcodeLabel = element.barcodeLabel - item.LabelSize = element.fontSize - } else if (item.Type === 'qrcode') { - item.Type = 'barcode' - item.BarcodeType = element.barcodeType - item.BarcodeWidth = element.qrcodeWidth - item.BarcodeHeight = element.qrcodeWidth - item.BarcodeLabel = false - } - - if (item.Field) { - fields.push(item.Field) - // 鏉$爜浜岀淮鐮佸瓧娈典笉鍙负绌� - if (item.Type === 'qrcode' || item.Type === 'barcode') { - nonEFields.push(item.Field) - } - } - - return item - }) - - _configparam = { - Version: '', - Title: configParam.name, - Author: sessionStorage.getItem('UserID'), - Description: configParam.remark, - PrintTempNO: configParam.PrintTempNO, - PageSetting: { - Width: configParam.width, - Height: configParam.height, - Left: '0', - Right: '0', - Top: '0', - Bottom: '0', - Landscape: false - }, - PageHeader: [], - ReportHeader: { - Control: control - }, - ReportFooter: [], - PageFooter: [] - } - } - } - - return { - error: error, - config: _configparam, - fields: fields, - nonEFields: nonEFields - } - } - - execPrint = (item, list, template, formdata) => { - let _errors = [] - - let defaultPrinter = item.verify.defaultPrinter || 'lackprinter' - let printers = {} - if (item.verify.printerTypeList && item.verify.printerTypeList.length > 0) { - item.verify.printerTypeList.forEach(cell => { - if (cell.printer) { - printers[cell.Value] = cell.printer - } - }) - } - - let printdata = {} - - list.forEach(res => { - let _printer = defaultPrinter - - if (res.printType && printers[res.printType]) { - _printer = printers[res.printType] - } - - printdata[_printer] = printdata[_printer] || [] - - printdata[_printer].push(res) - }) - - let printerList = [] - - Object.keys(printdata).forEach(printer => { - let _documents = [] - Object.keys(template).forEach(key => { - let _datalist = printdata[printer].filter(cell => cell.templateID === key) - - if (_datalist.length > 0) { - let _data = [] - _datalist.forEach(res => { - res.data.forEach(_cell => { - for (let i = 0; i < res.printCount; i++) { - _data.push({...formdata, ..._cell}) - } - }) - }) - - let _fields = Array.from(new Set(template[key].fields)) - let _nonEFields = Array.from(new Set(template[key].nonEFields)) - let lacks = [] - let emptys = [] - - _data.forEach(d => { - _fields.forEach(f => { - if (!d.hasOwnProperty(f)) { - lacks.push(f) - } else if (_nonEFields.includes(f) && !d[f] && d[f] !== 0) { - emptys.push(f) - } - }) - }) - - let _cell = { - documentID: Utils.getuuid(), - contents: [ - { - data: _data, - templateURL: JSON.stringify(template[key].config) - } - ] - } - - if (lacks.length > 0 || emptys.length > 0) { - lacks = Array.from(new Set(lacks)) - emptys = Array.from(new Set(emptys)) - - _errors.push({ - title: template[key].config.Title, - lacks: lacks, - emptys: emptys - }) - } - - _documents.push(_cell) - } - }) - - if (_documents.length > 0) { - printerList.push({ - cmd: 'print', - requestID: Utils.getuuid(), - version: Utils.getuuid(), - task: { - taskID: Utils.getuuid(), - preview: false, - printer: printer, - documents: _documents - } - }) - } - }) - - if (list.length === 0) { - this.setState({loadingUuid: ''}) - this.execError({ - ErrCode: 'N', - message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�', - ErrMesg: '', - status: false - }, item) - return - } else if (_errors.length > 0) { - let lackerror = [] - let emptyerror = [] - - _errors.forEach(err => { - if (err.lacks.length > 0) { - lackerror.push(`鏁版嵁涓湭鑾峰彇鍒版ā鏉匡紙${err.title}锛�${err.lacks.join('銆�')} 瀛楁`) - } - if (err.emptys.length > 0) { - emptyerror.push(`鏁版嵁涓ā鏉匡紙${err.title}锛� ${err.emptys.join('銆�')} 瀛楁涓嶅彲涓虹┖`) - } - }) - - let msg = [] - if (lackerror.length > 0) { - msg.push(lackerror.join(' ; ')) - } - - if (emptyerror.length > 0) { - msg.push(emptyerror.join(' ; ')) - } - - this.setState({loadingUuid: ''}) - this.execError({ - ErrCode: 'N', - message: msg.join(' ; ') + ' !', - ErrMesg: '', - status: false - }, item) - return - } - - let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] - - if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + item.verify.linkUrl) { - socket = new WebSocket('ws://' + item.verify.linkUrl) - } else { - if (lackItems) { - let request = { - requestID: '', - version: '', - cmd: 'getPrinters' - } - socket.send(JSON.stringify(request)) - } else { - printerList.forEach(cell => { - socket.send(JSON.stringify(cell)) - }) - - this.setState({loadingUuid: ''}) - this.execSuccess(item, { - ErrCode: 'S', - message: '', - ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true - }) - } - } - // 鎵撳紑Socket - socket.onopen = () =>{ - if (lackItems) { - let request = { - requestID: '', - version: '', - cmd: 'getPrinters' - } - socket.send(JSON.stringify(request)) - } else { - printerList.forEach(cell => { - socket.send(JSON.stringify(cell)) - }) - - this.setState({loadingUuid: ''}) - this.execSuccess(item, { - ErrCode: 'S', - message: '', - ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true - }) - } - } - // 鐩戝惉娑堟伅 - socket.onmessage = (event) => { - let data = '' - - if (event.data) { - try { - data = JSON.parse(event.data) - } catch { - this.setState({loadingUuid: ''}) - this.execError({ - ErrCode: 'N', - message: event.data, - ErrMesg: '', - status: false - }, item) - - data = '' - } - } - - if (data && data.cmd === 'getPrinters' && data.status) { - printerList.forEach(cell => { - if (cell.task.printer === 'lackprinter') { - cell.task.printer = data.defaultPrinter - } - socket.send(JSON.stringify(cell)) - }) - - this.setState({loadingUuid: ''}) - this.execSuccess(item, { - ErrCode: 'S', - message: '', - ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', - status: true - }) - } else if (data && data.message && !data.status) { - this.setState({loadingUuid: ''}) - this.execError({ - ErrCode: 'N', - message: data.message, - ErrMesg: '', - status: false - }, item) - } - } - - socket.onerror = () => { - this.setState({loadingUuid: ''}) - this.execError({ - ErrCode: 'N', - message: '鏃犳硶杩炴帴鍒�:' + item.verify.linkUrl, - ErrMesg: '', - status: false - }, item) - } - } - - /** - * @description 鍒囨崲鐢ㄦ埛 - */ - changeUser = (btn, data) => { - const { setting } = this.props - let _this = this - - let param = { - func: 'webapi_ChangeUser' - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } - - param[setting.primaryKey] = data[0][setting.primaryKey] - - this.setState({ - running: true - }) - confirm({ - title: this.props.dict['main.action.confirm.tip'], - onOk() { - return new Promise(resolve => { - Api.genericInterface(param).then(res => { - resolve() - if (res.status) { - sessionStorage.setItem('avatar', res.icon || '') - sessionStorage.setItem('UserID', res.UserID) - sessionStorage.setItem('SessionUid', Utils.getuuid()) - sessionStorage.setItem('LoginUID', res.LoginUID) - sessionStorage.setItem('User_Name', res.UserName) - sessionStorage.setItem('Full_Name', res.FullName) - - window.location.reload() - } else { - notification.error({ - top: 92, - message: res.message || res.ErrMesg, - duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10 - }) - } - }) - }) - }, - onCancel() { - _this.setState({ - running: false - }) - } - }) - } - - /** - * @description 鎸夐挳鎻愪氦鎵ц - */ - execSubmit = (btn, data, _resolve, formdata) => { - const { setting, logcolumns } = this.props - - if (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop') { - this.setState({ - confirmLoading: false, - visible: false - }) - this.triggerPrint(btn, data, formdata) - return - } - if (btn.intertype === 'inner') { - // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟鍜屾暟鎹簮涓嶅彲鍚屾椂涓虹┖, 浣跨敤绯荤粺鍑芥暟鏃讹紝绫诲瀷涓嶅彲涓虹┖ - if (!btn.innerFunc && (!btn.sql || (btn.sql && !btn.sqlType))) { - this.actionSettingError() - _resolve() - return - } - - // 鎵ц鏂瑰紡涓哄琛屾嫾鎺ワ紝涓旀墦寮�鏂瑰紡涓鸿〃鍗曟椂锛屼細杞负寰幆鍙戦�佽姹� - // 鎵撳紑鏂瑰紡涓烘ā鎬佹锛屼娇鐢ㄥ唴閮ㄥ嚱鏁版坊鍔�(鏈夋壒閲忔坊鍔犲満鏅紝宸插幓闄�) - if ( - btn.Ot === 'notRequired' || - btn.Ot === 'requiredSgl' || - btn.Ot === 'requiredOnce' - ) { - - // 鍒涘缓鍑瘉鏃讹紝闇�瑕侀�夋嫨琛屾椂 - if (data.length === 0 && !btn.innerFunc && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { - notification.warning({ - top: 92, - message: '浣跨敤鍒涘缓鍑瘉鍑芥暟锛岄渶瑕侀�夋嫨琛岋紒', - duration: 5 - }) - return - } - - let param = { // 绯荤粺瀛樺偍杩囩▼ - func: 'sPC_TableData_InUpDe' - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - let primaryId = '' - - if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { - let ids = data.map(d => { return d[setting.primaryKey] || ''}) - ids = ids.filter(Boolean) - primaryId = ids.join(',') - } - - if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� - if (btn.innerFunc) { // 浣跨敤鑷畾涔夊嚱鏁� - param.func = btn.innerFunc - if (setting.primaryKey) { // 涓婚敭瀛樺湪鏃讹紝璁剧疆涓婚敭鍙傛暟 - param[setting.primaryKey] = primaryId - } - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } - } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 - if (btn.innerFunc) { - param.func = btn.innerFunc - - if (setting.primaryKey) { // 涓婚敭瀛樺湪鏃讹紝璁剧疆涓婚敭鍙傛暟 - param[setting.primaryKey] = primaryId - } - - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - - } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid - primaryId = '' - - if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� - let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] - if (_form) { - primaryId = _form.value - } - } - - param.ID = primaryId || Utils.getguid() - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(btn, res) - } else { - this.execError(res, btn) - } - _resolve() - }) - } else if (btn.Ot === 'required') { - let _formPrimaryId = '' - if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� - let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] - if (_form) { - _formPrimaryId = _form.value - } - } - - let _params = data.map((cell, index) => { - let param = { - func: 'sPC_TableData_InUpDe' - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : '' - - if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� - - if (btn.innerFunc) { - param.func = btn.innerFunc - if (setting.primaryKey) { - param[setting.primaryKey] = primaryId - } - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } - } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 - if (index !== 0) { - formdata = formdata.map(_data => { - if (_data.readin && cell.hasOwnProperty(_data.key)) { - _data.value = cell[_data.key] - } - return _data - }) - } - - if (btn.innerFunc) { - param.func = btn.innerFunc - - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - - if (setting.primaryKey) { - param[setting.primaryKey] = primaryId - } - } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid - param.ID = _formPrimaryId || Utils.getguid() - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } - } - - return param - }) - - if (_params.length <= 20) { - let deffers = _params.map(param => { - return new Promise(resolve => { - Api.genericInterface(param).then(res => { - resolve(res) - }) - }) - }) - Promise.all(deffers).then(result => { - let iserror = false - let errorMsg = '' - result.forEach(res => { - if (res.status) { - errorMsg = res - } else { - iserror = true - errorMsg = res - } - }) - if (!iserror) { - this.execSuccess(btn, errorMsg) - } else { - this.execError(errorMsg, btn) - } - _resolve() - }) - } else { // 瓒呭嚭20涓姹傛椂寰幆鎵ц - this.innerLoopRequest(_params, btn, _resolve) - } - } else { - this.actionSettingError() - _resolve() - return - } - } else if (btn.intertype === 'outer') { - /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ - if (!btn.interface) { // 鎺ュ彛鍦板潃涓嶅瓨鍦ㄦ椂鎶ラ敊 - this.actionSettingError() - _resolve() - return - } - - let _params = [] // 璇锋眰鍙傛暟鏁扮粍 - - if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { - let param = {} - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - } - - // 鑾峰彇id - if (btn.Ot === 'notRequired') { - - } else if (btn.Ot === 'requiredSgl' && setting.primaryKey) { - param[setting.primaryKey] = data[0][setting.primaryKey] - } else if (btn.Ot === 'requiredOnce' && setting.primaryKey) { - let ids = data.map(d => { return d[setting.primaryKey]}) - param[setting.primaryKey] = ids.join(',') - } - - _params.push(param) - } else if (btn.Ot === 'required') { - // 閫夋嫨澶氳锛屽惊鐜皟鐢� - _params = data.map((cell, index) => { - let _cell = {} - - if (this.props.BID) { - _cell.BID = this.props.BID - } - - let _formparam = {} - if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 - formdata.forEach(_data => { - if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) { - _formparam[_data.key] = cell[_data.key] - } else { - _formparam[_data.key] = _data.value - } - }) - } - - if (setting.primaryKey) { - _cell[setting.primaryKey] = cell[setting.primaryKey] - } - - _cell = {..._formparam, ..._cell} - - return _cell - }) - } else { - this.actionSettingError() - _resolve() - return - } - - // 寰幆璋冪敤澶栭儴鎺ュ彛锛堝寘鎷唴閮ㄥ強鍥炶皟鍑芥暟锛� - this.outerLoopRequest(_params, btn, _resolve, _params.length > 20) - - } else { - this.actionSettingError() - _resolve() - return - } - } - - /** - * @description 鍐呴儴璇锋眰寰幆鎵ц - */ - innerLoopRequest = (params, btn, _resolve) => { - if (!params && params.length === 0) return - - let param = params.shift() - - this.setState({ - loadingNumber: params.length || '' - }) - - Api.genericInterface(param).then(res => { - if (res.status) { - if (params.length === 0) { - this.execSuccess(btn, res) - _resolve() - } else { - this.innerLoopRequest(params, btn, _resolve) - } - } else { - this.execError(res, btn) - _resolve() - } - }) - } - - /** - * @description 澶栭儴璇锋眰寰幆鎵ц - */ - outerLoopRequest = (params, btn, _resolve, widthNumber) => { - if (!params && params.length === 0) return - - let param = params.shift() - let _outParam = null - - if (widthNumber) { - this.setState({ - loadingNumber: params.length || '' - }) - } - - new Promise(resolve => { - // 鍐呴儴璇锋眰 - if (btn.innerFunc) { - param.func = btn.innerFunc - // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 - let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID - if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { - res.BID = this.props.BID - } - - resolve(res) - } else { - this.execError(res, btn) - resolve(false) - _resolve() - } - }) - } else { - resolve(param) - } - }).then(res => { - if (!res) return - // 澶栭儴璇锋眰 - _outParam = JSON.parse(JSON.stringify(res)) - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - res.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - res.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - return Api.genericInterface(res) - }).then(response => { - if (!response) return - // 鍥炶皟璇锋眰 - if (btn.callbackFunc) { - // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 - delete response.message - delete response.status - - response.func = btn.callbackFunc - - let _callbackparam = {..._outParam, ...response} - return Api.genericInterface(_callbackparam) - } else { - if (response.status) { - // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹� - - if (params.length === 0) { - this.execSuccess(btn, response) - _resolve() - } else { - this.outerLoopRequest(params, btn, _resolve, widthNumber) - } - } else { - this.execError(response, btn) - _resolve() - } - } - }).then(res => { - if (!res) return - - if (res.status) { - if (params.length === 0) { - this.execSuccess(btn, res) - _resolve() - } else { - this.outerLoopRequest(params, btn, _resolve, widthNumber) - } - } 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.setState({ - loadingUuid: '', - running: false, - loadingNumber: '' - }) - - 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 : 10 - }) - } 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 : 10 - }) - } else if (res.ErrCode === 'NM') { - message.error(res.message || res.ErrMesg) - } - - this.setState({ - loadingUuid: '', - running: false, - loadingNumber: '' - }) - - this.refreshdata(btn, 'error') - } - - /** - * @description 鎸夐挳閰嶇疆淇℃伅閿欒鎻愮ず - */ - actionSettingError = () => { - this.setState({ - running: false - }) - notification.warning({ - top: 92, - message: this.props.dict['main.action.settingerror'], - duration: 5 - }) - } - - /** - * @description 鑾峰彇鎸夐挳閰嶇疆淇℃伅 - */ - improveAction = (action) => { - const { configMap, execAction } = this.state - - let _config = configMap[action.uuid] - - if (_config) { - this.setState({ - execAction: {..._config, ...execAction} - }, () => { - this.improveActionForm() - }) - } else { - Api.getSystemCacheConfig({ - func: 'sPC_Get_LongParam', - MenuID: action.uuid - }).then(res => { - let _LongParam = '' - - if (res.status && res.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - this.setState({ - execAction: null, - tabledata: null, - btnloading: false - }) - } else if (!_LongParam || (action.OpenType === 'pop' && _LongParam.type !== 'Modal')) { - notification.warning({ - top: 92, - message: '鏈幏鍙栧埌鎸夐挳閰嶇疆淇℃伅锛�', - duration: 5 - }) - this.setState({ - execAction: null, - tabledata: null, - btnloading: false - }) - } else { - if (_LongParam.groups.length > 0) { - _LongParam.groups.forEach(group => { - group.sublist = group.sublist.filter(cell => { - if (!cell.blacklist || cell.blacklist.length === 0) return true - - let _black = cell.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0) { - return false - } else { - return true - } - }) - }) - } else { - _LongParam.fields = _LongParam.fields.filter(cell => { - if (!cell.blacklist || cell.blacklist.length === 0) return true - - let _black = cell.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0) { - return false - } else { - return true - } - }) - } - - this.setState({ - configMap: {...configMap, [action.uuid]: _LongParam}, - execAction: {..._LongParam, ...execAction} - }, () => { - this.improveActionForm() - }) - } - }) - } - } - - /** - * @description 鑾峰彇涓嬫媺琛ㄥ崟閫夐」淇℃伅 - */ - improveActionForm = () => { - const { configMap, execAction } = this.state - let subfields = [] - - if (execAction.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず锛屼笉璇锋眰涓嬫媺鑿滃崟淇℃伅 - this.setState({ - btnloading: false - }) - this.modelconfirm() - return - } - - if (execAction.groups.length > 0) { - execAction.groups.forEach(group => { - group.sublist.forEach(field => { - if ((field.type === 'select' || field.type === 'link' || field.type === 'multiselect') && field.resourceType === '1' && field.dataSource) { - subfields.push(field) - } - }) - }) - } else { - execAction.fields.forEach(field => { - if ((field.type === 'select' || field.type === 'link' || field.type === 'multiselect') && field.resourceType === '1' && field.dataSource) { - subfields.push(field) - } - }) - } - - if (subfields.length === 0) { - this.setState({ - visible: true, - btnloading: false - }) - return - } - - let deffers = subfields.map(item => { - let _option = Utils.getSelectQueryOptions(item) - let _sql = Utils.formatOptions(_option.sql) - let isSSO = item.database === 'sso' - - let param = { - func: 'sPC_Get_SelectedList', - LText: _sql, - obj_name: 'data', - arr_field: _option.field - } - - if (this.props.BID) { - param.BID = this.props.BID - } - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - return new Promise(resolve => { - Api.getSystemCacheConfig(param, isSSO).then(res => { - res.search = item - resolve(res) - }) - }) - }) - - let _field = {} - let error = '' - Promise.all(deffers).then(result => { - result.forEach(res => { - if (res.status) { - let options = res.data.map(cell => { - let item = { - key: Utils.getuuid(), - Value: cell[res.search.valueField], - Text: cell[res.search.valueText] - } - - if (res.search.type === 'link') { - item.parentId = cell[res.search.linkField] - } else if (res.search.type === 'select' && res.search.linkSubField && res.search.linkSubField.length > 0) { - res.search.linkSubField.forEach(_field => { - item[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' - }) - } - - return item - }) - - _field[res.search.uuid] = options - } else { - error = res - } - }) - - if (error) { - notification.warning({ - top: 92, - message: error.message, - duration: 5 - }) - } - - this.setState({ - configMap: {...configMap, ..._field} - }, () => { + if (!this.state.running) { this.setState({ - visible: true, - btnloading: false + triggerBtn: nextProps.triggerBtn }) - }) + } + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + updateStatus = (type, positon, unclose) => { + if (type === 'start') { + this.setState({running: true}) + } else if (type === 'over') { + this.setState({running: false}) + } else if (type === 'refresh') { + this.props.refreshdata(positon) + if (!unclose) { + this.setState({running: false}) + } + } + } + + getButtonList = (actions) => { + const { BID, BData, MenuID, Tab, logcolumns, setting, ContainerId, selectedData, getexceloutparam } = this.props + + return actions.map(item => { + if (['exec', 'prompt', 'pop'].includes(item.OpenType)) { + return ( + <NormalButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + BData={BData} + setting={setting} + columns={logcolumns} + ContainerId={ContainerId} + selectedData={selectedData} + triggerBtn={this.state.triggerBtn} + updateStatus={this.updateStatus} + /> + ) + } else if (item.OpenType === 'excelIn') { + return ( + <ExcelInButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + BData={BData} + setting={setting} + columns={logcolumns} + ContainerId={ContainerId} + selectedData={selectedData} + triggerBtn={this.state.triggerBtn} + updateStatus={this.updateStatus} + /> + ) + } else if (item.OpenType === 'excelOut') { + return ( + <ExcelOutButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + BData={BData} + setting={setting} + columns={logcolumns} + ContainerId={ContainerId} + triggerBtn={this.state.triggerBtn} + getexceloutparam={getexceloutparam} + updateStatus={this.updateStatus} + /> + ) + } else if (item.OpenType === 'popview') { + return ( + <PopupButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + BData={BData} + setting={setting} + selectedData={selectedData} + triggerBtn={this.state.triggerBtn} + updateStatus={this.updateStatus} + /> + ) + } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { + return ( + <TabButton + key={item.uuid} + btn={item} + MenuID={MenuID} + setting={setting} + selectedData={selectedData} + triggerBtn={this.state.triggerBtn} + /> + ) + } else if (item.OpenType === 'innerpage' || item.OpenType === 'outerpage') { + return ( + <NewPageButton + key={item.uuid} + btn={item} + setting={setting} + selectedData={selectedData} + triggerBtn={this.state.triggerBtn} + /> + ) + } else if (item.OpenType === 'funcbutton') { + if (item.funcType === 'changeuser') { + return ( + <ChangeUserButton + key={item.uuid} + BID={BID} + btn={item} + setting={setting} + selectedData={selectedData} + triggerBtn={this.state.triggerBtn} + updateStatus={this.updateStatus} + /> + ) + } else if (item.funcType === 'print') { + return ( + <PrintButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + BData={BData} + setting={setting} + ContainerId={ContainerId} + selectedData={selectedData} + triggerBtn={this.state.triggerBtn} + updateStatus={this.updateStatus} + /> + ) + } + } + return null }) - } - - /** - * @description Excel 瀵煎叆 - */ - getexceldata = (data, btn, errors, primaryId) => { - if (errors) { - if (errors === 'notexit') { - notification.warning({ - top: 92, - message: '宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬩笉瀛樺湪锛�', - duration: 5 - }) - } else if (errors === 'empty') { - notification.warning({ - top: 92, - message: '宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬩负绌猴紒', - duration: 5 - }) - } else if (errors === 'headerError') { - notification.warning({ - top: 92, - message: '宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬭〃澶磋缃敊璇紒', - duration: 5 - }) - } - - return - } - - if (!data || data.length === 0) { - notification.warning({ - top: 92, - message: '鏈幏鍙栧埌宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬫暟鎹紒', - duration: 5 - }) - return - } - - let result = Utils.getExcelInSql(btn, data, this.props.dict) - if (result.errors) { - notification.warning({ - top: 92, - message: result.errors, - duration: 5 - }) - return - } - - let param = { - ID: primaryId - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - result.sql = result.sql.replace(/\$@/ig, '/*') - result.sql = result.sql.replace(/@\$/ig, '*/') - } else { - result.sql = result.sql.replace(/@\$|\$@/ig, '') - } - - param.LText = Utils.formatOptions(result.sql) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - this.setState({loadingUuid: btn.uuid}) - - if (btn.intertype === 'inner' && !btn.innerFunc) { // 绯荤粺瀛樺偍杩囩▼ - param.func = 'sPC_TableData_InUpDe' - - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(btn, res) - } else { - this.execError(res, btn) - } - }) - } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋� - param.func = btn.innerFunc - - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(btn, res) - } else { - this.execError(res, btn) - } - }) - } else if (btn.intertype === 'outer') { // 澶栭儴鎺ュ彛 - let _outParam = null - - new Promise(resolve => { - // 鍐呴儴璇锋眰 - if (btn.innerFunc) { - param.func = btn.innerFunc - // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 - let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID - if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { - res.BID = this.props.BID - } - resolve(res) - } else { - this.execError(res, btn) - resolve(false) - } - }) - } else { - resolve(param) - } - }).then(res => { - if (!res) return - // 澶栭儴璇锋眰 - _outParam = JSON.parse(JSON.stringify(res)) - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - return Api.genericInterface(res) - }).then(response => { - if (!response) return - // 鍥炶皟璇锋眰 - if (btn.callbackFunc) { - // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 - delete response.message - delete response.status - - response.func = btn.callbackFunc - - let _callbackparam = {..._outParam, ...response} - return Api.genericInterface(_callbackparam) - } else { - if (response.status) { - this.execSuccess(btn, response) - } else { - this.execError(response, btn) - } - } - }).then(res => { - if (!res) return - - if (res.status) { - this.execSuccess(btn, res) - } else { - this.execError(res, btn) - } - }) - } - } - - /** - * @description Excel 瀵煎嚭 - */ - triggerExcelout = (btn) => { - let viewParam = this.props.getexceloutparam() - let name = `${viewParam.menuName}${moment().format('YYYYMMDDHHmmss')}.xlsx` - let pageSize = 1000 - - if (btn.search === 'true' && viewParam.search && viewParam.search.length > 0) { - let valid = false - viewParam.search.forEach(item => { - if (Array.isArray(item.value)) { - if (item.value.length > 0) { - valid = true - } - } else if (item.value || item.value === 0) { - valid = true - } - }) - - if (!valid) { - notification.warning({ - top: 92, - message: '鎼滅储鏉′欢涓嶅彲涓虹┖锛�', - duration: 5 - }) - return - } - } - - this.setState({loadingUuid: btn.uuid}) - - if (btn.pagination !== 'true') { - if (btn.intertype === 'inner' && !btn.innerFunc) { // 浣跨敤绯荤粺鍑芥暟 - if (!viewParam.arr_field) { - this.execError({ErrCode: 'N', message: '鏈缃樉绀哄垪锛�'}, btn) - return - } - - let param = this.getExcelDefaultParam(viewParam.arr_field, viewParam.orderBy, viewParam.search) - - Api.genericInterface(param).then(result => { - if (result.status) { - this.exportExcel(result.data, btn, name) - } else { - this.execError(result, btn) - } - }) - } else if (btn.intertype === 'inner' && btn.innerFunc) { // 浣跨敤鍐呴儴鍑芥暟 - let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) - param.func = btn.innerFunc - - Api.genericInterface(param).then(result => { - if (result.status) { - this.exportExcel(result.data, btn, name) - } else { - this.execError(result, btn) - } - }) - } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟 - let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } - - if (btn.outerFunc) { - param.func = btn.outerFunc - } - - Api.genericInterface(param).then(result => { - if (result.status) { - this.exportExcel(result.data, btn, name) - } else { - this.execError(result, btn) - } - }) - } else if (btn.intertype === 'outer' && btn.innerFunc) { - let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) - param.func = btn.innerFunc - - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - res.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - Api.genericInterface(res).then(result => { - if (result.status) { - this.exportExcel(result.data, btn, name) - } else { - this.execError(result, btn) - } - }) - } else { - this.execError(res, btn) - } - }) - } else { - this.execError({ErrCode: 'N', message: '瀵煎嚭鎸夐挳璁剧疆閿欒锛�'}, btn) - } - } else if (btn.intertype === 'outer' && btn.innerFunc) { // 鍒嗛〉锛屼笖涓ゆ璇锋眰 - this.getExcelOutDoubleData(btn, viewParam, 1, pageSize, [], name) - } else { // 鍒嗛〉锛屼竴姝ヨ姹� - this.getExcelOutData(btn, viewParam, 1, pageSize, [], name) - } - } - - /** - * @description 涓ゆ鍒嗛〉璇锋眰 - */ - getExcelOutDoubleData = (btn, viewParam, pageIndex, pageSize, data, name) => { - let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) - param.func = btn.innerFunc - - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - Api.genericInterface(res).then(result => { - if (result.status) { - if (!result.data) { - this.execError({ErrCode: 'N', message: '鏈幏鍙栧埌鏁版嵁淇℃伅锛�'}, btn) - } else if (result.data.length >= pageSize) { - data = data.concat(result.data) - pageIndex++ - this.getExcelOutDoubleData(btn, viewParam, pageIndex, pageSize, data, name) - } else { - data = data.concat(result.data) - this.exportExcel(data, btn, name) - } - } else { - this.execError(result, btn) - } - }) - } else { - this.execError(res, btn) - } - }) - } - - /** - * @description 涓�姝ュ垎椤佃姹� - */ - getExcelOutData = (btn, viewParam, pageIndex, pageSize, data, name) => { - let param = null - if (btn.intertype === 'inner' && !btn.innerFunc) { // 浣跨敤绯荤粺鍑芥暟 - if (!viewParam.arr_field) { - this.execError({ErrCode: 'N', message: '鏈缃樉绀哄垪锛�'}, btn) - return - } - - 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 - - } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟 - param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } - - if (btn.outerFunc) { - param.func = btn.outerFunc - } - } - - Api.genericInterface(param).then(result => { - if (result.status) { - if (!result.data) { - this.execError({ErrCode: 'N', message: '鏈幏鍙栧埌鏁版嵁淇℃伅锛�'}, btn) - } else if (result.data.length >= pageSize) { - data = data.concat(result.data) - pageIndex++ - this.getExcelOutData(btn, viewParam, pageIndex, pageSize, data, name) - } else { - data = data.concat(result.data) - this.exportExcel(data, btn, name) - } - } else { - this.execError(result, btn) - } - }) - } - - /** - * @description Excel 鐢熸垚 - */ - exportExcel = (data, btn, name) => { - const { logcolumns } = this.props - if (data && data.length > 0) { - try { - let _header = [] - let _topRow = {} - let colwidth = [] - - let hidecolumns = [] - - let verifyColumn = {} // 璁板綍楠岃瘉淇℃伅涓殑Excel鍒楅厤缃� - if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) { - btn.verify.columns.forEach(col => { - verifyColumn[col.Column] = col - }) - } - - logcolumns.forEach(col => { - if (col.Hide === 'true') { - hidecolumns.push(col.field) - return - } - if (!data[0].hasOwnProperty(col.field)) return - if (_topRow[col.field]) return - - if (verifyColumn[col.field]) { // 浼樺厛浣跨敤楠岃瘉淇℃伅涓殑鍒楄缃� - _header.push(col.field) - _topRow[col.field] = verifyColumn[col.field].Text - - colwidth.push({width: verifyColumn[col.field].Width}) - } else { - _header.push(col.field) - _topRow[col.field] = col.label - - let _colwidth = Math.floor(col.Width / 6) - - if (!_colwidth || _colwidth < 5) { - _colwidth = 5 - } - - colwidth.push({width: _colwidth}) - } - }) - - if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) { - btn.verify.columns.forEach(col => { - if (hidecolumns.includes(col.Column)) return - if (!data[0].hasOwnProperty(col.Column)) return - if (_topRow[col.Column]) return - - _header.push(col.Column) - _topRow[col.Column] = col.Text - - colwidth.push({width: col.Width}) - }) - } - - Object.keys(data[0]).forEach(key => { - if (hidecolumns.includes(key)) return - if (_topRow[key]) return - - _header.push(key) - _topRow[key] = key - - colwidth.push({width: 12}) - }) - - let table = [] - - table.push(_topRow) - - data.forEach(item => { - let _row = {} - _header.forEach(field => { - _row[field] = item[field] - }) - - table.push(_row) - }) - - const ws = XLSX.utils.json_to_sheet(table, {header: _header, skipHeader: true}) - - ws['!cols'] = colwidth - - const wb = XLSX.utils.book_new() - XLSX.utils.book_append_sheet(wb, ws, 'Sheet1') - - XLSX.writeFile(wb, name) - - this.execSuccess(btn, {ErrCode: 'S', ErrMesg: '瀵煎嚭鎴愬姛锛�'}) - } catch { - this.execError({ErrCode: 'N', message: 'Excel鐢熸垚澶辫触锛�'}, btn) - } - - } else { - this.execError({ErrCode: 'N', message: '鏈煡璇㈠埌瀵煎嚭鏁版嵁锛�'}, btn) - } - } - - /** - * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� - */ - getExcelCustomParam = (orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { - let _search = Utils.formatCustomMainSearch(search) - - let param = { - OrderCol: orderBy, - ..._search - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (pagination) { - param.PageIndex = pageIndex - param.PageSize = pageSize - } - - return param - } - - /** - * @description 鑾峰彇榛樿瀛樺偍杩囩▼璇锋眰鍙傛暟 - */ - getExcelDefaultParam = (arr_field, orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { - const { setting } = this.props - - let _search = Utils.joinMainSearchkey(search) - - _search = _search ? 'where ' + _search : '' - - let param = { - func: 'sPC_Get_TableData', - obj_name: 'data', - arr_field: arr_field, - custom_script: setting.customScript || '', - default_sql: setting.default || 'true', - dataM: this.props.dataManager ? 'Y' : '' - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - let _dataresource = setting.dataresource - - if (/\s/.test(_dataresource)) { - _dataresource = '(' + _dataresource + ') tb' - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - _dataresource = _dataresource.replace(/\$@/ig, '/*') - _dataresource = _dataresource.replace(/@\$/ig, '*/') - param.custom_script = param.custom_script.replace(/\$@/ig, '/*') - param.custom_script = param.custom_script.replace(/@\$/ig, '*/') - } else { - _dataresource = _dataresource.replace(/@\$|\$@/ig, '') - param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '') - } - - let regoptions = null - if (setting.queryType === 'statistics' || param.custom_script) { - let allSearch = Utils.getAllSearchOptions(search) - - regoptions = allSearch.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` - } - }) - - regoptions.push({ - reg: new RegExp('@orderBy@', 'ig'), - value: orderBy - }, { - reg: new RegExp('@pageSize@', 'ig'), - value: pageSize - }, { - reg: new RegExp('@pageIndex@', 'ig'), - value: pageIndex - }) - } - - if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 - regoptions.forEach(item => { - _dataresource = _dataresource.replace(item.reg, item.value) - }) - _search = '' - } - - let LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` - - if (pagination) { - LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` - } - - if (param.custom_script) { - regoptions.forEach(item => { - param.custom_script = param.custom_script.replace(item.reg, item.value) - }) - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.custom_script = param.custom_script.replace(/\$@/ig, '/*') - param.custom_script = param.custom_script.replace(/@\$/ig, '*/') - } else { - param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '') - } - - param.custom_script = Utils.formatOptions(param.custom_script) - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - LText = LText.replace(/\$@/ig, '/*') - LText = LText.replace(/@\$/ig, '*/') - } else { - LText = LText.replace(/@\$|\$@/ig, '') - } - - param.LText = Utils.formatOptions(LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - param.DateCount = '' - - return param - } - - /** - * @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, - confirmLoading: false - }) - } - - modelconfirm = () => { - const { BData } = this.props - const { execAction, tabledata } = this.state - let _this = this - let _fields = [] - - if (execAction.groups.length > 0) { - execAction.groups.forEach(group => { - _fields = [..._fields, ...group.sublist] - }) - } else { - _fields = execAction.fields - } - - let result = _fields.map(item => { - let _readin = item.readin !== 'false' - let _initval = item.initval - - if (item.type === 'linkMain' || item.type === 'funcvar') { - _readin = false - } - - if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) { - _initval = BData[item.field] - } else if (_readin && tabledata[0] && tabledata[0].hasOwnProperty(item.field)) { - _initval = tabledata[0][item.field] - } - - 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 - } - - return { - key: item.field, - readonly: item.readonly === 'true', - readin: _readin, - fieldlen: _fieldlen, - type: item.type, - value: _initval - } - }) - - _this.setState({ - running: true - }) - - confirm({ - title: this.props.dict['main.action.confirm.tip'], - onOk() { - _this.setState({ - loadingUuid: execAction.uuid - }) - - return new Promise(resolve => { - _this.execSubmit(execAction, tabledata, resolve, result) - }) - }, - onCancel() { - _this.setState({ - loadingUuid: '', - running: false - }) - } - }) - } - - /** - * @description 鏄剧ず妯℃�佹 - */ - getModels = () => { - const { execAction } = this.state - - if (!execAction || !this.state.visible) return null - - 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 (this.props.type === 'main' && 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() { - const { loadingUuid, btnloading, loadingNumber } = this.state - - let fixed = this.props.setting.actionfixed && this.props.type === 'main' // 鎸夐挳鏄惁鍥哄畾鍦ㄥご閮� + const { setting, MenuID, actions, operations } = this.props + let fixed = setting.actionfixed && setting.tabType === 'main' // 鎸夐挳鏄惁鍥哄畾鍦ㄥご閮� if (fixed) { return ( <Affix offsetTop={48}> - <div className="button-list toolbar-button" id={fixed ? this.props.MenuID + 'mainaction' : ''}> - {this.props.actions.map((item, index) => { - let label = item.label - if (loadingUuid === item.uuid && loadingNumber !== '') { - label = label + '(' + loadingNumber + ')' - } - - return ( - <Button - className={'mk-btn mk-' + item.class} - icon={item.icon} - key={'action' + index} - onClick={() => {this.actionTrigger(item)}} - loading={loadingUuid === item.uuid} - >{label}</Button> - ) - })} - {this.getModels()} - {btnloading && <Spin size="large" />} - <ExcelIn MenuID={this.props.MenuID} returndata={this.getexceldata} ref="excelIn" /> + <div className="button-list toolbar-button" id={fixed ? MenuID + 'mainaction' : ''}> + {this.getButtonList(actions)} + {operations && operations.length > 0 ? <div className="grid-button-list">{this.getButtonList(operations)}</div> : null} </div> </Affix> ) } else { return ( - <div className="button-list toolbar-button" id={fixed ? this.props.MenuID + 'mainaction' : ''}> - {this.props.actions.map((item, index) => { - let label = item.label - if (loadingUuid === item.uuid && loadingNumber !== '') { - label = label + '(' + loadingNumber + ')' - } - - return ( - <Button - className={'mk-btn mk-' + item.class} - icon={item.icon} - key={'action' + index} - onClick={() => {this.actionTrigger(item)}} - loading={loadingUuid === item.uuid} - >{label}</Button> - ) - })} - {this.getModels()} - {btnloading && <Spin size="large" />} - <ExcelIn MenuID={this.props.MenuID} returndata={this.getexceldata} ref="excelIn" /> + <div className="button-list toolbar-button" id={fixed ? MenuID + 'mainaction' : ''}> + {this.getButtonList(actions)} + {operations && operations.length > 0 ? <div className="grid-button-list">{this.getButtonList(operations)}</div> : null} </div> ) } } } -const mapStateToProps = (state) => { - return { - tabviews: state.tabviews, - permRoles: state.permRoles, - dataManager: state.dataManager - } -} - -const mapDispatchToProps = () => { - return {} -} - -export default connect(mapStateToProps, mapDispatchToProps)(MainAction) \ No newline at end of file +export default ActionList \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/index.scss b/src/tabviews/zshare/actionList/index.scss index 9dd1f19..ef3b2be 100644 --- a/src/tabviews/zshare/actionList/index.scss +++ b/src/tabviews/zshare/actionList/index.scss @@ -8,11 +8,20 @@ margin-bottom: 10px; overflow: hidden; } - .ant-spin { - position: fixed; - z-index: 1010; - left: calc(50vw - 22px); - top: calc(50vh - 70px); + + .loading-skeleton { + background: -webkit-gradient(linear,left top,right top,color-stop(25%,#f5f5f5),color-stop(37%,#ffffff),color-stop(63%,#f5f5f5)); + background: linear-gradient(90deg,#f5f5f5 25%,#ffffff 37%,#f5f5f5 63%); + background-size: 400% 100%; + -webkit-animation: mk-skeleton-loading 1.4s ease infinite; + animation: mk-skeleton-loading 1.4s ease infinite; + border-color: #f0f0f0; + } + @keyframes mk-skeleton-loading{0%{background-position:100% 50%}100%{background-position:0 50%}} + @-webkit-keyframes mk-skeleton-loading{0%{background-position:100% 50%}100%{background-position:0 50%}} + + .grid-button-list { + display: none; } } // 璁剧疆妯℃�佹鏍峰紡锛岃瀹氭渶澶ф渶灏忛珮搴︼紝閲嶇疆婊氬姩鏉� diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx new file mode 100644 index 0000000..ccf1319 --- /dev/null +++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx @@ -0,0 +1,112 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' +import { Button, notification } from 'antd' + +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import './index.scss' + +class NewPageButton extends Component { + static propTpyes = { + show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 + btn: PropTypes.object, // 鎸夐挳 + selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 + setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + triggerBtn: PropTypes.any, + } + + state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS + } + + /** + * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { + this.actionTrigger(nextProps.triggerBtn.data) + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 瑙﹀彂鎸夐挳鎿嶄綔 + */ + actionTrigger = (record) => { + const { setting, btn, selectedData } = this.props + let data = [] + + if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� + data = [record] + } else { + data = selectedData || [] + } + + if (btn.Ot === 'requiredSgl' && data.length !== 1) { + // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 + notification.warning({ + top: 92, + message: this.state.dict['main.action.confirm.selectSingleLine'], + duration: 5 + }) + return + } else if (btn.Ot === 'requiredSgl' && !setting.primaryKey) { + // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� + notification.warning({ + top: 92, + message: '鏈缃富閿紒', + duration: 5 + }) + return + } else if (!btn.pageTemplate) { + notification.warning({ + top: 92, + message: '椤甸潰绫诲瀷璁剧疆閿欒锛�', + duration: 5 + }) + return + } + + let Id = '' + if (btn.Ot === 'requiredSgl') { + Id = data[0][setting.primaryKey] || '' + } + + if (btn.pageTemplate === 'print') { + let cloudmsg = '&cuid=' + (sessionStorage.getItem('CloudUserID') || '') + '&csid=' + (sessionStorage.getItem('CloudSessionUid') || '') + '&clid=' + (sessionStorage.getItem('CloudLoginUID') || '') + '&cun=' + (sessionStorage.getItem('CloudUserName') || '') + let msg = '&uid=' + sessionStorage.getItem('UserID') + '&sid=' + sessionStorage.getItem('SessionUid') + '&lid=' + sessionStorage.getItem('LoginUID') + '&un=' + sessionStorage.getItem('User_Name') + let src = '#/print/' + window.btoa('ID=' + Id + msg + cloudmsg) + window.open(src) + } else if (btn.pageTemplate === 'custom') { + let url = btn.url + if (btn.Ot === 'requiredSgl') { + url = url + '?ID=' + Id + } + + window.open(url) + } + } + + render() { + const { btn, show } = this.props + + return ( + <div className="mk-btn-wrap"> + {!show ? <Button + className={'mk-btn mk-' + btn.class} + icon={btn.icon} + onClick={() => {this.actionTrigger()}} + >{btn.label}</Button> : null} + {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} onClick={() => {this.actionTrigger()}}></Button> : null} + {show === 'text' ? <Button className="action-cell" onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + </div> + ) + } +} + +export default NewPageButton \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.scss b/src/tabviews/zshare/actionList/newpagebutton/index.scss new file mode 100644 index 0000000..e9a2a7d --- /dev/null +++ b/src/tabviews/zshare/actionList/newpagebutton/index.scss @@ -0,0 +1,10 @@ +.mk-btn-wrap { + display: inline-block; + .action-cell { + border: 0; + background: transparent !important; + } + .action-cell[ant-click-animating-without-extra-node="true"]::after { + display: none!important; + } +} diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx new file mode 100644 index 0000000..5dc56c7 --- /dev/null +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -0,0 +1,1022 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import moment from 'moment' +import {connect} from 'react-redux' +import { is, fromJS } from 'immutable' +import { Button, Modal, notification, message } from 'antd' + +import Api from '@/api' +import Utils from '@/utils/utils.js' +import options from '@/store/options.js' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import asyncSpinComponent from '@/utils/asyncSpinComponent' +import './index.scss' + +const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) +const { confirm } = Modal + +class NormalButton extends Component { + static propTpyes = { + show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 + BID: PropTypes.string, // 涓昏〃ID + BData: PropTypes.any, // 涓昏〃鏁版嵁 + selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 + Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� + MenuID: PropTypes.string, // 鑿滃崟ID + btn: PropTypes.object, // 鎸夐挳 + columns: PropTypes.array, // 瀛楁鍒� + setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� + updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� + triggerBtn: PropTypes.any, + } + + state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + visible: false, + formdata: null, + tabledata: null, + confirmLoading: false, + btnconfig: null, + loading: false, + loadingNumber: '' + } + + /** + * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { + this.actionTrigger(nextProps.triggerBtn.data) + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 鎸夐挳鐘舵�佹敼鍙� + */ + updateStatus = (type) => { + if (type === 'start') { + this.setState({ + loading: true + }) + this.props.updateStatus('start') + } else if (type === 'over') { + this.setState({ + loading: false, + visible: false + }) + this.props.updateStatus('over') + } + } + + /** + * @description 瑙﹀彂鎸夐挳鎿嶄綔 + */ + actionTrigger = (record) => { + const { setting, Tab, BID, btn, selectedData } = this.props + console.log(selectedData) + if (Tab && Tab.supMenu && !BID) { + notification.warning({ + top: 92, + message: '闇�瑕佷笂绾т富閿�硷紒', + duration: 5 + }) + return + } + + let _this = this + let data = [] + + if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� + data = [record] + } else { + data = selectedData || [] + } + + if (btn.Ot !== 'notRequired' && data.length === 0) { + // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� + notification.warning({ + top: 92, + message: this.state.dict['main.action.confirm.selectline'], + duration: 5 + }) + return + } else if (btn.Ot === 'requiredSgl' && data.length !== 1) { + // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 + notification.warning({ + top: 92, + message: this.state.dict['main.action.confirm.selectSingleLine'], + duration: 5 + }) + return + } else if (!setting.primaryKey) { + // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� + notification.warning({ + top: 92, + message: '鏈缃富閿紒', + duration: 5 + }) + return + } else if (!['requiredSgl', 'notRequired', 'requiredOnce', 'required'].includes(btn.Ot)) { + // 鏁版嵁閫夋嫨绫诲瀷鏍¢獙 + this.actionSettingError() + return + } else if (btn.intertype === 'inner') { + // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟鍜屾暟鎹簮涓嶅彲鍚屾椂涓虹┖, 浣跨敤绯荤粺鍑芥暟鏃讹紝绫诲瀷涓嶅彲涓虹┖ + if (!btn.innerFunc && (!btn.sql || (btn.sql && !btn.sqlType))) { + this.actionSettingError() + return + } else if (data.length === 0 && !btn.innerFunc && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { + notification.warning({ + top: 92, + message: '浣跨敤鍒涘缓鍑瘉鍑芥暟锛岄渶瑕侀�夋嫨琛岋紒', + duration: 5 + }) + return + } + } else if (btn.intertype === 'outer') { + // 鎺ュ彛鍦板潃涓嶅瓨鍦ㄦ椂鎶ラ敊 + if (!btn.interface) { + this.actionSettingError() + return + } + } else if (!['inner', 'outer'].includes(btn.intertype)) { + // 鎺ュ彛绫诲瀷閿欒 + this.actionSettingError() + return + } + + if (btn.OpenType === 'prompt') { + this.updateStatus('start') + confirm({ + title: this.state.dict['main.action.confirm.tip'], + onOk() { + return new Promise(resolve => { + _this.execSubmit(data, resolve) + }) + }, + onCancel() { + _this.updateStatus('over') + } + }) + } else if (btn.OpenType === 'exec') { + this.updateStatus('start') + this.execSubmit(data, () => { this.setState({loading: false})}) + } else if (btn.OpenType === 'pop') { + this.updateStatus('start') + this.setState({ + tabledata: data + }, () => { + this.improveAction() + }) + } + } + + /** + * @description 鎸夐挳鎻愪氦鎵ц + */ + execSubmit = (data, _resolve, formdata) => { + const { setting, columns, btn } = this.props + if (btn.intertype === 'inner') { + // 鎵ц鏂瑰紡涓哄琛屾嫾鎺ワ紝涓旀墦寮�鏂瑰紡涓鸿〃鍗曟椂锛屼細杞负寰幆鍙戦�佽姹� + // 鎵撳紑鏂瑰紡涓烘ā鎬佹锛屼娇鐢ㄥ唴閮ㄥ嚱鏁版坊鍔�(鏈夋壒閲忔坊鍔犲満鏅紝宸插幓闄�) + if ( + btn.Ot === 'notRequired' || + btn.Ot === 'requiredSgl' || + btn.Ot === 'requiredOnce' + ) { + let param = { // 绯荤粺瀛樺偍杩囩▼ + func: 'sPC_TableData_InUpDe' + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + let primaryId = '' + + if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + let ids = data.map(d => { return d[setting.primaryKey] || ''}) + ids = ids.filter(Boolean) + primaryId = ids.join(',') + } + + if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� + if (btn.innerFunc) { // 浣跨敤鑷畾涔夊嚱鏁� + param.func = btn.innerFunc + if (setting.primaryKey) { // 涓婚敭瀛樺湪鏃讹紝璁剧疆涓婚敭鍙傛暟 + param[setting.primaryKey] = primaryId + } + } else if (btn.sql) { + param.ID = primaryId + param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab) // 鏁版嵁婧� + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + 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) + } + } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 + if (btn.innerFunc) { + param.func = btn.innerFunc + + if (setting.primaryKey) { // 涓婚敭瀛樺湪鏃讹紝璁剧疆涓婚敭鍙傛暟 + param[setting.primaryKey] = primaryId + } + + formdata.forEach(_data => { + param[_data.key] = _data.value + }) + + } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid + primaryId = '' + + if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� + let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] + if (_form) { + primaryId = _form.value + } + } + + param.ID = primaryId || Utils.getguid() + param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧� + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + 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) + } else if (btn.sql) { + param.ID = primaryId + param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 鏁版嵁婧� + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + 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.genericInterface(param).then((res) => { + if (res.status) { + this.execSuccess(res) + } else { + this.execError(res) + } + _resolve() + }, () => { + this.updateStatus('over') + _resolve() + }) + } else if (btn.Ot === 'required') { + let _formPrimaryId = '' + if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� + let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] + if (_form) { + _formPrimaryId = _form.value + } + } + + let _params = data.map((cell, index) => { + let param = { + func: 'sPC_TableData_InUpDe' + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : '' + + if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� + + if (btn.innerFunc) { + param.func = btn.innerFunc + if (setting.primaryKey) { + param[setting.primaryKey] = primaryId + } + } else if (btn.sql) { + param.ID = primaryId + param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab) // 鏁版嵁婧� + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + 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) + } + } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 + if (index !== 0) { + formdata = formdata.map(_data => { + if (_data.readin && cell.hasOwnProperty(_data.key)) { + _data.value = cell[_data.key] + } + return _data + }) + } + + if (btn.innerFunc) { + param.func = btn.innerFunc + + formdata.forEach(_data => { + param[_data.key] = _data.value + }) + + if (setting.primaryKey) { + param[setting.primaryKey] = primaryId + } + } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid + param.ID = _formPrimaryId || Utils.getguid() + param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧� + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + 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) + } else if (btn.sql) { + param.ID = primaryId + param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 鏁版嵁婧� + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + 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) + } + } + + return param + }) + + if (_params.length <= 20) { + let deffers = _params.map(param => { + return new Promise(resolve => { + Api.genericInterface(param).then(res => { + resolve(res) + }, () => { + this.updateStatus('over') + _resolve() + }) + }) + }) + Promise.all(deffers).then(result => { + let iserror = false + let errorMsg = '' + result.forEach(res => { + if (res.status) { + errorMsg = res + } else { + iserror = true + errorMsg = res + } + }) + if (!iserror) { + this.execSuccess(errorMsg) + } else { + this.execError(errorMsg) + } + _resolve() + }) + } else { // 瓒呭嚭20涓姹傛椂寰幆鎵ц + this.innerLoopRequest(_params, btn, _resolve) + } + } + } else if (btn.intertype === 'outer') { + /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ + let _params = [] // 璇锋眰鍙傛暟鏁扮粍 + + if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { + let param = {} + + if (this.props.BID) { + param.BID = this.props.BID + } + + if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 + formdata.forEach(_data => { + param[_data.key] = _data.value + }) + } + + // 鑾峰彇id + if (btn.Ot === 'notRequired') { + + } else if (btn.Ot === 'requiredSgl' && setting.primaryKey) { + param[setting.primaryKey] = data[0][setting.primaryKey] + } else if (btn.Ot === 'requiredOnce' && setting.primaryKey) { + let ids = data.map(d => { return d[setting.primaryKey]}) + param[setting.primaryKey] = ids.join(',') + } + + _params.push(param) + } else if (btn.Ot === 'required') { + // 閫夋嫨澶氳锛屽惊鐜皟鐢� + _params = data.map((cell, index) => { + let _cell = {} + + if (this.props.BID) { + _cell.BID = this.props.BID + } + + let _formparam = {} + if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 + formdata.forEach(_data => { + if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) { + _formparam[_data.key] = cell[_data.key] + } else { + _formparam[_data.key] = _data.value + } + }) + } + + if (setting.primaryKey) { + _cell[setting.primaryKey] = cell[setting.primaryKey] + } + + _cell = {..._formparam, ..._cell} + + return _cell + }) + } + + // 寰幆璋冪敤澶栭儴鎺ュ彛锛堝寘鎷唴閮ㄥ強鍥炶皟鍑芥暟锛� + this.outerLoopRequest(_params, btn, _resolve, _params.length > 20) + } + } + + /** + * @description 鍐呴儴璇锋眰寰幆鎵ц + */ + innerLoopRequest = (params, btn, _resolve) => { + if (!params && params.length === 0) return + + let param = params.shift() + + this.setState({ + loadingNumber: params.length || '' + }) + + Api.genericInterface(param).then(res => { + if (res.status) { + if (params.length === 0) { + this.execSuccess(res) + _resolve() + } else { + this.innerLoopRequest(params, btn, _resolve) + } + } else { + this.execError(res) + _resolve() + } + }, () => { + this.updateStatus('over') + _resolve() + }) + } + + /** + * @description 澶栭儴璇锋眰寰幆鎵ц + */ + outerLoopRequest = (params, btn, _resolve, widthNumber) => { + if (!params && params.length === 0) return + + let param = params.shift() + let _outParam = null + + if (widthNumber) { + this.setState({ + loadingNumber: params.length || '' + }) + } + + new Promise(resolve => { + // 鍐呴儴璇锋眰 + if (btn.innerFunc) { + param.func = btn.innerFunc + // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� + Api.genericInterface(param).then(res => { + if (res.status) { + delete res.ErrCode + delete res.ErrMesg + delete res.message + delete res.status + + // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 + let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID + if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { + res.BID = this.props.BID + } + + resolve(res) + } else { + this.execError(res, btn) + resolve(false) + _resolve() + } + }, () => { + this.updateStatus('over') + _resolve() + }) + } else { + resolve(param) + } + }).then(res => { + if (!res) return + // 澶栭儴璇锋眰 + _outParam = JSON.parse(JSON.stringify(res)) + + if (this.props.menuType === 'HS') { + if (btn.sysInterface === 'true' && options.cloudServiceApi) { + res.rduri = options.cloudServiceApi + } else if (btn.sysInterface !== 'true') { + res.rduri = btn.interface + } + } else { + if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { + res.rduri = window.GLOB.mainSystemApi + } else if (btn.sysInterface !== 'true') { + res.rduri = btn.interface + } + } + + if (btn.outerFunc) { + res.func = btn.outerFunc + } + + return Api.genericInterface(res) + }).then(response => { + if (!response) return + // 鍥炶皟璇锋眰 + if (btn.callbackFunc) { + // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 + delete response.message + delete response.status + + response.func = btn.callbackFunc + + let _callbackparam = {..._outParam, ...response} + return Api.genericInterface(_callbackparam) + } else { + if (response.status) { + // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹� + + if (params.length === 0) { + this.execSuccess(response) + _resolve() + } else { + this.outerLoopRequest(params, btn, _resolve, widthNumber) + } + } else { + this.execError(response) + _resolve() + } + } + }).then(res => { + if (!res) return + + if (res.status) { + if (params.length === 0) { + this.execSuccess(res) + _resolve() + } else { + this.outerLoopRequest(params, btn, _resolve, widthNumber) + } + } else { + this.execError(res) + _resolve() + } + }) + } + + /** + * @description 鎿嶄綔鎴愬姛鍚庡鐞� + * 1銆乪xcel瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� + * 2銆佺姸鎬佺爜涓� S 鏃讹紝鏄剧ず鎴愬姛淇℃伅鍚庣郴缁熼粯璁や俊鎭� + * 3銆佺姸鎬佺爜涓� -1 鏃讹紝涓嶆樉绀轰换浣曚俊鎭� + * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� + * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� + */ + execSuccess = (res) => { + const { btn } = this.props + const { btnconfig } = this.state + + if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 + notification.success({ + top: 92, + message: res.ErrMesg || this.state.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.state.dict['main.action.confirm.success'] + }) + } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず + + } + + let _unclose = false + if (btn.OpenType !== 'pop' || !btnconfig || btnconfig.setting.finish !== 'unclose') { + this.setState({ + loading: false, + visible: false + }) + } else { + _unclose = true + } + + this.props.updateStatus('refresh', btn.execSuccess, _unclose) + } + + /** + * @description 鎿嶄綔澶辫触鍚庡鐞� + * 1銆佺姸鎬佺爜涓� E銆丯銆丗銆丯M 鏃讹紝鏄剧ず鐩稿簲鎻愮ず淇℃伅 + * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� + * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂� + */ + execError = (res) => { + const { btn } = this.props + + 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 : 10 + }) + } 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 : 10 + }) + } else if (res.ErrCode === 'NM') { + message.error(res.message || res.ErrMesg) + } + + let _unclose = false + if (btn.OpenType === 'pop') { + _unclose = true + } else { + this.setState({ + loading: false + }) + } + + this.props.updateStatus('refresh', btn.execError, _unclose) + } + + /** + * @description 鎸夐挳閰嶇疆淇℃伅閿欒鎻愮ず + */ + actionSettingError = () => { + notification.warning({ + top: 92, + message: this.state.dict['main.action.settingerror'], + duration: 5 + }) + } + + /** + * @description 鑾峰彇鎸夐挳閰嶇疆淇℃伅 + */ + improveAction = () => { + const { btn } = this.props + const { btnconfig } = this.state + + if (btnconfig) { + if (btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + this.modelconfirm() + } else { + this.setState({ + visible: true + }) + } + } else { + Api.getSystemCacheConfig({ + func: 'sPC_Get_LongParam', + MenuID: btn.uuid + }).then(res => { + let _LongParam = '' + + if (res.status && res.LongParam) { + try { + _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) + } catch (e) { + console.warn('Parse Failure') + _LongParam = '' + } + } + + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + this.updateStatus('over') + } else if (!_LongParam || (btn.OpenType === 'pop' && _LongParam.type !== 'Modal')) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌鎸夐挳閰嶇疆淇℃伅锛�', + duration: 5 + }) + this.updateStatus('over') + } else { + if (_LongParam.groups.length > 0) { + _LongParam.groups.forEach(group => { + group.sublist = group.sublist.filter(cell => { + // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 + if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { + let _option = Utils.getSelectQueryOptions(cell) + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + _option.sql = _option.sql.replace(/\$@/ig, '/*') + _option.sql = _option.sql.replace(/@\$/ig, '*/') + } else { + _option.sql = _option.sql.replace(/@\$|\$@/ig, '') + } + + cell.data_sql = Utils.formatOptions(_option.sql) + cell.arr_field = _option.field + } + + // 瀛楁鏉冮檺榛戝悕鍗� + if (!cell.blacklist || cell.blacklist.length === 0) return true + + let _black = cell.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0) { + return false + } else { + return true + } + }) + }) + } else { + _LongParam.fields = _LongParam.fields.filter(cell => { + // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 + if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { + let _option = Utils.getSelectQueryOptions(cell) + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + _option.sql = _option.sql.replace(/\$@/ig, '/*') + _option.sql = _option.sql.replace(/@\$/ig, '*/') + } else { + _option.sql = _option.sql.replace(/@\$|\$@/ig, '') + } + + cell.data_sql = Utils.formatOptions(_option.sql) + cell.arr_field = _option.field + } + + // 瀛楁鏉冮檺榛戝悕鍗� + if (!cell.blacklist || cell.blacklist.length === 0) return true + + let _black = cell.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0) { + return false + } else { + return true + } + }) + } + + this.setState({ + btnconfig: _LongParam + }, () => { + if (_LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + this.modelconfirm() + } else { + this.setState({ + visible: true + }) + } + }) + } + }) + } + } + + /** + * @description 妯℃�佹锛堣〃鍗曪級锛岀‘璁� + */ + handleOk = () => { + this.formRef.handleConfirm().then(res => { + this.setState({ + confirmLoading: true + }) + + this.execSubmit(this.state.tabledata, () => { + this.setState({ + confirmLoading: false + }) + }, res) + }) + } + + /** + * @description 妯℃�佹锛堣〃鍗曪級锛屽彇娑� + */ + handleCancel = () => { + this.setState({ + visible: false, + confirmLoading: false + }) + this.updateStatus('over') + } + + modelconfirm = () => { + const { BData } = this.props + const { btnconfig, tabledata } = this.state + let _this = this + let _fields = [] + + if (btnconfig.groups.length > 0) { + btnconfig.groups.forEach(group => { + _fields = [..._fields, ...group.sublist] + }) + } else { + _fields = btnconfig.fields + } + + let result = _fields.map(item => { + let _readin = item.readin !== 'false' + let _initval = item.initval + + if (item.type === 'linkMain' || item.type === 'funcvar') { + _readin = false + } + + if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) { + _initval = BData[item.field] + } else if (_readin && tabledata[0] && tabledata[0].hasOwnProperty(item.field)) { + _initval = tabledata[0][item.field] + } else if (item.type === 'date' && _initval) { + _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD') + } 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') + } + + 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 + } + + return { + key: item.field, + readonly: item.readonly === 'true', + readin: _readin, + fieldlen: _fieldlen, + type: item.type, + value: _initval + } + }) + + confirm({ + title: this.state.dict['main.action.confirm.tip'], + onOk() { + return new Promise(resolve => { + _this.execSubmit(tabledata, resolve, result) + }) + }, + onCancel() { + _this.updateStatus('over') + } + }) + } + + /** + * @description 鏄剧ず妯℃�佹 + */ + getModels = () => { + const { setting, BID } = this.props + const { btnconfig } = this.state + + if (!this.state.visible || !btnconfig || !btnconfig.setting) return null + + let title = btnconfig.setting.title + let width = btnconfig.setting.width + 'vw' + let clickouter = false + let container = document.body + + if (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) { + width = btnconfig.setting.width + '%' + container = () => document.getElementById(this.props.ContainerId) + } + + if (btnconfig.setting.clickouter === 'close') { + clickouter = true + } + + 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.state.dict} + BID={BID} + action={btnconfig} + inputSubmit={this.handleOk} + data={this.state.tabledata[0]} + BData={this.props.BData} + wrappedComponentRef={(inst) => this.formRef = inst} + /> + </Modal> + ) + } + + render() { + const { btn, show } = this.props + const { loadingNumber, loading } = this.state + + return ( + <div className="mk-btn-wrap"> + {!show ? <Button + className={'mk-btn mk-' + btn.class} + icon={btn.icon} + onClick={() => {this.actionTrigger()}} + loading={loading} + >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button> : null} + {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null} + {show === 'text' ? <Button className="action-cell" loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + {this.getModels()} + </div> + ) + } +} + +const mapStateToProps = (state) => { + return { + tabviews: state.tabviews, + menuType: state.editLevel, + permRoles: state.permRoles, + dataManager: state.dataManager + } +} + +const mapDispatchToProps = () => { + return {} +} + +export default connect(mapStateToProps, mapDispatchToProps)(NormalButton) \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/normalbutton/index.scss b/src/tabviews/zshare/actionList/normalbutton/index.scss new file mode 100644 index 0000000..e9a2a7d --- /dev/null +++ b/src/tabviews/zshare/actionList/normalbutton/index.scss @@ -0,0 +1,10 @@ +.mk-btn-wrap { + display: inline-block; + .action-cell { + border: 0; + background: transparent !important; + } + .action-cell[ant-click-animating-without-extra-node="true"]::after { + display: none!important; + } +} diff --git a/src/tabviews/zshare/actionList/popupbutton/index.jsx b/src/tabviews/zshare/actionList/popupbutton/index.jsx new file mode 100644 index 0000000..f089b72 --- /dev/null +++ b/src/tabviews/zshare/actionList/popupbutton/index.jsx @@ -0,0 +1,183 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import {connect} from 'react-redux' +import { is, fromJS } from 'immutable' +import { Button, Modal, notification } from 'antd' + +import asyncSpinComponent from '@/utils/asyncSpinComponent' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import './index.scss' + +const SubTabTable = asyncSpinComponent(() => import('@/tabviews/subtabtable')) + +class NormalButton extends Component { + static propTpyes = { + show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 + BID: PropTypes.string, // 涓昏〃ID + BData: PropTypes.any, // 涓昏〃鏁版嵁 + selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 + Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� + MenuID: PropTypes.string, // 鑿滃崟ID + btn: PropTypes.object, // 鎸夐挳 + setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� + triggerBtn: PropTypes.any, + } + + state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + visible: false, + popData: null, + primaryId: '', + loading: false, + } + + /** + * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { + this.actionTrigger(nextProps.triggerBtn.data) + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 瑙﹀彂鎸夐挳鎿嶄綔 + */ + actionTrigger = (record) => { + const { setting, Tab, BID, btn, selectedData } = this.props + + if (Tab && Tab.supMenu && !BID) { + notification.warning({ + top: 92, + message: '闇�瑕佷笂绾т富閿�硷紒', + duration: 5 + }) + return + } + + let data = [] + + if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� + data = [record] + } else { + data = selectedData || [] + } + + if (btn.Ot === 'requiredSgl' && data.length !== 1) { + // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 + notification.warning({ + top: 92, + message: this.state.dict['main.action.confirm.selectSingleLine'], + duration: 5 + }) + return + } else if (!setting.primaryKey) { + // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� + notification.warning({ + top: 92, + message: '鏈缃富閿紒', + duration: 5 + }) + return + } else if (setting.tabType === 'subtab') { + notification.warning({ + top: 92, + message: '寮圭獥椤甸潰涓嶆敮鎸佹璁剧疆锛�', + duration: 5 + }) + return + } + + let _data = null + let primaryId = '' + + if (btn.Ot === 'requiredSgl') { + _data = data[0] + primaryId = _data[setting.primaryKey] || '' + } + + this.setState({ + loading: true, + popData: _data, + primaryId: primaryId, + visible: true + }) + this.props.updateStatus('start') + } + + // 鎿嶄綔鍚庡埛鏂颁富琛� + reloadtable = () => { + this.props.updateStatus('refresh', 'grid', true) + } + + /** + * @description 寮圭獥鍏抽棴 + */ + popclose = () => { + const { btn } = this.props + + this.setState({ + visible: false, + loading: false + }) + + this.props.updateStatus('refresh', btn.popClose) + } + + render() { + const { btn, show } = this.props + const { loading, popData, primaryId } = this.state + + return ( + <div className="mk-btn-wrap"> + {!show ? <Button + className={'mk-btn mk-' + btn.class} + icon={btn.icon} + onClick={() => {this.actionTrigger()}} + loading={loading} + >{btn.label}</Button> : null} + {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null} + {show === 'text' ? <Button className="action-cell" loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + <Modal + className="popview-modal" + title={btn.label} + width={'80vw'} + maskClosable={false} + visible={this.state.visible} + onCancel={this.popclose} + footer={[ + <Button key="close" onClick={this.popclose}>{this.state.dict['main.close']}</Button> + ]} + destroyOnClose + > + <SubTabTable + BID={popData ? primaryId : this.props.BID} + BData={popData || this.props.BData} + SupMenuID={this.props.MenuID} + MenuID={btn.linkTab} + refreshSupView={this.reloadtable} + /> + </Modal> + </div> + ) + } +} + +const mapStateToProps = (state) => { + return { + tabviews: state.tabviews, + } +} + +const mapDispatchToProps = () => { + return {} +} + +export default connect(mapStateToProps, mapDispatchToProps)(NormalButton) \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/popupbutton/index.scss b/src/tabviews/zshare/actionList/popupbutton/index.scss new file mode 100644 index 0000000..e9a2a7d --- /dev/null +++ b/src/tabviews/zshare/actionList/popupbutton/index.scss @@ -0,0 +1,10 @@ +.mk-btn-wrap { + display: inline-block; + .action-cell { + border: 0; + background: transparent !important; + } + .action-cell[ant-click-animating-without-extra-node="true"]::after { + display: none!important; + } +} diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index c6d4324..c739394 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -1,85 +1,84 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import moment from 'moment' +import {connect} from 'react-redux' import { is, fromJS } from 'immutable' -import { Button, Affix, Modal, notification, Spin, message } from 'antd' +import { Button, Modal, notification, message } from 'antd' + +import Api from '@/api' import Utils from '@/utils/utils.js' import options from '@/store/options.js' -import Api from '@/api' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import asyncSpinComponent from '@/utils/asyncSpinComponent' import './index.scss' +const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) +const { confirm } = Modal let socket = null class PrintButton extends Component { static propTpyes = { - menuType: PropTypes.any, // 鑿滃崟绫诲瀷锛屾櫘閫氳彍鍗曟垨HS + show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 BID: PropTypes.string, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 + selectedData: 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, // 瀛楀吀椤� + btn: PropTypes.object, // 鎸夐挳 setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� - refreshdata: PropTypes.func, // 鎵ц瀹屾垚鍚庢暟鎹埛鏂� - triggerPopview: PropTypes.func, // 寮圭獥鏍囩椤佃Е鍙� - getexceloutparam: PropTypes.func, // 鑾峰彇excel瀵煎嚭鏁版嵁 - gettableselected: PropTypes.func, // 鑾峰彇琛ㄦ牸涓暟鎹� + updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� triggerBtn: PropTypes.any, } state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, visible: false, formdata: null, tabledata: null, - confirmLoading: false, - execAction: null, - loadingUuid: '', - btnloading: false, - configMap: {}, - running: false, + btnconfig: null, + loading: false, loadingNumber: '' } /** - * @description 涓婄骇鑿滃崟id鍙樺寲鏃讹紝鍒锋柊鏁版嵁 + * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 */ UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.parentId === this.props.MenuID) { - if (!this.state.loadingUuid && !this.state.visible && !this.state.running) { - let _btn = nextProps.triggerBtn.button - if (!_btn.OpenType) { - _btn = this.props.actions.filter(item => item.uuid === _btn.uuid)[0] - } - if (_btn) { - this.actionTrigger(_btn, nextProps.triggerBtn.data) - } - } + if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { + this.actionTrigger(nextProps.triggerBtn.data) } } - refreshdata = (item, type) => { - this.props.refreshdata(item, type) + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 鎸夐挳鐘舵�佹敼鍙� + */ + updateStatus = (type) => { + if (type === 'start') { + this.setState({ + loading: true + }) + this.props.updateStatus('start') + } else if (type === 'over') { + this.setState({ + loading: false + }) + this.props.updateStatus('over') + } } /** * @description 瑙﹀彂鎸夐挳鎿嶄綔 */ - actionTrigger = (item, record) => { - const { setting, type, Tab, BID } = this.props + actionTrigger = (record) => { + const { setting, Tab, BID, btn, selectedData } = this.props - if (this.state.loadingUuid || this.state.visible || this.state.running) { - notification.warning({ - top: 92, - message: '浠诲姟鎵ц涓紝璇风◢鍚庯紒', - duration: 5 - }) - return - } - - if (type === 'sub' && Tab && Tab.supMenu && !BID) { + if (Tab && Tab.supMenu && !BID) { notification.warning({ top: 92, message: '闇�瑕佷笂绾т富閿�硷紒', @@ -89,29 +88,31 @@ } let _this = this - let data = this.props.gettableselected() || [] + let data = [] if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� data = [record] + } else { + data = selectedData || [] } - if (item.Ot !== 'notRequired' && data.length === 0) { + if (btn.Ot !== 'notRequired' && data.length === 0) { // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾暟鎹� notification.warning({ top: 92, - message: this.props.dict['main.action.confirm.selectline'], + message: this.state.dict['main.action.confirm.selectline'], duration: 5 }) return - } else if (item.Ot === 'requiredSgl' && data.length !== 1) { + } else if (btn.Ot === 'requiredSgl' && data.length !== 1) { // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 notification.warning({ top: 92, - message: this.props.dict['main.action.confirm.selectSingleLine'], + message: this.state.dict['main.action.confirm.selectSingleLine'], duration: 5 }) return - } else if (item.Ot !== 'notRequired' && !setting.primaryKey) { + } else if (!setting.primaryKey) { // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� notification.warning({ top: 92, @@ -119,157 +120,11 @@ duration: 5 }) return - } - - if (item.OpenType === 'prompt') { - this.setState({ - running: true - }) - confirm({ - title: this.props.dict['main.action.confirm.tip'], - onOk() { - _this.setState({ - loadingUuid: item.uuid - }) - - return new Promise(resolve => { - _this.execSubmit(item, data, resolve) - }) - }, - onCancel() { - _this.setState({ - running: false - }) - } - }) - } else if (item.OpenType === 'exec') { - this.setState({loadingUuid: item.uuid}) - this.execSubmit(item, data, () => { - this.setState({loadingUuid: ''}) - }) - } else if (item.OpenType === 'pop') { - this.setState({ - execAction: item, - tabledata: data, - btnloading: true - }, () => { - this.improveAction(item) - }) - } else if (item.OpenType === 'excelOut') { - if ( - item.intertype === 'inner' && !item.innerFunc && - ((setting.interType === 'inner' && setting.innerFunc) || setting.interType === 'outer') - ) { - notification.warning({ - top: 92, - message: '瀵煎嚭鎸夐挳閰嶇疆閿欒锛�', - duration: 5 - }) - return - } - - this.triggerExcelout(item) - - } else if (item.OpenType === 'excelIn') { - if (item.verify && item.verify.sheet && item.verify.columns && item.verify.columns.length > 0) { - let primaryId = '' // 瀵煎叆鏃惰Id - if (item.Ot === 'requiredSgl') { - primaryId = data[0][setting.primaryKey] || '' - } - - this.refs.excelIn.exceltrigger(item, primaryId) - } else { - notification.warning({ - top: 92, - message: 'excel瀵煎叆楠岃瘉淇℃伅鏈缃紒', - duration: 5 - }) - } - } else if (item.OpenType === 'popview' && this.props.type !== 'subtab') { - // 寮圭獥鏍囩璁剧疆涓轰笉閫夊垯琛屾椂锛屼笉浼犻�掓暟鎹� - this.props.triggerPopview(item, item.Ot === 'notRequired' ? [] : data) - } else if (item.OpenType === 'popview' && this.props.type === 'subtab') { - notification.warning({ - top: 92, - message: '寮圭獥椤甸潰涓嶆敮鎸佹璁剧疆锛�', - duration: 5 - }) - } else if (item.OpenType === 'innerpage') { - let Id = data[0][setting.primaryKey] - - if (item.pageTemplate === 'print') { - let cloudmsg = '&cuid=' + (sessionStorage.getItem('CloudUserID') || '') + '&csid=' + (sessionStorage.getItem('CloudSessionUid') || '') + '&clid=' + (sessionStorage.getItem('CloudLoginUID') || '') + '&cun=' + (sessionStorage.getItem('CloudUserName') || '') - let msg = '&uid=' + sessionStorage.getItem('UserID') + '&sid=' + sessionStorage.getItem('SessionUid') + '&lid=' + sessionStorage.getItem('LoginUID') + '&un=' + sessionStorage.getItem('User_Name') - let src = '#/print/' + window.btoa('ID=' + Id + msg + cloudmsg) - window.open(src) - } else { - notification.warning({ - top: 92, - message: '椤甸潰绫诲瀷璁剧疆閿欒锛�', - duration: 5 - }) - } - } else if (item.OpenType === 'outerpage') { - let url = item.url - if (item.Ot === 'requiredSgl' && setting.primaryKey) { - url = url + '?ID=' + data[0][setting.primaryKey] - } else if (item.Ot !== 'notRequired' && !setting.primaryKey) { - let ids = data.map(_data => _data[setting.primaryKey]).join(',') - url = url + '?ID=' + ids - } - window.open(url) - } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { - this.props.triggerPopview(item, data) - } else if (item.OpenType === 'funcbutton') { - if (item.funcType === 'changeuser') { - this.changeUser(item, data) - } else if (item.funcType === 'print') { - if (item.execMode === 'pop') { - this.setState({ - execAction: item, - tabledata: data, - btnloading: true - }, () => { - this.improveAction(item) - }) - } else if (item.execMode === 'prompt') { - this.setState({ - running: true - }) - confirm({ - title: this.props.dict['main.action.confirm.tip'], - onOk() { - _this.triggerPrint(item, data) - }, - onCancel() { - _this.setState({ - running: false - }) - } - }) - } else { - this.triggerPrint(item, data) - } - } - } else { - notification.warning({ - top: 92, - message: '瀹屽杽涓�傘�傘��', - duration: 5 - }) - } - } - - /** - * @description 瑙﹀彂鎵撳嵃 - */ - triggerPrint = (btn, data, formlist = []) => { - let formdata = {} - formlist.forEach(_data => { - formdata[_data.key] = _data.value - }) - - if ( + } else if (!['requiredSgl', 'notRequired', 'requiredOnce', 'required'].includes(btn.Ot)) { + // 鏁版嵁閫夋嫨绫诲瀷鏍¢獙 + this.actionSettingError() + return + } else if ( !btn.verify || (btn.verify.printMode === 'normal' && (!btn.verify.Template || !btn.verify.linkUrl)) || (btn.verify.printMode === 'custom' && (!btn.verify.printFunc || !btn.verify.linkUrl)) @@ -282,6 +137,40 @@ return } + if (btn.execMode === 'pop') { + this.updateStatus('start') + this.setState({ + tabledata: data + }, () => { + this.improveAction() + }) + } else if (btn.execMode === 'prompt') { + this.updateStatus('start') + confirm({ + title: this.state.dict['main.action.confirm.tip'], + onOk() { + _this.triggerPrint(data) + }, + onCancel() { + _this.updateStatus('over') + } + }) + } else { + this.triggerPrint(data) + } + } + + /** + * @description 瑙﹀彂鎵撳嵃 + */ + triggerPrint = (data, formlist = []) => { + const { btn } = this.props + let formdata = {} + + formlist.forEach(_data => { + formdata[_data.key] = _data.value + }) + let printlist = [] let templates = [] let printCount = 1 @@ -289,8 +178,6 @@ if (formdata.printCount && typeof(formdata.printCount) === 'number' && formdata.printCount >= 1) { printCount = formdata.printCount } - - this.setState({loadingUuid: btn.uuid}) new Promise(resolve => { if (btn.intertype === 'inner' && !btn.innerFunc) { @@ -341,7 +228,7 @@ if (!res) return false if (btn.verify.printMode === 'custom') { - this.execCustomPrint(btn, printlist, formdata) + this.execCustomPrint(printlist, formdata) return false } @@ -395,16 +282,20 @@ }) if (!errorMsg) { - this.execPrint(btn, printlist, _temps, formdata) + this.execPrint(printlist, _temps, formdata) } else { - this.execError(errorMsg, btn) + this.execError(errorMsg) } }) } - execCustomPrint = (item, printlist, formdata) => { - this.setState({loadingUuid: ''}) - this.execSuccess(item, { + /** + * @description 鑷畾涔夋墦鍗帮紝瑙f瀽鑷畾涔塲s + */ + execCustomPrint = (printlist, formdata) => { + const { btn } = this.props + + this.execSuccess({ ErrCode: '-1', message: '', ErrMesg: '', @@ -413,15 +304,15 @@ try { // eslint-disable-next-line - let func = new Function('data', 'form', 'printer', 'notification', item.verify.printFunc) - func(printlist, formdata, item.verify, notification) + let func = new Function('data', 'form', 'printer', 'notification', btn.verify.printFunc) + func(printlist, formdata, btn.verify, notification) } catch (e) { console.warn(e) try { // eslint-disable-next-line - let evalfunc = eval('(true && function (data, form, printer, notification) {' + item.verify.printFunc + '})') - evalfunc(printlist, formdata, item.verify, notification) + let evalfunc = eval('(true && function (data, form, printer, notification) {' + btn.verify.printFunc + '})') + evalfunc(printlist, formdata, btn.verify, notification) } catch (error) { console.warn(error) notification.warning({ @@ -508,7 +399,7 @@ if (!errorMsg) { resolve({next: true, list: result}) } else { - this.execError(errorMsg, btn) + this.execError(errorMsg) resolve({next: false, list: []}) } }) @@ -548,7 +439,7 @@ resolve(res) } else { - this.execError(res, btn) + this.execError(res) resolve(false) _resolve({next: false, list: []}) } @@ -604,7 +495,7 @@ this.printOuterLoopRequest(params, btn, _list, _resolve) } } else { - this.execError(response, btn) + this.execError(response) _resolve({next: false, list: []}) } }).then(response => { @@ -620,7 +511,7 @@ this.printOuterLoopRequest(params, btn, _list, _resolve) } } else { - this.execError(response, btn) + this.execError(response) _resolve({next: false, list: []}) } }) @@ -642,7 +533,7 @@ this.printInnerLoopRequest(params, btn, _list, _resolve) } } else { - this.execError(res, btn) + this.execError(res) _resolve({next: false, list: []}) } }) @@ -770,13 +661,14 @@ } } - execPrint = (item, list, template, formdata) => { + execPrint = (list, template, formdata) => { + const { btn } = this.props let _errors = [] - let defaultPrinter = item.verify.defaultPrinter || 'lackprinter' + let defaultPrinter = btn.verify.defaultPrinter || 'lackprinter' let printers = {} - if (item.verify.printerTypeList && item.verify.printerTypeList.length > 0) { - item.verify.printerTypeList.forEach(cell => { + if (btn.verify.printerTypeList && btn.verify.printerTypeList.length > 0) { + btn.verify.printerTypeList.forEach(cell => { if (cell.printer) { printers[cell.Value] = cell.printer } @@ -870,13 +762,12 @@ }) if (list.length === 0) { - this.setState({loadingUuid: ''}) this.execError({ ErrCode: 'N', message: '鏈幏鍙栧埌鎵撳嵃淇℃伅锛�', ErrMesg: '', status: false - }, item) + }) return } else if (_errors.length > 0) { let lackerror = [] @@ -900,20 +791,19 @@ msg.push(emptyerror.join(' ; ')) } - this.setState({loadingUuid: ''}) this.execError({ ErrCode: 'N', message: msg.join(' ; ') + ' !', ErrMesg: '', status: false - }, item) + }) return } let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0] - if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + item.verify.linkUrl) { - socket = new WebSocket('ws://' + item.verify.linkUrl) + if (!socket || socket.readyState !== 1 || socket.url !== 'ws://' + btn.verify.linkUrl) { + socket = new WebSocket('ws://' + btn.verify.linkUrl) } else { if (lackItems) { let request = { @@ -927,8 +817,7 @@ socket.send(JSON.stringify(cell)) }) - this.setState({loadingUuid: ''}) - this.execSuccess(item, { + this.execSuccess({ ErrCode: 'S', message: '', ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', @@ -950,8 +839,7 @@ socket.send(JSON.stringify(cell)) }) - this.setState({loadingUuid: ''}) - this.execSuccess(item, { + this.execSuccess({ ErrCode: 'S', message: '', ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', @@ -967,13 +855,12 @@ try { data = JSON.parse(event.data) } catch { - this.setState({loadingUuid: ''}) this.execError({ ErrCode: 'N', message: event.data, ErrMesg: '', status: false - }, item) + }) data = '' } @@ -987,575 +874,31 @@ socket.send(JSON.stringify(cell)) }) - this.setState({loadingUuid: ''}) - this.execSuccess(item, { + this.execSuccess({ ErrCode: 'S', message: '', ErrMesg: '鎵撳嵃璇锋眰宸插彂鍑恒��', status: true }) } else if (data && data.message && !data.status) { - this.setState({loadingUuid: ''}) this.execError({ ErrCode: 'N', message: data.message, ErrMesg: '', status: false - }, item) + }) } } socket.onerror = () => { - this.setState({loadingUuid: ''}) this.execError({ ErrCode: 'N', - message: '鏃犳硶杩炴帴鍒�:' + item.verify.linkUrl, + message: '鏃犳硶杩炴帴鍒�:' + btn.verify.linkUrl, ErrMesg: '', status: false - }, item) - } - } - - /** - * @description 鍒囨崲鐢ㄦ埛 - */ - changeUser = (btn, data) => { - const { setting } = this.props - let _this = this - - let param = { - func: 'webapi_ChangeUser' - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } - - param[setting.primaryKey] = data[0][setting.primaryKey] - - this.setState({ - running: true - }) - confirm({ - title: this.props.dict['main.action.confirm.tip'], - onOk() { - return new Promise(resolve => { - Api.genericInterface(param).then(res => { - resolve() - if (res.status) { - sessionStorage.setItem('avatar', res.icon || '') - sessionStorage.setItem('UserID', res.UserID) - sessionStorage.setItem('SessionUid', Utils.getuuid()) - sessionStorage.setItem('LoginUID', res.LoginUID) - sessionStorage.setItem('User_Name', res.UserName) - sessionStorage.setItem('Full_Name', res.FullName) - - window.location.reload() - } else { - notification.error({ - top: 92, - message: res.message || res.ErrMesg, - duration: btn.verify && btn.verify.ntime ? btn.verify.ntime : 10 - }) - } - }) - }) - }, - onCancel() { - _this.setState({ - running: false - }) - } - }) - } - - /** - * @description 鎸夐挳鎻愪氦鎵ц - */ - execSubmit = (btn, data, _resolve, formdata) => { - const { setting, logcolumns } = this.props - - if (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop') { - this.setState({ - confirmLoading: false, - visible: false - }) - this.triggerPrint(btn, data, formdata) - return - } - if (btn.intertype === 'inner') { - // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟鍜屾暟鎹簮涓嶅彲鍚屾椂涓虹┖, 浣跨敤绯荤粺鍑芥暟鏃讹紝绫诲瀷涓嶅彲涓虹┖ - if (!btn.innerFunc && (!btn.sql || (btn.sql && !btn.sqlType))) { - this.actionSettingError() - _resolve() - return - } - - // 鎵ц鏂瑰紡涓哄琛屾嫾鎺ワ紝涓旀墦寮�鏂瑰紡涓鸿〃鍗曟椂锛屼細杞负寰幆鍙戦�佽姹� - // 鎵撳紑鏂瑰紡涓烘ā鎬佹锛屼娇鐢ㄥ唴閮ㄥ嚱鏁版坊鍔�(鏈夋壒閲忔坊鍔犲満鏅紝宸插幓闄�) - if ( - btn.Ot === 'notRequired' || - btn.Ot === 'requiredSgl' || - btn.Ot === 'requiredOnce' - ) { - - // 鍒涘缓鍑瘉鏃讹紝闇�瑕侀�夋嫨琛屾椂 - if (data.length === 0 && !btn.innerFunc && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { - notification.warning({ - top: 92, - message: '浣跨敤鍒涘缓鍑瘉鍑芥暟锛岄渶瑕侀�夋嫨琛岋紒', - duration: 5 - }) - return - } - - let param = { // 绯荤粺瀛樺偍杩囩▼ - func: 'sPC_TableData_InUpDe' - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - let primaryId = '' - - if (btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { - let ids = data.map(d => { return d[setting.primaryKey] || ''}) - ids = ids.filter(Boolean) - primaryId = ids.join(',') - } - - if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� - if (btn.innerFunc) { // 浣跨敤鑷畾涔夊嚱鏁� - param.func = btn.innerFunc - if (setting.primaryKey) { // 涓婚敭瀛樺湪鏃讹紝璁剧疆涓婚敭鍙傛暟 - param[setting.primaryKey] = primaryId - } - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } - } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 - if (btn.innerFunc) { - param.func = btn.innerFunc - - if (setting.primaryKey) { // 涓婚敭瀛樺湪鏃讹紝璁剧疆涓婚敭鍙傛暟 - param[setting.primaryKey] = primaryId - } - - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - - } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid - primaryId = '' - - if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� - let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] - if (_form) { - primaryId = _form.value - } - } - - param.ID = primaryId || Utils.getguid() - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(btn, res) - } else { - this.execError(res, btn) - } - _resolve() - }) - } else if (btn.Ot === 'required') { - let _formPrimaryId = '' - if (formdata && setting.primaryKey) { // 琛ㄥ崟涓瓨鍦ㄤ富閿瓧娈碉紝涓婚敭鍊间互琛ㄥ崟涓殑鍊间负鍑� - let _form = formdata.filter(_form => _form.key === setting.primaryKey)[0] - if (_form) { - _formPrimaryId = _form.value - } - } - - let _params = data.map((cell, index) => { - let param = { - func: 'sPC_TableData_InUpDe' - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : '' - - if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� - - if (btn.innerFunc) { - param.func = btn.innerFunc - if (setting.primaryKey) { - param[setting.primaryKey] = primaryId - } - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } - } else if (btn.OpenType === 'pop') { // 琛ㄥ崟 - if (index !== 0) { - formdata = formdata.map(_data => { - if (_data.readin && cell.hasOwnProperty(_data.key)) { - _data.value = cell[_data.key] - } - return _data - }) - } - - if (btn.innerFunc) { - param.func = btn.innerFunc - - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - - if (setting.primaryKey) { - param[setting.primaryKey] = primaryId - } - } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid - param.ID = _formPrimaryId || Utils.getguid() - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, logcolumns, this.props.Tab) // 鏁版嵁婧� - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - 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) - } - } - - return param - }) - - if (_params.length <= 20) { - let deffers = _params.map(param => { - return new Promise(resolve => { - Api.genericInterface(param).then(res => { - resolve(res) - }) - }) - }) - Promise.all(deffers).then(result => { - let iserror = false - let errorMsg = '' - result.forEach(res => { - if (res.status) { - errorMsg = res - } else { - iserror = true - errorMsg = res - } - }) - if (!iserror) { - this.execSuccess(btn, errorMsg) - } else { - this.execError(errorMsg, btn) - } - _resolve() - }) - } else { // 瓒呭嚭20涓姹傛椂寰幆鎵ц - this.innerLoopRequest(_params, btn, _resolve) - } - } else { - this.actionSettingError() - _resolve() - return - } - } else if (btn.intertype === 'outer') { - /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ - if (!btn.interface) { // 鎺ュ彛鍦板潃涓嶅瓨鍦ㄦ椂鎶ラ敊 - this.actionSettingError() - _resolve() - return - } - - let _params = [] // 璇锋眰鍙傛暟鏁扮粍 - - if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { - let param = {} - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - } - - // 鑾峰彇id - if (btn.Ot === 'notRequired') { - - } else if (btn.Ot === 'requiredSgl' && setting.primaryKey) { - param[setting.primaryKey] = data[0][setting.primaryKey] - } else if (btn.Ot === 'requiredOnce' && setting.primaryKey) { - let ids = data.map(d => { return d[setting.primaryKey]}) - param[setting.primaryKey] = ids.join(',') - } - - _params.push(param) - } else if (btn.Ot === 'required') { - // 閫夋嫨澶氳锛屽惊鐜皟鐢� - _params = data.map((cell, index) => { - let _cell = {} - - if (this.props.BID) { - _cell.BID = this.props.BID - } - - let _formparam = {} - if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 - formdata.forEach(_data => { - if (index !== 0 && _data.readin && cell.hasOwnProperty(_data.key)) { - _formparam[_data.key] = cell[_data.key] - } else { - _formparam[_data.key] = _data.value - } - }) - } - - if (setting.primaryKey) { - _cell[setting.primaryKey] = cell[setting.primaryKey] - } - - _cell = {..._formparam, ..._cell} - - return _cell - }) - } else { - this.actionSettingError() - _resolve() - return - } - - // 寰幆璋冪敤澶栭儴鎺ュ彛锛堝寘鎷唴閮ㄥ強鍥炶皟鍑芥暟锛� - this.outerLoopRequest(_params, btn, _resolve, _params.length > 20) - - } else { - this.actionSettingError() - _resolve() - return - } - } - - /** - * @description 鍐呴儴璇锋眰寰幆鎵ц - */ - innerLoopRequest = (params, btn, _resolve) => { - if (!params && params.length === 0) return - - let param = params.shift() - - this.setState({ - loadingNumber: params.length || '' - }) - - Api.genericInterface(param).then(res => { - if (res.status) { - if (params.length === 0) { - this.execSuccess(btn, res) - _resolve() - } else { - this.innerLoopRequest(params, btn, _resolve) - } - } else { - this.execError(res, btn) - _resolve() - } - }) - } - - /** - * @description 澶栭儴璇锋眰寰幆鎵ц - */ - outerLoopRequest = (params, btn, _resolve, widthNumber) => { - if (!params && params.length === 0) return - - let param = params.shift() - let _outParam = null - - if (widthNumber) { - this.setState({ - loadingNumber: params.length || '' }) } - - new Promise(resolve => { - // 鍐呴儴璇锋眰 - if (btn.innerFunc) { - param.func = btn.innerFunc - // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 - let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID - if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { - res.BID = this.props.BID - } - - resolve(res) - } else { - this.execError(res, btn) - resolve(false) - _resolve() - } - }) - } else { - resolve(param) - } - }).then(res => { - if (!res) return - // 澶栭儴璇锋眰 - _outParam = JSON.parse(JSON.stringify(res)) - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - res.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - res.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - return Api.genericInterface(res) - }).then(response => { - if (!response) return - // 鍥炶皟璇锋眰 - if (btn.callbackFunc) { - // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 - delete response.message - delete response.status - - response.func = btn.callbackFunc - - let _callbackparam = {..._outParam, ...response} - return Api.genericInterface(_callbackparam) - } else { - if (response.status) { - // 涓�娆¤姹傛垚鍔燂紝杩涜涓嬩竴椤硅姹� - - if (params.length === 0) { - this.execSuccess(btn, response) - _resolve() - } else { - this.outerLoopRequest(params, btn, _resolve, widthNumber) - } - } else { - this.execError(response, btn) - _resolve() - } - } - }).then(res => { - if (!res) return - - if (res.status) { - if (params.length === 0) { - this.execSuccess(btn, res) - _resolve() - } else { - this.outerLoopRequest(params, btn, _resolve, widthNumber) - } - } else { - this.execError(res, btn) - _resolve() - } - }) } - /** * @description 鎿嶄綔鎴愬姛鍚庡鐞� * 1銆乪xcel瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� @@ -1564,34 +907,28 @@ * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� */ - execSuccess = (btn, res) => { + execSuccess = (res) => { + const { btn } = this.props + if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 notification.success({ top: 92, - message: res.ErrMesg || this.props.dict['main.action.confirm.success'], + message: res.ErrMesg || this.state.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'] + title: res.ErrMesg || this.state.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.setState({ - loadingUuid: '', - running: false, - loadingNumber: '' + loading: false }) - this.refreshdata(btn, 'success') + this.props.updateStatus('refresh', btn.execSuccess) } /** @@ -1600,7 +937,9 @@ * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂� */ - execError = (res, btn) => { + execError = (res) => { + const { btn } = this.props + if (res.ErrCode === 'E') { Modal.error({ title: res.message || res.ErrMesg, @@ -1623,24 +962,19 @@ } this.setState({ - loadingUuid: '', - running: false, - loadingNumber: '' + loading: false }) - - this.refreshdata(btn, 'error') + + this.props.updateStatus('refresh', btn.execError) } /** * @description 鎸夐挳閰嶇疆淇℃伅閿欒鎻愮ず */ actionSettingError = () => { - this.setState({ - running: false - }) notification.warning({ top: 92, - message: this.props.dict['main.action.settingerror'], + message: this.state.dict['main.action.settingerror'], duration: 5 }) } @@ -1648,21 +982,22 @@ /** * @description 鑾峰彇鎸夐挳閰嶇疆淇℃伅 */ - improveAction = (action) => { - const { configMap, execAction } = this.state + improveAction = () => { + const { btn } = this.props + const { btnconfig } = this.state - let _config = configMap[action.uuid] - - if (_config) { - this.setState({ - execAction: {..._config, ...execAction} - }, () => { - this.improveActionForm() - }) + if (btnconfig) { + if (btnconfig.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + this.modelconfirm() + } else { + this.setState({ + visible: true + }) + } } else { Api.getSystemCacheConfig({ func: 'sPC_Get_LongParam', - MenuID: action.uuid + MenuID: btn.uuid }).then(res => { let _LongParam = '' @@ -1681,26 +1016,34 @@ message: res.message, duration: 5 }) - this.setState({ - execAction: null, - tabledata: null, - btnloading: false - }) - } else if (!_LongParam || (action.OpenType === 'pop' && _LongParam.type !== 'Modal')) { + this.updateStatus('over') + } else if (!_LongParam || (btn.OpenType === 'pop' && _LongParam.type !== 'Modal')) { notification.warning({ top: 92, message: '鏈幏鍙栧埌鎸夐挳閰嶇疆淇℃伅锛�', duration: 5 }) - this.setState({ - execAction: null, - tabledata: null, - btnloading: false - }) + this.updateStatus('over') } else { if (_LongParam.groups.length > 0) { _LongParam.groups.forEach(group => { group.sublist = group.sublist.filter(cell => { + // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 + if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { + let _option = Utils.getSelectQueryOptions(cell) + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + _option.sql = _option.sql.replace(/\$@/ig, '/*') + _option.sql = _option.sql.replace(/@\$/ig, '*/') + } else { + _option.sql = _option.sql.replace(/@\$|\$@/ig, '') + } + + cell.data_sql = Utils.formatOptions(_option.sql) + cell.arr_field = _option.field + } + + // 瀛楁鏉冮檺榛戝悕鍗� if (!cell.blacklist || cell.blacklist.length === 0) return true let _black = cell.blacklist.filter(v => { @@ -1716,6 +1059,22 @@ }) } else { _LongParam.fields = _LongParam.fields.filter(cell => { + // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 + if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { + let _option = Utils.getSelectQueryOptions(cell) + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + _option.sql = _option.sql.replace(/\$@/ig, '/*') + _option.sql = _option.sql.replace(/@\$/ig, '*/') + } else { + _option.sql = _option.sql.replace(/@\$|\$@/ig, '') + } + + cell.data_sql = Utils.formatOptions(_option.sql) + cell.arr_field = _option.field + } + + // 瀛楁鏉冮檺榛戝悕鍗� if (!cell.blacklist || cell.blacklist.length === 0) return true let _black = cell.blacklist.filter(v => { @@ -1731,777 +1090,19 @@ } this.setState({ - configMap: {...configMap, [action.uuid]: _LongParam}, - execAction: {..._LongParam, ...execAction} + btnconfig: _LongParam }, () => { - this.improveActionForm() - }) - } - }) - } - } - - /** - * @description 鑾峰彇涓嬫媺琛ㄥ崟閫夐」淇℃伅 - */ - improveActionForm = () => { - const { configMap, execAction } = this.state - let subfields = [] - - if (execAction.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず锛屼笉璇锋眰涓嬫媺鑿滃崟淇℃伅 - this.setState({ - btnloading: false - }) - this.modelconfirm() - return - } - - if (execAction.groups.length > 0) { - execAction.groups.forEach(group => { - group.sublist.forEach(field => { - if ((field.type === 'select' || field.type === 'link' || field.type === 'multiselect') && field.resourceType === '1' && field.dataSource) { - subfields.push(field) - } - }) - }) - } else { - execAction.fields.forEach(field => { - if ((field.type === 'select' || field.type === 'link' || field.type === 'multiselect') && field.resourceType === '1' && field.dataSource) { - subfields.push(field) - } - }) - } - - if (subfields.length === 0) { - this.setState({ - visible: true, - btnloading: false - }) - return - } - - let deffers = subfields.map(item => { - let _option = Utils.getSelectQueryOptions(item) - let _sql = Utils.formatOptions(_option.sql) - let isSSO = item.database === 'sso' - - let param = { - func: 'sPC_Get_SelectedList', - LText: _sql, - obj_name: 'data', - arr_field: _option.field - } - - if (this.props.BID) { - param.BID = this.props.BID - } - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - return new Promise(resolve => { - Api.getSystemCacheConfig(param, isSSO).then(res => { - res.search = item - resolve(res) - }) - }) - }) - - let _field = {} - let error = '' - Promise.all(deffers).then(result => { - result.forEach(res => { - if (res.status) { - let options = res.data.map(cell => { - let item = { - key: Utils.getuuid(), - Value: cell[res.search.valueField], - Text: cell[res.search.valueText] - } - - if (res.search.type === 'link') { - item.parentId = cell[res.search.linkField] - } else if (res.search.type === 'select' && res.search.linkSubField && res.search.linkSubField.length > 0) { - res.search.linkSubField.forEach(_field => { - item[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' + if (_LongParam.setting.display === 'prompt') { // 濡傛灉琛ㄥ崟浠ユ槸鍚︽灞曠ず + this.modelconfirm() + } else { + this.setState({ + visible: true }) } - - return item - }) - - _field[res.search.uuid] = options - } else { - error = res - } - }) - - if (error) { - notification.warning({ - top: 92, - message: error.message, - duration: 5 - }) - } - - this.setState({ - configMap: {...configMap, ..._field} - }, () => { - this.setState({ - visible: true, - btnloading: false - }) - }) - }) - } - - /** - * @description Excel 瀵煎叆 - */ - getexceldata = (data, btn, errors, primaryId) => { - if (errors) { - if (errors === 'notexit') { - notification.warning({ - top: 92, - message: '宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬩笉瀛樺湪锛�', - duration: 5 - }) - } else if (errors === 'empty') { - notification.warning({ - top: 92, - message: '宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬩负绌猴紒', - duration: 5 - }) - } else if (errors === 'headerError') { - notification.warning({ - top: 92, - message: '宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬭〃澶磋缃敊璇紒', - duration: 5 - }) - } - - return - } - - if (!data || data.length === 0) { - notification.warning({ - top: 92, - message: '鏈幏鍙栧埌宸ヤ綔琛ㄣ��' + btn.verify.sheet + '銆嬫暟鎹紒', - duration: 5 - }) - return - } - - let result = Utils.getExcelInSql(btn, data, this.props.dict) - if (result.errors) { - notification.warning({ - top: 92, - message: result.errors, - duration: 5 - }) - return - } - - let param = { - ID: primaryId - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - result.sql = result.sql.replace(/\$@/ig, '/*') - result.sql = result.sql.replace(/@\$/ig, '*/') - } else { - result.sql = result.sql.replace(/@\$|\$@/ig, '') - } - - param.LText = Utils.formatOptions(result.sql) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - this.setState({loadingUuid: btn.uuid}) - - if (btn.intertype === 'inner' && !btn.innerFunc) { // 绯荤粺瀛樺偍杩囩▼ - param.func = 'sPC_TableData_InUpDe' - - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(btn, res) - } else { - this.execError(res, btn) - } - }) - } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋� - param.func = btn.innerFunc - - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(btn, res) - } else { - this.execError(res, btn) - } - }) - } else if (btn.intertype === 'outer') { // 澶栭儴鎺ュ彛 - let _outParam = null - - new Promise(resolve => { - // 鍐呴儴璇锋眰 - if (btn.innerFunc) { - param.func = btn.innerFunc - // 瀛樺湪鍐呴儴鍑芥暟鏃讹紝鏁版嵁棰勫鐞� - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 - let keys = Object.keys(res) // 鎻愪氦澶栭儴鎺ュ彛鍓嶏紝娣诲姞BID - if (this.props.BID && keys.filter(key => key.toLowerCase() === 'bid').length === 0) { - res.BID = this.props.BID - } - resolve(res) - } else { - this.execError(res, btn) - resolve(false) - } - }) - } else { - resolve(param) - } - }).then(res => { - if (!res) return - // 澶栭儴璇锋眰 - _outParam = JSON.parse(JSON.stringify(res)) - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - return Api.genericInterface(res) - }).then(response => { - if (!response) return - // 鍥炶皟璇锋眰 - if (btn.callbackFunc) { - // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 - delete response.message - delete response.status - - response.func = btn.callbackFunc - - let _callbackparam = {..._outParam, ...response} - return Api.genericInterface(_callbackparam) - } else { - if (response.status) { - this.execSuccess(btn, response) - } else { - this.execError(response, btn) - } - } - }).then(res => { - if (!res) return - - if (res.status) { - this.execSuccess(btn, res) - } else { - this.execError(res, btn) - } - }) - } - } - - /** - * @description Excel 瀵煎嚭 - */ - triggerExcelout = (btn) => { - let viewParam = this.props.getexceloutparam() - let name = `${viewParam.menuName}${moment().format('YYYYMMDDHHmmss')}.xlsx` - let pageSize = 1000 - - if (btn.search === 'true' && viewParam.search && viewParam.search.length > 0) { - let valid = false - viewParam.search.forEach(item => { - if (Array.isArray(item.value)) { - if (item.value.length > 0) { - valid = true - } - } else if (item.value || item.value === 0) { - valid = true - } - }) - - if (!valid) { - notification.warning({ - top: 92, - message: '鎼滅储鏉′欢涓嶅彲涓虹┖锛�', - duration: 5 - }) - return - } - } - - this.setState({loadingUuid: btn.uuid}) - - if (btn.pagination !== 'true') { - if (btn.intertype === 'inner' && !btn.innerFunc) { // 浣跨敤绯荤粺鍑芥暟 - if (!viewParam.arr_field) { - this.execError({ErrCode: 'N', message: '鏈缃樉绀哄垪锛�'}, btn) - return - } - - let param = this.getExcelDefaultParam(viewParam.arr_field, viewParam.orderBy, viewParam.search) - - Api.genericInterface(param).then(result => { - if (result.status) { - this.exportExcel(result.data, btn, name) - } else { - this.execError(result, btn) - } - }) - } else if (btn.intertype === 'inner' && btn.innerFunc) { // 浣跨敤鍐呴儴鍑芥暟 - let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) - param.func = btn.innerFunc - - Api.genericInterface(param).then(result => { - if (result.status) { - this.exportExcel(result.data, btn, name) - } else { - this.execError(result, btn) - } - }) - } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟 - let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } - - if (btn.outerFunc) { - param.func = btn.outerFunc - } - - Api.genericInterface(param).then(result => { - if (result.status) { - this.exportExcel(result.data, btn, name) - } else { - this.execError(result, btn) - } - }) - } else if (btn.intertype === 'outer' && btn.innerFunc) { - let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) - param.func = btn.innerFunc - - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - res.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - Api.genericInterface(res).then(result => { - if (result.status) { - this.exportExcel(result.data, btn, name) - } else { - this.execError(result, btn) - } - }) - } else { - this.execError(res, btn) - } - }) - } else { - this.execError({ErrCode: 'N', message: '瀵煎嚭鎸夐挳璁剧疆閿欒锛�'}, btn) - } - } else if (btn.intertype === 'outer' && btn.innerFunc) { // 鍒嗛〉锛屼笖涓ゆ璇锋眰 - this.getExcelOutDoubleData(btn, viewParam, 1, pageSize, [], name) - } else { // 鍒嗛〉锛屼竴姝ヨ姹� - this.getExcelOutData(btn, viewParam, 1, pageSize, [], name) - } - } - - /** - * @description 涓ゆ鍒嗛〉璇锋眰 - */ - getExcelOutDoubleData = (btn, viewParam, pageIndex, pageSize, data, name) => { - let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) - param.func = btn.innerFunc - - Api.genericInterface(param).then(res => { - if (res.status) { - delete res.ErrCode - delete res.ErrMesg - delete res.message - delete res.status - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - Api.genericInterface(res).then(result => { - if (result.status) { - if (!result.data) { - this.execError({ErrCode: 'N', message: '鏈幏鍙栧埌鏁版嵁淇℃伅锛�'}, btn) - } else if (result.data.length >= pageSize) { - data = data.concat(result.data) - pageIndex++ - this.getExcelOutDoubleData(btn, viewParam, pageIndex, pageSize, data, name) - } else { - data = data.concat(result.data) - this.exportExcel(data, btn, name) - } - } else { - this.execError(result, btn) - } - }) - } else { - this.execError(res, btn) - } - }) - } - - /** - * @description 涓�姝ュ垎椤佃姹� - */ - getExcelOutData = (btn, viewParam, pageIndex, pageSize, data, name) => { - let param = null - if (btn.intertype === 'inner' && !btn.innerFunc) { // 浣跨敤绯荤粺鍑芥暟 - if (!viewParam.arr_field) { - this.execError({ErrCode: 'N', message: '鏈缃樉绀哄垪锛�'}, btn) - return - } - - 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 - - } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟 - param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) - - if (this.props.menuType === 'HS') { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - param.rduri = btn.interface - } - } - - if (btn.outerFunc) { - param.func = btn.outerFunc - } - } - - Api.genericInterface(param).then(result => { - if (result.status) { - if (!result.data) { - this.execError({ErrCode: 'N', message: '鏈幏鍙栧埌鏁版嵁淇℃伅锛�'}, btn) - } else if (result.data.length >= pageSize) { - data = data.concat(result.data) - pageIndex++ - this.getExcelOutData(btn, viewParam, pageIndex, pageSize, data, name) - } else { - data = data.concat(result.data) - this.exportExcel(data, btn, name) - } - } else { - this.execError(result, btn) - } - }) - } - - /** - * @description Excel 鐢熸垚 - */ - exportExcel = (data, btn, name) => { - const { logcolumns } = this.props - if (data && data.length > 0) { - try { - let _header = [] - let _topRow = {} - let colwidth = [] - - let hidecolumns = [] - - let verifyColumn = {} // 璁板綍楠岃瘉淇℃伅涓殑Excel鍒楅厤缃� - if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) { - btn.verify.columns.forEach(col => { - verifyColumn[col.Column] = col }) } - - logcolumns.forEach(col => { - if (col.Hide === 'true') { - hidecolumns.push(col.field) - return - } - if (!data[0].hasOwnProperty(col.field)) return - if (_topRow[col.field]) return - - if (verifyColumn[col.field]) { // 浼樺厛浣跨敤楠岃瘉淇℃伅涓殑鍒楄缃� - _header.push(col.field) - _topRow[col.field] = verifyColumn[col.field].Text - - colwidth.push({width: verifyColumn[col.field].Width}) - } else { - _header.push(col.field) - _topRow[col.field] = col.label - - let _colwidth = Math.floor(col.Width / 6) - - if (!_colwidth || _colwidth < 5) { - _colwidth = 5 - } - - colwidth.push({width: _colwidth}) - } - }) - - if (btn.verify && btn.verify.columns && btn.verify.columns.length > 0) { - btn.verify.columns.forEach(col => { - if (hidecolumns.includes(col.Column)) return - if (!data[0].hasOwnProperty(col.Column)) return - if (_topRow[col.Column]) return - - _header.push(col.Column) - _topRow[col.Column] = col.Text - - colwidth.push({width: col.Width}) - }) - } - - Object.keys(data[0]).forEach(key => { - if (hidecolumns.includes(key)) return - if (_topRow[key]) return - - _header.push(key) - _topRow[key] = key - - colwidth.push({width: 12}) - }) - - let table = [] - - table.push(_topRow) - - data.forEach(item => { - let _row = {} - _header.forEach(field => { - _row[field] = item[field] - }) - - table.push(_row) - }) - - const ws = XLSX.utils.json_to_sheet(table, {header: _header, skipHeader: true}) - - ws['!cols'] = colwidth - - const wb = XLSX.utils.book_new() - XLSX.utils.book_append_sheet(wb, ws, 'Sheet1') - - XLSX.writeFile(wb, name) - - this.execSuccess(btn, {ErrCode: 'S', ErrMesg: '瀵煎嚭鎴愬姛锛�'}) - } catch { - this.execError({ErrCode: 'N', message: 'Excel鐢熸垚澶辫触锛�'}, btn) - } - - } else { - this.execError({ErrCode: 'N', message: '鏈煡璇㈠埌瀵煎嚭鏁版嵁锛�'}, btn) - } - } - - /** - * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� - */ - getExcelCustomParam = (orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { - let _search = Utils.formatCustomMainSearch(search) - - let param = { - OrderCol: orderBy, - ..._search - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - if (pagination) { - param.PageIndex = pageIndex - param.PageSize = pageSize - } - - return param - } - - /** - * @description 鑾峰彇榛樿瀛樺偍杩囩▼璇锋眰鍙傛暟 - */ - getExcelDefaultParam = (arr_field, orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => { - const { setting } = this.props - - let _search = Utils.joinMainSearchkey(search) - - _search = _search ? 'where ' + _search : '' - - let param = { - func: 'sPC_Get_TableData', - obj_name: 'data', - arr_field: arr_field, - custom_script: setting.customScript || '', - default_sql: setting.default || 'true', - dataM: this.props.dataManager ? 'Y' : '' - } - - if (this.props.BID) { - param.BID = this.props.BID - } - - let _dataresource = setting.dataresource - - if (/\s/.test(_dataresource)) { - _dataresource = '(' + _dataresource + ') tb' - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - _dataresource = _dataresource.replace(/\$@/ig, '/*') - _dataresource = _dataresource.replace(/@\$/ig, '*/') - param.custom_script = param.custom_script.replace(/\$@/ig, '/*') - param.custom_script = param.custom_script.replace(/@\$/ig, '*/') - } else { - _dataresource = _dataresource.replace(/@\$|\$@/ig, '') - param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '') - } - - let regoptions = null - if (setting.queryType === 'statistics' || param.custom_script) { - let allSearch = Utils.getAllSearchOptions(search) - - regoptions = allSearch.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` - } - }) - - regoptions.push({ - reg: new RegExp('@orderBy@', 'ig'), - value: orderBy - }, { - reg: new RegExp('@pageSize@', 'ig'), - value: pageSize - }, { - reg: new RegExp('@pageIndex@', 'ig'), - value: pageIndex }) } - - if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 - regoptions.forEach(item => { - _dataresource = _dataresource.replace(item.reg, item.value) - }) - _search = '' - } - - let LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` - - if (pagination) { - LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows` - } - - if (param.custom_script) { - regoptions.forEach(item => { - param.custom_script = param.custom_script.replace(item.reg, item.value) - }) - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.custom_script = param.custom_script.replace(/\$@/ig, '/*') - param.custom_script = param.custom_script.replace(/@\$/ig, '*/') - } else { - param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '') - } - - param.custom_script = Utils.formatOptions(param.custom_script) - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - LText = LText.replace(/\$@/ig, '/*') - LText = LText.replace(/@\$/ig, '*/') - } else { - LText = LText.replace(/@\$|\$@/ig, '') - } - - param.LText = Utils.formatOptions(LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - param.DateCount = '' - - return param } /** @@ -2510,15 +1111,10 @@ handleOk = () => { this.formRef.handleConfirm().then(res => { this.setState({ - confirmLoading: true + visible: false }) - - this.execSubmit(this.state.execAction, this.state.tabledata, () => { - this.setState({ - confirmLoading: false - }) - }, res) - }, () => {}) + this.triggerPrint(this.state.tabledata, res) + }) } /** @@ -2526,23 +1122,23 @@ */ handleCancel = () => { this.setState({ - visible: false, - confirmLoading: false + visible: false }) + this.updateStatus('over') } modelconfirm = () => { const { BData } = this.props - const { execAction, tabledata } = this.state + const { btnconfig, tabledata } = this.state let _this = this let _fields = [] - if (execAction.groups.length > 0) { - execAction.groups.forEach(group => { + if (btnconfig.groups.length > 0) { + btnconfig.groups.forEach(group => { _fields = [..._fields, ...group.sublist] }) } else { - _fields = execAction.fields + _fields = btnconfig.fields } let result = _fields.map(item => { @@ -2557,6 +1153,12 @@ _initval = BData[item.field] } else if (_readin && tabledata[0] && tabledata[0].hasOwnProperty(item.field)) { _initval = tabledata[0][item.field] + } else if (item.type === 'date' && _initval) { + _initval = moment().subtract(_initval, 'days').format('YYYY-MM-DD') + } 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') } let _fieldlen = item.fieldlength || 50 @@ -2576,26 +1178,13 @@ } }) - _this.setState({ - running: true - }) - confirm({ - title: this.props.dict['main.action.confirm.tip'], + title: this.state.dict['main.action.confirm.tip'], onOk() { - _this.setState({ - loadingUuid: execAction.uuid - }) - - return new Promise(resolve => { - _this.execSubmit(execAction, tabledata, resolve, result) - }) + _this.triggerPrint(tabledata, result) }, onCancel() { - _this.setState({ - loadingUuid: '', - running: false - }) + _this.updateStatus('over') } }) } @@ -2604,31 +1193,23 @@ * @description 鏄剧ず妯℃�佹 */ getModels = () => { - const { execAction } = this.state + const { setting, BID } = this.props + const { btnconfig } = this.state - if (!execAction || !this.state.visible) return null + if (!this.state.visible || !btnconfig || !btnconfig.setting) return null - let title = '' - let width = '62vw' + let title = btnconfig.setting.title + let width = btnconfig.setting.width + 'vw' let clickouter = false let container = document.body - if (execAction && execAction.setting) { - title = execAction.setting.title - width = execAction.setting.width + 'vw' - - if (this.props.type === 'main' && 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 (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) { + width = btnconfig.setting.width + '%' + container = () => document.getElementById(this.props.ContainerId) } - if (this.props.type === 'subtab') { - container = document.body + if (btnconfig.setting.clickouter === 'close') { + clickouter = true } return ( @@ -2640,15 +1221,14 @@ visible={this.state.visible} width={width} onOk={this.handleOk} - confirmLoading={this.state.confirmLoading} onCancel={this.handleCancel} destroyOnClose > <MutilForm - dict={this.props.dict} - action={execAction} + dict={this.state.dict} + BID={BID} + action={btnconfig} inputSubmit={this.handleOk} - configMap={this.state.configMap} data={this.state.tabledata[0]} BData={this.props.BData} wrappedComponentRef={(inst) => this.formRef = inst} @@ -2658,62 +1238,37 @@ } render() { - const { loadingUuid, btnloading, loadingNumber } = this.state + const { btn, show } = this.props + const { loadingNumber, loading } = this.state - let fixed = this.props.setting.actionfixed && this.props.type === 'main' // 鎸夐挳鏄惁鍥哄畾鍦ㄥご閮� - - if (fixed) { - return ( - <Affix offsetTop={48}> - <div className="button-list toolbar-button" id={fixed ? this.props.MenuID + 'mainaction' : ''}> - {this.props.actions.map((item, index) => { - let label = item.label - if (loadingUuid === item.uuid && loadingNumber !== '') { - label = label + '(' + loadingNumber + ')' - } - - return ( - <Button - className={'mk-btn mk-' + item.class} - icon={item.icon} - key={'action' + index} - onClick={() => {this.actionTrigger(item)}} - loading={loadingUuid === item.uuid} - >{label}</Button> - ) - })} - {this.getModels()} - {btnloading && <Spin size="large" />} - <ExcelIn MenuID={this.props.MenuID} returndata={this.getexceldata} ref="excelIn" /> - </div> - </Affix> - ) - } else { - return ( - <div className="button-list toolbar-button" id={fixed ? this.props.MenuID + 'mainaction' : ''}> - {this.props.actions.map((item, index) => { - let label = item.label - if (loadingUuid === item.uuid && loadingNumber !== '') { - label = label + '(' + loadingNumber + ')' - } - - return ( - <Button - className={'mk-btn mk-' + item.class} - icon={item.icon} - key={'action' + index} - onClick={() => {this.actionTrigger(item)}} - loading={loadingUuid === item.uuid} - >{label}</Button> - ) - })} - {this.getModels()} - {btnloading && <Spin size="large" />} - <ExcelIn MenuID={this.props.MenuID} returndata={this.getexceldata} ref="excelIn" /> - </div> - ) - } + return ( + <div className="mk-btn-wrap"> + {!show ? <Button + className={'mk-btn mk-' + btn.class} + icon={btn.icon} + onClick={() => {this.actionTrigger()}} + loading={loading} + >{loadingNumber ? `(${loadingNumber})` : '' + btn.label}</Button> : null} + {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} loading={loading} onClick={() => {this.actionTrigger()}}></Button> : null} + {show === 'text' ? <Button className="action-cell" loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} loading={loading} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + {this.getModels()} + </div> + ) } } -export default PrintButton \ No newline at end of file +const mapStateToProps = (state) => { + return { + tabviews: state.tabviews, + menuType: state.editLevel, + permRoles: state.permRoles, + dataManager: state.dataManager + } +} + +const mapDispatchToProps = () => { + return {} +} + +export default connect(mapStateToProps, mapDispatchToProps)(PrintButton) \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/printbutton/index.scss b/src/tabviews/zshare/actionList/printbutton/index.scss index 4f63e95..e9a2a7d 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.scss +++ b/src/tabviews/zshare/actionList/printbutton/index.scss @@ -1,228 +1,10 @@ -.card-row-box { - min-height: 50px; - padding: 0px 10px; - margin-bottom: 15px; - - .chart-card-box { - padding: 0 10px; - .anticon { - margin-right: 0px; - } +.mk-btn-wrap { + display: inline-block; + .action-cell { + border: 0; + background: transparent !important; } - > .chart-card-box { - margin-bottom: 20px; - } - - .chart-card-box:not(.ant-col) { - display: inline-block; - margin-bottom: 20px; - } - - >.ant-tabs { - .ant-tabs-bar { - border: 0; - margin: 0; - .ant-tabs-nav-scroll { - .ant-tabs-tab { - margin: 0; - padding: 12px 5px; - cursor: default; - - .chart-card-box:not(.ant-col) { - margin-bottom: 0px; - } - } - } - } - } - - .ant-empty { - .ant-empty-image { - height: 60px; - } - } - - .loading-mask { - position: absolute; - left: 20px; - top: 0; - right: 20px; - bottom: 0; - display: flex; - align-items: center; - justify-content: center; - text-align: justify; - z-index: 1; - - .ant-spin-blur { - position: absolute; - width: 100%; - height: 100%; - opacity: 0.5; - background: #ffffff; - } - } - - .ant-card.chart-card { - transition: all 0.3s; - - .ant-card-head { - min-height: 40px; - line-height: 2; - .ant-card-head-title { - font-weight: 500; - } - .ant-card-extra { - color: #1890ff; - .action-cell { - cursor: pointer; - } - } - } - .ant-card-actions { - height: 48px; - } - } - - .ant-card.chart-card:not(.ant-card-bordered) { - .ant-card-head { - border-bottom: 0; - } - .ant-card-actions { - border-top: 0; - } - } - - .ant-card.chart-card.chart-card-selected { - border: 1px solid #1890ff; - box-shadow: 0px 0px 8px #c4ebfd; - } - - .ant-card.chart-card .ant-card-body { - padding: 0px; - zoom: 1; - - .ant-card-meta.switch { - cursor: pointer; - } - - .ant-card-meta { - margin: 0px; - padding: 20px; - position: relative; - white-space: normal; - - .ant-card-meta-avatar { - padding-top: 0px; - padding-left: 0px; - } - - .ant-avatar-image { - box-sizing: border-box; - margin: 0; - padding: 0; - font-variant: tabular-nums; - line-height: 1.5; - list-style: none; - font-feature-settings: 'tnum'; - position: relative; - display: inline-block; - overflow: hidden; - color: #fff; - white-space: nowrap; - text-align: center; - vertical-align: middle; - border-radius: 50%; - - img { - width: 100%; - } - .font { - background: transparent; - } - } - .ant-card-meta-title { - font-size: 14px; - } - .ant-card-meta-detail > div { - height: 23px; - vertical-align: top; - } - .ant-card-meta-detail > div:not(:last-child) { - margin-bottom: 2px; - } - .helf { - display: inline-block; - width: 50%; - } - .third { - display: inline-block; - width: 33.3%; - } - .align-center { - text-align: center; - } - .align-right { - text-align: right; - } - } - } - - .chart-title { - margin-bottom: 10px; - margin-left: 0px; - margin-right: 0px; - } - - .ant-card.chart-card { - .ant-card-actions { - li { - color: rgba(0, 0, 0, 0.45); - span { - overflow: hidden; - word-break: break-word; - white-space: nowrap; - text-overflow: ellipsis; - } - .anticon { - width: unset; - margin-right: 3px; - color: rgba(0, 0, 0, 0.45); - } - } - li:hover { - color: #1890ff; - .anticon { - color: #1890ff; - } - } - } - } - .ant-card.chart-card.background { - .ant-card-meta-title { - color: unset; - } - .ant-card-meta-description { - color: unset; - } - .ant-card-head { - color: unset; - .ant-card-head-title { - color: unset; - } - } - .ant-card-actions { - background: transparent; - li { - white-space: nowrap; - color: unset; - .anticon { - color: unset; - } - } - } - } - .clear { - clear: both; + .action-cell[ant-click-animating-without-extra-node="true"]::after { + display: none!important; } } diff --git a/src/tabviews/zshare/actionList/tabbutton/index.jsx b/src/tabviews/zshare/actionList/tabbutton/index.jsx new file mode 100644 index 0000000..dab08e7 --- /dev/null +++ b/src/tabviews/zshare/actionList/tabbutton/index.jsx @@ -0,0 +1,143 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import {connect} from 'react-redux' +import { is, fromJS } from 'immutable' +import { Button, notification } from 'antd' + +import { modifyTabview } from '@/store/action' +import zhCN from '@/locales/zh-CN/main.js' +import enUS from '@/locales/en-US/main.js' +import './index.scss' + +class TabButton extends Component { + static propTpyes = { + show: PropTypes.any, // 鎸夐挳鏄剧ず鏍峰紡鎺у埗 + MenuID: PropTypes.string, // 鑿滃崟ID + btn: PropTypes.object, // 鎸夐挳 + selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 + setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + triggerBtn: PropTypes.any, + } + + state = { + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + primaryId: '' + } + + /** + * @description 澶栭儴瑙﹀彂鎸夐挳鐐瑰嚮 + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.button.uuid === this.props.btn.uuid) { + this.actionTrigger(nextProps.triggerBtn.data) + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 瑙﹀彂鎸夐挳鎿嶄綔 + */ + actionTrigger = (record) => { + const { setting, btn, tabviews, MenuID, selectedData } = this.props + let data = [] + + if (record) { // 琛ㄦ牸涓Е鍙戞寜閽� + data = [record] + } else { + data = selectedData || [] + } + + if (btn.Ot === 'requiredSgl' && data.length !== 1) { + // 闇�瑕侀�夋嫨鍗曡鏃讹紝鏍¢獙鏁版嵁 + notification.warning({ + top: 92, + message: this.state.dict['main.action.confirm.selectSingleLine'], + duration: 5 + }) + return + } else if (!setting.primaryKey) { + // 闇�瑕侀�夋嫨琛屾椂锛屾牎楠屾槸鍚﹁缃富閿� + notification.warning({ + top: 92, + message: '鏈缃富閿紒', + duration: 5 + }) + return + } + + let primaryId = '' + + if (btn.Ot === 'requiredSgl') { + primaryId = data[0][setting.primaryKey] || '' + } + + let newtab = { + MenuNo: '', + MenuID: btn.uuid, + MenuName: btn.label, + type: btn.tabTemplate, + selected: true, + param: { + parentId: this.props.MenuID, + btn: btn, + data: data[0] || null, + primaryId: primaryId + } + } + + let index = 0 + let isexit = false + let tabs = tabviews.map((tab, i) => { + tab.selected = false + + if (tab.MenuID === MenuID) { + index = i + } else if (tab.MenuID === btn.uuid) { + tab.selected = true + isexit = true + } + + return tab + }) + + if (!isexit) { + tabs.splice(index + 1, 0, newtab) + } + + this.props.modifyTabview(tabs) + } + + render() { + const { btn, show } = this.props + + return ( + <div className="mk-btn-wrap"> + {!show ? <Button + className={'mk-btn mk-' + btn.class} + icon={btn.icon} + onClick={() => {this.actionTrigger()}} + >{btn.label}</Button> : null} + {show === 'icon' ? <Button className="action-cell" icon={btn.icon || 'dash'} onClick={() => {this.actionTrigger()}}></Button> : null} + {show === 'text' ? <Button className="action-cell" onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + {show === 'all' ? <Button className="action-cell" icon={btn.icon || ''} onClick={() => {this.actionTrigger()}}>{btn.label}</Button> : null} + </div> + ) + } +} + +const mapStateToProps = (state) => { + return { + tabviews: state.tabviews, + } +} + +const mapDispatchToProps = (dispatch) => { + return { + modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(TabButton) \ No newline at end of file diff --git a/src/tabviews/zshare/actionList/tabbutton/index.scss b/src/tabviews/zshare/actionList/tabbutton/index.scss new file mode 100644 index 0000000..e9a2a7d --- /dev/null +++ b/src/tabviews/zshare/actionList/tabbutton/index.scss @@ -0,0 +1,10 @@ +.mk-btn-wrap { + display: inline-block; + .action-cell { + border: 0; + background: transparent !important; + } + .action-cell[ant-click-animating-without-extra-node="true"]::after { + display: none!important; + } +} diff --git a/src/tabviews/zshare/cardcomponent/index.jsx b/src/tabviews/zshare/cardcomponent/index.jsx index d17f336..503416b 100644 --- a/src/tabviews/zshare/cardcomponent/index.jsx +++ b/src/tabviews/zshare/cardcomponent/index.jsx @@ -1,70 +1,75 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Icon, Card, Dropdown, Menu, Spin, Empty, Tabs } from 'antd' +import { Icon, Card, Spin, Empty, Tabs } from 'antd' +import asyncComponent from '@/utils/asyncComponent' import './index.scss' + +const NormalButton = asyncComponent(() => import('@/tabviews/zshare/actionList/normalbutton')) +const PopupButton = asyncComponent(() => import('@/tabviews/zshare/actionList/popupbutton')) +const TabButton = asyncComponent(() => import('@/tabviews/zshare/actionList/tabbutton')) +const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton')) +const ChangeUserButton = asyncComponent(() => import('@/tabviews/zshare/actionList/changeuserbutton')) +const PrintButton = asyncComponent(() => import('@/tabviews/zshare/actionList/printbutton')) const { TabPane } = Tabs class CardCell extends Component { static propTpyes = { - card: PropTypes.object, - data: PropTypes.object, - selectKey: PropTypes.string, - colMap: PropTypes.any, - triggerBtn: PropTypes.func, - switchCard: PropTypes.func + BID: PropTypes.any, // 涓昏〃ID + BData: PropTypes.any, // 涓昏〃鏁版嵁 + Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� + MenuID: PropTypes.string, // 鑿滃崟ID + setting: PropTypes.object, // 椤甸潰璁惧畾 + logcolumns: PropTypes.array, // 瀛楁鍒� + card: PropTypes.object, // 鍗$墖璁剧疆淇℃伅 + data: PropTypes.object, // 鍗$墖鏁版嵁 + selectKey: PropTypes.string, // 閫夋嫨鍗$墖鐨勫簭鍙� + colMap: PropTypes.any, // 鏄剧ず鍒椾俊鎭紝鐢ㄤ簬璁剧疆鏍囪 + refreshdata: PropTypes.func, // 鎸夐挳鎿嶄綔鍚庢暟鎹埛鏂� + switchCard: PropTypes.func // 鍗$墖鍒囨崲 } state = { - card: null, - extra: null, - actions: null + extra: null, // 椤堕儴鎸夐挳淇℃伅 + actions: null // 搴曢儴鎸夐挳琛� } UNSAFE_componentWillMount () { + this.getCardActions() + } + + /** + * @description 鏁版嵁鍒囨崲锛岄噸鏂扮粦瀹氭寜閽暟鎹� + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (!is(fromJS(this.props.data), fromJS(nextProps.data))) { + this.setState({}, () => { + this.getCardActions() + }) + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 鑾峰彇椤堕儴鍙婃寜閽鐨勬寜閽泦 + */ + getCardActions = () => { const { card } = this.props let extra = null if (card.header && card.header.actions) { - let actions = card.header.actions.map(item => { - let _action = null - if (card.header.show === 'icon') { - _action = <span className="action-cell" onClick={() => this.triggerAction(item)} key={item.uuid}><Icon type={item.icon || 'dash'} /></span> - } else if (card.bottom.show === 'text') { - _action = <span className="action-cell" onClick={() => this.triggerAction(item)} key={item.uuid}>{item.label}</span> - } else { - _action = <span className="action-cell" onClick={() => this.triggerAction(item)} key={item.uuid}><Icon type={item.icon || 'dash'} /> {item.label}</span> - } - - return _action - }) - if (actions.length === 1) { - extra = actions[0] - } else { - extra = <Dropdown overlay={ - <Menu>{actions.map((item, i) => <Menu.Item key={i}> {item} </Menu.Item>)}</Menu> - } placement="bottomRight"> - Action - </Dropdown> - } + let actions = this.getActionList(card.header.actions, card.header.show) + extra = actions[0] } let _actions = null if (card.bottom && card.bottom.actions) { - _actions = card.bottom.actions.map(item => { - let _action = null - if (card.bottom.show === 'icon') { - _action = <span className="action-cell" onClick={() => this.triggerAction(item)} key={item.uuid}><Icon type={item.icon || 'dash'} /></span> - } else if (card.bottom.show === 'text') { - _action = <span className="action-cell" onClick={() => this.triggerAction(item)} key={item.uuid}>{item.label}</span> - } else { - _action = <span className="action-cell" onClick={() => this.triggerAction(item)} key={item.uuid}><Icon type={item.icon || 'dash'} /> {item.label}</span> - } - - return _action - }) + _actions = this.getActionList(card.bottom.actions, card.bottom.show) } this.setState({ @@ -72,15 +77,113 @@ extra: extra }) } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + + /** + * @description 鑾峰彇鎸夐挳鍏冪礌 + */ + getActionList = (actions, show) => { + const { BID, BData, Tab, setting, logcolumns, ContainerId, data, MenuID } = this.props + + return actions.map(item => { + if (['exec', 'prompt', 'pop'].includes(item.OpenType)) { + return ( + <NormalButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + show={show} + BData={BData} + setting={setting} + columns={logcolumns} + selectedData={[data]} + ContainerId={ContainerId} + updateStatus={this.updateStatus} + /> + ) + } else if (item.OpenType === 'popview') { + return ( + <PopupButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + show={show} + BData={BData} + setting={setting} + selectedData={[data]} + updateStatus={this.updateStatus} + /> + ) + } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { + return ( + <TabButton + key={item.uuid} + btn={item} + show={show} + MenuID={MenuID} + setting={setting} + selectedData={[data]} + updateStatus={this.updateStatus} + /> + ) + } else if (item.OpenType === 'innerpage' || item.OpenType === 'outerpage') { + return ( + <NewPageButton + key={item.uuid} + btn={item} + show={show} + setting={setting} + selectedData={[data]} + /> + ) + } else if (item.OpenType === 'funcbutton') { + if (item.funcType === 'changeuser') { + return ( + <ChangeUserButton + key={item.uuid} + BID={BID} + btn={item} + show={show} + setting={setting} + selectedData={[data]} + updateStatus={this.updateStatus} + /> + ) + } else if (item.funcType === 'print') { + return ( + <PrintButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + show={show} + BData={BData} + setting={setting} + selectedData={[data]} + ContainerId={ContainerId} + updateStatus={this.updateStatus} + /> + ) + } + } + + return null + }) } - triggerAction = (btn) => { - this.props.triggerBtn(btn, [this.props.data]) + /** + * @description 鎿嶄綔瀹屾垚鍚庯紝鏁版嵁鍒锋柊 + */ + updateStatus = (type, positon) => { + if (type === 'refresh') { + this.props.refreshdata(positon) + } } + /** + * @description 鍗$墖涓厓绱犳爣璁拌缃� + */ getMark = (record, marks) => { const { colMap } = this.props let className = '' @@ -150,6 +253,9 @@ } } + /** + * @description 鑾峰彇鍗$墖鍐呭 + */ getContent = (col) => { const { data } = this.props @@ -232,6 +338,9 @@ } } + /** + * @description 鑾峰彇鍗$墖涓浘鐗囨垨鍥炬爣璁剧疆 + */ getAvatar = () => { const { card, data } = this.props @@ -252,6 +361,9 @@ } } + /** + * @description 鍗$墖鐐瑰嚮鍒囨崲浜嬩欢 + */ switchCard = () => { const { card, data } = this.props @@ -309,12 +421,18 @@ class CardChart extends Component { static propTpyes = { + BID: PropTypes.any, // 涓昏〃ID + BData: PropTypes.any, // 涓昏〃鏁版嵁 + Tab: PropTypes.any, // 濡傛灉褰撳墠鍏冪礌涓烘爣绛炬椂锛宼ab涓烘爣绛句俊鎭� + MenuID: PropTypes.string, // 鑿滃崟ID + config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 + logcolumns: PropTypes.array, // 鏄剧ず鍒� + ContainerId: PropTypes.any, // tab椤甸潰ID锛岀敤浜庡脊绐楁帶鍒� plot: PropTypes.object, - config: PropTypes.object, tableId: PropTypes.string, loading: PropTypes.bool, data: PropTypes.array, - buttonTrigger: PropTypes.func, + refreshdata: PropTypes.func, handleTableId: PropTypes.func } @@ -324,6 +442,9 @@ selectKey: '' } + /** + * @description 鍗$墖鍒濆鍖栵紝璁剧疆鍗$墖鐨勯厤缃俊鎭� + */ UNSAFE_componentWillMount () { const { plot, config } = this.props let card = {} @@ -340,7 +461,7 @@ }) actions.forEach(item => { - if (item.Ot && item.Ot !== 'notRequired' && !['excelIn', 'excelOut'].includes(item.OpenType)) { + if ((item.Ot && item.Ot !== 'notRequired' && !['excelIn', 'excelOut'].includes(item.OpenType)) || item.funcType === 'changeuser') { actionMap.set(item.uuid, item) } }) @@ -362,6 +483,7 @@ if (!actionMap.get(item.value)) return card.header.actions.push(actionMap.get(item.value)) }) + card.header.actions.length = 1 } if (card.header.actions.length === 0) { card.header.actions = null @@ -482,10 +604,10 @@ shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) } - triggerBtn = (btn, data) => { - this.props.buttonTrigger(btn, data) - } + /** + * @description 鍗$墖鍒囨崲 + */ switchCard = (data) => { const { config } = this.props @@ -497,7 +619,7 @@ } render() { - const { plot, data, loading } = this.props + const { plot, data, loading, BID, BData, Tab, MenuID, config, logcolumns, ContainerId } = this.props const { card, colMap, selectKey } = this.state return ( @@ -513,12 +635,19 @@ data.map((item, i) => ( <CardCell key={i} + BID={BID} + Tab={Tab} card={card} data={item} + BData={BData} + MenuID={MenuID} colMap={colMap} selectKey={selectKey} - triggerBtn={this.triggerBtn} + logcolumns={logcolumns} + setting={config.setting} + ContainerId={ContainerId} switchCard={this.switchCard} + refreshdata={this.props.refreshdata} /> )) } @@ -526,12 +655,19 @@ <Tabs activeKey=""> {data.map((item, i) => ( <TabPane tab={<CardCell + BID={BID} + Tab={Tab} card={card} data={item} + BData={BData} + MenuID={MenuID} colMap={colMap} selectKey={selectKey} - triggerBtn={this.triggerBtn} + logcolumns={logcolumns} + setting={config.setting} + ContainerId={ContainerId} switchCard={this.switchCard} + refreshdata={this.props.refreshdata} />} key={i}></TabPane> ))} diff --git a/src/tabviews/zshare/cardcomponent/index.scss b/src/tabviews/zshare/cardcomponent/index.scss index 4f63e95..be3cbbd 100644 --- a/src/tabviews/zshare/cardcomponent/index.scss +++ b/src/tabviews/zshare/cardcomponent/index.scss @@ -8,9 +8,25 @@ .anticon { margin-right: 0px; } + .ant-btn { + padding: 0; + > .anticon + span { + margin-left: 4px; + } + } } > .chart-card-box { margin-bottom: 20px; + } + + .chart-card-box:hover { + .ant-card.chart-card { + .ant-card-head { + .ant-card-extra { + display: block; + } + } + } } .chart-card-box:not(.ant-col) { @@ -73,14 +89,19 @@ font-weight: 500; } .ant-card-extra { - color: #1890ff; - .action-cell { - cursor: pointer; - } + padding: 0px; + display: none; } } .ant-card-actions { height: 48px; + > li { + margin: 8px 0; + + .ant-btn > .anticon + span { + vertical-align: top; + } + } } } @@ -183,17 +204,10 @@ word-break: break-word; white-space: nowrap; text-overflow: ellipsis; + cursor: default; } .anticon { width: unset; - margin-right: 3px; - color: rgba(0, 0, 0, 0.45); - } - } - li:hover { - color: #1890ff; - .anticon { - color: #1890ff; } } } diff --git a/src/tabviews/zshare/mutilform/index.1.jsx b/src/tabviews/zshare/mutilform/index.1.jsx new file mode 100644 index 0000000..bf40107 --- /dev/null +++ b/src/tabviews/zshare/mutilform/index.1.jsx @@ -0,0 +1,845 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification } from 'antd' +import moment from 'moment' +import { formRule } from '@/utils/option.js' +import Utils from '@/utils/utils.js' +import FileUpload from '../fileupload' +import './index.scss' + +const {MonthPicker} = DatePicker +const { TextArea } = Input + +class MainSearch extends Component { + static propTpyes = { + action: PropTypes.object, // 鎸夐挳淇℃伅銆佽〃鍗曞垪琛� + dict: PropTypes.object, // 瀛楀吀椤� + data: PropTypes.any, // 琛ㄦ牸鏁版嵁 + BData: PropTypes.any, // 涓昏〃鏁版嵁 + configMap: PropTypes.object, // 鎸夐挳鍙婁笅鎷夎〃鍗曢厤缃俊鎭泦 + inputSubmit: PropTypes.func // input鍥炶溅鎻愪氦 + } + + state = { + cols: 2, // 鏄剧ず涓哄灏戝垪 + datatype: null, // 鏁版嵁绫诲瀷 + readtype: null, // 鏄惁鍙 + readin: null, // 琛屾暟鎹槸鍚﹀啓鍏� + fieldlen: null, // 瀛楁闀垮害 + formlist: [], // 琛ㄥ崟椤� + encrypts: [], // 鍔犲瘑瀛楁 + intercepts: [], // 鎴彇瀛楁 + record: {} // 璁板綍涓嬫媺琛ㄥ崟鍏宠仈瀛楁锛岀敤浜庢暟鎹啓鍏� + } + + UNSAFE_componentWillMount () { + let cols = 2 + if (this.props.action.setting && this.props.action.setting.cols) { + cols = parseInt(this.props.action.setting.cols) + if (cols > 3 || cols < 1) { + cols = 2 + } + } + + this.setState({ + cols: cols + }) + } + + componentDidMount () { + const { data, BData } = this.props + let action = JSON.parse(JSON.stringify(this.props.action)) + + let datatype = {} + let readtype = {} + let readin = {} + let fieldlen = {} + let formlist = [] + let encrypts = [] + let intercepts = [] + + if (action.groups.length > 0) { + action.groups.forEach(group => { + if (group.sublist.length === 0) return + + if (!group.default) { + formlist.push({ + type: 'title', + label: group.label, + uuid: group.uuid + }) + } + + formlist.push(...group.sublist) + }) + } else { + formlist = action.fields + } + + let _inputfields = formlist.filter(item => item.type === 'text' || item.type === 'number') // 鐢ㄤ簬杩囨护涓嬫媺鑿滃崟鍏宠仈琛ㄥ崟 + + formlist = formlist.map(item => { + if (item.type === 'title') return item + + // 鍔犲瘑瀛楁 + if (item.type === 'textarea' && item.encryption === 'true') { + encrypts.push(item.field) + } + + // 瀛楃鎴彇瀛楁 + if (item.interception === 'true') { + intercepts.push(item.field) + } + + // 鏁版嵁鍐欏叆 + let _readin = item.readin !== 'false' + if (item.type === 'linkMain' || item.type === 'funcvar') { + _readin = false + } + + // 鐢ㄤ簬鍙楁帶鍊肩殑琛ㄥ崟锛岄殣钘忔椂浼犻粯璁ゅ��(鏈娇鐢紵) + item.initVal = typeof(item.initval) === 'object' ? JSON.parse(JSON.stringify(item.initval)) : item.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 + } + + datatype[item.field] = item.type + readtype[item.field] = item.readonly === 'true' + readin[item.field] = _readin + fieldlen[item.field] = _fieldlen + + if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') { + if (item.setAll === 'true') { + item.options.unshift({ + key: Utils.getuuid(), + Value: '', + Text: this.props.dict['main.all'] + }) + } + + if (item.resourceType === '1' && this.props.configMap.hasOwnProperty(item.uuid)) { + item.options = [...item.options, ...this.props.configMap[item.uuid]] + } + + // 淇濆瓨鍒濆鍒楄〃锛岀敤浜庡叧鑱旇彍鍗曟帶鍒� + item.oriOptions = JSON.parse(JSON.stringify(item.options)) + + // 涓嬬骇琛ㄥ崟鎺у埗-瀛楁鍐欏叆 + if (item.linkSubField && item.linkSubField.length > 0) { + let _fields = _inputfields.map(_item => _item.field) + item.linkSubField = item.linkSubField.filter(_item => _fields.includes(_item)) + } + } + + 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)) { + newval = this.props.data[item.field] + } else if (item.type === 'date') { // 鏃堕棿鎼滅储 + if (_readin && this.props.data && this.props.data.hasOwnProperty(item.field)) { + newval = this.props.data[item.field] + } + if (newval) { + newval = moment(newval, 'YYYY-MM-DD') + newval = newval.format('YYYY-MM-DD') === 'Invalid date' ? '' : newval + } + if (!newval && item.initval) { + newval = moment().subtract(item.initval, 'days') + } else if (!newval) { + newval = null + } + } else if (item.type === 'datemonth') { + if (_readin && this.props.data && this.props.data.hasOwnProperty(item.field)) { + newval = this.props.data[item.field] + } + if (newval) { + newval = moment(newval, 'YYYY-MM') + newval = newval.format('YYYY-MM') === 'Invalid date' ? '' : newval + } + if (!newval && item.initval) { + newval = moment().subtract(item.initval, 'month') + } else if (!newval) { + newval = null + } + } else if (item.type === 'datetime') { + if (_readin && this.props.data && this.props.data.hasOwnProperty(item.field)) { + newval = this.props.data[item.field] + } + if (newval) { + newval = moment(newval, 'YYYY-MM-DD HH:mm:ss') + newval = newval.format('YYYY-MM-DD HH:mm:ss') === 'Invalid date' ? '' : newval + } + if (!newval && item.initval) { + newval = moment().subtract(item.initval, 'days') + } else if (!newval) { + newval = null + } + } + + // 鍔犲瘑瀛楁锛岃В瀵嗗鐞� + if (item.type === 'textarea' && item.encryption === 'true' && newval !== '') { + try { + newval = window.decodeURIComponent(window.atob(newval)) + } catch (e) { + console.warn(e) + } + } + + // 璇诲彇琛ㄦ牸鏁版嵁鎴栬鏈夋椂闂寸殑鍒濆鍊� + item.initval = newval !== '' ? newval : item.initval + + // 涓嬫媺琛ㄥ崟锛屽瓨鍦ㄤ笂绾ц彍鍗曟椂锛岀敓鎴愭樉绀哄�煎垪琛紝浼樺厛浠ユ暟瀛楀垽鏂� + if (item.supvalue) { + let supvals = [] + item.supvalue.split(',').forEach(val => { + supvals.push(val) + if (/^([-]?(0|[1-9][0-9]*)(\.[0-9]+)?)$/.test(val)) { + supvals.push(+val) + } + }) + item.supvalue = supvals + } + + return item + }) + + formlist = formlist.map(item => { + if (item.type === 'link') { + let supItem = formlist.filter(form => form.field === item.linkField)[0] + + // 鍏宠仈鏄剧ず鍒椾腑鐨勫瓧娈靛�硷紝閫氳繃璇ュ�艰繃婊や笅鎷夐�夐」 + if (!supItem && data && data.hasOwnProperty(item.linkField)) { + supItem = {initval: data[item.linkField]} + } + + if (!supItem) { + notification.warning({ + top: 92, + message: '鏈煡璇㈠埌琛ㄥ崟銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', + duration: 5 + }) + } else { + item.options = item.oriOptions.filter(option => option.parentId === supItem.initval) + } + } + + return item + }) + + this.setState({ + readtype: readtype, + datatype: datatype, + readin: readin, + fieldlen: fieldlen, + encrypts: encrypts, + intercepts: intercepts, + formlist: formlist + }, () => { + if (action.setting && action.setting.focus) { + try { + let _form = document.getElementById('main-form-box') + let _item = _form.getElementsByTagName('input') + _item = [..._item] + _item.forEach(input => { + if (!input || input.id !== action.setting.focus) return + input.select() + }) + } catch { + console.warn('focus error锛�') + } + } + this.setState({ + loaded: true + }) + }) + } + + resetform = (formlist, supfields, index, fieldsvalue) => { + index++ + let subfields = [] + + supfields.forEach(supfield => { + formlist = formlist.map(item => { + if (item.type === 'link' && item.linkField === supfield.field) { + item.options = item.oriOptions.filter(option => option.parentId === supfield.initval) + item.initval = item.options[0] ? item.options[0].Value : '' + + fieldsvalue[item.field] = item.initval + + subfields.push(item) + } + return item + }) + }) + + if (subfields.length === 0 || index > 6) { + return {formlist: formlist, fieldsvalue: fieldsvalue} + } else { + return this.resetform(formlist, subfields, index, fieldsvalue) + } + } + + selectChange = (_field, value, option) => { + const { record } = this.state + let formlist = JSON.parse(JSON.stringify(this.state.formlist)) + + let subfields = [] + let fieldsvalue = {} + let _record = {} + formlist = formlist.map(item => { + if (item.type === 'link' && item.linkField === _field.field) { + item.options = item.oriOptions.filter(option => option.parentId === value) + item.initval = item.options[0] ? item.options[0].Value : '' + + fieldsvalue[item.field] = item.initval + + subfields.push(item) + } + return item + }) + + // 琛ㄥ崟鍒囨崲鏃讹紝鏇存柊鍏宠仈瀛楁 + if (_field.type === 'select' && _field.linkSubField && _field.linkSubField.length > 0 && option.props.data) { + let _data = option.props.data + _field.linkSubField.forEach(subfield => { + if (this.props.form.getFieldValue(subfield) !== undefined) { + fieldsvalue[subfield] = (_data[subfield] || _data[subfield] === 0) ? _data[subfield] : '' + } else { + _record[subfield] = (_data[subfield] || _data[subfield] === 0) ? _data[subfield] : '' + } + }) + } + + if (subfields.length === 0) { + if (Object.keys(fieldsvalue).length > 0) { + this.props.form.setFieldsValue(fieldsvalue) + } + if (Object.keys(_record).length > 0) { + this.setState({ + record: {...record, ..._record} + }) + } + } else { + let result = this.resetform(formlist, subfields, 0, fieldsvalue) + + if (Object.keys(result.fieldsvalue).length > 0) { + this.props.form.setFieldsValue(fieldsvalue) + } + + let _param = { + formlist: result.formlist + } + + if (Object.keys(_record).length > 0) { + _param.record = {...record, ..._record} + } + + this.setState(_param) + } + } + + handleConfirmPassword = (rule, value, callback, item) => { + let val = parseFloat(value) + + if (!isNaN(val)) { + if (typeof(item.min) === 'number' && val < item.min) { + callback(item.label + '鏈�灏忓�间负 ' + item.min) + } else if (typeof(item.max) === 'number' && val > item.max) { + callback(item.label + '鏈�澶у�间负 ' + item.max) + } + } + + callback() + } + + getFields(formlist) { + const { getFieldDecorator } = this.props.form + const { cols } = this.state + + const fields = [] + + formlist.forEach((item, index) => { + if (item.type === 'title') { + fields.push( + <Col span={24} key={index}> + <p>{item.label}</p> + </Col> + ) + } else if (item.type === 'text') { + let _max = item.fieldlength || 50 + let _rules = [] + if (item.regular) { + if (item.regular === 'number') { + _rules = [{ + pattern: /^[0-9]*$/ig, + message: formRule.input.numbermsg + }] + } else if (item.regular === 'letter') { + _rules = [{ + pattern: /^[a-zA-Z]*$/ig, + message: formRule.input.lettermsg + }] + } else if (item.regular === 'letter&number') { + _rules = [{ + pattern: /^[a-zA-Z0-9]*$/ig, + message: formRule.input.letternummsg + }] + } else if (item.regular === 'funcname') { + _rules = [{ + pattern: /^[\u4E00-\u9FA50-9a-zA-Z_]*$/ig, + message: formRule.input.funcname + }] + } + } + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.input'] + item.label + '!' + }, + { + max: _max, + message: formRule.input.formMessage.replace('@max', _max) + }, + ..._rules + ] + })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />)} + </Form.Item> + </Col> + ) + } else if (item.type === 'number') { // 鏁板瓧 + let _initval = item.initval + let precision = (item.decimal || item.decimal === 0) ? item.decimal : null + + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: _initval, + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + item.label + '!' + }, + { + validator: (rule, value, callback) => this.handleConfirmPassword(rule, value, callback, item) + } + ] + })( + precision === null ? + <InputNumber disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> : + <InputNumber precision={precision} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'select' || item.type === 'link') { // 涓嬫媺鎼滅储 + let hasSubField = false + if (item.linkSubField && item.linkSubField.length > 0) { // 瀛樺湪鍏宠仈瀛楁锛屾暟鎹瓨鍌� + hasSubField = true + } + + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <Select + showSearch + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + onChange={(value, option) => {this.selectChange(item, value, option)}} + disabled={item.readonly === 'true'} + > + {item.options.map(option => + <Select.Option id={option.key} data={hasSubField ? option : ''} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'multiselect') { // 澶氶�� + let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: _initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <Select + showSearch + mode="multiple" + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + disabled={item.readonly === 'true'} + > + {item.options.map(option => + <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'date') { // 鏃堕棿鎼滅储 + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <DatePicker disabled={item.readonly === 'true'} /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'datemonth') { + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <MonthPicker disabled={item.readonly === 'true'} /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'datetime') { + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <DatePicker showTime disabled={item.readonly === 'true'} /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'fileupload') { + let filelist = this.props.data ? this.props.data[item.field] : item.initval + if (filelist && this.state.readin[item.field]) { + try { + filelist = filelist.split(',').map((url, index) => { + return { + uid: `${index}`, + name: url.slice(url.lastIndexOf('/') + 1), + status: 'done', + url: url, + origin: true + } + }) + } catch { + filelist = [] + } + } else { + filelist = [] + } + + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: filelist, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <FileUpload maxFile={item.maxfile} fileType={item.fileType || 'text'} /> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'linkMain') { + fields.push( + <Col span={24 / cols} key={index}> + <Form.Item label={item.label}> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.input'] + item.label + '!' + } + ] + })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} />)} + </Form.Item> + </Col> + ) + } else if (item.type === 'funcvar') { + // 鍑芥暟鍙橀噺瀛楁锛岄粯璁や笉鏄剧ず + } else if (item.type === 'textarea') { + let _max = item.fieldlength || 512 + let _labelcol = cols !== 3 ? 8 / cols : 3 + let _wrapcol = cols !== 3 ? 16 + (cols - 1) * 4 : 21 + let _style = {} + if (cols === 2) { + _style.paddingLeft = '7px' + } + fields.push( + <Col span={24} key={index} className="textarea-row" style={{..._style}}> + <Form.Item label={item.label} labelCol={{xs: { span: 24 }, sm: { span: _labelcol }}} wrapperCol={ {xs: { span: 24 }, sm: { span: _wrapcol }} }> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.input'] + item.label + '!' + }, + { + max: _max, + message: formRule.input.formMessage.replace('@max', _max) + } + ] + })(<TextArea autosize={{ minRows: 2, maxRows: item.maxRows || 6 }} disabled={item.readonly === 'true'} />)} + </Form.Item> + </Col> + ) + } + }) + + return fields + } + + handleConfirm = () => { + const { record, intercepts } = this.state + let _encrypts = JSON.parse(JSON.stringify(this.state.encrypts)) + let _format = { + date: 'YYYY-MM-DD', + datemonth: 'YYYY-MM', + datetime: 'YYYY-MM-DD HH:mm:ss' + } + + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� + return new Promise((resolve, reject) => { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + let search = [] + // 闅愯棌琛ㄥ崟 + this.state.formlist.forEach(item => { + if (!item.field) return + + let _item = null + if (item.type === 'funcvar') { + _item = { + type: 'funcvar', + readonly: 'true', + readin: false, + fieldlen: this.state.fieldlen[item.field], + key: item.field, + value: '' + } + } else if (item.hidden === 'true') { + let _val = item.initval + if (record.hasOwnProperty(item.field)) { + _val = record[item.field] + _encrypts = _encrypts.filter(_field => _field !== item.field) // 闅愯棌瀛楁锛屼笉鍙備笌鍔犲瘑澶勭悊 + } + + _item = { + type: this.state.datatype[item.field], + readonly: this.state.readtype[item.field], + readin: this.state.readin[item.field], + fieldlen: this.state.fieldlen[item.field], + key: item.field, + value: _val + } + } else if (item.supField && !item.supvalue.includes(this.props.form.getFieldValue(item.supField))) { + _item = { + type: this.state.datatype[item.field], + readonly: this.state.readtype[item.field], + readin: this.state.readin[item.field], + fieldlen: this.state.fieldlen[item.field], + key: item.field, + value: item.initval + } + } + + if (!_item) return + + if (item.type === 'date' || item.type === 'datemonth' || item.type === 'datetime') { + if (_item.value && _item.value.format) { + _item.value = _item.value.format(_format[item.type]) + } else if (!_item.value) { + _item.value = '' + } + } + + search.push(_item) + }) + + Object.keys(values).forEach(key => { + let _value = '' + if (this.state.datatype[key] === 'datetime') { + _value = values[key] ? moment(values[key]).format('YYYY-MM-DD HH:mm:ss') : '' + } else if (this.state.datatype[key] === 'datemonth') { + _value = values[key] ? moment(values[key]).format('YYYY-MM') : '' + } else if (this.state.datatype[key] === 'date') { + _value = values[key] ? moment(values[key]).format('YYYY-MM-DD') : '' + } else if (this.state.datatype[key] === 'number') { + _value = values[key] + + } else if (this.state.datatype[key] === 'multiselect') { + _value = values[key] ? values[key].join(',') : '' + + } else if (this.state.datatype[key] === 'fileupload') { + let vals = [] + + if (values[key] && values[key].length > 0) { + values[key].forEach(_val => { + if (_val.origin && _val.url) { + vals.push(_val.url) + } else if (!_val.origin && _val.status === 'done' && _val.response) { + vals.push(Utils.getrealurl(_val.response)) + } + }) + } + + _value = vals.join(',') + } else if (this.state.datatype[key] === 'text' || this.state.datatype[key] === 'textarea') { + _value = values[key].replace(/\t*|\v*/g, '') // 鍘婚櫎鍒惰〃绗� + + if (intercepts.includes(key)) { // 鍘婚櫎棣栧熬绌烘牸 + _value = _value.replace(/(^\s*|\s*$)/g, '') + } + } else { + _value = values[key] + + } + + search.push({ + type: this.state.datatype[key], + readonly: this.state.readtype[key], + readin: this.state.readin[key], + fieldlen: this.state.fieldlen[key], + key: key, + value: _value + }) + }) + + // 鍚湁鍔犲瘑瀛楁鏃讹紝瀵硅〃鍗曞�艰繘琛屽姞瀵� + if (_encrypts && _encrypts.length > 0) { + search = search.map(item => { + let _value = item.value + if (_encrypts.includes(item.key)) { + try { + _value = window.btoa(window.encodeURIComponent(_value)) + } catch (e) { + console.warn(e) + } + } + item.value = _value + + return item + }) + } + + resolve(search) + } else { + reject(err) + } + }) + }) + } + + handleSubmit = (e) => { + e.preventDefault() + this.props.inputSubmit() + } + + render() { + const { formlist, cols } = this.state + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + + let _formlist = [] + let rowIndex = 0 + let colIndex = 0 + + // 琛ㄥ崟鍒嗚锛岄伩鍏嶆帓鍒椾笉鏁撮綈 + formlist.forEach(item => { + if ((!item.field && item.type !== 'title') || item.hidden === 'true' || item.type === 'funcvar') return + + if (item.supField && !item.supvalue.includes(this.props.form.getFieldValue(item.supField))) return + + _formlist[rowIndex] = _formlist[rowIndex] || [] + if (item.type === 'textarea' || item.type === 'title') { + if (colIndex === 0) { + _formlist[rowIndex].push(item) + } else { + rowIndex++ + _formlist[rowIndex] = [item] + } + rowIndex++ + colIndex = 0 + } else { + _formlist[rowIndex].push(item) + colIndex++ + } + if (colIndex >= cols) { + rowIndex++ + colIndex = 0 + } + }) + + return ( + <Form {...formItemLayout} className="ant-advanced-search-form main-form-field" id="main-form-box"> + {_formlist.map((formrow, index) => <Row key={index} gutter={24}>{this.getFields(formrow)}</Row>)} + </Form> + ) + } +} + +export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index bf40107..063dd6d 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -2,6 +2,8 @@ import PropTypes from 'prop-types' import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification } from 'antd' import moment from 'moment' + +import Api from '@/api' import { formRule } from '@/utils/option.js' import Utils from '@/utils/utils.js' import FileUpload from '../fileupload' @@ -15,8 +17,8 @@ action: PropTypes.object, // 鎸夐挳淇℃伅銆佽〃鍗曞垪琛� dict: PropTypes.object, // 瀛楀吀椤� data: PropTypes.any, // 琛ㄦ牸鏁版嵁 + BID: PropTypes.any, // 涓昏〃ID BData: PropTypes.any, // 涓昏〃鏁版嵁 - configMap: PropTypes.object, // 鎸夐挳鍙婁笅鎷夎〃鍗曢厤缃俊鎭泦 inputSubmit: PropTypes.func // input鍥炶溅鎻愪氦 } @@ -121,10 +123,6 @@ }) } - if (item.resourceType === '1' && this.props.configMap.hasOwnProperty(item.uuid)) { - item.options = [...item.options, ...this.props.configMap[item.uuid]] - } - // 淇濆瓨鍒濆鍒楄〃锛岀敤浜庡叧鑱旇彍鍗曟帶鍒� item.oriOptions = JSON.parse(JSON.stringify(item.options)) @@ -224,7 +222,9 @@ message: '鏈煡璇㈠埌琛ㄥ崟銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', duration: 5 }) + item.supInitVal = '' } else { + item.supInitVal = supItem.initval item.options = item.oriOptions.filter(option => option.parentId === supItem.initval) } } @@ -254,9 +254,110 @@ console.warn('focus error锛�') } } + // 鐢ㄦ潵鏇存柊state锛岄槻姝㈠彈鎺ц〃鍗曞垵濮嬫椂涓嶆樉绀� this.setState({ loaded: true }) + this.improveActionForm() + }) + } + + /** + * @description 鑾峰彇涓嬫媺琛ㄥ崟閫夐」淇℃伅 + */ + improveActionForm = () => { + const { formlist } = this.state + let deffers = [] + + formlist.forEach(item => { + if (!['select', 'link', 'multiselect'].includes(item.type) || item.resourceType !== '1') return + + let param = { + func: 'sPC_Get_SelectedList', + LText: item.data_sql, + obj_name: 'data', + arr_field: item.arr_field + } + + if (this.props.BID) { + param.BID = this.props.BID + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + deffers.push( + new Promise(resolve => { + Api.getSystemCacheConfig(param, item.database === 'sso').then(res => { + res.$search = item + resolve(res) + }) + }) + ) + }) + + if (deffers.length === 0) return + + let _field = {} + let error = '' + Promise.all(deffers).then(result => { + result.forEach(res => { + if (res.status) { + let options = res.data.map(cell => { + let item = { + key: Utils.getuuid(), + Value: cell[res.$search.valueField], + Text: cell[res.$search.valueText] + } + + if (res.$search.type === 'link') { + item.parentId = cell[res.$search.linkField] + } else if (res.$search.type === 'select' && res.$search.linkSubField && res.$search.linkSubField.length > 0) { + res.$search.linkSubField.forEach(_field => { + item[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' + }) + } + + return item + }) + + _field[res.$search.uuid] = options + } else { + error = res + } + }) + + if (error) { + notification.warning({ + top: 92, + message: error.message, + duration: 5 + }) + } + + let _formlist = formlist.map(item => { + if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') { + if (item.resourceType === '1' && _field.hasOwnProperty(item.uuid)) { + item.oriOptions = [...item.oriOptions, ..._field[item.uuid]] + } + } + return item + }) + + _formlist = _formlist.map(item => { + if (item.type === 'link') { + if (item.supInitVal) { + item.options = item.oriOptions.filter(option => option.parentId === item.supInitVal) + } else { + item.options = item.oriOptions + } + } + return item + }) + + this.setState({ + formlist: _formlist + }) }) } diff --git a/src/tabviews/zshare/normalTable/index.jsx b/src/tabviews/zshare/normalTable/index.jsx index 14ab88f..272a670 100644 --- a/src/tabviews/zshare/normalTable/index.jsx +++ b/src/tabviews/zshare/normalTable/index.jsx @@ -1,22 +1,24 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import md5 from 'md5' +import { is, fromJS } from 'immutable' +import {connect} from 'react-redux' import { Table, message, Affix, Button, Typography, Modal, Icon } from 'antd' + +import { modifyTabview } from '@/store/action' import './index.scss' import '@/assets/css/table.scss' const { Paragraph } = Typography -export default class MainTable extends Component { +class NormalTable extends Component { static defaultProps = { - pagination: true, - total: 0, - menuType: 'normal' + total: 0 } static propTpyes = { - menuType: PropTypes.any, // 涓夌骇鑿滃崟绫诲瀷锛孒S闇�鐗规畩澶勭悊 tableId: PropTypes.string, // 鍒楄〃Id + resetTable: PropTypes.bool, // 琛ㄦ牸閲嶇疆 pageSize: PropTypes.any, // 姣忛〉鏁版嵁 dict: PropTypes.object, // 瀛楀吀椤� config: PropTypes.object, // 椤甸潰閰嶇疆 @@ -29,10 +31,8 @@ loading: PropTypes.bool, // 琛ㄦ牸鍔犺浇涓� refreshdata: PropTypes.func, // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂� buttonTrigger: PropTypes.func, // 琛ㄦ牸涓寜閽Е鍙戞搷浣� - linkTrigger: PropTypes.func, // 瀛楁閫忚 handleTableId: PropTypes.func, // 鏁版嵁鍒囨崲 - memberLevel: PropTypes.any, // 浼氬憳绛夌骇 - pagination: PropTypes.any // 鏁版嵁鍒嗛〉 + chgSelectData: PropTypes.func, // 鏁版嵁鍒囨崲 } state = { @@ -139,7 +139,31 @@ }) } + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 涓婄骇鑿滃崟id鍙樺寲鏃讹紝鍒锋柊鏁版嵁 + */ + UNSAFE_componentWillReceiveProps(nextProps) { + if (this.props.resetTable !== nextProps.resetTable) { + this.resetTable() + } + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + + // 瀛楁閫忚 triggerLink = (item, record) => { + const { tabviews, MenuID } = this.props let tabmenu = item.linkThdMenu let iframes = ['Main/Index', 'bda/rdt', 'Home/rdt'] @@ -165,7 +189,29 @@ searchval: record[item.field] || '' } - this.props.linkTrigger(tabmenu) + tabmenu.selected = true + + let index = 0 + let isexit = false + let tabs = tabviews.map((tab, i) => { + tab.selected = false + + if (tab.MenuID === MenuID) { + index = i + } else if (tab.MenuID === tabmenu.MenuID) { + tab.param = tabmenu.param + tab.selected = true + isexit = true + } + + return tab + }) + + if (!isexit) { + tabs.splice(index + 1, 0, tabmenu) + } + + this.props.modifyTabview(tabs) } getMark = (record, marks) => { @@ -602,6 +648,9 @@ } } + /** + * @description 鍥剧墖缂╂斁 + */ imgScaleClose = () => { this.setState({ imgShow: false @@ -634,6 +683,9 @@ message.success(this.props.dict['main.copy.success']) } + /** + * + */ onSelectChange = selectedRowKeys => { let index = '' if (selectedRowKeys.length > 0) { @@ -643,19 +695,29 @@ this.changedata(index) this.setState({ selectedRowKeys }) + + let selects = [] + selectedRowKeys.forEach(item => { + selects.push(this.props.data[item]) + }) + + this.props.chgSelectData(selects) } + /** + * @description 鐐瑰嚮鏁磋锛岃Е鍙戝垏鎹紝 鍒ゆ柇鏄惁鍙�夛紝鍗曢�夋垨澶氶�夛紝杩涜瀵瑰簲鎿嶄綔 + */ changeRow = (record, index) => { - // 鐐瑰嚮鏁磋锛岃Е鍙戝垏鎹紝鍒ゆ柇鏄惁鍙�夛紝鍗曢�夋垨澶氶�夛紝杩涜瀵瑰簲鎿嶄綔 if (!this.props.setting.tableType || this.props.pickup) return let newkeys = JSON.parse(JSON.stringify(this.state.selectedRowKeys)) - let _re = newkeys.includes(index) if (this.props.setting.tableType === 'radio') { + newkeys = [index] this.changedata(index) - this.setState({ selectedRowKeys: [index] }) + this.setState({ selectedRowKeys: newkeys }) } else { + let _re = newkeys.includes(index) if (_re) { newkeys = newkeys.filter(item => item !== index) this.changedata('') @@ -666,6 +728,13 @@ this.setState({ selectedRowKeys: newkeys }) } + + let selects = [] + newkeys.forEach(item => { + selects.push(this.props.data[item]) + }) + + this.props.chgSelectData(selects) } changeTable = (pagination, filters, sorter) => { @@ -701,7 +770,7 @@ } render() { - const { setting, pickup, pagination } = this.props + const { setting, pickup } = this.props const { selectedRowKeys, lineMarks, colMap } = this.state // 璁剧疆琛ㄦ牸閫夋嫨灞炴�э細鍗曢�夈�佸閫夈�佷笉鍙�� @@ -737,7 +806,7 @@ } let _pagination = false - if (pagination) { + if (setting.laypage !== 'false') { _pagination = { current: this.state.pageIndex, pageSize: this.state.pageSize, @@ -846,3 +915,19 @@ ) } } + +const mapStateToProps = (state) => { + return { + menuType: state.editLevel, + tabviews: state.tabviews, + memberLevel: state.memberLevel + } +} + +const mapDispatchToProps = (dispatch) => { + return { + modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(NormalTable) \ No newline at end of file diff --git a/src/tabviews/zshare/settingcomponent/index.jsx b/src/tabviews/zshare/settingcomponent/index.jsx new file mode 100644 index 0000000..8acead5 --- /dev/null +++ b/src/tabviews/zshare/settingcomponent/index.jsx @@ -0,0 +1,170 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' +import { Icon, Button, Modal, notification } from 'antd' + +import Api from '@/api' +import asyncComponent from '@/utils/asyncSpinComponent' +import './index.scss' + +const VerifyCard = asyncComponent(() => import('@/tabviews/zshare/verifycard')) + +class CustomSetting extends Component { + static propTpyes = { + dict: PropTypes.any, // 瀛楀吀琛� + reloadview: PropTypes.func, // 椤甸潰鍒锋柊 + } + + state = { + userParam: null, // 淇濆瓨鐢ㄦ埛缂栬緫涓殑閰嶇疆 + visible: false, // 妯℃�佹鎺у埗 + revertLoading: false, // 鎭㈠榛樿璁剧疆 + confirmLoading: false, // 鑷畾涔夎缃ā鎬佹鍔犺浇涓� + } + + /** + * @description 鍗$墖鍒濆鍖栵紝璁剧疆鍗$墖鐨勯厤缃俊鎭� + */ + UNSAFE_componentWillMount () { + + } + + UNSAFE_componentWillReceiveProps(nextProps) { + + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + } + + controlCustomSetting = () => { + this.setState({ + visible: true, + confirmLoading: false, + revertLoading: false + }) + } + + changeMenuParam = (param) => { + this.setState({userParam: param}) + } + + settingRevert = () => { + let param = { + func: 's_TrdMenu_UserParam_del', + MenuID: this.props.MenuID + } + this.setState({ + revertLoading: true + }) + + Api.getSystemConfig(param).then(result => { + if (!result.status) { + this.setState({ + revertLoading: false + }) + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + return + } + this.setState({ + visible: false, + revertLoading: false + }, () => { + window.GLOB.CacheMap = new Map() + this.props.reloadview() + }) + }) + } + + settingSubmit = () => { + const { userParam } = this.state + let _LongParam = '' + + try { + _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(userParam))) + } catch (e) { + notification.warning({ + top: 92, + message: '缂栬瘧閿欒', + duration: 5 + }) + return + } + + let easyCode = userParam[this.props.MenuID] ? userParam[this.props.MenuID].easyCode : '' + + let param = { + func: 'sPC_TrdMenu_UserParam', + MenuID: this.props.MenuID, + EasyCode: easyCode || '', + LongParam: _LongParam + } + + this.setState({ + confirmLoading: true + }) + + Api.getSystemConfig(param).then(result => { + if (!result.status) { + this.setState({ + confirmLoading: false + }) + notification.warning({ + top: 92, + message: result.message, + duration: 5 + }) + return + } + this.setState({ + visible: false, + confirmLoading: false + }, () => { + window.GLOB.CacheMap = new Map() + this.props.reloadview() + }) + }) + } + + render() { + + return ( + <div> + <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} /> + <Modal + wrapClassName="common-table-custom-modal" + title={'鑷畾涔夎缃�'} + maskClosable={false} + width={950} + visible={this.state.visible} + onCancel={() => { this.setState({ visible: false }) }} + footer={[ + <Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>{this.props.dict['main.revert.default']}</Button>, + <Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{this.props.dict['main.cancel']}</Button>, + <Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>{this.props.dict['main.submit']}</Button> + ]} + destroyOnClose + > + {this.state.visible ? + <VerifyCard + MenuID={this.props.MenuID} + MenuName={this.props.MenuName} + permAction={this.props.permAction} + permRoles={this.props.permRoles} + config={this.props.config} + userConfig={this.props.userConfig} + columns={this.props.columns} + handleParam={this.changeMenuParam} + /> : null + } + </Modal> + </div> + ) + } +} + +export default CustomSetting \ No newline at end of file diff --git a/src/tabviews/zshare/settingcomponent/index.scss b/src/tabviews/zshare/settingcomponent/index.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/tabviews/zshare/settingcomponent/index.scss diff --git a/src/templates/comtableconfig/source.jsx b/src/templates/comtableconfig/source.jsx index c7edb97..44e9a78 100644 --- a/src/templates/comtableconfig/source.jsx +++ b/src/templates/comtableconfig/source.jsx @@ -304,20 +304,8 @@ }, { type: 'action', - label: CommonDict['header.form.blank'], - subType: 'blank', - url: '' - }, - { - type: 'action', - label: CommonDict['header.form.newpage.inner'], + label: CommonDict['header.form.newpage'], subType: 'innerpage', - url: '' - }, - { - type: 'action', - label: CommonDict['header.form.newpage.outer'], - subType: 'outerpage', url: '' }, { diff --git a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx index 329d0c8..4677c2e 100644 --- a/src/templates/sharecomponent/actioncomponent/actionform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/actionform/index.jsx @@ -74,14 +74,18 @@ if (card.execMode) { // 杞崲鎵撳嵃鏃舵墦寮�鏂瑰紡 _opentype = 'funcbutton' + } else if (_opentype === 'outerpage') { + card.pageTemplate = 'custom' + _opentype = 'innerpage' } let _tabs = this.props.tabs.filter(tab => tab.type === _tabType) - if (_opentype === 'innerpage') { // 鏂伴〉闈紙鍐呴儴锛夛紝鍙�夋ā鏉� + if (_opentype === 'innerpage') { // 鏂伴〉闈紝鍙�夋ā鏉�(鑷畾涔夋椂锛屽彲濉叆澶栭儴閾炬帴) _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] - } else if (_opentype === 'outerpage') { // 鏂伴〉闈紙澶栭儴锛夛紝闇�瑕侀〉闈㈠湴鍧� - _options = ['label', 'Ot', 'OpenType', 'url', 'icon', 'class', 'position'] + if (card.pageTemplate === 'custom') { + _options.push('url') + } } else if (_opentype === 'blank' || _opentype === 'tab') { // 鏂版爣绛炬垨褰撳墠椤甸潰鏇挎崲 _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate'] } else if (_opentype === 'popview') { // 妯℃�佹鏍囩椤� @@ -128,9 +132,9 @@ } else if (item.key === 'icon') { item.options = btnIcons } else if (item.key === 'Ot') { - if (_opentype === 'innerpage' || card.position === 'grid') { + if (card.position === 'grid') { item.options = this.state.requireOptions.filter(op => ['requiredSgl'].includes(op.value)) - } else if (['outerpage', 'blank', 'tab', 'popview', 'excelIn'].includes(_opentype)) { + } else if (['innerpage', 'blank', 'tab', 'popview', 'excelIn'].includes(_opentype)) { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) } else if (card.sqlType === 'insert') { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl', 'required'].includes(op.value)) @@ -181,12 +185,15 @@ * 3銆佸垏鎹㈡爣绛剧被鍨嬶紝閲嶇疆鍙�夋爣绛� */ openTypeChange = (key, value) => { + const { card } = this.props + if (key === 'OpenType') { let _options = null if (value === 'innerpage') { _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] - } else if (value === 'outerpage') { - _options = ['label', 'Ot', 'OpenType', 'url', 'icon', 'class', 'position'] + if (card.pageTemplate === 'custom') { + _options.push('url') + } } else if (value === 'blank' || value === 'tab') { _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabTemplate'] } else if (value === 'popview') { @@ -233,10 +240,10 @@ if (item.key === 'intertype') { _fieldval.intertype = this.state.interType } else if (item.key === 'Ot') { - if (value === 'innerpage' || this.state.position === 'grid') { + if (this.state.position === 'grid') { item.options = this.state.requireOptions.filter(op => ['requiredSgl'].includes(op.value)) _fieldval.Ot = 'requiredSgl' - } else if (['outerpage', 'blank', 'tab', 'popview'].includes(value)) { + } else if (['innerpage', 'blank', 'tab', 'popview'].includes(value)) { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) _fieldval.Ot = 'requiredSgl' } else if (value === 'excelIn') { @@ -278,10 +285,10 @@ position: value, formlist: this.state.formlist.map(item => { if (item.key === 'Ot') { - if (this.state.openType === 'innerpage' || value === 'grid') { + if (value === 'grid') { item.options = this.state.requireOptions.filter(op => ['requiredSgl'].includes(op.value)) _fieldval.Ot = 'requiredSgl' - } else if (['outerpage', 'blank', 'tab', 'popview'].includes(this.state.openType)) { + } else if (['innerpage', 'blank', 'tab', 'popview'].includes(this.state.openType)) { item.options = this.state.requireOptions.filter(op => ['notRequired', 'requiredSgl'].includes(op.value)) _fieldval.Ot = 'requiredSgl' } else { @@ -372,6 +379,22 @@ this.props.form.setFieldsValue(_fieldval) }) + } else if (key === 'pageTemplate') { + let _options = null + if (value === 'custom') { + _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'url', 'icon', 'class', 'position'] + } else { + _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class', 'position'] + } + + this.setState({ + openType: value, + formlist: this.state.formlist.map(item => { + item.hidden = !_options.includes(item.key) + + return item + }) + }) } } diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx index eac33e2..9757d5a 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx @@ -241,7 +241,7 @@ </Tooltip> }> {getFieldDecorator('position', { - initialValue: 'back' + initialValue: 'front' })( <Radio.Group> <Radio value="init">鍒濆鍖�</Radio> diff --git a/src/templates/sharecomponent/cardcomponent/carddetailform/index.jsx b/src/templates/sharecomponent/cardcomponent/carddetailform/index.jsx index e274771..744c7e2 100644 --- a/src/templates/sharecomponent/cardcomponent/carddetailform/index.jsx +++ b/src/templates/sharecomponent/cardcomponent/carddetailform/index.jsx @@ -127,7 +127,7 @@ this.state.formlist.forEach((item, index) => { if (item.hidden || item.forbid) return - if (item.type === 'text') { // 鏂囨湰鎼滅储 + if (item.type === 'text') { fields.push( <Col span={12} key={index}> <Form.Item label={item.tooltip ? @@ -270,9 +270,13 @@ values.content = columns.filter(col => col.value === values.field)[0].text } } - if (['bottom', 'header'].includes(values.elemType) && values.actions) { + if (values.elemType === 'bottom' && values.actions) { values.actions = values.actions.map(item => actions.filter(action => action.value === item)[0]) } + if (values.elemType === 'header' && values.actions) { + values.actions = actions.filter(action => action.value === values.actions) + } + if (['avatar'].includes(values.elemType)) { if (values.type === 'icon') { let column = columns.filter(col => col.value === values.field)[0] diff --git a/src/templates/sharecomponent/cardcomponent/index.jsx b/src/templates/sharecomponent/cardcomponent/index.jsx index a55ddf4..a63c6a9 100644 --- a/src/templates/sharecomponent/cardcomponent/index.jsx +++ b/src/templates/sharecomponent/cardcomponent/index.jsx @@ -99,7 +99,10 @@ text: col.label } }) - let _actions = config.action.filter(item => item.Ot && item.Ot !== 'notRequired' && !['excelIn', 'excelOut'].includes(item.OpenType)) + let _actions = config.action.filter(item => + (item.Ot && item.Ot !== 'notRequired' && !['excelIn', 'excelOut'].includes(item.OpenType)) || + item.funcType === 'changeuser' + ) let actionIds = [] _actions = _actions.map(item => { @@ -130,7 +133,10 @@ editBottom = () => { const { config, card } = this.props - let _actions = config.action.filter(item => item.Ot && item.Ot !== 'notRequired' && !['excelIn', 'excelOut'].includes(item.OpenType)) + let _actions = config.action.filter(item => + (item.Ot && item.Ot !== 'notRequired' && !['excelIn', 'excelOut'].includes(item.OpenType)) || + item.funcType === 'changeuser' + ) let actionIds = [] _actions = _actions.map(item => { @@ -305,7 +311,7 @@ } else { outclass += ' ant-card-bordered' } - + console.log(card.header.actions) return ( <div className="line-card-edit-box mingke-table"> {card.title ? <p className="chart-title">{card.title}</p> : null} @@ -321,13 +327,10 @@ <div className="ant-card-head-title">{card.header.content}</div> {card.header.actions && card.header.actions.length > 0 ? <div className="ant-card-extra"> - {card.header.actions.length === 1 ? - <span> - {['icon', 'all'].includes(card.header.show) ? <Icon type={card.header.actions[0].icon || 'dash'}/> : null} - {['text', 'all'].includes(card.header.show) ? card.header.actions[0].text : null} - </span> : null - } - {card.header.actions.length > 1 ? <span>Action</span> : null} + <span> + {['icon', 'all'].includes(card.header.show) ? <Icon type={card.header.actions[0].icon || 'dash'}/> : null} + {['text', 'all'].includes(card.header.show) ? card.header.actions[0].text : null} + </span> </div> : null } </div> diff --git a/src/templates/sharecomponent/cardcomponent/index.scss b/src/templates/sharecomponent/cardcomponent/index.scss index c21dd06..2c31437 100644 --- a/src/templates/sharecomponent/cardcomponent/index.scss +++ b/src/templates/sharecomponent/cardcomponent/index.scss @@ -95,7 +95,7 @@ .edit { position: absolute; left: 0; - top: 3px; + top: 0px; font-size: 13px; color: #1890ff; cursor: pointer; @@ -118,7 +118,7 @@ .edit { position: absolute; left: 0; - top: 3px; + top: 0px; font-size: 13px; color: #1890ff; cursor: pointer; diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 2145a23..cc32c26 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -949,14 +949,8 @@ value: 'tab', text: Formdict['header.form.tab'] }, { - value: 'blank', - text: Formdict['header.form.blank'] - }, { value: 'innerpage', - text: Formdict['header.form.newpage.inner'] - }, { - value: 'outerpage', - text: Formdict['header.form.newpage.outer'] + text: Formdict['header.form.newpage'] }, { value: 'funcbutton', text: Formdict['header.form.funcbutton'] @@ -1095,6 +1089,9 @@ options: [{ value: 'print', text: Formdict['header.menu.printTemplate'] + }, { + value: 'custom', + text: Formdict['header.form.custom'] }] }, { @@ -2468,6 +2465,16 @@ * @param {object} card // 鏍囩閰嶇疆淇℃伅 */ export function getCardDetailForm (card, _columns, _type, _actions = []) { + let actions = '' + if (_type === 'bottom') { + actions = card.actions ? card.actions.map(cell => cell.value) : [] + } else { + _actions.unshift({ + value: '', + text: '绌�' + }) + actions = card.actions[0] ? card.actions[0].value : '' + } return [ { type: 'radio', @@ -2606,6 +2613,16 @@ }] }, { + type: _type === 'bottom' ? 'multiselect' : 'select', + key: 'actions', + label: '鎸夐挳缁�', + tooltip: '', + initVal: actions, + required: false, + forbid: !['header', 'bottom'].includes(_type), + options: _actions + }, + { type: 'radio', key: 'show', label: '鏄剧ず', @@ -2623,15 +2640,6 @@ text: '鍏ㄩ儴' }] }, - { - type: 'multiselect', - key: 'actions', - label: '鎸夐挳缁�', - tooltip: '', - initVal: card.actions ? card.actions.map(cell => cell.value) : [], - required: false, - forbid: !['header', 'bottom'].includes(_type), - options: _actions - }, + ] } \ No newline at end of file diff --git a/src/templates/zshare/verifycard/customscript/index.jsx b/src/templates/zshare/verifycard/customscript/index.jsx index 6a84018..7191459 100644 --- a/src/templates/zshare/verifycard/customscript/index.jsx +++ b/src/templates/zshare/verifycard/customscript/index.jsx @@ -203,7 +203,7 @@ </Tooltip> }> {getFieldDecorator('position', { - initialValue: 'back' + initialValue: 'front' })( <Radio.Group> <Radio value="init">鍒濆鍖�</Radio> diff --git a/src/templates/zshare/verifycard/voucherform/index.jsx b/src/templates/zshare/verifycard/voucherform/index.jsx index 7af62dc..6341055 100644 --- a/src/templates/zshare/verifycard/voucherform/index.jsx +++ b/src/templates/zshare/verifycard/voucherform/index.jsx @@ -1,9 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Form, Row, Col, Select, Switch } from 'antd' +import { Form, Row, Col, Select, Switch, notification } from 'antd' import './index.scss' - class UniqueForm extends Component { static propTpyes = { @@ -126,6 +125,15 @@ if (!err) { values.enabled = true let _detail = this.state.voucherDetail.filter(item => item.ModularDetailCode === values.VoucherTypeOne)[0] + + if (!_detail) { + notification.warning({ + top: 92, + message: '鍑瘉绫诲瀷鎴栧嚟璇佹爣璇嗕笉瀛樺湪锛�', + duration: 5 + }) + return + } values.VoucherTypeTwo = _detail.VoucherTypeTwo values.Type = _detail.IDefine1 diff --git a/src/utils/asyncSpinComponent.jsx b/src/utils/asyncSpinComponent.jsx index d9be073..0754c07 100644 --- a/src/utils/asyncSpinComponent.jsx +++ b/src/utils/asyncSpinComponent.jsx @@ -26,7 +26,7 @@ return C ? <C {...this.props} /> : - <div style={{textAlign: 'center', minHeight: 50, lineHeight: '50px'}}><Spin/></div> + <div className="async-spin" style={{textAlign: 'center', minHeight: 50, lineHeight: '50px'}}><Spin/></div> } } } \ No newline at end of file diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index add45cc..02a6226 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -8,14 +8,12 @@ import enUS from '@/locales/en-US/login.js' import options from '@/store/options.js' import Utils from '@/utils/utils.js' -import asyncComponent from '@/utils/asyncComponent' import asyncLoadComponent from '@/utils/asyncLoadComponent' import { modifyMemberLevel } from '@/store/action' import './index.scss' const LoginForm = asyncLoadComponent(() => import('./loginform')) const LoginCloudForm = asyncLoadComponent(() => import('./logincloudform')) -const Action = asyncComponent(() => import('@/tabviews/zshare/actionList')) const iszhCN = !localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN' class Login extends Component { @@ -32,7 +30,6 @@ lineColor: window.GLOB.lineColor || '', webSite: window.GLOB.webSite || '', langList: [], - loaded: false, syncApp: false, syncing: false } @@ -317,7 +314,6 @@ isDisabled={this.state.isDisabled} changelang={(value) => this.changelang(value)} handleSubmit={() => this.handleSubmit()} - handleloaded={() => {this.setState({loaded: true})}} wrappedComponentRef={(inst) => this.loginformRef = inst} /> </div> @@ -343,24 +339,6 @@ > <LoginCloudForm handleSubmit={() => this.syncSubmit()} wrappedComponentRef={(inst) => this.logincloudRef = inst}/> </Modal> - {this.state.loaded ? <div style={{position: 'fixed', bottom: '-300px'}}> - <Action - BID="" - type="" - menuType="" - setting={{}} - actions={[]} - triggerBtn={{}} - dict={{}} - MenuID="" - logcolumns={[]} - ContainerId="" - refreshdata={() => {}} - triggerPopview={() => {}} - getexceloutparam={() => {}} - gettableselected={() => {}} - /> - </div> : null} </div> ) } diff --git a/src/views/login/loginform.jsx b/src/views/login/loginform.jsx index 0b42bc9..4aa10ca 100644 --- a/src/views/login/loginform.jsx +++ b/src/views/login/loginform.jsx @@ -10,7 +10,6 @@ isDisabled: PropTypes.bool, changelang: PropTypes.func, handleSubmit: PropTypes.func, - handleloaded: PropTypes.func, dict: PropTypes.object, auth: PropTypes.bool, lang: PropTypes.string, @@ -98,7 +97,6 @@ input.focus() } } - this.props.handleloaded() } render() { -- Gitblit v1.8.0