From 2ff464f30d94235b3ad04475593b75a74a354de9 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 09 四月 2020 19:04:01 +0800 Subject: [PATCH] 2020-04-09 --- src/templates/subtableconfig/source.jsx | 6 src/components/header/index.jsx | 147 +++++++++++--- src/store/reducer.js | 31 ++- src/templates/comtableconfig/source.jsx | 6 src/templates/formtabconfig/index.jsx | 5 src/templates/zshare/verifycard/index.jsx | 94 ++++++++- src/store/action-type.js | 5 src/components/sidemenu/editthdmenu/index.jsx | 128 ++++-------- src/templates/comtableconfig/index.jsx | 9 src/views/login/logincloudform.jsx | 2 src/templates/zshare/verifycard/customscript/index.jsx | 43 +++ src/templates/subtableconfig/index.jsx | 9 src/templates/modalconfig/index.jsx | 19 + src/templates/zshare/verifycard/customform/index.jsx | 45 +++ src/store/action.js | 16 + src/templates/zshare/createinterface/index.jsx | 3 src/utils/utils.js | 3 17 files changed, 397 insertions(+), 174 deletions(-) diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index c32acd7..cd58ef4 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -15,6 +15,7 @@ resetEditState, resetEditLevel, initPermission, + initActionPermission, initMenuPermission, logout } from '@/store/action' @@ -56,6 +57,7 @@ // 灞曞紑銆佹敹璧峰乏渚ц彍鍗曟爮 if (!this.props.editState) { this.props.toggleCollapse(!this.props.collapse) + localStorage.setItem('collapse', !this.props.collapse) } } @@ -201,44 +203,89 @@ async getRolesMenu () { // 鑾峰彇瑙掕壊鏉冮檺 - let result = await Api.getSystemConfig({func: 'sPC_Get_RolesMenu'}) + let promiseRole = new Promise(resolve => { + Api.getSystemConfig({func: 'sPC_Get_RolesMenu'}).then(result => { + let _permAction = {} + let _permRoles = [] + if (result && result.status) { + if (result.UserRoles) { + result.UserRoles.forEach(role => { + _permRoles.push(role.RoleID) - // 鐧诲綍瓒呮椂 - if (!result) return - - if (result.status) { - let _permAction = {} - let _permRoles = [] - let _permFuncField = [] - if (result.UserRoles) { - result.UserRoles.forEach(role => { - _permRoles.push(role.RoleID) - - role.RoleMenu.forEach(menu => { - if (!menu.MenuID) return - _permAction[menu.MenuID] = true - }) - }) - } - - if (result.sModular && result.sModular.length > 0) { - result.sModular.forEach(field => { - if (field.ModularNo) { - _permFuncField.push(field.ModularNo) + role.RoleMenu.forEach(menu => { + if (!menu.MenuID) return + _permAction[menu.MenuID] = true + }) + }) } - }) - _permFuncField = _permFuncField.sort() - } + } else if (result) { + notification.error({ + top: 92, + message: result.message, + duration: 15 + }) + } - this.props.initPermission(_permRoles, _permAction, _permFuncField) - this.loadmenu() - } else { - notification.error({ - top: 92, - message: result.message, - duration: 15 + resolve({permAction: _permAction, permRoles: _permRoles}) }) + }) + + // 鑾峰彇涓昏彍鍗曞弬鏁� + let promiseMenu = new Promise(resolve => { + Api.getSystemConfig({func: 'sPC_Get_MainMenu', systemType: options.systemType}).then(result => { + let mainMenu = null + if (result && result.status) { + if (result.debug === 'true') { // 鏄惁涓篸ebug妯″紡锛屽嵆鍙鍒惰彍鍗曞弬鏁� + this.props.resetDebug() + } + + let MainMenuId = sessionStorage.getItem('MainMenu') // 鏄惁涓烘墦寮�鏂伴〉闈� + if (MainMenuId) { + // 閫氳繃url涓璵enuid绛涢�夊嚭閫変腑鐨勪富鑿滃崟 + let _menu = result.data.filter(item => item.MenuID === MainMenuId)[0] + sessionStorage.removeItem('MainMenu') + mainMenu = _menu || result.data[0] + } else { + mainMenu = result.data[0] + } + + this.setState({ + menulist: result.data.map((item, index) => { + item.id = index + item.text = item.MenuName + if (item.PageParam) { + try { + item.PageParam = JSON.parse(item.PageParam) + } catch (e) { + item.PageParam = {OpenType: 'menu', linkUrl: ''} + } + } else { + item.PageParam = {OpenType: 'menu', linkUrl: ''} + } + return item + }), + systems: result.Systems.filter(sys => sys.LinkUrl1 && sys.AppKey !== window.GLOB.appkey) + }) + } else if (result) { + notification.error({ + top: 92, + message: result.message, + duration: 15 + }) + } + + resolve(mainMenu) + }) + }) + + let _mainMenu = await promiseMenu + if (_mainMenu) { + this.props.modifyMainMenu(_mainMenu) } + + let _role = await promiseRole + + this.props.initActionPermission(_role.permRoles, _role.permAction) } reload = () => { @@ -280,6 +327,36 @@ this.loadmenu() this.props.modifyMainMenu('') this.props.resetEditState(state) + } + + if (state && this.props.sysRoles.length === 0 && this.props.permFuncField.length === 0) { + Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => { + if (res.status) { + let _permFuncField = [] + let _sysRoles = [] + + if (res.Roles && res.Roles.length > 0) { + _sysRoles = res.Roles.map(role => { + return { + uuid: Utils.getuuid(), + value: role.RoleID, + text: role.RoleName + } + }) + } + + if (res.sModular && res.sModular.length > 0) { + res.sModular.forEach(field => { + if (field.ModularNo) { + _permFuncField.push(field.ModularNo) + } + }) + _permFuncField = _permFuncField.sort() + } + + this.props.initPermission(_sysRoles, _permFuncField) + } + }) } } @@ -496,6 +573,7 @@ editState: state.editState, editLevel: state.editLevel, permAction: state.permAction, + sysRoles: state.sysRoles, permFuncField: state.permFuncField } } @@ -506,7 +584,8 @@ modifyMainMenu: (selectmenu) => dispatch(modifyMainMenu(selectmenu)), resetEditState: (state) => dispatch(resetEditState(state)), resetEditLevel: (level) => dispatch(resetEditLevel(level)), - initPermission: (permRoles, permAction, permFuncField) => dispatch(initPermission(permRoles, permAction, permFuncField)), + initActionPermission: (permRoles, permAction) => dispatch(initActionPermission(permRoles, permAction)), + initPermission: (sysRoles, permFuncField) => dispatch(initPermission(sysRoles, permFuncField)), initMenuPermission: (permMenus) => dispatch(initMenuPermission(permMenus)), resetState: () => dispatch(resetState()), resetDebug: () => dispatch(resetDebug()), diff --git a/src/components/sidemenu/editthdmenu/index.jsx b/src/components/sidemenu/editthdmenu/index.jsx index 3128f22..8226e8f 100644 --- a/src/components/sidemenu/editthdmenu/index.jsx +++ b/src/components/sidemenu/editthdmenu/index.jsx @@ -71,8 +71,7 @@ sysMenu: false, // 娣诲姞鎴栫紪杈戣彍鍗曪紙瑙掕壊鏉冮檺鍒嗛厤绛夛級 optionLibs: [], // 鑷畾涔変笅鎷夐�夐」搴� fstMenuId: null, // 涓�绾ц彍鍗旾d - fstMenuList: null, // 涓�绾ц彍鍗曞垪琛� - roleList: null // 瑙掕壊鍒楄〃锛屽缓绔嬮粦鍚嶅崟 + fstMenuList: null // 涓�绾ц彍鍗曞垪琛� } /** @@ -146,7 +145,6 @@ _menu.supMenuList = this.props.supMenuList _menu.fstMenuId = this.state.fstMenuId || '' _menu.fstMenuList = this.state.fstMenuList || [] - _menu.roleList = this.state.roleList || [] this.setState({ handleMVisible: true, @@ -183,7 +181,6 @@ _menu.supMenuList = this.props.supMenuList _menu.fstMenuId = this.state.fstMenuId || '' _menu.fstMenuList = this.state.fstMenuList || [] - _menu.roleList = this.state.roleList || [] // 妫�娴嬫ā鏉挎槸鍚﹀瓨鍦� let _Template = this.state.sysTemplates.filter(temp => temp.type === _menu.PageParam.Template) @@ -269,7 +266,6 @@ isSubtable: '', // 鏄惁涓轰富瀛愯〃 ParentID: this.props.supMenu.MenuID, supMenuList: this.props.supMenuList, - roleList: this.state.roleList || [], fstMenuId: this.state.fstMenuId, fstMenuList: this.state.fstMenuList, menuSort: (this.props.menulist.length + 1) * 10 // 鏂板缓鑿滃崟璁剧疆鎺掑簭 @@ -443,7 +439,6 @@ if (!editMenu.fstMenuId) { editMenu.fstMenuId = this.state.fstMenuId editMenu.fstMenuList = this.state.fstMenuList - editMenu.roleList = this.state.roleList || [] } if (useType === 'sys' && template.type === 'RolePermission') { // 鐙珛椤甸潰 @@ -680,85 +675,56 @@ loading: true }) - 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 - }) - } - 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 { - uuid: Utils.getuuid(), - 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 - }, () => { - let _menu = JSON.parse(JSON.stringify(this.state.editMenu)) - - if (!_menu || !_menu.loadingFstMenuId) { - return - } - - delete _menu.loadingFstMenuId - _menu.fstMenuId = this.state.fstMenuId - _menu.fstMenuList = this.state.fstMenuList - _menu.roleList = this.state.roleList || [] - + Api.getSystemConfig(_param).then(result => { + if (result.status) { this.setState({ - type: 'edit', - editMenu: _menu, loading: false, - optionLibs: new Map(), // 缂栬緫鏃讹紝鍒濆鍖栦负绌� - tabview: _menu.PageParam.Template + 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' + let _menu = JSON.parse(JSON.stringify(this.state.editMenu)) + + if (!_menu || !_menu.loadingFstMenuId) { + return + } + + delete _menu.loadingFstMenuId + _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 { + this.setState({ + loading: false + }) + notification.warning({ + top: 92, + message: result.message, + duration: 10 + }) + } }) } diff --git a/src/store/action-type.js b/src/store/action-type.js index 7654804..d7a4482 100644 --- a/src/store/action-type.js +++ b/src/store/action-type.js @@ -25,7 +25,10 @@ // 閲嶇疆缂栬緫绾у埆 export const RESET_EDITLEVEL = 'RESET_EDITLEVEL' -// 鍒濆鍖栨寜閽潈闄愬強鍒涘缓瀛樺偍杩囩▼鍙敤瀛楁 +// 鍒濆鍖栨寜閽潈闄� +export const INIT_ACTIONPERMISSION = 'INIT_ACTIONPERMISSION' + +// 鍒濆鍖栬鑹插垪琛ㄥ強鍒涘缓瀛樺偍杩囩▼鍙敤瀛楁 export const INIT_PERMISSION = 'INIT_PERMISSION' // 鍒濆鍖栬彍鍗曟潈闄� diff --git a/src/store/action.js b/src/store/action.js index 73896f1..f3723b0 100644 --- a/src/store/action.js +++ b/src/store/action.js @@ -70,12 +70,20 @@ } } -// 鍒濆鍖栨寜閽潈闄愬強鍒涘缓瀛樺偍杩囩▼鍙敤瀛楁 -export const initPermission = (permRoles, permAction, permFuncField) => { +// 鍒濆鍖栨寜閽潈闄� +export const initActionPermission = (permRoles, permAction) => { + return { + type: user.INIT_ACTIONPERMISSION, + permRoles: permRoles, + permAction: permAction + } +} + +// 鍒濆鍖栬鑹插垪琛ㄥ強鍒涘缓瀛樺偍杩囩▼鍙敤瀛楁 +export const initPermission = (sysRoles, permFuncField) => { return { type: user.INIT_PERMISSION, - permRoles: permRoles, - permAction: permAction, + sysRoles: sysRoles, permFuncField: permFuncField } } diff --git a/src/store/reducer.js b/src/store/reducer.js index 74d1f39..ca36ee2 100644 --- a/src/store/reducer.js +++ b/src/store/reducer.js @@ -1,18 +1,21 @@ import * as Type from './action-type' +let _collapse = localStorage.getItem('collapse') === 'true' + let defaultState = { selectedMainMenu: '', // 宸查�変富鑿滃崟 tabviews: [], // 瀵艰埅鏍� - collapse: false, // 鏄惁鏀惰捣渚ц竟鏍忓鑸� + collapse: _collapse, // 鏄惁鏀惰捣渚ц竟鏍忓鑸� isiframe: false, // 鏄惁涓篿frame绐楀彛 debug: false, // 鐭ュ惁鍙互澶嶅埗鑿滃崟鍙傛暟, 鏄惁鍙繘鍏ョ紪杈戞ā寮� editState: false, // 鏄惁涓虹紪杈戠姸鎬侊紝鍊间负false銆乼rue editLevel: null, // 缂栬緫鑿滃崟绾у埆锛屽�间负level1銆乴evel2銆乴evel3銆傘�傘�� refreshTab: null, // 鍒锋柊tabview椤甸潰淇℃伅 - permRoles: [], - permAction: {}, - permMenus: {}, - permFuncField: [] + permRoles: [], // 鐢ㄦ埛瑙掕壊鍒楄〃 + permAction: {}, // 鐢ㄦ埛鎸夐挳鏉冮檺 + permMenus: {}, // 鐢ㄦ埛涓夌骇鑿滃崟鏉冮檺 + permFuncField: [], // 绯荤粺妯″潡 + sysRoles: [] // 绯荤粺瑙掕壊鍒楄〃 } // 鐢ㄦ埛娑堟伅 @@ -90,12 +93,18 @@ ...state, editLevel: action.editLevel } - case Type.INIT_PERMISSION: - // 鍒濆鍖栨寜閽潈闄愬強鍒涘缓瀛樺偍杩囩▼鍙敤瀛楁 + case Type.INIT_ACTIONPERMISSION: + // 鍒濆鍖栨寜閽潈闄� return { ...state, permRoles: action.permRoles, - permAction: action.permAction, + permAction: action.permAction + } + case Type.INIT_PERMISSION: + // 鍒濆鍖栬鑹插垪琛ㄥ強鍒涘缓瀛樺偍杩囩▼鍙敤瀛楁 + return { + ...state, + sysRoles: action.sysRoles, permFuncField: action.permFuncField } case Type.INIT_MENUPERMISSION: @@ -108,14 +117,16 @@ return { selectedMainMenu: '', tabviews: [], - collapse: false, + collapse: localStorage.getItem('collapse') === 'true', isiframe: false, debug: false, editState: false, editLevel: null, refreshTab: null, permAction: {}, - permFuncField: [] + permFuncField: [], + sysRoles: [], + permMenus: {} } default: return state diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 849c1c3..e328ef9 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -435,12 +435,10 @@ * @description 鎼滅储鏉′欢缂栬緫锛岃幏鍙栨悳绱㈡潯浠惰〃鍗曚俊鎭� */ handleSearch = (card) => { - const { menu } = this.props - this.setState({ modaltype: 'search', card: card, - formlist: getSearchForm(card, menu.roleList) + formlist: getSearchForm(card, this.props.sysRoles) }) } @@ -528,14 +526,14 @@ loading: false, modaltype: 'columns', card: card, - formlist: getColumnForm(card, menu.roleList, menulist) + formlist: getColumnForm(card, this.props.sysRoles, menulist) }) }) } else { this.setState({ modaltype: 'columns', card: card, - formlist: getColumnForm(card, menu.roleList, menulist) + formlist: getColumnForm(card, this.props.sysRoles, menulist) }) } } else { @@ -3377,6 +3375,7 @@ const mapStateToProps = (state) => { return { + sysRoles: state.sysRoles, permFuncField: state.permFuncField } } diff --git a/src/templates/comtableconfig/source.jsx b/src/templates/comtableconfig/source.jsx index 7bd38c1..8fc542e 100644 --- a/src/templates/comtableconfig/source.jsx +++ b/src/templates/comtableconfig/source.jsx @@ -296,6 +296,12 @@ label: CommonDict['header.form.newpage.outer'], subType: 'outerpage', url: '' + }, + { + type: 'action', + label: CommonDict['header.form.funcbutton'], + subType: 'funcbutton', + url: '' } ] diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 4a905f6..f38b376 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -477,8 +477,8 @@ } let roleList = [] - if (menu.roleList && menu.roleList.length > 0) { - roleList = menu.roleList.map(role => { + if (this.props.sysRoles && this.props.sysRoles.length > 0) { + roleList = this.props.sysRoles.map(role => { return { uuid: role.uuid, field: role.value, @@ -2306,6 +2306,7 @@ const mapStateToProps = (state) => { return { + sysRoles: state.sysRoles, permFuncField: state.permFuncField } } diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index d15da7d..620b41b 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -1,5 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import {connect} from 'react-redux' import { is, fromJS } from 'immutable' import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' @@ -29,7 +30,7 @@ const { confirm } = Modal const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS -class ComTableConfig extends Component { +class ComModalConfig extends Component { static propTpyes = { menu: PropTypes.any, optionLibs: PropTypes.any, @@ -495,8 +496,8 @@ } let roleList = [] - if (menu.roleList && menu.roleList.length > 0) { - roleList = menu.roleList.map(role => { + if (this.props.sysRoles && this.props.sysRoles.length > 0) { + roleList = this.props.sysRoles.map(role => { return { uuid: role.uuid, field: role.value, @@ -1439,4 +1440,14 @@ } } -export default ComTableConfig \ No newline at end of file +const mapStateToProps = (state) => { + return { + sysRoles: state.sysRoles + } +} + +const mapDispatchToProps = () => { + return {} +} + +export default connect(mapStateToProps, mapDispatchToProps)(ComModalConfig) \ No newline at end of file diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx index e5fcada..8bab18e 100644 --- a/src/templates/subtableconfig/index.jsx +++ b/src/templates/subtableconfig/index.jsx @@ -417,12 +417,10 @@ * @description 鎼滅储鏉′欢缂栬緫锛岃幏鍙栨悳绱㈡潯浠惰〃鍗曚俊鎭� */ handleSearch = (card) => { - const { menu } = this.props - this.setState({ modaltype: 'search', card: card, - formlist: getSearchForm(card, menu.roleList) + formlist: getSearchForm(card, this.props.sysRoles) }) } @@ -510,14 +508,14 @@ loading: false, modaltype: 'columns', card: card, - formlist: getColumnForm(card, menu.roleList, menulist) + formlist: getColumnForm(card, this.props.sysRoles, menulist) }) }) } else { this.setState({ modaltype: 'columns', card: card, - formlist: getColumnForm(card, menu.roleList, menulist) + formlist: getColumnForm(card, this.props.sysRoles, menulist) }) } } else { @@ -2646,6 +2644,7 @@ const mapStateToProps = (state) => { return { + sysRoles: state.sysRoles, permFuncField: state.permFuncField } } diff --git a/src/templates/subtableconfig/source.jsx b/src/templates/subtableconfig/source.jsx index d0de914..9a6c5cc 100644 --- a/src/templates/subtableconfig/source.jsx +++ b/src/templates/subtableconfig/source.jsx @@ -246,6 +246,12 @@ label: CommonDict['header.form.excelOut'], subType: 'excelOut', url: '' + }, + { + type: 'action', + label: CommonDict['header.form.funcbutton'], + subType: 'funcbutton', + url: '' } ] diff --git a/src/templates/zshare/createinterface/index.jsx b/src/templates/zshare/createinterface/index.jsx index 83fc27c..31e61c9 100644 --- a/src/templates/zshare/createinterface/index.jsx +++ b/src/templates/zshare/createinterface/index.jsx @@ -805,6 +805,9 @@ @VoucherTypeOne ='${_voucher.VoucherTypeOne}', @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}', @Type =${_voucher.Type}, + @UserID=@UserID@, + @Username=@Username, + @FullName=@FullName, @BVoucher =@BVoucher OUTPUT , @FIBVoucherDate =@FIBVoucherDate OUTPUT , @FiYear =@FiYear OUTPUT , diff --git a/src/templates/zshare/verifycard/customform/index.jsx b/src/templates/zshare/verifycard/customform/index.jsx index 5ddb237..2217988 100644 --- a/src/templates/zshare/verifycard/customform/index.jsx +++ b/src/templates/zshare/verifycard/customform/index.jsx @@ -1,6 +1,10 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { Form, Row, Col, Input, Select, Button, notification } from 'antd' +import moment from 'moment' + +import Utils from '@/utils/utils.js' +import Api from '@/api' import './index.scss' const { TextArea } = Input @@ -9,11 +13,13 @@ static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� usefulfields: PropTypes.string, // 鍙敤瀛楁 + initsql: PropTypes.string, // 鍙敤瀛楁 customChange: PropTypes.func // 琛ㄥ崟 } state = { - editItem: null + editItem: null, + loading: false } edit = (record) => { @@ -67,14 +73,35 @@ }) return } + + let param = { + func: 's_debug_sql', + LText: this.props.initsql + values.sql + } + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) - this.props.customChange(values) - this.setState({ - editItem: null - }) - this.props.form.setFieldsValue({ - sql: '', - errmsg: '' + this.setState({loading: true}) + Api.getLocalConfig(param).then(res => { + if (res.status) { + this.props.customChange(values) + this.setState({ + loading: false, + editItem: null + }) + this.props.form.setFieldsValue({ + sql: '', + errmsg: '' + }) + } else { + this.setState({loading: false}) + notification.warning({ + top: 92, + message: res.message, + duration: 10 + }) + } }) } }) @@ -115,7 +142,7 @@ </Form.Item> </Col> <Col span={3} className="add"> - <Button onClick={this.handleConfirm} type="primary" className="add-row"> + <Button onClick={this.handleConfirm} loading={this.state.loading} type="primary" className="add-row"> 纭畾 </Button> </Col> diff --git a/src/templates/zshare/verifycard/customscript/index.jsx b/src/templates/zshare/verifycard/customscript/index.jsx index 549ba8c..3802050 100644 --- a/src/templates/zshare/verifycard/customscript/index.jsx +++ b/src/templates/zshare/verifycard/customscript/index.jsx @@ -1,6 +1,10 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { Form, Row, Col, Input, Button, notification } from 'antd' +import moment from 'moment' + +import Utils from '@/utils/utils.js' +import Api from '@/api' import './index.scss' const { TextArea } = Input @@ -9,11 +13,13 @@ static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� usefulfields: PropTypes.string, // 鍙敤瀛楁 + initsql: PropTypes.string, // 鍙敤瀛楁 scriptsChange: PropTypes.func // 琛ㄥ崟 } state = { - editItem: null + editItem: null, + loading: false } edit = (record) => { @@ -64,12 +70,33 @@ return } - this.props.scriptsChange(values) - this.setState({ - editItem: null - }) - this.props.form.setFieldsValue({ - sql: '' + let param = { + func: 's_debug_sql', + LText: this.props.initsql + values.sql + } + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + this.setState({loading: true}) + Api.getLocalConfig(param).then(res => { + if (res.status) { + this.props.scriptsChange(values) + this.setState({ + loading: false, + editItem: null + }) + this.props.form.setFieldsValue({ + sql: '' + }) + } else { + this.setState({loading: false}) + notification.warning({ + top: 92, + message: res.message, + duration: 10 + }) + } }) } }) @@ -111,7 +138,7 @@ </Form.Item> </Col> <Col span={3} className="add"> - <Button onClick={this.handleConfirm} type="primary" className="add-row"> + <Button onClick={this.handleConfirm} loading={this.state.loading} type="primary" className="add-row"> 纭畾 </Button> </Col> diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index c292b7b..452686b 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -28,6 +28,7 @@ state = { updateloading: false, // 淇敼涓� + initsql: '', // sql楠岃瘉鏃跺彉閲忓0鏄庡強璧嬪�� verify: {}, fields: [], usefulfields: '', @@ -457,11 +458,39 @@ } let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName'] + let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)'] + let _select = ['@UserName=\'\'', '@FullName=\'\''] let hasBid = false + let fieldArr = _usefulfields.map(_f => _f.toLowerCase()) _fields.forEach(_f => { if (_f.field) { + if (fieldArr.includes(_f.field.toLowerCase())) return + fieldArr.push(_f.field.toLowerCase()) + _usefulfields.push(_f.field) + + let _fieldlen = _f.fieldlength || 50 + + if (['textarea', 'fileupload', 'multiselect'].includes(_f.type)) { + _fieldlen = _f.fieldlength || 512 + } else if (_f.type === 'number') { + _fieldlen = _f.decimal ? _f.decimal : 0 + } + + let _type = `nvarchar(${_fieldlen})` + + if (_f.type.match(/date/ig)) { + _type = 'datetime' + _select.push(`@${_f.field}='1900-01-01'`) + } else if (_f.type === 'number') { + _type = `decimal(18,${_fieldlen})` + _select.push(`@${_f.field}=0`) + } else { + _select.push(`@${_f.field}=''`) + } + + _declare.push(`@${_f.field} ${_type}`) } if (_f.field && _f.field.toLowerCase() === 'bid') { hasBid = true @@ -479,18 +508,38 @@ if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired') { columns.forEach(_f => { - if (_f.field) { - _usefulfields.push(_f.field) + if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return + + fieldArr.push(_f.field.toLowerCase()) + + _usefulfields.push(_f.field) + + let _type = `nvarchar(${_f.fieldlength || 50})` + + if (_f.type === 'number') { + _type = `decimal(18,${_f.decimal ? _f.decimal : 0})` + } else if (_f.type === 'picture' || _f.type === 'textarea') { + _type = `nvarchar(${_f.fieldlength || 512})` } + + if (_f.type === 'number') { + _select.push(`@${_f.field}=0`) + } else { + _select.push(`@${_f.field}=''`) + } + + _declare.push(`@${_f.field} ${_type}`) }) } - _usefulfields = Array.from(new Set(_usefulfields)) _usefulfields = _usefulfields.join(', ') - + let _sql = `Declare ${_declare.join(', ')} + Select ${_select.join(', ')} + ` this.setState({ fields: _fields, + initsql: _sql, usefulfields: _usefulfields }) } else { @@ -503,20 +552,43 @@ }) } else { let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName'] + let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)'] + let _select = ['@UserName=\'\'', '@FullName=\'\''] + let fieldArr = _usefulfields.map(_f => _f.toLowerCase()) if (columns && columns.length > 0 && this.props.card.Ot !== 'notRequired') { columns.forEach(_f => { - if (_f.field) { - _usefulfields.push(_f.field) + if (!_f.field || fieldArr.includes(_f.field.toLowerCase())) return + + fieldArr.push(_f.field.toLowerCase()) + + _usefulfields.push(_f.field) + + let _type = `nvarchar(${_f.fieldlength || 50})` + + if (_f.type === 'number') { + _type = `decimal(18,${_f.decimal ? _f.decimal : 0})` + } else if (_f.type === 'picture' || _f.type === 'textarea') { + _type = `nvarchar(${_f.fieldlength || 512})` } + + if (_f.type === 'number') { + _select.push(`@${_f.field}=0`) + } else { + _select.push(`@${_f.field}=''`) + } + + _declare.push(`@${_f.field} ${_type}`) }) } - _usefulfields = Array.from(new Set(_usefulfields)) _usefulfields = _usefulfields.join(', ') - + let _sql = `Declare ${_declare.join(', ')} + Select ${_select.join(', ')} + ` this.setState({ + initsql: _sql, usefulfields: _usefulfields }) } @@ -588,7 +660,7 @@ // 鑾峰彇鍑瘉浜岀骇鑿滃崟 let defer3 = new Promise(resolve => { - let _voucherSql = 'select ID,ModularCode+ModularName+ModularNo as NameNO,TypeCharOne from sModular where deleted=0' + let _voucherSql = 'select distinct ModularCode as ID,ModularCode+ModularName+ModularNo as NameNO,TypeCharOne from sModular where deleted=0 and Appkey=case when Appkey=\'\' then \'\' else @Appkey@ end order by ModularCode' _voucherSql = Utils.formatOptions(_voucherSql) let voucherParam = { @@ -616,7 +688,7 @@ // 鑾峰彇鍑瘉涓夌骇鑿滃崟 let defer4 = new Promise(resolve => { - let _voucherDetailSql = 'select ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,BID, VoucherTypeTwo, IDefine1 from sModularDetail where Deleted=0 and VoucherTypeTwo!=\'\'' + let _voucherDetailSql = 'select distinct ModularDetailCode,ModularDetailCode+ModularDetailName as CodeName,ModularCode as BID, VoucherTypeTwo, IDefine1 from sModularDetail where Deleted=0 and VoucherTypeTwo!=\'\' and Appkey=case when Appkey=\'\' then \'\' else @Appkey@ end order by ModularDetailCode' _voucherDetailSql = Utils.formatOptions(_voucherDetailSql) let voucherDetailParam = { @@ -1142,6 +1214,7 @@ <TabPane tab="鑷畾涔夐獙璇�" key="3"> <CustomForm dict={this.props.dict} + initsql={this.state.initsql} usefulfields={this.state.usefulfields} customChange={this.customChange} wrappedComponentRef={(inst) => this.customForm = inst} @@ -1190,6 +1263,7 @@ <TabPane tab="鑷畾涔夎剼鏈�" key="6"> <CustomScript usefulfields={this.state.usefulfields} + initsql={this.state.initsql} dict={this.props.dict} scriptsChange={this.scriptsChange} wrappedComponentRef={(inst) => this.scriptsForm = inst} diff --git a/src/utils/utils.js b/src/utils/utils.js index aadd620..506e85e 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -964,6 +964,9 @@ @VoucherTypeOne ='${_voucher.VoucherTypeOne}', @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}', @Type =${_voucher.Type}, + @UserID=@UserID@, + @Username=@Username, + @FullName=@FullName, @BVoucher =@BVoucher OUTPUT , @FIBVoucherDate =@FIBVoucherDate OUTPUT , @FiYear =@FiYear OUTPUT , diff --git a/src/views/login/logincloudform.jsx b/src/views/login/logincloudform.jsx index de65e1c..4a6c448 100644 --- a/src/views/login/logincloudform.jsx +++ b/src/views/login/logincloudform.jsx @@ -44,7 +44,7 @@ } componentDidMount () { - const input = document.getElementById('username') + const input = document.getElementById('cloudusername') if (input) { input.focus() } -- Gitblit v1.8.0