From 5088d267c69e87673c85ba302dd9dc62c9da4951 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 16 二月 2020 18:54:49 +0800 Subject: [PATCH] 2020-02-16 --- src/components/tabview/index.jsx | 74 +- src/tabviews/tableshare/mutilform/index.jsx | 86 -- src/templates/comtableconfig/actionform/index.jsx | 35 src/tabviews/formtab/index.jsx | 195 ++++++- src/tabviews/formtab/actionList/index.jsx | 510 ++++++------------- src/tabviews/formtab/formgroup/index.jsx | 130 ++--- src/components/sidemenu/editthdmenu/index.jsx | 3 src/templates/comtableconfig/index.jsx | 20 src/tabviews/tableshare/actionList/index.jsx | 104 +++ src/tabviews/subtable/index.jsx | 26 src/tabviews/subtabtable/index.jsx | 26 src/components/sidemenu/index.jsx | 6 src/tabviews/commontable/index.jsx | 83 ++- src/templates/ushare/editable/index.jsx | 8 src/utils/utils.js | 136 ++++ src/templates/subtableconfig/actionform/index.jsx | 47 + 16 files changed, 812 insertions(+), 677 deletions(-) diff --git a/src/components/sidemenu/editthdmenu/index.jsx b/src/components/sidemenu/editthdmenu/index.jsx index 0ffe016..a078950 100644 --- a/src/components/sidemenu/editthdmenu/index.jsx +++ b/src/components/sidemenu/editthdmenu/index.jsx @@ -88,7 +88,6 @@ */ handleMenu = (menu) => { const _this = this - console.log(menu) if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) { notification.warning({ top: 92, @@ -554,7 +553,7 @@ this.setState({ confirmLoading: true }) - console.log(param) + Api.getSystemConfig(param).then(response => { if (response.status) { this.setState({ diff --git a/src/components/sidemenu/index.jsx b/src/components/sidemenu/index.jsx index 1f98c89..cda1c72 100644 --- a/src/components/sidemenu/index.jsx +++ b/src/components/sidemenu/index.jsx @@ -206,13 +206,7 @@ } shouldComponentUpdate(nextProps, nextState) { - // if (!is(fromJS(this.props.mainMenu), fromJS(nextProps.mainMenu)) || (!this.props.collapse && !is(fromJS(this.props.tabviews), fromJS(nextProps.tabviews)))) { - // if (!is(fromJS(this.props.mainMenu), fromJS(nextProps.mainMenu))) { - // // 涓昏彍鍗曞垏鎹紝鎴栬彍鍗曞睍寮�涓嬬殑tab椤靛彉鍖栵紝涓嶄細鍒锋柊 - // return false - // } else { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) - // } } onOpenChange = openKeys => { diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx index eeefeef..ddbc7d9 100644 --- a/src/components/tabview/index.jsx +++ b/src/components/tabview/index.jsx @@ -32,47 +32,46 @@ } state = { - selectedTabId: '', // 褰撳墠閫変腑tab椤甸潰 + tabviews: null, // 鏍囩闆� iFrameHeight: 0, dict: (!sessionStorage.getItem('lang') || sessionStorage.getItem('lang') === 'zh-CN') ? mzhCN : menUS, locale: (!sessionStorage.getItem('lang') || sessionStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS } - handleTabview (menu) { + handleTabview (e, menu) { + e.stopPropagation() // 鍏抽棴tab椤碉紝閲嶆柊閫夋嫨鏄剧ず椤� - let tabs = JSON.parse(JSON.stringify(this.props.tabviews)) + let tabs = JSON.parse(JSON.stringify(this.state.tabviews)) tabs = tabs.filter(tab => { - if (tab.MenuID === this.state.selectedTabId) { - tab.selected = true - } else { - tab.selected = false - } return tab.MenuID !== menu.MenuID }) - if (menu.MenuID === this.state.selectedTabId) { + if (menu.selected) { tabs[0] && (tabs[0].selected = true) } this.props.modifyTabview(tabs) } - changeTab (menu) { + changeTab (e, menu) { + e.stopPropagation() // 绐楀彛鍒囨崲 - this.setState({ - selectedTabId: menu.MenuID - }) - let tabs = JSON.parse(JSON.stringify(this.props.tabviews)) + let tabs = JSON.parse(JSON.stringify(this.state.tabviews)) tabs = tabs.map(tab => { + tab.selected = false + if (tab.MenuID === menu.MenuID) { tab.selected = true - } else { - tab.selected = false } + return tab }) + + this.setState({ + tabviews: tabs + }) + this.props.modifyTabview(tabs) - this.resetWindow(menu) } selectcomponent (view) { @@ -129,6 +128,9 @@ } else { moment.locale('en') } + this.setState({ + tabviews: this.props.tabviews + }) } componentDidMount () { @@ -147,11 +149,11 @@ } UNSAFE_componentWillReceiveProps (nextProps) { - if (nextProps.tabviews && !is(fromJS(this.props.tabviews), fromJS(nextProps.tabviews))) { + if (nextProps.tabviews && !is(fromJS(this.state.tabviews), fromJS(nextProps.tabviews))) { // tab绐楀彛椤靛鍔犳垨鍒犻櫎 - if (nextProps.tabviews.length > this.props.tabviews.length) { + if (nextProps.tabviews.length > this.state.tabviews.length) { // 鏌ョ湅鏂皌ab椤甸渶瑕佺粍浠舵槸鍚﹀姞杞� - let MenuIDs = this.props.tabviews.map(tab => {return tab.MenuID}) + let MenuIDs = this.state.tabviews.map(tab => {return tab.MenuID}) let newtab = nextProps.tabviews.filter(tab => !MenuIDs.includes(tab.MenuID))[0] if (!Comps.Home && newtab.type === 'Home') { Comps.Home = asyncComponent(() => import('@/tabviews/home')) @@ -170,36 +172,44 @@ } } - // 璁剧疆閫変腑绐楀彛 - let view = nextProps.tabviews.filter(tab => tab.selected)[0] + // 淇濆瓨淇敼鏍囩闆� this.setState({ - selectedTabId: view ? view.MenuID : '' + tabviews: nextProps.tabviews }) - this.resetWindow(view) + + let node = document.getElementById('root').parentNode.parentNode + if (node) { + node.scrollTop = 0 + } } } - shouldComponentUpdate(nextProps, nextState) { - return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) - } + // shouldComponentUpdate(nextProps, nextState) { + // return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) + // } render () { + const { tabviews } = this.state + let view = tabviews.filter(tab => tab.selected)[0] + this.resetWindow(view) + let selectedTabId = view ? view.MenuID : '' + return ( <section className={'flex-container content-box' + (this.props.collapse ? ' collapsed' : '')}> <ConfigProvider locale={this.state.locale}> <div className="content-header"> - {this.props.tabviews && this.props.tabviews.length > 0 && - <Tabs activeKey={this.state.selectedTabId}> - {this.props.tabviews.map(view => { + {tabviews && tabviews.length > 0 && + <Tabs activeKey={selectedTabId}> + {tabviews.map(view => { return ( <Tabs.TabPane className="test" tab={ <span className="tab-control"> - <span className="tab-name" onClick={() => {this.changeTab(view)}}> + <span className="tab-name" onClick={(e) => {this.changeTab(e, view)}}> {view.MenuName} </span> - {view.type !== 'Home' ? <Icon type="close" onClick={() => {this.handleTabview(view)}}/> : null} + {view.type !== 'Home' ? <Icon type="close" onClick={(e) => {this.handleTabview(e, view)}}/> : null} </span> } key={view.MenuID} diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index ffc11cf..4da0895 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -49,8 +49,7 @@ loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 - orderColumn: '', // 鎺掑簭瀛楁 - orderType: 'asc', // 鎺掑簭鏂瑰紡 + orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� BIDs: {}, // 涓婄骇琛╥d setsingle: false, // 涓昏〃鍗曢�夊閫夊垏鎹� @@ -58,7 +57,9 @@ isLinkMain: false, // 鏄惁瀛樺湪涓庝富琛ㄥ叧鑱旂殑瀛愯〃 popAction: false, // 寮规椤甸潰锛屾寜閽俊鎭� popData: false, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 - visible: false // 寮规鏄剧ず闅愯棌鎺у埗 + visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 + tabBtn: null, // 琛ㄥ崟鏍囩鎸夐挳 + tabParam: null // 琛ㄥ崟鏍囩鍙傛暟 } /** @@ -355,15 +356,14 @@ * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� */ getCustomParam = () => { - const { pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state + const { pageIndex, pageSize, orderBy, search, setting } = this.state let _search = Utils.formatCustomMainSearch(search) let param = { PageIndex: pageIndex, PageSize: pageSize, - OrderCol: orderColumn, - OrderType: orderType, + OrderCol: orderBy || setting.order, ..._search } @@ -390,7 +390,7 @@ * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� */ getDefaultParam = () => { - const { arr_field, pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state + const { arr_field, pageIndex, pageSize, orderBy, search, setting } = this.state if (!arr_field) { notification.warning({ @@ -412,7 +412,7 @@ appkey: window.GLOB.appkey || '' } - let orderBy = orderColumn ? (orderColumn + ' ' + orderType) : setting.order + let _orderBy = orderBy || setting.order let _dataresource = setting.dataresource if (/\s/.test(_dataresource)) { @@ -445,10 +445,9 @@ _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 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}` - console.log(LText) - console.log(DateCount) + param.LText = Utils.formatOptions(LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' param.secretkey = Utils.encrypt(param.LText, param.timestamp) @@ -502,8 +501,7 @@ loading: true, pageIndex: pagination.current, pageSize: pagination.pageSize, - orderColumn: sorter.field || this.state.setting.orderColumn, - orderType: sorter.order || 'asc' + orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' }, () => { this.loadmaindata() }) @@ -542,8 +540,7 @@ loading: false, pageIndex: 1, pageSize: 10, - orderColumn: '', - orderType: 'asc', + orderBy: '', search: '', BIDs: {}, setsingle: false, @@ -576,6 +573,23 @@ } /** + * @description 琛ㄥ崟鎿嶄綔瀹屾垚鍚庡埛鏂颁富椤甸潰 + */ + refreshbyformtab = (type) => { + this.setState({ + view: 'commontable', + tabBtn: null, + tabParam: null + }, () => { + if (type === 'grid') { + this.reloadtable() + } else if (type === 'view') { + this.reloadview() + } + }) + } + + /** * @description 瀛愯〃鎿嶄綔瀹屾垚鍚庡埛鏂颁富琛� */ handleMainTable = () => { @@ -587,7 +601,7 @@ */ handleDefaultExcelout = (btn) => { const { MenuName } = this.props - const { arr_field, orderColumn, orderType, search, setting, config } = this.state + const { arr_field, orderBy, search, setting, config } = this.state let _arr_labels = [] // 鍒楀悕绉伴泦 let _arr_label_field = [] // 鍒楀悕绉板瓧娈甸泦 @@ -613,14 +627,14 @@ appkey: window.GLOB.appkey || '' } - let orderBy = orderColumn ? (orderColumn + ' ' + orderType) : setting.order + let _orderBy = orderBy || setting.order let _dataresource = setting.dataresource if (/\s/.test(_dataresource)) { _dataresource = '(' + _dataresource + ') tb' } - let LText = `select ${_arr_label_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` + let LText = `select ${_arr_label_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` param.LText = Utils.formatOptions(LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' @@ -712,7 +726,7 @@ if (btn.OpenType === 'popview') { this.setState({ popAction: btn, - popData: data[0] ? data[0] : null, + popData: data[0] || null, visible: true }) } else if (btn.OpenType === 'tab') { @@ -724,25 +738,33 @@ type: btn.tabTemplate, selected: true, param: { + parentId: this.props.MenuID, btn: btn, - data: data, + data: data[0] || null, primaryId: _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 } - tab.selected = false return tab }) - tabs.splice(index + 1, 0, newtab) - + if (!isexit) { + tabs.splice(index + 1, 0, newtab) + } + this.props.modifyTabview(tabs) } else if (btn.OpenType === 'blank') { this.setState({ @@ -750,7 +772,7 @@ tabBtn: btn, tabParam: { btn: btn, - data: data, + data: data[0] || null, primaryId: _primaryId, arr_field: this.state.arr_field } @@ -768,6 +790,17 @@ 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) { @@ -894,7 +927,7 @@ </Modal> {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> : null} - {view === 'formtab' ? <FormTab MenuID={this.state.tabBtn.uuid} param={this.state.tabParam}/> : null} + {view === 'formtab' ? <FormTab MenuID={this.state.tabBtn.uuid} param={this.state.tabParam} refresh={this.refreshbyformtab}/> : null} </div> ) } diff --git a/src/tabviews/formtab/actionList/index.jsx b/src/tabviews/formtab/actionList/index.jsx index f6a51ac..72af4f9 100644 --- a/src/tabviews/formtab/actionList/index.jsx +++ b/src/tabviews/formtab/actionList/index.jsx @@ -11,11 +11,13 @@ class MainAction extends Component { static propTpyes = { MenuID: PropTypes.string, // 鑿滃崟ID + primaryId: PropTypes.string, // 涓婚敭 actions: PropTypes.array, // 鎸夐挳缁� logcolumns: PropTypes.array, // 鏄剧ず鍒� dict: PropTypes.object, // 瀛楀吀椤� data: PropTypes.any, // 鏁版嵁 setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + getFormData: PropTypes.func, // 鑾峰彇琛ㄥ崟鍊� refreshdata: PropTypes.func, // 鎵ц瀹屾垚鍚庢暟鎹埛鏂� } @@ -33,21 +35,29 @@ let _this = this - if (item.OpenType === 'prompt') { - confirm({ - title: this.props.dict['main.action.confirm.tip'], - onOk() { - return new Promise(resolve => { - _this.execSubmit(item, data, resolve) + if (item.btnType !== 'cancel') { + this.props.getFormData().then(res => { + if (item.OpenType === 'prompt') { + confirm({ + title: this.props.dict['main.action.confirm.tip'], + onOk() { + return new Promise(resolve => { + _this.execSubmit(item, data, resolve, res) + }) + }, + onCancel() {} }) - }, - onCancel() {} + } else if (item.OpenType === 'exec') { + this.setState({loadingUuid: item.uuid}) + + this.execSubmit(item, data, () => { + this.setState({loadingUuid: ''}) + }, res) + } }) - } else if (item.OpenType === 'exec') { - this.setState({loadingUuid: item.uuid}) - this.execSubmit(item, data, () => { - this.setState({loadingUuid: ''}) - }) + } else { + item.afterExecSuccess = 'close' + this.props.refreshdata(item, 'success', '') } } @@ -55,7 +65,9 @@ * @description 鎸夐挳鎻愪氦鎵ц */ execSubmit = (btn, data, _resolve, formdata) => { - const { setting, logcolumns } = this.props + const { setting, logcolumns, primaryId } = this.props + + let _primaryId = primaryId if (btn.intertype === 'inner') { // 浣跨敤鍐呴儴鎺ュ彛鏃讹紝鍐呴儴鍑芥暟鍜屾暟鎹簮涓嶅彲鍚屾椂涓虹┖, 浣跨敤绯荤粺鍑芥暟鏃讹紝绫诲瀷涓嶅彲涓虹┖ @@ -65,163 +77,58 @@ return } - // 鎵ц鏂瑰紡涓哄琛屾嫾鎺ワ紝涓旀墦寮�鏂瑰紡涓鸿〃鍗曟椂锛屼細杞负寰幆鍙戦�佽姹� - // 鎵撳紑鏂瑰紡涓烘ā鎬佹锛屼娇鐢ㄥ唴閮ㄥ嚱鏁版坊鍔� - if ( - btn.Ot === 'notRequired' || - btn.Ot === 'requiredSgl' || - (btn.Ot === 'requiredOnce' && btn.OpenType !== 'pop') || - (btn.OpenType === 'pop' && !btn.innerFunc && btn.sql && btn.sqlType === 'insert') - ) { - - // 鍒涘缓鍑瘉鏃讹紝闇�瑕侀�夋嫨琛屾椂 - if (data.length === 0 && !btn.innerFunc && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { - notification.warning({ - top: 92, - message: '浣跨敤鍒涘缓鍑瘉鍑芥暟锛岄渶瑕侀�夋嫨琛岋紒', - duration: 10 - }) - return - } - - let param = { // 绯荤粺瀛樺偍杩囩▼ - func: 'sPC_TableData_InUpDe', - BID: '' - } - let primaryId = setting.primaryKey && data[0] ? (data[0][setting.primaryKey] || '') : '' - - if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 鏄惁寮规鎴栫洿鎺ユ墽琛� - let ID = '' - if (btn.Ot === 'notRequired') { - - } else if (btn.Ot === 'requiredSgl') { - ID = data[0][setting.primaryKey] - } else if (btn.Ot === 'requiredOnce') { // id鍊兼嫾鎺� - let ids = data.map(d => { return d[setting.primaryKey]}) - ID = ids.join(',') - } - - if (btn.innerFunc) { // 浣跨敤鑷畾涔夊嚱鏁� - param.func = btn.innerFunc - if (setting.primaryKey) { // 涓婚敭瀛樺湪鏃讹紝璁剧疆涓婚敭鍙傛暟 - param[setting.primaryKey] = ID - } - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, '', param, data[0], logcolumns)) // 鏁版嵁婧� - 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 - param.ID = Utils.getguid() - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns)) // 鏁版嵁婧� - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], logcolumns)) // 鏁版嵁婧� - param.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() + // 鍒涘缓鍑瘉鏃讹紝闇�瑕侀�夋嫨琛屾椂 + if (!data && !btn.innerFunc && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { + notification.warning({ + top: 92, + message: '浣跨敤鍒涘缓鍑瘉鍑芥暟锛岄渶瑕侀�夋嫨琛岋紒', + duration: 10 }) - } else if (btn.Ot === 'required' || (btn.Ot === 'requiredOnce' && btn.OpenType === 'pop')) { - let _params = data.map(cell => { - let param = { - func: 'sPC_TableData_InUpDe', - 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.formatOptions(Utils.getSysDefaultSql(btn, setting, '', param, cell, logcolumns)) // 鏁版嵁婧� - 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 - - formdata.forEach(_data => { - param[_data.key] = _data.value - }) - - if (setting.primaryKey) { - param[setting.primaryKey] = primaryId - } - } else if (btn.sql) { - param.ID = primaryId - param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, cell, logcolumns)) // 鏁版嵁婧� - 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 } + + let param = { // 绯荤粺瀛樺偍杩囩▼ + func: 'sPC_TableData_InUpDe', + BID: '' + } + + if (btn.innerFunc) { + param.func = btn.innerFunc + + param[setting.primaryKey] = primaryId + + formdata.forEach(_data => { + param[_data.key] = _data.value + }) + + if (!param[setting.primaryKey]) { + param[setting.primaryKey] = Utils.getguid() + } + + _primaryId = param[setting.primaryKey] + + } else if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid + param.ID = Utils.getguid() + param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, data, logcolumns)) // 鏁版嵁婧� + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + _primaryId = param.ID + } else if (btn.sql) { + param.ID = primaryId + param.LText = Utils.formatOptions(Utils.getSysDefaultSql(btn, setting, formdata, param, data, logcolumns)) // 鏁版嵁婧� + 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, _primaryId) + } else { + this.execError(res, btn) + } + _resolve() + }) } else if (btn.intertype === 'outer') { /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ @@ -231,183 +138,102 @@ return } - let _params = [] // 璇锋眰鍙傛暟鏁扮粍 - - if (btn.Ot === 'notRequired' || btn.Ot === 'requiredSgl' || btn.Ot === 'requiredOnce') { - let param = { - 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') { - // 閫夋嫨澶氳锛屽惊鐜皟鐢� - - let _formparam = {} - if (btn.OpenType === 'pop' && formdata) { // 琛ㄥ崟 - formdata.forEach(_data => { - _formparam[_data.key] = _data.value - }) - } - - _params = data.map(cell => { - let _cell = { - BID: '', - } - if (setting.primaryKey) { - _cell[setting.primaryKey] = cell[setting.primaryKey] - } - - _cell = {..._formparam, ..._cell} - - return _cell - }) - } else { - this.actionSettingError() - _resolve() - return + let param = { + BID: '' } - // 寰幆璋冪敤澶栭儴鎺ュ彛锛堝寘鎷唴閮ㄥ強鍥炶皟鍑芥暟锛� - this.outerLoopRequest(_params, btn, _resolve) + param[setting.primaryKey] = primaryId + + formdata.forEach(_data => { + param[_data.key] = _data.value + }) + + if (!param[setting.primaryKey]) { + param[setting.primaryKey] = Utils.getguid() + } + _primaryId = param[setting.primaryKey] + + 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 + + // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 + 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 (btn.sysInterface === 'true') { + res.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi + } else { + res.rduri = btn.interface + } + + if (btn.outerFunc) { + res.func = btn.outerFunc + } + + res.appkey = window.GLOB.appkey || '' // 澶栭儴璇锋眰鏃讹紝缁熶竴娣诲姞appkey + + 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, _primaryId) + _resolve() + } else { + this.execError(response, btn) + _resolve() + } + } + }).then(res => { + if (!res) return + + if (res.status) { + this.execSuccess(btn, res, _primaryId) + _resolve() + } else { + this.execError(res, btn) + _resolve() + } + }) } else { this.actionSettingError() _resolve() return } - } - - /** - * @description 鍐呴儴璇锋眰寰幆鎵ц - */ - innerLoopRequest = (params, btn, _resolve) => { - if (!params && params.length === 0) return - - let param = params.shift() - - 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) => { - if (!params && params.length === 0) return - - 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 - - // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 - 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 (btn.sysInterface === 'true') { - res.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi - } else { - res.rduri = btn.interface - } - // res.method = btn.method - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - res.appkey = window.GLOB.appkey || '' // 澶栭儴璇锋眰鏃讹紝缁熶竴娣诲姞appkey - - 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) - } - } 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) - } - } else { - this.execError(res, btn) - _resolve() - } - }) } /** @@ -418,12 +244,8 @@ * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� */ - execSuccess = (btn, res) => { - if (btn.OpenType === 'excelOut') { // 瀵煎嚭excel - this.setState({ - loadingUuid: '' - }) - } else if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 + execSuccess = (btn, res, primaryId) => { + if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 notification.success({ top: 92, message: res.ErrMesg || this.props.dict['main.action.confirm.success'], @@ -433,7 +255,7 @@ } - this.props.refreshdata(btn, 'success') + this.props.refreshdata(btn, 'success', primaryId) } /** diff --git a/src/tabviews/formtab/formgroup/index.jsx b/src/tabviews/formtab/formgroup/index.jsx index 9bd6ce0..7260090 100644 --- a/src/tabviews/formtab/formgroup/index.jsx +++ b/src/tabviews/formtab/formgroup/index.jsx @@ -24,6 +24,8 @@ state = { datatype: null, readtype: null, + readin: null, + fieldlen: null, groups: null, formlist: [], record: {} @@ -34,14 +36,30 @@ let datatype = {} let readtype = {} + let readin = {} + let fieldlen = {} let _formlist = [] let _groups = groups.map(group => { group.sublist = group.sublist.map(item => { + let _readin = item.readin !== 'false' + if (item.type === 'funcvar') { + _readin = false + } + + let _fieldlen = item.fieldlength || 50 + if (item.type === 'textarea' || item.type === 'fileupload') { + _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' - - if (!/^date/.test(item.type) && data && data.hasOwnProperty(item.field)) { + readin[item.field] = _readin + fieldlen[item.field] = _fieldlen + + if (_readin && !/^date/.test(item.type) && data && data.hasOwnProperty(item.field)) { item.initval = data[item.field] } @@ -87,6 +105,8 @@ this.setState({ readtype: readtype, datatype: datatype, + readin: readin, + fieldlen: fieldlen, formlist: _formlist, groups: _groups }) @@ -302,11 +322,12 @@ ) } else if (item.type === 'date') { // 鏃堕棿鎼滅储 let _initval = this.props.data ? this.props.data[item.field] : '' - if (_initval) { + if (_initval && this.state.readin[item.field]) { _initval = moment(_initval, 'YYYY-MM-DD') } else { _initval = item.initval ? moment().subtract(item.initval, 'days') : null } + fields.push( <Col span={24 / cols} key={index}> <Form.Item label={item.label}> @@ -326,11 +347,12 @@ ) } else if (item.type === 'datemonth') { let _initval = this.props.data ? this.props.data[item.field] : '' - if (_initval) { + if (_initval && this.state.readin[item.field]) { _initval = moment(_initval, 'YYYY-MM') } else { _initval = item.initval ? moment().subtract(item.initval, 'month') : null } + fields.push( <Col span={24 / cols} key={index}> <Form.Item label={item.label}> @@ -350,11 +372,12 @@ ) } else if (item.type === 'datetime') { let _initval = this.props.data ? this.props.data[item.field] : '' - if (_initval) { + if (_initval && this.state.readin[item.field]) { _initval = moment(_initval, 'YYYY-MM-DD HH:mm:ss') } else { _initval = item.initval ? moment().subtract(item.initval, 'days') : null } + fields.push( <Col span={24 / cols} key={index}> <Form.Item label={item.label}> @@ -374,7 +397,7 @@ ) } else if (item.type === 'fileupload') { let filelist = this.props.data ? this.props.data[item.field] : item.initval - if (filelist) { + if (filelist && this.state.readin[item.field]) { try { filelist = filelist.split(',').map((url, index) => { return { @@ -388,6 +411,8 @@ } catch { filelist = [] } + } else { + filelist = [] } fields.push( @@ -404,22 +429,6 @@ })( <FileUpload /> )} - </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> ) @@ -472,10 +481,12 @@ search.push({ type: 'funcvar', readonly: 'true', + readin: false, + fieldlen: this.state.fieldlen[item.field], key: item.field, value: '' }) - } else if (item.hidden === 'true') { + } else if (item.hidden === 'true' && item.field !== this.props.setting.primaryKey) { let _val = item.initval if (record.hasOwnProperty(item.field)) { _val = record[item.field] @@ -483,6 +494,8 @@ search.push({ 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 }) @@ -490,53 +503,25 @@ }) Object.keys(values).forEach(key => { + let _value = '' if (this.state.datatype[key] === 'datetime') { - let _value = '' if (values[key]) { _value = moment(values[key]).format('YYYY-MM-DD HH:mm:ss') } - search.push({ - type: this.state.datatype[key], - readonly: this.state.readtype[key], - key: key, - value: _value - }) } else if (this.state.datatype[key] === 'datemonth') { - let _value = '' if (values[key]) { _value = moment(values[key]).format('YYYY-MM') } - search.push({ - type: this.state.datatype[key], - readonly: this.state.readtype[key], - key: key, - value: _value - }) } else if (this.state.datatype[key] === 'date') { - let _value = '' if (values[key]) { _value = moment(values[key]).format('YYYY-MM-DD') } - search.push({ - type: this.state.datatype[key], - readonly: this.state.readtype[key], - key: key, - value: _value - }) } else if (this.state.datatype[key] === 'number') { - search.push({ - type: this.state.datatype[key], - readonly: this.state.readtype[key], - key: key, - value: values[key] - }) + _value = values[key] + } else if (this.state.datatype[key] === 'multiselect') { - search.push({ - type: this.state.datatype[key], - readonly: this.state.readtype[key], - key: key, - value: values[key] ? values[key].join(',') : '' - }) + _value = values[key] ? values[key].join(',') : '' + } else if (this.state.datatype[key] === 'fileupload') { let vals = [] @@ -550,28 +535,23 @@ }) } - search.push({ - type: this.state.datatype[key], - readonly: this.state.readtype[key], - key: key, - value: vals.join(',') - }) + _value = vals.join(',') } else if (this.state.datatype[key] === 'text') { - search.push({ - type: this.state.datatype[key], - readonly: this.state.readtype[key], - key: key, - value: values[key].replace(/(^\s*|\s*$)/ig, '') - // value: values[key].replace(/[\x00-\xff]+/ig, '') - }) + _value = values[key].replace(/(^\s*|\s*$) | \t* | \v*/ig, '') + } else { - search.push({ - type: this.state.datatype[key], - readonly: this.state.readtype[key], - key: key, - value: values[key] - }) + _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 + }) }) resolve(search) } else { diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx index 79c1cea..f64cfe6 100644 --- a/src/tabviews/formtab/index.jsx +++ b/src/tabviews/formtab/index.jsx @@ -14,7 +14,7 @@ import FormAction from './actionList' import SubTable from '@/tabviews/subtable' import NotFount from '@/components/404' -import {refreshTabView} from '@/store/action' +import {refreshTabView, modifyTabview} from '@/store/action' import './index.scss' const { TabPane } = Tabs @@ -23,8 +23,9 @@ static propTpyes = { // MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 // MenuName: PropTypes.string, // 鑿滃崟鍙傛暟 - MenuID: PropTypes.string, // 鑿滃崟Id - param: PropTypes.any // 涓昏〃浼犻�掑弬鏁� + MenuID: PropTypes.string, // 鑿滃崟Id + param: PropTypes.any, // 涓昏〃浼犻�掑弬鏁� + refresh: PropTypes.any // 鍒锋柊涓昏〃椤甸潰 } state = { @@ -45,7 +46,8 @@ pickup: false, // 涓昏〃鏁版嵁闅愯棌鏄剧ず鍒囨崲 isLinkMain: false, // 鏄惁瀛樺湪涓庝富琛ㄥ叧鑱旂殑瀛愯〃 popData: false, // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁 - visible: false // 寮规鏄剧ず闅愯棌鎺у埗 + visible: false, // 寮规鏄剧ず闅愯棌鎺у埗 + primaryId: null } /** @@ -90,18 +92,18 @@ let _arrField = [] // 瀛楁闆� - if (this.props.param && this.props.param.arr_field) { - _arrField = this.props.param.arr_field - } else { - config.groups.forEach(group => { - group.sublist.forEach(item => { - if (!item.field) return + // if (this.props.param && this.props.param.arr_field) { // 浣跨敤鏄剧ず鍒楀瓧娈垫煡璇� + // _arrField = this.props.param.arr_field + // } else { + config.groups.forEach(group => { + group.sublist.forEach(item => { + if (!item.field) return - _arrField.push(item.field) - }) + _arrField.push(item.field) }) - _arrField = _arrField.join(',') - } + }) + _arrField = _arrField.join(',') + // } // 鏉冮檺杩囨护 config.action = config.action.filter(item => permAction[item.uuid]) @@ -138,15 +140,16 @@ actions: config.action, isLinkMain: _isLinkMain, arr_field: _arrField, - data: config.setting.datatype === 'query' ? null : (this.props.param.data[0] || null), + primaryId: this.props.param.primaryId || '', + data: config.setting.datatype === 'query' ? null : this.props.param.data, BIDs: { mainTable: this.props.param.primaryId || '', - mainTabledata: config.setting.datatype === 'query' ? '' : (this.props.param.data[0] || '') + mainTabledata: config.setting.datatype === 'query' ? '' : this.props.param.data } }, () => { this.improveSelectOption(config.groups) - if (config.setting.datatype === 'query') { + if (config.setting.datatype === 'query' && this.props.param.primaryId) { this.loadmaindata() } }) @@ -279,15 +282,34 @@ */ async loadmaindata () { const { setting } = this.state - let param = this.getCustomParam() + + if (setting.datatype !== 'query') return + + let param = null + + if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { + param = this.getCustomParam() + } else { + param = this.getDefaultParam() + } + + if (!param) return // 鏈幏鍙栧弬鏁版椂锛屼笉鍙戣姹� let result = await Api.genericInterface(param) if (result.status) { + let _data = result.data[0] || '' + let _primaryId = '' + + if (_data) { + _primaryId = _data[setting.primaryKey] || '' + } + this.setState({ - data: result.data, + data: _data, + primaryId: _primaryId, BIDs: { - mainTable: (result.data[0] && result.data[0][setting.primaryKey]) || '', - mainTabledata: result.data[0] || '' + mainTable: _primaryId, + mainTabledata: _data } }) } else { @@ -300,10 +322,56 @@ } /** + * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� + */ + getDefaultParam = () => { + const { arr_field, setting, primaryId } = this.state + + if (!arr_field) { + notification.warning({ + top: 92, + message: '鏈缃〃鍗曞瓧娈碉紒', + duration: 10 + }) + return null + } else if (!primaryId) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌涓婚敭鍊硷紒', + duration: 10 + }) + return null + } + + + let param = { + func: 'sPC_Get_TableData', + obj_name: 'data', + arr_field: arr_field, + appkey: window.GLOB.appkey || '' + } + + let _dataresource = setting.dataresource + + if (/\s/.test(_dataresource)) { + _dataresource = '(' + _dataresource + ') tb' + } + + let LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() from ${_dataresource}) tmptable where ${setting.primaryKey}=${primaryId}` + + 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 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� */ getCustomParam = () => { - const { setting } = this.state + const { setting, primaryId } = this.state let param = {} @@ -323,21 +391,73 @@ } } + param[setting.primaryKey] = primaryId + return param } /** * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� */ - refreshbyaction = (btn, type) => { - if (btn.execSuccess === 'grid' && type === 'success') { + refreshbyaction = (btn, type, primaryId) => { + if (type === 'success' && btn.afterExecSuccess === 'notclose') { + this.setState({ + primaryId: primaryId + }, () => { + if (btn.execSuccess === 'refresh') { + this.loadmaindata() + } + }) + } else if (type === 'success' && btn.afterExecSuccess === 'close') { + if (this.props.refresh) { + this.props.refresh(btn.execSuccess) + } else { + if (btn.execSuccess !== 'never') { + let PMenu = { + MenuID: this.props.param.parentId || '', + position: btn.execSuccess + } + this.props.refreshTabView(PMenu) + } - } else if (btn.execError === 'grid' && type === 'error') { + let tabs = this.props.tabviews.filter(tab => { + tab.selected = false + if (tab.MenuID === this.props.param.parentId) { + tab.selected = true + } - } else if (btn.execSuccess === 'view' && type === 'success') { + return tab.MenuID !== this.props.MenuID + }) - } else if (btn.execError === 'view' && type === 'error') { + this.props.modifyTabview(tabs) + } + } else if (type === 'error' && btn.afterExecError === 'notclose') { + if (btn.execSuccess === 'refresh') { + this.loadmaindata() + } + } else if (type === 'error' && btn.afterExecError === 'close') { + if (this.props.refresh) { + this.props.refresh(btn.execError) + } else { + if (btn.execError !== 'never') { + let PMenu = { + MenuID: this.props.param.parentId || '', + position: btn.execError + } + this.props.refreshTabView(PMenu) + } + let tabs = this.props.tabviews.filter(tab => { + tab.selected = false + if (tab.MenuID === this.props.param.parentId) { + tab.selected = true + } + + return tab.MenuID !== this.props.MenuID + }) + + this.props.modifyTabview(tabs) + } } } @@ -354,6 +474,10 @@ [type + 'data']: data } }) + } + + getFormData = () => { + return this.formGroupRef.handleConfirm() } UNSAFE_componentWillMount () { @@ -376,11 +500,16 @@ render() { const { setting, actions, loadingview, viewlost, isLinkMain, config, groups, data } = this.state + let hasform = false + + if (groups && (groups.length > 1 || groups[0].sublist.length > 0)) { + hasform = true + } return ( <div className={'formtab ' + (isLinkMain ? 'pick-control' : '')} id={this.state.ContainerId}> {loadingview && <Spin size="large" />} - {groups && (groups.length > 1 || groups[0].sublist.length > 0) ? + {hasform ? <FormGroup dict={this.state.dict} data={data} @@ -389,14 +518,16 @@ wrappedComponentRef={(inst) => this.formGroupRef = inst} /> : null } - {actions ? + {hasform ? <FormAction + logcolumns={[]} setting={setting} actions={actions} dict={this.state.dict} data={this.state.data} MenuID={this.props.MenuID} - logcolumns={[]} + primaryId={this.state.primaryId} + getFormData={this.getFormData} refreshdata={this.refreshbyaction} /> : null } @@ -440,6 +571,7 @@ const mapStateToProps = (state) => { return { + tabviews: state.tabviews, refreshTab: state.refreshTab, permAction: state.permAction } @@ -447,7 +579,8 @@ const mapDispatchToProps = (dispatch) => { return { - refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)) + refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)), + modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews)) } } diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index ad821f1..a88f0f8 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -46,8 +46,7 @@ loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 - orderColumn: '', // 鎺掑簭瀛楁 - orderType: 'asc', // 鎺掑簭鏂瑰紡 + orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� configMap: {}, // 椤甸潰閰嶇疆淇℃伅锛氫笅鎷夈�佹寜閽瓑 popAction: false, // 寮规椤甸潰锛屾寜閽俊鎭� @@ -321,15 +320,14 @@ * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� */ getCustomParam = (BID) => { - const { pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state + const { pageIndex, pageSize, orderBy, search, setting } = this.state let _search = Utils.formatCustomMainSearch(search) let param = { PageIndex: pageIndex, PageSize: pageSize, - OrderCol: orderColumn, - OrderType: orderType, + OrderCol: orderBy || setting.order, BID: BID, ..._search } @@ -357,7 +355,7 @@ * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� */ getDefaultParam = (BID) => { - const { arr_field, pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state + const { arr_field, pageIndex, pageSize, orderBy, search, setting } = this.state let _search = Utils.joinMainSearchkey(search) _search = _search ? 'where ' + _search : '' @@ -370,7 +368,7 @@ appkey: window.GLOB.appkey || '' } - let orderBy = orderColumn ? (orderColumn + ' ' + orderType) : setting.order + let _orderBy = orderBy || setting.order let _dataresource = setting.dataresource if (/\s/.test(_dataresource)) { @@ -403,7 +401,7 @@ _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 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}` param.LText = Utils.formatOptions(LText) @@ -446,8 +444,7 @@ loading: true, pageIndex: pagination.current, pageSize: pagination.pageSize, - orderColumn: sorter.field || this.state.setting.orderColumn, - orderType: sorter.order || 'asc' + orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' }, () => { this.loadmaindata() }) @@ -485,8 +482,7 @@ loading: false, pageIndex: 1, pageSize: 10, - orderColumn: '', - orderType: 'asc', + orderBy: '', search: '', configMap: {} }, () => { @@ -520,7 +516,7 @@ */ handleDefaultExcelout = (btn) => { const { MenuName } = this.props - const { arr_field, orderColumn, orderType, search, setting, config } = this.state + const { arr_field, orderBy, search, setting, config } = this.state let _arr_labels = [] // 鍒楀悕绉伴泦 let _arr_label_field = [] // 鍒楀悕绉板瓧娈甸泦 @@ -546,14 +542,14 @@ appkey: window.GLOB.appkey || '' } - let orderBy = orderColumn ? (orderColumn + ' ' + orderType) : setting.order + let _orderBy = orderBy || setting.order let _dataresource = setting.dataresource if (/\s/.test(_dataresource)) { _dataresource = '(' + _dataresource + ') tb' } - let LText = `select ${_arr_label_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` + let LText = `select ${_arr_label_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` param.LText = Utils.formatOptions(LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx index f3306e6..2b52ef8 100644 --- a/src/tabviews/subtabtable/index.jsx +++ b/src/tabviews/subtabtable/index.jsx @@ -42,8 +42,7 @@ loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� pageIndex: 1, // 椤电爜 pageSize: 10, // 姣忛〉鏁版嵁鏉℃暟 - orderColumn: '', // 鎺掑簭瀛楁 - orderType: 'asc', // 鎺掑簭鏂瑰紡 + orderBy: '', // 鎺掑簭 search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� configMap: {} // 椤甸潰閰嶇疆淇℃伅锛氫笅鎷夈�佹寜閽瓑 } @@ -286,15 +285,14 @@ * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� */ getCustomParam = () => { - const { pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state + const { pageIndex, pageSize, orderBy, search, setting } = this.state let _search = Utils.formatCustomMainSearch(search) let param = { PageIndex: pageIndex, PageSize: pageSize, - OrderCol: orderColumn, - OrderType: orderType, + OrderCol: orderBy || setting.order, ..._search } @@ -321,7 +319,7 @@ * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� */ getDefaultParam = () => { - const { arr_field, pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state + const { arr_field, pageIndex, pageSize, orderBy, search, setting } = this.state let _search = Utils.joinMainSearchkey(search) _search = _search ? 'where ' + _search : '' @@ -334,7 +332,7 @@ appkey: window.GLOB.appkey || '' } - let orderBy = orderColumn ? (orderColumn + ' ' + orderType) : setting.order + let _orderBy = orderBy || setting.order let _dataresource = setting.dataresource if (/\s/.test(_dataresource)) { @@ -367,7 +365,7 @@ _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 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}` param.LText = Utils.formatOptions(LText) @@ -410,8 +408,7 @@ loading: true, pageIndex: pagination.current, pageSize: pagination.pageSize, - orderColumn: sorter.field || this.state.setting.orderColumn, - orderType: sorter.order || 'asc' + orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : '' }, () => { this.loadmaindata() }) @@ -449,8 +446,7 @@ loading: false, pageIndex: 1, pageSize: 10, - orderColumn: '', - orderType: 'asc', + orderBy: '', search: '', configMap: {} }, () => { @@ -483,7 +479,7 @@ */ handleDefaultExcelout = (btn) => { const { MenuName } = this.props - const { arr_field, orderColumn, orderType, search, setting, config } = this.state + const { arr_field, orderBy, search, setting, config } = this.state let _arr_labels = [] // 鍒楀悕绉伴泦 let _arr_label_field = [] // 鍒楀悕绉板瓧娈甸泦 @@ -509,14 +505,14 @@ appkey: window.GLOB.appkey || '' } - let orderBy = orderColumn ? (orderColumn + ' ' + orderType) : setting.order + let _orderBy = orderBy || setting.order let _dataresource = setting.dataresource if (/\s/.test(_dataresource)) { _dataresource = '(' + _dataresource + ') tb' } - let LText = `select ${_arr_label_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` + let LText = `select ${_arr_label_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows` param.LText = Utils.formatOptions(LText) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' diff --git a/src/tabviews/tableshare/actionList/index.jsx b/src/tabviews/tableshare/actionList/index.jsx index 5f897b6..77d8372 100644 --- a/src/tabviews/tableshare/actionList/index.jsx +++ b/src/tabviews/tableshare/actionList/index.jsx @@ -818,17 +818,19 @@ }) return } - if (!btn.innerFunc) { - let param = { // 绯荤粺瀛樺偍杩囩▼ - func: 'sPC_TableData_InUpDe', - BID: this.props.BID - } - 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) + let param = { + BID: this.props.BID + } - this.setState({loadingUuid: btn.uuid}) + 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) { @@ -837,17 +839,8 @@ this.execError(res, btn) } }) - } else { - let param = { // 鑷畾涔夊瓨鍌ㄨ繃绋� - func: btn.innerFunc, - BID: this.props.BID - } - - 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}) + } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋� + param.func = btn.innerFunc Api.genericInterface(param).then((res) => { if (res.status) { @@ -856,6 +849,77 @@ 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 + + // 浣跨敤澶勭悊鍚庣殑鏁版嵁璋冪敤澶栭儴鎺ュ彛 + resolve(res) + } else { + this.execError(res, btn) + resolve(false) + } + }) + } else { + resolve(param) + } + }).then(res => { + if (!res) return + // 澶栭儴璇锋眰 + _outParam = JSON.parse(JSON.stringify(res)) + + if (btn.sysInterface === 'true') { + res.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi + } else { + res.rduri = btn.interface + } + + if (btn.outerFunc) { + res.func = btn.outerFunc + } + + res.appkey = window.GLOB.appkey || '' // 澶栭儴璇锋眰鏃讹紝缁熶竴娣诲姞appkey + + 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) + } + }) } } diff --git a/src/tabviews/tableshare/mutilform/index.jsx b/src/tabviews/tableshare/mutilform/index.jsx index b4fec62..46e8a1c 100644 --- a/src/tabviews/tableshare/mutilform/index.jsx +++ b/src/tabviews/tableshare/mutilform/index.jsx @@ -570,63 +570,25 @@ }) Object.keys(values).forEach(key => { + let _value = '' if (this.state.datatype[key] === 'datetime') { - let _value = '' if (values[key]) { _value = moment(values[key]).format('YYYY-MM-DD HH:mm:ss') } - 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 - }) } else if (this.state.datatype[key] === 'datemonth') { - let _value = '' if (values[key]) { _value = moment(values[key]).format('YYYY-MM') } - 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 - }) } else if (this.state.datatype[key] === 'date') { - let _value = '' if (values[key]) { _value = moment(values[key]).format('YYYY-MM-DD') } - 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 - }) } else if (this.state.datatype[key] === 'number') { - 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: values[key] - }) + _value = values[key] + } else if (this.state.datatype[key] === 'multiselect') { - 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: values[key] ? values[key].join(',') : '' - }) + _value = values[key] ? values[key].join(',') : '' + } else if (this.state.datatype[key] === 'fileupload') { let vals = [] @@ -640,33 +602,23 @@ }) } - 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: vals.join(',') - }) + _value = vals.join(',') } else if (this.state.datatype[key] === 'text') { - 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: values[key].replace(/(^\s*|\s*$) | \t* | \v*/ig, '') - }) + _value = values[key].replace(/(^\s*|\s*$) | \t* | \v*/ig, '') + } else { - 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: values[key] - }) + _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 + }) }) resolve(search) diff --git a/src/templates/comtableconfig/actionform/index.jsx b/src/templates/comtableconfig/actionform/index.jsx index d65053e..a40a22c 100644 --- a/src/templates/comtableconfig/actionform/index.jsx +++ b/src/templates/comtableconfig/actionform/index.jsx @@ -102,15 +102,19 @@ _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] } else if (_opentype === 'excelOut') { // 瀵煎叆瀵煎嚭 if (_intertype === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError', 'method'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] } else { _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] } } else if (_opentype === 'excelIn') { // 瀵煎叆瀵煎嚭 - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] + if (_intertype === 'outer') { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] + } else { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] + } } else { if (_intertype === 'outer') { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'method'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] } else { _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] } @@ -149,9 +153,6 @@ if (!initTab) { item.initVal = '' } - } else if (item.key === 'intertype' && _opentype === 'excelIn') { - item.initVal = 'inner' - item.readonly = true } item.hidden = !_options.includes(item.key) return item @@ -191,17 +192,21 @@ _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] } else if (value === 'excelOut') { if (this.state.interType === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError', 'method'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] } else { _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] } } else if (value === 'excelIn') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] + if (this.state.interType === 'outer') { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] + } else { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] + } } else { if (this.state.interType === 'inner') { _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'method'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc'] } } @@ -212,12 +217,8 @@ if (item.hidden) return item - if (item.key === 'intertype' && value === 'excelIn') { - _fieldval.intertype = 'inner' - item.readonly = true - } else if (item.key === 'intertype' && value !== 'excelIn') { + if (item.key === 'intertype') { _fieldval.intertype = this.state.interType - item.readonly = false } else if (item.key === 'Ot') { if (value === 'innerpage' || this.state.position === 'grid') { item.options = this.state.reqOptionSgl @@ -299,13 +300,13 @@ let _options = null if (openType === 'excelOut') { if (value === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError', 'method'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] } else { _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] } } else if (openType === 'excelIn') { if (value === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError', 'method'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] } else { _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] } @@ -313,7 +314,7 @@ if (value === 'inner') { _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'method'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc'] } } diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index fedf01d..ea8f770 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -775,6 +775,26 @@ }) } }) + } else if (btn.OpenType === 'excelIn') { + if (btn.verify && btn.verify.sheet && btn.verify.columns && btn.verify.columns.length > 0) { + let _param = { + funcName: btn.innerFunc, + name: config.setting.tableName || '', + fields: '', + menuNo: menu.MenuNo + } + newLText = Utils.formatOptions(Utils.getexcelInfunc(_param, btn, menu, config)) + DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) + // resolve(true) + resolve(false) + } else { + notification.warning({ + top: 92, + message: '璇峰畬鍠勫鍏xcel楠岃瘉淇℃伅锛�', + duration: 10 + }) + resolve(false) + } } else { let _param = { funcName: btn.innerFunc, diff --git a/src/templates/subtableconfig/actionform/index.jsx b/src/templates/subtableconfig/actionform/index.jsx index d7abe45..c9bd789 100644 --- a/src/templates/subtableconfig/actionform/index.jsx +++ b/src/templates/subtableconfig/actionform/index.jsx @@ -87,15 +87,21 @@ if (_opentype === 'popview') { _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] - } else if (_opentype === 'excelIn' || _opentype === 'excelOut') { + } else if (_opentype === 'excelOut') { if (_intertype === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError', 'method'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] + } else { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] + } + } else if (_opentype === 'excelIn') { + if (_intertype === 'outer') { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] } else { _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] } } else { if (_intertype === 'outer') { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'method'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError'] } else { _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] } @@ -177,9 +183,15 @@ if (value === 'popview') { _options = ['label', 'Ot', 'OpenType', 'icon', 'class', 'position', 'tabType', 'linkTab', 'popClose'] - } else if (value === 'excelIn' || value === 'excelOut') { + } else if (value === 'excelOut') { if (this.state.interType === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError', 'method'] + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] + } else { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] + } + } else if (value === 'excelIn') { + if (this.state.interType === 'outer') { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] } else { _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] } @@ -187,7 +199,7 @@ if (this.state.interType === 'inner') { _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'method'] + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc'] } } @@ -292,14 +304,31 @@ } onChange = (e, key) => { + const { openType } = this.state let value = e.target.value if (key === 'intertype') { let _options = null - if (value === 'inner') { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] + + if (openType === 'excelOut') { + if (value === 'outer') { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] + } else { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] + } + } else if (openType === 'excelIn') { + if (value === 'outer') { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'icon', 'class', 'execSuccess', 'execError'] + } else { + _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'icon', 'class', 'execSuccess', 'execError'] + } } else { - _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc', 'method'] + if (value === 'inner') { + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sql', 'sqlType'] + } else { + _options = ['label', 'position', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class', 'execSuccess', 'execError', 'sysInterface', 'interface', 'outerFunc', 'callbackFunc'] + } } + this.setState({ interType: value, formlist: this.state.formlist.map(item => { diff --git a/src/templates/ushare/editable/index.jsx b/src/templates/ushare/editable/index.jsx index 7e41ec8..856c600 100644 --- a/src/templates/ushare/editable/index.jsx +++ b/src/templates/ushare/editable/index.jsx @@ -229,18 +229,14 @@ let dataSource = JSON.parse(JSON.stringify(this.state.dataSource)) let _width = '40%' let fields = [] - console.log(linkSubFields) + if (type === 'select' && linkSubFields.length > this.state.linkSubFields) { let addcol = linkSubFields[linkSubFields.length - 1] dataSource = dataSource.map(data => { data[addcol.field] = data.Text return data }) - console.log(addcol) } - // console.log(linkSubFields) - // console.log(type) - // console.log(dataSource) if (type === 'link') { _width = '27%' @@ -255,8 +251,6 @@ } }) } - - console.log(fields) let columns = [ { diff --git a/src/utils/utils.js b/src/utils/utils.js index 3bf9737..9994fd0 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -517,9 +517,10 @@ return `'${val}' as ${col.Column}` }) - if (!item.innerFunc) { - vals.push(`@upid+'${this.getuuid()}' as jskey`) - } + let _lineIndex = '0000' + (lindex + 1) + '0' + _lineIndex = _lineIndex.substring(_lineIndex.length - 6) + + vals.push(`@upid+'${_lineIndex}' as jskey`) return `Select ${vals.join(',')}` }) @@ -528,10 +529,9 @@ let _sql = '' - if (!item.innerFunc) { + if (item.intertype === 'inner' && !item.innerFunc) { let declarefields = [] let fields = [] - let timestamp = new Date().getTime() btn.columns.forEach(col => { declarefields.push(`${col.Column} ${col.type}`) @@ -541,10 +541,13 @@ fields = fields.join(',') _sql = `declare @${btn.sheet} table (${declarefields.join(',')},jskey nvarchar(50) ) - Declare @UserName nvarchar(50),@FullName nvarchar(50) ,@upid nvarchar(50) + Declare @UserName nvarchar(50),@FullName nvarchar(50) ,@upid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000) + + Select @ErrorCode='', @retmsg='' + select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ - set @upid='${timestamp}' + set @upid='${this.getuuid()}' Insert into @${btn.sheet} (${fields},jskey) ${_Ltext} @@ -552,7 +555,9 @@ Insert into ${btn.sheet} (${fields},createuserid,createuser,createstaff,bid,upid) Select ${fields},@userid@,@username,@fullname,@BID@,@upid From @${btn.sheet} - Delete @${btn.sheet}` + Delete @${btn.sheet} + + aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` } else { _sql = _Ltext @@ -866,8 +871,14 @@ let primaryKeyName = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'].includes(primaryKey.toLowerCase()) ? primaryKey + '@' : primaryKey + let _actionType = null + + if (verify.default !== 'false') { // 鍒ゆ柇鏄惁浣跨敤榛樿sql + _actionType = btn.sqlType + } + // 娣诲姞銆佷慨鏀广�侀�昏緫鍒犻櫎銆佺墿鐞嗗垹闄� - if (btn.OpenType === 'pop' && btn.sqlType === 'insert' && verify.default !== 'false') { + if (_actionType === 'insert') { let keys = [] let values = [] @@ -909,7 +920,7 @@ values = values.join(',') _sql += _user _sql += `insert into ${btn.sql} (${keys}) select ${values};` - } else if (btn.OpenType === 'pop' && btn.sqlType === 'update' && verify.default !== 'false') { + } else if (_actionType === 'update') { let _form = [] let _arr = [] @@ -945,9 +956,10 @@ _form = _form.join(',') _sql += `update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKeyName};` - } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'LogicDelete' && verify.default !== 'false') { // 閫昏緫鍒犻櫎 + } else if (_actionType === 'LogicDelete') { // 閫昏緫鍒犻櫎 _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKeyName};` - } else if ((btn.OpenType === 'prompt' || btn.OpenType === 'exec') && btn.sqlType === 'delete' && verify.default !== 'false') { // 鐗╃悊鍒犻櫎 + + } else if (_actionType === 'delete') { // 鐗╃悊鍒犻櫎 let _msg = '' if (data && logcolumns && logcolumns.length > 0) { let _index = 0 @@ -1258,4 +1270,104 @@ return Ltext } + + /** + * @description 鍒涘缓瀵煎叆瀛樺偍杩囩▼ + * @return {String} + */ + static getexcelInfunc (param, btn, menu) { + let _verify = btn.verify + + let declarefields = [] + let fields = [] + + _verify.columns.forEach(col => { + declarefields.push(`${col.Column} ${col.type}`) + fields.push(col.Column) + }) + + fields = fields.join(',') + + let _sql = `declare @${_verify.sheet} table (${declarefields.join(',')},jskey nvarchar(50) ) + Declare @UserName nvarchar(50),@FullName nvarchar(50),@upid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000) + + Select @ErrorCode='',@retmsg='' + + select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ + + set @upid='鏃堕棿鎴�' + + Insert into @${_verify.sheet} (${fields},jskey) + + exec s_KeyWords_Replace + @LText=@LText, @BID=@BID,@LoginUID=@LoginUID,@SessionUid=@SessionUid,@UserID=@UserID,@ID=@ID + + Insert into ${_verify.sheet} (${fields},createuserid,createuser,createstaff,bid,upid) + Select ${fields},@userid@,@username,@fullname,@BID@,@upid From @${_verify.sheet} + + Delete @${_verify.sheet} + + aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` + + let Ltext = `create proc ${param.funcName} + ( /*${menu.MenuName} ${btn.label}*/ + @ID nvarchar(50)='', + @BID nvarchar(50)='', + @Ltext nvarchar(max)='', + @sEPTMenuNo nvarchar(50)='${param.menuNo}', + @lang nvarchar(50)='', + @LoginUID nvarchar(50)='', + @SessionUid nvarchar(50)='', + @UserID nvarchar(50), + @ErrorCode nvarchar(50) out, + @retmsg nvarchar(4000) out + ) + as + begin + declare @sEPTMenuNo ,@Begindate datetime,@Enddate datetime + select @sEPTMenuNo=@retmsg,@Begindate=getdate() + set @ErrorCode='' + set @retmsg='' + BEGIN TRY + /*浜嬪姟鎿嶄綔*/ + BEGIN TRAN + /*鍏蜂綋涓氬姟鎿嶄綔*/ + + /* + ${_sql} + */ + + COMMIT TRAN + SET NOCOUNT ON + RETURN + END TRY + BEGIN CATCH + /*閿欒澶勭悊*/ + ROLLBACK TRAN + DECLARE @ErrorMessage NVARCHAR(4000); + DECLARE @ErrorSeverity INT; + DECLARE @ErrorState INT; + + /*鎶婅嚜瀹氫箟鐨勫弸濂界殑閿欒淇℃伅鎻愮ず鍔犱笂*/ + set @ErrorCode=cast(ERROR_NUMBER() as nvarchar(50)) + SET @retmsg=ERROR_MESSAGE(); + SELECT @ErrorMessage=ERROR_MESSAGE(), + @ErrorSeverity=ERROR_SEVERITY(), + @ErrorState=ERROR_STATE(); + + RAISERROR(@ErrorMessage, /*-- Message text.*/ + @ErrorSeverity, /*-- Severity.*/ + @ErrorState /*-- State.*/ + ); + END CATCH + + GOTO_RETURN: + ROLLBACK TRAN + + END` + + Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') + + return Ltext + } } \ No newline at end of file -- Gitblit v1.8.0