From 8eb9303af35b6bee86daaa9ff478b623516fc183 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 16 三月 2020 11:49:29 +0800 Subject: [PATCH] 2020-03-16 --- src/views/printTemplate/index.jsx | 3 src/components/header/index.jsx | 15 + src/store/reducer.js | 2 src/components/sidemenu/editthdmenu/index.jsx | 278 ++++++++++++++-------------------- src/templates/comtableconfig/index.jsx | 4 src/templates/subtableconfig/index.jsx | 3 src/store/action.js | 3 src/views/printTemplate/print.js | 1 src/tabviews/subtable/index.jsx | 2 src/tabviews/commontable/index.jsx | 14 + src/components/sidemenu/editthdmenu/menuform/index.jsx | 61 ++++++ src/tabviews/commontable/mainTable/index.jsx | 54 ++++-- src/utils/utils.js | 3 13 files changed, 236 insertions(+), 207 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 2ef03c9..40d130b 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -206,11 +206,16 @@ if (result.status) { let _permAction = {} + let _permRoles = [] let _permFuncField = [] - if (result.UserRoles && result.UserRoles[0] && result.UserRoles[0].RoleMenu) { - result.UserRoles[0].RoleMenu.forEach(menu => { - if (!menu.MenuID) return - _permAction[menu.MenuID] = true + if (result.UserRoles) { + result.UserRoles.forEach(role => { + _permRoles.push(role.RoleID) + + role.RoleMenu.forEach(menu => { + if (!menu.MenuID) return + _permAction[menu.MenuID] = true + }) }) } @@ -223,7 +228,7 @@ _permFuncField = _permFuncField.sort() } - this.props.initPermission(_permAction, _permFuncField) + this.props.initPermission(_permRoles, _permAction, _permFuncField) } } diff --git a/src/components/sidemenu/editthdmenu/index.jsx b/src/components/sidemenu/editthdmenu/index.jsx index 0d1a91f..327e280 100644 --- a/src/components/sidemenu/editthdmenu/index.jsx +++ b/src/components/sidemenu/editthdmenu/index.jsx @@ -71,7 +71,8 @@ sysMenu: false, // 娣诲姞鎴栫紪杈戣彍鍗曪紙瑙掕壊鏉冮檺鍒嗛厤绛夛級 optionLibs: [], // 鑷畾涔変笅鎷夐�夐」搴� fstMenuId: null, // 涓�绾ц彍鍗旾d - fstMenuList: null // 涓�绾ц彍鍗曞垪琛� + fstMenuList: null, // 涓�绾ц彍鍗曞垪琛� + roleList: null // 瑙掕壊鍒楄〃锛屽缓绔嬮粦鍚嶅崟 } /** @@ -129,16 +130,27 @@ delete _menu.src delete _menu.text + if (!this.state.fstMenuId) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌涓�绾ц彍鍗曚俊鎭紝璇风◢绛夋垨鍒锋柊閲嶈瘯銆�', + duration: 10 + }) + return + } + + _menu.ParentID = this.props.supMenu.MenuID + _menu.supMenuList = this.props.supMenuList + _menu.fstMenuId = this.state.fstMenuId + _menu.fstMenuList = this.state.fstMenuList + _menu.roleList = this.state.roleList + if (_menu.PageParam && _menu.PageParam.Template === 'RolePermission') { // 鍗曢〉闈慨鏀� - let _menu_ = { - ..._menu, - ParentID: this.props.supMenu.MenuID, - Template: _menu.PageParam.Template - } + _menu.Template = _menu.PageParam.Template this.setState({ handleMVisible: true, - sysMenu: _menu_ + sysMenu: _menu }) return @@ -167,8 +179,7 @@ } _menu.LongParam = _LongParam - _menu.ParentID = this.props.supMenu.MenuID - _menu.supMenuList = this.props.supMenuList + // 妫�娴嬫ā鏉挎槸鍚﹀瓨鍦� let _Template = this.state.sysTemplates.filter(temp => temp.type === _menu.PageParam.Template) @@ -190,65 +201,15 @@ document.getElementById('root').style.overflowY = 'hidden' }) } else { - if (this.state.fstMenuId) { - _menu.fstMenuId = this.state.fstMenuId - _menu.fstMenuList = this.state.fstMenuList - - this.setState({ - type: 'edit', - editMenu: _menu, - loading: false, - optionLibs: new Map(), // 缂栬緫鏃讹紝鍒濆鍖栦负绌� - tabview: _menu.PageParam.Template - }, () => { - document.getElementById('root').style.overflowY = 'hidden' - }) - } else { - let _param = { - func: 's_Get_FSMenusForOpen', - SndMenuID: this.props.supMenu.MenuID, - TYPE: 20, - TypeCharOne: 'PC' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - _menu.fstMenuId = result.FstIDSeleted - _menu.fstMenuList = result.data.map(smenu => { - let _smenu = { - MenuID: smenu.FstID, - text: smenu.FstName, - options: smenu.SndData.map(menu => { - return { - MenuID: menu.SndID, - text: menu.SndName, - } - }) - } - return _smenu - }) - - this.setState({ - type: 'edit', - editMenu: _menu, - loading: false, - optionLibs: new Map(), // 缂栬緫鏃讹紝鍒濆鍖栦负绌� - tabview: _menu.PageParam.Template - }, () => { - document.getElementById('root').style.overflowY = 'hidden' - }) - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - } - }) - } + this.setState({ + type: 'edit', + editMenu: _menu, + loading: false, + optionLibs: new Map(), // 缂栬緫鏃讹紝鍒濆鍖栦负绌� + tabview: _menu.PageParam.Template + }, () => { + document.getElementById('root').style.overflowY = 'hidden' + }) } } else { this.setState({ @@ -276,75 +237,34 @@ return } - if (this.state.fstMenuId) { - this.setState({ - tabview: 'template', - editMenu: { - MenuID: Utils.getuuid(), - MenuName: '', - MenuNo: '', - type: '', - PageParam: '', - LongParam: '', - isSubtable: '', // 鏄惁涓轰富瀛愯〃 - ParentID: this.props.supMenu.MenuID, - supMenuList: this.props.supMenuList, - fstMenuId: this.state.fstMenuId, - fstMenuList: this.state.fstMenuList - } - }, () => { - document.getElementById('root').style.overflowY = 'hidden' + if (!this.state.fstMenuId) { + notification.warning({ + top: 92, + message: '鏈幏鍙栧埌涓�绾ц彍鍗曚俊鎭紝璇风◢绛夋垨鍒锋柊閲嶈瘯', + duration: 10 }) - } else { - let _param = { - func: 's_Get_FSMenusForOpen', - SndMenuID: this.props.supMenu.MenuID, - TYPE: 20, - TypeCharOne: 'PC' - } - - Api.getSystemConfig(_param).then(result => { - if (result.status) { - this.setState({ - tabview: 'template', - editMenu: { - MenuID: Utils.getuuid(), - MenuName: '', - MenuNo: '', - type: '', - PageParam: '', - LongParam: '', - isSubtable: '', // 鏄惁涓轰富瀛愯〃 - ParentID: this.props.supMenu.MenuID, - supMenuList: this.props.supMenuList, - fstMenuId: result.FstIDSeleted, - fstMenuList: result.data.map(smenu => { - let _smenu = { - MenuID: smenu.FstID, - text: smenu.FstName, - options: smenu.SndData.map(menu => { - return { - MenuID: menu.SndID, - text: menu.SndName, - } - }) - } - return _smenu - }) - } - }, () => { - document.getElementById('root').style.overflowY = 'hidden' - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - } - }) + return } - + + this.setState({ + tabview: 'template', + editMenu: { + MenuID: Utils.getuuid(), + MenuName: '', + MenuNo: '', + type: '', + PageParam: '', + LongParam: '', + isSubtable: '', // 鏄惁涓轰富瀛愯〃 + ParentID: this.props.supMenu.MenuID, + supMenuList: this.props.supMenuList, + roleList: this.state.roleList, + fstMenuId: this.state.fstMenuId, + fstMenuList: this.state.fstMenuList + } + }, () => { + document.getElementById('root').style.overflowY = 'hidden' + }) } else if (type === 'thaw') { if (!is(fromJS(this.props.menulist), fromJS(this.state.menulist))) { notification.warning({ @@ -668,6 +588,7 @@ let param = { func: 'sPC_TrdMenu_AddUpt', + FstID: res.fstMenuId, SndID: res.ParentID, ParentID: res.ParentID, MenuID: sysMenu.MenuID, @@ -728,33 +649,67 @@ TYPE: 20, TypeCharOne: 'PC' } + this.setState({ + loading: true + }) - Api.getSystemConfig(_param).then(result => { - if (result.status) { - this.setState({ - fstMenuId: result.FstIDSeleted, - fstMenuList: result.data.map(smenu => { - let _smenu = { - MenuID: smenu.FstID, - text: smenu.FstName, - options: smenu.SndData.map(menu => { - return { - MenuID: menu.SndID, - text: menu.SndName, - } - }) - } - - return _smenu + let menuDefer = new Promise(resolve => { + Api.getSystemConfig(_param).then(result => { + if (result.status) { + this.setState({ + fstMenuId: result.FstIDSeleted, + fstMenuList: result.data.map(smenu => { + let _smenu = { + MenuID: smenu.FstID, + text: smenu.FstName, + options: smenu.SndData.map(menu => { + return { + MenuID: menu.SndID, + text: menu.SndName, + } + }) + } + + return _smenu + }) }) - }) - } else { - notification.warning({ - top: 92, - message: result.message, - duration: 10 - }) - } + } else { + notification.warning({ + top: 92, + message: result.message, + duration: 10 + }) + } + resolve() + }) + }) + + let roleDefer = new Promise(resolve => { + Api.getSystemConfig({func: 'sPC_Get_RolesMenu'}).then(res => { + if (res.status) { + this.setState({ + roleList: res.Roles.map(role => { + return { + value: role.RoleID, + text: role.RoleName + } + }) + }) + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 10 + }) + } + resolve() + }) + }) + + Promise.all([menuDefer, roleDefer]).then(() => { + this.setState({ + loading: false + }) }) } @@ -924,7 +879,7 @@ {!this.state.thawmenulist && <Spin style={{marginLeft: 'calc(50% - 22px)', marginTop: '70px', marginBottom: '70px'}} size="large" />} {this.state.thawmenulist && <TransferForm ref="trawmenu" dict={this.state.dict} menulist={this.state.thawmenulist}/>} </Modal> - {/* 瑙e喕鑿滃崟妯℃�佹 */} + {/* 娣诲姞绯荤粺鑿滃崟 */} <Modal title={this.state.sysMenu && this.state.sysMenu.isSystem ? this.state.dict['header.menu.tadd'] : this.state.dict['header.menu.tupdate']} okText={this.state.dict['header.confirm']} @@ -938,7 +893,6 @@ <MenuForm menu={this.state.sysMenu} dict={this.state.dict} - supMenuList={this.props.supMenuList} wrappedComponentRef={(inst) => this.menuFormRef = inst} /> </Modal> diff --git a/src/components/sidemenu/editthdmenu/menuform/index.jsx b/src/components/sidemenu/editthdmenu/menuform/index.jsx index c366f49..162f0ab 100644 --- a/src/components/sidemenu/editthdmenu/menuform/index.jsx +++ b/src/components/sidemenu/editthdmenu/menuform/index.jsx @@ -11,7 +11,29 @@ supMenuList: PropTypes.any // 琛ㄦ牸鏁版嵁 } - state = {} + state = { + menu: null + } + + UNSAFE_componentWillMount () { + this.setState({ + menu: this.props.menu + }) + } + + changeMenu = (val) => { + const { menu } = this.state + + let submenu = menu.fstMenuList.filter(item => item.MenuID === val)[0] + + if (submenu) { + this.setState({ + menu: {...menu, supMenuList: submenu.options} + }, () => { + this.props.form.setFieldsValue({ParentID: submenu.options[0] ? submenu.options[0].MenuID : ''}) + }) + } + } handleConfirm = () => { // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� @@ -28,6 +50,7 @@ render() { const { getFieldDecorator } = this.props.form + const { menu } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -38,13 +61,37 @@ sm: { span: 16 } } } + return ( <Form {...formItemLayout} style={{paddingRight: '20px'}}> <Row gutter={24}> <Col span={24}> - <Form.Item label={'涓婄骇鑿滃崟'}> + <Form.Item label={'涓�绾ц彍鍗�'}> + {getFieldDecorator('fstMenuId', { + initialValue: menu.fstMenuId, + rules: [ + { + required: true, + message: this.props.dict['form.required.select'] + '涓婄骇鑿滃崟!' + } + ] + })( + <Select + showSearch + filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} + onChange={this.changeMenu} + > + {menu.fstMenuList.map(option => + <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>{option.text}</Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> + <Col span={24}> + <Form.Item label={'浜岀骇鑿滃崟'}> {getFieldDecorator('ParentID', { - initialValue: this.props.menu.ParentID, + initialValue: menu.ParentID, rules: [ { required: true, @@ -56,8 +103,8 @@ showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} > - {this.props.supMenuList.map(option => - <Select.Option id={option.id} title={option.text} key={option.id} value={option.id}>{option.text}</Select.Option> + {menu.supMenuList.map(option => + <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>{option.text}</Select.Option> )} </Select> )} @@ -66,7 +113,7 @@ <Col span={24}> <Form.Item label={'鑿滃崟鍚嶇О'}> {getFieldDecorator('MenuName', { - initialValue: this.props.menu.MenuName || '', + initialValue: menu.MenuName || '', rules: [ { required: true, @@ -79,7 +126,7 @@ <Col span={24}> <Form.Item label={'鑿滃崟鍙傛暟'}> {getFieldDecorator('MenuNo', { - initialValue: this.props.menu.MenuNo || '', + initialValue: menu.MenuNo || '', rules: [ { required: true, diff --git a/src/store/action.js b/src/store/action.js index ea3b57c..a0c08bd 100644 --- a/src/store/action.js +++ b/src/store/action.js @@ -71,9 +71,10 @@ } // 鍒濆鍖栨寜閽潈闄愬強鍒涘缓瀛樺偍杩囩▼鍙敤瀛楁 -export const initPermission = (permAction, permFuncField) => { +export const initPermission = (permRoles, permAction, permFuncField) => { return { type: user.INIT_PERMISSION, + permRoles: permRoles, permAction: permAction, permFuncField: permFuncField } diff --git a/src/store/reducer.js b/src/store/reducer.js index 703ad78..9056e8c 100644 --- a/src/store/reducer.js +++ b/src/store/reducer.js @@ -9,6 +9,7 @@ editState: false, // 鏄惁涓虹紪杈戠姸鎬侊紝鍊间负false銆乼rue editLevel: null, // 缂栬緫鑿滃崟绾у埆锛屽�间负level1銆乴evel2銆乴evel3銆傘�傘�� refreshTab: null, // 鍒锋柊tabview椤甸潰淇℃伅 + permRoles: [], permAction: {}, permFuncField: [] } @@ -92,6 +93,7 @@ // 鍒濆鍖栨寜閽潈闄愬強鍒涘缓瀛樺偍杩囩▼鍙敤瀛楁 return { ...state, + permRoles: action.permRoles, permAction: action.permAction, permFuncField: action.permFuncField } diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index d131e3a..1d30b9b 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -91,11 +91,13 @@ config = '' } - try { // 閰嶇疆淇℃伅瑙f瀽 - userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) - } catch (e) { - console.warn('Parse Failure') - userConfig = '' + if (result.LongParamUser) { + try { // 閰嶇疆淇℃伅瑙f瀽 + userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) + } catch (e) { + console.warn('Parse Failure') + userConfig = '' + } } // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� @@ -118,7 +120,7 @@ } // 鏉冮檺杩囨护 - config.action = config.action.filter(item => permAction[item.uuid] || (item.linkTab && permAction[item.linkTab])) + config.action = config.action.filter(item => permAction[item.uuid]) config.tabgroups.forEach(group => { if (!config[group]) return diff --git a/src/tabviews/commontable/mainTable/index.jsx b/src/tabviews/commontable/mainTable/index.jsx index 8d9bfca..0d7425b 100644 --- a/src/tabviews/commontable/mainTable/index.jsx +++ b/src/tabviews/commontable/mainTable/index.jsx @@ -164,29 +164,41 @@ </div> ) } else if (item.type === 'colspan') { - let contents = '' - if (item.subColumn.length > 0) { - contents = item.subColumn.map(col => { - let content = '' - if (col.type === 'text' || col.type === 'textarea') { - if (col.field && record.hasOwnProperty(col.field)) { - content = `${record[col.field]}` - } + if (item.subColumn.length === 0) return '' - content = (col.prefix || '') + content + (col.postfix || '') - } else if (col.type === 'number') { - if (col.field && record.hasOwnProperty(col.field)) { - content = +record[col.field] - } - if (content && col.format === 'thdSeparator') { - content = `${content}` - content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') - } - content = (col.prefix || '') + content + (col.postfix || '') + let contents = item.subColumn.map(col => { + let content = '' + if (col.type === 'text' || col.type === 'textarea') { + if (col.field && record.hasOwnProperty(col.field)) { + content = `${record[col.field]}` } - return content - }) - } + + content = (col.prefix || '') + content + (col.postfix || '') + } else if (col.type === 'number') { + if (col.field && record.hasOwnProperty(col.field)) { + content = +record[col.field] + } + if (content && col.format === 'thdSeparator') { + content = `${content}` + content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,') + } + content = (col.prefix || '') + content + (col.postfix || '') + } else if (col.type === 'picture') { + let photos = '' + if (col.field && record.hasOwnProperty(col.field)) { + photos = record[col.field].split(',') + } else { + photos = '' + } + content = <div className="picture-col"> + {photos && photos.map((url, i) => { + return <img key={`${i}`} src={url} alt=""/> + })} + </div> + } + + return content + }) if (contents && item.order === 'vertical2') { let _contents = [] diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index c8e8bc6..5a14bc9 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -119,7 +119,7 @@ // 鏉冮檺杩囨护 if (this.props.menuType !== 'HS') { - config.action = config.action.filter(item => permAction[item.uuid] || (item.linkTab && permAction[item.linkTab])) + config.action = config.action.filter(item => permAction[item.uuid]) } // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index c245ad2..305ebaf 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -1782,9 +1782,9 @@ label: item.label, sort: _sort }) - } else { - btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`) } + + btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`) }) btnParam.LText = btnParam.LText.join(' union all ') diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index 0cfba96..3445cb6 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -1456,9 +1456,8 @@ config.action.forEach((item, index) => { if (item.OpenType === 'popview') { btntabs.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`) - } else { - btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`) } + btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`) }) btnParam.LText = btnParam.LText.join(' union all ') diff --git a/src/utils/utils.js b/src/utils/utils.js index 461e3b8..291c0fa 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1112,6 +1112,7 @@ let Ltext = `create proc ${param.innerFunc} ( /*${menu.MenuName}*/ + @appkey nvarchar(50)='', @BID nvarchar(50)='',${formParam} @PageIndex nvarchar(50)='', @PageSize nvarchar(50)='', @@ -1277,6 +1278,7 @@ let Ltext = `create proc ${param.funcName} ( /*${menu.MenuName} ${btn.label}*/ + @appkey nvarchar(50)='', @BID nvarchar(50)='',${formParam} @sEPTMenuNo nvarchar(50)='${param.menuNo}', @lang nvarchar(50)='', @@ -1384,6 +1386,7 @@ let Ltext = `create proc ${param.funcName} ( /*${menu.MenuName} ${btn.label}*/ + @appkey nvarchar(50)='', @ID nvarchar(50)='', @BID nvarchar(50)='', @Ltext nvarchar(max)='', diff --git a/src/views/printTemplate/index.jsx b/src/views/printTemplate/index.jsx index b071926..8072f48 100644 --- a/src/views/printTemplate/index.jsx +++ b/src/views/printTemplate/index.jsx @@ -314,6 +314,8 @@ document.getElementById('darea').style.width = '700px' } else if (document.body.offsetWidth < 1920) { document.getElementById('darea').style.width = '800px' + } else { + document.getElementById('darea').style.width = '1000px' } } @@ -373,6 +375,7 @@ this.loadFields(result.data[0].TableName) } + this.handleResize() this.setState({ config: _config, editItemId: _config.uuid, diff --git a/src/views/printTemplate/print.js b/src/views/printTemplate/print.js index f6b5be1..b45fbdd 100644 --- a/src/views/printTemplate/print.js +++ b/src/views/printTemplate/print.js @@ -394,6 +394,7 @@ static cachesketch (context, resolve) { let cacheCanvas = context.canvas let canvas = document.getElementById('darea') + canvas.width = cacheCanvas.width canvas.height = cacheCanvas.height let ctx = canvas.getContext('2d') -- Gitblit v1.8.0