From d340a56429b12c3c893762730638631e147e047c Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 27 八月 2023 13:46:34 +0800 Subject: [PATCH] 2023-08-27 --- src/templates/sharecomponent/settingcomponent/index.jsx | 62 - src/utils/utils-datamanage.js | 5 src/templates/zshare/createfunc/index.jsx | 256 ++----- src/tabviews/custom/components/module/voucher/index.jsx | 8 src/menu/components/card/cardcellcomponent/index.jsx | 75 +- src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx | 9 src/menu/components/share/actioncomponent/formconfig.jsx | 30 + src/menu/datasource/verifycard/settingform/index.jsx | 16 src/menu/components/share/actioncomponent/index.jsx | 84 +- src/tabviews/zshare/actionList/excelInbutton/index.jsx | 37 src/tabviews/zshare/actionList/printbutton/index.jsx | 5 src/menu/datasource/index.jsx | 46 + src/tabviews/zshare/actionList/exceloutbutton/index.jsx | 10 src/menu/components/share/actioncomponent/actionform/index.jsx | 10 src/templates/zshare/createfunc/utils.js | 454 +++++++++++++++ src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx | 11 src/tabviews/zshare/actionList/normalbutton/index.jsx | 10 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx | 16 src/menu/datasource/verifycard/index.jsx | 12 src/utils/utils.js | 638 ++------------------- 20 files changed, 871 insertions(+), 923 deletions(-) diff --git a/src/menu/components/card/cardcellcomponent/index.jsx b/src/menu/components/card/cardcellcomponent/index.jsx index 22adfb8..1100466 100644 --- a/src/menu/components/card/cardcellcomponent/index.jsx +++ b/src/menu/components/card/cardcellcomponent/index.jsx @@ -7,7 +7,6 @@ import asyncComponent from '@/utils/asyncComponent' import { getCardCellForm } from './formconfig' import { getActionForm, getBaseTableActionForm } from '@/menu/components/share/actioncomponent/formconfig' -import Utils, { FuncUtils } from '@/utils/utils.js' import MKEmitter from '@/utils/events.js' import MenuUtils from '@/utils/utils-custom.js' import ElementForm from './elementform' @@ -660,47 +659,47 @@ * @description 鍒涘缓鎸夐挳瀛樺偍杩囩▼ */ creatFunc = () => { + const { cards } = this.props const menu = window.GLOB.customMenu - let _config = fromJS(this.props.cards).toJS() - this.actionFormRef.handleConfirm().then(res => { - let btn = res // 鎸夐挳淇℃伅 - let newLText = '' // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = '' // 鍒犻櫎瀛樺偍杩囩▼sql + return new Promise((resolve) => { + this.actionFormRef.handleConfirm().then(res => { + let btn = fromJS(res).toJS() + let _config = fromJS(cards).toJS() - if (btn.intertype !== 'inner') return + if (btn.OpenType === 'excelIn') { + btn.func = btn.innerFunc + btn.menuNo = menu.MenuNo + btn.MenuName = menu.MenuName + _config.name + btn.$type = 'excelIn' - if (btn.OpenType === 'pop') { - let _param = { - funcName: btn.innerFunc, - name: _config.setting.tableName || '', - fields: btn.modal ? btn.modal.fields : [], - menuNo: menu.MenuNo + resolve(btn) + } else if (btn.OpenType === 'excelOut') { + _config.MenuName = menu.MenuName + '-' + _config.name + _config.menuNo = menu.MenuNo + _config.MenuID = menu.MenuID + _config.func = btn.innerFunc + _config.$type = 'table' + + resolve(_config) + } else { + btn.func = btn.innerFunc + btn.name = _config.setting.tableName || '' + btn.menuNo = menu.MenuNo + btn.MenuID = menu.MenuID + btn.MenuName = menu.MenuName + _config.name + btn.fields = [] + btn.columns = _config.columns + btn.primaryKey = _config.setting.primaryKey || 'ID' + btn.$type = 'btn' + + if (btn.OpenType === 'pop') { + btn.fields = btn.modal ? btn.modal.fields : [] + } + + resolve(btn) } - newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) - } else if (btn.OpenType === 'excelIn') { - let _param = { - funcName: btn.innerFunc, - menuNo: menu.MenuNo - } - newLText = Utils.formatOptions(FuncUtils.getexcelInfunc(_param, btn, menu)) - DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) - } else if (btn.OpenType === 'excelOut') { - newLText = Utils.formatOptions(FuncUtils.getTableFunc(btn.innerFunc, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql - DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) - } else { - let _param = { - funcName: btn.innerFunc, - name: _config.setting.tableName || '', - fields: '', - menuNo: menu.MenuNo - } - newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) - } - - this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText) + }) }) } @@ -787,7 +786,7 @@ maskClosable={false} onCancel={this.editModalCancel} footer={[ - record && record.intertype === 'inner' && cards.subtype === 'dualdatacard' ? <CreateFunc key="create" ref="btnCreatFunc" trigger={this.creatFunc}/> : null, + record && record.intertype === 'inner' && cards.subtype === 'dualdatacard' ? <CreateFunc key="create" getMsg={this.creatFunc}/> : null, <Button key="cancel" onClick={this.editModalCancel}>鍙栨秷</Button>, <Button key="confirm" type="primary" onClick={this.handleActionSubmit}>纭畾</Button> ]} diff --git a/src/menu/components/share/actioncomponent/actionform/index.jsx b/src/menu/components/share/actioncomponent/actionform/index.jsx index c0ce3c6..c02a963 100644 --- a/src/menu/components/share/actioncomponent/actionform/index.jsx +++ b/src/menu/components/share/actioncomponent/actionform/index.jsx @@ -214,7 +214,7 @@ shows.push('exInterface', 'exProInterface') } } else if (intertype === 'inner') { - shows.push('innerFunc', 'output') + shows.push('innerFunc', 'output', 'recordUser') if (Ot === 'requiredOnce') { // 鍓嶇疆鍑芥暟 shows.push('preFunc') } @@ -295,7 +295,7 @@ shows.push('exInterface', 'exProInterface') } } else if (intertype === 'inner') { - shows.push('innerFunc') + shows.push('innerFunc', 'recordUser') reRequired.innerFunc = true } else { shows.push('sql', 'sqlType') @@ -346,7 +346,7 @@ shows.push('exInterface', 'exProInterface') } } else if (this.record.intertype === 'inner') { - shows.push('innerFunc') + shows.push('innerFunc', 'recordUser') reRequired.innerFunc = true } if (this.record.execSuccess === 'grid' || this.record.execError === 'grid') { @@ -381,7 +381,7 @@ shows.push('exInterface', 'exProInterface') } } else if (this.record.intertype === 'inner') { - shows.push('innerFunc') + shows.push('innerFunc', 'recordUser') reRequired.innerFunc = true } if (this.record.execSuccess === 'grid' || this.record.execError === 'grid') { @@ -459,7 +459,7 @@ shows.push('exInterface', 'exProInterface') } } else if (this.record.intertype === 'inner') { - shows.push('innerFunc') + shows.push('innerFunc', 'recordUser') reRequired.innerFunc = true } if (this.record.execSuccess === 'grid' || this.record.execError === 'grid') { diff --git a/src/menu/components/share/actioncomponent/formconfig.jsx b/src/menu/components/share/actioncomponent/formconfig.jsx index 957a299..361a3a6 100644 --- a/src/menu/components/share/actioncomponent/formconfig.jsx +++ b/src/menu/components/share/actioncomponent/formconfig.jsx @@ -1061,6 +1061,21 @@ }, { type: 'radio', + key: 'recordUser', + label: '璁板綍鐢ㄦ埛', + initVal: card.recordUser || 'false', + tooltip: '褰撻�夋嫨鈥滄槸鈥濇椂锛屽唴閮ㄥ嚱鏁扮殑浼犲弬浼氬鍔� username 涓� fullname銆�', + required: false, + options: [{ + value: 'false', + text: '鍚�' + }, { + value: 'true', + text: '鏄�' + }] + }, + { + type: 'radio', key: 'control', label: '鎸夐挳鎺у埗', initVal: card.control || (card.controlField ? 'disabled' : ''), @@ -2007,6 +2022,21 @@ }, { type: 'radio', + key: 'recordUser', + label: '璁板綍鐢ㄦ埛', + initVal: card.recordUser || 'false', + tooltip: '褰撻�夋嫨鈥滄槸鈥濇椂锛屽唴閮ㄥ嚱鏁扮殑浼犲弬浼氬鍔� username 涓� fullname銆�', + required: false, + options: [{ + value: 'false', + text: '鍚�' + }, { + value: 'true', + text: '鏄�' + }] + }, + { + type: 'radio', key: 'control', label: '鎸夐挳鎺у埗', initVal: card.control || (card.controlField ? 'disabled' : ''), diff --git a/src/menu/components/share/actioncomponent/index.jsx b/src/menu/components/share/actioncomponent/index.jsx index 516e8c2..3599e68 100644 --- a/src/menu/components/share/actioncomponent/index.jsx +++ b/src/menu/components/share/actioncomponent/index.jsx @@ -4,7 +4,7 @@ import { Modal, notification, Button } from 'antd' import moment from 'moment' -import Utils, { FuncUtils } from '@/utils/utils.js' +import Utils from '@/utils/utils.js' import { getActionForm, getBaseTableActionForm } from './formconfig' import asyncSpinComponent from '@/utils/asyncSpinComponent' import MKEmitter from '@/utils/events.js' @@ -526,55 +526,47 @@ * @description 鍒涘缓鎸夐挳瀛樺偍杩囩▼ */ creatFunc = () => { + const { config } = this.props const menu = window.GLOB.customMenu - let _config = fromJS(this.props.config).toJS() - this.actionFormRef.handleConfirm().then(res => { - let btn = res // 鎸夐挳淇℃伅 - let newLText = '' // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = '' // 鍒犻櫎瀛樺偍杩囩▼sql + return new Promise((resolve) => { + this.actionFormRef.handleConfirm().then(res => { + let btn = fromJS(res).toJS() + let _config = fromJS(config).toJS() - // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕 - if (btn.intertype !== 'inner') { - notification.warning({ - top: 92, - message: '浣跨敤鍐呴儴鍑芥暟鏃讹紝鎵嶅彲浠ュ垱寤哄瓨鍌ㄨ繃绋嬶紒', - duration: 5 - }) - return - } + if (btn.OpenType === 'excelIn') { + btn.func = btn.innerFunc + btn.menuNo = menu.MenuNo + btn.MenuName = menu.MenuName + _config.name + btn.$type = 'excelIn' - if (btn.OpenType === 'pop') { - let _param = { - funcName: btn.innerFunc, - name: _config.setting.tableName || '', - fields: btn.modal ? btn.modal.fields : [], - menuNo: menu.MenuNo + resolve(btn) + } else if (btn.OpenType === 'excelOut') { + _config.MenuName = menu.MenuName + '-' + _config.name + _config.menuNo = menu.MenuNo + _config.MenuID = menu.MenuID + _config.func = btn.innerFunc + _config.$type = 'table' + + resolve(_config) + } else { + btn.func = btn.innerFunc + btn.name = _config.setting.tableName || '' + btn.menuNo = menu.MenuNo + btn.MenuID = menu.MenuID + btn.MenuName = menu.MenuName + _config.name + btn.fields = [] + btn.columns = _config.columns + btn.primaryKey = _config.setting.primaryKey || 'ID' + btn.$type = 'btn' + + if (btn.OpenType === 'pop') { + btn.fields = btn.modal ? btn.modal.fields : [] + } + + resolve(btn) } - newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) - } else if (btn.OpenType === 'excelIn') { - let _param = { - funcName: btn.innerFunc, - menuNo: menu.MenuNo - } - newLText = Utils.formatOptions(FuncUtils.getexcelInfunc(_param, btn, menu)) - DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) - } else if (btn.OpenType === 'excelOut') { - newLText = Utils.formatOptions(FuncUtils.getTableFunc(btn.innerFunc, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql - DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) - } else { - let _param = { - funcName: btn.innerFunc, - name: _config.setting.tableName || '', - fields: '', - menuNo: menu.MenuNo - } - newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config)) - DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc)) - } - - this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText) + }) }) } @@ -710,7 +702,7 @@ maskClosable={false} onCancel={this.editModalCancel} footer={[ - record && record.intertype === 'inner' ? <CreateFunc key="create" ref="btnCreatFunc" trigger={this.creatFunc}/> : null, + record && record.intertype === 'inner' ? <CreateFunc key="create" getMsg={this.creatFunc}/> : null, <Button key="cancel" onClick={this.editModalCancel}>鍙栨秷</Button>, <Button key="confirm" type="primary" onClick={this.handleSubmit}>纭畾</Button> ]} diff --git a/src/menu/datasource/index.jsx b/src/menu/datasource/index.jsx index dfa48d8..4076942 100644 --- a/src/menu/datasource/index.jsx +++ b/src/menu/datasource/index.jsx @@ -1,10 +1,11 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Modal } from 'antd' +import { Modal, Button } from 'antd' import { SettingOutlined } from '@ant-design/icons' import VerifyCard from './verifycard' +import CreateFunc from '@/templates/zshare/createfunc' import './index.scss' class DataSource extends Component { @@ -19,7 +20,8 @@ mainSearch: [], visible: false, loading: false, - setting: null + setting: null, + record: {} } UNSAFE_componentWillMount () { @@ -134,7 +136,8 @@ this.setState({ visible: true, - mainSearch: search + mainSearch: search, + record: {...config.setting} }) } @@ -224,9 +227,34 @@ }) } + creatFunc = () => { + const { config } = this.props + const { mainSearch } = this.state + const menu = window.GLOB.customMenu + + return new Promise((resolve) => { + this.verifyRef.submitDataSource().then(res => { + let _config = fromJS(config).toJS() + _config.MenuName = menu.MenuName + '-' + _config.name + _config.menuNo = menu.MenuNo + _config.MenuID = menu.MenuID + _config.setting = res.setting + _config.columns = res.columns + _config.func = res.setting.innerFunc + _config.$type = 'table' + + if (res.setting.useMSearch === 'true') { // 浣跨敤涓绘悳绱㈡潯浠� + _config.search = [..._config.search, ...mainSearch] + } + + resolve(_config) + }) + }) + } + render () { const { config } = this.props - const { visible, loading, mainSearch } = this.state + const { visible, loading, mainSearch, record } = this.state return ( <div className="model-datasource"> @@ -238,14 +266,18 @@ width={'75vw'} maskClosable={false} okText="鎻愪氦" - onOk={this.verifySubmit} - confirmLoading={loading} - onCancel={() => {this.setState({ visible: false }) }} + onCancel={() => {this.setState({ visible: false, loading: false }) }} + footer={[ + config.subtype !== 'dualdatacard' && record.interType === 'inner' ? <CreateFunc key="create" getMsg={this.creatFunc}/> : null, + <Button key="cancel" onClick={() => { this.setState({ visible: false, loading: false }) }}>鍙栨秷</Button>, + <Button key="confirm" type="primary" loading={loading} onClick={this.verifySubmit}>纭畾</Button> + ]} destroyOnClose > <VerifyCard mainSearch={mainSearch} config={config} + updRecord={(record) => this.setState({record: record})} wrappedComponentRef={(inst) => this.verifyRef = inst} /> </Modal> diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx index 8cc92cc..9d84902 100644 --- a/src/menu/datasource/verifycard/index.jsx +++ b/src/menu/datasource/verifycard/index.jsx @@ -29,7 +29,8 @@ class VerifyCard extends Component { static propTpyes = { - config: PropTypes.object, // 缁勪欢閰嶇疆淇℃伅 + config: PropTypes.object, + updRecord: PropTypes.func } state = { @@ -911,7 +912,14 @@ this.setState({reload: false}) }) } + + this.props.updRecord({...res.data.setting}) }) + } + + updateStatus = (res) => { + this.setState({median: {...res}}) + this.props.updRecord({...res}) } copyColumns = () => { @@ -985,7 +993,7 @@ subColumns={subColumns} setting={setting} scripts={scripts} - updateStatus={(res) => this.setState({median: {...res}})} + updateStatus={this.updateStatus} wrappedComponentRef={(inst) => this.settingForm = inst} /> : null} </TabPane> diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index 6d5fa3e..3c256d0 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -484,6 +484,22 @@ })(<InputNumber min={1} max={500} precision={0} />)} </Form.Item> </Col> : null} + {setting.interType === 'inner' ? <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title="褰撻�夋嫨鈥滄槸鈥濇椂锛屽唴閮ㄥ嚱鏁扮殑浼犲弬浼氬鍔� username 涓� fullname銆�"> + <QuestionCircleOutlined className="mk-form-tip" /> + 璁板綍鐢ㄦ埛 + </Tooltip> + }> + {getFieldDecorator('recordUser', { + initialValue: setting.recordUser || 'false' + })( + <Radio.Group onChange={(e) => {this.onOptionChange(e.target.value, 'recordUser')}}> + <Radio value="false">鍚�</Radio> + <Radio value="true">鏄�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} {/* 1銆佷笉鍒嗛〉涓斾笉瀛樺湪涓婄骇妯″潡 */} {!['navbar', 'interface', 'calendar'].includes(config.type) && !['editable', 'basetable', 'dualdatacard'].includes(config.subtype) && (!config.pageable || (config.pageable && setting.laypage === 'false')) && (setting.supModule.length === 0 || setting.supModule[0] === 'empty') && setting.interType === 'system' && setting.onload !== 'false' ? <Col span={8}> <Form.Item label={ diff --git a/src/tabviews/custom/components/module/voucher/index.jsx b/src/tabviews/custom/components/module/voucher/index.jsx index 8142461..361e710 100644 --- a/src/tabviews/custom/components/module/voucher/index.jsx +++ b/src/tabviews/custom/components/module/voucher/index.jsx @@ -609,7 +609,7 @@ sup_data.push(`'${n.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${n.voucher_sup_lp || ''}','${item.subject_code}','${item.subject_name}','${n.sup_voucher_text || ''}','${direct}',${item.debit || item.credit},'${n.customercode || ''}','${n.customername || ''}','${n.suppliercode || ''}','${n.suppliername || ''}','${n.co_pro_code || ''}','${n.co_pro_name || ''}','${n.workercode || ''}','${n.workername || ''}','${n.project_code || ''}','${n.project_name || ''}','${n.productcode || ''}','${n.productname || ''}','${n.cash_flow_code || ''}','${n.cash_flow_name || ''}','${n.sup_acc_code || ''}','${n.sup_acc_name || ''}','${n.sup_acc_type || ''}','${item.uuid}',0,'${n.lessor_code || ''}','${n.lessor_name || ''}','${n.logistics_code || ''}','${n.logistics_name || ''}'`) }) } - return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'` + return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : ''}','${curr ? item.exratename : ''}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'` }) if (type === 'createVoucher') { @@ -625,7 +625,7 @@ let curr = item.foreign_currency_type === 'Y' let direct = item.debit ? 'debit' : 'credit' - subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'`) + subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit},'${direct}','${curr ? item.exratecode : ''}','${curr ? item.exratename : ''}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.debit ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'`) }) supMap.forEach(n => { @@ -902,7 +902,7 @@ sup_data.push(`'${n.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${n.voucher_sup_lp || ''}','${item.subject_code}','${item.subject_name}','${n.sup_voucher_text || ''}','${direct}',${item.debit || item.credit || 0},'${n.customercode || ''}','${n.customername || ''}','${n.suppliercode || ''}','${n.suppliername || ''}','${n.co_pro_code || ''}','${n.co_pro_name || ''}','${n.workercode || ''}','${n.workername || ''}','${n.project_code || ''}','${n.project_name || ''}','${n.productcode || ''}','${n.productname || ''}','${n.cash_flow_code || ''}','${n.cash_flow_name || ''}','${n.sup_acc_code || ''}','${n.sup_acc_name || ''}','${n.sup_acc_type || ''}','${item.uuid}',0,'${n.lessor_code || ''}','${n.lessor_name || ''}','${n.logistics_code || ''}','${n.logistics_name || ''}'`) }) } - return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'` + return `'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : ''}','${curr ? item.exratename : ''}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},0,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'` }) voucherMap.forEach(item => { @@ -910,7 +910,7 @@ let curr = item.foreign_currency_type === 'Y' let direct = !item.credit ? 'debit' : 'credit' - subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : '01010001'}','${curr ? item.exratename : 'CNY'}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'`) + subject_data.push(`'${item.uuid}','${item.subject_voucher_code || ''}','${item.voucher_lp || ''}','${item.subject_code}','${item.subject_name}','${item.subject_voucher_text || ''}',${count ? item.fcc_count || 0 : 0},${count ? item.net_unitprice || 0 : 0},'${item.unit}',${item.debit || item.credit || 0},'${direct}','${curr ? item.exratecode : ''}','${curr ? item.exratename : ''}',${curr ? item.unitratio || 0 : 0},'${item.sup_accounting}',${item.direct ? 1 : -1},${curr ? item.foreign_amount || 0 : 0},1,'${item.local_currency || ''}','${count ? 'Y' : ''}','${curr ? 'Y' : ''}','${item.closing_foreign_exchange || ''}'`) }) supMap.forEach(n => { diff --git a/src/tabviews/zshare/actionList/excelInbutton/index.jsx b/src/tabviews/zshare/actionList/excelInbutton/index.jsx index 0104e10..2a9e4a7 100644 --- a/src/tabviews/zshare/actionList/excelInbutton/index.jsx +++ b/src/tabviews/zshare/actionList/excelInbutton/index.jsx @@ -271,7 +271,7 @@ * @description Excel 瀵煎叆 */ getexceldata = (data, errors, sheetName, errDetail) => { - const { btn } = this.props + const { btn, BID } = this.props if (errors) { if (errors === 'notexit') { @@ -314,7 +314,7 @@ }) } - let result = getExcelInSql(btn, data, (this.props.BID || ''), this.state.primaryId) + let result = getExcelInSql(btn, data, (BID || ''), this.state.primaryId) if (result.errors) { notification.warning({ @@ -331,30 +331,29 @@ excel_in: result.lines } - if (this.props.BID) { - param.BID = this.props.BID + if (BID) { + param.BID = BID } if (btn.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼ param.func = 'sPC_TableData_InUpDe' - param.excel_in_type = 'true' - param.LText1 = Utils.formatOptions(result.insert) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.LText2 = result.bottom + delete param.excel_in + + // param.excel_in_type = 'true' + param.exec_type = 'y' param.LText = result.sql + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') let unCheckParam = null - if (/\$check@|@check\$/ig.test(param.LText2) || /\$check@|@check\$/ig.test(param.LText)) { + if (/\$check@|@check\$/ig.test(param.LText)) { unCheckParam = fromJS(param).toJS() param.LText = param.LText.replace(/\$check@|@check\$/ig, '') - param.LText2 = param.LText2.replace(/\$check@|@check\$/ig, '') } - param.LText2 = Utils.formatOptions(param.LText2) param.LText = Utils.formatOptions(param.LText) - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.secretkey = Utils.encrypt('', param.timestamp) if (window.GLOB.mkHS && param.timestamp) { // 浜戠楠岃瘉 param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) } @@ -368,11 +367,7 @@ if (unCheckParam) { unCheckParam.LText = unCheckParam.LText.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') unCheckParam.LText = Utils.formatOptions(unCheckParam.LText) - unCheckParam.LText2 = unCheckParam.LText2.replace(/\$check@/ig, '/*').replace(/@check\$/ig, '*/') - unCheckParam.LText2 = Utils.formatOptions(unCheckParam.LText2) - - unCheckParam.secretkey = Utils.encrypt(unCheckParam.LText, unCheckParam.timestamp) - + unCheckParam.secretkey = Utils.encrypt('', unCheckParam.timestamp) unCheckParam.menuname = btn.logLabel if (window.GLOB.probation) { @@ -424,6 +419,11 @@ } } else if (btn.intertype === 'inner' && btn.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋� param.func = btn.innerFunc + + if (btn.recordUser === 'true') { + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + } Api.genericInterface(param).then((res) => { if (res.status) { @@ -515,7 +515,8 @@ } if (window.GLOB.mkHS && res.func === 's_sDataDictb_excelIn') { // s_sDataDictb_excelIn 浜戠楠岃瘉 - param.LText = Utils.formatOptions(result.sql) + let sql = `Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512)` + param.LText = Utils.formatOptions(sql) param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt(param.LText, param.timestamp) param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) diff --git a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx index c4d8307..0cab6e9 100644 --- a/src/tabviews/zshare/actionList/exceloutbutton/index.jsx +++ b/src/tabviews/zshare/actionList/exceloutbutton/index.jsx @@ -180,6 +180,11 @@ let param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search) param.func = btn.innerFunc + if (btn.recordUser === 'true') { + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + } + Api.genericInterface(param).then(result => { if (result.status) { this.exportExcel(result.data, result.ErrCode, result.message) @@ -420,6 +425,11 @@ param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) param.func = btn.innerFunc + if (btn.recordUser === 'true') { + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + } + } else if (btn.intertype === 'outer' && !btn.innerFunc) { // 浣跨敤澶栭儴鍑芥暟 param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize) diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index f07a1dd..a5c366c 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -740,6 +740,11 @@ if (this.props.BID) { param.BID = this.props.BID } + + if (btn.recordUser === 'true') { + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + } let primaryId = '' @@ -778,6 +783,11 @@ param.BID = this.props.BID } + if (btn.recordUser === 'true') { + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + } + let primaryId = setting.primaryKey ? cell[setting.primaryKey] || '' : '' if (btn.OpenType === 'pop') { // 琛ㄥ崟 diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index fdc3ac2..db4fd6a 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -903,6 +903,11 @@ if (btn.intertype === 'inner') { params = params.map(_param => { _param.func = btn.innerFunc + + if (btn.recordUser === 'true') { + _param.username = sessionStorage.getItem('User_Name') || '' + _param.fullname = sessionStorage.getItem('Full_Name') || '' + } return _param }) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx index 83ebde0..e3eda1e 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx @@ -46,16 +46,9 @@ } this.props.columnChange(values) - this.setState({ - locked: false, - type: 'Nvarchar(50)' - }) this.props.form.setFieldsValue({ Column: '', - Text: '', - required: 'true', - import: 'true', - type: 'Nvarchar(50)' + Text: '' }) } }) diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx index f5726e6..fae2423 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx @@ -50,7 +50,7 @@ _dec += ',' } - let _sql = `Declare @${btn.sheet.replace(/@db@/ig, '')} table (${_dec}jskey nvarchar(50) ) + let _sql = `create table #${btn.sheet.replace(/@db@/ig, '')} (${_dec}jskey nvarchar(50),BID nvarchar(50) ) Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50), @retmsg nvarchar(4000),@tbid Nvarchar(512) Select @ErrorCode='', @retmsg='' ` @@ -81,7 +81,7 @@ } handleConfirm = () => { - const { type } = this.props + const { type, btn } = this.props const { editItem, skip } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� @@ -162,7 +162,8 @@ } let tail = ` - aaa: + drop table #${btn.sheet.replace(/@db@/ig, '')} + aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg ` let _initCustomScript = '' // 鍒濆鍖栬剼鏈� @@ -290,7 +291,7 @@ database = database ? (database[0] || '') : '' - _value = `Insert into ${database}${sheet} (${fields}createuserid,createuser,createstaff,bid)\nSelect ${fields}@userid@,@username,@fullname,@BID@ From @${sheet}` + _value = `Insert into ${database}${sheet} (${fields}createuserid,createuser,createstaff,bid)\nSelect ${fields}@userid@,@username,@fullname,@BID@ From #${sheet}` } else { _value = value } @@ -336,7 +337,7 @@ <Row gutter={24}> {!type && btn.sheet ? <Col span={8}> <Form.Item label={'琛ㄥ悕'} style={{whiteSpace: 'nowrap', margin: 0}}> - {btn.sheet} + {btn.sheet}锛堣〃鍙橀噺璇蜂娇鐢�#{btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '')}锛� </Form.Item> </Col> : null} {!type ? <Col span={10}> diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx index 0bc167a..38fdf04 100644 --- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx +++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx @@ -73,14 +73,6 @@ ] }, { - title: '蹇呭~', - dataIndex: 'required', - width: '10%', - editable: true, - inputType: 'switch', - render: (text, record) => record.required === 'true' ? '鏄�' : '鍚�' - }, - { title: '瀵煎叆', dataIndex: 'import', width: '10%', @@ -101,6 +93,14 @@ ] }, { + title: '蹇呭~', + dataIndex: 'required', + width: '10%', + editable: true, + inputType: 'switch', + render: (text, record) => record.required === 'true' ? '鏄�' : '鍚�' + }, + { title: '鏈�灏忓��', dataIndex: 'min', width: '10%', diff --git a/src/templates/sharecomponent/settingcomponent/index.jsx b/src/templates/sharecomponent/settingcomponent/index.jsx index 24a1ce3..6d9bb70 100644 --- a/src/templates/sharecomponent/settingcomponent/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/index.jsx @@ -4,10 +4,7 @@ import { Modal, Button } from 'antd' import { SettingOutlined } from '@ant-design/icons' -import Utils, { FuncUtils } from '@/utils/utils.js' import SettingForm from './settingform' -import CreateFunc from '@/templates/zshare/createfunc' -import CreateInterface from '@/templates/zshare/createinterface' // import './index.scss' @@ -73,43 +70,26 @@ }) } - /** - * @description 鍒涘缓琛ㄦ牸瀛樺偍杩囩▼ - */ - tableCreatFunc = () => { - const { config } = this.props - const { menu } = this.state + // /** + // * @description 鍒涘缓琛ㄦ牸鎺ュ彛锛堣鍑猴級 + // */ + // tableCreatInterface = () => { + // const { config } = this.props + // const { menu } = this.state - this.settingRef.handleConfirm('loading').then(setting => { - let res = this.resetSetting(setting, config.setting) - let _config = {...config, setting: res} - let newLText = Utils.formatOptions(FuncUtils.getTableFunc(setting.innerFunc, menu, _config)) // 鍒涘缓瀛樺偍杩囩▼sql - let DelText = Utils.formatOptions(FuncUtils.dropfunc(setting.innerFunc)) // 鍒犻櫎瀛樺偍杩囩▼sql + // this.settingRef.handleConfirm('loading').then(setting => { + // let res = this.resetSetting(setting, config.setting) + // let _config = {...config, setting: res} + // let _menu = { + // type: config.Template === 'CommonTable' ? 'main' : 'subtable', + // MenuID: menu.MenuID, + // menuName: menu.MenuName, + // menuNo: menu.MenuNo + // } - this.refs.funcCreatComponent.exec(setting.innerFunc, newLText, DelText) - }) - } - - /** - * @description 鍒涘缓琛ㄦ牸鎺ュ彛锛堣鍑猴級 - */ - tableCreatInterface = () => { - const { config } = this.props - const { menu } = this.state - - this.settingRef.handleConfirm('loading').then(setting => { - let res = this.resetSetting(setting, config.setting) - let _config = {...config, setting: res} - let _menu = { - type: config.Template === 'CommonTable' ? 'main' : 'subtable', - MenuID: menu.MenuID, - menuName: menu.MenuName, - menuNo: menu.MenuNo - } - - this.refs.tableCreatInterface.triggerOutInterface(_menu, _config) - }) - } + // this.refs.tableCreatInterface.triggerOutInterface(_menu, _config) + // }) + // } resetSetting = (s, ori) => { let setting = fromJS(s).toJS() @@ -179,7 +159,7 @@ render() { const { config } = this.props - const { visible, search, menu, record } = this.state + const { visible, search, menu } = this.state return ( <> @@ -192,8 +172,6 @@ maskClosable={false} onCancel={() => { this.setState({ visible: false, loading: false })}} footer={[ - record && record.interType === 'system' ? <CreateInterface key="interface" loading={this.state.interloading} ref="tableCreatInterface" trigger={this.tableCreatInterface}/> : null, - record && record.interType === 'inner' ? <CreateFunc key="create" ref="funcCreatComponent" trigger={this.tableCreatFunc}/> : null, <Button key="cancel" onClick={() => { this.setState({ visible: false, loading: false }) }}>鍙栨秷</Button>, <Button key="confirm" type="primary" loading={this.state.loading} onClick={this.settingSave}>纭畾</Button> ]} @@ -203,7 +181,7 @@ menu={menu} config={config} search={search} - updRecord={(record) => this.setState({record: fromJS(record).toJS()})} + updRecord={() => {}} wrappedComponentRef={(inst) => this.settingRef = inst} /> </Modal> diff --git a/src/templates/zshare/createfunc/index.jsx b/src/templates/zshare/createfunc/index.jsx index 6fca05b..d464a7f 100644 --- a/src/templates/zshare/createfunc/index.jsx +++ b/src/templates/zshare/createfunc/index.jsx @@ -4,203 +4,125 @@ import moment from 'moment' import Utils from '@/utils/utils.js' +import FuncUtils from './utils.js' import Api from '@/api' // import './index.scss' class CreateFunc extends Component { static propTypes = { - trigger: PropTypes.func + getMsg: PropTypes.func } state = { - loading: false, + loading: false } - exec = (innerFunc, newLText, DelText) => { + trigger = () => { + this.props.getMsg().then(config => { + let newLText = '' + let func = '' + + if (config.$type === 'table') { + func = config.func + newLText = FuncUtils.getTableFunc(config) + } else if (config.$type === 'excelIn') { + func = config.func + newLText = FuncUtils.getexcelInfunc(config) + } else if (config.$type === 'btn') { + func = config.func + newLText = FuncUtils.getfunc(config) + } + + if (!newLText || !func) return + + this.createExec(func, newLText) + }) + } + + createExec = (func, newLText) => { + let dropfunc = `IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('${func}') AND type in (N'P', N'PC')) mdrpk PROCEDURE ${func}` + // 鍒犻櫎瀛樺偍杩囩▼ + let droparam = { + func: 'sPC_TableData_InUpDe', + LText: Utils.formatOptions(dropfunc), + TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋嬫爣蹇� + } + + droparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + droparam.secretkey = Utils.encrypt(droparam.LText, droparam.timestamp) + droparam.open_key = Utils.encryptOpenKey(droparam.secretkey, droparam.timestamp) + + // 鏂板缓瀛樺偍杩囩▼ + let _param = { + func: 'sPC_TableData_InUpDe', + LText: Utils.formatOptions(newLText), + TypeCharOne: 'proc' + } + _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) + _param.open_key = Utils.encryptOpenKey(_param.secretkey, _param.timestamp) + + let saveParam = { + func: 's_proc_save', + sql_script: window.btoa(window.encodeURIComponent(newLText)), + proc_name: func, + save_type: 'auto' + } + this.setState({ loading: true }) - this.createExec(innerFunc, newLText, DelText) - } - - createExec = (innerFunc, newLText, DelText) => { - let isExist = false // 瀛樺偍杩囩▼鏄惁瀛樺湪 - let cloudText = '' // 浜戠瀛樺偍缁撴灉 - let localfunc = '' // 鏈湴瀛樺偍杩囩▼ - - new Promise(resolve => { - // 鑾峰彇浜戠瀛樺偍杩囩▼淇℃伅 - Api.getCloudConfig({ - func: 'sPC_Get_TVP', - TVPName: innerFunc - }).then(result => { + Api.genericInterface(droparam).then(res => { + if (!res.status) { + notification.warning({ + top: 92, + message: res.message, + duration: 5 + }) + this.setState({ + loading: false + }) + return + } + Api.genericInterface(_param).then(result => { if (!result.status) { notification.warning({ top: 92, message: result.message, duration: 5 }) - resolve(false) - } else { - cloudText = result.TVPText - resolve(true) - } - }) - }).then(res => { - if (!res) return res - // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅 - - let _param = { - func: 's_get_userproc', - LText: innerFunc - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - - return Api.genericInterface(_param) - }).then(res => { - if (!res) return res - - // 澶勭悊鏈湴缁撴灉 - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - return false - } else { - isExist = true - localfunc = Utils.formatOptions(res.Ltext) - return true - } - }).then(res => { - if (!res) return res - - // 鏍规嵁鏈湴鍙婅繙绔粨鏋滃垽鏂墽琛屽姩浣� - if ((newLText === localfunc) && (newLText === cloudText)) { - return 'drop' - } else if (!localfunc || (cloudText === localfunc)) { - // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝鎴栦簯绔拰鏈湴瀛樺偍杩囩▼涓�鑷存椂锛屽皢鏂扮殑瀛樺偍杩囩▼鏇存柊鑷充簯绔� - return Api.getCloudConfig({ - func: 'sPC_TVP_InUp', - TVPName: innerFunc, - TVPText: newLText, - TypeName: 'P' - }) - } else { - return new Promise(resolve => { - Api.getCloudConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠 - func: 'sPC_TVP_InUp', - TVPName: innerFunc, - TVPText: localfunc, - TypeName: 'P' - }).then(result => { - if (result.status) { - Api.getCloudConfig({ - func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔� - TVPName: innerFunc, - TVPText: newLText, - TypeName: 'P' - }).then(response => { - resolve(response) - }) - } else { - resolve(result) - } + this.setState({ + loading: false }) + return + } + + Api.genericInterface(saveParam).then(response => { + this.setState({loading: false}) + if (!response.status) { + notification.warning({ + top: 92, + message: response.message, + duration: 5 + }) + } else { + notification.success({ + top: 92, + message: '鍒涘缓鎴愬姛銆�', + duration: 5 + }) + } }) - } - }).then(res => { - if (!res || res === 'drop') return res - - // 澶勭悊浜戠鏇存柊缁撴灉 - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - return false - } else if (isExist) { - return 'drop' - } else { - return 'create' - } - }).then(res => { - if (!res || res === 'create') return res - - // 鍒犻櫎瀛樺偍杩囩▼ - let _param = { - func: 'sPC_TableData_InUpDe', - LText: DelText, - TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋嬫爣蹇� - } - - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - _param.open_key = Utils.encryptOpenKey(_param.secretkey, _param.timestamp) - - return Api.genericInterface(_param) - }).then(res => { - if (!res || res === 'create') return res - - // 鍒犻櫎缁撴灉澶勭悊 - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - return false - } else { - return true - } - }).then(res => { - if (!res) return res - - // 鏂板缓瀛樺偍杩囩▼ - let _param = { - func: 'sPC_TableData_InUpDe', - LText: newLText, - TypeCharOne: 'proc' - } - _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp) - _param.open_key = Utils.encryptOpenKey(_param.secretkey, _param.timestamp) - - return Api.genericInterface(_param) - }).then(res => { - this.setState({ - loading: false }) - - if (!res) return res - - // 澶勭悊鏂板缓缁撴灉 - if (!res.status) { - notification.warning({ - top: 92, - message: res.message, - duration: 5 - }) - } else { - notification.success({ - top: 92, - message: '鍒涘缓鎴愬姛', - duration: 2 - }) - } }) } render() { - return ( <Button className="mk-btn mk-purple" - onClick={this.props.trigger} + onClick={this.trigger} loading={this.state.loading} > 鍒涘缓瀛樺偍杩囩▼ diff --git a/src/templates/zshare/createfunc/utils.js b/src/templates/zshare/createfunc/utils.js new file mode 100644 index 0000000..2e0c1b6 --- /dev/null +++ b/src/templates/zshare/createfunc/utils.js @@ -0,0 +1,454 @@ +/** + * @description 鍒涘缓瀛樺偍杩囩▼绫� + */ +export default class FuncUtils { + /** + * @description 鍒涘缓椤甸潰瀛樺偍杩囩▼ + * @return {String} + */ + static getTableFunc (config) { + let form = '' + let formParam = '' + let _vars = ['bid', 'pageindex', 'pagesize', 'ordercol', 'ordertype', 'exceltype', 'septmenuno', 'lang', 'debug', 'loginuid', 'sessionuid', 'userid', 'errorcode', 'retmsg'] + let _columns = [] + let primaryKey = config.setting.primaryKey || 'ID' + + if (!_vars.includes(primaryKey.toLowerCase())) { + _vars.push(primaryKey.toLowerCase()) + formParam = `mchr13k@${primaryKey} nvarchar(50)='',` + } + + if (config.search && config.search.length > 0) { + let _fields = new Map() + config.search.forEach(item => { + if (item.field) { + let type = '' + + if (item.type.match(/date/ig)) { + type = 'datetime=null' + } else { + type = 'nvarchar(50)=\'\'' + } + + item.field.split(',').forEach(cell => { + let _f = cell + if (_fields.has(cell)) { + _f = _f + '1' + } + + _fields.set(cell, true) + + if (!_vars.includes(_f.toLowerCase())) { + _vars.push(_f.toLowerCase()) + formParam = formParam + `mchr13k@${_f} ${type},` + } + }) + } + }) + } + + if (config.columns && config.columns.length > 0) { + config.columns.forEach(item => { + if (item.field) { + _columns.push(`${item.field} as ${item.label}`) + } + }) + + form = ` + declare @dc table (${_columns.join(',')}) + + @tableid ='${config.MenuID}' + ` + } + + let Ltext = `create proc ${config.func} + ( /*${config.MenuName}*/ + @appkey nvarchar(50)='', + @BID nvarchar(50)='', + @UserName nvarchar(50)='', + @FullName nvarchar(50)='',${formParam} + @PageIndex nvarchar(50)='', + @PageSize nvarchar(50)='', + @OrderCol nvarchar(50)='', + @OrderType nvarchar(50)='', + @exceltype nvarchar(50)='', + @sEPTMenuNo nvarchar(50)='${config.menuNo}', + @lang nvarchar(50)='', + @debug nvarchar(50)='', + @LoginUID nvarchar(50)='', + @SessionUid nvarchar(50)='', + @UserID nvarchar(50), + @dataM nvarchar(50), + @ErrorCode nvarchar(50) out, + @retmsg nvarchar(4000) out + ) + as + begin + declare @BegindateTest datetime,@EnddateTest datetime + select @BegindateTest=getdate() + set @ErrorCode='' + set @retmsg='' + BEGIN TRY + /*浜嬪姟鎿嶄綔*/ + BEGIN TRAN + /*鍏蜂綋涓氬姟鎿嶄綔*/ + + /* + select top 10 * from sProcExcep order by id desc + + ${form} + if 1=2 + begin + set @ErrorCode='E' + set @retmsg='鍦ㄦ鍐欐姤閿�' + goto GOTO_RETURN + end + + insert into sNote (remark,createuserid,CreateUser,CreateStaff) + select '鍦ㄦ鍐欐棩蹇�',@UserID,@UserName,@FullName + */ + + COMMIT TRAN + SET NOCOUNT ON + RETURN + END TRY + BEGIN CATCH + /*閿欒澶勭悊*/ + ROLLBACK TRAN + DECLARE @ErrorMessage NVARCHAR(4000); + DECLARE @ErrorSeverity INT; + DECLARE @ErrorState INT; + + /*鎶婅嚜瀹氫箟鐨勫弸濂界殑閿欒淇℃伅鎻愮ず鍔犱笂*/ + set @ErrorCode=cast(ERROR_NUMBER() as nvarchar(50)) + SET @retmsg=ERROR_MESSAGE(); + SELECT @ErrorMessage=ERROR_MESSAGE(), + @ErrorSeverity=ERROR_SEVERITY(), + @ErrorState=ERROR_STATE(); + + RAISERROR(@ErrorMessage, /*-- Message text.*/ + @ErrorSeverity, /*-- Severity.*/ + @ErrorState /*-- State.*/ + ); + END CATCH + + GOTO_RETURN: + ROLLBACK TRAN + + END` + + Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') + + return Ltext + } + + /** + * @description 鍒涘缓瀛樺偍杩囩▼ + * @return {String} + */ + static getfunc (btn) { + let form = '' + let formParam = '' + let _vars = ['bid', 'septmenuno', 'lang', 'debug', 'loginuid', 'sessionuid', 'userid', 'errorcode', 'retmsg'] + let columns = btn.columns + let primaryKey = btn.primaryKey + + if (!_vars.includes(primaryKey.toLowerCase())) { + _vars.push(primaryKey.toLowerCase()) + let _type = '50' + if (btn.Ot === 'requiredOnce') { // 澶氳鎷兼帴鏃讹紝涓婚敭璁句负max + _type = 'max' + } + formParam = `mchr13k@${primaryKey} nvarchar(${_type})='',` + } + + if (btn.fields && btn.fields.length > 0) { + let _fields = [] + btn.fields.forEach(item => { + if (item.field) { + let type = '' + if (item.type.match(/date/ig)) { + type = 'datetime=null' + } else if (item.type === 'number') { + type = `decimal(18,${item.decimal})=0` + } else if (item.type === 'rate') { + type = `decimal(18,2)=0` + } else { + type = 'nvarchar(50)=\'\'' + } + + if (!_vars.includes(item.field.toLowerCase())) { + _vars.push(item.field.toLowerCase()) + formParam = formParam + `mchr13k@${item.field} ${type},` + } + + _fields.push(item.field) + } + }) + + let field1 = _fields.join(',') + let field2 = _fields.join(',@') + let field3 = _fields.map(cell => { + return cell + '=@' + cell + }) + + field2 = field2 ? '@' + field2 : '' + field3 = field3.join(',') + + form = ` + insert into ${btn.name} (${field1},createuserid) select ${field2},@UserID + + update ${btn.name} set ${field3},modifydate=getdate(),modifyuser=@username,modifyuserid=@UserID + ` + } else if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { + form = ` + update ${btn.name} set ModifyDate=getdate(),ModifyUserID=@UserID where ${primaryKey}=@${primaryKey} + ` + } + + if (columns) { + let _col = [] + let _field = [] + columns.forEach(col => { + if (col.field) { + if (col.type === 'number') { + _col.push(col.field + ' decimal(18,2)') + } else { + _col.push(col.field + ' nvarchar(50)') + } + _field.push(col.field) + } + }) + _col = _col.join(',') + _field = _field.join(',') + + form = form + ` + declare @dc table (${_col}) + + insert into @dc (${_field}) + + @tableid ='${btn.MenuID}' + ` + } + + // 鎵撳嵃鑷畾涔夋ā鏉垮瓧娈垫彁绀� + let _printRemark = '' + if (btn.funcType === 'print') { + _printRemark = '/* 鑷畾涔夋暟鎹墦鍗版ā鏉挎椂锛岃浣跨敤TemplateID瀛楁 */' + } + + let Ltext = `create proc ${btn.func} + ( /*${btn.MenuName} ${btn.label}*/ + @appkey nvarchar(50)='', + @BID nvarchar(50)='', + @UserName nvarchar(50)='', + @FullName nvarchar(50)='',${formParam} + @sEPTMenuNo nvarchar(50)='${btn.menuNo}', + @lang nvarchar(50)='', + @debug nvarchar(50)='', + @LoginUID nvarchar(50)='', + @SessionUid nvarchar(50)='', + @UserID nvarchar(50), + @ErrorCode nvarchar(50) out, + @retmsg nvarchar(4000) out + ) + as + begin + declare @BegindateTest datetime,@EnddateTest datetime + select @BegindateTest=getdate() + set @ErrorCode='' + set @retmsg='' + BEGIN TRY + /*浜嬪姟鎿嶄綔*/ + BEGIN TRAN + /*鍏蜂綋涓氬姟鎿嶄綔*/ + ${_printRemark} + /* + select top 10 * from sProcExcep order by id desc + + ${form} + if 1=2 + begin + set @ErrorCode='E' + set @retmsg='鍦ㄦ鍐欐姤閿�' + goto GOTO_RETURN + end + + insert into sNote (remark,createuserid,CreateUser,CreateStaff) + select '鍦ㄦ鍐欐棩蹇�',@UserID,@UserName,@FullName + */ + + COMMIT TRAN + SET NOCOUNT ON + RETURN + END TRY + BEGIN CATCH + /*閿欒澶勭悊*/ + ROLLBACK TRAN + DECLARE @ErrorMessage NVARCHAR(4000); + DECLARE @ErrorSeverity INT; + DECLARE @ErrorState INT; + + /*鎶婅嚜瀹氫箟鐨勫弸濂界殑閿欒淇℃伅鎻愮ず鍔犱笂*/ + set @ErrorCode=cast(ERROR_NUMBER() as nvarchar(50)) + SET @retmsg=ERROR_MESSAGE(); + SELECT @ErrorMessage=ERROR_MESSAGE(), + @ErrorSeverity=ERROR_SEVERITY(), + @ErrorState=ERROR_STATE(); + + RAISERROR(@ErrorMessage, /* Message text.*/ + @ErrorSeverity, /* Severity.*/ + @ErrorState /* State.*/ + ); + END CATCH + + GOTO_RETURN: + ROLLBACK TRAN + + END` + + Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') + + return Ltext + } + + /** + * @description 鍒涘缓瀵煎叆瀛樺偍杩囩▼ + * @return {String} + */ + static getexcelInfunc (btn) { + let _verify = btn.verify + + let _uniquesql = '' + if (_verify.uniques && _verify.uniques.length > 0) { + _verify.uniques.forEach(unique => { + if (unique.status === 'false') return + + let _fields = unique.field.split(',') + let _fields_ = _fields.map(_field => { + return `a.${_field}=b.${_field}` + }) + _fields_ = _fields_.join(' and ') + + if (unique.verifyType !== 'physical') { + _fields_ += ' and b.deleted=0' + } + + _uniquesql += ` + Set @tbid='' + Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from @${btn.sheet} ) a group by ${unique.field} having sum(n)>1 + + If @tbid!='' + Begin + select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 閲嶅' + goto aaa + end + + Set @tbid='' + Select top 1 @tbid=${_fields.join('+\' \'+')} from @${btn.sheet} a + Inner join ${btn.sheet} b on ${_fields_} + + If @tbid!='' + Begin + select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�' + goto aaa + end + ` + }) + + if (_uniquesql) { + _uniquesql = ` + Declare @tbid Nvarchar(512) + ${_uniquesql}` + } + } + + let declarefields = [] + let fields = [] + + _verify.columns.forEach(col => { + declarefields.push(`${col.Column} ${col.type}`) + fields.push(col.Column) + }) + + fields = fields.join(',') + + let _sql = `declare @${btn.sheet} table (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50)) + + Insert into @${btn.sheet} (${fields},jskey,BID) + + select @LText=dbo.urldecode(dbo.base64decode(@LText)) + + ${_uniquesql} + Insert into ${btn.sheet} (${fields},createuserid,createuser,createstaff,bid) + Select ${fields},@userid,@username,@fullname,@BID From @${btn.sheet} + + Delete @${btn.sheet}` + + let Ltext = `create proc ${btn.func} + ( /*${btn.MenuName} ${btn.label}*/ + @appkey nvarchar(50)='', + @ID nvarchar(50)='', + @BID nvarchar(50)='', + @UserName nvarchar(50)='', + @FullName nvarchar(50)='', + @Ltext nvarchar(max)='', + @sEPTMenuNo nvarchar(50)='${btn.menuNo}', + @secretkey nvarchar(50)='', + @timestamp nvarchar(50)='', + @lang nvarchar(50)='', + @LoginUID nvarchar(50)='', + @SessionUid nvarchar(50)='', + @UserID nvarchar(50), + @ErrorCode nvarchar(50) out, + @retmsg nvarchar(4000) out + ) + as + begin + declare @BegindateTest datetime,@EnddateTest datetime + select @BegindateTest=getdate() + set @ErrorCode='' + set @retmsg='' + BEGIN TRY + /*浜嬪姟鎿嶄綔*/ + BEGIN TRAN + /*鍏蜂綋涓氬姟鎿嶄綔*/ + + /* + ${_sql} + */ + + COMMIT TRAN + SET NOCOUNT ON + RETURN + END TRY + BEGIN CATCH + /*閿欒澶勭悊*/ + ROLLBACK TRAN + DECLARE @ErrorMessage NVARCHAR(4000); + DECLARE @ErrorSeverity INT; + DECLARE @ErrorState INT; + + /*鎶婅嚜瀹氫箟鐨勫弸濂界殑閿欒淇℃伅鎻愮ず鍔犱笂*/ + set @ErrorCode=cast(ERROR_NUMBER() as nvarchar(50)) + SET @retmsg=ERROR_MESSAGE(); + SELECT @ErrorMessage=ERROR_MESSAGE(), + @ErrorSeverity=ERROR_SEVERITY(), + @ErrorState=ERROR_STATE(); + + RAISERROR(@ErrorMessage, /* Message text.*/ + @ErrorSeverity, /* Severity.*/ + @ErrorState /* State.*/ + ); + END CATCH + + GOTO_RETURN: + ROLLBACK TRAN + + END` + + Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') + + return Ltext + } +} \ No newline at end of file diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index 0d4babb..a5cb08d 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -54,6 +54,11 @@ if (setting.interType === 'inner') { param.func = setting.innerFunc + + if (setting.recordUser === 'true') { + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + } } else { if (window.GLOB.mkHS) { if (setting.sysInterface === 'true' && window.GLOB.cloudServiceApi) { diff --git a/src/utils/utils.js b/src/utils/utils.js index 7f89611..6299d02 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -33,7 +33,8 @@ { key: 'TRAN', value: ' mtrnk ' }, { key: 'goto', value: ' mgtk ' }, { key: 'set', value: ' mstk ' }, - { key: 'ROLLBACK', value: ' mrlbkk ' } + { key: 'ROLLBACK', value: ' mrlbkk ' }, + { key: 'drop', value: ' mdrpk ' }, ] export default class Utils { @@ -921,37 +922,6 @@ let _topline = btn.range || 0 let upId = getuuid() - let _initCustomScript = '' // 鍒濆鍖栬剼鏈� - let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈� - let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈� - - if (btn.scripts) { - btn.scripts.forEach(script => { - if (script.status === 'false') return - - let _sql = script.sql - - if (script.position === 'init') { - _initCustomScript += ` - /* 鑷畾涔夎剼鏈� */ - ${_sql} - ` - } else if (script.position === 'front') { - _prevCustomScript += ` - /* 鑷畾涔夎剼鏈� */ - ${_sql} - ` - } else { - _backCustomScript += ` - /* 鑷畾涔夎剼鏈� */ - ${_sql} - ` - } - }) - } - - // 鎺у埗鍙版墦鍗版暟鎹� - let conLtext = [] let cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] for (let i = 0; i < 26; i++) { cols.push('A' + cols[i]) @@ -959,7 +929,6 @@ let _Ltext = data.map((item, lindex) => { let vals = [] - let convals = [] btn.columns.forEach((col, cindex) => { if (col.import === 'false') return @@ -1029,10 +998,6 @@ } vals.push(`'${val}'`) - - if (lindex < 40) { - convals.push(`'${val}' as ${col.Column}`) - } }) let _lineIndex = '0000' + (lindex + 1) + '0' @@ -1040,26 +1005,57 @@ vals.push(`'${upId + _lineIndex}'`) vals.push(`'${BID}'`) - - if (lindex < 40) { - convals.push(`'${upId + _lineIndex}' as jskey`) - convals.push(`'${BID}' as BID`) - conLtext.push(`Select ${convals.join(',')}`) - } return `Select ${vals.join(',')}` }) let result = [] - for(let i = 0; i < _Ltext.length; i += 20) { - result.push(_Ltext.slice(i, i + 20)) - } - - let _sql = '' - let _sqlInsert = '' - let _sqlBottom = '' - + let sql = '' + if (item.intertype === 'system') { + let _initCustomScript = '' // 鍒濆鍖栬剼鏈� + let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈� + let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈� + let tb = new RegExp('(^|\\s)@' + sheet + '(\\s|$|(|))', 'ig') + + btn.scripts && btn.scripts.forEach(script => { + if (script.status === 'false') return + + let _sql = script.sql + + _sql = _sql.replace(tb, `#${sheet}`) + _sql = _sql.replace(/@ID@/ig, `'${primaryId || ''}'`) + _sql = _sql.replace(/@BID@/ig, `'${BID}'`) + _sql = _sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) + _sql = _sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) + _sql = _sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) + _sql = _sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) + _sql = _sql.replace(/@typename@/ig, `'admin'`) + + if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 + _sql = _sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') + } else { + _sql = _sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + } + + if (script.position === 'init') { + _initCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${_sql} + ` + } else if (script.position === 'front') { + _prevCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${_sql} + ` + } else { + _backCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${_sql} + ` + } + }) + let _uniquesql = '' if (btn.uniques && btn.uniques.length > 0) { btn.uniques.forEach(unique => { @@ -1077,7 +1073,7 @@ _uniquesql += ` /* 閲嶅鎬ч獙璇� */ Set @tbid='' - Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from @${sheet} ) a group by ${unique.field} having sum(n)>1 + Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from #${sheet} ) a group by ${unique.field} having sum(n)>1 If @tbid!='' Begin @@ -1086,7 +1082,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 #${sheet} a Inner join ${sheet} b on ${_fields_} If @tbid!='' Begin @@ -1118,88 +1114,50 @@ _insert = ` /* 榛樿sql */ Insert into ${database}${sheet} (${fields},createuserid,createuser,createstaff,bid) - Select ${fields},@userid@,@username,@fullname,@BID@ From @${sheet} + Select ${fields},'${sessionStorage.getItem('UserID') || ''}',@username,@fullname,'${BID}' From #${sheet} ` } - _sql = ` + sql = ` /* 绯荤粺鐢熸垚 */ - declare @${sheet} table (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50) ) + create table #${sheet} (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50) ) Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}' ${_initCustomScript} - ` - _sqlInsert = `Insert into @${sheet} (${fields},jskey,BID)` - _sqlBottom = ` - /* 榛樿sql */ - delete tmp_excel_in where upid=@upid@ - delete tmp_excel_in where datediff(day,createdate,getdate())>15 + Insert into #${sheet} (${fields},jskey,BID) + + /* excel鏁版嵁*/ + ${_Ltext.join(' Union all ')} + ${_uniquesql} ${_prevCustomScript} ${_insert} ${_backCustomScript} - Delete @${sheet} + + drop table #${sheet} aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` - _sql = _sql.replace(/@ID@/ig, `'${primaryId || ''}'`) - _sql = _sql.replace(/@BID@/ig, `'${BID}'`) - _sql = _sql.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) - _sql = _sql.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) - _sql = _sql.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) - _sql = _sql.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) - _sql = _sql.replace(/@typename@/ig, `'admin'`) - - _sqlBottom = _sqlBottom.replace(/@ID@/ig, `'${primaryId || ''}'`) - _sqlBottom = _sqlBottom.replace(/@BID@/ig, `'${BID}'`) - _sqlBottom = _sqlBottom.replace(/@LoginUID@/ig, `'${sessionStorage.getItem('LoginUID') || ''}'`) - _sqlBottom = _sqlBottom.replace(/@SessionUid@/ig, `'${localStorage.getItem('SessionUid') || ''}'`) - _sqlBottom = _sqlBottom.replace(/@UserID@/ig, `'${sessionStorage.getItem('UserID') || ''}'`) - _sqlBottom = _sqlBottom.replace(/@Appkey@/ig, `'${window.GLOB.appkey || ''}'`) - _sqlBottom = _sqlBottom.replace(/@typename@/ig, `'admin'`) - - if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - _sql = _sql.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') - _sqlBottom = _sqlBottom.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') - } else { - _sql = _sql.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') - _sqlBottom = _sqlBottom.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') - } if (window.GLOB.debugger === true) { - let fsql = ` - ${_sql} - ${_sqlInsert} - - /* excel鏁版嵁锛堝墠40鏉★級 */ - ${conLtext.join(' Union all ')} - ${_sqlBottom} - ` - fsql = fsql.replace(/\n\s{8}/ig, '\n') - console.info(fsql) + console.info(sql.replace(/\n\s{8}/ig, '\n')) } - } else { // s_sDataDictb_excelIn 浜戠瀵嗛挜楠岃瘉鍙傛暟 - _sql = ` - /* 绯荤粺鐢熸垚 */ - declare @${sheet} table (jskey nvarchar(50)) - Declare @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) - - Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}' - ` + } else { + for(let i = 0; i < _Ltext.length; i += 20) { + result.push(_Ltext.slice(i, i + 20)) + } } return { - sql: _sql, + sql: sql, lines: result.map((list, index) => { return { Ltext: window.btoa(window.encodeURIComponent(list.join(' Union all '))), Sort: (index + 1) * 10 } }), - insert: _sqlInsert, - bottom: _sqlBottom, errors: errors.join('; ') } } @@ -2326,471 +2284,5 @@ }) cursor.continue() } - } -} - -/** - * @description 鍒涘缓瀛樺偍杩囩▼绫� - */ -export class FuncUtils { - /** - * @description 鍒犻櫎瀛樺偍杩囩▼sql - * @return {String} name 瀛樺偍杩囩▼鍚嶇О - */ - static dropfunc (name) { - return `IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID('${name}') AND type in (N'P', N'PC')) mdrpk PROCEDURE ${name}` - } - - /** - * @description 鍒涘缓椤甸潰瀛樺偍杩囩▼ - * @return {String} - */ - static getTableFunc (func = 'func', menu, config) { - let form = '' - let formParam = '' - let _vars = ['bid', 'pageindex', 'pagesize', 'ordercol', 'ordertype', 'exceltype', 'septmenuno', 'lang', 'debug', 'loginuid', 'sessionuid', 'userid', 'errorcode', 'retmsg'] - let _columns = [] - let primaryKey = config.setting.primaryKey || 'ID' - - if (!_vars.includes(primaryKey.toLowerCase())) { - _vars.push(primaryKey.toLowerCase()) - formParam = `mchr13k@${primaryKey} nvarchar(50)='',` - } - - if (config.search && config.search.length > 0) { - let _fields = new Map() - config.search.forEach(item => { - if (item.field) { - let type = '' - - if (item.type.match(/date/ig)) { - type = 'datetime=null' - } else { - type = 'nvarchar(50)=\'\'' - } - - item.field.split(',').forEach(cell => { - let _f = cell - if (_fields.has(cell)) { - _f = _f + '1' - } - - _fields.set(cell, true) - - if (!_vars.includes(_f.toLowerCase())) { - _vars.push(_f.toLowerCase()) - formParam = formParam + `mchr13k@${_f} ${type},` - } - }) - } - }) - } - - if (config.columns && config.columns.length > 0) { - config.columns.forEach(item => { - if (item.field) { - _columns.push(`${item.field} as ${item.label}`) - } - }) - - form = ` - declare @dc table (${_columns.join(',')}) - - @tableid ='${menu.MenuID}' - ` - } - - let Ltext = `create proc ${func} - ( /*${menu.MenuName}*/ - @appkey nvarchar(50)='', - @BID nvarchar(50)='',${formParam} - @PageIndex nvarchar(50)='', - @PageSize nvarchar(50)='', - @OrderCol nvarchar(50)='', - @OrderType nvarchar(50)='', - @exceltype nvarchar(50)='', - @sEPTMenuNo nvarchar(50)='${menu.MenuNo}', - @lang nvarchar(50)='', - @debug nvarchar(50)='', - @LoginUID nvarchar(50)='', - @SessionUid nvarchar(50)='', - @UserID nvarchar(50), - @dataM nvarchar(50), - @ErrorCode nvarchar(50) out, - @retmsg nvarchar(4000) out - ) - as - begin - declare @BegindateTest datetime,@EnddateTest datetime - select @BegindateTest=getdate() - set @ErrorCode='' - set @retmsg='' - BEGIN TRY - /*浜嬪姟鎿嶄綔*/ - BEGIN TRAN - /*鍏蜂綋涓氬姟鎿嶄綔*/ - - /* - select top 10 * from sProcExcep order by id desc - - declare @UserName nvarchar(50),@FullName nvarchar(50) - - select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID - ${form} - if 1=2 - begin - set @ErrorCode='E' - set @retmsg='鍦ㄦ鍐欐姤閿�' - goto GOTO_RETURN - end - - insert into sNote (remark,createuserid,CreateUser,CreateStaff) - select '鍦ㄦ鍐欐棩蹇�',@UserID,@UserName,@FullName - */ - - COMMIT TRAN - SET NOCOUNT ON - RETURN - END TRY - BEGIN CATCH - /*閿欒澶勭悊*/ - ROLLBACK TRAN - DECLARE @ErrorMessage NVARCHAR(4000); - DECLARE @ErrorSeverity INT; - DECLARE @ErrorState INT; - - /*鎶婅嚜瀹氫箟鐨勫弸濂界殑閿欒淇℃伅鎻愮ず鍔犱笂*/ - set @ErrorCode=cast(ERROR_NUMBER() as nvarchar(50)) - SET @retmsg=ERROR_MESSAGE(); - SELECT @ErrorMessage=ERROR_MESSAGE(), - @ErrorSeverity=ERROR_SEVERITY(), - @ErrorState=ERROR_STATE(); - - RAISERROR(@ErrorMessage, /*-- Message text.*/ - @ErrorSeverity, /*-- Severity.*/ - @ErrorState /*-- State.*/ - ); - END CATCH - - GOTO_RETURN: - ROLLBACK TRAN - - END` - - Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') - - return Ltext - } - - /** - * @description 鍒涘缓瀛樺偍杩囩▼ - * @return {String} - */ - static getfunc (param, btn, menu, config) { - let form = '' - let formParam = '' - let _vars = ['bid', 'septmenuno', 'lang', 'debug', 'loginuid', 'sessionuid', 'userid', 'errorcode', 'retmsg'] - let columns = config.columns - let primaryKey = config.setting.primaryKey || 'ID' - - if (!_vars.includes(primaryKey.toLowerCase())) { - _vars.push(primaryKey.toLowerCase()) - let _type = '50' - if (btn.Ot === 'requiredOnce') { // 澶氳鎷兼帴鏃讹紝涓婚敭璁句负max - _type = 'max' - } - formParam = `mchr13k@${primaryKey} nvarchar(${_type})='',` - } - - if (param.fields && param.fields.length > 0) { - let _fields = [] - param.fields.forEach(item => { - if (item.field) { - let type = '' - if (item.type.match(/date/ig)) { - type = 'datetime=null' - } else if (item.type === 'number') { - type = `decimal(18,${item.decimal})=0` - } else if (item.type === 'rate') { - type = `decimal(18,2)=0` - } else { - type = 'nvarchar(50)=\'\'' - } - - if (!_vars.includes(item.field.toLowerCase())) { - _vars.push(item.field.toLowerCase()) - formParam = formParam + `mchr13k@${item.field} ${type},` - } - - _fields.push(item.field) - } - }) - - let field1 = _fields.join(',') - let field2 = _fields.join(',@') - let field3 = _fields.map(cell => { - return cell + '=@' + cell - }) - - field2 = field2 ? '@' + field2 : '' - field3 = field3.join(',') - - form = ` - insert into ${param.name} (${field1},createuserid) select ${field2},@UserID - - update ${param.name} set ${field3},modifydate=getdate(),modifyuser=@username,modifyuserid=@UserID - ` - } else if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { - form = ` - update ${param.name} set ModifyDate=getdate(),ModifyUserID=@UserID where ${primaryKey}=@${primaryKey} - ` - } - - if (columns) { - let _col = [] - let _field = [] - columns.forEach(col => { - if (col.field) { - if (col.type === 'number') { - _col.push(col.field + ' decimal(18,2)') - } else { - _col.push(col.field + ' nvarchar(50)') - } - _field.push(col.field) - } - }) - _col = _col.join(',') - _field = _field.join(',') - - form = form + ` - declare @dc table (${_col}) - - insert into @dc (${_field}) - - @tableid ='${menu.MenuID}' - ` - } - - // 鎵撳嵃鑷畾涔夋ā鏉垮瓧娈垫彁绀� - let _printRemark = '' - if (btn.funcType === 'print') { - _printRemark = '/* 鑷畾涔夋暟鎹墦鍗版ā鏉挎椂锛岃浣跨敤TemplateID瀛楁 */' - } - - let Ltext = `create proc ${param.funcName} - ( /*${menu.MenuName} ${btn.label}*/ - @appkey nvarchar(50)='', - @BID nvarchar(50)='',${formParam} - @sEPTMenuNo nvarchar(50)='${param.menuNo}', - @lang nvarchar(50)='', - @debug nvarchar(50)='', - @LoginUID nvarchar(50)='', - @SessionUid nvarchar(50)='', - @UserID nvarchar(50), - @ErrorCode nvarchar(50) out, - @retmsg nvarchar(4000) out - ) - as - begin - declare @BegindateTest datetime,@EnddateTest datetime - select @BegindateTest=getdate() - set @ErrorCode='' - set @retmsg='' - BEGIN TRY - /*浜嬪姟鎿嶄綔*/ - BEGIN TRAN - /*鍏蜂綋涓氬姟鎿嶄綔*/ - ${_printRemark} - /* - select top 10 * from sProcExcep order by id desc - - declare @UserName nvarchar(50),@FullName nvarchar(50) - - select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID - ${form} - if 1=2 - begin - set @ErrorCode='E' - set @retmsg='鍦ㄦ鍐欐姤閿�' - goto GOTO_RETURN - end - - insert into sNote (remark,createuserid,CreateUser,CreateStaff) - select '鍦ㄦ鍐欐棩蹇�',@UserID,@UserName,@FullName - */ - - COMMIT TRAN - SET NOCOUNT ON - RETURN - END TRY - BEGIN CATCH - /*閿欒澶勭悊*/ - ROLLBACK TRAN - DECLARE @ErrorMessage NVARCHAR(4000); - DECLARE @ErrorSeverity INT; - DECLARE @ErrorState INT; - - /*鎶婅嚜瀹氫箟鐨勫弸濂界殑閿欒淇℃伅鎻愮ず鍔犱笂*/ - set @ErrorCode=cast(ERROR_NUMBER() as nvarchar(50)) - SET @retmsg=ERROR_MESSAGE(); - SELECT @ErrorMessage=ERROR_MESSAGE(), - @ErrorSeverity=ERROR_SEVERITY(), - @ErrorState=ERROR_STATE(); - - RAISERROR(@ErrorMessage, /* Message text.*/ - @ErrorSeverity, /* Severity.*/ - @ErrorState /* State.*/ - ); - END CATCH - - GOTO_RETURN: - ROLLBACK TRAN - - END` - - Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') - - return Ltext - } - - /** - * @description 鍒涘缓瀵煎叆瀛樺偍杩囩▼ - * @return {String} - */ - static getexcelInfunc (param, btn, menu) { - let _verify = btn.verify - - let _uniquesql = '' - if (_verify.uniques && _verify.uniques.length > 0) { - _verify.uniques.forEach(unique => { - if (unique.status === 'false') return - - let _fields = unique.field.split(',') - let _fields_ = _fields.map(_field => { - return `a.${_field}=b.${_field}` - }) - _fields_ = _fields_.join(' and ') - - if (unique.verifyType !== 'physical') { - _fields_ += ' and b.deleted=0' - } - - _uniquesql += ` - Set @tbid='' - Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${unique.field} from @${btn.sheet} ) a group by ${unique.field} having sum(n)>1 - - If @tbid!='' - Begin - select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 閲嶅' - goto aaa - end - - Set @tbid='' - Select top 1 @tbid=${_fields.join('+\' \'+')} from @${btn.sheet} a - Inner join ${btn.sheet} b on ${_fields_} - - If @tbid!='' - Begin - select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�' - goto aaa - end - ` - }) - - if (_uniquesql) { - _uniquesql = ` - Declare @tbid Nvarchar(512) - ${_uniquesql}` - } - } - - let declarefields = [] - let fields = [] - - _verify.columns.forEach(col => { - declarefields.push(`${col.Column} ${col.type}`) - fields.push(col.Column) - }) - - fields = fields.join(',') - - let _sql = `declare @${btn.sheet} table (${declarefields.join(',')},jskey nvarchar(50)) - Declare @UserName nvarchar(50),@FullName nvarchar(50) - - select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID - - Insert into @${btn.sheet} (${fields},jskey) - - exec s_KeyWords_Replace - @LText=@LText, @BID=@BID,@LoginUID=@LoginUID,@SessionUid=@SessionUid,@UserID=@UserID,@ID=@ID - ${_uniquesql} - Insert into ${btn.sheet} (${fields},createuserid,createuser,createstaff,bid) - Select ${fields},@userid,@username,@fullname,@BID From @${btn.sheet} - - Delete @${btn.sheet}` - - let Ltext = `create proc ${param.funcName} - ( /*${menu.MenuName} ${btn.label}*/ - @appkey nvarchar(50)='', - @ID nvarchar(50)='', - @BID nvarchar(50)='', - @Ltext nvarchar(max)='', - @sEPTMenuNo nvarchar(50)='${param.menuNo}', - @secretkey nvarchar(50)='', - @timestamp nvarchar(50)='', - @lang nvarchar(50)='', - @LoginUID nvarchar(50)='', - @SessionUid nvarchar(50)='', - @UserID nvarchar(50), - @ErrorCode nvarchar(50) out, - @retmsg nvarchar(4000) out - ) - as - begin - declare @BegindateTest datetime,@EnddateTest datetime - select @BegindateTest=getdate() - set @ErrorCode='' - set @retmsg='' - BEGIN TRY - /*浜嬪姟鎿嶄綔*/ - BEGIN TRAN - /*鍏蜂綋涓氬姟鎿嶄綔*/ - - /* - ${_sql} - */ - - COMMIT TRAN - SET NOCOUNT ON - RETURN - END TRY - BEGIN CATCH - /*閿欒澶勭悊*/ - ROLLBACK TRAN - DECLARE @ErrorMessage NVARCHAR(4000); - DECLARE @ErrorSeverity INT; - DECLARE @ErrorState INT; - - /*鎶婅嚜瀹氫箟鐨勫弸濂界殑閿欒淇℃伅鎻愮ず鍔犱笂*/ - set @ErrorCode=cast(ERROR_NUMBER() as nvarchar(50)) - SET @retmsg=ERROR_MESSAGE(); - SELECT @ErrorMessage=ERROR_MESSAGE(), - @ErrorSeverity=ERROR_SEVERITY(), - @ErrorState=ERROR_STATE(); - - RAISERROR(@ErrorMessage, /* Message text.*/ - @ErrorSeverity, /* Severity.*/ - @ErrorState /* State.*/ - ); - END CATCH - - GOTO_RETURN: - ROLLBACK TRAN - - END` - - Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k') - - return Ltext } } \ No newline at end of file -- Gitblit v1.8.0