From 9a11e62adeb8d435b52a361eb62d5b59e1deef2a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 23 五月 2024 21:14:50 +0800 Subject: [PATCH] 2024-05-23 --- src/menu/components/form/simple-form/index.scss | 12 src/menu/modalconfig/formfork/index.scss | 14 src/templates/zshare/editTable/index.jsx | 2 src/menu/components/table/edit-table/columns/tableIn/index.jsx | 88 +++ src/components/header/index.jsx | 2 src/menu/components/form/tab-form/index.scss | 8 public/options.json | 1 src/menu/components/form/simple-form/index.jsx | 85 -- src/templates/modalconfig/index.jsx | 80 --- src/api/index.js | 4 src/tabviews/custom/components/module/invoice/index.jsx | 20 src/menu/components/form/step-form/index.scss | 8 src/mob/modalconfig/index.jsx | 60 -- src/assets/css/design.scss | 24 + public/README.txt | 1 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 89 ++++ src/utils/utils.js | 71 +++ src/index.js | 23 + src/menu/components/form/step-form/index.jsx | 86 --- src/templates/zshare/formconfig.jsx | 65 ++ src/menu/components/form/tab-form/index.jsx | 85 -- src/menu/modalconfig/formfork/index.jsx | 241 ++++++++++ src/templates/zshare/verifycard/index.jsx | 4 src/menu/modalconfig/index.scss | 20 src/menu/modalconfig/index.jsx | 92 --- src/menu/debug/index.jsx | 82 +++ src/views/login/index.jsx | 13 27 files changed, 815 insertions(+), 465 deletions(-) diff --git a/public/README.txt b/public/README.txt index fa1cceb..6cbdae7 100644 --- a/public/README.txt +++ b/public/README.txt @@ -14,6 +14,7 @@ nginx -- 鏄惁寮�鍚簡nginx鏈嶅姟锛屽�间负 true 鏃跺紑鍚紝濡傞渶浣跨敤寰俊妯℃澘娑堟伅绛夋湇鍔★紝璇峰厛璁剧疆nginx鏈嶅姟骞跺紑鍚閰嶇疆 debugger -- 鍊间负 true 鏃跺紑鍚皟璇曟ā寮忥紝寮�鍚悗绉诲姩绔瓙搴旂敤涓細鏈夋帶鍒跺彴 licenseKey -- 璁稿彲瀵嗛挜锛屽湪鍐呴儴缃戠粶涓娇鐢ㄧ郴缁熸椂锛屼細璺宠繃epc楠岃瘉 +storeKey -- 鐢靛瓙妗f鏈湴鎺堟潈鐮侊紝浣跨敤鏈湴璁稿彲瀵嗛挜鏃舵湁鏁� probation -- 璇曠敤鏈燂紙YYYY-MM-DD锛夛紝鍦ㄦ寮忕郴缁熶腑锛岃瘯鐢ㄦ湡鍐呰皟鐢ㄧ郴缁熸帴鍙g殑鑴氭湰浼氳褰曚笅鏉� transfer -- 鏄惁浣跨敤杞帴鍙o紝浣跨敤杞帴鍙f椂璇疯缃负 true, 浣跨敤杞帴鍙f椂锛屽閮ㄦ帴鍙h皟鐢ㄥ墠涓嶄細鍋氱櫥褰曢獙璇� keepPassword -- 璁颁綇瀵嗙爜锛岄粯璁ゅ紑鍚紝褰撳�间负 false 鏃剁鐢� diff --git a/public/options.json b/public/options.json index 33a2f80..ccd6826 100644 --- a/public/options.json +++ b/public/options.json @@ -14,6 +14,7 @@ "nginx": "true", "debugger": false, "licenseKey": "", + "storeKey": "", "probation": "", "transfer": "false", "keepPassword": "true", diff --git a/src/api/index.js b/src/api/index.js index bd49113..f1c531d 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -865,8 +865,8 @@ if (script) { try { // eslint-disable-next-line - let func = new Function('axios', 'Api', 'param', 'position', 'systemType', script) - let promise = func(axios, this, param, position, window.GLOB.systemType) + let func = new Function('axios', 'Api', 'param', 'position', 'systemType', 'notification', script) + let promise = func(axios, this, param, position, window.GLOB.systemType, notification) if (promise instanceof Promise) { return promise diff --git a/src/assets/css/design.scss b/src/assets/css/design.scss index e7a8ac6..c252031 100644 --- a/src/assets/css/design.scss +++ b/src/assets/css/design.scss @@ -110,3 +110,27 @@ } } +// 琛ㄥ崟宸ュ叿 +.mk-form-tool { + float: right; + padding-right: 15px; + .anticon { + margin-right: 15px; + font-size: 16px; + cursor: pointer!important; + position: relative; + top: 2px; + } + .anticon-copy { + color: #26C281; + } + .anticon-swap { + color: #1890ff; + } + .anticon-fork { + color: purple; + } + .anticon-delete { + color: #f5222d; + } +} diff --git a/src/components/header/index.jsx b/src/components/header/index.jsx index 5697adb..1a8b396 100644 --- a/src/components/header/index.jsx +++ b/src/components/header/index.jsx @@ -578,6 +578,8 @@ } else { Api.updateAppVersion() Api.delCacheConfig('all') + localStorage.removeItem(window.location.href.split('#')[0] + 'AuthCode') + setTimeout(() => { notification.success({ top: 92, diff --git a/src/index.js b/src/index.js index 2b532b4..b6c7c93 100644 --- a/src/index.js +++ b/src/index.js @@ -254,6 +254,29 @@ let lang = localStorage.getItem(_href + 'lang') || (config.defaultLang !== 'en-US' ? 'zh-CN' : 'en-US') sessionStorage.setItem('lang', lang) + if (localStorage.getItem(_href + 'files') === md5(_href + 'files')) { + let d = localStorage.getItem(_href + 'filesDate') + + GLOB.storeFiles = true + GLOB.storeDate = Math.ceil((new Date(d).getTime() - new Date().getTime()) / 86400000) + } else if (GLOB.licenseKey && config.storeKey && config.storeKey.length === 16) { + let d = config.storeKey.slice(0, 8) + let key = config.storeKey.slice(8) + let _key = GLOB.appId + GLOB.appkey + 'e_files_key' + _key = md5(_key.toLowerCase()) + _key = _key.toUpperCase() + _key = _key.slice(-8) + + if (key === _key) { + GLOB.storeFiles = true + + let trans = {A:0, B:1, C:2, D:3, E:4, F:5, G:6, H:7, I:8, J:9} + d = d.split('').map(k => trans[k]).join('') + d = d.slice(0, 4) + '-' + d.slice(4, 6) + '-' + d.slice(6) + GLOB.storeDate = Math.ceil((new Date(d).getTime() - new Date().getTime()) / 86400000) + } + } + GLOB.mkActions = {} // 鎸夐挳鏉冮檺闆� Object.defineProperty(GLOB, 'appId', { diff --git a/src/menu/components/form/simple-form/index.jsx b/src/menu/components/form/simple-form/index.jsx index 974b624..245b90b 100644 --- a/src/menu/components/form/simple-form/index.jsx +++ b/src/menu/components/form/simple-form/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Popover, Modal, Button, Switch, message } from 'antd' -import { PlusOutlined, SettingOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons' +import { PlusOutlined, SettingOutlined, EditOutlined, ToolOutlined, DeleteOutlined, SwapOutlined, FontColorsOutlined } from '@ant-design/icons' import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' @@ -19,6 +19,7 @@ const CardComponent = asyncComponent(() => import('@/templates/modalconfig/dragelement')) const MobCardComponent = asyncComponent(() => import('@/mob/components/formdragelement')) const FormAction = asyncComponent(() => import('../formaction')) +// const FormFork = asyncComponent(() => import('@/menu/modalconfig/formfork')) const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) const PasteForms = asyncIconComponent(() => import('@/menu/components/share/pasteforms')) @@ -346,69 +347,13 @@ */ handleForm = (_item) => { const { card } = this.state + let _form = fromJS(_item).toJS() - let _inputfields = [] - let _tabfields = [] - let _linkableFields = [] - let _linksupFields = [] - - card.subcards[0].fields.forEach((item, i) => { - if (!item.field || _form.field === item.field) return - - if (['text', 'number', 'textarea', 'select'].includes(item.type)) { - _inputfields.push({ - field: item.field, - label: item.label - }) - } - if (item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { - _tabfields.push({ - field: item.field, - label: item.label - }) - } - - if (['switch', 'check', 'popSelect'].includes(item.type)) { - _linksupFields.push({ - field: item.field, - label: item.label - }) - } - - if (!['select', 'link', 'radio', 'checkcard', 'multiselect'].includes(item.type)) return - - _linksupFields.push({ - field: item.field, - label: item.label - }) - - if (item.type === 'multiselect' || (item.type === 'checkcard' && item.multiple === 'true')) return - - _linkableFields.push({ - field: item.field, - label: item.label + '-琛ㄥ崟' - }) - }) - - let _fields = _linkableFields.map(cell => cell.field) - card.columns.forEach(col => { - if (col.field && !_fields.includes(col.field)) { - _linkableFields.push({ - field: col.field, - label: col.label + '-鏄剧ず鍒�' - }) - } - }) - - if (_form.linkSubField && _form.linkSubField.length > 0) { - let fields = _inputfields.map(item => item.field) - _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item)) - } this.setState({ visible: true, editform: _form, - formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, card.columns) + formlist: getModalForm(_form, card.subcards[0].fields, card.columns) }) } @@ -605,12 +550,22 @@ <div className={`form-area mk-${card.wrap.formStyle || ''}`}> <PlusOutlined className="plus" title="娣诲姞琛ㄥ崟" onClick={this.addForm}/> <FieldsComponent config={card.subcards[0]} type="form" plusFields={this.plusFields} /> - <span style={{color: 'red', marginLeft: '30px', cursor: 'pointer'}} onClick={this.clearGroup}>娓呯┖</span> - <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button> : null} - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2鍒�</Button> : null} - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(3)}>3鍒�</Button> : null} - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(4)}>4鍒�</Button> : null} + <div className="mk-form-tool"> + <DeleteOutlined title="娓呯┖" onClick={this.clearGroup} /> + {appType !== 'mob' ? <Popover title="鍒囨崲甯冨眬" overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(1)}>1鍒�</Button> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(2)}>2鍒�</Button> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(3)}>3鍒�</Button> + <Button onClick={() => this.changecols(4)}>4鍒�</Button> + </> + } trigger="hover"> + <SwapOutlined /> + </Popover> : null} + {/* <FormFork forms={card.subcards[0].fields}/> */} + {/* <CopyOutlined title="澶嶅埗" onClick={this.triggerCopy} /> */} + <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> + </div> <div style={{clear: 'both'}}></div> {appType !== 'mob' ? <CardComponent list={card.subcards[0].fields} diff --git a/src/menu/components/form/simple-form/index.scss b/src/menu/components/form/simple-form/index.scss index 5911202..2615482 100644 --- a/src/menu/components/form/simple-form/index.scss +++ b/src/menu/components/form/simple-form/index.scss @@ -34,14 +34,6 @@ cursor: pointer; padding: 4px 10px; } - >button { - float: right; - margin-right: 10px; - } - >.mk-cols-change { - height: 24px; - padding: 0 10px; - } >.quickly-add { display: inline-block; margin-left: 10px; @@ -78,12 +70,12 @@ // } // } } -.menu-normal-form-edit-box::after { +.menu-simple-form-edit-box::after { display: block; content: ' '; clear: both; } -.menu-normal-form-edit-box:hover { +.menu-simple-form-edit-box:hover { z-index: 1; box-shadow: 0px 0px 4px #1890ff; } diff --git a/src/menu/components/form/step-form/index.jsx b/src/menu/components/form/step-form/index.jsx index 700588a..82463e1 100644 --- a/src/menu/components/form/step-form/index.jsx +++ b/src/menu/components/form/step-form/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Popover, Modal, Button, Switch, notification, message } from 'antd' -import { PlusOutlined, SettingOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons' +import { PlusOutlined, SettingOutlined, EditOutlined, ToolOutlined, DeleteOutlined, SwapOutlined, FontColorsOutlined } from '@ant-design/icons' import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' @@ -20,6 +20,7 @@ const MobCardComponent = asyncComponent(() => import('@/mob/components/formdragelement')) const FormTitle = asyncComponent(() => import('../dragtitle')) const FormAction = asyncComponent(() => import('../formaction')) +// const FormFork = asyncComponent(() => import('@/menu/modalconfig/formfork')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) @@ -447,70 +448,13 @@ */ handleForm = (_item) => { const { card, group } = this.state + let _form = fromJS(_item).toJS() - let _inputfields = [] - let _tabfields = [] - let _linkableFields = [] - let _linksupFields = [] - - group.fields.forEach((item, i) => { - if (!item.field || _form.field === item.field) return - - if (['text', 'number', 'textarea', 'select'].includes(item.type)) { - _inputfields.push({ - field: item.field, - label: item.label - }) - } - - if (item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { - _tabfields.push({ - field: item.field, - label: item.label - }) - } - - if (['switch', 'check', 'popSelect'].includes(item.type)) { - _linksupFields.push({ - field: item.field, - label: item.label - }) - } - - if (!['select', 'link', 'radio', 'checkcard', 'multiselect'].includes(item.type)) return - - _linksupFields.push({ - field: item.field, - label: item.label - }) - - if (item.type === 'multiselect' || (item.type === 'checkcard' && item.multiple === 'true')) return - - _linkableFields.push({ - field: item.field, - label: item.label + '-琛ㄥ崟' - }) - }) - - let _fields = _linkableFields.map(cell => cell.field) - card.columns.forEach(col => { - if (col.field && !_fields.includes(col.field)) { - _linkableFields.push({ - field: col.field, - label: col.label + '-鏄剧ず鍒�' - }) - } - }) - - if (_form.linkSubField && _form.linkSubField.length > 0) { - let fields = _inputfields.map(item => item.field) - _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item)) - } this.setState({ visible: true, editform: _form, - formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, card.columns) + formlist: getModalForm(_form, group.fields, card.columns) }) } @@ -721,12 +665,22 @@ {group ? <div className={`form-area mk-${card.wrap.formStyle || ''}`}> <PlusOutlined className="plus" title="娣诲姞琛ㄥ崟" onClick={this.addForm}/> <FieldsComponent config={group} type="form" plusFields={this.plusFields} /> - <span style={{color: 'red', marginLeft: '30px', cursor: 'pointer'}} onClick={this.clearGroup}>娓呯┖</span> - <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button> : null} - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2鍒�</Button> : null} - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(3)}>3鍒�</Button> : null} - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(4)}>4鍒�</Button> : null} + <div className="mk-form-tool"> + <DeleteOutlined title="娓呯┖" onClick={this.clearGroup} /> + {appType !== 'mob' ? <Popover title="鍒囨崲甯冨眬" overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(1)}>1鍒�</Button> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(2)}>2鍒�</Button> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(3)}>3鍒�</Button> + <Button onClick={() => this.changecols(4)}>4鍒�</Button> + </> + } trigger="hover"> + <SwapOutlined /> + </Popover> : null} + {/* <FormFork forms={group.fields}/> */} + {/* <CopyOutlined title="澶嶅埗" onClick={this.triggerCopy} /> */} + <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> + </div> <div style={{clear: 'both'}}></div> {appType !== 'mob' ? <CardComponent list={group.fields} diff --git a/src/menu/components/form/step-form/index.scss b/src/menu/components/form/step-form/index.scss index 40539f2..5f2d0f2 100644 --- a/src/menu/components/form/step-form/index.scss +++ b/src/menu/components/form/step-form/index.scss @@ -35,14 +35,6 @@ cursor: pointer; padding: 4px 10px; } - >button { - float: right; - margin-right: 10px; - } - >.mk-cols-change { - height: 24px; - padding: 0 10px; - } >.quickly-add { display: inline-block; margin-left: 10px; diff --git a/src/menu/components/form/tab-form/index.jsx b/src/menu/components/form/tab-form/index.jsx index e9af1d4..8671d15 100644 --- a/src/menu/components/form/tab-form/index.jsx +++ b/src/menu/components/form/tab-form/index.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Popover, Modal, Button, Switch, notification, message } from 'antd' -import { PlusOutlined, SettingOutlined, EditOutlined, ToolOutlined, DeleteOutlined, FontColorsOutlined } from '@ant-design/icons' +import { PlusOutlined, SettingOutlined, EditOutlined, ToolOutlined, DeleteOutlined, SwapOutlined, FontColorsOutlined } from '@ant-design/icons' import asyncComponent from '@/utils/asyncComponent' import asyncIconComponent from '@/utils/asyncIconComponent' @@ -20,6 +20,7 @@ const MobCardComponent = asyncComponent(() => import('@/mob/components/formdragelement')) const FormTitle = asyncComponent(() => import('../dragtitle')) const FormAction = asyncComponent(() => import('../formaction')) +// const FormFork = asyncComponent(() => import('@/menu/modalconfig/formfork')) const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent')) const PasteComponent = asyncIconComponent(() => import('@/menu/components/share/pastecomponent')) const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) @@ -453,69 +454,13 @@ */ handleForm = (_item) => { const { card, group } = this.state + let _form = fromJS(_item).toJS() - let _inputfields = [] - let _tabfields = [] - let _linkableFields = [] - let _linksupFields = [] - - group.fields.forEach((item, i) => { - if (!item.field || _form.field === item.field) return - - if (['text', 'number', 'textarea', 'select'].includes(item.type)) { - _inputfields.push({ - field: item.field, - label: item.label - }) - } - if (item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { - _tabfields.push({ - field: item.field, - label: item.label - }) - } - - if (['switch', 'check', 'popSelect'].includes(item.type)) { - _linksupFields.push({ - field: item.field, - label: item.label - }) - } - - if (!['select', 'link', 'radio', 'checkcard', 'multiselect'].includes(item.type)) return - - _linksupFields.push({ - field: item.field, - label: item.label - }) - - if (item.type === 'multiselect' || (item.type === 'checkcard' && item.multiple === 'true')) return - - _linkableFields.push({ - field: item.field, - label: item.label + '-琛ㄥ崟' - }) - }) - - let _fields = _linkableFields.map(cell => cell.field) - card.columns.forEach(col => { - if (col.field && !_fields.includes(col.field)) { - _linkableFields.push({ - field: col.field, - label: col.label + '-鏄剧ず鍒�' - }) - } - }) - - if (_form.linkSubField && _form.linkSubField.length > 0) { - let fields = _inputfields.map(item => item.field) - _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item)) - } this.setState({ visible: true, editform: _form, - formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, card.columns) + formlist: getModalForm(_form, group.fields, card.columns) }) } @@ -723,12 +668,22 @@ {group ? <div className={`form-area mk-${card.wrap.formStyle || ''}`}> <PlusOutlined className="plus" title="娣诲姞琛ㄥ崟" onClick={this.addForm}/> <FieldsComponent config={group} type="form" plusFields={this.plusFields} /> - <span style={{color: 'red', marginLeft: '30px', cursor: 'pointer'}} onClick={this.clearGroup}>娓呯┖</span> - <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button> : null} - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2鍒�</Button> : null} - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(3)}>3鍒�</Button> : null} - {appType !== 'mob' ? <Button className="mk-cols-change" onClick={() => this.changecols(4)}>4鍒�</Button> : null} + <div className="mk-form-tool"> + <DeleteOutlined title="娓呯┖" onClick={this.clearGroup} /> + {appType !== 'mob' ? <Popover title="鍒囨崲甯冨眬" overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(1)}>1鍒�</Button> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(2)}>2鍒�</Button> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(3)}>3鍒�</Button> + <Button onClick={() => this.changecols(4)}>4鍒�</Button> + </> + } trigger="hover"> + <SwapOutlined /> + </Popover> : null} + {/* <FormFork forms={group.fields}/> */} + {/* <CopyOutlined title="澶嶅埗" onClick={this.triggerCopy} /> */} + <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> + </div> <div style={{clear: 'both'}}></div> {appType !== 'mob' ? <CardComponent list={group.fields} diff --git a/src/menu/components/form/tab-form/index.scss b/src/menu/components/form/tab-form/index.scss index ffb7696..76ad654 100644 --- a/src/menu/components/form/tab-form/index.scss +++ b/src/menu/components/form/tab-form/index.scss @@ -34,14 +34,6 @@ cursor: pointer; padding: 4px 10px; } - >button { - float: right; - margin-right: 10px; - } - >.mk-cols-change { - height: 24px; - padding: 0 10px; - } >.quickly-add { display: inline-block; margin-left: 10px; diff --git a/src/menu/components/table/edit-table/columns/tableIn/index.jsx b/src/menu/components/table/edit-table/columns/tableIn/index.jsx index 0b443d7..4bf55dc 100644 --- a/src/menu/components/table/edit-table/columns/tableIn/index.jsx +++ b/src/menu/components/table/edit-table/columns/tableIn/index.jsx @@ -104,6 +104,92 @@ </div> ) }, + { + dataIndex: 'sqlRender', + render: (record) => { + let columns = this.props.config.columns + + let textFields = [] + let numberFields = [] + let dateFields = [] + columns.forEach((col) => { + if (/Nvarchar/ig.test(col.datatype)) { + textFields.push(col.field) + } else if (/Decimal|int/ig.test(col.datatype)) { + numberFields.push(col.field) + } else if (/date/ig.test(col.datatype)) { + dateFields.push(col.field) + } + }) + + let _sheet = this.state.verify.sheet + + if (window.GLOB.externalDatabase !== null) { + _sheet = _sheet.replace(/@db@/ig, window.GLOB.externalDatabase) + } + + let database = _sheet.match(/(.*)\.(.*)\./ig) + let sheet = _sheet.replace(/(.*)\.(.*)\./ig, '') + + database = database ? (database[0] || '') : '' + + let _fields = record.field.split(',') + let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) + _fields_ = _fields_.join(' and ') + + let _where = [] + _fields.forEach(f => { + if (textFields.includes(f)) { + _where.push(`${f}!=''`) + } else if (numberFields.includes(f)) { + _where.push(`${f}!=0`) + } else if (dateFields.includes(f)) { + _where.push(`${f}>'1949-10-01'`) + } + }) + _where = _where.length ? `where ${_where.join(' and ')} ` : '' + + if (record.verifyType === 'logic' || record.verifyType === 'logic_temp') { + _fields_ += ' and b.deleted=0' + } + + let _afields = [] + _fields = _fields.map(f => { + if (numberFields.includes(f)) { + _afields.push(`cast(a.${f} as nvarchar(50))`) + return `cast(${f} as nvarchar(50))` + } else if (dateFields.includes(f)) { + _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`) + return `CONVERT(nvarchar(50), ${f}, 21)` + } + _afields.push(`a.${f}`) + + return f + }) + + let sql = ` + /* 閲嶅鎬ч獙璇� */ + Set @tbid='' + Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${record.field} from #${sheet} ) a group by ${record.field} having sum(n)>1 + + If @tbid!='' + Begin + select @ErrorCode='${record.errorCode}',@retmsg=@tbid+' 閲嶅' + goto aaa + end + + ${record.verifyType.indexOf('temp') === -1 ? `Set @tbid='' + Select top 1 @tbid=${_afields.join('+\' \'+')} from ${_where ? `(select * from #${sheet} ${_where})` : `#${sheet}`} a Inner join ${database}${sheet} b on ${_fields_} + + If @tbid!='' + Begin + select @ErrorCode='${record.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�' + goto aaa + end` : ''} + ` + return sql.split(/\n\s{10}/ig).map(n => n.replace(/^\s{2}/ig, ' ')) + } + } ], scriptsColumns: [ { @@ -611,7 +697,7 @@ </span> } key="unique"> <UniqueForm fields={fields} uniqueChange={this.uniqueChange}/> - <EditTable actions={['edit', 'move', 'del']} data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/> + <EditTable actions={['edit', 'move', 'del', 'sql']} data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/> </TabPane> <TabPane disabled={verify.intertype !== 'system'} tab={ <span> diff --git a/src/menu/debug/index.jsx b/src/menu/debug/index.jsx index 09c2038..4a71502 100644 --- a/src/menu/debug/index.jsx +++ b/src/menu/debug/index.jsx @@ -1470,17 +1470,54 @@ let _uniquesql = '' if (btn.uniques && btn.uniques.length > 0) { + let textFields = [] + let numberFields = [] + let dateFields = [] + btn.columns.forEach((col) => { + if (/Nvarchar/ig.test(col.type)) { + textFields.push(col.Column) + } else if (/Decimal|int/ig.test(col.type)) { + numberFields.push(col.Column) + } else if (/date/ig.test(col.type)) { + dateFields.push(col.Column) + } + }) btn.uniques.forEach(unique => { if (unique.status === 'false' || !unique.verifyType) return let _fields = unique.field.split(',') let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) - let _afields = _fields.map(_field => `a.${_field}`) _fields_ = _fields_.join(' and ') + + let _where = [] + _fields.forEach(f => { + if (textFields.includes(f)) { + _where.push(`${f}!=''`) + } else if (numberFields.includes(f)) { + _where.push(`${f}!=0`) + } else if (dateFields.includes(f)) { + _where.push(`${f}>'1949-10-01'`) + } + }) + _where = _where.length ? `where ${_where.join(' and ')} ` : '' if (unique.verifyType === 'logic' || unique.verifyType === 'logic_temp') { _fields_ += ' and b.deleted=0' } + + let _afields = [] + _fields = _fields.map(f => { + if (numberFields.includes(f)) { + _afields.push(`cast(a.${f} as nvarchar(50))`) + return `cast(${f} as nvarchar(50))` + } else if (dateFields.includes(f)) { + _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`) + return `CONVERT(nvarchar(50), ${f}, 21)` + } + _afields.push(`a.${f}`) + + return f + }) _uniquesql += ` /* 閲嶅鎬ч獙璇� */ @@ -1494,7 +1531,7 @@ end ${unique.verifyType.indexOf('temp') === -1 ? `Set @tbid='' - Select top 1 @tbid=${_afields.join('+\' \'+')} from #${sheet} a Inner join ${sheet} b on ${_fields_} + Select top 1 @tbid=${_afields.join('+\' \'+')} from ${_where ? `(select * from #${sheet} ${_where})` : `#${sheet}`} a Inner join ${sheet} b on ${_fields_} If @tbid!='' Begin @@ -1662,17 +1699,54 @@ let _uniquesql = '' if (btn.uniques && btn.uniques.length > 0) { + let textFields = [] + let numberFields = [] + let dateFields = [] + columns.forEach((col) => { + if (/Nvarchar/ig.test(col.datatype)) { + textFields.push(col.field) + } else if (/Decimal|int/ig.test(col.datatype)) { + numberFields.push(col.field) + } else if (/date/ig.test(col.datatype)) { + dateFields.push(col.field) + } + }) btn.uniques.forEach(unique => { if (unique.status === 'false' || !unique.verifyType) return let _fields = unique.field.split(',') let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) - let _afields = _fields.map(_field => `a.${_field}`) _fields_ = _fields_.join(' and ') + + let _where = [] + _fields.forEach(f => { + if (textFields.includes(f)) { + _where.push(`${f}!=''`) + } else if (numberFields.includes(f)) { + _where.push(`${f}!=0`) + } else if (dateFields.includes(f)) { + _where.push(`${f}>'1949-10-01'`) + } + }) + _where = _where.length ? `where ${_where.join(' and ')} ` : '' if (unique.verifyType === 'logic' || unique.verifyType === 'logic_temp') { _fields_ += ' and b.deleted=0' } + + let _afields = [] + _fields = _fields.map(f => { + if (numberFields.includes(f)) { + _afields.push(`cast(a.${f} as nvarchar(50))`) + return `cast(${f} as nvarchar(50))` + } else if (dateFields.includes(f)) { + _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`) + return `CONVERT(nvarchar(50), ${f}, 21)` + } + _afields.push(`a.${f}`) + + return f + }) _uniquesql += ` /* 閲嶅鎬ч獙璇� */ @@ -1686,7 +1760,7 @@ end ${unique.verifyType.indexOf('temp') === -1 ? `Set @tbid='' - Select top 1 @tbid=${_afields.join('+\' \'+')} from #${sheet} a Inner join ${sheet} b on ${_fields_} + Select top 1 @tbid=${_afields.join('+\' \'+')} from ${_where ? `(select * from #${sheet} ${_where})` : `#${sheet}`} a Inner join ${sheet} b on ${_fields_} If @tbid!='' Begin diff --git a/src/menu/modalconfig/formfork/index.jsx b/src/menu/modalconfig/formfork/index.jsx new file mode 100644 index 0000000..0a37edd --- /dev/null +++ b/src/menu/modalconfig/formfork/index.jsx @@ -0,0 +1,241 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { is, fromJS } from 'immutable' +import { Modal } from 'antd' +import { ForkOutlined } from '@ant-design/icons' + +import './index.scss' + +class FormFork extends Component { + static propTpyes = { + forms: PropTypes.array + } + + state = { + visible: false, + } + + shouldComponentUpdate (nextProps, nextState) { + return !is(fromJS(this.state), fromJS(nextState)) + } + + trigger = () => { + const { forms } = this.props + + // let linkSubField = [] + // let supField = [] + // let tabField = [] + // let linkField = [] + + + let linkFields = {} // 鍏宠仈鑿滃崟 + let controlFields = {} // 鎺у埗琛ㄥ崟 + let fieldMap = new Map() + let formlist = fromJS(forms).toJS() + + formlist.forEach(item => { + if (item.supField) { // 澶氬眰琛ㄥ崟鎺у埗 + if (['hint', 'split', 'formula'].includes(item.type)) { + item.field = item.uuid + } + let supvals = [] + if (item.supvalue) { + item.supvalue.split(',').forEach(val => { + supvals.push(val) + }) + } else { + supvals.push('') + } + supvals = Array.from(new Set(supvals)) + controlFields[item.supField] = controlFields[item.supField] || [] + controlFields[item.supField].push({field: item.field, values: supvals.join(',')}) + } else { + delete item.supField + delete item.supvalue + } + if (item.linkField) { + linkFields[item.linkField] = linkFields[item.linkField] || [] + linkFields[item.linkField].push({field: item.field, label: item.label, uuid: item.uuid}) + } else { + delete item.linkField + } + + Object.keys(item).forEach(key => { + if (!['type', 'uuid', 'field', 'label', 'supField', 'supvalue', 'linkField', 'linkSubField', 'multiple', 'enter', 'tabField'].includes(key)) { + delete item[key] + } + }) + + if (!item.field) return + + fieldMap.set(item.field, item) + }) + + Object.keys(controlFields).forEach(key => { + if (!fieldMap.has(key)) return + + let supItem = fieldMap.get(key) + let fields = [] + + controlFields[key].forEach(item => { + if (!fieldMap.has(item.field)) return + + item.label = fieldMap.get(item.field).label + + fields.push(item) + }) + + if (fields.length === 0) return + + supItem.controlFields = fields + + fieldMap.set(key, supItem) + }) + + let _f = fromJS([...fieldMap.values()]).toJS() + _f.forEach(item => { + // 涓嬬骇琛ㄥ崟鎺у埗-瀛楁鍐欏叆 + if (item.linkSubField && item.linkSubField.length > 0) { + item.subFields = [] + if ((['select', 'radio', 'link', 'cascader'].includes(item.type) || (item.type === 'checkcard' && item.multiple !== 'true'))) { + item.linkSubField.forEach(m => { + let n = fieldMap.get(m) + if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) { + item.subFields.push({ + uuid: n.uuid, + field: m, + label: n.label + }) + } + }) + } else if (item.type === 'switch') { + item.linkSubField.forEach(m => { + let n = fieldMap.get(m) + if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) { + item.subFields.push({ + uuid: n.uuid, + field: m, + label: n.label + }) + } + }) + } else if (item.type === 'fileupload') { + item.linkSubField.forEach(m => { + let n = fieldMap.get(m) + if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) { + item.subFields.push({ + uuid: n.uuid, + field: m, + label: n.label + }) + } + }) + } else if (item.type === 'popSelect') { + item.linkSubField.forEach(m => { + let n = fieldMap.get(m) + if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) { + item.subFields.push({ + uuid: n.uuid, + field: m, + label: n.label + }) + } + }) + } + + if (item.subFields.length === 0) { + delete item.subFields + } + } + + if (linkFields[item.field]) { + item.linkFields = linkFields[item.field] + } + + if (item.enter === 'tab' || item.enter === 'sub') { + if (item.tabField) { + if (!fieldMap.has(item.tabField)) { + delete item.tabField + } else { + item.tabLabel = fieldMap.get(item.tabField).label + } + } + } else { + delete item.tabField + } + + if (item.supField) { + if (!fieldMap.has(item.supField)) { + delete item.supField + delete item.supvalue + } else { + item.supLabel = fieldMap.get(item.supField).label + } + } + if (item.linkField) { + if (!fieldMap.has(item.linkField)) { + item.linkLabel = '瀛楁闆�' + } else { + item.linkLabel = fieldMap.get(item.linkField).label + } + } + + delete item.enter + delete item.multiple + delete item.linkSubField + + // if (!item.controlFields && !item.linkFields && !item.subFields && !item.resubFields) + + fieldMap.set(item.field, item) + }) + + let _t = fromJS([...fieldMap.values()]).toJS() + + _t.forEach(item => { + if (item.subFields) { + item.subFields.forEach(cell => { + let _cell = fieldMap.get(cell.field) + + _cell.resubFields = _cell.resubFields || [] + + _cell.resubFields.push({ + uuid: item.uuid, + field: item.field, + label: item.label + }) + + fieldMap.set(cell.field, _cell) + }) + } + }) + + this.setState({ + visible: true + }) + } + + render() { + const { visible } = this.state + + return ( + <> + <ForkOutlined title="琛ㄥ崟鍏崇郴鍥�" onClick={this.trigger}/> + <Modal + title="琛ㄥ崟鍏崇郴鍥�" + wrapClassName="form-fork-modal mk-scroll-modal" + visible={visible} + width={900} + maskClosable={false} + cancelText="鍏抽棴" + onOk={() => { this.setState({ visible: false })}} + onCancel={() => { this.setState({ visible: false })}} + destroyOnClose + > + + </Modal> + </> + ) + } +} + +export default FormFork \ No newline at end of file diff --git a/src/menu/modalconfig/formfork/index.scss b/src/menu/modalconfig/formfork/index.scss new file mode 100644 index 0000000..43f399e --- /dev/null +++ b/src/menu/modalconfig/formfork/index.scss @@ -0,0 +1,14 @@ +.form-fork-modal { + .ant-modal-header { + text-align: center; + } + .ant-modal-body { + min-height: 350px!important; + } + + .ant-modal-footer { + .ant-btn-primary { + display: none; + } + } +} \ No newline at end of file diff --git a/src/menu/modalconfig/index.jsx b/src/menu/modalconfig/index.jsx index 65a7158..9124c01 100644 --- a/src/menu/modalconfig/index.jsx +++ b/src/menu/modalconfig/index.jsx @@ -3,8 +3,8 @@ import { is, fromJS } from 'immutable' import { DndProvider } from 'react-dnd' import HTML5Backend from 'react-dnd-html5-backend' -import { Button, Card, Modal, Collapse, Switch, message } from 'antd' -import { SettingOutlined, CopyOutlined } from '@ant-design/icons' +import { Button, Card, Modal, Collapse, Switch, message, Popover } from 'antd' +import { SettingOutlined, CopyOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons' import { getModalForm } from '@/templates/zshare/formconfig' import SourceElement from '@/templates/modalconfig/dragelement/source' @@ -21,6 +21,7 @@ const TableComponent = asyncComponent(() => import('./tablecomponent')) const ModalForm = asyncComponent(() => import('@/templates/zshare/modalform')) const PasteForms = asyncComponent(() => import('@/menu/components/share/pasteforms')) +// const FormFork = asyncComponent(() => import('@/menu/modalconfig/formfork')) const DragElement = asyncComponent(() => import('@/templates/modalconfig/dragelement')) const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent')) @@ -97,81 +98,21 @@ /** * @description 琛ㄥ崟缂栬緫 - * 1銆佹樉绀虹紪杈戝脊绐�-visible - * 2銆佷繚瀛樼紪杈戦」-card - * 3銆佽缃紪杈戝弬鏁伴」-formlist */ handleForm = (_card) => { const { componentConfig, btn } = this.props const { config } = this.state + let card = fromJS(_card).toJS() - let _inputfields = [] - let _tabfields = [] - let _linkableFields = [] - let _linksupFields = [] - - config.fields.forEach((item, i) => { - if (!item.field || card.field === item.field) return - - if (['text', 'number', 'textarea', 'select'].includes(item.type)) { - _inputfields.push({ - field: item.field, - label: item.label - }) - } - if (item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { - _tabfields.push({ - field: item.field, - label: item.label - }) - } - - if (['switch', 'check', 'popSelect'].includes(item.type)) { - _linksupFields.push({ - field: item.field, - label: item.label - }) - } - - if (!['select', 'link', 'radio', 'checkcard', 'multiselect'].includes(item.type)) return - - _linksupFields.push({ - field: item.field, - label: item.label - }) - - if (item.type === 'multiselect' || (item.type === 'checkcard' && item.multiple === 'true')) return - - _linkableFields.push({ - field: item.field, - label: item.label + '-琛ㄥ崟' - }) - }) - let columns = componentConfig.columns if (btn.$sub) { columns = componentConfig.subColumns || [] } - let _fields = _linkableFields.map(cell => cell.field) - columns.forEach(col => { - if (col.field && !_fields.includes(col.field)) { - _linkableFields.push({ - field: col.field, - label: col.label + '-鏄剧ず鍒�' - }) - } - }) - - if (card.linkSubField && card.linkSubField.length > 0) { - let fields = _inputfields.map(item => item.field) - card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) - } - this.setState({ visible: true, card: card, - formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, columns) + formlist: getModalForm(card, config.fields, columns) }) } @@ -451,7 +392,6 @@ <div className="setting"> <Card title="琛ㄥ崟閰嶇疆" bordered={false} extra={ <div> - <Button type="danger" onClick={this.clearConfig}>娓呯┖</Button> <PasteForms type="toolbar" config={config} update={this.pasteFields}/> <Button type="primary" id="save-modal-config" loading={saving} onClick={this.submitConfig}>淇濆瓨</Button> <Button onClick={this.cancelConfig}>杩斿洖</Button> @@ -461,12 +401,22 @@ <div className="ant-modal-content" style={{width: config.setting.width > 100 ? config.setting.width : config.setting.width + '%'}}> <div className="ant-modal-header"> <div className="ant-modal-title">{config.setting.icon ? <span className={'mk-modal-icon-' + config.setting.iconType} style={{background: config.setting.iconColor || 'unset', color: config.setting.iconColor || 'inherit'}}><MkIcon type={config.setting.icon}/></span> : null}{btn.label}</div> - <Button className="mk-cols-change" onClick={() => this.changecols(1)}>1鍒�</Button> - <Button className="mk-cols-change" onClick={() => this.changecols(2)}>2鍒�</Button> - <Button className="mk-cols-change" onClick={() => this.changecols(3)}>3鍒�</Button> - <Button className="mk-cols-change" onClick={() => this.changecols(4)}>4鍒�</Button> - <CopyOutlined title="澶嶅埗" onClick={this.triggerCopy} /> - <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> + <div className="mk-form-tool"> + <DeleteOutlined title="娓呯┖" onClick={this.clearConfig} /> + <Popover title="鍒囨崲甯冨眬" overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={ + <> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(1)}>1鍒�</Button> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(2)}>2鍒�</Button> + <Button style={{marginRight: '10px'}} onClick={() => this.changecols(3)}>3鍒�</Button> + <Button onClick={() => this.changecols(4)}>4鍒�</Button> + </> + } trigger="hover"> + <SwapOutlined /> + </Popover> + {/* <FormFork forms={config.fields}/> */} + <CopyOutlined title="澶嶅埗" onClick={this.triggerCopy} /> + <Switch checkedChildren="寮�" unCheckedChildren="鍏�" defaultChecked={this.state.showField} onChange={(val) => this.setState({showField: val})} /> + </div> </div> <div className="ant-modal-body"> <div className="modal-form"> diff --git a/src/menu/modalconfig/index.scss b/src/menu/modalconfig/index.scss index af280fa..ce93e36 100644 --- a/src/menu/modalconfig/index.scss +++ b/src/menu/modalconfig/index.scss @@ -125,7 +125,8 @@ z-index: 10; background: transparent; min-height: 50px; - padding-right: 80px; + padding-right: 10px; + .ant-modal-title { display: inline-block; height: 22px; @@ -143,23 +144,6 @@ text-align: center; line-height: 30px; } - } - .anticon-copy { - position: absolute; - top: 18px; - color: #26C281; - right: 65px; - font-size: 16px; - } - .ant-switch { - position: absolute; - top: 15px; - right: 10px; - } - .mk-cols-change { - float: right; - height: 25px; - margin-right: 10px; } } .ant-modal-close { diff --git a/src/mob/modalconfig/index.jsx b/src/mob/modalconfig/index.jsx index 4c20d8e..8ef83d0 100644 --- a/src/mob/modalconfig/index.jsx +++ b/src/mob/modalconfig/index.jsx @@ -106,74 +106,18 @@ handleForm = (_card) => { const { componentConfig, btn } = this.props const { config } = this.state + let card = fromJS(_card).toJS() - let _inputfields = [] - let _tabfields = [] - let _linkableFields = [] - let _linksupFields = [] - - config.fields.forEach((item, i) => { - if (!item.field || card.field === item.field) return - - if (['text', 'number', 'textarea', 'select'].includes(item.type)) { - _inputfields.push({ - field: item.field, - label: item.label - }) - } - if (item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { - _tabfields.push({ - field: item.field, - label: item.label - }) - } - - if (item.type === 'switch' || item.type === 'check') { - _linksupFields.push({ - field: item.field, - label: item.label - }) - } - - if (!['select', 'link', 'radio', 'checkcard'].includes(item.type)) return - - _linksupFields.push({ - field: item.field, - label: item.label - }) - - if (item.type === 'checkcard' && item.multiple === 'true') return - - _linkableFields.push({ - field: item.field, - label: item.label + '-琛ㄥ崟' - }) - }) let columns = componentConfig.columns if (btn.$sub) { columns = componentConfig.subColumns || [] } - let _fields = _linkableFields.map(cell => cell.field) - columns.forEach(col => { - if (col.field && !_fields.includes(col.field)) { - _linkableFields.push({ - field: col.field, - label: col.label + '-鏄剧ず鍒�' - }) - } - }) - - if (card.linkSubField && card.linkSubField.length > 0) { - let fields = _inputfields.map(item => item.field) - card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) - } - this.setState({ visible: true, card: card, - formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, columns) + formlist: getModalForm(card, config.fields, columns) }) } diff --git a/src/tabviews/custom/components/module/invoice/index.jsx b/src/tabviews/custom/components/module/invoice/index.jsx index e50407c..ad7b49b 100644 --- a/src/tabviews/custom/components/module/invoice/index.jsx +++ b/src/tabviews/custom/components/module/invoice/index.jsx @@ -541,6 +541,22 @@ outBill = () => { const { config, BID, saveType } = this.state + if (window.GLOB.storeFiles) { + if (!window.GLOB.storeDate || window.GLOB.storeDate < 0) { + Modal.warning({ + title: `鐢靛瓙妗f瀛樺偍鍖呭凡杩囨湡銆俙, + okText: '鐭ラ亾浜�' + }) + return + } else if (window.GLOB.storeDate < 30) { + notification.warning({ + top: 92, + message: `鐢靛瓙妗f瀛樺偍鍖呰繕鍓�${window.GLOB.storeDate}澶┿�俙, + duration: 5 + }) + } + } + if (window.GLOB.systemType === 'production' && !config.billOutBtn.proInterface) { notification.warning({ top: 92, @@ -797,6 +813,10 @@ param.data.invoiceTypeCode = trans[param.data.invoiceTypeCode] || '' + if (window.GLOB.storeFiles) { + param.store = true + } + let url = '' if (window.GLOB.systemType === 'production') { url = config.billOutBtn.proInterface diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index f0fb90d..cabfc7d 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -216,89 +216,21 @@ handleForm = (_card) => { const { menu, tabConfig, subTabConfig } = this.props const { config } = this.state + let card = fromJS(_card).toJS() - let _inputfields = [] - let _tabfields = [] - let _linkableFields = [] - let _linksupFields = [] - - config.fields.forEach((item, i) => { - if (!item.field || card.field === item.field) return - - if (['text', 'number', 'textarea', 'select'].includes(item.type)) { - _inputfields.push({ - field: item.field, - label: item.label - }) - } - if (item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { - _tabfields.push({ - field: item.field, - label: item.label - }) - } - - if (['switch', 'check', 'popSelect'].includes(item.type)) { - _linksupFields.push({ - field: item.field, - label: item.label - }) - } - - if (!['select', 'link', 'radio', 'checkcard', 'multiselect'].includes(item.type)) return - - _linksupFields.push({ - field: item.field, - label: item.label - }) - - if (item.type === 'multiselect' || (item.type === 'checkcard' && item.multiple === 'true')) return - - _linkableFields.push({ - field: item.field, - label: item.label + '-琛ㄥ崟' - }) - }) - - let _fields = _linkableFields.map(cell => cell.field) + let columns = [] if (subTabConfig) { - subTabConfig.columns.forEach(col => { - if (col.field && !_fields.includes(col.field)) { - _linkableFields.push({ - field: col.field, - label: col.label + '-鏄剧ず鍒�' - }) - } - }) + columns = subTabConfig.columns } else if (tabConfig) { - tabConfig.columns.forEach(col => { - if (col.field && !_fields.includes(col.field)) { - _linkableFields.push({ - field: col.field, - label: col.label + '-鏄剧ず鍒�' - }) - } - }) + columns = tabConfig.columns } else if (menu.LongParam) { - menu.LongParam.columns.forEach(col => { - if (col.field && !_fields.includes(col.field)) { - _linkableFields.push({ - field: col.field, - label: col.label + '-鏄剧ず鍒�' - }) - } - }) - } - - if (card.linkSubField && card.linkSubField.length > 0) { - let fields = _inputfields.map(item => item.field) - card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) + columns = menu.LongParam.columns } this.setState({ visible: true, card: card, - formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields) + formlist: getModalForm(card, config.fields, columns) }) } diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index c58226f..9986355 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -205,6 +205,93 @@ </div> ) }, + { + dataIndex: 'sqlRender', + render: (record) => { + let columns = this.state.verify.columns + + let textFields = [] + let numberFields = [] + let dateFields = [] + columns.forEach((col) => { + if (/Nvarchar/ig.test(col.type)) { + textFields.push(col.Column) + } else if (/Decimal|int/ig.test(col.type)) { + numberFields.push(col.Column) + } else if (/date/ig.test(col.type)) { + dateFields.push(col.Column) + } + }) + + let _fields = record.field.split(',') + let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) + _fields_ = _fields_.join(' and ') + + let _where = [] + _fields.forEach(f => { + if (textFields.includes(f)) { + _where.push(`${f}!=''`) + } else if (numberFields.includes(f)) { + _where.push(`${f}!=0`) + } else if (dateFields.includes(f)) { + _where.push(`${f}>'1949-10-01'`) + } + }) + _where = _where.length ? `where ${_where.join(' and ')} ` : '' + + if (record.verifyType === 'logic' || record.verifyType === 'logic_temp') { + _fields_ += ' and b.deleted=0' + } + + let _afields = [] + _fields = _fields.map(f => { + if (numberFields.includes(f)) { + _afields.push(`cast(a.${f} as nvarchar(50))`) + return `cast(${f} as nvarchar(50))` + } else if (dateFields.includes(f)) { + _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`) + return `CONVERT(nvarchar(50), ${f}, 21)` + } + _afields.push(`a.${f}`) + + return f + }) + + let _sheet = this.props.card.sheet + + if (window.GLOB.externalDatabase !== null) { + _sheet = _sheet.replace(/@db@/ig, window.GLOB.externalDatabase) + } + + let database = _sheet.match(/(.*)\.(.*)\./ig) + let sheet = _sheet.replace(/(.*)\.(.*)\./ig, '') + + database = database ? (database[0] || '') : '' + + let sql = ` + /* 閲嶅鎬ч獙璇� */ + Set @tbid='' + Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${record.field} from #${sheet} ${_where}) a group by ${record.field} having sum(n)>1 + + If @tbid!='' + Begin + select @ErrorCode='${record.errorCode}',@retmsg=@tbid+' 閲嶅' + goto aaa + end + + ${record.verifyType.indexOf('temp') === -1 ? `Set @tbid='' + Select top 1 @tbid=${_afields.join('+\' \'+')} from ${_where ? `(select * from #${sheet} ${_where})` : `#${sheet}`} a Inner join ${database}${sheet} b on ${_fields_} + + If @tbid!='' + Begin + select @ErrorCode='${record.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�' + goto aaa + end` : ''} + ` + + return sql.split(/\n\s{10}/ig).map(n => n.replace(/^\s{2}/ig, ' ')) + } + } ], scriptsColumns: [ { @@ -980,7 +1067,7 @@ </span> } key="unique"> <UniqueForm fields={verify.columns} uniqueChange={this.uniqueChange}/> - <EditTable actions={['edit', 'move', 'del', 'status']} data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/> + <EditTable actions={['edit', 'move', 'del', 'status', 'sql']} data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/> </TabPane> : null} {card.intertype === 'system' ? <TabPane tab={ <span> diff --git a/src/templates/zshare/editTable/index.jsx b/src/templates/zshare/editTable/index.jsx index fcc5e6d..2c9ecc4 100644 --- a/src/templates/zshare/editTable/index.jsx +++ b/src/templates/zshare/editTable/index.jsx @@ -366,7 +366,7 @@ if (list) { Modal.info({ title: '', - width: 500, + width: 700, className: 'sql-example', icon: null, content: list.map((n, index) => <div key={index} dangerouslySetInnerHTML={{ __html: n }}></div>) diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index 50071ac..c36d6b6 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -731,13 +731,8 @@ /** * @description 鑾峰彇琛ㄥ崟閰嶇疆淇℃伅 - * @param {*} card // 琛ㄥ崟瀵硅薄 - * @param {*} inputfields // 鍙啓鍏ヨ〃鍗� - * @param {*} tabfields // 鍙垏鎹㈣〃鍗� - * @param {*} linkableFields // 鍙叧鑱旇〃鍗� - * @param {*} linksupFields // 涓婄骇琛ㄥ崟 */ -export function getModalForm (card, inputfields = [], tabfields = [], linkableFields, linksupFields, columns = []) { +export function getModalForm (card, fields, columns = []) { let appType = sessionStorage.getItem('appType') let roleList = sessionStorage.getItem('sysRoles') if (roleList) { @@ -774,6 +769,64 @@ msgTemps = [] } + let inputfields = [] + let tabfields = [] + let linkableFields = [] + let linksupFields = [] + + fields.forEach(item => { + if (!item.field || card.field === item.field) return + + if (['text', 'number', 'textarea', 'select'].includes(item.type)) { + inputfields.push({ + field: item.field, + label: item.label + }) + } + if (item.hidden !== 'true' && ['text', 'number', 'select', 'link'].includes(item.type)) { + tabfields.push({ + field: item.field, + label: item.label + }) + } + + if (['switch', 'check', 'popSelect'].includes(item.type)) { + linksupFields.push({ + field: item.field, + label: item.label + }) + } + + if (!['select', 'link', 'radio', 'checkcard', 'multiselect'].includes(item.type)) return + + linksupFields.push({ + field: item.field, + label: item.label + }) + + if (item.type === 'multiselect' || (item.type === 'checkcard' && item.multiple === 'true')) return + + linkableFields.push({ + field: item.field, + label: item.label + '-琛ㄥ崟' + }) + }) + + let _fields = linkableFields.map(cell => cell.field) + columns.forEach(col => { + if (col.field && !_fields.includes(col.field)) { + linkableFields.push({ + field: col.field, + label: col.label + '-鏄剧ず鍒�' + }) + } + }) + + if (card.linkSubField && card.linkSubField.length > 0) { + let fields = inputfields.map(item => item.field) + card.linkSubField = card.linkSubField.filter(item => fields.includes(item)) + } + inputfields = inputfields.map((item, index) => { item.label = `${index + 1}銆�${item.field || ''}锛�${item.label}锛塦 return item diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx index 8bc3126..98fa67f 100644 --- a/src/templates/zshare/verifycard/index.jsx +++ b/src/templates/zshare/verifycard/index.jsx @@ -86,7 +86,7 @@ title: '楠岃瘉绫诲瀷', dataIndex: 'verifyType', width: '14%', - render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉', + render: (text) => text === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉', inputType: 'select', editable: true, options: [ @@ -124,7 +124,7 @@ record.field.split(',').forEach((_field, index) => { let _key = _field.toLowerCase() - _fieldValue.push(`${_key}=${_key === 'bid' ? '@BID@' : ''}`) + _fieldValue.push(`${_key}=${_key === 'bid' ? '@BID@' : `''`}`) _value.push(`${_labels[index] || ''}锛歺xx`) }) diff --git a/src/utils/utils.js b/src/utils/utils.js index 02050a4..ea19a1d 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -1134,9 +1134,15 @@ let _uniquesql = '' if (btn.uniques && btn.uniques.length > 0) { let textFields = [] + let numberFields = [] + let dateFields = [] btn.columns.forEach((col) => { - if (/^Nvarchar/ig.test(col.type)) { + if (/Nvarchar/ig.test(col.type)) { textFields.push(col.Column) + } else if (/Decimal|int/ig.test(col.type)) { + numberFields.push(col.Column) + } else if (/date/ig.test(col.type)) { + dateFields.push(col.Column) } }) @@ -1145,13 +1151,17 @@ let _fields = unique.field.split(',') let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) - let _afields = _fields.map(_field => `a.${_field}`) + _fields_ = _fields_.join(' and ') let _where = [] _fields.forEach(f => { if (textFields.includes(f)) { _where.push(`${f}!=''`) + } else if (numberFields.includes(f)) { + _where.push(`${f}!=0`) + } else if (dateFields.includes(f)) { + _where.push(`${f}>'1949-10-01'`) } }) _where = _where.length ? `where ${_where.join(' and ')} ` : '' @@ -1159,6 +1169,20 @@ if (unique.verifyType === 'logic' || unique.verifyType === 'logic_temp') { _fields_ += ' and b.deleted=0' } + + let _afields = [] + _fields = _fields.map(f => { + if (numberFields.includes(f)) { + _afields.push(`cast(a.${f} as nvarchar(50))`) + return `cast(${f} as nvarchar(50))` + } else if (dateFields.includes(f)) { + _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`) + return `CONVERT(nvarchar(50), ${f}, 21)` + } + _afields.push(`a.${f}`) + + return f + }) _uniquesql += ` /* 閲嶅鎬ч獙璇� */ @@ -1368,17 +1392,54 @@ let _uniquesql = '' if (btn.uniques && btn.uniques.length > 0) { + let textFields = [] + let numberFields = [] + let dateFields = [] + columns.forEach((col) => { + if (/Nvarchar/ig.test(col.datatype)) { + textFields.push(col.field) + } else if (/Decimal|int/ig.test(col.datatype)) { + numberFields.push(col.field) + } else if (/date/ig.test(col.datatype)) { + dateFields.push(col.field) + } + }) btn.uniques.forEach(unique => { if (unique.status === 'false' || !unique.verifyType) return let _fields = unique.field.split(',') let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`) - let _afields = _fields.map(_field => `a.${_field}`) _fields_ = _fields_.join(' and ') + + let _where = [] + _fields.forEach(f => { + if (textFields.includes(f)) { + _where.push(`${f}!=''`) + } else if (numberFields.includes(f)) { + _where.push(`${f}!=0`) + } else if (dateFields.includes(f)) { + _where.push(`${f}>'1949-10-01'`) + } + }) + _where = _where.length ? `where ${_where.join(' and ')} ` : '' if (unique.verifyType === 'logic' || unique.verifyType === 'logic_temp') { _fields_ += ' and b.deleted=0' } + + let _afields = [] + _fields = _fields.map(f => { + if (numberFields.includes(f)) { + _afields.push(`cast(a.${f} as nvarchar(50))`) + return `cast(${f} as nvarchar(50))` + } else if (dateFields.includes(f)) { + _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`) + return `CONVERT(nvarchar(50), ${f}, 21)` + } + _afields.push(`a.${f}`) + + return f + }) _uniquesql += ` /* 閲嶅鎬ч獙璇� */ @@ -1392,7 +1453,7 @@ end ${unique.verifyType.indexOf('temp') === -1 ? `Set @tbid='' - Select top 1 @tbid=${_afields.join('+\' \'+')} from #${sheet} a Inner join ${database}${sheet} b on ${_fields_} + Select top 1 @tbid=${_afields.join('+\' \'+')} from ${_where ? `(select * from #${sheet} ${_where})` : `#${sheet}`} a Inner join ${database}${sheet} b on ${_fields_} If @tbid!='' Begin @@ -1873,7 +1934,7 @@ if (_key === 'bid' && !_val) { // 琛ㄥ崟涓病鏈塨id鍒欎娇鐢ㄧ郴缁焍id鍙橀噺 _val = BID } - + _fieldValue.push(`${_key}='${_val}'`) _value.push(`${_labels[index] || ''}锛�${_val || ''}`) }) diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index c2fa81c..d8a5ada 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -464,6 +464,16 @@ } box = box.join(',') localStorage.setItem(_authUrl, box) + + if (res.e_files === 'true') { + localStorage.setItem(_href + 'files', md5(_href + 'files')) + localStorage.setItem(_href + 'filesDate', res.e_files_end_date) + window.GLOB.storeFiles = true + window.GLOB.storeDate = Math.ceil((new Date(res.e_files_end_date).getTime() - new Date().getTime()) / 86400000) + } else { + localStorage.removeItem(_href + 'files') + window.GLOB.storeFiles = false + } this.setState({ auth: true @@ -477,6 +487,9 @@ } } else { localStorage.removeItem(_authUrl) + localStorage.removeItem(_href + 'files') + window.GLOB.storeFiles = false + this.setState({ auth: false }) -- Gitblit v1.8.0