From 3b1c5118e37500a26021adb8a6c1c11b741d7bbc Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 03 七月 2023 17:37:52 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/components/tabview/index.jsx | 2 src/templates/zshare/editTable/index.jsx | 20 src/templates/treepageconfig/updatetable/index.jsx | 1227 ++++++++++++++++++++++++++++++++++++ src/templates/treepageconfig/updatetable/index.scss | 0 src/tabviews/custom/components/tabs/antv-tabs/index.jsx | 30 src/templates/comtableconfig/updatetable/index.jsx | 137 --- src/menu/components/tabs/antv-tabs/options.jsx | 4 src/templates/treepageconfig/index.jsx | 4 src/menu/components/calendar/index.scss | 53 + src/tabviews/custom/popview/index.jsx | 57 src/menu/components/share/actioncomponent/actionform/index.jsx | 2 src/api/index.js | 1 src/tabviews/custom/index.jsx | 57 src/tabviews/zshare/actionList/newpagebutton/index.jsx | 4 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 2 src/menu/components/calendar/options.jsx | 201 +++++ src/menu/components/calendar/index.jsx | 187 +++++ src/menu/modulesource/option.jsx | 1 18 files changed, 1,802 insertions(+), 187 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 2fbd3ee..cdea893 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -42,6 +42,7 @@ Modal.destroyAll() Modal.error({ title: response.data.message, + okText: '鐭ラ亾浜�', onOk: () => { window.GLOB.$error = false sessionStorage.clear() diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx index dfd0c2b..de4b230 100644 --- a/src/components/tabview/index.jsx +++ b/src/components/tabview/index.jsx @@ -22,6 +22,7 @@ const Iframe = asyncComponent(() => import('@/tabviews/iframe')) const RoleManage = asyncComponent(() => import('@/tabviews/rolemanage')) const FormTab = asyncComponent(() => import('@/tabviews/formtab')) +// const Calendar = asyncComponent(() => import('@/tabviews/calendar')) class TabViews extends Component { static propTpyes = { @@ -210,6 +211,7 @@ } 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 />) } } diff --git a/src/menu/components/calendar/index.jsx b/src/menu/components/calendar/index.jsx new file mode 100644 index 0000000..6daaeb0 --- /dev/null +++ b/src/menu/components/calendar/index.jsx @@ -0,0 +1,187 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' +import { Popover, message } from 'antd' +import { EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons' + +import asyncComponent from '@/utils/asyncComponent' +import asyncIconComponent from '@/utils/asyncIconComponent' +import { resetStyle, getTables, checkComponent } from '@/utils/utils-custom.js' +import MKEmitter from '@/utils/events.js' +import getWrapForm from './options' +import './index.scss' + +const SettingComponent = asyncIconComponent(() => import('@/menu/datasource')) +const NormalForm = asyncIconComponent(() => import('@/components/normalform')) +const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) +const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent')) +const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) + +class NormalCalendarComponent extends Component { + static propTpyes = { + card: PropTypes.object, + deletecomponent: PropTypes.func, + updateConfig: PropTypes.func, + } + + state = { + card: null + } + + UNSAFE_componentWillMount () { + const { card } = this.props + + if (card.isNew) { + let _card = { + uuid: card.uuid, + type: card.type, + format: 'array', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 + pageable: false, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� + switchable: false, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� + width: card.width || 24, + name: card.name, + subtype: card.subtype, + setting: { interType: 'system' }, + wrap: { title: '', name: card.name, width: card.width || 24 }, + style: { marginLeft: '0px', marginRight: '0px', marginTop: '0px', marginBottom: '0px' }, + headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, + columns: [], + scripts: [], + } + + if (card.config) { + let config = fromJS(card.config).toJS() + + _card.wrap = config.wrap + _card.wrap.name = card.name + _card.style = config.style + + _card.setting = config.setting + _card.columns = config.columns + _card.scripts = config.scripts + } + + this.updateComponent(_card) + } else { + this.setState({ + card: fromJS(card).toJS() + }) + } + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) + } + + /** + * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊锛屾竻闄ゅ揩鎹烽敭璁剧疆 + */ + componentWillUnmount () { + this.setState = () => { + return + } + } + + /** + * @description 鍗$墖琛屽灞備俊鎭洿鏂帮紙鏁版嵁婧愶紝鏍峰紡绛夛級 + */ + updateComponent = (card) => { + card.width = card.wrap.width + card.name = card.wrap.name + if (!window.GLOB.styling || !card.errors) { // 鏍峰紡淇敼鏃朵笉鍋氱瓫鏌� + card.$c_ds = true + card.$c_sc = true + + card.errors = checkComponent(card) + + if (card.errors.length === 0) { + card.$tables = getTables(card) + } + } + + this.setState({ + card: card + }) + + this.props.updateConfig(card) + } + + changeStyle = () => { + const { card } = this.state + + MKEmitter.emit('changeStyle', ['height', 'background', 'border', 'padding', 'margin', 'shadow', 'clear', 'minHeight'], card.style, this.getStyle) + } + + getStyle = (style) => { + let _card = {...this.state.card, style} + + this.updateComponent(_card) + } + + getWrapForms = () => { + const { card } = this.state + + return getWrapForm(card.wrap, card.columns) + } + + updateWrap = (res) => { + delete res.quick + + if (res.hmode) { + res.mode = res.hmode + delete res.hmode + } + + this.updateComponent({...this.state.card, wrap: res}) + } + + render() { + const { card } = this.state + + let _style = resetStyle(card.style) + + return ( + <div className="menu-calendar-edit-box" style={_style} id={card.uuid}> + <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <div className="mk-popover-control"> + <NormalForm title="鏃ュ巻璁剧疆" width={800} update={this.updateWrap} getForms={this.getWrapForms}> + <EditOutlined style={{color: '#1890ff'}} title="缂栬緫"/> + </NormalForm> + <CopyComponent type="calendar" card={card}/> + <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/> + <UserComponent config={card}/> + <DeleteOutlined className="close" title="鍒犻櫎缁勪欢" onClick={() => this.props.deletecomponent(card.uuid)} /> + <SettingComponent config={card} updateConfig={this.updateComponent} /> + </div> + } trigger="hover"> + <ToolOutlined /> + </Popover> + <NormalHeader hideSearch="true" config={card} updateComponent={this.updateComponent}/> + <div className="component-name"> + <div className="center"> + <div className="title" onDoubleClick={() => { + let oInput = document.createElement('input') + oInput.value = 'anchor' + card.uuid + document.body.appendChild(oInput) + oInput.select() + document.execCommand('Copy') + document.body.removeChild(oInput) + message.success('澶嶅埗鎴愬姛銆�') + }}>{card.name}</div> + <div className="content"> + {card.errors && card.errors.map((err, index) => { + if (err.level === 0) { + return <span key={index} className="error">{err.detail}</span> + } else { + return <span key={index} className="waring">{err.detail}锛�</span> + } + })} + </div> + </div> + </div> + </div> + ) + } +} + +export default NormalCalendarComponent \ No newline at end of file diff --git a/src/menu/components/calendar/index.scss b/src/menu/components/calendar/index.scss new file mode 100644 index 0000000..6c942d6 --- /dev/null +++ b/src/menu/components/calendar/index.scss @@ -0,0 +1,53 @@ +.menu-calendar-edit-box { + position: relative; + box-sizing: border-box; + background: #ffffff; + background-position: center center; + background-repeat: no-repeat; + background-size: cover; + min-height: 50px; + + .model-menu-card-cell-list { + flex: 1; + } + + >.anticon-tool { + position: absolute; + z-index: 2; + font-size: 16px; + right: 1px; + top: 1px; + cursor: pointer; + padding: 5px; + background: rgba(255, 255, 255, 0.55); + } + + .card-item { + overflow: hidden; + position: relative; + background-color: #ffffff; + background-position: center center; + background-repeat: no-repeat; + background-size: cover; + min-height: 20px; + } + + .card-item:hover { + box-shadow: 0px 0px 2px #1890ff; + } + + .model-menu-card-cell-list .card-detail-row > .anticon-plus { + position: absolute; + right: -30px; + font-size: 16px; + } +} +.menu-calendar-edit-box::after { + display: block; + content: ' '; + clear: both; +} +.menu-calendar-edit-box:hover { + z-index: 1; + box-shadow: 0px 0px 4px #1890ff; +} diff --git a/src/menu/components/calendar/options.jsx b/src/menu/components/calendar/options.jsx new file mode 100644 index 0000000..f9537e1 --- /dev/null +++ b/src/menu/components/calendar/options.jsx @@ -0,0 +1,201 @@ +/** + * @description Wrap琛ㄥ崟閰嶇疆淇℃伅 + */ +export default function (wrap, columns) { + let roleList = sessionStorage.getItem('sysRoles') + let appType = sessionStorage.getItem('appType') + + if (roleList) { + try { + roleList = JSON.parse(roleList) + } catch (e) { + roleList = [] + } + } else { + roleList = [] + } + + const balconyWrapForm = [ + { + type: 'text', + field: 'title', + label: '鏍囬', + initval: wrap.title || '', + required: false + }, + { + type: 'text', + field: 'name', + label: '缁勪欢鍚嶇О', + initval: wrap.name || '', + tooltip: '鐢ㄤ簬缁勪欢闂寸殑鍖哄垎銆�', + required: true + }, + { + type: 'number', + field: 'width', + label: '瀹藉害', + initval: wrap.width || 24, + tooltip: '鏍呮牸甯冨眬锛屾瘡琛岀瓑鍒嗕负24鍒椼��', + min: 1, + max: 24, + precision: 0, + required: true + }, + { + type: 'radio', + field: 'direction', + label: '杞寸嚎鏂瑰悜', + initval: wrap.direction || 'vertical', + required: false, + options: [ + {value: 'vertical', label: '绾靛悜'}, + {value: 'horizontal', label: '妯悜'}, + ], + controlFields: [ + {field: 'mode', values: ['vertical']}, + {field: 'hmode', values: ['horizontal']}, + {field: 'label', values: ['vertical']}, + {field: 'iconSize', values: ['horizontal']}, + {field: 'dotSign', values: ['horizontal']}, + ] + }, + { + type: 'radio', + field: 'mode', + label: '杞寸嚎浣嶇疆', + initval: ['left', 'alternate', 'right'].includes(wrap.mode) ? wrap.mode : 'left', + required: false, + options: [ + {value: 'left', label: '宸︿晶'}, + {value: 'alternate', label: '涓棿'}, + {value: 'right', label: '鍙充晶'}, + ] + }, + { + type: 'radio', + field: 'hmode', + label: '杞寸嚎浣嶇疆', + initval: ['up', 'down'].includes(wrap.mode) ? wrap.mode : 'up', + required: false, + options: [ + {value: 'up', label: '涓婁晶'}, + {value: 'down', label: '涓嬩晶'} + ] + }, + // { + // type: 'radio', + // field: 'reverse', + // label: '鎺掑簭', + // initval: wrap.reverse || 'false', + // required: false, + // options: [ + // {value: 'false', label: '姝e簭'}, + // {value: 'true', label: '鍊掑簭'}, + // ] + // }, + { + type: 'color', + field: 'color', + label: '鑺傜偣棰滆壊', + initval: wrap.color || '#1890ff', + tooltip: '鑺傜偣榛樿棰滆壊銆�', + required: false + }, + { + type: 'radio', + field: 'line', + label: '杩炵嚎棰滆壊', + initval: wrap.line || '', + required: false, + options: [ + {value: '', label: '榛樿'}, + {value: 'system', label: '绯荤粺鑹�'}, + ] + }, + { + type: 'radio', + field: 'dotSign', + label: '鑺傜偣娓叉煋', + initval: wrap.dotSign || 'background', + tooltip: '鑺傜偣鐨勬覆鏌撴柟寮忥紝鍦ㄨ妭鐐圭粍涓缃殑棰滆壊娓叉煋鍥炬爣杩樻槸娓叉煋鑳屾櫙鑹层��', + required: false, + options: [ + {value: 'background', label: '鑳屾櫙鑹�'}, + {value: 'icon', label: '鍥炬爣'}, + ] + }, + { + type: 'select', + field: 'iconSize', + label: '鍥炬爣澶у皬', + initval: wrap.iconSize || '', + tooltip: '鍥炬爣鍙湪鑺傜偣缁勪腑娣诲姞銆�', + required: false, + options: [ + {value: '', label: '榛樿(14px)'}, + {value: 'size16', label: '16px'}, + {value: 'size18', label: '18px'}, + {value: 'size20', label: '20px'}, + {value: 'size22', label: '22px'}, + {value: 'size24', label: '24px'}, + {value: 'adaptive', label: '鑷�傚簲'}, + ] + }, + { + type: 'select', + field: 'label', + label: '鏍囩', + initval: wrap.label || '', + tooltip: '鍦ㄥ唴瀹瑰闈㈠崟鐙睍绀恒��', + required: false, + options: columns, + forbid: !appType + }, + { + type: 'select', + field: 'node', + label: '鑺傜偣鎺у埗', + initval: wrap.node || '', + tooltip: '閫夋嫨鑷畾涔夎妭鐐圭殑鎺у埗瀛楁鍚庯紝鍦ㄨ妭鐐圭粍涓坊鍔犺妭鐐规牱寮忋��', + required: false, + options: columns + }, + { + type: 'radio', + field: 'permission', + label: '鏉冮檺楠岃瘉', + initval: wrap.permission || (!appType ? 'true' : 'false'), + required: false, + options: [ + {value: 'true', label: '鍚敤'}, + {value: 'false', label: '绂佺敤'}, + ], + forbid: sessionStorage.getItem('editMenuType') === 'popview' + }, + { + type: 'radio', + field: 'empty', + label: '绌哄�奸殣钘�', + initval: wrap.empty || 'show', + tooltip: '褰撴煡璇㈡暟鎹负绌烘椂锛岄殣钘忚缁勪欢銆�', + required: false, + skip: true, + options: [ + {value: 'show', label: '鍚�'}, + {value: 'hidden', label: '鏄�'}, + ], + }, + { + type: 'multiselect', + field: 'blacklist', + label: '榛戝悕鍗�', + initval: wrap.blacklist || [], + required: false, + options: roleList, + forbid: !!appType + }, + ] + + return balconyWrapForm +} \ No newline at end of file diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index bd8ddb5..c57b171 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -413,7 +413,7 @@ reTooltip.linkmenu = '' } else if (this.record.pageTemplate === 'billprint') { shows.push('printTemp') - reOptions.Ot = requireOptions.filter(op => ['notRequired', 'requiredSgl', 'required'].includes(op.value)) + reOptions.Ot = requireOptions } else if (this.record.pageTemplate === 'pay') { reOptions.Ot = requireOptions.filter(op => op.value === 'requiredSgl') } diff --git a/src/menu/components/tabs/antv-tabs/options.jsx b/src/menu/components/tabs/antv-tabs/options.jsx index 798a655..8654b25 100644 --- a/src/menu/components/tabs/antv-tabs/options.jsx +++ b/src/menu/components/tabs/antv-tabs/options.jsx @@ -39,7 +39,7 @@ field: 'controlVal', label: '闅愯棌鏍囪', initval: tab.controlVal || '', - tooltip: '褰撶鐢ㄥ瓧娈靛�间笌闅愯棌鏍囪鐩哥瓑鏃讹紝鏍囩椤典細闅愯棌銆傛敞锛氬涓�艰鐢ㄩ�楀彿鍒嗛殧銆�', + tooltip: '褰撶鐢ㄥ瓧娈靛�间笌闅愯棌鏍囪鐩哥瓑鏃讹紝鏍囩椤典細闅愯棌銆傛敞锛�1銆佸涓�艰鐢ㄩ�楀彿鍒嗛殧锛�2銆丂pass@鍊艰〃绀哄拷鐣ユ璁剧疆锛堝缁堟樉绀猴級锛�2銆丂pass_empty@鍊艰〃绀哄拷鐣ョ┖鍊硷紝鍗虫湭鑾峰彇涓婄骇缁勪欢淇℃伅鏃舵樉绀猴紙鍙笌鍏朵粬鍊兼嫾鎺ワ級銆�', required: false, }, { @@ -209,7 +209,7 @@ field: 'controlField', label: '绂佺敤瀛楁', initval: setting.controlField || '', - tooltip: '鐢ㄤ簬鎺у埗鏍囩闅愯棌鐨勫瓧娈碉紝鍦ㄦ爣绛句腑濉叆闅愯棌鏍囪銆�', + tooltip: '鐢ㄤ簬鎺у埗鏍囩闅愯棌鐨勫瓧娈碉紝鍦ㄦ爣绛句腑濉叆闅愯棌鏍囪銆傛敞锛氭爲褰㈢粍浠朵腑涓嶅悓灞傜骇浼氳嚜鍔ㄧ敓鎴恗k_floor锛堝眰绾у瓧娈�1銆�2銆�3...锛夈��', required: true, }, { diff --git a/src/menu/modulesource/option.jsx b/src/menu/modulesource/option.jsx index 4b50498..f077659 100644 --- a/src/menu/modulesource/option.jsx +++ b/src/menu/modulesource/option.jsx @@ -50,6 +50,7 @@ { type: 'menu', url: NormalTable, component: 'table', subtype: 'normaltable', title: '甯哥敤琛�', width: 24 }, { type: 'menu', url: NormalTable, component: 'table', subtype: 'editable', title: '琛ㄦ牸锛堝彲缂栬緫锛�', width: 24, forbid: ['billPrint'] }, { type: 'menu', url: timeline, component: 'timeline', subtype: 'timeline', title: '鏃堕棿杞�', width: 12 }, + { type: 'menu', url: timeline, component: 'calendar', subtype: 'calendar', title: '鏃ュ巻', width: 24 }, { type: 'menu', url: tree, component: 'tree', subtype: 'normaltree', title: '鏍戝舰鍒楄〃', width: 12, forbid: ['billPrint'] }, { type: 'menu', url: line, component: 'line', subtype: 'line', title: '鎶樼嚎鍥�', width: 24 }, { type: 'menu', url: bar, component: 'bar', subtype: 'bar', title: '鏌辩姸鍥�', width: 24 }, diff --git a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx index 6d8b799..63eb3e2 100644 --- a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx +++ b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx @@ -40,12 +40,15 @@ } }) _tabs.subtabs = config.subtabs.filter(tab => { - if (tab.controlVal === val) { - return false - } else if (/,/ig.test(tab.controlVal)) { - return !tab.controlVal.split(',').includes(val) - } - return true + if (tab.$pass) return true + + return !tab.controlVals.includes(val) + }) + } else { + _tabs.subtabs = config.subtabs.filter(tab => { + if (tab.$pass) return true + + return tab.controlVals.includes('@pass_empty@') }) } } @@ -90,7 +93,11 @@ if (tabs.setting.supModule === MenuID) { if (!data) { this.setState({ - tabs: {...tabs, subtabs: []} + tabs: {...tabs, subtabs: this.props.config.subtabs.filter(tab => { + if (tab.$pass) return true + + return tab.controlVals.includes('@pass_empty@') + })} }) } else { let val = '' @@ -101,12 +108,9 @@ }) this.setState({ tabs: {...tabs, subtabs: this.props.config.subtabs.filter(tab => { - if (tab.controlVal === val) { - return false - } else if (/,/ig.test(tab.controlVal)) { - return !tab.controlVal.split(',').includes(val) - } - return true + if (tab.$pass) return true + + return !tab.controlVals.includes(val) })} }) } diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index c34c160..900ef50 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -359,6 +359,13 @@ return false } + if (item.setting.supModule) { + let pid = item.setting.supModule.pop() + item.setting.supModule = pid || '' + } else { + item.setting.supModule = '' + } + item.subtabs = item.subtabs.filter(tab => { if ( tab.blacklist && tab.blacklist.length > 0 && @@ -368,35 +375,37 @@ } else if (tab.hide === 'true') { return false } + + if (item.setting.supModule) { + if (tab.controlVal === '@pass@') { + tab.$pass = true + } else if (/,/ig.test(tab.controlVal)) { + tab.controlVals = tab.controlVal.split(',') + } else { + tab.controlVals = [(tab.controlVal || '')] + } + } + return true }) if (item.setting.supModule) { - let pid = item.setting.supModule.pop() - item.setting.supModule = pid || '' + item.setting.controlField = item.setting.controlField.toLowerCase() - if (item.setting.supModule) { - item.setting.controlField = item.setting.controlField.toLowerCase() - - if (item.setting.supModule === 'preview') { - item.setting.supModule = '' - let val = '' - Object.keys(urlparam).forEach(key => { - if (key.toLowerCase() === item.setting.controlField) { - val = urlparam[key] - } - }) - - item.subtabs = item.subtabs.filter(tab => { - if (tab.controlVal === val) { - return false - } else if (/,/ig.test(tab.controlVal)) { - return !tab.controlVal.split(',').includes(val) - } - - return true - }) - } + if (item.setting.supModule === 'preview') { + item.setting.supModule = '' + let val = '' + Object.keys(urlparam).forEach(key => { + if (key.toLowerCase() === item.setting.controlField) { + val = urlparam[key] + } + }) + + item.subtabs = item.subtabs.filter(tab => { + if (tab.$pass) return true + + return !tab.controlVals.includes(val) + }) } } diff --git a/src/tabviews/custom/popview/index.jsx b/src/tabviews/custom/popview/index.jsx index 67bdd49..ca59201 100644 --- a/src/tabviews/custom/popview/index.jsx +++ b/src/tabviews/custom/popview/index.jsx @@ -201,6 +201,13 @@ return false } + if (item.setting.supModule) { + let pid = item.setting.supModule.pop() + item.setting.supModule = pid || '' + } else { + item.setting.supModule = '' + } + item.subtabs = item.subtabs.filter(tab => { if ( tab.blacklist && tab.blacklist.length > 0 && @@ -210,35 +217,37 @@ } else if (tab.hide === 'true') { return false } + + if (item.setting.supModule) { + if (tab.controlVal === '@pass@') { + tab.$pass = true + } else if (/,/ig.test(tab.controlVal)) { + tab.controlVals = tab.controlVal.split(',') + } else { + tab.controlVals = [(tab.controlVal || '')] + } + } + return true }) if (item.setting.supModule) { - let pid = item.setting.supModule.pop() - item.setting.supModule = pid || '' + item.setting.controlField = item.setting.controlField.toLowerCase() - if (item.setting.supModule) { - item.setting.controlField = item.setting.controlField.toLowerCase() - - if (item.setting.supModule === 'preview') { - item.setting.supModule = '' - let val = '' - Object.keys(urlparam).forEach(key => { - if (key.toLowerCase() === item.setting.controlField) { - val = urlparam[key] - } - }) - - item.subtabs = item.subtabs.filter(tab => { - if (tab.controlVal === val) { - return false - } else if (/,/ig.test(tab.controlVal)) { - return !tab.controlVal.split(',').includes(val) - } - - return true - }) - } + if (item.setting.supModule === 'preview') { + item.setting.supModule = '' + let val = '' + Object.keys(urlparam).forEach(key => { + if (key.toLowerCase() === item.setting.controlField) { + val = urlparam[key] + } + }) + + item.subtabs = item.subtabs.filter(tab => { + if (tab.$pass) return true + + return !tab.controlVals.includes(val) + }) } } diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx index c8f8539..93c97c4 100644 --- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx +++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx @@ -161,6 +161,10 @@ let url = '#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: _id, tempId: btn.printTemp, dataM: sessionStorage.getItem('dataM') }))) window.open(url) }) + } else if (btn.Ot === 'requiredOnce' && data && data.length > 0) { + Id = data.map(item => item.$$uuid).filter(Boolean).join(',') + + window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, dataM: sessionStorage.getItem('dataM') })))) } else { window.open('#/billprint/' + window.btoa(window.encodeURIComponent(JSON.stringify({ id: Id, tempId: btn.printTemp, dataM: sessionStorage.getItem('dataM') })))) } diff --git a/src/templates/comtableconfig/updatetable/index.jsx b/src/templates/comtableconfig/updatetable/index.jsx index 82d0052..299a683 100644 --- a/src/templates/comtableconfig/updatetable/index.jsx +++ b/src/templates/comtableconfig/updatetable/index.jsx @@ -87,14 +87,13 @@ let formActions = [] let popActions = [] let errors = [] - let formTabs = [] let mainTb = {name: '涓昏〃', uuid: Utils.getuuid(), useMSearch: 'false', isMain: true} let oldtabs = { mainTable: mainTb.uuid } - let tbl = this.getTable(config, mainTb, errors, formActions, formTabs, popActions, oldtabs) + let tbl = this.getTable(config, mainTb, errors, formActions, popActions, oldtabs) if (config.autoMatic && config.autoMatic.enable === 'true') { if (tbl.action.filter(item => item.uuid === config.autoMatic.action && (['pop', 'prompt', 'exec'].includes(item.OpenType) || (item.OpenType === 'funcbutton' && item.funcType === 'print'))).length === 0) { @@ -191,7 +190,7 @@ _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, formTabs, popActions, oldtabs) + tab.components[0] = this.getTable(menus[tab.components[0].linkTab], tab.components[0], errors, formActions, popActions, oldtabs) return tab }) @@ -199,14 +198,14 @@ return item }) - this.setPopView(_resolve, _config, formActions, formTabs, popActions, errors) + this.setPopView(_resolve, _config, formActions, popActions, errors) }) } else { - this.setPopView(_resolve, _config, formActions, formTabs, popActions, errors) + this.setPopView(_resolve, _config, formActions, popActions, errors) } } - setPopView = (_resolve, _config, formActions, formTabs, popActions, errors) => { + setPopView = (_resolve, _config, formActions, popActions, errors) => { if (popActions.length > 0) { let defers = popActions.map((item, i) => { return new Promise((resolve) => { @@ -267,7 +266,7 @@ MenuName: btn.label, tables: _config.tables || [], Template: 'BaseTable', - components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions, formTabs)], + components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], viewType: 'popview', style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } } @@ -293,7 +292,7 @@ MenuName: btn.label, tables: _config.tables || [], Template: 'BaseTable', - components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions, formTabs)], + components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], viewType: 'popview', style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } } @@ -319,7 +318,7 @@ MenuName: btn.label, tables: _config.tables || [], Template: 'BaseTable', - components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions, formTabs)], + components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], viewType: 'popview', style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } } @@ -345,7 +344,7 @@ MenuName: btn.label, tables: _config.tables || [], Template: 'BaseTable', - components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions, formTabs)], + components: [this.getTable(menus[btn.uuid], mainTb, errors, formActions)], viewType: 'popview', style: { backgroundColor: '#ffffff', backgroundImage: '', paddingTop: '16px', paddingBottom: '40px', paddingLeft: '16px', paddingRight: '16px' } } @@ -360,10 +359,10 @@ } }) - this.setPopForm(_resolve, _config, formActions, formTabs, errors) + this.setPopForm(_resolve, _config, formActions, errors) }) } else { - this.setPopForm(_resolve, _config, formActions, formTabs, errors) + this.setPopForm(_resolve, _config, formActions, errors) } } @@ -386,7 +385,7 @@ return enabled } - setPopForm = (_resolve, _config, formActions, formTabs, errors) => { + setPopForm = (_resolve, _config, formActions, errors) => { if (formActions.length > 0) { let defers = formActions.map((item, i) => { return new Promise((resolve) => { @@ -512,10 +511,10 @@ } }) - this.saveConfig(_resolve, _config, errors, formTabs) + this.saveConfig(_resolve, _config, errors) }) } else { - this.saveConfig(_resolve, _config, errors, formTabs) + this.saveConfig(_resolve, _config, errors) } } @@ -554,7 +553,7 @@ }) } - saveConfig = (_resolve, _config, errors, formTabs) => { + saveConfig = (_resolve, _config, errors) => { let err = errors.join('锛�') let _this = this @@ -565,17 +564,17 @@ content: '', onOk() { return new Promise(resolve => { - _this.saveNewMenu(resolve, _config, formTabs) + _this.saveNewMenu(resolve, _config) }) }, onCancel() {} }) } else { - this.saveNewMenu(_resolve, _config, formTabs) + this.saveNewMenu(_resolve, _config) } } - saveNewMenu = (_resolve, _config, formTabs) => { + saveNewMenu = (_resolve, _config) => { _config.components.forEach(item => { if (item.type === 'tabs') { item.subtabs.forEach(tab => { @@ -616,82 +615,7 @@ } }) - // if (formTabs.length > 0) { - // this.transformTabs(_resolve, _config, formTabs) - // } else { - this.submitConfig(_resolve, _config) - // } - } - - transformTabs = (_resolve, _config, formTabs) => { - let tab = formTabs.shift() - - Api.getSystemConfig({ - func: 'sPC_Get_LongParam', - MenuID: tab.uuid - }).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.type === 'FormTab' || _LongParam.Template === 'FormTab') && _LongParam.enabled) { - if (!_LongParam.tabgroups) { - _LongParam.tabgroups = [] - } else if (typeof(_LongParam.tabgroups[0]) === 'string') { - let _tabgroups = [] - _LongParam.tabgroups.forEach(groupId => { - let _group = { - uuid: groupId, - sublist: fromJS(_LongParam[groupId]).toJS() - } - - delete _LongParam[groupId] - - _tabgroups.push(_group) - }) - - _LongParam.tabgroups = _tabgroups - } - - _LongParam.tabgroups = _LongParam.tabgroups.filter(group => group.sublist.length > 0) - - _LongParam.tabgroups.forEach(group => { - group.sublist = group.sublist.map(tab => { - if (tab.supMenu === 'mainTable') { - tab.supMenu = '' - } - return tab - }) - }) - - _LongParam.action = _LongParam.action.map(item => { - if (item.intertype === 'inner' && !item.innerFunc) { - item.intertype = 'system' - } - return item - }) - - delete _LongParam.funcs - delete _LongParam.tables - } else { - _config.components[0].action = _config.components[0].action.filter(btn => btn.uuid !== tab.uuid) - } - } else { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - _resolve() - } - }) + this.submitConfig(_resolve, _config) } checkBtns = (card) => { @@ -854,7 +778,7 @@ }) } - getTable = (config, newCon, errors, formActions, formTabs, popActions, oldtabs) => { + getTable = (config, newCon, errors, formActions, popActions, oldtabs) => { let _card = { uuid: newCon.uuid, type: 'table', @@ -1155,27 +1079,6 @@ if (btn.tabTemplate === 'FormTab') { errors.push(newCon.name + '涓寜閽��' + btn.label + '銆嬩笉鍦ㄦ敮鎸�') return - // if (newCon.isMain !== true) { - // errors.push(newCon.name + '涓寜閽��' + btn.label + '銆嬩笉鍦ㄦ敮鎸�') - // return - // } - - // delete _btn.tabTemplate - - // _btn.MenuID = 'tab' + md5(btn.uuid).substr(3) - // _btn.MenuName = this.baseMsg.MenuName + '-' + btn.label - // _btn.MenuNo = this.baseMsg.MenuNo + '_' + _btn.MenuID.substr(-4).toUpperCase() - // _btn.hidden = _btn.hidden || 'false' - // _btn.tabType = 'CustomPage' - // _btn.linkmenu = [this.baseMsg.fstMenuId, this.baseMsg.parentId, _btn.MenuID] - - // let _tab = {...btn} - - // _tab.MenuID = _btn.MenuID - // _tab.MenuNo = _btn.MenuNo - // _tab.MenuName = _btn.MenuName - - // formTabs.push(_tab) } else if (!btn.linkmenu || btn.linkmenu.length !== 3) { errors.push(newCon.name + '涓寜閽��' + btn.label + '銆嬩笉鍦ㄦ敮鎸�') diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index a3460ed..32de2fd 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -839,7 +839,7 @@ 娓呯┖Excel鍒� </Button> <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆�</Col> - <EditTable actions={['edit', 'move', 'copy', 'del']} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> + <EditTable actions={['edit', 'move', 'copy', 'del', 'extra:required:鏄惁蹇呭~']} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/> </TabPane> {card.intertype === 'system' ? <TabPane tab={ <span> diff --git a/src/templates/treepageconfig/index.jsx b/src/templates/treepageconfig/index.jsx index f5c1eba..d71b891 100644 --- a/src/templates/treepageconfig/index.jsx +++ b/src/templates/treepageconfig/index.jsx @@ -19,6 +19,8 @@ const { Panel } = Collapse const { confirm } = Modal const { TreeNode } = Tree + +const UpdateTable = asyncComponent(() => import('./updatetable')) const TreeSettingComponent = asyncComponent(() => import('@/templates/sharecomponent/treesettingcomponent')) const TabsComponent = asyncComponent(() => import('@/templates/sharecomponent/tabscomponent')) @@ -68,6 +70,7 @@ _config.MenuName = menu.MenuName || '' _config.MenuNo = menu.MenuNo || '' _config.OpenType = menu.PageParam ? menu.PageParam.OpenType : '' + _config.MenuID = menu.MenuID || '' // 閰嶇疆榛樿鍊硷紝鍏煎 _config.Template = 'TreePage' @@ -715,6 +718,7 @@ </div> } bordered={false} extra={ <div> + <UpdateTable config={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> diff --git a/src/templates/treepageconfig/updatetable/index.jsx b/src/templates/treepageconfig/updatetable/index.jsx new file mode 100644 index 0000000..a0ba9f4 --- /dev/null +++ b/src/templates/treepageconfig/updatetable/index.jsx @@ -0,0 +1,1227 @@ +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 config = fromJS(this.props.config).toJS() + this.delButtons = [] + this.baseMsg = { + fstMenuId: config.fstMenuId, + parentId: config.ParentId, + MenuName: config.MenuName, + MenuNo: config.MenuNo, + } + + let _config = { + version: 1.0, + uuid: config.MenuID, + MenuID: config.MenuID, + fstMenuId: config.fstMenuId, + parentId: config.ParentId, + Template: 'CustomPage', + easyCode: config.easyCode, + enabled: false, + MenuName: config.MenuName, + MenuNo: config.MenuNo, + OpenType: 'newtab', + tables: config.tables || [], + urlFields: config.urlFields || [], + hidden: config.hidden || 'false', + Remark: config.Remark || '', + components: [], + viewType: 'menu', + style: { backgroundColor: '#ffffff', paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px'}, + } + + let formActions = [] + let popActions = [] + let errors = [] + + let mainTr = { + uuid: Utils.getuuid(), + type: 'tree', + format: 'array', // 缁勪欢灞炴�� - 鏁版嵁鏍煎紡 + pageable: false, // 缁勪欢灞炴�� - 鏄惁鍙垎椤� + switchable: true, // 缁勪欢灞炴�� - 鏁版嵁鏄惁鍙垏鎹� + width: config.setting.width || 5, + name: config.setting.title || '缁撴瀯鏍�', + subtype: 'normaltree', + setting: {}, + wrap: { name: config.setting.title || '缁撴瀯鏍�', title: config.setting.title || '', width: config.setting.width || 5, showIcon: config.setting.showIcon || 'false', showLine: config.setting.showLine || 'false', searchable: config.setting.searchable || 'false' }, + style: { marginLeft: '8px', marginRight: '8px', marginTop: '8px', marginBottom: '8px' }, + headerStyle: { fontSize: '16px', borderBottomWidth: '1px', borderBottomColor: '#e8e8e8' }, + columns: [], + scripts: [], + action: [], + } + + mainTr.setting = { + interType: config.setting.interType || 'system', + innerFunc: config.setting.innerFunc || '', + interface: config.setting.interface || '', + dataresource: config.setting.dataresource || '', + tableName: config.setting.tableName || '', + order: config.setting.order || '', + execute: config.setting.default || 'true', + primaryKey: config.setting.valueField || '', + supModule: ['empty'], + sync: 'false', + onload: 'true' + } + + mainTr.wrap.valueField = config.setting.valueField || '' + mainTr.wrap.labelField = config.setting.labelField || '' + mainTr.wrap.parentField = config.setting.parentField || '' + mainTr.wrap.mark = config.setting.mark || '' + + mainTr.scripts = config.setting.scripts || [] + + let fields = [mainTr.wrap.valueField, mainTr.wrap.labelField, mainTr.wrap.parentField] + + fields.forEach(col => { + mainTr.columns.push({ + datatype: `Nvarchar(50)`, + field: col, + fieldlength: 50, + label: col, + type: 'text', + uuid: Utils.getuuid() + }) + }) + + let oldtabs = { + mainTable: mainTr.uuid + } + + _config.components.push(mainTr) + + 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 - mainTr.width, + setting: {supModule: [mainTr.uuid], controlField: 'mk_floor', name: '鏍囩缁�' + (i + 1), width: 24 - mainTr.width, position: 'top'}, + style: {paddingTop: '10px'}, + subtabs: m.sublist.map(n => { + let level = '' + if (n.level === 0) { + level = '@pass_empty@,1,2,3,4,5' + } else if (!n.level) { + level = '@pass@' + } else { + if (n.level === 1) { + level = '2,3,4,5' + } else if (n.level === 2) { + level = '1,3,4,5' + } else if (n.level === 3) { + level = '1,2,4,5' + } else if (n.level === 4) { + level = '1,2,3,5' + } else if (n.level === 5) { + level = '1,2,3,4' + } + } + + let tab = { uuid: Utils.getuuid(), controlVal: level, 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 !== 'tree') { + 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 !== 'tree') { + 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: 'CustomPage' + } + 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 + localStorage.setItem('menuUpdate', new Date().getTime() + ',' + config.uuid) + + 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 + delete urlparam.MenuType + + let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) + + window.history.replaceState(null, null, window.location.href.split('#')[0] + `#/menudesign/${_param}`) + window.location.reload() + } else { + Modal.warning({ + title: res.message, + okText: '鐭ラ亾浜�', + onOk: () => { + if (save) { + delete urlparam.type + delete urlparam.MenuType + + let _param = window.btoa(window.encodeURIComponent(JSON.stringify(urlparam))) + + window.history.replaceState(null, null, window.location.href.split('#')[0] + `#/menudesign/${_param}`) + window.location.reload() + } 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/treepageconfig/updatetable/index.scss b/src/templates/treepageconfig/updatetable/index.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/templates/treepageconfig/updatetable/index.scss diff --git a/src/templates/zshare/editTable/index.jsx b/src/templates/zshare/editTable/index.jsx index ad29e43..36ab937 100644 --- a/src/templates/zshare/editTable/index.jsx +++ b/src/templates/zshare/editTable/index.jsx @@ -180,6 +180,15 @@ const { data, actions } = this.props let columns = fromJS(this.props.columns).toJS() let operation = null + let extra = null + + if (actions) { + actions.forEach(item => { + if (/^extra/.test(item)) { + extra = item.split(':') + } + }) + } if (actions && (actions.includes('edit') || actions.includes('copy') || actions.includes('del'))) { let _operation = null @@ -217,9 +226,10 @@ </div> ) : ( <div className={'edit-operation-btn' + (editingKey !== '' ? ' disabled' : '')} style={{minWidth: '110px', whiteSpace: 'nowrap'}}> - {actions.includes('edit') ? <span className="primary" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><EditOutlined /></span> : null} - {actions.includes('copy') ? <span className="copy" onClick={() => {editingKey === '' && this.copy(record)}}><CopyOutlined /></span> : null} - {actions.includes('status') ? <span className="status" onClick={() => {editingKey === '' && this.handleStatus(record)}}><SwapOutlined /></span> : null} + {actions.includes('edit') ? <span className="primary" title="缂栬緫" onClick={() => {editingKey === '' && this.edit(record.uuid)}}><EditOutlined /></span> : null} + {extra ? <span className="status" title={extra[2]} onClick={() => {editingKey === '' && this.handleStatus(record, extra[1])}}><SwapOutlined /></span> : null} + {actions.includes('status') ? <span className="status" title="鏄惁鍚敤" onClick={() => {editingKey === '' && this.handleStatus(record, 'status')}}><SwapOutlined /></span> : null} + {actions.includes('copy') ? <span className="copy" title="澶嶅埗" onClick={() => {editingKey === '' && this.copy(record)}}><CopyOutlined /></span> : null} {actions.includes('del') && editingKey === '' ? <Popconfirm overlayClassName="popover-confirm" title="纭畾鍒犻櫎鍚�?" @@ -474,10 +484,10 @@ message.success('绮樿创鎴愬姛銆�') } - handleStatus = (record) => { + handleStatus = (record, type) => { const { data } = this.state - record.status = record.status === 'false' ? 'true' : 'false' + record[type] = record[type] === 'false' ? 'true' : 'false' let newData = data.map(item => { if (record.uuid === item.uuid) return record -- Gitblit v1.8.0