From 061e2388d84fc545d01175ed6793ce8dea0e7338 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 11 七月 2023 18:02:58 +0800 Subject: [PATCH] 2023-07-11 --- src/components/tabview/index.jsx | 9 src/menu/components/form/formaction/formconfig.jsx | 7 src/tabviews/custom/components/form/tab-form/index.jsx | 3 src/menu/components/form/formaction/index.scss | 1 src/tabviews/custom/components/form/tab-form/index.scss | 1 src/templates/treepageconfig/updatetable/index.jsx | 5 src/templates/formtabconfig/index.jsx | 6 src/menu/components/form/formaction/actionform/index.jsx | 8 src/tabviews/custom/components/form/simple-form/index.scss | 1 src/components/breadview/index.jsx | 3 src/menu/components/form/simple-form/index.jsx | 2 /dev/null | 230 -------- src/views/basedesign/index.jsx | 9 src/templates/formtabconfig/updatetable/index.scss | 0 src/tabviews/custom/components/form/step-form/index.scss | 1 src/tabviews/custom/components/form/step-form/index.jsx | 3 src/tabviews/custom/components/form/simple-form/index.jsx | 3 src/templates/formtabconfig/updatetable/index.jsx | 1274 +++++++++++++++++++++++++++++++++++++++++++++++ 18 files changed, 1,309 insertions(+), 257 deletions(-) diff --git a/src/components/breadview/index.jsx b/src/components/breadview/index.jsx index 29ae6c0..15a578b 100644 --- a/src/components/breadview/index.jsx +++ b/src/components/breadview/index.jsx @@ -18,7 +18,6 @@ const TreePage = asyncComponent(() => import('@/tabviews/treepage')) const Iframe = asyncComponent(() => import('@/tabviews/iframe')) const RoleManage = asyncComponent(() => import('@/tabviews/rolemanage')) -const FormTab = asyncComponent(() => import('@/tabviews/formtab')) moment.locale('zh-cn') @@ -100,8 +99,6 @@ return (<CommonTable MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} param={view.param} changeTemp={this.changeTemp}/>) } else if (view.type === 'TreePage') { return (<TreePage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} param={view.param}/>) - } else if (view.type === 'FormTab') { - return (<FormTab MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} param={view.param}/>) } else if (view.type === 'iframe') { return (<Iframe MenuID={view.MenuID} title={view.MenuName} url={view.src}/>) } else { diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx index 991ce27..789e4ad 100644 --- a/src/components/tabview/index.jsx +++ b/src/components/tabview/index.jsx @@ -8,7 +8,7 @@ import 'moment/locale/zh-cn' import asyncComponent from '@/utils/asyncLoadComponent' -// import NotFount from '@/components/404' +import NotFount from '@/components/404' import options from '@/store/options.js' import MKEmitter from '@/utils/events.js' import Api from '@/api' @@ -21,8 +21,6 @@ const TreePage = asyncComponent(() => import('@/tabviews/treepage')) const Iframe = asyncComponent(() => import('@/tabviews/iframe')) const RoleManage = asyncComponent(() => import('@/tabviews/rolemanage')) -const FormTab = asyncComponent(() => import('@/tabviews/formtab')) -const Calendar = asyncComponent(() => import('@/tabviews/calendar')) moment.locale('zh-cn') @@ -208,13 +206,10 @@ return (<TreePage MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} param={view.param}/>) } else if (view.type === 'RolePermission') { return (<RoleManage MenuID={view.MenuID}/>) - } else if (view.type === 'FormTab') { - return (<FormTab MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} param={view.param}/>) } else if (view.type === 'iframe') { return (<Iframe MenuID={view.MenuID} title={view.MenuName} url={view.src}/>) } else { - return (<Calendar MenuNo={view.MenuNo} MenuID={view.MenuID} MenuName={view.MenuName} param={view.param}/>) - // return (<NotFount />) + return (<NotFount />) } } diff --git a/src/menu/components/form/formaction/actionform/index.jsx b/src/menu/components/form/formaction/actionform/index.jsx index 6e9ac94..85144b8 100644 --- a/src/menu/components/form/formaction/actionform/index.jsx +++ b/src/menu/components/form/formaction/actionform/index.jsx @@ -51,13 +51,13 @@ let reReadonly = {} if (this.record.type === 'prev') { - shows = ['type', 'label', 'enable', 'actionType'] + shows = ['typeName', 'label', 'actionType'] } else if (this.record.type === 'next') { - shows = ['type', 'label', 'enable', 'actionType'] + shows = ['typeName', 'label', 'actionType'] } else if (this.record.type === 'close') { - shows = ['type', 'label', 'enable'] + shows = ['typeName', 'label'] } else { - shows = ['type', 'label', 'intertype', 'Ot', 'execSuccess', 'syncComponent', 'anchors', 'linkmenu', 'enable', 'output', 'reload'] // 閫夐」鍒楄〃 + shows = ['typeName', 'label', 'intertype', 'Ot', 'execSuccess', 'syncComponent', 'anchors', 'linkmenu', 'output', 'reload'] // 閫夐」鍒楄〃 if (this.record.intertype === 'custom') { shows.pop() diff --git a/src/menu/components/form/formaction/formconfig.jsx b/src/menu/components/form/formaction/formconfig.jsx index cb9881e..65448fa 100644 --- a/src/menu/components/form/formaction/formconfig.jsx +++ b/src/menu/components/form/formaction/formconfig.jsx @@ -60,6 +60,13 @@ type: 'tip', key: 'type', label: '鎸夐挳绫诲瀷', + initVal: card.type, + forbid: true + }, + { + type: 'tip', + key: 'typeName', + label: '鎸夐挳绫诲瀷', initVal: _type }, { diff --git a/src/menu/components/form/formaction/index.scss b/src/menu/components/form/formaction/index.scss index 79055ca..b980900 100644 --- a/src/menu/components/form/formaction/index.scss +++ b/src/menu/components/form/formaction/index.scss @@ -10,6 +10,7 @@ .submit { border: none; height: auto; + border-style: solid; } .skip { color: rgba(0, 0, 0, 0.85); diff --git a/src/menu/components/form/simple-form/index.jsx b/src/menu/components/form/simple-form/index.jsx index 5c012de..9e00fe2 100644 --- a/src/menu/components/form/simple-form/index.jsx +++ b/src/menu/components/form/simple-form/index.jsx @@ -69,7 +69,7 @@ scripts: [], subcards: [{ uuid: Utils.getuuid(), - setting: {title: '绌�', align: 'left_right', enable: 'true'}, + setting: {title: '', align: 'left_right', enable: 'true'}, style: {}, fields: [], subButton: {label: '鎻愪氦', type: 'submit', intertype: 'system', reload: 'false', sqlType: 'update', sql: '', Ot: 'notRequired', execSuccess: 'never', enable: 'true', style: {backgroundColor: '#1890ff', color: '#ffffff', paddingLeft: '25px', paddingRight: '25px', paddingTop: '5px', paddingBottom: '5px'}}, diff --git a/src/tabviews/calendar/index.jsx b/src/tabviews/calendar/index.jsx deleted file mode 100644 index 7ed4d3f..0000000 --- a/src/tabviews/calendar/index.jsx +++ /dev/null @@ -1,590 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { notification, Spin, Modal, Button } from 'antd' -import moment from 'moment' - -import Api from '@/api' -import options from '@/store/options.js' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' -import Utils from '@/utils/utils.js' -import asyncComponent from '@/utils/asyncComponent' -import asyncSpinComponent from '@/utils/asyncSpinComponent' -import MKEmitter from '@/utils/events.js' -import NotFount from '@/components/404' -import './index.scss' - -// 閫氱敤缁勪欢 -const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) -const CalendarComponent = asyncSpinComponent(() => import('@/tabviews/zshare/calendar')) -const SubTabTable = asyncSpinComponent(() => import('@/tabviews/subtabtable')) -const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage')) - -class MkCalendar extends Component { - static propTpyes = { - param: PropTypes.any, // 鍏朵粬椤甸潰浼犻�掔殑鍙傛暟 - MenuID: PropTypes.string, // 鑿滃崟Id - MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 - MenuName: PropTypes.string // 鑿滃崟鍚嶇О - } - - state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - BID: null, // 椤甸潰璺宠浆鏃舵惡甯D - loadingview: true, // 椤甸潰鍔犺浇涓� - viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 - lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 - config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佹悳绱€�佹樉绀哄垪銆佹爣绛剧瓑 - userConfig: null, // 鐢ㄦ埛鑷畾涔夎缃� - arr_field: '', // 鏌ヨ瀛楁闆� - setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 - data: null, // 鍒楄〃鏁版嵁闆� - loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� - search: '', // 鎼滅储鏉′欢鏁扮粍锛屼娇鐢ㄦ椂闇�鍒嗗満鏅鐞� - visible: false, // 鏍囩椤垫帶鍒� - triggerTime: '', // 鐐瑰嚮鏃堕棿 - calendarYear: moment().format('YYYY'), // 鏃ュ巻骞翠唤 - hasReqFields: false - } - - /** - * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 - */ - async loadconfig () { - const { param } = this.props - - let _param = { - func: 'sPC_Get_LongParam', - MenuID: this.props.MenuID - } - let result = await Api.getCacheConfig(_param) - - if (result.status) { - let config = '' - let userConfig = null - let _curUserConfig = '' - - try { // 閰嶇疆淇℃伅瑙f瀽 - config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - } catch (e) { - console.warn('Parse Failure') - config = '' - } - - // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆 - if (result.LongParamUser && !window.GLOB.mkHS) { - try { // 閰嶇疆淇℃伅瑙f瀽 - userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) - _curUserConfig = userConfig[this.props.MenuID] - } catch (e) { - console.warn('Parse Failure') - userConfig = null - } - } - - // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� - if (!config) { - this.setState({ - loadingview: false, - viewlost: true - }) - return - } - - // 椤甸潰鏈惎鐢ㄦ椂锛屾樉绀烘湭鍚敤椤甸潰 - if (!config.enabled) { - this.setState({ - loadingview: false, - viewlost: true, - lostmsg: this.state.dict['main.view.unenabled'] - }) - return - } - - // 鏉冮檺杩囨护 - if (config.tab) { - config.tab.uuid = Utils.getuuid() - } - - if (_curUserConfig) { - config.setting = {...config.setting, ..._curUserConfig.setting} - config.easyCode = _curUserConfig.easyCode || config.easyCode || '' - } - - config.search = Utils.initSearchVal(config.search) - - // 瀛楁閫忚 - let hasReqFields = false - config.search = config.search.map(item => { - if (param && ['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { - item.initval = param.$searchval - } - - if (item.required) { - hasReqFields = true - } - - return item - }) - - // 鏁版嵁婧� - if (config.setting.interType === 'inner' && !config.setting.innerFunc) { - config.setting.interType = 'system' - } - - if (config.setting.interType === 'system') { - // 鏁寸悊鏁版嵁婧愯嚜瀹氫箟鑴氭湰 - let _customScript = '' - config.scripts && config.scripts.forEach(script => { - if (script.status !== 'false') { - _customScript += ` - ${script.sql} - ` - } - }) - - if (/\s/.test(config.setting.dataresource)) { - config.setting.dataresource = '(' + config.setting.dataresource + ') tb' - } - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') - config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') - _customScript = _customScript.replace(/\$@/ig, '/*') - _customScript = _customScript.replace(/@\$/ig, '*/') - } else { - config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') - _customScript = _customScript.replace(/@\$|\$@/ig, '') - } - - let userName = sessionStorage.getItem('User_Name') || '' - let fullName = sessionStorage.getItem('Full_Name') || '' - - if (sessionStorage.getItem('isEditState') === 'true') { - userName = sessionStorage.getItem('CloudUserName') || '' - fullName = sessionStorage.getItem('CloudFullName') || '' - } - - let regs = [ - { reg: /@userName@/ig, value: `'${userName}'` }, - { reg: /@fullName@/ig, value: `'${fullName}'` } - ] - - regs.forEach(cell => { - config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value) - _customScript = _customScript.replace(cell.reg, cell.value) - }) - - if (config.urlFields) { - let _param = param || {} - config.urlFields.forEach(field => { - let reg = new RegExp('@' + field + '@', 'ig') - let val = `'${_param[field] || ''}'` - config.setting.dataresource = config.setting.dataresource.replace(reg, val) - _customScript = _customScript.replace(reg, val) - }) - } - - config.setting.customScript = _customScript - } - - config.type = 'table' - config.wrap = { - show: config.setting.show || '', - float: config.setting.float || '', - advanceType: config.setting.advanceType || '', - advanceWidth: config.setting.advanceWidth || '', - drawerPlacement: config.setting.drawerPlacement || '', - searchRatio: config.setting.searchRatio || '', - searchLwidth: config.setting.searchLwidth, - borderRadius: config.setting.borderRadius, - } - - this.setState({ - hasReqFields, - BID: param && param.$BID ? param.$BID : '', - loadingview: false, - config: config, - userConfig: userConfig, - setting: config.setting, - arr_field: config.columns.map(item => item.field).join(','), - search: Utils.initMainSearch(config.search) - }, () => { - if (config.setting.onload !== 'false') { - this.loadmaindata() - } - }) - } else { - this.setState({ - loadingview: false, - viewlost: true - }) - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - } - - /** - * @description 涓昏〃鏁版嵁鍔犺浇 - */ - async loadmaindata () { - const { setting, search, BID, hasReqFields } = this.state - let param = '' - - if (hasReqFields) { - let requireFields = search.filter(item => item.required && item.value === '') - - if (requireFields.length > 0) { - return - } - } - - this.setState({ - loading: true - }) - - if (setting.interType === 'system') { - param = this.getDefaultParam() - } else { - param = this.getCustomParam() - } - - if (BID) { - param.BID = BID - } - // 鏁版嵁绠$悊鏉冮檺 - if (sessionStorage.getItem('dataM') === 'true') { - param.dataM = 'Y' - } - - let result = await Api.genericInterface(param) - if (result.status) { - this.setState({ - data: result.data.map((item, index) => { - item.key = index - return item - }), - loading: false - }) - } else { - this.setState({ - loading: false - }) - if (result.ErrCode === 'N') { - Modal.error({ - title: result.message, - }) - } else { - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } - } - } - - /** - * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� - */ - getCustomParam = () => { - const { search, setting, calendarYear, config } = this.state - - let _search = Utils.formatCustomMainSearch(search) - - let param = { - ..._search - } - - if (config.calendar.refresh === 'true') { - param.calendarDate = calendarYear - } - - if (setting.interType === 'inner') { - param.func = setting.innerFunc - } else { - if (window.GLOB.mkHS) { - if (setting.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - param.userid = sessionStorage.getItem('CloudUserID') || '' - param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } else if (setting.sysInterface !== 'true') { - param.rduri = setting.interface - } - } else { - if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (setting.sysInterface !== 'true') { - param.rduri = setting.interface - } - } - - if (setting.outerFunc) { - param.func = setting.outerFunc - } - } - - return param - } - - /** - * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼鐨勫弬鏁� - */ - getDefaultParam = () => { - const { arr_field, search, setting, config, calendarYear } = this.state - - let _search = Utils.joinMainSearchkey(search) - _search = _search ? 'where ' + _search : '' - - let param = { - func: 'sPC_Get_TableData', - obj_name: 'data', - arr_field: arr_field, - custom_script: setting.customScript, - default_sql: setting.execute || 'true', - menuname: this.props.MenuName || '' - } - - let _dataresource = setting.dataresource - let regoptions = [] - let userName = sessionStorage.getItem('User_Name') || '' - let fullName = sessionStorage.getItem('Full_Name') || '' - let RoleID = sessionStorage.getItem('role_id') || '' - let departmentcode = sessionStorage.getItem('departmentcode') || '' - let organization = sessionStorage.getItem('organization') || '' - let mk_user_type = sessionStorage.getItem('mk_user_type') || '' - let nation = sessionStorage.getItem('nation') || '' - let province = sessionStorage.getItem('province') || '' - let city = sessionStorage.getItem('city') || '' - let district = sessionStorage.getItem('district') || '' - let address = sessionStorage.getItem('address') || '' - - if (sessionStorage.getItem('isEditState') === 'true') { - userName = sessionStorage.getItem('CloudUserName') || '' - fullName = sessionStorage.getItem('CloudFullName') || '' - } - - if (setting.queryType === 'statistics' || param.custom_script) { - let allSearch = Utils.getAllSearchOptions(search) - regoptions = allSearch.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` - } - }) - regoptions.push({ - reg: new RegExp('@userName@', 'ig'), - value: userName - }, { - reg: new RegExp('@fullName@', 'ig'), - value: fullName - }) - } - - if (config.calendar.refresh === 'true') { - regoptions.push({ - reg: new RegExp('@calendarDate@', 'ig'), - value: `'${calendarYear}-01-01 00:00:00.000'` - }) - regoptions.push({ - reg: new RegExp('@calendarDate1@', 'ig'), - value: `'${calendarYear}-12-31 23:59:59.999'` - }) - } - - if ((setting.queryType === 'statistics' || config.calendar.refresh === 'true') && setting.execute !== 'false') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 - regoptions.forEach(item => { - _dataresource = _dataresource.replace(item.reg, item.value) - }) - _search = '' - } - - let LText = '' - - if (setting.execute !== 'false') { - LText = `select ${arr_field} from ${_dataresource} ${_search}` - } - - if (param.custom_script) { - regoptions.forEach(item => { - param.custom_script = param.custom_script.replace(item.reg, item.value) - }) - - param.custom_script = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) - Select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}' - ${param.custom_script} - ` - - if (LText) { - LText += ` - aaa: - if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ - ` - } else { - param.custom_script += ` - aaa: - if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ - ` - } - } - - // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 - if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { - param.custom_script && console.info(`${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${param.custom_script}`) - LText && console.info(LText) - } - - param.custom_script = Utils.formatOptions(param.custom_script) - param.LText = Utils.formatOptions(LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - param.DateCount = '' - - if (window.GLOB.probation) { - param.s_debug_type = 'Y' - } - - if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - return param - } - - /** - * @description 鎼滅储鏉′欢鏀瑰彉鏃讹紝閲嶇疆琛ㄦ牸鏁版嵁 - * 鍚湁鍒濆涓嶅姞杞界殑椤甸潰锛屼慨鏀硅缃� - */ - refreshbysearch = (searches) => { - const { setting } = this.state - - if (setting.onload === 'false') { - this.setState({ - search: searches, - setting: {...setting, onload: 'true'} - }, () => { - this.loadmaindata() - }) - } else { - this.setState({ - search: searches - }, () => { - this.loadmaindata() - }) - } - } - - - /** - * @description 椤甸潰鍒锋柊锛岄噸鏂拌幏鍙栭厤缃� - */ - reloadview = () => { - this.setState({ loadingview: true, viewlost: false, lostmsg: '', data: null, loading: false, search: '' - }, () => { - this.loadconfig() - }) - } - - reloadMenuView = (menuId) => { - const { MenuID } = this.props - - if (MenuID !== menuId) return - - this.reloadview() - } - - UNSAFE_componentWillMount () { - // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 - this.loadconfig() - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) - } - - componentDidMount () { - MKEmitter.addListener('openNewTab', this.closeTab) - MKEmitter.addListener('reloadMenuView', this.reloadMenuView) - MKEmitter.addListener('refreshPopButton', this.refreshPopButton) - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 - */ - componentWillUnmount () { - this.setState = () => { - return - } - MKEmitter.removeListener('openNewTab', this.closeTab) - MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) - MKEmitter.removeListener('refreshPopButton', this.refreshPopButton) - } - - refreshPopButton = (tabId) => { - const { config } = this.props - - if (!config.tab || config.tab.uuid !== tabId) return - - this.loadmaindata() - } - - triggerDate = (item) => { - const { config } = this.state - - if (!config.tab) return - - this.setState({ - visible: true, - triggerTime: item.time.substr(0, 4) + '-' + item.time.substr(4, 2) + '-' + item.time.substr(6, 2) - }) - } - - closeTab = () => { - this.setState({ - visible: false, - triggerTime: '' - }) - } - - render() { - const { BID, loadingview, viewlost, config, loading, data, triggerTime } = this.state - - return ( - <div className="calendar-page"> - {loadingview && <Spin size="large" />} - {config.search && config.search.length > 0 ? - <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null - } - {config && config.calendar ? <CalendarComponent calendar={config.calendar} loading={loading} data={data} triggerDate={this.triggerDate} changeDate={this.changeDate}/> : null} - {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} - <Modal - title={config.tab ? config.tab.label : ''} - width={'80vw'} - maskClosable={false} - visible={this.state.visible} - onCancel={this.closeTab} - footer={[ - <Button key="close" onClick={this.closeTab}>{this.state.dict['main.close']}</Button> - ]} - destroyOnClose - > - {config.tab ? <SubTabTable - BID={triggerTime} - Tab={config.tab} - MenuID={config.tab.linkTab} - SupMenuID={this.props.MenuID} - /> : null} - </Modal> - {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} - </div> - ) - } -} - -export default MkCalendar \ No newline at end of file diff --git a/src/tabviews/calendar/index.scss b/src/tabviews/calendar/index.scss deleted file mode 100644 index 23d25cf..0000000 --- a/src/tabviews/calendar/index.scss +++ /dev/null @@ -1,44 +0,0 @@ -.calendar-page { - position: relative; - min-height: calc(100vh - 94px); - padding-top: 16px; - padding-bottom: 80px; - .box404 { - padding-top: 30px; - } - >.mk-search-wrap { - padding: 0px 24px 5px; - border-bottom: 1px solid #efefef; - } - - .ant-modal-mask { - position: absolute; - } - .ant-modal-wrap { - position: absolute; - } - .action-modal .ant-modal { - top: 40px; - max-width: 95%; - .ant-modal-body { - max-height: calc(100vh - 265px); - } - } - > .ant-spin { - position: absolute; - z-index: 10; - left: calc(50% - 22px); - top: calc(50vh - 70px); - } - - .common-table-copy { - position: fixed; - z-index: 2; - bottom: 65px; - right: 30px; - width: 40px; - height: 40px; - } -} - - diff --git a/src/tabviews/custom/components/form/simple-form/index.jsx b/src/tabviews/custom/components/form/simple-form/index.jsx index d3214a5..4d1bb99 100644 --- a/src/tabviews/custom/components/form/simple-form/index.jsx +++ b/src/tabviews/custom/components/form/simple-form/index.jsx @@ -226,6 +226,7 @@ }, () => { this.setState({data: {$$empty: true}}) }) + MKEmitter.emit('resetSelectLine', config.uuid, '', '') return } @@ -256,6 +257,8 @@ this.setState({data: _data}) }) + MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid, _data) + if (result.message) { if (result.ErrCode === 'Y') { Modal.success({ diff --git a/src/tabviews/custom/components/form/simple-form/index.scss b/src/tabviews/custom/components/form/simple-form/index.scss index 123523e..78ba331 100644 --- a/src/tabviews/custom/components/form/simple-form/index.scss +++ b/src/tabviews/custom/components/form/simple-form/index.scss @@ -17,6 +17,7 @@ .submit { min-width: 70px; border: none; + border-style: solid; } } .mk-form-action.no-button { diff --git a/src/tabviews/custom/components/form/step-form/index.jsx b/src/tabviews/custom/components/form/step-form/index.jsx index 326a191..3965ad6 100644 --- a/src/tabviews/custom/components/form/step-form/index.jsx +++ b/src/tabviews/custom/components/form/step-form/index.jsx @@ -285,6 +285,7 @@ }, () => { this.setState({data: {$$empty: true}}) }) + MKEmitter.emit('resetSelectLine', config.uuid, '', '') return } @@ -334,6 +335,8 @@ this.setState({group: _group}) }) + MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid, _data) + if (result.message) { if (result.ErrCode === 'Y') { Modal.success({ diff --git a/src/tabviews/custom/components/form/step-form/index.scss b/src/tabviews/custom/components/form/step-form/index.scss index 12ca54d..8a2908a 100644 --- a/src/tabviews/custom/components/form/step-form/index.scss +++ b/src/tabviews/custom/components/form/step-form/index.scss @@ -71,6 +71,7 @@ .submit { min-width: 70px; border: none; + border-style: solid; } .skip { color: rgba(0, 0, 0, 0.85); diff --git a/src/tabviews/custom/components/form/tab-form/index.jsx b/src/tabviews/custom/components/form/tab-form/index.jsx index 8538f65..988b04c 100644 --- a/src/tabviews/custom/components/form/tab-form/index.jsx +++ b/src/tabviews/custom/components/form/tab-form/index.jsx @@ -242,6 +242,7 @@ }, () => { this.setState({data: {$$empty: true}}) }) + MKEmitter.emit('resetSelectLine', config.uuid, '', '') return } @@ -272,6 +273,8 @@ this.setState({data: _data}) }) + MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid, _data) + if (result.message) { if (result.ErrCode === 'Y') { Modal.success({ diff --git a/src/tabviews/custom/components/form/tab-form/index.scss b/src/tabviews/custom/components/form/tab-form/index.scss index a079e22..04a53bd 100644 --- a/src/tabviews/custom/components/form/tab-form/index.scss +++ b/src/tabviews/custom/components/form/tab-form/index.scss @@ -60,6 +60,7 @@ .submit { min-width: 70px; border: none; + border-style: solid; } } .mk-form-action.no-button { diff --git a/src/tabviews/formtab/actionList/index.jsx b/src/tabviews/formtab/actionList/index.jsx deleted file mode 100644 index 9b97235..0000000 --- a/src/tabviews/formtab/actionList/index.jsx +++ /dev/null @@ -1,368 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import moment from 'moment' -import { Button, Modal, notification, message } from 'antd' -import Utils, { getSysDefaultSql } from '@/utils/utils.js' -import options from '@/store/options.js' -import Api from '@/api' -import './index.scss' - -const { confirm } = Modal - -class MainAction extends Component { - static propTpyes = { - MenuID: PropTypes.string, // 鑿滃崟ID - primaryId: PropTypes.string, // 涓婚敭 - actions: PropTypes.array, // 鎸夐挳缁� - dict: PropTypes.object, // 瀛楀吀椤� - data: PropTypes.any, // 鏁版嵁 - setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 - getFormData: PropTypes.func, // 鑾峰彇琛ㄥ崟鍊� - refreshdata: PropTypes.func, // 鎵ц瀹屾垚鍚庢暟鎹埛鏂� - } - - state = { - formdata: null, - loadingUuid: '' - } - - /** - * @description 瑙﹀彂鎸夐挳鎿嶄綔 - */ - actionTrigger = (item) => { - const { data } = this.props - let _this = this - - 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() {} - }) - } else if (item.OpenType === 'exec') { - this.setState({loadingUuid: item.uuid}) - - this.execSubmit(item, data, () => { - this.setState({loadingUuid: ''}) - }, res) - } - }) - } else { - item.afterExecSuccess = 'close' - this.props.refreshdata(item, 'success', '') - } - } - - /** - * @description 鎸夐挳鎻愪氦鎵ц - */ - execSubmit = (btn, data, _resolve, formdata) => { - const { setting, primaryId } = this.props - - let _primaryId = primaryId - - if (btn.intertype === 'inner') { - let param = { // 绯荤粺瀛樺偍杩囩▼ - func: btn.innerFunc, - BID: '' - } - - 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] - - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(btn, res, _primaryId, formdata) - } else { - this.execError(res, btn) - } - _resolve() - }) - } else if (btn.intertype === 'system') { - // 浣跨敤绯荤粺鎺ュ彛鏃讹紝鏁版嵁婧愪笉鍙负绌�, 浣跨敤绯荤粺鍑芥暟鏃讹紝绫诲瀷涓嶅彲涓虹┖ - if (!btn.sql || !btn.sqlType) { - this.actionSettingError() - _resolve() - return - } - - // 鍒涘缓鍑瘉鏃讹紝闇�瑕侀�夋嫨琛屾椂 - if (!data && btn.verify && btn.verify.voucher && btn.verify.voucher.enabled) { - notification.warning({ - top: 92, - message: '浣跨敤鍒涘缓鍑瘉鍑芥暟锛岄渶瑕侀�夋嫨琛岋紒', - duration: 5 - }) - return - } - - let param = { // 绯荤粺瀛樺偍杩囩▼ - func: 'sPC_TableData_InUpDe', - exec_type: 'y', // 鍚庡彴瑙g爜 - BID: '' - } - - if (btn.sql && btn.sqlType === 'insert') { // 绯荤粺鍑芥暟娣诲姞鏃讹紝鐢熸垚uuid - param.ID = Utils.getguid() - param.LText = getSysDefaultSql(btn, setting, formdata, param, data, []) // 鏁版嵁婧� - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt('', param.timestamp) - param.LText = Utils.formatOptions(param.LText) - - _primaryId = param.ID - } else if (btn.sql && btn.sqlType === 'insertOrUpdate') { // 绯荤粺鍑芥暟娣诲姞鎴栦慨鏀规椂 - param.ID = primaryId || Utils.getguid() - param.LText = getSysDefaultSql(btn, setting, formdata, param, data, []) // 鏁版嵁婧� - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt('', param.timestamp) - param.LText = Utils.formatOptions(param.LText) - - _primaryId = param.ID - } else if (btn.sql) { - param.ID = primaryId - param.LText = getSysDefaultSql(btn, setting, formdata, param, data, []) // 鏁版嵁婧� - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt('', param.timestamp) - param.LText = Utils.formatOptions(param.LText) - } - - if (window.GLOB.mkHS && param.timestamp) { // 浜戠楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - Api.genericInterface(param).then((res) => { - if (res.status) { - this.execSuccess(btn, res, _primaryId, formdata) - } else { - this.execError(res, btn) - } - _resolve() - }) - } else if (btn.intertype === 'outer') { - /** *********************璋冪敤澶栭儴鎺ュ彛************************* */ - - if (!btn.interface) { // 鎺ュ彛鍦板潃涓嶅瓨鍦ㄦ椂鎶ラ敊 - this.actionSettingError() - _resolve() - return - } - - let param = { - BID: '' - } - - 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 (window.GLOB.mkHS) { - if (btn.sysInterface === 'true' && options.cloudServiceApi) { - res.rduri = options.cloudServiceApi - res.userid = sessionStorage.getItem('CloudUserID') || '' - res.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - } else { - if (btn.sysInterface === 'true' && window.GLOB.mainSystemApi) { - res.rduri = window.GLOB.mainSystemApi - } else if (btn.sysInterface !== 'true') { - res.rduri = btn.interface - } - } - - if (btn.outerFunc) { - res.func = btn.outerFunc - } - - return Api.genericInterface(res) - }).then(response => { - if (!response) return - // 鍥炶皟璇锋眰 - if (btn.callbackFunc) { - // 瀛樺湪鍥炶皟鍑芥暟鏃讹紝璋冪敤 - delete response.message - delete response.status - - response.func = btn.callbackFunc - - let _callbackparam = {..._outParam, ...response} - return Api.genericInterface(_callbackparam) - } else { - if (response.status) { - this.execSuccess(btn, response, _primaryId, formdata) - _resolve() - } else { - this.execError(response, btn) - _resolve() - } - } - }).then(res => { - if (!res) return - - if (res.status) { - this.execSuccess(btn, res, _primaryId, formdata) - _resolve() - } else { - this.execError(res, btn) - _resolve() - } - }) - - } else { - this.actionSettingError() - _resolve() - return - } - } - - /** - * @description 鎿嶄綔鎴愬姛鍚庡鐞� - * 1銆乪xcel瀵煎嚭锛屾垚鍔熷悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� - * 2銆佺姸鎬佺爜涓� S 鏃讹紝鏄剧ず鎴愬姛淇℃伅鍚庣郴缁熼粯璁や俊鎭� - * 3銆佺姸鎬佺爜涓� -1 鏃讹紝涓嶆樉绀轰换浣曚俊鎭� - * 4銆佹ā鎬佹鎵ц鎴愬姛鍚庢槸鍚﹀叧闂� - * 5銆侀�氱煡涓诲垪琛ㄥ埛鏂� - */ - execSuccess = (btn, res, primaryId, formdata) => { - if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛 - notification.success({ - top: 92, - message: res.ErrMesg || this.props.dict['main.action.confirm.success'], - duration: 2 - }) - } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず - - } - - this.props.refreshdata(btn, 'success', primaryId, formdata) - } - - /** - * @description 鎿嶄綔澶辫触鍚庡鐞� - * 1銆佺姸鎬佺爜涓� E銆丯銆丗銆丯M 鏃讹紝鏄剧ず鐩稿簲鎻愮ず淇℃伅 - * 2銆乪xcel瀵煎嚭锛屽け璐ュ悗鍙栨秷瀵煎嚭鎸夐挳鍔犺浇涓姸鎬� - * 3銆侀�氱煡涓诲垪琛ㄥ埛鏂� - */ - execError = (res, btn) => { - if (res.ErrCode === 'E') { - Modal.error({ - title: res.message || res.ErrMesg, - }) - } else if (res.ErrCode === 'N') { - notification.error({ - top: 92, - message: res.message || res.ErrMesg, - duration: 10 - }) - } else if (res.ErrCode === 'F') { - notification.error({ - className: 'notification-custom-error', - top: 92, - message: res.message || res.ErrMesg, - duration: 10 - }) - } else if (res.ErrCode === 'NM') { - message.error(res.message || res.ErrMesg) - } - - this.props.refreshdata(btn, 'error') - } - - /** - * @description 鎸夐挳閰嶇疆淇℃伅閿欒鎻愮ず - */ - actionSettingError = () => { - notification.warning({ - top: 92, - message: '鎸夐挳璁剧疆閿欒锛�', - duration: 5 - }) - } - - - render() { - const { loadingUuid } = this.state - - return ( - <div className="button-list formtab-button"> - {this.props.actions.map((item, index) => { - if (loadingUuid === item.uuid) { - return ( - <Button - className={'mk-btn mk-' + item.class} - icon={item.icon} - key={'action' + index} - onClick={() => {this.actionTrigger(item)}} - loading - >{item.label}</Button> - ) - } else { - return ( - <Button - className={'mk-btn mk-' + item.class} - icon={item.icon} - key={'action' + index} - onClick={() => {this.actionTrigger(item)}} - >{item.label}</Button> - ) - } - })} - </div> - ) - } -} - -export default MainAction \ No newline at end of file diff --git a/src/tabviews/formtab/actionList/index.scss b/src/tabviews/formtab/actionList/index.scss deleted file mode 100644 index 3a6a441..0000000 --- a/src/tabviews/formtab/actionList/index.scss +++ /dev/null @@ -1,19 +0,0 @@ -.button-list.formtab-button { - padding: 20px 20px 10px; - background: #ffffff; - text-align: center; - button { - min-width: 70px; - margin-right: 20px; - margin-bottom: 10px; - height: 35px; - font-size: 15px; - padding: 5px 20px; - } - .ant-spin { - position: fixed; - z-index: 1010; - left: calc(50vw - 22px); - top: calc(50vh - 70px); - } -} diff --git a/src/tabviews/formtab/formgroup/index.jsx b/src/tabviews/formtab/formgroup/index.jsx deleted file mode 100644 index 53e2d67..0000000 --- a/src/tabviews/formtab/formgroup/index.jsx +++ /dev/null @@ -1,725 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification, Collapse } from 'antd' -import moment from 'moment' -import { formRule } from '@/utils/option.js' -import FileUpload from '@/tabviews/zshare/fileupload' -import './index.scss' - -const {MonthPicker} = DatePicker -const { TextArea } = Input -const { Panel } = Collapse - -class MainSearch extends Component { - static propTpyes = { - setting: PropTypes.object, // 鍩烘湰淇℃伅 - groups: PropTypes.array, // 琛ㄥ崟缁� - dict: PropTypes.object, // 瀛楀吀椤� - data: PropTypes.any, // 琛ㄦ牸鏁版嵁 - configMap: PropTypes.object, // 鎸夐挳鍙婁笅鎷夎〃鍗曢厤缃俊鎭泦 - inputSubmit: PropTypes.func // input鍥炶溅鎻愪氦 - } - - state = { - datatype: null, - readtype: null, - readin: null, - fieldlen: null, - groups: null, - formlist: [], - encrypts: [], // 鍔犲瘑瀛楁 - intercepts: [], // 鎴彇瀛楁 - record: {} - } - - UNSAFE_componentWillReceiveProps (nextProps) { - const { datatype, encrypts } = this.state - if (nextProps.data && !is(fromJS(this.props.data), fromJS(nextProps.data))) { - - let _fieldsvalue = {} - let _record = {} - Object.keys(nextProps.data).forEach(key => { - if (this.props.form.getFieldValue(key) !== undefined) { - if (datatype[key] === 'multiselect') { - let _val = nextProps.data[key] ? nextProps.data[key].split(',').filter(Boolean) : [] - _fieldsvalue[key] = _val - } else if (datatype[key] === 'date') { - let _val = nextProps.data[key] ? nextProps.data[key] : null - - if (_val) { - _val = moment(_val, 'YYYY-MM-DD') - } - - _fieldsvalue[key] = _val - } else if (datatype[key] === 'datemonth') { - let _val = nextProps.data[key] ? nextProps.data[key] : null - - if (_val) { - _val = moment(_val, 'YYYY-MM') - } - - _fieldsvalue[key] = _val - } else if (datatype[key] === 'datetime') { - let _val = nextProps.data[key] ? nextProps.data[key] : null - - if (_val) { - _val = moment(_val, 'YYYY-MM-DD HH:mm:ss') - } - - _fieldsvalue[key] = _val - } else if (datatype[key] === 'fileupload') { - let _val = nextProps.data[key] ? nextProps.data[key] : '' - - _fieldsvalue[key] = _val - } else if (datatype[key] === 'text' || datatype[key] === 'textarea') { - let _value = nextProps.data[key] - if (encrypts.includes(key)) { // 鍔犲瘑瀛楁 - try { - _value = window.btoa(window.encodeURIComponent(_value)) - } catch (e) { - console.warn(e) - } - } - - _fieldsvalue[key] = _value - } else { - _fieldsvalue[key] = nextProps.data[key] - } - } else { - let _value = nextProps.data[key] - if (encrypts.includes(key)) { // 鍔犲瘑瀛楁 - try { - _value = window.btoa(window.encodeURIComponent(_value)) - } catch (e) { - console.warn(e) - } - } - - _record[key] = _value - } - }) - - if (Object.keys(_fieldsvalue).length > 0) { - this.props.form.setFieldsValue(_fieldsvalue) - } - - this.setState({ - record: _record - }) - } - } - - UNSAFE_componentWillMount () { - const { data, groups } = this.props - - let datatype = {} - let readtype = {} - let readin = {} - let fieldlen = {} - let _formlist = [] - let encrypts = [] - let intercepts = [] - - let _groups = groups.map(group => { - group.sublist = group.sublist.map(item => { - let _readin = item.readin !== 'false' - if (item.type === 'funcvar') { - _readin = false - item.initval = '' // 鍒濆鍖栦负绌� - } - - if (item.type === 'textarea' && item.encryption === 'true') { - encrypts.push(item.field) - } - if (item.interception !== 'false') { - intercepts.push(item.field) - } - - item.initVal = item.initval ? JSON.parse(JSON.stringify(item.initval)) : '' - - let _fieldlen = item.fieldlength || 50 - if (item.type === 'textarea' || item.type === 'fileupload' || item.type === 'multiselect') { - _fieldlen = item.fieldlength || 512 - } else if (item.type === 'number') { - _fieldlen = item.decimal ? item.decimal : 0 - } - - datatype[item.field] = item.type - readtype[item.field] = item.readonly === 'true' - readin[item.field] = _readin - fieldlen[item.field] = _fieldlen - - if (_readin && !/^date/.test(item.type) && data && data.hasOwnProperty(item.field)) { - let newval = data[item.field] - - if (encrypts.includes(item.field) && newval) { - try { - newval = window.decodeURIComponent(window.atob(newval)) - } catch (e) { - console.warn(e) - } - } - - item.initval = newval - } - - if (item.supvalue) { - item.supvalue = item.supvalue.split(',') - } - - _formlist.push(item) - - return item - }) - - return group - }) - - _groups = _groups.map(group => { - group.sublist = group.sublist.map(item => { - if (item.type === 'link') { - let supItem = _formlist.filter(form => form.field === item.linkField)[0] - - // 鍏宠仈鏄剧ず鍒椾腑鐨勫瓧娈靛�硷紝閫氳繃璇ュ�艰繃婊や笅鎷夐�夐」 - if (!supItem && data && data.hasOwnProperty(item.linkField)) { - supItem = {initval: data[item.linkField]} - } - - if (!supItem) { - notification.warning({ - top: 92, - message: '鏈煡璇㈠埌琛ㄥ崟銆�' + item.label + '銆嬪叧鑱斿瓧娈碉紒', - duration: 5 - }) - } else { - item.options = item.oriOptions.filter(option => option.ParentID === supItem.initval) - } - } - return item - }) - - return group - }) - - this.setState({ - readtype: readtype, - datatype: datatype, - readin: readin, - fieldlen: fieldlen, - formlist: _formlist, - groups: _groups - }) - } - - resetform = (groups, supfields, index, fieldsvalue) => { - index++ - let subfields = [] - - supfields.forEach(supfield => { - groups = groups.map(group => { - group.sublist = group.sublist.map(item => { - if (item.type === 'link' && item.linkField === supfield.field) { - item.options = item.oriOptions.filter(option => option.ParentID === supfield.initval) - item.initval = item.options[0] ? item.options[0].Value : '' - - fieldsvalue[item.field] = item.initval - - subfields.push(item) - } - - return item - }) - return group - }) - }) - - if (subfields.length === 0 || index > 6) { - return {groups: groups, fieldsvalue: fieldsvalue} - } else { - return this.resetform(groups, subfields, index, fieldsvalue) - } - } - - selectChange = (_field, value, option) => { - const { record } = this.state - let groups = JSON.parse(JSON.stringify(this.state.groups)) - - let subfields = [] - let fieldsvalue = {} - let _record = {} - groups = groups.map(group => { - group.sublist = group.sublist.map(item => { - if (item.type === 'link' && item.linkField === _field.field) { - item.options = item.oriOptions.filter(option => option.ParentID === value) - item.initval = item.options[0] ? item.options[0].Value : '' - - fieldsvalue[item.field] = item.initval - - subfields.push(item) - } - return item - }) - return group - }) - - // 琛ㄥ崟鍒囨崲鏃讹紝鏇存柊鍏宠仈瀛楁 - if (_field.type === 'select' && _field.linkSubField && _field.linkSubField.length > 0 && option.props.data) { - let _data = option.props.data - _field.linkSubField.forEach(subfield => { - if (this.props.form.getFieldValue(subfield) !== undefined) { - fieldsvalue[subfield] = _data[subfield] - } else { - _record[subfield] = _data[subfield] - } - }) - } - - if (subfields.length === 0) { - if (Object.keys(fieldsvalue).length > 0) { - this.props.form.setFieldsValue(fieldsvalue) - } - if (Object.keys(_record).length > 0) { - this.setState({ - record: {...record, ..._record} - }) - } - } else { - let result = this.resetform(groups, subfields, 0, fieldsvalue) - - if (Object.keys(result.fieldsvalue).length > 0) { - this.props.form.setFieldsValue(fieldsvalue) - } - - let _param = { - groups: result.groups - } - - if (Object.keys(_record).length > 0) { - _param.record = {...record, ..._record} - } - - this.setState(_param) - } - } - - getFields(formlist) { - const { getFieldDecorator } = this.props.form - - const fields = [] - let cols = 2 - if (this.props.setting && this.props.setting.cols) { - cols = parseInt(this.props.setting.cols) - if (cols > 4 || cols < 1) { - cols = 2 - } - } - - formlist.forEach((item, index) => { - if (item.hidden === 'true') return - - if (item.supField && !item.supvalue.includes(this.props.form.getFieldValue(item.supField))) return - - if (item.type === 'text') { - fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: item.initval || '', - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.input'] + item.label + '!' - }, - { - max: formRule.input.max, - message: formRule.input.message - } - ] - })(<Input placeholder="" autoComplete="off" disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'number') { // 鏁板瓧 - let min = (item.min || item.min === 0) ? item.min : -Infinity - let max = (item.max || item.max === 0) ? item.max : Infinity - let _initval = item.initval - let precision = (item.decimal || item.decimal === 0) ? item.decimal : null - - fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: _initval, - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })( - precision === null ? - <InputNumber min={min} max={max} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> : - <InputNumber min={min} max={max} precision={precision} disabled={item.readonly === 'true'} onPressEnter={this.handleSubmit} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'select' || item.type === 'link') { // 涓嬫媺鎼滅储 - let hasSubField = false - if (item.linkSubField && item.linkSubField.length > 0) { // 瀛樺湪鍏宠仈瀛楁锛屾暟鎹瓨鍌� - hasSubField = true - } - - fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={(value, option) => {this.selectChange(item, value, option)}} - disabled={item.readonly === 'true'} - > - {item.options.map(option => - <Select.Option id={option.key} data={hasSubField ? option : ''} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'multiselect') { // 澶氶�� - let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] - fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: _initval, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - mode="multiple" - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - disabled={item.readonly === 'true'} - > - {item.options.map(option => - <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'date') { // 鏃堕棿鎼滅储 - let _initval = this.props.data ? this.props.data[item.field] : '' - 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}> - {getFieldDecorator(item.field, { - initialValue: _initval, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <DatePicker disabled={item.readonly === 'true'} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datemonth') { - let _initval = this.props.data ? this.props.data[item.field] : '' - 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}> - {getFieldDecorator(item.field, { - initialValue: _initval, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <MonthPicker disabled={item.readonly === 'true'} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datetime') { - let _initval = this.props.data ? this.props.data[item.field] : '' - - 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}> - {getFieldDecorator(item.field, { - initialValue: _initval, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <DatePicker showTime disabled={item.readonly === 'true'} /> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'fileupload') { - fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: item.initval, - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <FileUpload config={item}/> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'funcvar') { - fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.field, { - initialValue: '绯荤粺鑷姩鐢熸垚', - })(<Input placeholder="" autoComplete="off" disabled={true} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'textarea') { - let _labelcol = cols !== 3 ? 8 / cols : 3 - let _wrapcol = cols !== 3 ? 16 + (cols - 1) * 4 : 21 - let _style = {} - if (cols === 2 || cols === 4) { - _style.paddingLeft = '7px' - } - fields.push( - <Col span={24} key={index} className="textarea-row" style={{..._style}}> - <Form.Item label={item.label} labelCol={{xs: { span: 24 }, sm: { span: _labelcol }}} wrapperCol={ {xs: { span: 24 }, sm: { span: _wrapcol }} }> - {getFieldDecorator(item.field, { - initialValue: item.initval || '', - rules: [ - { - required: item.required === 'true', - message: this.props.dict['form.required.input'] + item.label + '!' - }, - { - max: formRule.textarea.max, - message: formRule.textarea.message - } - ] - })(<TextArea autoSize={{ minRows: 2, maxRows: item.maxRows || 6 }} disabled={item.readonly === 'true'} />)} - </Form.Item> - </Col> - ) - } - }) - - return fields - } - - handleConfirm = () => { - const { record, encrypts, intercepts } = this.state - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - let search = [] - // 闅愯棌琛ㄥ崟 - this.state.formlist.forEach(item => { - if (!item.field) return - - if (item.type === 'funcvar') { - let _val = item.initval - if (values.hasOwnProperty(item.field)) { - _val = values[item.field] === '绯荤粺鑷姩鐢熸垚' ? '' : values[item.field] - } else if (record.hasOwnProperty(item.field)) { - _val = record[item.field] - } - search.push({ - type: 'funcvar', - readonly: 'true', - readin: false, - fieldlen: this.state.fieldlen[item.field], - key: item.field, - value: _val - }) - } else if (item.hidden === 'true' && item.field !== this.props.setting.primaryKey) { - let _val = item.initval - if (record.hasOwnProperty(item.field)) { - _val = record[item.field] - } - - 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 - }) - } else if (item.supField && !item.supvalue.includes(this.props.form.getFieldValue(item.supField))) { - 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: item.initVal - }) - } - }) - - Object.keys(values).forEach(key => { - if (this.state.datatype[key] === 'funcvar') return - - let _value = '' - if (this.state.datatype[key] === 'datetime') { - if (values[key]) { - _value = moment(values[key]).format('YYYY-MM-DD HH:mm:ss') - } - } else if (this.state.datatype[key] === 'datemonth') { - if (values[key]) { - _value = moment(values[key]).format('YYYY-MM') - } - } else if (this.state.datatype[key] === 'date') { - if (values[key]) { - _value = moment(values[key]).format('YYYY-MM-DD') - } - } else if (this.state.datatype[key] === 'number') { - _value = values[key] - - } else if (this.state.datatype[key] === 'multiselect') { - _value = values[key] ? values[key].join(',') : '' - - } else if (this.state.datatype[key] === 'fileupload') { - _value = values[key] - - } else if (this.state.datatype[key] === 'text' || this.state.datatype[key] === 'textarea') { - _value = values[key].replace(/\t*|\v*/g, '') // 鍘婚櫎鍒惰〃绗� - - if (intercepts.includes(key)) { // 鍘婚櫎棣栧熬绌烘牸 - _value = _value.replace(/(^\s*|\s*$)/g, '') - } - } else { - _value = values[key] - - } - - search.push({ - type: this.state.datatype[key], - readonly: this.state.readtype[key], - readin: this.state.readin[key], - fieldlen: this.state.fieldlen[key], - key: key, - value: _value - }) - }) - - if (encrypts && encrypts.length > 0) { - search = search.map(item => { - let _value = item.value - if (encrypts.includes(item.key)) { - try { - _value = window.btoa(window.encodeURIComponent(_value)) - } catch (e) { - console.warn(e) - } - } - item.value = _value - - return item - }) - } - resolve(search) - } else { - reject(err) - } - }) - }) - } - - handleSubmit = (e) => { - e.preventDefault() - this.props.inputSubmit() - } - - render() { - const { setting } = this.props - const { groups } = this.state - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - let _width = (setting && setting.width) || 100 - - let keys = groups.map(group => group.uuid) - - return ( - <Form {...formItemLayout} className="form-tab-form-field"> - <Collapse - defaultActiveKey={keys} - expandIconPosition='right' - > - {groups.map(group => - <Panel header={group.label} key={group.uuid}> - <Row style={{margin: '0 auto', width: _width + '%'}} gutter={24}>{this.getFields(group.sublist)}</Row> - </Panel> - )} - </Collapse> - </Form> - ) - } -} - -export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/tabviews/formtab/formgroup/index.scss b/src/tabviews/formtab/formgroup/index.scss deleted file mode 100644 index 1d63657..0000000 --- a/src/tabviews/formtab/formgroup/index.scss +++ /dev/null @@ -1,47 +0,0 @@ -.form-tab-form-field { - position: relative; - padding: 0px; - .ant-form-item { - display: flex; - } - .ant-form-item-control-wrapper { - flex: 1; - } - .ant-form-item-label { - overflow: hidden; - display: inline-block; - text-overflow: ellipsis; - white-space: nowrap; - } - .textarea-row { - .ant-col-sm-3 { - width: 10.5%; - } - .ant-col-sm-21 { - width: 89.5%; - } - } - .ant-form-explain { - overflow:hidden; - text-overflow:ellipsis; - white-space:nowrap; - } - p { - color: #1890ff; - border-bottom: 1px solid #d9d9d9; - } - .ant-input-disabled { - color: rgba(0, 0, 0, 0.65)!important; - cursor: default!important; - } - .ant-input-number-input { - color: rgba(0, 0, 0, 0.65)!important; - cursor: default!important; - } - .ant-select-disabled { - color: rgba(0, 0, 0, 0.65)!important; - .ant-select-selection--multiple .ant-select-selection__choice { - color: rgba(0, 0, 0, 0.65)!important; - } - } -} \ No newline at end of file diff --git a/src/tabviews/formtab/index.jsx b/src/tabviews/formtab/index.jsx deleted file mode 100644 index dcc0d1d..0000000 --- a/src/tabviews/formtab/index.jsx +++ /dev/null @@ -1,663 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { notification, Spin, Tabs} from 'antd' -import moment from 'moment' - -import Api from '@/api' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' -import Utils from '@/utils/utils.js' -import options from '@/store/options.js' -import asyncComponent from '@/utils/asyncLoadComponent' -import MKEmitter from '@/utils/events.js' -import MkIcon from '@/components/mk-icon' -import FormGroup from './formgroup' -import FormAction from './actionList' -import NotFount from '@/components/404' -import './index.scss' - -const { TabPane } = Tabs -const SubTable = asyncComponent(() => import('@/tabviews/subtable')) -const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage')) - -class NormalTable extends Component { - static propTpyes = { - MenuID: PropTypes.string, // 鑿滃崟Id - param: PropTypes.any, // 涓昏〃浼犻�掑弬鏁� - } - - state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, - ContainerId: Utils.getuuid(), // 鑿滃崟澶栧眰html Id - loadingview: true, // 椤甸潰鍔犺浇涓� - viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 - lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 - config: {}, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷寜閽�佽〃鍗曘�佹爣绛剧瓑 - groups: null, // 琛ㄥ崟缁� - actions: null, // 鎸夐挳闆� - arr_field: '', // 鏌ヨ瀛楁闆� - setting: null, // 椤甸潰鍏ㄥ眬璁剧疆锛氭暟鎹簮銆佹寜閽強鏄剧ず鍒楀浐瀹氥�佷富閿瓑 - data: null, // 鍒楄〃鏁版嵁闆� - BIDs: {}, // 涓婄骇琛╥d - primaryId: null, - } - - /** - * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 - */ - async loadconfig () { - const { MenuID } = this.props - - let param = { - func: 'sPC_Get_LongParam', - MenuID: MenuID - } - let result = await Api.getCacheConfig(param) - if (result.status) { - let config = '' - - try { // 閰嶇疆淇℃伅瑙f瀽 - config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - } catch (e) { - console.warn('Parse Failure') - config = '' - } - - // 椤甸潰閰嶇疆瑙f瀽閿欒鏃舵彁绀� - if (!config) { - this.setState({ - loadingview: false, - viewlost: true - }) - return - } - - // 椤甸潰鏈惎鐢ㄦ椂锛屾樉绀烘湭鍚敤椤甸潰 - if (!config.enabled) { - this.setState({ - loadingview: false, - viewlost: true, - lostmsg: this.state.dict['main.view.unenabled'] - }) - return - } - - // 鍏煎鏍囩 - if (!config.tabgroups) { - config.tabgroups = [{ uuid: 'tabs', sublist: [] }] - } else if (typeof(config.tabgroups[0]) === 'string') { - let _tabgroups = [] - config.tabgroups.forEach(groupId => { - let _group = { - uuid: groupId, - sublist: fromJS(config[groupId]).toJS() - } - - delete config[groupId] - - _tabgroups.push(_group) - }) - - config.tabgroups = _tabgroups - } - - config.tabgroups.forEach(group => { - group.sublist = group.sublist.map(tab => { - if (tab.supMenu === 'mainTable') { - tab.supMenu = MenuID - } - tab.ContainerId = this.state.ContainerId - return tab - }) - }) - - // 鎸夐挳绫诲瀷鍏煎 - config.action = config.action.map(item => { - if (item.intertype === 'inner' && !item.innerFunc) { - item.intertype = 'system' - } - return item - }) - - let _arrField = [config.setting.primaryKey] // 瀛楁闆� , 榛樿娣诲姞涓婚敭 - let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID - - config.groups.forEach(group => { - group.sublist = group.sublist.filter(item => { - item.field && _arrField.push(item.field) - if (!item.blacklist || item.blacklist.length === 0) { - return true - } - return item.blacklist.filter(v => roleId.indexOf(v) > -1).length === 0 - }) - }) - _arrField = _arrField.join(',') - - this.setState({ - config: config, - setting: config.setting, - actions: config.action, - arr_field: _arrField, - primaryId: this.props.param.primaryId || '', - data: this.props.param.data || null, - BIDs: { - [MenuID]: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '', - [MenuID + 'data']: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : '' - } - }, () => { - this.improveSelectOption(config.groups) - - if (config.setting.datatype === 'query' && config.setting.onload !== 'false') { - this.loadmaindata() - } else if (config.setting.datatype !== 'query' && (!this.props.param.primaryId || !this.props.param.data)) { - notification.warning({ - top: 92, - message: '鏈幏鍙栧埌涓昏〃鏁版嵁锛�', - duration: 5 - }) - } - }) - } else { - this.setState({ - loadingview: false, - viewlost: true - }) - notification.warning({ - top: 92, - message: result.message, - duration: 5 - }) - } - } - - /** - * @description 琛ㄥ崟涓嬫媺閫夐」鍔犺浇 - */ - improveSelectOption = (groups) => { - let deffers = [] - groups.forEach(group => { - group.sublist = group.sublist.map(item => { - if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return item - - if (item.setAll === 'true') { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: '鍏ㄩ儴' - }) - } - - if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - let _sql = Utils.formatOptions(_option.sql) - - let param = { - func: 'sPC_Get_SelectedList', - LText: _sql, - obj_name: 'data', - arr_field: _option.field - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - - if (item.database === 'sso' && options.cloudServiceApi) { // 瀛樺湪浜戠鍦板潃鏃讹紝浣跨敤浜戠绯荤粺鍙傛暟 - param.rduri = options.cloudServiceApi - param.userid = sessionStorage.getItem('CloudUserID') || '' - param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } - } else if (item.database === 'sso' && window.GLOB.mainSystemApi && window.GLOB.systemType === 'production') { - param.rduri = window.GLOB.mainSystemApi - } - - let defer = new Promise(resolve => { - Api.getSystemCacheConfig(param).then(res => { - res.search = item - resolve(res) - }) - }) - deffers.push(defer) - } else if (item.resourceType === '1' && !item.dataSource) { - notification.warning({ - top: 92, - message: item.label + ': 鏁版嵁婧愰厤缃敊璇紒', - duration: 5 - }) - } - - return item - }) - }) - - if (deffers.length === 0) { - this.setState({ - loadingview: false, - groups: groups - }) - return - } - - Promise.all(deffers).then(result => { - let _result = {} - result.forEach(res => { - if (res.status) { - let _options = res.data.map(cell => { - let _item = { - key: Utils.getuuid(), - Value: cell[res.search.valueField], - Text: cell[res.search.valueText] - } - - if (res.search.type === 'link') { - _item.ParentID = cell[res.search.linkField] - } else if (res.search.type === 'select' && res.search.linkSubField && res.search.linkSubField.length > 0) { - res.search.linkSubField.forEach(_field => { - _item[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' - }) - } - - return _item - }) - - _result[res.search.uuid] = _options - } else { - notification.warning({ - top: 92, - message: res.search.label + ':' + res.message, - duration: 5 - }) - } - }) - - groups.forEach(group => { - group.sublist = group.sublist.map(item => { - if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') { - if (_result[item.uuid]) { - item.options = [...item.options, ..._result[item.uuid]] - } - item.oriOptions = JSON.parse(JSON.stringify(item.options)) - } - - return item - }) - }) - - this.setState({ - loadingview: false, - groups: groups - }) - }) - } - - /** - * @description 涓昏〃鏁版嵁鍔犺浇 - */ - async loadmaindata () { - const { setting, BIDs, config } = this.state - - if (setting.datatype !== 'query') { - notification.warning({ - top: 92, - message: '鏈缃暟鎹煡璇㈤厤缃紒', - duration: 5 - }) - return - } - - let param = null - - if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) { - param = this.getCustomParam() - } else { - param = this.getDefaultParam() - } - - if (!param) return // 鏈幏鍙栧弬鏁版椂锛屼笉鍙戣姹� - - // 鏁版嵁绠$悊鏉冮檺 - if (sessionStorage.getItem('dataM') === 'true') { - param.dataM = 'Y' - } - - let result = await Api.genericInterface(param) - if (result.status) { - let _data = result.data[0] || '' - let _primaryId = '' - - if (_data) { - _primaryId = _data[setting.primaryKey] || '' - } else { - notification.warning({ - top: 92, - message: '鏈煡璇㈠埌鏁版嵁淇℃伅锛�', - duration: 5 - }) - } - - this.setState({ - data: _data, - primaryId: _primaryId, - BIDs: { ...BIDs, [this.props.MenuID]: _primaryId, [this.props.MenuID + 'data']: _data } - }) - - if (_data && (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc))) { - let keys = Object.keys(_data) - let emptys = [] - - if (!keys.includes(config.setting.primaryKey)) { - emptys.push(config.setting.primaryKey) - } - - config.groups.forEach(group => { - group.sublist.forEach(item => { - if (!keys.includes(item.field)) { - emptys.push(item.field + '(' + item.label + ')') - } - }) - }) - - if (emptys.length > 0) { - notification.warning({ - top: 92, - message: '鏈煡璇㈠埌' + emptys.join(', ') + '瀛楁淇℃伅锛�', - duration: 5 - }) - } - } - } else { - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) - } - } - - /** - * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼鐨勫弬鏁� - */ - getDefaultParam = () => { - const { arr_field, setting, primaryId } = this.state - - if (!arr_field) { - notification.warning({ - top: 92, - message: '鏈缃〃鍗曞瓧娈碉紒', - duration: 5 - }) - return null - } - - let param = { - func: 'sPC_Get_TableData', - obj_name: 'data', - arr_field: arr_field, - ID: primaryId - } - - let _dataresource = setting.dataresource - - if (/\s/.test(_dataresource)) { - _dataresource = '(' + _dataresource + ') tb' - } - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - _dataresource = _dataresource.replace(/\$@/ig, '/*') - _dataresource = _dataresource.replace(/@\$/ig, '*/') - // param.custom_script = param.custom_script.replace(/\$@/ig, '/*') - // param.custom_script = param.custom_script.replace(/@\$/ig, '*/') - } else { - _dataresource = _dataresource.replace(/@\$|\$@/ig, '') - // param.custom_script = param.custom_script.replace(/@\$|\$@/ig, '') - } - - if (!/@ID@/ig.test(_dataresource)) { - _dataresource = `${_dataresource} where ${setting.primaryKey}='${primaryId}'` - } - - let LText = `select ${arr_field} from ${_dataresource}` - - param.LText = Utils.formatOptions(LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - param.DateCount = '' - - if (window.GLOB.probation) { - param.s_debug_type = 'Y' - } - - if (!window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) - } - - return param - } - - /** - * @description 鑾峰彇鐢ㄦ埛鑷畾涔夊瓨鍌ㄨ繃绋嬩紶鍙� - */ - getCustomParam = () => { - const { setting, primaryId } = this.state - - let param = {} - - if (setting.interType === 'inner') { - param.func = setting.innerFunc - } else { - if (window.GLOB.mkHS) { - if (setting.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi - param.userid = sessionStorage.getItem('CloudUserID') || '' - param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } else if (setting.sysInterface !== 'true') { - param.rduri = setting.interface - } - } else { - if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } else if (setting.sysInterface !== 'true') { - param.rduri = setting.interface - } - } - - if (setting.outerFunc) { - param.func = setting.outerFunc - } - } - - param[setting.primaryKey] = primaryId - - return param - } - - /** - * @description 鎸夐挳鎿嶄綔瀹屾垚鍚庯紙鎴愬姛鎴栧け璐ワ級锛岄〉闈㈠埛鏂帮紝閲嶇疆椤电爜鍙婇�夋嫨椤� - */ - refreshbyaction = (btn, type, primaryId, formdata) => { - const { BIDs } = this.state - - if (type === 'success' && btn.afterExecSuccess === 'notclose') { - this.setState({ - primaryId: primaryId - }, () => { - if (btn.execSuccess === 'refresh' || btn.execSuccess === 'grid') { - this.loadmaindata() - } else { - let data = {} - - if (formdata && formdata.length > 0) { - formdata.forEach(item => { - data[item.key] = item.value - }) - } - - this.setState({ - BIDs: { ...BIDs, [this.props.MenuID]: primaryId, [this.props.MenuID + 'data']: data } - }) - } - }) - } else if (type === 'success' && btn.afterExecSuccess === 'close') { - if (btn.execSuccess !== 'never') { - MKEmitter.emit('reloadData', this.props.param.parentId, 'formtab', btn) - } - - MKEmitter.emit('closeTabView', this.props.MenuID) - } else if (type === 'error' && btn.afterExecError === 'notclose') { - if (btn.execError === 'refresh') { - this.loadmaindata() - } - } else if (type === 'error' && btn.afterExecError === 'close') { - if (btn.execError !== 'never') { - MKEmitter.emit('reloadData', this.props.param.parentId, 'formtab', btn) - } - MKEmitter.emit('closeTabView', this.props.MenuID) - } - } - - /** - * @description 鑾峰彇琛ㄥ崟鍙傛暟 - */ - getFormData = () => { - return this.formGroupRef.handleConfirm() - } - - reloadview = () => { - this.setState({ - loadingview: true, - viewlost: false, - lostmsg: '', - config: {}, - groups: null, - actions: null, - setting: null, - data: null, - BIDs: {}, - primaryId: null, - }, () => { - this.loadconfig() - }) - } - - reloadMenuView = (menuId) => { - const { MenuID } = this.props - - if (MenuID !== menuId) return - - this.reloadview() - } - - reloadData = (menuId) => { - const { MenuID } = this.props - - if (MenuID !== menuId) return - - this.loadmaindata() - } - - changeTableLine = (ContainerId, tableId, id, data) => { - if (this.state.ContainerId !== ContainerId) return - - this.setState({ - BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data} - }) - } - - UNSAFE_componentWillMount () { - // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁 - this.loadconfig() - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) - } - - componentDidMount () { - MKEmitter.addListener('reloadData', this.reloadData) - MKEmitter.addListener('reloadMenuView', this.reloadMenuView) - MKEmitter.addListener('changeTableLine', this.changeTableLine) - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 - */ - componentWillUnmount () { - this.setState = () => { - return - } - - MKEmitter.removeListener('reloadData', this.reloadData) - MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) - MKEmitter.removeListener('changeTableLine', this.changeTableLine) - } - - render() { - const { setting, actions, loadingview, viewlost, config, groups, data } = this.state - let hasform = false - - if (groups && (groups.length > 1 || groups[0].sublist.length > 0)) { - hasform = true - } - - return ( - <div className="formtab" id={this.state.ContainerId}> - {loadingview && <Spin size="large" />} - {hasform ? - <FormGroup - dict={this.state.dict} - data={data} - groups={groups} - setting={setting} - wrappedComponentRef={(inst) => this.formGroupRef = inst} - /> : null - } - {hasform ? - <FormAction - setting={setting} - actions={actions} - dict={this.state.dict} - data={this.state.data} - MenuID={this.props.MenuID} - primaryId={this.state.primaryId} - getFormData={this.getFormData} - refreshdata={this.refreshbyaction} - /> : null - } - {!loadingview && !viewlost && config.tabgroups.map(group => { - if (group.sublist.length === 0) return null - - return ( - <Tabs defaultActiveKey="0" key={group.uuid}> - {group.sublist.map((_tab, index) => { - return ( - <TabPane tab={ - <span> - {_tab.icon ? <MkIcon type={_tab.icon} /> : null} - {_tab.label} - </span> - } key={`${index}`}> - <SubTable - Tab={_tab} - MenuID={_tab.linkTab} - SupMenuID={this.props.MenuID} - BID={this.state.BIDs[_tab.supMenu] || ''} - BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} - /> - </TabPane> - ) - })} - </Tabs> - ) - }) - } - {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} - {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} - </div> - ) - } -} - -export default NormalTable \ No newline at end of file diff --git a/src/tabviews/formtab/index.scss b/src/tabviews/formtab/index.scss deleted file mode 100644 index b5c70bb..0000000 --- a/src/tabviews/formtab/index.scss +++ /dev/null @@ -1,112 +0,0 @@ -.formtab { - position: relative; - min-height: calc(100vh - 94px); - padding-top: 16px; - padding-bottom: 80px; - .box404 { - padding-top: 30px; - } - >.ant-form.ant-form-horizontal { - .ant-collapse { - border-radius: 0; - border: 0; - .ant-collapse-header { - cursor: default; - border-radius: 0!important; - background: #1890ff; - color: #ffffff; - padding-left: 30px; - padding-right: 20px; - .anticon { - font-size: 16px; - } - .ant-collapse-extra { - .anticon-edit { - position: absolute; - left: 5px; - top: 2px; - } - } - } - .ant-collapse-item:last-child { - border-radius: 0; - .ant-collapse-content { - border-radius: 0; - } - } - .ant-collapse-content-box { - padding: 16px 30px; - > .ant-row { - .ant-calendar-picker { - min-width: 100px!important; - width: 100%; - } - } - } - } - } - - .ant-modal-mask { - position: absolute; - } - .ant-modal-wrap { - position: absolute; - } - .action-modal .ant-modal { - top: 40px; - max-width: 95%; - .ant-modal-body { - max-height: calc(100vh - 265px); - } - } - > .ant-spin { - position: fixed; - left: calc(50vw - 22px); - top: calc(50vh - 70px); - } - > .ant-tabs { - padding: 0px 20px; - margin-bottom: 20px; - .ant-tabs-tab:not(.ant-tabs-tab-active) { - cursor: pointer; - } - } - > .ant-card { - margin: 0 20px 20px; - > .ant-card-head { - border: 0; - padding: 0; - min-height: 30px; - .ant-card-head-title { - padding: 10px 0 0; - span { - color: #1890ff; - display: inline-block; - padding: 0 10px; - font-size: 15px; - border-bottom: 1px solid #1890ff; - .anticon { - margin-right: 10px; - } - } - } - } - > .ant-card-body { - padding: 0; - } - } - .main-table-box { - position: relative; - .pickchange { - position: absolute; - right: 0px; - top: -25px; - .ant-switch { - z-index: 1; - float: right; - margin-right: 20px; - margin-bottom: 5px; - } - } - } -} diff --git a/src/tabviews/zshare/calendar/index.jsx b/src/tabviews/zshare/calendar/index.jsx deleted file mode 100644 index 19c209a..0000000 --- a/src/tabviews/zshare/calendar/index.jsx +++ /dev/null @@ -1,398 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { Select, Radio, Row, Col, Popover, Badge, Spin } from 'antd' -import moment from 'moment' - -import './index.scss' - -const { Option } = Select - -class Calendar extends Component { - static propTpyes = { - data: PropTypes.any, // 浜嬩欢鏁版嵁 - calendar: PropTypes.any, - changeDate: PropTypes.func, - triggerDate: PropTypes.func, - loading: false - } - - state = { - level: 'day', - levels: null, - yearlist: null, - selectYear: moment().format('YYYY'), - selectMonth: moment().format('MM'), - datelist: null, - monthlist: null - } - - UNSAFE_componentWillMount() { - const { calendar, data } = this.props - - let yearlist = [] - let _selectYear = +this.state.selectYear - yearlist.push(`${_selectYear}`) - - for (let i = 1; i <= 50; i++) { - yearlist.unshift(`${_selectYear - i}`) - yearlist.push(`${_selectYear + i}`) - } - - let datelist = this.getDateList(this.state.selectYear) - - if (data && data.length > 0) { - datelist = this.mountdata(datelist, data) - } - - let _levels = calendar.levels - let level = _levels[0] - let monthlist = null - - if (_levels.includes('month') || _levels.includes('year')) { - monthlist = datelist.filter(item => item.month === moment().format('MM'))[0] - } - - this.setState({ - yearlist, - datelist, - monthlist, - level, - levels: _levels - }) - } - - UNSAFE_componentWillReceiveProps(nextProps) { - if (!is(fromJS(this.props.data), fromJS(nextProps.data))) { - let datelist = this.getDateList(this.state.selectYear) - let monthlist = null - - datelist = this.mountdata(datelist, nextProps.data) - - if (this.state.levels.includes('month') || this.state.levels.includes('year')) { - monthlist = datelist.filter(item => item.month === this.state.selectMonth)[0] - } - - this.setState({ - datelist: datelist, - monthlist - }) - } else if (!is(fromJS(this.props.calendar), fromJS(nextProps.calendar))) { - this.setState({ - levels: nextProps.calendar.levels - }) - } - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.props.loading), fromJS(nextProps.loading)) || !is(fromJS(this.state), fromJS(nextState)) - } - - mountdata = (datelist, data) => { - const { calendar } = this.props - - let datalist = [] - let colors = { - transparent: 'rgba(0, 0, 0, 0)', - red: 'rgba(208, 2, 27, 1)', - orange: 'rgba(245, 166, 35, 1)', - yellow: 'rgba(248, 231, 28, 1)', - green: 'rgba(126, 211, 33, 1)', - cyan: 'rgba(80, 227, 194, 1)', - blue: 'rgba(24, 144, 255, 1)', - purple: 'rgba(189, 16, 224, 1)', - gray: 'rgba(155, 155, 155, 1)' - } - - data && data.forEach(item => { - let startTime = item[calendar.startfield] - let endTime = item[calendar.endfield] - let color = item[calendar.colorfield] || '#ffffff' - - if (!startTime || !/^(1|2)\d{3}(-|\/)\d{2}(-|\/)\d{2}/.test(startTime)) return - if (!endTime || !/^(1|2)\d{3}(-|\/)\d{2}(-|\/)\d{2}/.test(endTime)) return - if (!item[calendar.remarkfield]) return - - let equal = endTime.substr(0, 4) === startTime.substr(0, 4) - - datalist.push({ - color: colors[color] || color, - remark: item[calendar.remarkfield], - startMonth: startTime.substr(0, 4) + startTime.substr(5, 2), - endMonth: endTime.substr(0, 4) + endTime.substr(5, 2), - start: startTime.substr(0, 4) + startTime.substr(5, 2) + startTime.substr(8, 2), - startTime: equal ? `${startTime.substr(5, 2)}-${startTime.substr(8, 2)}` : `${startTime.substr(0, 4)}-${startTime.substr(5, 2)}-${startTime.substr(8, 2)}`, - end: endTime.substr(0, 4) + endTime.substr(5, 2) + endTime.substr(8, 2), - endTime: equal ? `${endTime.substr(5, 2)}-${endTime.substr(8, 2)}` : `${endTime.substr(0, 4)}-${endTime.substr(5, 2)}-${endTime.substr(8, 2)}` - }) - }) - - return datelist.map(month => { - month.subData = [] - datalist.forEach(item => { - if (item.startMonth <= month.time && item.endMonth >= month.time) { - month.subData.push(item) - } - }) - month.style = this.getStyle(month.subData[0]) - month.sublist = month.sublist.map(week => { - week.sublist = week.sublist.map(day => { - if (!day) return null - - day.subData = [] - datalist.forEach(item => { - if (item.start <= day.time && item.end >= day.time) { - day.subData.push(item) - } - }) - day.style = this.getStyle(day.subData[0]) - return day - }) - return week - }) - return month - }) - } - - getStyle = (item ) => { - if (!item || !item.color) return null - let style = {background: item.color} - - if (/rgb/ig.test(item.color)) { - try { - let colors = item.color.match(/\d+/g) - if ((colors[0] * 0.299 + colors[1] * 0.578 + colors[2] * 0.114) * colors[3] < 192) { - style.color = '#ffffff' - } - } catch (e) {} - } - - return style - } - - getDateList = (selectYear) => { - let datelist = [] - let months = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'] - let monthName = { - '01': '涓�鏈�', '02': '浜屾湀', '03': '涓夋湀', '04': '鍥涙湀', '05': '浜旀湀', '06': '鍏湀', - '07': '涓冩湀', '08': '鍏湀', '09': '涔濇湀', '10': '鍗佹湀', '11': '鍗佷竴鏈�', '12': '鍗佷簩鏈�' - } - - months.forEach(month => { - let _weeklist = [{week: 1, sublist: []}] - let _week = moment(`${selectYear}${month}01`, 'YYYYMMDD').weekday() - let end = +moment(`${selectYear}${month}`, 'YYYYMM').endOf('month').format('DD') - - for (let i = 0; i < _week; i++) { - _weeklist[0].sublist.push(null) - } - - for (let i = 1; i <= end; i++) { - let _day = i < 10 ? `0${i}` : `${i}` - - if (_weeklist[_weeklist.length - 1].sublist.length < 7) { - _weeklist[_weeklist.length - 1].sublist.push({day: _day, time: selectYear + month + _day, label: i, subData: []}) - } else { - let _week = {week: _weeklist.length + 1, sublist: [{day: _day, time: selectYear + month + _day, label: i, subData: []}]} - _weeklist.push(_week) - } - } - - let re = 7 - _weeklist.slice(-1)[0].sublist.length - for (let i = 0; i < re; i++) { - _weeklist[_weeklist.length - 1].sublist.push(null) - } - - datelist.push({ - month: month, - time: selectYear + month, - label: monthName[month], - sublist: _weeklist, - subData: [] - }) - }) - - return datelist - } - - levelChange = (e) => { - this.setState({ level: e.target.value }) - } - - yearChange = (value) => { - const { calendar, data } = this.props - const { levels, selectMonth } = this.state - let datelist = this.getDateList(value) - let monthlist = null - - if (levels.includes('month') || levels.includes('year')) { - monthlist = datelist.filter(item => item.month === selectMonth)[0] - } - - if (calendar.refresh !== 'true') { - datelist = this.mountdata(datelist, data) - - this.setState({ selectYear: value, datelist, monthlist }) - } else { - this.setState({ selectYear: value, datelist, monthlist }, () => { - this.props.changeDate(value) - }) - } - } - - monthChange = (value) => { - const { datelist, levels, selectYear } = this.state - - if (!levels.includes('month')) { - if (this.props.triggerDate) { - this.props.triggerDate({ - time: `${selectYear}${value}01` - }) - } - return - } - - this.setState({ - level: 'month', - selectMonth: value, - monthlist: datelist.filter(item => item.month === value)[0] - }) - } - - triggerDay = (item) => { - if (this.props.triggerDate) { - this.props.triggerDate(item) - } - } - - render() { - const { loading } = this.props - const { level, selectMonth, selectYear, yearlist, levels, datelist, monthlist } = this.state - const _levelName = {day: '鏃�', month: '鏈�', year: '骞�'} - - return ( - <div className="mk-calendar"> - {loading ? <div className="loading-data"><Spin /></div> : null} - <div className="mk-calendar-control"> - <Select value={selectYear} onChange={this.yearChange}> - {yearlist.map(item => (<Option key={item} value={item}>{item}骞�</Option>))} - </Select> - {level === 'month' ? <Select value={selectMonth} onChange={this.monthChange}> - <Option value="01">1鏈�</Option> - <Option value="02">2鏈�</Option> - <Option value="03">3鏈�</Option> - <Option value="04">4鏈�</Option> - <Option value="05">5鏈�</Option> - <Option value="06">6鏈�</Option> - <Option value="07">7鏈�</Option> - <Option value="08">8鏈�</Option> - <Option value="09">9鏈�</Option> - <Option value="10">10鏈�</Option> - <Option value="11">11鏈�</Option> - <Option value="12">12鏈�</Option> - </Select> : null} - {levels.length > 1 ? <Radio.Group value={level} onChange={this.levelChange}> - {levels.map(item => (<Radio.Button key={item} value={item}>{_levelName[item]}</Radio.Button>))} - </Radio.Group> : null} - </div> - <div className="mk-calendar-content"> - {level === 'day' ? <Row className="day-calendar" gutter={16}> - {datelist.map(item => ( - <Col span={4} key={item.month}> - <table> - <thead> - <tr> - <th colSpan="7">{item.label}</th> - </tr> - <tr> - <th>涓�</th><th>浜�</th><th>涓�</th><th>鍥�</th><th>浜�</th><th>鍏�</th><th>鏃�</th> - </tr> - </thead> - <tbody> - {item.sublist.map(cell => ( - <tr key={cell.week}> - {cell.sublist.map((d, i) => ( - <td key={i}> - {d ? <div className="day-wrap" style={d.style || null} onClick={() => this.triggerDay(d)}> - {d.subData.length > 0 ? <Popover mouseEnterDelay={0.3} overlayClassName="calendar-day-pop" content={ - <div> - {d.subData.map((data, index) => ( - <div key={index} className="message"> - <Badge color={data.color} text={ - <span> - {data.remark} - <span style={{color: 'rgba(0,0,0,.45)'}}>({data.startTime + ' ~ ' + data.endTime})</span> - </span>} - /> - </div> - ))} - </div> - } trigger="hover"> - {d.label} - </Popover> : d.label} - </div> : null } - </td> - ))} - </tr> - ))} - </tbody> - </table> - </Col> - ))} - </Row> : null} - {level === 'month' && monthlist ? <div className="month-calendar"> - <table> - <thead> - <tr> - <th>涓�</th><th>浜�</th><th>涓�</th><th>鍥�</th><th>浜�</th><th>鍏�</th><th>鏃�</th> - </tr> - </thead> - <tbody> - {monthlist.sublist.map(cell => ( - <tr key={cell.week}> - {cell.sublist.map((d, i) => ( - <td key={i}> - {d ? <div className="month-wrap" style={d.style || null} onClick={() => this.triggerDay(d)}> - <div className="header"> - {d.label} - </div> - <ul className="content"> - {d.subData.map((data, index) => ( - <li key={index} className="message"> - <Badge color={d.style ? (data.color === d.style.background ? '#ffffff' : data.color) : data.color} text={data.remark} /> - </li> - ))} - </ul> - </div> : null } - </td> - ))} - </tr> - ))} - </tbody> - </table> - </div>: null} - {level === 'year' && monthlist ? <Row className="year-calendar"> - {datelist.map(item => ( - <Col span={8} key={item.month}> - <div className="year-wrap" style={item.style || null} onClick={() => this.monthChange(item.month)}> - <div className="header" style={item.style ? null : {color: '#1890ff'}}> - {item.label} - </div> - <ul className="content"> - {item.subData.map((data, index) => ( - <li key={index} className="message"> - <Badge color={item.style ? (data.color === item.style.background ? '#ffffff' : data.color) : data.color} text={`${data.remark} (${data.startTime} ~ ${data.endTime})`}/> - </li> - ))} - </ul> - </div> - </Col> - ))} - </Row>: null} - </div> - </div> - ) - } -} - -export default Calendar \ No newline at end of file diff --git a/src/tabviews/zshare/calendar/index.scss b/src/tabviews/zshare/calendar/index.scss deleted file mode 100644 index 52faea5..0000000 --- a/src/tabviews/zshare/calendar/index.scss +++ /dev/null @@ -1,208 +0,0 @@ -.mk-calendar { - position: relative; - width: 100%; - padding: 20px; - - .loading-data { - position: absolute; - top: 0; - left: 20px; - right: 20px; - bottom: 0; - z-index: 2; - opacity: 0.5; - background: #ffffff; - .ant-spin-spinning { - position: absolute; - left: 50%; - top: 270px; - } - } - .mk-calendar-control { - text-align: right; - .ant-select { - width: 90px; - margin-right: 15px; - } - } - .mk-calendar-content { - margin-top: 10px; - .day-calendar .ant-col { - min-height: 235px; - table { - width: 100%; - thead { - text-align: center; - color: #1890ff; - tr { - height: 30px; - } - tr:first-child { - th { - font-weight: 600; - font-size: 16px; - } - } - } - tbody { - text-align: center; - tr { - height: 28px; - td { - .day-wrap { - cursor: pointer; - transition: background 0.1s; - span { - display: inline-block; - width: 100%; - height: 100%; - } - } - .day-wrap:hover { - background: #bae7ff; - } - } - } - } - } - } - .month-calendar { - table { - width: 100%; - thead { - text-align: center; - color: #1890ff; - font-size: 16px; - tr { - height: 35px; - } - } - tbody { - tr { - td { - position: relative; - width: 14.2%; - .month-wrap { - cursor: pointer; - height: 120px; - width: calc(100% - 2px); - transition: background 0.1s; - margin-bottom: 2px; - box-shadow: 0px 0px 3px #bae7ff; - .header { - text-align: center; - font-size: 16px; - } - .content { - padding: 0 10px 10px; - height: 90px; - overflow-y: auto; - position: absolute; - left: 0; - right: 0; - .message { - width: 100%; - .ant-badge-status-text { - color: inherit; - } - } - } - .content::-webkit-scrollbar { - width: 5px; - } - .content::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.7); - background: rgba(255, 255, 255, 0.7); - } - .content::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } - } - .month-wrap:hover { - background: #e6f7ff; - } - } - } - } - } - } - .year-calendar { - .year-wrap { - width: calc(100% - 2px); - box-shadow: 0px 0px 3px #bae7ff; - cursor: pointer; - transition: background 0.1s; - .header { - text-align: center; - font-size: 16px; - } - .content { - padding: 5px 15px 10px; - height: 110px; - overflow-y: auto; - margin-bottom: 2px; - .ant-badge-status-text { - color: inherit; - } - .message { - width: 100%; - // white-space: nowrap; - overflow: hidden; - margin-bottom: 5px; - text-overflow: ellipsis; - } - } - .content::-webkit-scrollbar { - width: 5px; - } - .content::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.7); - background: rgba(255, 255, 255, 0.7); - } - .content::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } - } - .year-wrap:hover { - background: #e6f7ff; - } - } - } -} -.calendar-day-pop { - .message { - .ant-badge-status-text { - display: inline-block; - min-width: 200px; - max-width: 350px; - vertical-align: middle; - } - } - .ant-popover-inner-content { - min-height: 100px; - max-height: 200px; - overflow-y: auto; - } - .ant-popover-inner-content::-webkit-scrollbar { - width: 5px; - } - .ant-popover-inner-content::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.09); - background: rgba(0, 0, 0, 0.09); - } - .ant-popover-inner-content::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } -} diff --git a/src/templates/calendarconfig/calcomponent/calendarform/index.jsx b/src/templates/calendarconfig/calcomponent/calendarform/index.jsx deleted file mode 100644 index 2d1f32a..0000000 --- a/src/templates/calendarconfig/calcomponent/calendarform/index.jsx +++ /dev/null @@ -1,156 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Select, Checkbox, Tooltip, Radio } from 'antd' -import { QuestionCircleOutlined } from '@ant-design/icons' -// import './index.scss' - -class MainTab extends Component { - static propTpyes = { - config: PropTypes.object, // 椤甸潰閰嶇疆 - calendar: PropTypes.any // 鏃ュ巻閰嶇疆淇℃伅 - } - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - resolve(values) - } else { - reject(err) - } - }) - }) - } - - render() { - const { getFieldDecorator } = this.props.form - const { calendar, config } = this.props - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 10 } - } - } - return ( - <Form {...formItemLayout}> - <Row gutter={24}> - <Col span={24}> - <Form.Item label="寮�濮嬫椂闂�"> - {getFieldDecorator('startfield', { - initialValue: calendar.startfield, - rules: [ - { - required: true, - message: '璇烽�夋嫨寮�濮嬫椂闂�!' - } - ] - })( - <Select> - {config.columns.map(option => - <Select.Option key={option.uuid} value={option.field}>{option.label}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label="缁撴潫鏃堕棿"> - {getFieldDecorator('endfield', { - initialValue: calendar.endfield, - rules: [ - { - required: true, - message: '璇烽�夋嫨缁撴潫鏃堕棿!' - } - ] - })( - <Select> - {config.columns.map(option => - <Select.Option key={option.uuid} value={option.field}>{option.label}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label="淇℃伅瀛楁"> - {getFieldDecorator('remarkfield', { - initialValue: calendar.remarkfield, - rules: [ - { - required: true, - message: '璇烽�夋嫨淇℃伅瀛楁!' - } - ] - })( - <Select> - {config.columns.map(option => - <Select.Option key={option.uuid} value={option.field}>{option.label}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label="棰滆壊瀛楁"> - {getFieldDecorator('colorfield', { - initialValue: calendar.colorfield, - rules: [ - { - required: false, - message: '璇烽�夋嫨棰滆壊瀛楁!' - } - ] - })( - <Select> - {config.columns.map(option => - <Select.Option key={option.uuid} value={option.field}>{option.label}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label="鏃ュ巻绛夌骇"> - {getFieldDecorator('levels', { - initialValue: calendar.levels, - rules: [ - { - required: true, - message: '璇烽�夋嫨鏃ュ巻绛夌骇!' - } - ] - })( - <Checkbox.Group options={[{ value: 'day', label: '鏃�' }, { value: 'month', label: '鏈�' }, { value: 'year', label: '骞�' }]}/> - )} - </Form.Item> - </Col> - <Col span={24}> - <Form.Item label={ - <Tooltip placement="topLeft" title="寮�鍚悗锛屼娇鐢ㄧ郴缁熷嚱鏁版椂浼氳嚜鍔ㄦ浛鎹㈡暟鎹簮鍙婅嚜瀹氫箟鑴氭湰涓殑calendarDate涓巆alendarDate1锛屽叾鍊煎垎鍒负閫夋嫨骞翠唤鐨勫紑濮嬪拰缁撴潫鏃堕棿锛屼娇鐢ㄨ嚜瀹氫箟鍑芥暟鏃讹紝浼氬鍔燾alendarDate浼犲弬锛屽叾鍊间负閫夋嫨骞翠唤銆�"> - <QuestionCircleOutlined className="mk-form-tip" /> - 鏁版嵁鍒锋柊 - </Tooltip> - }> - {getFieldDecorator('refresh', { - initialValue: calendar.refresh || 'false', - })( - <Radio.Group> - <Radio key="true" value="true">寮�鍚�</Radio> - <Radio key="false" value="false">鍏抽棴</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(MainTab) \ No newline at end of file diff --git a/src/templates/calendarconfig/calcomponent/calendarform/index.scss b/src/templates/calendarconfig/calcomponent/calendarform/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/templates/calendarconfig/calcomponent/calendarform/index.scss +++ /dev/null diff --git a/src/templates/calendarconfig/calcomponent/index.jsx b/src/templates/calendarconfig/calcomponent/index.jsx deleted file mode 100644 index 4a475c3..0000000 --- a/src/templates/calendarconfig/calcomponent/index.jsx +++ /dev/null @@ -1,93 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { Modal } from 'antd' -import { EditOutlined } from '@ant-design/icons' - -import CalendarForm from './calendarform' - -import './index.scss' - -class SettingComponent extends Component { - static propTpyes = { - config: PropTypes.any, // 鏍囩 - updateConfig: PropTypes.func, - } - - state = { - calendar: null, // 鏃ュ巻璁剧疆 - visible: false, // 妯℃�佹鎺у埗 - } - - /** - * @description 淇濆瓨椤甸潰閰嶇疆淇℃伅 - */ - calendarSave = () => { - const { config } = this.props - - this.calendarRef.handleConfirm().then(res => { - this.setState({ - visible: false - }) - this.props.updateConfig({...config, calendar: res}) - }) - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 - */ - componentWillUnmount () { - this.setState = () => { - return - } - } - - /** - * @description 娣诲姞鎴栦慨鏀规爣绛� - */ - handleTab = (e) => { - const { config } = this.props - e.stopPropagation() - - let calendar = fromJS(config.calendar).toJS() - - this.setState({ - visible: true, - calendar - }) - } - - render() { - const { config } = this.props - const { visible, calendar } = this.state - - return ( - <div className="model-calendar-setting"> - <EditOutlined onClick={this.handleTab} /> - {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} - <Modal - wrapClassName="model-calendar-setting-modal" - title="鏃ュ巻鍏宠仈瀛楁" - visible={visible} - width={700} - maskClosable={false} - onCancel={() => { this.setState({ visible: false })}} - onOk={this.calendarSave} - destroyOnClose - > - <CalendarForm - config={config} - calendar={calendar} - wrappedComponentRef={(inst) => this.calendarRef = inst} - /> - </Modal> - </div> - ) - } -} - -export default SettingComponent \ No newline at end of file diff --git a/src/templates/calendarconfig/calcomponent/index.scss b/src/templates/calendarconfig/calcomponent/index.scss deleted file mode 100644 index 5065e8f..0000000 --- a/src/templates/calendarconfig/calcomponent/index.scss +++ /dev/null @@ -1,41 +0,0 @@ -.model-calendar-setting { - position: absolute; - right: 0; - top: 0; - z-index: 2; - >.anticon-edit { - font-size: 18px; - padding: 5px; - margin-right: 10px; - color: #1890ff; - cursor: pointer; - } -} - -.model-calendar-setting-modal { - .ant-modal { - top: 50px; - padding-bottom: 5px; - .ant-modal-body { - max-height: calc(100vh - 190px); - overflow-y: auto; - } - .ant-modal-body::-webkit-scrollbar { - width: 7px; - } - .ant-modal-body::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - } - .ant-modal-body::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } - .ant-empty-normal { - margin: 5px 0px; - } - } -} \ No newline at end of file diff --git a/src/templates/calendarconfig/index.jsx b/src/templates/calendarconfig/index.jsx deleted file mode 100644 index 34f957a..0000000 --- a/src/templates/calendarconfig/index.jsx +++ /dev/null @@ -1,842 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { DndProvider } from 'react-dnd' -import HTML5Backend from 'react-dnd-html5-backend' -import { Button, Card, Modal, Collapse, notification, Spin, Switch } from 'antd' -import { RedoOutlined } from '@ant-design/icons' -import moment from 'moment' - -import Api from '@/api' -import Utils from '@/utils/utils.js' - -import asyncComponent from '@/utils/asyncComponent' -import SearchComponent from '@/templates/sharecomponent/searchcomponent' - -import MenuForm from '@/templates/comtableconfig/menuform' -import SourceElement from '@/templates/zshare/dragsource' -import Source from './source' -import './index.scss' - -const { Panel } = Collapse -const { confirm } = Modal - -const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) -const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent')) -const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcalcomponent')) -const TabComponent = asyncComponent(() => import('./tabcomponent')) -const CalComponent = asyncComponent(() => import('./calcomponent')) -const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) -const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) -const CalendarComponent = asyncComponent(() => import('@/tabviews/zshare/calendar')) - -class SubTableConfig extends Component { - static propTpyes = { - menu: PropTypes.any, - reloadmenu: PropTypes.func, - handleView: PropTypes.func - } - - state = { - config: null, // 椤甸潰閰嶇疆 - visible: false, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪锛屾ā鎬佹鏄剧ず鎺у埗 - fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� - formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 - menuloading: false, // 鑿滃崟淇濆瓨涓� - menucloseloading: false, // 鑿滃崟鍏抽棴鏃讹紝閫夋嫨淇濆瓨 - loading: false, // 鍔犺浇涓紝椤甸潰spin - closeVisible: false, // 鍏抽棴妯℃�佹 - originConfig: null, // 鍘熼厤缃� - tabviews: [], // 鎵�鏈夋爣绛鹃〉 - activeKey: '0', // 榛樿灞曞紑鍩烘湰淇℃伅 - openEdition: '', // 缂栬緫鐗堟湰鏍囪锛岄槻姝㈠浜烘搷浣� - mockdata: [], // 娴嬭瘯鏁版嵁 - } - - /** - * @description 鏁版嵁棰勫鐞� - * 1銆佽缃〉闈㈤厤缃俊鎭紝鏂板缓鎴栨棤閰嶇疆淇℃伅鏃讹紙鍒囨崲妯℃澘鍚庢棤閰嶇疆淇℃伅锛夛紝浣跨敤妯℃澘榛樿閰嶇疆 - * 2銆佽缃搷浣滅被鍨嬨�佸師濮嬭彍鍗曚俊鎭紙姣忔淇濆瓨鍚庨噸缃級銆佸凡浣跨敤琛ㄥ強鍩烘湰淇℃伅琛ㄥ崟 - */ - UNSAFE_componentWillMount () { - const { menu } = this.props - let _LongParam = menu.LongParam - let _config = '' - - if (!_LongParam) { - _config = fromJS(Source.baseConfig).toJS() - _config.isAdd = true - } else { - _config = _LongParam - } - - if (_config.type === 'user') { - if (_config.tab) { - _config.tab.linkTab = '' - } - } - - // 椤甸潰閰嶇疆涓繚鐣欒彍鍗曚俊鎭紝鍙敤浜庢暟鎹紶閫� - _config.ParentId = menu.ParentId - _config.fstMenuId = menu.fstMenuId - _config.MenuName = menu.MenuName || '' - _config.MenuNo = menu.MenuNo || '' - _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : '' - _config.easyCode = _config.easyCode || '' - - // 鏁版嵁婧� - if (_config.setting.interType === 'inner' && !_config.setting.innerFunc) { - _config.setting.interType = 'system' - } - - this.setState({ - openEdition: menu.open_edition || '', - activeKey: menu.activeKey || '0', - config: _config, - originMenu: fromJS(_config).toJS(), - mockdata: this.getMockData(moment().format('YYYY')) - }) - } - - /** - * @description 鍔犺浇瀹屾垚鍚� - * 1銆佽幏鍙栫郴缁熷彲浣跨敤琛� - * 2銆佹牴鎹厤缃俊鎭腑宸蹭娇鐢ㄨ〃鑾峰彇鐩稿叧瀛楁淇℃伅 - */ - componentDidMount () { - this.reloadTab(false) - document.onkeydown = (event) => { - let e = event || window.event - let keyCode = e.keyCode || e.which || e.charCode - let preKey = '' - - if (e.ctrlKey) { - preKey = 'ctrl' - } - if (e.shiftKey) { - preKey = 'shift' - } else if (e.altKey) { - preKey = 'alt' - } - - if (!preKey || !keyCode) return - - let _shortcut = `${preKey}+${keyCode}` - - if (_shortcut === 'ctrl+83') { - let modals = document.querySelectorAll('.mk-pop-modal') - let msg = null - for (let i = 0; i < modals.length; i++) { - if (msg) { - break - } - - let node = modals[i].querySelector('.mk-com-name') - - if (node) { - msg = node.innerText - } - } - if (msg) { - notification.warning({ - top: 92, - message: '璇蜂繚瀛�' + msg, - duration: 5 - }) - return false - } - - let node = document.getElementById('save-config') - if (node && node.click) { - node.click() - } - return false - } - } - } - - getMockData = (year) => { - let msgs = [ - {color: 'red', remark: '鎮ㄦ湁涓�鏉℃柊鐨勬秷鎭紒'}, - {color: 'orange', remark: '鎮ㄦ湁涓�鏉℃柊鐨勬秷鎭紒'}, - {color: 'yellow', remark: '鎮ㄦ湁涓�鏉℃柊鐨勬秷鎭紒'}, - {color: 'green', remark: '鎮ㄦ湁涓�鏉℃柊鐨勬秷鎭��'}, - {color: 'cyan', remark: '鎮ㄦ湁涓�鏉℃柊鐨勬秷鎭��'}, - {color: 'blue', remark: '鎮ㄦ湁涓�鏉℃柊鐨勬秷鎭紒'}, - {color: 'purple', remark: '鎮ㄦ湁涓�鏉℃柊鐨勬秷鎭��'}, - {color: 'gray', remark: '鎮ㄦ湁涓�鏉℃柊鐨勬秷鎭��'} - ] - let mockdata = [] - - for (let i = 1; i <= 12; i++) { - if (Math.random() > 0.5) { - let cell = {uuid: Utils.getuuid()} - let msg = msgs[Math.floor(Math.random() * 8)] - let day = Math.floor(Math.random() * 28 + 1) - - cell.color = msg.color - cell.remark = msg.remark - cell.start = `${year}-${i < 10 ? '0' + i : i}-${day < 10 ? '0' + day : day}` - cell.end = moment(cell.start, 'YYYY-MM-DD').add(Math.floor(Math.random() * 10), 'days').format('YYYY-MM-DD') - - mockdata.push(cell) - - if (Math.random() > 0.5) { - let _cell = {uuid: Utils.getuuid()} - let _msg = msgs[Math.floor(Math.random() * 8)] - let _day = Math.floor(Math.random() * 28 + 1) - - _cell.color = _msg.color - _cell.remark = _msg.remark - _cell.start = `${year}-${i < 10 ? '0' + i : i}-${_day < 10 ? '0' + _day : _day}` - _cell.end = moment(_cell.start, 'YYYY-MM-DD').add(Math.floor(Math.random() * 10), 'days').format('YYYY-MM-DD') - - mockdata.push(_cell) - } - } - } - - return mockdata - } - - /** - * @description 鍔犺浇鎴栧埛鏂版爣绛句俊鎭� - */ - reloadTab = (type) => { - this.setState({ - loading: type, - tabviews: [] - }) - Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => { - if (res.status) { - let _tabviews = [] - res.UserTemp.forEach(temp => { - let item = { - uuid: temp.MenuID, - value: temp.MenuID, - text: temp.MenuName, - type: temp.Template, - MenuNo: temp.MenuNo - } - - _tabviews.push(item) - }) - - this.setState({ - loading: false, - tabviews: _tabviews - }) - - if (type) { - notification.success({ - top: 92, - message: '鍒锋柊鎴愬姛銆�', - duration: 2 - }) - } - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 - */ - componentWillUnmount () { - this.setState = () => { - return - } - document.onkeydown = () => {} - } - - // 椤甸潰杩斿洖 - handleViewBack = () => { - let param = { - editMenu: null, - editTab: null, - tabConfig: null, - subTabConfig: null, - btnTab: null, - btnTabConfig: null, - editAction: null, - subConfig: null, - tabview: '' - } - - this.props.handleView(param) - } - - getFuncNames = (data, funcNames, tableNames) => { - data.forEach(item => { - // if (item.subfuncs) { - // this.getFuncNames(item.subfuncs, funcNames, tableNames) - // return - // } - - if (item.tableName) { - tableNames.push(item.tableName) - } - if (item.innerFunc) { - funcNames.push({func: item.innerFunc, label: item.label || ''}) - } - - if (item.callbackFunc) { - funcNames.push({func: item.callbackFunc, label: item.label || ''}) - } - }) - - return { - func: funcNames, - table: tableNames - } - } - - /** - * @description 涓夌骇鑿滃崟淇濆瓨 - */ - submitConfig = () => { - const { menu } = this.props - const { openEdition } = this.state - - let _config = fromJS(this.state.config).toJS() - - // 鍩烘湰淇℃伅楠岃瘉 - if (!_config.fstMenuId || !_config.ParentId || !_config.MenuName || !_config.MenuNo) { - notification.warning({ - top: 92, - message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', - duration: 5 - }) - this.setState({activeKey: '0'}) - return - } - - if (_config.isAdd) { - _config.search = _config.search.filter(item => !item.origin) - } - - if (_config.type === 'user') { // 浣跨敤宸叉湁鑿滃崟鏃讹紝榛樿娣诲姞鍏宠仈鏍囩id - if (_config.tab && !_config.tab.linkTab) { - _config.tab.linkTab = Utils.getuuid() - } - } - - // 鏈缃暟鎹簮鎴栨爣绛句笉鍚堟硶鏃讹紝鍚敤鐘舵�佷负false - let vresult = this.verifyconfig(_config) - if (vresult !== true) { - _config.enabled = false - } - - _config.funcs = [] // 椤甸潰鍙婂瓙椤甸潰瀛樺偍杩囩▼闆� - - _config.funcs.push({ - type: 'view', - subtype: 'view', - uuid: menu.MenuID, - intertype: _config.setting.interType || 'system', - interface: _config.setting.interface || '', - tableName: _config.setting.tableName || '', - innerFunc: _config.setting.innerFunc || '', - outerFunc: _config.setting.outerFunc || '' - }) - - if (_config.tab) { - _config.funcs.push({ - type: 'tab', - subtype: 'tab', - uuid: _config.tab.uuid, - label: _config.tab.label, - linkTab: _config.tab.linkTab - }) - } - - if (this.state.closeVisible) { // 鏄剧ず鍏抽棴瀵硅瘽妗嗘椂锛屾ā鎬佹涓繚瀛樻寜閽紝鏄剧ず淇濆瓨涓姸鎬� - this.setState({ - menucloseloading: true - }) - } else { - this.setState({ - menuloading: true - }) - } - - new Promise(resolve => { - // if (_config.tab) { - // Api.getSystemConfig({ - // func: 'sPC_Get_LongParam', - // MenuID: _config.tab.linkTab - // }).then(result => { - // if (result.status && result.LongParam) { - // let _LongParam = '' - - // if (result.LongParam) { - // try { - // _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) - // } catch (e) { - // console.warn('Parse Failure') - // _LongParam = '' - // } - // } - - // if (_LongParam) { - // _config.funcs[1].menuNo = _LongParam.tabNo || '' - // _config.funcs[1].subfuncs = _LongParam.funcs || [] - // } - // } - // resolve() - // }) - // } else { - // resolve() - // } - resolve() - }).then(() => { - // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser - delete _config.type - delete _config.isAdd - - let _LongParam = '' - - try { - _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config))) - } catch (e) { - notification.warning({ - top: 92, - message: '缂栬瘧閿欒', - duration: 5 - }) - this.setState({ - menucloseloading: false, - menuloading: false - }) - return - } - - // let tabParam = { // 娣诲姞鑿滃崟tab椤� - // func: 'sPC_sMenusTab_AddUpt', - // MenuID: menu.MenuID - // } - - // if (_config.tab) { - // tabParam.LText = Utils.formatOptions(`select '${menu.MenuID}' as MenuID ,'${_config.tab.linkTab}' as Tabid,'${_config.tab.label}' as TabName ,'0' as Sort`) - // } else { - // tabParam.LText = Utils.formatOptions(`select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort`) - // } - - // tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - // tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp) - - let _vals = this.getFuncNames(_config.funcs, [], []) - let _tables = Array.from(new Set(_vals.table)) - - let param = { - func: 'sPC_TrdMenu_AddUpt', - FstID: _config.fstMenuId, - SndID: _config.ParentId, - ParentID: _config.ParentId, - MenuID: menu.MenuID, - MenuNo: _config.MenuNo, - EasyCode: _config.easyCode || '', - Template: _config.Template || '', - MenuName: _config.MenuName, - PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}), - LongParam: _LongParam, - LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), - LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`) - } - - if (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴� - param.Sort = menu.menuSort - } - - param.LText = param.LText.join(' union all ') - param.LText = Utils.formatOptions(param.LText) - param.LTexttb = param.LTexttb.join(' union all ') - param.LTexttb = Utils.formatOptions(param.LTexttb) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (openEdition) { // 鐗堟湰绠$悊 - param.open_edition = openEdition - } - - // 淇濆瓨鏈湴 - let localParam = fromJS(param).toJS() - - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - config: _config, - openEdition: response.open_edition || '', - originMenu: fromJS(_config).toJS(), - menuloading: false, - menucloseloading: false - }) - - this.props.reloadmenu() - - localParam.func = 'sPC_TrdMenu_AddUpt_For_Local' - delete localParam.LongParam - delete localParam.PageParam - delete localParam.Template - delete localParam.Sort - delete localParam.EasyCode - delete localParam.open_edition - - Api.genericInterface(localParam) - - notification.success({ - top: 92, - message: '淇濆瓨鎴愬姛', - duration: 2 - }) - - if (this.state.closeVisible) { - this.handleViewBack() - } - } else { - this.setState({ - menuloading: false, - menucloseloading: false - }) - notification.warning({ - top: 92, - message: response.message, - duration: 5 - }) - } - }) - }) - } - - cancelConfig = () => { - const { config, originMenu } = this.state - let _this = this - - if (config.isAdd) { - confirm({ - content: '鑿滃崟灏氭湭鎻愪氦锛岀‘瀹氭斁寮冧繚瀛樺悧锛�', - onOk() { - _this.props.handleView() - }, - onCancel() {} - }) - } else { - if (!is(fromJS(originMenu), fromJS(config))) { - this.setState({ - closeVisible: true - }) - } else { - this.props.handleView() - } - } - } - - /** - * @description 璁剧疆鍙厤缃寜閽� - */ - setSubConfig = () => { - const { menu } = this.props - const { config, originMenu, activeKey, openEdition } = this.state - - if (config.isAdd) { // 鏂板缓鑿滃崟锛屾彁绀鸿彍鍗曞皻鏈繚瀛� - notification.warning({ - top: 92, - message: '鑿滃崟灏氭湭淇濆瓨锛岃鍏堜繚瀛樿彍鍗曢厤缃紒', - duration: 5 - }) - } else { - // 鍩烘湰淇℃伅楠岃瘉 - if (!config.fstMenuId || !config.ParentId || !config.MenuName || !config.MenuNo) { - notification.warning({ - top: 92, - message: '璇峰畬鍠勮彍鍗曞熀鏈俊鎭紒', - duration: 5 - }) - this.setState({activeKey: '0'}) - return - } - - if (!is(fromJS(originMenu), fromJS(config))) { // 鑿滃崟淇℃伅鍙樺寲鏃讹紝鎻愮ず淇濆瓨 - notification.warning({ - top: 92, - message: '鑿滃崟閰嶇疆宸蹭慨鏀癸紝璇蜂繚瀛橈紒', - duration: 5 - }) - return - } - - let submenu = menu.fstMenuList.filter(item => item.MenuID === config.fstMenuId)[0] - let _Menu = { - ...menu, - LongParam: config, - PageParam: {...menu.PageParam, Template: config.Template, OpenType: config.OpenType}, - MenuName: config.MenuName, - MenuNo: config.MenuNo, - ParentId: config.ParentId, - fstMenuId: config.fstMenuId, - supMenuList: submenu ? submenu.options : [] - } - - // 鑿滃崟淇℃伅楠岃瘉閫氳繃鍚庯紝璺宠浆瀛愰厤缃〉闈� - _Menu.activeKey = activeKey // 淇濆瓨褰撳墠鎵撳紑椤电 - _Menu.open_edition = openEdition // 鏇存柊鐗堟湰鍙� - - let param = { - editMenu: _Menu, - editTab: fromJS(config.tab).toJS(), - tabConfig: null, - editSubTab: null, - subTabConfig: null, - btnTab: null, - btnTabConfig: null, - editAction: '', - subConfig: '', - tabview: config.tab.type - } - - // 褰撳瓙琛ㄤ娇鐢ㄤ富椤垫悳绱㈡潯浠舵椂锛屽皢涓婚〉鎼滅储鍚戜笅浼犻�� - if (param.editTab && param.editTab.searchPass === 'true') { - param.editTab.mainsearch = fromJS(config.search).toJS() - } - - this.setState({ - loading: true - }) - - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: config.tab.linkTab - }).then(res => { - if (res.status) { - this.setState({ - loading: false - }) - let _LongParam = '' - if (res.LongParam) { - try { - _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) - } catch (e) { - console.warn('Parse Failure') - _LongParam = '' - } - } - - if (_LongParam && param.tabview === 'SubTable' && _LongParam.Template === 'SubTable') { - param.subConfig = _LongParam - } - - if (param.editTab) { - param.editTab.open_edition = res.open_edition || '' - } - - this.props.handleView(param) - } else { - this.setState({ - loading: false - }) - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } - }) - } - } - - /** - * @description 鍒囨崲鏍囩鏄惁鍚敤 - */ - onEnabledChange = () => { - const { config } = this.state - - let _enabled = !config.enabled - let result = this.verifyconfig(config) - - if (_enabled && result !== true) { - notification.warning({ - top: 92, - message: result, - duration: 5 - }) - return - } - - this.setState({ - config: {...config, enabled: _enabled} - }) - } - - /** - * @description 鏍¢獙閰嶇疆淇℃伅鐨勫悎娉曟�� - */ - verifyconfig = (config) => { - let cols = [] - config.columns.forEach(col => { - if (col.field) { - cols.push(col.field) - } - }) - - if (config.setting.interType === 'system' && config.setting.default !== 'false' && !config.setting.dataresource) { - return '鑿滃崟灏氭湭璁剧疆鏁版嵁婧愶紝涓嶅彲鍚敤锛�' - } else if (config.columns.length === 0) { - return '鑿滃崟灏氭湭璁剧疆瀛楁闆嗭紝涓嶅彲鍚敤锛�' - } else if (!config.calendar.startfield) { - return '鏃ュ巻鍏宠仈瀛楁鏈缃紝涓嶅彲鍚敤锛�' - } else if (!cols.includes(config.calendar.startfield)) { - return '寮�濮嬫椂闂村瓧娈靛凡鍒犻櫎锛屼笉鍙惎鐢紒' - } else if (!cols.includes(config.calendar.endfield)) { - return '缁撴潫鏃堕棿瀛楁宸插垹闄わ紝涓嶅彲鍚敤锛�' - } else if (config.calendar.colorfield && !cols.includes(config.calendar.colorfield)) { - return '棰滆壊瀛楁宸插垹闄わ紝涓嶅彲鍚敤锛�' - } else if (!cols.includes(config.calendar.remarkfield)) { - return '淇℃伅瀛楁宸插垹闄わ紝涓嶅彲鍚敤锛�' - } else { - return true - } - } - - /** - * @description 缂栬緫鍔熻兘瀹屾垚鏇存柊锛屽寘鎷В鍐绘寜閽�佺矘璐淬�佹浛鎹㈢瓑 - */ - updateConfig = (res) => { - if (res.type === 'thaw') { - this.setState({ - config: res.config - }) - } else if (res.type === 'paste') { - this.setState({config: res.config}) - } - } - - /** - * @description 鏇存柊鎼滅储鏉′欢閰嶇疆淇℃伅 - */ - updatesearch = (config) => { - - this.setState({ - config: config - }) - } - - /** - * @description 鏇存柊鏄剧ず鍒楅厤缃俊鎭� - */ - updateconfig = (config) => { - this.setState({ - config: config - }) - } - - // 骞村垏鎹㈡椂閲嶆柊鐢熸垚鏁版嵁 - changeDate = (year) => { - this.setState({ - mockdata: this.getMockData(year) - }) - } - - render () { - const { menu } = this.props - const { activeKey, config, tabviews, mockdata } = this.state - - return ( - <div className="model-calendar-board"> - <DndProvider backend={HTML5Backend}> - {/* 宸ュ叿鏍� */} - <div className="tools"> - <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> - {/* 鍩烘湰淇℃伅 */} - <Panel forceRender={true} header="鍩烘湰淇℃伅" key="0" id="subtable-basedata"> - {/* 鑿滃崟淇℃伅 */} - <MenuForm - menu={menu} - config={config} - updatemenu={this.updateconfig} - /> - {config ? <UrlFieldComponent - config={config} - updateConfig={this.updateconfig} - /> : null} - {/* 琛ㄥ悕娣诲姞 */} - <TableComponent - config={config} - containerId="subtable-basedata" - updatetable={this.updateconfig} - /> - </Panel> - {/* 鎼滅储鏉′欢娣诲姞 */} - <Panel header="鎼滅储" key="1"> - <div className="search-element"> - {Source.searchItems.map((item, index) => { - return (<SourceElement key={index} content={item}/>) - })} - </div> - <FieldsComponent config={config} type="search" /> - </Panel> - </Collapse> - </div> - <div className="setting"> - <Card title={ - <div> - 鏃ュ巻椤甸潰閰嶇疆 - <RedoOutlined style={{marginLeft: '10px'}} title="鍒锋柊鏍囩鍒楄〃" onClick={() => this.reloadTab(true)} /> - </div> - } bordered={false} extra={ - <div> - <EditComponent type="table" options={['search', 'form']} config={this.state.config}/> - <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> - <Button type="primary" id="save-config" onClick={this.submitConfig} loading={this.state.menuloading}>淇濆瓨</Button> - <Button onClick={this.cancelConfig}>鍏抽棴</Button> - </div> - } style={{ width: '100%' }}> - <SettingComponent - config={config} - MenuID={menu.MenuID} - updateConfig={this.updateconfig} - /> - <SearchComponent - menu={{MenuID: menu.MenuID, MenuName: config.MenuName}} - config={config} - updatesearch={this.updatesearch} - /> - <div className="calendar-wrap"> - <TabComponent config={config} updateConfig={this.updateconfig} tabviews={tabviews} setSubConfig={this.setSubConfig} /> - <CalComponent config={config} updateConfig={this.updateconfig} /> - <CalendarComponent calendar={{ - levels: config.calendar.levels, startfield: 'start', endfield: 'end', colorfield: 'color', remarkfield: 'remark', refresh: config.calendar.refresh - }} data={mockdata} changeDate={this.changeDate}/> - </div> - </Card> - </div> - </DndProvider> - <Modal - bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}} - closable={false} - maskClosable={false} - visible={this.state.closeVisible} - onCancel={() => { this.setState({closeVisible: false}) }} - footer={[ - <Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>淇濆瓨</Button>, - <Button key="confirm" className="mk-btn mk-yellow" onClick={this.handleViewBack}>涓嶄繚瀛�</Button>, - <Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>鍙栨秷</Button> - ]} - destroyOnClose - > - 閰嶇疆宸蹭慨鏀癸紝鏄惁淇濆瓨閰嶇疆淇℃伅锛� - </Modal> - {this.state.loading && <Spin size="large" />} - </div> - ) - } -} - -export default SubTableConfig diff --git a/src/templates/calendarconfig/index.scss b/src/templates/calendarconfig/index.scss deleted file mode 100644 index d40120f..0000000 --- a/src/templates/calendarconfig/index.scss +++ /dev/null @@ -1,159 +0,0 @@ -.model-calendar-board { - position: fixed; - z-index: 1; - padding-top: 48px; - top: 0px; - left: 0px; - right: 0px; - bottom: 0px; - background: rgba(0, 0, 0, 0.35); - display: flex; - .tools { - flex: 1; - background: #ffffff; - border-right: 1px solid #d9d9d9; - height: 100%; - overflow-y: hidden; - padding-bottom: 30px; - .ant-collapse-borderless { - background-color: #ffffff; - } - .ant-collapse-item { - position: relative; - border: 0; - } - .ant-input-search { - margin-top: 10px; - } - .ant-collapse-item.ant-collapse-item-active { - border-bottom: 1px solid #d9d9d9; - } - .ant-collapse .ant-collapse-header { - padding: 11px 16px 10px 40px; - border-bottom: 1px solid #d9d9d9; - background: #1890ff; - color: #ffffff; - } - .ant-collapse-content-box { - .ant-form-item { - margin-bottom: 10px; - .ant-form-item-label { - text-align: left; - height: 25px; - line-height: 25px; - } - } - } - .search-element { - padding-top: 10px; - li { - padding: 0px 16px 10px; - div { - cursor: move; - } - } - } - - .config-button { - min-width: 65px; - } - } - .tools:hover { - overflow-y: auto; - } - .tools::-webkit-scrollbar { - width: 7px; - } - .tools::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0); - background: rgba(0, 0, 0, 0); - } - .tools::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0); - background: rgba(0, 0, 0, 0); - } - .tools:hover::-webkit-scrollbar-thumb { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - } - .tools:hover::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border: 1px solid rgba(0, 0, 0, 0.07); - } - .setting { - position: relative; - width: calc(100vw - 235px); - height: 100%; - background: #ffffff; - .ant-switch.big { - min-width: 60px; - height: 28px; - line-height: 28px; - margin-top: -2px; - .ant-switch-inner { - font-size: 14px; - } - } - .ant-switch.big::after { - width: 24px; - height: 24px; - } - .ant-card-head { - min-height: 44px; - } - .ant-card-head-title { - padding: 5px 0; - color: #1890ff; - } - .ant-card-extra { - padding: 5px 0; - button { - margin-left: 20px; - } - } - .ant-card-body { - position: relative; - padding: 0; - - > .anticon-setting { - position: absolute; - font-size: 18px; - right: 7px; - top: 10px; - } - .calendar-wrap { - position: relative; - padding-top: 10px; - } - } - } - .setting { - overflow-y: scroll; - } - .setting::-webkit-scrollbar { - width: 7px; - } - .setting::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - display: none; - } - .setting::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } - .setting:hover::-webkit-scrollbar-thumb { - display: block; - } - .ant-spin { - position: absolute; - margin-left: calc(50vw - 22px); - margin-top: 30vh; - } -} diff --git a/src/templates/calendarconfig/source.jsx b/src/templates/calendarconfig/source.jsx deleted file mode 100644 index 9638d63..0000000 --- a/src/templates/calendarconfig/source.jsx +++ /dev/null @@ -1,101 +0,0 @@ -import Utils from '@/utils/utils.js' - -class CalendarBaseData { - baseConfig = { - version: '1.0', - type: 'system', - Template: 'CalendarPage', - enabled: false, - tabName: '', - tabNo: '', - Remark: '', - uuid: Utils.getuuid(), - setting: { - tableName: '', - primaryKey: '', - dataresource: '', - interType: 'system', - innerFunc: '', - interface: '', - outerFunc: '' - }, - columns: [], - scripts: [], - tables: [], - tab: null, - calendar: { - levels: ['day', 'month', 'year'], - startfield: '', - endfield: '', - colorfield: '', - remarkfield: '', - refresh: 'false' - }, - search: [] - } - - searchItems = [ - { - type: 'search', - label: '鏂囨湰', - subType: 'text', - url: '' - }, - { - type: 'search', - label: '涓嬫媺閫夋嫨', - subType: 'select', - url: '' - }, - { - type: 'search', - label: '涓嬫媺澶氶��', - subType: 'multiselect', - url: '' - }, - { - type: 'search', - label: '鑱斿姩鑿滃崟', - subType: 'link', - url: '' - }, - { - type: 'search', - label: '閫夐」鍗�', - subType: 'checkcard', - url: '' - }, - { - type: 'search', - label: '鏃ユ湡锛堝ぉ锛�', - subType: 'date', - url: '' - }, - { - type: 'search', - label: '鏃ユ湡锛堝懆锛�', - subType: 'dateweek', - url: '' - }, - { - type: 'search', - label: '鏃ユ湡锛堟湀锛�', - subType: 'datemonth', - url: '' - }, - { - type: 'search', - label: '鏃ユ湡锛堝尯闂达級', - subType: 'daterange', - url: '' - }, - { - type: 'search', - label: '鏃ユ湡锛堢粍鍚堬級', - subType: 'group', - url: '' - } - ] -} - -export default new CalendarBaseData() diff --git a/src/templates/calendarconfig/tabcomponent/index.jsx b/src/templates/calendarconfig/tabcomponent/index.jsx deleted file mode 100644 index f85bba9..0000000 --- a/src/templates/calendarconfig/tabcomponent/index.jsx +++ /dev/null @@ -1,115 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { Modal } from 'antd' -import { EditOutlined, CloseOutlined, PlusOutlined } from '@ant-design/icons' - -import { getTabForm } from '@/templates/zshare/formconfig' -import TabForm from './tabform' -import './index.scss' - -const { confirm } = Modal - -class SettingComponent extends Component { - static propTpyes = { - config: PropTypes.any, // 鏍囩 - tabviews: PropTypes.array, // 鏍囩闆� - updateConfig: PropTypes.func, - setSubConfig: PropTypes.func - } - - state = { - menu: null, // 鑿滃崟淇℃伅 - formlist: null, // 琛ㄥ崟淇℃伅 - visible: false // 妯℃�佹鎺у埗 - } - - /** - * @description 淇濆瓨椤甸潰閰嶇疆淇℃伅 - */ - tabSave = () => { - const { config } = this.props - - this.tabRef.handleConfirm().then(res => { - this.setState({ - visible: false - }) - this.props.updateConfig({...config, tab: res}) - }) - } - - shouldComponentUpdate (nextProps, nextState) { - return !is(fromJS(this.state), fromJS(nextState)) || !is(fromJS(this.props.config.tab), fromJS(nextProps.config.tab)) - } - - /** - * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊 - */ - componentWillUnmount () { - this.setState = () => { - return - } - } - - /** - * @description 娣诲姞鎴栦慨鏀规爣绛� - */ - handleTab = (e) => { - e.stopPropagation() - const { config } = this.props - - this.setState({ - visible: true, - formlist: getTabForm(config.tab || {}, '', [], '', [], config.Template) - }) - } - - closeTab = (e) => { - const { config } = this.props - const _this = this - e.stopPropagation() - - confirm({ - content: '纭畾鍒犻櫎鏍囩鍚楋紵', - onOk() { - _this.props.updateConfig({...config, tab: ''}) - }, - onCancel() {} - }) - } - - render() { - const { tabviews, config } = this.props - const { visible } = this.state - - return ( - <div className="model-calendar-tab"> - {config.tab ? <div className="tab-control"> - <span onDoubleClick={this.props.setSubConfig}>{config.tab.label}</span> - <EditOutlined onClick={this.handleTab} /> - <CloseOutlined onClick={this.closeTab} /> - </div> : <PlusOutlined title="娣诲姞鏍囩" onClick={this.handleTab} />} - {/* 璁剧疆鍏ㄥ眬閰嶇疆鍙婂垪琛ㄦ暟鎹簮 */} - <Modal - wrapClassName="model-calendar-tab-modal" - title="缂栬緫" - visible={visible} - width={700} - maskClosable={false} - onCancel={() => { this.setState({ visible: false })}} - onOk={this.tabSave} - destroyOnClose - > - <TabForm - tabs={tabviews} - inputSubmit={this.tabSave} - formlist={this.state.formlist} - wrappedComponentRef={(inst) => this.tabRef = inst} - /> - </Modal> - </div> - ) - } -} - -export default SettingComponent \ No newline at end of file diff --git a/src/templates/calendarconfig/tabcomponent/index.scss b/src/templates/calendarconfig/tabcomponent/index.scss deleted file mode 100644 index 9bb7caf..0000000 --- a/src/templates/calendarconfig/tabcomponent/index.scss +++ /dev/null @@ -1,86 +0,0 @@ -.model-calendar-tab { - position: absolute; - top: 0; - z-index: 2; - >.anticon-plus { - position: absolute; - font-size: 18px; - left: 10px; - top: 10px; - color: #26c281; - cursor: pointer; - } - .tab-control { - position: absolute; - padding: 15px 0px 0px 10px; - left: 0px; - top: 0px; - - span:not(.anticon) { - display: inline-block; - white-space: nowrap; - font-size: 16px; - cursor: pointer; - padding: 0 10px; - border-bottom: 2px solid #1890ff; - } - - .anticon-edit { - position: absolute; - font-size: 14px; - left: 10px; - top: 2px; - color: #1890ff; - cursor: pointer; - display: none; - } - .anticon-close { - position: absolute; - font-size: 14px; - left: 35px; - top: 2px; - color: #ff4d4f; - cursor: pointer; - display: none; - } - } - .tab-control:hover { - .anticon-edit { - display: inline-block; - } - .anticon-close { - display: inline-block; - } - } -} - -.model-calendar-tab-modal { - .ant-modal { - top: 50px; - padding-bottom: 5px; - .ant-modal-body { - max-height: calc(100vh - 190px); - overflow-y: auto; - // .ant-empty { - // margin: 15vh 8px; - // } - } - .ant-modal-body::-webkit-scrollbar { - width: 7px; - } - .ant-modal-body::-webkit-scrollbar-thumb { - border-radius: 5px; - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13); - background: rgba(0, 0, 0, 0.13); - } - .ant-modal-body::-webkit-scrollbar-track { - box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); - border-radius: 3px; - border: 1px solid rgba(0, 0, 0, 0.07); - background: rgba(0, 0, 0, 0); - } - .ant-empty-normal { - margin: 5px 0px; - } - } -} \ No newline at end of file diff --git a/src/templates/calendarconfig/tabcomponent/tabform/index.jsx b/src/templates/calendarconfig/tabcomponent/tabform/index.jsx deleted file mode 100644 index 0584c22..0000000 --- a/src/templates/calendarconfig/tabcomponent/tabform/index.jsx +++ /dev/null @@ -1,230 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, Tooltip, Radio } from 'antd' -import { QuestionCircleOutlined } from '@ant-design/icons' - -import { formRule } from '@/utils/option.js' -import Utils from '@/utils/utils.js' -import './index.scss' - -class MainTab extends Component { - static propTpyes = { - tabs: PropTypes.array, // 鍙叧鑱旀爣绛鹃泦 - formlist: PropTypes.any, // 琛ㄥ崟 - inputSubmit: PropTypes.any // 鍥炶溅鎻愪氦浜嬩欢 - } - - state = { - formlist: null // 琛ㄥ崟 - } - - /** - * @description 琛ㄥ崟棰勫鐞� - */ - UNSAFE_componentWillMount () { - const { formlist } = this.props - - let _tabs = this.props.tabs.filter(tab => tab.type === 'SubTable') - - this.setState({ - formlist: formlist.map(item => { - if (item.key === 'linkTab') { - item.options = [ - { - value: '', - text: '鏂板缓' - }, - ..._tabs - ] - } - - return item - }) - }) - } - - /** - * @description 鏍囩椤电被鍨嬪垏鎹� - */ - openTypeChange = (key, value) => { - const { formlist } = this.state - - if (key === 'type') { - let _tabs = this.props.tabs.filter(tab => tab.type === value) - - this.setState({ - formlist: formlist.map(item => { - if (item.key === 'linkTab') { - item.options = [ - { - value: '', - text: '鏂板缓' - }, - ..._tabs - ] - item.initVal = '' - } - return item - }) - }, () => { - if (this.props.form.getFieldValue('linkTab') !== undefined) { - this.props.form.setFieldsValue({linkTab: ''}) - } - }) - } - } - - handleSubmit = (e) => { - e.preventDefault() - - if (this.props.inputSubmit) { - this.props.inputSubmit() - } - } - - getFields() { - const { getFieldDecorator } = this.props.form - const fields = [] - - this.state.formlist.forEach((item, index) => { - if (item.hidden || item.forbid) return - - if (item.type === 'text') { - let rules = [] - - if (item.key === 'foreignKey') { - rules.push({ - pattern: /^[a-zA-Z_]*$/ig, - message: item.label + '瀛楁鍙厑璁稿寘鍚瓧姣嶅強涓嬪垝绾匡紒' - }) - } - fields.push( - <Col span={24} key={index}> - <Form.Item label={ - item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: '璇疯緭鍏�' + item.label + '!' - }, - { - max: formRule.input.max, - message: formRule.input.message - }, - ...rules - ] - })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={24} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: '璇烽�夋嫨' + item.label + '!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={(value) => {this.openTypeChange(item.key, value)}} - > - {item.options.map((option, i) => - <Select.Option id={'mk' + i} title={option.text} key={'mk' + i} value={option.value}> - {option.text} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'radio') { - fields.push( - <Col span={24} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: '璇烽�夋嫨' + item.label + '!' - } - ] - })( - <Radio.Group> - { - item.options.map(option => { - return ( - <Radio key={option.value} value={option.value}>{option.text}</Radio> - ) - }) - } - </Radio.Group> - )} - </Form.Item> - </Col> - ) - } - }) - - return fields - } - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - - if (!values.linkTab) { // 娌℃湁鍏宠仈鏍囩锛堟柊寤烘椂锛夛紝鍒涘缓鏂版爣绛綢d - values.linkTab = Utils.getuuid() - } - values.type = 'SubTable' // 绫诲瀷涓哄瓙琛� - - resolve(values) - } else { - reject(err) - } - }) - }) - } - - render() { - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 12 } - } - } - return ( - <Form {...formItemLayout} style={{minHeight: '180px'}}> - <Row gutter={24}>{this.getFields()}</Row> - </Form> - ) - } -} - -export default Form.create()(MainTab) \ No newline at end of file diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index d9b92c4..2a172db 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -28,6 +28,8 @@ const { Panel } = Collapse const { confirm } = Modal + +const UpdateTable = asyncComponent(() => import('./updatetable')) const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform')) const CreateFunc = asyncComponent(() => import('@/templates/zshare/createfunc')) const VerifyCard = asyncComponent(() => import('@/templates/zshare/verifycard')) @@ -128,6 +130,9 @@ } return item }) + + _config.btnId = btnTab.uuid + _config.btnName = btnTab.label this.setState({ config: _config, @@ -1568,6 +1573,7 @@ </div> } bordered={false} extra={ <div> + <UpdateTable config={config} menu={this.props.menu}/> <Switch className="big" checkedChildren="鍚�" unCheckedChildren="鍋�" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>淇濆瓨</Button> <Button onClick={this.cancelConfig}>杩斿洖</Button> diff --git a/src/templates/formtabconfig/updatetable/index.jsx b/src/templates/formtabconfig/updatetable/index.jsx new file mode 100644 index 0000000..5245a83 --- /dev/null +++ b/src/templates/formtabconfig/updatetable/index.jsx @@ -0,0 +1,1274 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' +import { Modal, Button, notification } from 'antd' +import { ArrowUpOutlined } from '@ant-design/icons' +import moment from 'moment' +import md5 from 'md5' + +import { colorTransform } from '@/utils/option.js' +import { getTables } from '@/utils/utils-custom.js' +import Api from '@/api' +import Utils from '@/utils/utils.js' +// import './index.scss' + +const { confirm } = Modal + +class UpdateTable extends Component { + static propTpyes = { + config: PropTypes.object + } + + state = {} + delButtons = [] + baseMsg = {} + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) + } + + trigger = () => { + const { config } = this.props + const _this = this + + if (!config.enabled) { + notification.warning({ + top: 92, + message: '鏈惎鐢ㄨ彍鍗曚笉鍙崌绾э紒', + duration: 5 + }) + return + } + + confirm({ + title: '纭畾鍗囩骇褰撳墠鑿滃崟鍚楋紵', + content: '', + onOk() { + return new Promise(resolve => { + _this.execUpdate(resolve) + }) + }, + onCancel() {} + }) + } + + execUpdate = (_resolve) => { + const { menu } = this.props + const config = fromJS(this.props.config).toJS() + this.delButtons = [] + this.baseMsg = { + fstMenuId: config.fstMenuId, + parentId: config.ParentId, + MenuName: config.MenuName, + MenuNo: config.MenuNo, + } + + let MenuID = md5(menu.MenuID + config.btnId) + + let _config = { + version: 1.0, + uuid: MenuID, + MenuID: MenuID, + fstMenuId: menu.fstMenuId, + parentId: menu.ParentId, + Template: 'CustomPage', + easyCode: '', + enabled: false, + MenuName: menu.MenuName + '-' + config.btnName, + MenuNo: menu.MenuNo + '_' + MenuID.substr(-4), + OpenType: 'newtab', + tables: config.tables || [], + urlFields: [], + hidden: 'true', + Remark: '', + components: [], + viewType: 'menu', + style: { backgroundColor: '#ffffff', paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px'}, + } + + let formActions = [] + let popActions = [] + let errors = [] + + let mainF = { + uuid: Utils.getuuid(), + type: 'form', + format: 'object', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 + pageable: false, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� + switchable: false, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� + width: 24, + name: '涓昏〃鍗�', + subtype: 'simpleform', + setting: { interType: 'system' }, + wrap: { name: '涓昏〃鍗�', width: 24, datatype: 'static' }, + style: { marginLeft: '0px', marginRight: '0px', marginTop: '8px', marginBottom: '8px' }, + headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, + columns: [], + scripts: [], + subcards: [] + } + + let card = { + uuid: Utils.getuuid(), + setting: {title: '', align: 'left_right', enable: 'true'}, + style: {}, + fields: [], + subButton: {label: '纭畾', type: 'submit', reload: 'false', sql: '', Ot: 'notRequired', enable: 'true', style: {backgroundColor: 'rgba(255, 255, 255, 1)', color: 'rgba(24, 144, 255, 1)', paddingLeft: '20px', paddingRight: '20px', paddingTop: '5px', paddingBottom: '5px', borderColor: 'rgba(24, 144, 255, 1)', borderWidth: '1px'}}, + closeButton: {label: '鍏抽棴', type: 'close', enable: 'true', style: { color: 'rgba(245, 34, 45, 1)', paddingTop: '5px', paddingRight: '20px', marginLeft: '20px', backgroundColor: '#ffffff', borderColor: 'rgba(245, 34, 45, 1)', paddingLeft: '20px', borderWidth: '1px', paddingBottom: '5px'}}, + } + + let btn = config.action[0] + + card.subButton.intertype = btn.intertype + card.subButton.innerFunc = btn.innerFunc || '' + card.subButton.execSuccess = btn.execSuccess || 'never' + card.subButton.execError = btn.execError || 'never' + + if (btn.intertype === 'outer') { + card.subButton.procMode = btn.innerFunc ? 'inner' : 'none' + card.subButton.sysInterface = btn.sysInterface || 'false' + card.subButton.interface = btn.interface || '' + card.subButton.outerFunc = btn.outerFunc || '' + card.subButton.callbackFunc = btn.callbackFunc || '' + card.subButton.callbackType = btn.callbackFunc ? 'func' : 'none' + } else if (btn.intertype === 'system') { + card.subButton.sqlType = btn.sqlType || '' + card.subButton.sql = btn.sql || '' + card.subButton.verify = btn.verify || null + } + + if (config.setting.datatype === 'query') { + mainF.wrap.datatype = 'dynamic' + mainF.setting = { + interType: config.setting.interType || 'system', + innerFunc: config.setting.innerFunc || '', + outerFunc: config.setting.outerFunc || '', + interface: config.setting.interface || '', + dataresource: config.setting.dataresource || '', + sysInterface: config.setting.sysInterface || 'false', + order: '', + primaryKey: config.setting.primaryKey || '', + tableName: menu.LongParam.setting.tableName || '', + supModule: ['empty'], + sync: 'false', + onload: 'true' + } + + if (mainF.setting.interType === 'inner' && !mainF.setting.innerFunc) { + mainF.setting.interType = 'system' + } + + card.subButton.Ot = 'requiredSgl' + } + + config.groups.forEach(group => { + if (!group.isDefault) { + card.fields.push({ + uuid: Utils.getuuid(), + label: group.label, + span: 24, + type: 'split' + }) + } + + group.sublist.forEach(item => { + item.labelwidth = 33.3 + item.span = 12 + + if (item.type === 'textarea' && config.setting.cols === '2') { + item.labelwidth = 16.2 + item.span = 24 + } + + card.fields.push(item) + }) + }) + + card.fields.forEach(item => { + if (item.field) { + if (item.type === 'number') { + mainF.columns.push({ + datatype: `decimal(18,${item.decimal === 0 ? 0 : (item.decimal || 2)})`, + field: item.field, + decimal: item.decimal || 0, + label: item.label, + type: 'number', + uuid: Utils.getuuid() + }) + } else { + mainF.columns.push({ + datatype: `Nvarchar(${item.fieldlength || 50})`, + field: item.field, + fieldlength: 50, + label: item.label, + type: 'text', + uuid: Utils.getuuid() + }) + } + } + }) + + mainF.subcards.push(card) + + let oldtabs = { + mainTable: mainF.uuid + } + + _config.components.push(mainF) + + let _tbs = [] + if (config.tabgroups && config.tabgroups.length > 0) { + config.tabgroups.forEach((m, i) => { + if (!m.sublist || m.sublist.length === 0) return + + let tabs = { + uuid: Utils.getuuid(), + type: 'tabs', + subtype: 'tabs', + name: '鏍囩缁�' + (i + 1), + width: 24, + setting: {name: '鏍囩缁�' + (i + 1), width: 24, position: 'top'}, + style: {}, + subtabs: m.sublist.map(n => { + let tab = { uuid: Utils.getuuid(), label: n.label, icon: n.icon, permission: 'false', components: [ + { + uuid: Utils.getuuid(), + linkTab: n.linkTab, + name: n.label, + useMSearch: 'false', + supModule: n.supMenu || '', + equalTab: n.equalTab && n.equalTab.length > 0 ? n.equalTab[0] : '' + } + ]} + this.delButtons.push(n.linkTab) + oldtabs[n.uuid] = tab.components[0].uuid + + _tbs.push(tab.components[0]) + + return tab + }) + } + + _config.components.push(tabs) + }) + } + + if (_tbs.length > 0) { + let defers = _tbs.map((item, i) => { + return new Promise((resolve) => { + setTimeout(() => { + Api.getSystemConfig({ + func: 'sPC_Get_LongParam', + MenuID: item.linkTab + }).then(res => { + if (res.status) { + let _LongParam = '' + if (res.LongParam) { + try { + _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) + } catch (e) { + console.warn('Parse Failure') + _LongParam = '' + } + } + + if (_LongParam) { + _LongParam.uuid = item.linkTab + resolve(_LongParam) + } else { + resolve({uuid: item.linkTab, $empty: true}) + } + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + resolve({uuid: item.linkTab, $empty: true}) + } + }) + }, i * 50) + }) + }) + Promise.all(defers).then(res => { + let menus = {} + res.forEach(item => { + if (item && !item.$empty) { + menus[item.uuid] = item + } + }) + + _config.components = _config.components.map(item => { + if (item.type === 'tabs') { + item.subtabs = item.subtabs.map(tab => { + tab.components[0] = this.getTable(menus[tab.components[0].linkTab], tab.components[0], errors, formActions, popActions, oldtabs) + + return tab + }) + } + return item + }) + + this.setPopView(_resolve, _config, formActions, popActions, errors) + }) + } else { + this.setPopView(_resolve, _config, formActions, popActions, errors) + } + } + + setPopView = (_resolve, _config, formActions, popActions, errors) => { + if (popActions.length > 0) { + let defers = popActions.map((item, i) => { + return new Promise((resolve) => { + setTimeout(() => { + Api.getSystemConfig({ + func: 'sPC_Get_LongParam', + MenuID: item.linkTab + }).then(res => { + if (res.status) { + let _LongParam = '' + if (res.LongParam) { + try { + _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) + } catch (e) { + console.warn('Parse Failure') + _LongParam = '' + } + } + + if (_LongParam) { + _LongParam.uuid = item.uuid + resolve(_LongParam) + } else { + resolve({uuid: item.uuid, $empty: true}) + } + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + resolve({uuid: item.uuid, $empty: true}) + } + }) + }, i * 50) + }) + }) + Promise.all(defers).then(res => { + let menus = {} + res.forEach(item => { + if (item && !item.$empty) { + menus[item.uuid] = item + } + }) + + _config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components[0].action.forEach(btn => { + if (btn.OpenType === 'popview') { + if (menus[btn.uuid]) { + let mainTb = {name: '涓昏〃', uuid: Utils.getuuid(), useMSearch: 'false'} + + btn.config = { + uuid: btn.uuid, + MenuID: btn.uuid, + ParentId: tab.components[0].uuid, + MenuName: btn.label, + tables: _config.tables || [], + Template: 'CustomPage', + components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], + viewType: 'popview', + style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } + } + + btn.config.enabled = this.setEnabled(btn.config) + } else { + errors.push(tab.label + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + tab.components[0].cols.forEach(col => { + if (col.type !== 'custom') return + col.elements.forEach(btn => { + if (btn.eleType !== 'button') return + if (btn.OpenType === 'popview') { + if (menus[btn.uuid]) { + let mainTb = {name: '涓昏〃', uuid: Utils.getuuid(), useMSearch: 'false'} + + btn.config = { + uuid: btn.uuid, + MenuID: btn.uuid, + ParentId: tab.components[0].uuid, + MenuName: btn.label, + tables: _config.tables || [], + Template: 'CustomPage', + components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], + viewType: 'popview', + style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } + } + + btn.config.enabled = this.setEnabled(btn.config) + } else { + errors.push(tab.label + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + }) + }) + } else if (item.type !== 'form') { + item.action.forEach(btn => { + if (btn.OpenType === 'popview') { + if (menus[btn.uuid]) { + let mainTb = {name: '涓昏〃', uuid: Utils.getuuid(), useMSearch: 'false'} + + btn.config = { + uuid: btn.uuid, + MenuID: btn.uuid, + ParentId: item.uuid, + MenuName: btn.label, + tables: _config.tables || [], + Template: 'CustomPage', + components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], + viewType: 'popview', + style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } + } + + btn.config.enabled = this.setEnabled(btn.config) + } else { + errors.push('涓昏〃涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + item.cols.forEach(col => { + if (col.type !== 'custom') return + col.elements.forEach(btn => { + if (btn.eleType !== 'button') return + if (btn.OpenType === 'popview') { + if (menus[btn.uuid]) { + let mainTb = {name: '涓昏〃', uuid: Utils.getuuid(), useMSearch: 'false'} + + btn.config = { + uuid: btn.uuid, + MenuID: btn.uuid, + ParentId: item.uuid, + MenuName: btn.label, + tables: _config.tables || [], + Template: 'CustomPage', + components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], + viewType: 'popview', + style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } + } + + btn.config.enabled = this.setEnabled(btn.config) + } else { + errors.push('涓昏〃涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + }) + } + }) + + this.setPopForm(_resolve, _config, formActions, errors) + }) + } else { + this.setPopForm(_resolve, _config, formActions, errors) + } + } + + setEnabled = (config) => { + let enabled = true + config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (tab.components[0].errors.length > 0) { + enabled = false + } + }) + } else { + if (item.errors.length > 0) { + enabled = false + } + } + }) + + return enabled + } + + setPopForm = (_resolve, _config, formActions, errors) => { + if (formActions.length > 0) { + let defers = formActions.map((item, i) => { + return new Promise((resolve) => { + setTimeout(() => { + Api.getSystemConfig({ + func: 'sPC_Get_LongParam', + MenuID: item.origin + }).then(res => { + if (res.status) { + let _LongParam = '' + if (res.LongParam) { + try { + _LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam))) + } catch (e) { + console.warn('Parse Failure') + _LongParam = '' + } + } + + if (_LongParam) { + _LongParam.uuid = item.uuid + resolve(_LongParam) + } else { + resolve({uuid: item.uuid, $empty: true}) + } + } else { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + resolve({uuid: item.uuid, $empty: true}) + } + }) + }, i * 50) + }) + }) + Promise.all(defers).then(res => { + let menus = {} + res.forEach(item => { + if (item && !item.$empty) { + menus[item.uuid] = item + } + }) + + _config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components[0].action.forEach(btn => { + if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { + this.setTbForm(btn.config.components[0], menus, errors, tab.components[0].name + '-' + btn.label) + } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { + if (menus[btn.uuid]) { + btn.modal = { + setting: menus[btn.uuid].setting, + tables: [], + groups: [], + fields: menus[btn.uuid].fields || [] + } + } else { + errors.push(tab.label + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + tab.components[0].cols.forEach(col => { + if (col.type !== 'custom') return + col.elements.forEach(btn => { + if (btn.eleType !== 'button') return + if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { + this.setTbForm(btn.config.components[0], menus, errors, tab.components[0].name + '-' + btn.label) + } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { + if (menus[btn.uuid]) { + btn.modal = { + setting: menus[btn.uuid].setting, + tables: [], + groups: [], + fields: menus[btn.uuid].fields || [] + } + } else { + errors.push(tab.label + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + }) + }) + } else if (item.type !== 'form') { + item.action.forEach(btn => { + if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { + this.setTbForm(btn.config.components[0], menus, errors, item.name + '-' + btn.label) + } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { + if (menus[btn.uuid]) { + btn.modal = { + setting: menus[btn.uuid].setting, + tables: [], + groups: [], + fields: menus[btn.uuid].fields || [] + } + } else { + errors.push('涓昏〃涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + + item.cols.forEach(col => { + if (col.type !== 'custom') return + col.elements.forEach(btn => { + if (btn.eleType !== 'button') return + if (btn.OpenType === 'popview' && btn.config && btn.config.components[0]) { + this.setTbForm(btn.config.components[0], menus, errors, item.name + '-' + btn.label) + } else if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { + if (menus[btn.uuid]) { + btn.modal = { + setting: menus[btn.uuid].setting, + tables: [], + groups: [], + fields: menus[btn.uuid].fields || [] + } + } else { + errors.push('涓昏〃涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + }) + } + }) + + this.saveConfig(_resolve, _config, errors) + }) + } else { + this.saveConfig(_resolve, _config, errors) + } + } + + setTbForm = (item, menus, errors, name) => { + item.action.forEach(btn => { + if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { + if (menus[btn.uuid]) { + btn.modal = { + setting: menus[btn.uuid].setting, + tables: [], + groups: [], + fields: menus[btn.uuid].fields || [] + } + } else { + errors.push(name + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + item.cols.forEach(col => { + if (col.type !== 'custom') return + col.elements.forEach(btn => { + if (btn.eleType !== 'button') return + if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.funcType === 'print' && btn.execMode === 'pop')) { + if (menus[btn.uuid]) { + btn.modal = { + setting: menus[btn.uuid].setting, + tables: [], + groups: [], + fields: menus[btn.uuid].fields || [] + } + } else { + errors.push(name + '涓寜閽��' + btn.label + '銆嬮厤缃俊鎭涪澶�') + } + } + }) + }) + } + + saveConfig = (_resolve, _config, errors) => { + let err = errors.join('锛�') + let _this = this + + if (err) { + _resolve() + confirm({ + title: err + '锛岀‘瀹氬崌绾у綋鍓嶈彍鍗曞悧锛�', + content: '', + onOk() { + return new Promise(resolve => { + _this.saveNewMenu(resolve, _config) + }) + }, + onCancel() {} + }) + } else { + this.saveNewMenu(_resolve, _config) + } + } + + saveNewMenu = (_resolve, _config) => { + _config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + tab.components[0].action.forEach(btn => { + if (btn.OpenType === 'popview' && btn.config) { + btn.config.$tables = getTables(btn.config.components[0]) + } + }) + tab.components[0].cols.forEach(col => { + if (col.type !== 'custom') return + col.elements.forEach(btn => { + if (btn.eleType !== 'button') return + if (btn.OpenType === 'popview' && btn.config) { + btn.config.$tables = getTables(btn.config.components[0]) + } + }) + }) + + tab.components[0].$tables = getTables(tab.components[0]) + }) + } else { + item.$tables = getTables(item) + } + }) + + this.submitConfig(_resolve, _config) + } + + checkBtns = (card) => { + card.action.forEach(cell => { + if (cell.hidden === 'true') return + if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { + if (!cell.modal || cell.modal.fields.length === 0) { + card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`}) + } + } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) { + card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎叆鍒楁湭璁剧疆锛乣}) + } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) { + card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎嚭鍒楁湭璁剧疆锛乣}) + } + }) + + card.cols.forEach(col => { + if (col.type !== 'custom') return + + col.elements.forEach(cell => { + if (cell.hidden === 'true' || cell.eleType !== 'button') return + if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) { + if (!cell.modal || cell.modal.fields.length === 0) { + card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑琛ㄥ崟灏氭湭娣诲姞`}) + } + } else if (cell.OpenType === 'excelIn' && (!cell.verify || !cell.verify.sheet || !cell.verify.columns || cell.verify.columns.length === 0)) { + card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎叆鍒楁湭璁剧疆锛乣}) + } else if (cell.OpenType === 'excelOut' && (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0)) { + card.errors.push({ level: 0, detail: `鎸夐挳鈥�${cell.label}鈥濅腑瀵煎嚭鍒楁湭璁剧疆锛乣}) + } + }) + }) + } + + submitConfig = (_resolve, config) => { + let tbs = [] + config.components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + if (tab.components[0].$tables) { + tbs.push(...tab.components[0].$tables) + } + + this.checkBtns(tab.components[0]) + }) + } else { + if (item.$tables) { + tbs.push(...item.$tables) + } + } + }) + + let arr = [] + tbs = tbs.filter(tb => { + let _tb = tb.toLowerCase() + + if (arr.includes(_tb)) return false + arr.push(_tb) + + return true + }) + tbs.sort() + if (tbs.length && sessionStorage.getItem('mk_tb_names')) { + let names = sessionStorage.getItem('mk_tb_names') + tbs = tbs.filter(tb => names.indexOf(',' + tb.toLowerCase() + ',') > -1) + } + tbs = tbs.map(tb => `'${tb}'`).join(';') + + let key = md5(config.uuid + tbs.toLowerCase()) + + let urlparam = { + FstId: config.fstMenuId, + ParentId: config.parentId, + MenuID: config.uuid, + MenuName: config.MenuName, + MenuNo: config.MenuNo, + EasyCode: config.easyCode, + type: 'admin', + OpenType: config.OpenType, + PageParam: {Template: 'CustomPage', OpenType: 'newtab', hidden: config.hidden}, + MenuType: 'custom' + } + let url = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) + config.tbkey = key + + let param = { + func: 'sPC_TrdMenu_AddUpt', + FstID: config.fstMenuId || '', + SndID: config.parentId, + ParentID: config.parentId, + MenuID: config.uuid, + MenuNo: config.MenuNo || '', + EasyCode: config.easyCode || '', + Template: 'CustomPage', + MenuName: config.MenuName || '', + PageParam: JSON.stringify({Template: 'CustomPage', OpenType: config.OpenType, hidden: config.hidden}), + open_edition: '', + debug_md5: key, + debug_url: url, + debug_list: window.btoa(tbs), + LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))) + } + + param.LText = Utils.formatOptions(param.LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + let save = false + + new Promise(resolve => { + Api.getSystemConfig(param).then(res => { + resolve(res) + }) + }).then(res => { // 鍒犻櫎鍘熻彍鍗� + if (!res || !res.status) return res + + save = true + + return res + // if (this.delButtons.length === 0) return res + + // return Api.getSystemConfig({ + // func: 'sPC_MainMenu_Del', + // up_type: 'Y', + // MenuID: this.delButtons.join(',') + // }) + }).then(res => { + if (!res) return + + _resolve() + + if (res.status) { + delete urlparam.type + + let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) + + window.open(window.location.href.split('#')[0] + `#/menudesign/${_param}`) + } else { + Modal.warning({ + title: res.message, + okText: '鐭ラ亾浜�', + onOk: () => { + if (save) { + delete urlparam.type + + let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) + window.open(window.location.href.split('#')[0] + `#/menudesign/${_param}`) + } else { + window.location.reload() + } + } + }) + } + }) + } + + getTable = (config, newCon, errors, formActions, popActions, oldtabs) => { + let _card = { + uuid: newCon.uuid, + type: 'table', + name: newCon.name, + format: 'array', + pageable: true, + switchable: true, + search: [], + action: [], + subtype: 'normaltable', + setting: { useMSearch: 'false', sync: 'false', onload: 'true' }, + wrap: {}, + style: {}, + headerStyle: {}, + columns: [], + cols: [], + scripts: [] + } + + if (!config) { + errors.push(newCon.name + '閰嶇疆淇℃伅涓㈠け') + return _card + } + + if (oldtabs && newCon.supModule && oldtabs[newCon.supModule]) { + _card.setting.supModule = [oldtabs[newCon.supModule]] + } else { + _card.setting.supModule = ['empty'] + } + + _card.search = config.search.map(item => { + item.uuid = Utils.getuuid() + return item + }) + + let _cols = {} + let _colspan = [] + let lineMarks = [] + config.columns.forEach(col => { + if (col.type === 'colspan') { + _colspan.push(...col.subfield.split(', ')) + } + if (!col.field) return + + let _col = fromJS(col).toJS() + + if (_col.marks) { + _col.marks = [] + col.marks.forEach(m => { + if (m.signType === 'card') return + + let field = [] + field.push(m.field) + field.push(m.contrastType) + + if (m.contrastField) { + field.push(m.contrastField) + } + let color = '#1890ff' + if (m.color && m.color[1]) { + color = colorTransform[m.color[1]] + } + let signType = ['font'] + if (m.signType === 'background') { + signType = ['background'] + } else if (m.signType === 'icon') { + if (m.position === 'back') { + signType = ['iconback'] + } else { + signType = ['iconfront'] + } + signType.push(m.iconType) + signType.push(m.icon) + } + + if (m.signType === 'line') { + lineMarks.push({ + $index: lineMarks.length + 1, + uuid: Utils.getuuid(), + field: field, + color: color, + contrastValue: m.contrastValue || '', + match: m.match, + signType: ['background'] + }) + } else { + _col.marks.push({ + $index: _col.marks.length + 1, + uuid: Utils.getuuid(), + field: field, + color: color, + contrastValue: m.contrastValue || '', + match: m.match, + signType: signType + }) + } + }) + } + + _cols[col.field] = _col + }) + + config.columns.forEach(col => { + if (col.type === 'index') { + _card.cols.push(fromJS(col).toJS()) + } else if (col.field && _cols[col.field]) { + let _col = fromJS(_cols[col.field]).toJS() + + if (_colspan.includes(col.field)) { + _col.Hide = 'true' + } + + _card.cols.push(_col) + } + + if (col.type === 'colspan') { + let ucol = { + Align: col.Align, + Hide: col.Hide, + label: col.label, + marks: [], + isSub: false, + uuid: col.uuid, + blacklist: [] + } + if (col.unfold === 'true') { + ucol.type = 'colspan' + ucol.subcols = [] + + col.subfield.split(', ').forEach(sub => { + if (_cols[sub]) { + let _col = fromJS(_cols[sub]).toJS() + _col.Hide = 'false' + _col.isSub = true + _col.uuid = Utils.getuuid() + + ucol.subcols.push(_col) + } + }) + + if (ucol.subcols.length > 0) { + _card.cols.push(ucol) + } + } else { + ucol.Width = 120 + ucol.type = 'custom' + ucol.elements = [] + ucol.style = {paddingTop: '12px', paddingLeft: '8px', paddingBottom: '12px', paddingRight: '8px'} + + col.subfield.split(', ').forEach(sub => { + if (_cols[sub]) { + let _col = { + copyable: 'false', + datatype: 'dynamic', + eleType: _cols[sub].type !== 'number' ? 'text' : 'number', + field: sub, + height: '', + innerHeight: 'auto', + marks: _cols[sub].marks || null, + noValue: 'show', + prefix: _cols[sub].prefix || '', + postfix: _cols[sub].postfix || '', + style: {}, + width: 24, + uuid: Utils.getuuid() + } + + ucol.elements.push(_col) + } + }) + + if (ucol.elements.length > 0) { + _card.cols.push(ucol) + } + } + } + }) + + _card.lineMarks = lineMarks + _card.columns = [] + _card.absFields = [] + _card.cols.forEach(col => { + if (!col.field) return + if (['text', 'picture', 'video', 'textarea'].includes(col.type)) { + _card.columns.push({ + datatype: `Nvarchar(${col.fieldlength || 50})`, + field: col.field, + fieldlength: col.fieldlength || 50, + label: col.label, + type: 'text', + uuid: col.uuid + }) + } else if (col.type === 'link') { + _card.columns.push({ + datatype: `Nvarchar(${col.fieldlength || 50})`, + field: col.field, + fieldlength: col.fieldlength || 50, + label: col.label, + type: 'text', + uuid: col.uuid + }) + if (col.nameField) { + _card.columns.push({ + datatype: `Nvarchar(${col.fieldlength || 50})`, + field: col.nameField, + fieldlength: col.fieldlength || 50, + label: col.label + '(鍚嶇О)', + type: 'text', + uuid: col.uuid + 'name' + }) + } + } else if (col.type === 'number') { + _card.columns.push({ + datatype: `Decimal(18,${col.decimal || 0})`, + field: col.field, + decimal: col.decimal || 0, + label: col.label, + type: 'number', + uuid: col.uuid + }) + + if (col.format === 'abs') { + _card.absFields.push(col.field) + } + } + }) + + if (_card.absFields.length) { + _card.absFields = Array.from(new Set(_card.absFields)) + } else { + _card.absFields = null + } + + let colbtns = [] + let colors = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#E7E7EF', default: 'rgba(0, 0, 0, 0.65)' } + + let uuids = {} + config.action.forEach(btn => { + let _c = btn.class ? btn.class.replace('border-', '') : '' + let color = colors[_c] || '#1890ff' + let _btn = fromJS(btn).toJS() + + delete _btn.position + delete _btn.linkTab + + if (_btn.intertype === 'inner' && !_btn.innerFunc) { + _btn.intertype = 'system' + } + if ((_btn.intertype === 'outer' || _btn.intertype === 'custom') && !_btn.procMode) { // 鍏煎澶栭儴鍑芥暟鐩翠紶绫诲瀷 + _btn.procMode = !_btn.innerFunc ? 'none' : 'inner' + } + if (_btn.funcType === 'print' && _btn.execMode) { + _btn.OpenType = 'funcbutton' + } else if (_btn.OpenType === 'blank') { + _btn.OpenType = 'tab' + } + + this.delButtons.push(btn.uuid) + + _btn.show = 'button' + + if (_btn.execSuccess === 'equaltab') { + _btn.execSuccess = 'grid' + _btn.syncComponent = [] + + if (newCon.equalTab && oldtabs && oldtabs[newCon.equalTab]) { + _btn.syncComponent.push(oldtabs[newCon.equalTab]) + } + } else if (_btn.execSuccess === 'maingrid') { + _btn.execSuccess = 'mainline' + } + + if (_btn.execError === 'equaltab') { + _btn.execError = 'grid' + } else if (_btn.execError === 'maingrid') { + _btn.execError = 'mainline' + } + + if (_btn.popClose === 'equaltab') { + _btn.popClose = 'grid' + _btn.syncComponent = [] + + if (newCon.equalTab && oldtabs && oldtabs[newCon.equalTab]) { + _btn.syncComponent.push(oldtabs[newCon.equalTab]) + } + } else if (_btn.popClose === 'maingrid') { + _btn.popClose = 'mainline' + } + + if (_btn.OpenType === 'pop' || (_btn.OpenType === 'funcbutton' && _btn.funcType === 'print' && _btn.execMode === 'pop')) { + + formActions.push({origin: btn.uuid, uuid: _btn.uuid, name: newCon.name, label: btn.label}) + } else if (_btn.OpenType === 'popview') { + if (!popActions) return + + popActions.push({origin: btn.uuid, linkTab: btn.linkTab || '', uuid: _btn.uuid, name: newCon.name, label: btn.label}) + } else if (_btn.OpenType === 'tab') { + if (btn.tabTemplate === 'FormTab') { + errors.push(newCon.name + '涓寜閽��' + btn.label + '銆嬩笉鍦ㄦ敮鎸�') + return + } else if (!btn.linkmenu || btn.linkmenu.length !== 3) { + + errors.push(newCon.name + '涓寜閽��' + btn.label + '銆嬩笉鍦ㄦ敮鎸�') + return + } + } + + uuids[btn.uuid] = true + + if (_btn.tabType === 'CommonTable' || _btn.tabType === 'SubTable') { + _btn.tabType = 'BaseTable' + } + + if (btn.position === 'grid') { + _btn.eleType = 'button' + _btn.width = 24 + _btn.style = {color: color, backgroundColor: 'transparent', borderColor: 'transparent'} + colbtns.push(_btn) + } else { + if (btn.class === 'default') { + _btn.style = {color: 'rgba(0, 0, 0, 0.65)', backgroundColor: '#fff', borderColor: '#d9d9d9', marginRight: '15px'} + } else if (btn.class.indexOf('border') > -1) { + _btn.style = {color: color, backgroundColor: '#fff', borderColor: color, marginRight: '15px'} + } else { + _btn.style = {color: btn.class === 'gray' ? 'rgba(0, 0, 0, 0.65)' : '#fff', backgroundColor: color, borderColor: color, marginRight: '15px'} + } + _card.action.push(_btn) + } + }) + + if (colbtns.length > 0) { + _card.cols.push({ + Align: 'left', + label: '鎿嶄綔', + marks: [], + isSub: false, + uuid: Utils.getuuid(), + type: 'custom', + Width: 120, + elements: colbtns, + style: {paddingTop: '12px', paddingLeft: '8px', paddingBottom: '12px', paddingRight: '8px'} + }) + } + + let sets = ['tableName', 'interType', 'sysInterface', 'innerFunc', 'interface', 'proInterface', 'outerFunc', 'dataresource', ['queryType', 'query'], 'primaryKey', 'order', 'execute', ['laypage', 'true'], ['pageSize', 10], ['onload', 'true']] + let wraps = ['tableType', ['bordered', 'true'], 'actionfixed', ['size', 'middle'], ['selected', 'false'], ['tableMode', 'compatible'], ['mask', 'show'], ['borderColor', '#e8e8e8'], 'height', 'controlField', 'controlVal'] + + _card.scripts = config.setting.scripts || [] + + sets.forEach(n => { + if (n === 'interType') { + if (!['system', 'inner', 'outer'].includes(config.setting.interType)) { + _card.setting.interType = 'system' + } else if (config.setting.interType === 'inner' && !config.setting.innerFunc) { + _card.setting.interType = 'system' + } else { + _card.setting.interType = config.setting.interType + } + } else if (typeof(n) === 'string') { + _card.setting[n] = config.setting[n] || '' + } else { + _card.setting[n[0]] = config.setting[n[0]] || n[1] + } + }) + wraps.forEach(w => { + if (typeof(w) === 'string') { + _card.wrap[w] = config.setting[w] || '' + } else { + _card.wrap[w[0]] = config.setting[w[0]] || w[1] + } + }) + + _card.wrap.doubleClick = config.setting.doubleClick || '' + if (_card.wrap.doubleClick && !uuids[_card.wrap.doubleClick]) { + _card.wrap.doubleClick = '' + } + + _card.errors = [] + let columns = _card.columns.map(c => c.field) + if (_card.setting.interType === 'system' && _card.setting.execute !== 'false' && !_card.setting.dataresource) { + _card.errors.push({ level: 0, detail: '鏈缃暟鎹簮锛�'}) + } else if (_card.setting.interType === 'system' && _card.setting.execute === 'false' && _card.scripts.filter(script => script.status !== 'false').length === 0) { + _card.errors.push({ level: 0, detail: '鏁版嵁婧愪腑鏃犲彲鐢ㄨ剼鏈紒'}) + } else if (!_card.setting.primaryKey) { + _card.errors.push({ level: 0, detail: '鏈缃富閿紒'}) + } else if (!columns.includes(_card.setting.primaryKey)) { + _card.errors.push({ level: 0, detail: '涓婚敭宸插け鏁堬紒'}) + } else if (!_card.setting.supModule) { + _card.errors.push({ level: 0, detail: '鏈缃笂绾х粍浠讹紒'}) + } + + return _card + } + + render() { + return ( + <Button className="mk-border-purple" onClick={this.trigger}><ArrowUpOutlined /> 鍗囩骇</Button> + ) + } +} + +export default UpdateTable \ No newline at end of file diff --git a/src/templates/calendarconfig/tabcomponent/tabform/index.scss b/src/templates/formtabconfig/updatetable/index.scss similarity index 100% rename from src/templates/calendarconfig/tabcomponent/tabform/index.scss rename to src/templates/formtabconfig/updatetable/index.scss diff --git a/src/templates/treepageconfig/updatetable/index.jsx b/src/templates/treepageconfig/updatetable/index.jsx index a0ba9f4..8cb7244 100644 --- a/src/templates/treepageconfig/updatetable/index.jsx +++ b/src/templates/treepageconfig/updatetable/index.jsx @@ -111,6 +111,7 @@ interface: config.setting.interface || '', dataresource: config.setting.dataresource || '', tableName: config.setting.tableName || '', + sysInterface: config.setting.sysInterface || 'false', order: config.setting.order || '', execute: config.setting.default || 'true', primaryKey: config.setting.valueField || '', @@ -741,7 +742,7 @@ type: 'admin', OpenType: config.OpenType, PageParam: {Template: 'CustomPage', OpenType: 'newtab', hidden: config.hidden}, - MenuType: 'CustomPage' + MenuType: 'custom' } let url = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) config.tbkey = key @@ -794,7 +795,6 @@ if (res.status) { delete urlparam.type - delete urlparam.MenuType let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) @@ -807,7 +807,6 @@ onOk: () => { if (save) { delete urlparam.type - delete urlparam.MenuType let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) diff --git a/src/views/basedesign/index.jsx b/src/views/basedesign/index.jsx index bc036a1..0adc4d0 100644 --- a/src/views/basedesign/index.jsx +++ b/src/views/basedesign/index.jsx @@ -14,7 +14,6 @@ const Header = asyncComponent(() => import('@/menu/header')) const ComTableConfig = asyncLoadComponent(() => import('@/templates/comtableconfig')) const TreePageConfig = asyncLoadComponent(() => import('@/templates/treepageconfig')) -const FormTabConfig = asyncLoadComponent(() => import('@/templates/formtabconfig')) const ModalConfig = asyncLoadComponent(() => import('@/templates/modalconfig')) const SubTable = asyncLoadComponent(() => import('@/templates/subtableconfig')) @@ -229,14 +228,6 @@ tabConfig={this.state.tabConfig} btnTab={this.state.btnTab} btnTabConfig={this.state.btnTabConfig} - config={this.state.subConfig} - handleView={this.handleView} - /> : null - } - {this.state.tabview === 'FormTab' ? - <FormTabConfig - menu={this.state.editMenu} - btnTab={this.state.btnTab} config={this.state.subConfig} handleView={this.handleView} /> : null -- Gitblit v1.8.0