src/assets/mobimg/sandbox.png
src/menu/modelsource/option.jsx
@@ -10,6 +10,7 @@ import NormalTable from '@/assets/mobimg/normal-table.png' import Pie from '@/assets/mobimg/pie.png' import Editor from '@/assets/mobimg/editor.png' import SandBox from '@/assets/mobimg/sandbox.png' import Pie1 from '@/assets/mobimg/ring.png' import Pie2 from '@/assets/mobimg/nightingale.png' import Mainsearch from '@/assets/mobimg/mainsearch.png' @@ -29,7 +30,7 @@ { type: 'menu', url: Pie, component: 'pie', subtype: 'pie', title: '饼图', width: 12 }, { type: 'menu', url: Pie1, component: 'pie', subtype: 'ring', title: '环图', width: 12 }, { type: 'menu', url: Editor, component: 'editor', subtype: 'brafteditor', title: '富文本', width: 24 }, { type: 'menu', url: Editor, component: 'code', subtype: 'sandbox', title: '自定义', width: 24 }, { type: 'menu', url: SandBox, component: 'code', subtype: 'sandbox', title: '自定义', width: 24 }, { type: 'menu', url: Pie2, component: 'pie', subtype: 'nightingale', title: '南丁格尔图', width: 12 }, { type: 'menu', url: group, component: 'group', subtype: 'normalgroup', title: '分组', width: 24, forbid: ['billPrint'] }, ] src/menu/pastecontroller/index.jsx
@@ -241,7 +241,7 @@ return ( <div style={{display: 'inline-block'}}> {type !== 'menu' ? <Icon type="snippets" style={{color: 'purple'}} onClick={() => {this.setState({visible: true})}} /> : null} {type === 'menu' ? <Button type="link" style={{padding: '5px'}} icon="snippets" onClick={() => {this.setState({visible: true})}}>粘贴</Button> : null} {type === 'menu' ? <Button className="Menu-config-paste" icon="snippets" onClick={() => {this.setState({visible: true})}}>粘贴</Button> : null} <Modal title="粘贴" visible={visible} src/menu/pastecontroller/index.scss
@@ -0,0 +1,4 @@ .Menu-config-paste { border-color: #40a9ff; color: #40a9ff; } src/menu/picturecontroller/index.jsx
New file @@ -0,0 +1,52 @@ import React, {Component} from 'react' // import { fromJS } from 'immutable' import { Modal, Button } from 'antd' // import Utils from '@/utils/utils.js' // import asyncComponent from '@/utils/asyncComponent' import './index.scss' // const PasteForm = asyncComponent(() => import('@/templates/zshare/pasteform')) class PasteController extends Component { state = { visible: false } addSource = () => { } render() { const { visible } = this.state return ( <div style={{display: 'inline-block'}}> <Button className="mk-border-purple" icon="picture" onClick={() => {this.setState({visible: true})}}>资源管理</Button> <Modal title="粘贴" visible={visible} width={600} maskClosable={false} onOk={this.pasteSubmit} onCancel={() => {this.setState({visible: false})}} footer={[ <Button key="back" type="link" icon="plus" onClick={this.addSource}> 添加 </Button>, <Button key="colse" onClick={() => {this.setState({visible: false})}}> 关闭 </Button> ]} destroyOnClose > <div> </div> </Modal> </div> ) } } export default PasteController src/menu/picturecontroller/index.scss
New file @@ -0,0 +1,4 @@ .Menu-config-paste { border-color: #40a9ff; color: #40a9ff; } src/menu/popview/index.jsx
@@ -585,10 +585,10 @@ {customComponents && customComponents.length ? <Panel header="自定义组件" key="cuscomponent"> <SourceWrap components={customComponents} MenuType={MenuType} /> </Panel> : null} <Panel header={'背景'} key="background"> <Panel header={'页面背景'} key="background"> {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null} </Panel> <Panel header={'内边距'} key="padding"> <Panel header={'页面内边距'} key="padding"> {config ? <PaddingController config={config} updateConfig={this.updateConfig} /> : null} </Panel> </Collapse> src/menu/stylecombcontrolbutton/index.jsx
@@ -148,7 +148,7 @@ render() { const { label } = this.state return ( <Button className="style-control-button" type="link" icon="font-colors" title="调整样式" onClick={this.triggerStyleChange}>{label}</Button> <Button className="style-control-button" icon="font-colors" title="调整样式" onClick={this.triggerStyleChange}>{label}</Button> ) } } src/menu/stylecombcontrolbutton/index.scss
@@ -1,6 +1,7 @@ .style-control-button.ant-btn-link, .style-control-button.ant-btn-link:hover, .style-control-button.ant-btn-link:focus { .style-control-button, .style-control-button:hover, .style-control-button:focus { color: orange; border-color: orange; position: relative; z-index: 13; background: #ffffff; src/tabviews/commontable/index.jsx
@@ -10,7 +10,7 @@ import Utils from '@/utils/utils.js' import options from '@/store/options.js' import UtilsDM from '@/utils/utils-datamanage.js' import UtilsUpdate from '@/utils/utils-update.js' import { updateCommonTable } from '@/utils/utils-update.js' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' import MKEmitter from '@/utils/events.js' @@ -151,7 +151,7 @@ } // 版本兼容 config = UtilsUpdate.updateCommonTable(config) config = updateCommonTable(config) // 权限过滤 if (this.props.menuType !== 'HS') { @@ -565,9 +565,6 @@ customCallbackRequest = (result) => { const { setting } = this.state let lines = [] let pre = setting.callbackType === 'script' ? '@' : '' let errSql = '' if (result.$ErrCode === 'E') { errSql = ` @@ -578,68 +575,11 @@ delete result.$ErrMesg } let getDefaultSql = (obj, tb, bid, level) => { let keys = [] let vals = [] let subObjs = [] let id = Utils.getuuid() delete obj.$$key Object.keys(obj).forEach(key => { let val = obj[key] if (val === null || val === undefined) return if (typeof(val) === 'object') { if (Array.isArray(val)) { val.forEach(item => { if (typeof(item) !== 'object' || Array.isArray(item)) return if (Object.keys(item).length > 0) { item.$$key = tb + '_' + key subObjs.push(item) } }) } else if (Object.keys(val).length > 0) { val.$$key = tb + '_' + key subObjs.push(val) } } else { keys.push(key) vals.push(`'${val}'`) } }) lines.push({ table: tb, insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`, select: `Select ${vals.join(',')},'${level}','${id}','${bid}'` }) subObjs.forEach(item => { getDefaultSql(item, item.$$key, id, level + 1) }) } getDefaultSql(result, setting.cbTable, '', 1) let lineMap = new Map() lines.forEach(line => { if (lineMap.has(line.table)) { let _line = lineMap.get(line.table) _line.selects.push(line.select) lineMap.set(line.table, _line) } else { lineMap.set(line.table, { table: line.table, insert: line.insert, selects: [line.select] }) } }) let lines = UtilsDM.getCallBackSql(setting, result) let param = {} if (setting.callbackType === 'script') { // 使用自定义脚本 let sql = [...lineMap.values()].map(item => (` let sql = lines.map(item => (` ${item.insert} ${item.selects.join(` union all `)} @@ -657,7 +597,7 @@ } } else { param.func = 's_ex_result_back' param.s_ex_result = [...lineMap.values()].map((item, index) => ({ param.s_ex_result = lines.map((item, index) => ({ MenuID: this.state.config.MenuID, MenuName: this.state.config.MenuName, TableName: item.table, @@ -666,7 +606,7 @@ })) if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { let sql = [...lineMap.values()].map(item => (` let sql = lines.map(item => (` ${item.insert} ${item.selects.join(` union all `)} src/tabviews/formtab/actionList/index.jsx
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import moment from 'moment' import { Button, Modal, notification, message } from 'antd' import Utils from '@/utils/utils.js' import Utils, { getSysDefaultSql } from '@/utils/utils.js' import options from '@/store/options.js' import Api from '@/api' import './index.scss' @@ -121,7 +121,7 @@ if (btn.sql && btn.sqlType === 'insert') { // 系统函数添加时,生成uuid param.ID = Utils.getguid() param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data, []) // 数据源 param.LText = getSysDefaultSql(btn, setting, formdata, param, data, []) // 数据源 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) param.LText = Utils.formatOptions(param.LText) @@ -129,7 +129,7 @@ _primaryId = param.ID } else if (btn.sql && btn.sqlType === 'insertOrUpdate') { // 系统函数添加或修改时 param.ID = primaryId || Utils.getguid() param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data, []) // 数据源 param.LText = getSysDefaultSql(btn, setting, formdata, param, data, []) // 数据源 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) param.LText = Utils.formatOptions(param.LText) @@ -137,7 +137,7 @@ _primaryId = param.ID } else if (btn.sql) { param.ID = primaryId param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data, []) // 数据源 param.LText = getSysDefaultSql(btn, setting, formdata, param, data, []) // 数据源 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) param.LText = Utils.formatOptions(param.LText) src/tabviews/subtable/index.jsx
@@ -10,7 +10,7 @@ import Utils from '@/utils/utils.js' import options from '@/store/options.js' import UtilsDM from '@/utils/utils-datamanage.js' import UtilsUpdate from '@/utils/utils-update.js' import { updateSubTable } from '@/utils/utils-update.js' import { modifyTabview } from '@/store/action' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' @@ -135,7 +135,7 @@ let absFields = [] // 绝对值字段 // 版本兼容 config = UtilsUpdate.updateSubTable(config) config = updateSubTable(config) // 权限过滤 if (this.props.menuType !== 'HS') { @@ -494,9 +494,6 @@ customCallbackRequest = (result) => { const { setting } = this.state let lines = [] let pre = setting.callbackType === 'script' ? '@' : '' let errSql = '' if (result.$ErrCode === 'E') { errSql = ` @@ -507,68 +504,11 @@ delete result.$ErrMesg } let getDefaultSql = (obj, tb, bid, level) => { let keys = [] let vals = [] let subObjs = [] let id = Utils.getuuid() delete obj.$$key Object.keys(obj).forEach(key => { let val = obj[key] if (val === null || val === undefined) return if (typeof(val) === 'object') { if (Array.isArray(val)) { val.forEach(item => { if (typeof(item) !== 'object' || Array.isArray(item)) return if (Object.keys(item).length > 0) { item.$$key = tb + '_' + key subObjs.push(item) } }) } else if (Object.keys(val).length > 0) { val.$$key = tb + '_' + key subObjs.push(val) } } else { keys.push(key) vals.push(`'${val}'`) } }) lines.push({ table: tb, insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`, select: `Select ${vals.join(',')},'${level}','${id}','${bid}'` }) subObjs.forEach(item => { getDefaultSql(item, item.$$key, id, level + 1) }) } getDefaultSql(result, setting.cbTable, '', 1) let lineMap = new Map() lines.forEach(line => { if (lineMap.has(line.table)) { let _line = lineMap.get(line.table) _line.selects.push(line.select) lineMap.set(line.table, _line) } else { lineMap.set(line.table, { table: line.table, insert: line.insert, selects: [line.select] }) } }) let lines = UtilsDM.getCallBackSql(setting, result) let param = {} if (setting.callbackType === 'script') { // 使用自定义脚本 let sql = [...lineMap.values()].map(item => (` let sql = lines.map(item => (` ${item.insert} ${item.selects.join(` union all `)} @@ -586,7 +526,7 @@ } } else { param.func = 's_ex_result_back' param.s_ex_result = [...lineMap.values()].map((item, index) => ({ param.s_ex_result = lines.map((item, index) => ({ MenuID: this.props.MenuID, MenuName: this.props.Tab.label, TableName: item.table, @@ -595,7 +535,7 @@ })) if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { let sql = [...lineMap.values()].map(item => (` let sql = lines.map(item => (` ${item.insert} ${item.selects.join(` union all `)} src/tabviews/subtabtable/index.jsx
@@ -10,7 +10,7 @@ import Utils from '@/utils/utils.js' import options from '@/store/options.js' import UtilsDM from '@/utils/utils-datamanage.js' import UtilsUpdate from '@/utils/utils-update.js' import { updateSubTable } from '@/utils/utils-update.js' import asyncComponent from '@/utils/asyncComponent' import asyncSpinComponent from '@/utils/asyncSpinComponent' import NotFount from '@/components/404' @@ -111,7 +111,7 @@ let absFields = [] // 绝对值字段 // 版本兼容 config = UtilsUpdate.updateSubTable(config) config = updateSubTable(config) // 不支持funcbutton、popview 类型按钮 let labels = [] @@ -455,9 +455,6 @@ customCallbackRequest = (result) => { const { setting } = this.state let lines = [] let pre = setting.callbackType === 'script' ? '@' : '' let errSql = '' if (result.$ErrCode === 'E') { errSql = ` @@ -468,68 +465,11 @@ delete result.$ErrMesg } let getDefaultSql = (obj, tb, bid, level) => { let keys = [] let vals = [] let subObjs = [] let id = Utils.getuuid() delete obj.$$key Object.keys(obj).forEach(key => { let val = obj[key] if (val === null || val === undefined) return if (typeof(val) === 'object') { if (Array.isArray(val)) { val.forEach(item => { if (typeof(item) !== 'object' || Array.isArray(item)) return if (Object.keys(item).length > 0) { item.$$key = tb + '_' + key subObjs.push(item) } }) } else if (Object.keys(val).length > 0) { val.$$key = tb + '_' + key subObjs.push(val) } } else { keys.push(key) vals.push(`'${val}'`) } }) lines.push({ table: tb, insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`, select: `Select ${vals.join(',')},'${level}','${id}','${bid}'` }) subObjs.forEach(item => { getDefaultSql(item, item.$$key, id, level + 1) }) } getDefaultSql(result, setting.cbTable, '', 1) let lineMap = new Map() lines.forEach(line => { if (lineMap.has(line.table)) { let _line = lineMap.get(line.table) _line.selects.push(line.select) lineMap.set(line.table, _line) } else { lineMap.set(line.table, { table: line.table, insert: line.insert, selects: [line.select] }) } }) let lines = UtilsDM.getCallBackSql(setting, result) let param = {} if (setting.callbackType === 'script') { // 使用自定义脚本 let sql = [...lineMap.values()].map(item => (` let sql = lines.map(item => (` ${item.insert} ${item.selects.join(` union all `)} @@ -548,7 +488,7 @@ } else { let name = this.props.Tab ? (this.props.Tab.label || '') : '' param.func = 's_ex_result_back' param.s_ex_result = [...lineMap.values()].map((item, index) => ({ param.s_ex_result = lines.map((item, index) => ({ MenuID: this.props.MenuID, MenuName: name, TableName: item.table, @@ -557,7 +497,7 @@ })) if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { let sql = [...lineMap.values()].map(item => (` let sql = lines.map(item => (` ${item.insert} ${item.selects.join(` union all `)} src/tabviews/verupmanage/actionList/index.jsx
@@ -3,7 +3,7 @@ import moment from 'moment' import { Button, Modal, notification, message } from 'antd' import MutilForm from '@/tabviews/zshare/mutilform' import Utils from '@/utils/utils.js' import Utils, { getSysDefaultSql } from '@/utils/utils.js' import options from '@/store/options.js' import Api from '@/api' import './index.scss' @@ -171,7 +171,7 @@ } } else if (btn.sql) { param.ID = primaryId param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns) // 数据源 param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns) // 数据源 param.exec_type = 'y' // 后台解码 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -199,7 +199,7 @@ } } param.ID = primaryId || Utils.getguid() param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns) // 数据源 param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns) // 数据源 param.exec_type = 'y' // 后台解码 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -207,7 +207,7 @@ param.LText = Utils.formatOptions(param.LText) } else if (btn.sql) { param.ID = primaryId param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns) // 数据源 param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns) // 数据源 param.exec_type = 'y' // 后台解码 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -253,7 +253,7 @@ } } else if (btn.sql) { param.ID = primaryId param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns) // 数据源 param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns) // 数据源 param.exec_type = 'y' // 后台解码 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -277,7 +277,7 @@ } } else if (btn.sql && btn.sqlType === 'insert') { // 系统函数添加时,生成uuid param.ID = _formPrimaryId || Utils.getguid() param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns) // 数据源 param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns) // 数据源 param.exec_type = 'y' // 后台解码 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -294,7 +294,7 @@ } param.ID = primaryId param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns) // 数据源 param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns) // 数据源 param.exec_type = 'y' // 后台解码 param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -6,7 +6,7 @@ import { Button, Modal, notification, message } from 'antd' import ExcelIn from './excelin' import Utils from '@/utils/utils.js' import Utils, { getExcelInSql } from '@/utils/utils.js' import options from '@/store/options.js' import Api from '@/api' import zhCN from '@/locales/zh-CN/main.js' @@ -238,7 +238,7 @@ }) } let result = Utils.getExcelInSql(btn, data, this.state.dict, (this.props.BID || '')) let result = getExcelInSql(btn, data, this.state.dict, (this.props.BID || '')) if (result.errors) { notification.warning({ src/tabviews/zshare/actionList/normalbutton/index.jsx
@@ -6,7 +6,7 @@ import { Button, Modal, notification, message } from 'antd' import Api from '@/api' import Utils from '@/utils/utils.js' import Utils, { getSysDefaultSql } from '@/utils/utils.js' import options from '@/store/options.js' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' @@ -239,7 +239,14 @@ if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 是否弹框或直接执行 param.ID = primaryId param.LText = Utils.getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg) // 数据源 if (retmsg) { const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab, retmsg) // 数据源 param.LText = sql param.$callbacksql = callbacksql } else { param.LText = getSysDefaultSql(btn, setting, '', param, data[0], columns, this.props.Tab) // 数据源 } if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 param.LText = param.LText.replace(/\$@/ig, '/*') @@ -274,7 +281,14 @@ } param.ID = primaryId || Utils.getguid() param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 数据源 if (retmsg) { const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 数据源 param.LText = sql param.$callbacksql = callbacksql } else { param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 数据源 } if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 param.LText = param.LText.replace(/\$@/ig, '/*') @@ -299,7 +313,14 @@ param.LText = Utils.formatOptions(param.LText) } else { param.ID = primaryId param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 数据源 if (retmsg) { const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab, retmsg) // 数据源 param.LText = sql param.$callbacksql = callbacksql } else { param.LText = getSysDefaultSql(btn, setting, formdata, param, data[0], columns, this.props.Tab) // 数据源 } if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 param.LText = param.LText.replace(/\$@/ig, '/*') @@ -354,7 +375,14 @@ if (btn.OpenType === 'prompt' || btn.OpenType === 'exec') { // 是否弹框或直接执行 param.ID = primaryId param.LText = Utils.getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg) // 数据源 if (retmsg) { const { sql, callbacksql } = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab, retmsg) // 数据源 param.LText = sql param.$callbacksql = callbacksql } else { param.LText = getSysDefaultSql(btn, setting, '', param, cell, columns, this.props.Tab) // 数据源 } if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 param.LText = param.LText.replace(/\$@/ig, '/*') @@ -380,7 +408,14 @@ if (btn.sqlType === 'insert') { // 系统函数添加时,生成uuid param.ID = Utils.getguid() param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 数据源 if (retmsg) { const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 数据源 param.LText = sql param.$callbacksql = callbacksql } else { param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 数据源 } if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 param.LText = param.LText.replace(/\$@/ig, '/*') @@ -396,7 +431,14 @@ param.LText = Utils.formatOptions(param.LText) } else { param.ID = primaryId param.LText = Utils.getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 数据源 if (retmsg) { const { sql, callbacksql } = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab, retmsg) // 数据源 param.LText = sql param.$callbacksql = callbacksql } else { param.LText = getSysDefaultSql(btn, setting, formdata, param, cell, columns, this.props.Tab) // 数据源 } if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 param.LText = param.LText.replace(/\$@/ig, '/*') @@ -638,6 +680,14 @@ loadingNumber: params.length || '' }) let record = { BID: param.BID || '', ID: param.ID || '', callbacksql: param.$callbacksql || '' } delete param.$callbacksql Api.genericInterface(param).then(res => { if (res.status) { if (res.mk_ex_invoke === 'false' && params.length === 0) { @@ -646,7 +696,7 @@ } else if (res.mk_ex_invoke === 'false' && params.length > 0) { this.customLoopRequest(params, _resolve) } else { this.customOuterRequest(params, res, _resolve) this.customOuterRequest(params, res, record, _resolve) } } else if (res.ErrCode === 'C' && this.state.checkParam) { const _this = this @@ -663,7 +713,7 @@ } else if (result.mk_ex_invoke === 'false' && params.length > 0) { _this.customLoopRequest(params, _resolve) } else { _this.customOuterRequest(params, result, _resolve) _this.customOuterRequest(params, result, record, _resolve) } } else { _this.execError(result) @@ -696,7 +746,7 @@ /** * @description 自定义请求循环执行 */ customOuterRequest = (params, result, _resolve) => { customOuterRequest = (params, result, record, _resolve) => { const { btn } = this.props let url = '' @@ -736,10 +786,10 @@ $ErrMesg: error } this.customCallbackRequest(params, result, _resolve) this.customCallbackRequest(params, result, record, _resolve) } else { res.mk_api_key = mkey this.customCallbackRequest(params, res, _resolve) this.customCallbackRequest(params, res, record, _resolve) } }, () => { this.updateStatus('over') @@ -750,7 +800,7 @@ /** * @description 回调请求循环执行 */ customCallbackRequest = (params, result, _resolve) => { customCallbackRequest = (params, result, record, _resolve) => { const { btn } = this.props let lines = [] let pre = btn.callbackType === 'script' ? '@' : '' @@ -828,11 +878,14 @@ if (btn.callbackType === 'script') { // 使用自定义脚本 param.func = 'sPC_TableData_InUpDe' if (this.props.BID) { if (record.BID) { param.BID = this.props.BID } if (record.ID) { param.ID = record.ID } let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) let _prevCustomScript = `${record.callbacksql || 'declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000)'} Select @ErrorCode='',@retmsg='' ${errSql} ` @@ -855,7 +908,7 @@ }) _backCustomScript += ` aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` let sql = [...lineMap.values()].map(item => (` ${item.insert} src/tabviews/zshare/mutilform/index.jsx
@@ -1284,16 +1284,18 @@ if (!_item) return if (item.type === 'date' || item.type === 'datemonth' || item.type === 'datetime') { if (_item.value && _item.value.format) { _item.value = _item.value.format(_format[item.type]) } else if (!_item.value) { _item.value = '' } } if (_item.value === undefined) { _item.value = '' } else if (item.type === 'date' || item.type === 'datemonth' || item.type === 'datetime') { if (!_item.value) { _item.value = '' } else if (_item.value.format) { _item.value = _item.value.format(_format[item.type]) } } else if (item.type === 'text' && _item.value) { // 特殊字段替换 _item.value = _item.value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey) _item.value = _item.value.replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')) _item.value = _item.value.replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || '')) } search.push(_item) @@ -1316,19 +1318,20 @@ } let _value = '' if (this.state.datatype[key] === 'datetime') { let _type = this.state.datatype[key] if (_type === 'datetime') { _value = values[key] ? moment(values[key]).format('YYYY-MM-DD HH:mm:ss') : '' } else if (this.state.datatype[key] === 'datemonth') { } else if (_type === 'datemonth') { _value = values[key] ? moment(values[key]).format('YYYY-MM') : '' } else if (this.state.datatype[key] === 'date') { } else if (_type === 'date') { _value = values[key] ? moment(values[key]).format('YYYY-MM-DD') : '' } else if (this.state.datatype[key] === 'number') { } else if (_type === 'number') { _value = values[key] } else if (this.state.datatype[key] === 'multiselect' || this.state.datatype[key] === 'checkbox') { } else if (_type === 'multiselect' || _type === 'checkbox') { _value = values[key] ? values[key].join(',') : '' } else if (this.state.datatype[key] === 'fileupload') { } else if (_type === 'fileupload') { let vals = [] if (values[key] && values[key].length > 0) { @@ -1342,12 +1345,17 @@ } _value = vals.join(',') } else if (this.state.datatype[key] === 'text' || this.state.datatype[key] === 'textarea') { } else if (_type === 'text' || _type === 'textarea') { _value = values[key].replace(/\t*|\v*/g, '') // 去除制表符 if (intercepts.includes(key)) { // 去除首尾空格 _value = _value.replace(/(^\s*|\s*$)/g, '') } if (_type === 'text' && _value) { // 特殊字段替换 _value = _value.replace(/^(\s*)@appkey@(\s*)$/ig, window.GLOB.appkey) _value = _value.replace(/^(\s*)@SessionUid@(\s*)$/ig, (localStorage.getItem('SessionUid') || '')) _value = _value.replace(/^(\s*)@bid@(\s*)$/ig, (this.props.BID || '')) } } else { _value = values[key] } src/tabviews/zshare/settingcomponent/index.jsx
@@ -5,7 +5,7 @@ import Api from '@/api' import MKEmitter from '@/utils/events.js' import UtilsUpdate from '@/utils/utils-update.js' import { updateSubTable } from '@/utils/utils-update.js' import options from '@/store/options.js' import asyncComponent from '@/utils/asyncSpinComponent' import './index.scss' @@ -252,7 +252,7 @@ if (!subconfig || !subconfig.enabled) return subconfig = UtilsUpdate.updateSubTable(subconfig) subconfig = updateSubTable(subconfig) let _comp = {title: res.tab.label, uuid: res.tab.uuid, action: []} src/templates/comtableconfig/index.jsx
@@ -9,7 +9,7 @@ import Api from '@/api' import Utils from '@/utils/utils.js' import UtilsUpdate from '@/utils/utils-update.js' import { updateCommonTable } from '@/utils/utils-update.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' @@ -90,7 +90,7 @@ _config.easyCode = _config.easyCode || '' // 版本兼容 _config = UtilsUpdate.updateCommonTable(_config) _config = updateCommonTable(_config) let _oriActions = [] if (_config.type === 'user') { src/templates/sharecomponent/settingcomponent/settingform/simplescript/index.jsx
@@ -430,6 +430,11 @@ id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id{usefulFields ? ', ' + usefulFields : ''} </Form.Item> </Col> : null} {!usefulFields ? <Col span={24} className="sqlfield"> <Form.Item label={'可用字段'}> id, bid, loginuid, sessionuid, userid, username, fullname, appkey, time_id </Form.Item> </Col> : null} {!usefulFields ? <Col span={8} style={{whiteSpace: 'nowrap'}}> <Form.Item style={{marginBottom: 0}} label="执行位置"> {getFieldDecorator('position', { src/templates/subtableconfig/index.jsx
@@ -11,7 +11,7 @@ import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' import Utils from '@/utils/utils.js' import UtilsUpdate from '@/utils/utils-update.js' import { updateSubTable } from '@/utils/utils-update.js' import asyncComponent from '@/utils/asyncComponent' import SearchComponent from '@/templates/sharecomponent/searchcomponent' @@ -106,7 +106,7 @@ let _activeKey = editSubTab ? editSubTab.activeKey : editTab.activeKey // 版本兼容 _config = UtilsUpdate.updateSubTable(_config) _config = updateSubTable(_config) this.setState({ openEdition: editSubTab ? (editSubTab.open_edition || '') : (editTab.open_edition || ''), src/templates/zshare/verifycard/callbackcustomscript/index.jsx
@@ -12,6 +12,8 @@ static propTpyes = { dict: PropTypes.object, // 字典项 btn: PropTypes.object, // 按钮信息 initsql: PropTypes.string, // 初始化脚本 usefulfields: PropTypes.string, // 可用字段 systemScripts: PropTypes.array, // 系统脚本 customScripts: PropTypes.array, // 自定义脚本 scriptsChange: PropTypes.func // 表单 @@ -82,8 +84,6 @@ return } let prev = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) ` let tail = ` aaa: ` @@ -110,11 +110,12 @@ let param = { func: 's_debug_sql', exec_type: 'y', LText: prev + _prevCustomScript + _backCustomScript + tail LText: this.props.initsql + _prevCustomScript + _backCustomScript + tail } // 数据权限 param.LText = param.LText.replace(/@\$|\$@/ig, '') // check param.LText = param.LText.replace(/\$check@|@check\$/ig, '') @@ -184,7 +185,7 @@ } render() { const { systemScripts, btn } = this.props const { usefulfields, systemScripts, btn } = this.props const { getFieldDecorator } = this.props.form const formItemLayout = { labelCol: { @@ -210,6 +211,11 @@ ErrorCode(增加后缀NT表示数据不回滚,如ENT、NNT、FNT、NMNT), retmsg </Form.Item> </Col> {usefulfields ? <Col span={24} className="sqlfield"> <Form.Item label={'可用字段'}> {usefulfields} </Form.Item> </Col> : null} <Col span={8} style={{whiteSpace: 'nowrap'}}> <Form.Item style={{marginBottom: 0}} label={ <Tooltip placement="bottomLeft" title={'自定义脚本与默认sql位置关系。'}> src/templates/zshare/verifycard/index.jsx
@@ -1570,12 +1570,12 @@ </span> } key="6"> <CustomScript usefulfields={this.state.usefulfields} initsql={this.state.initsql} dict={this.props.dict} btn={this.props.card} dict={this.props.dict} initsql={this.state.initsql} customScripts={verify.scripts} defaultsql={this.state.defaultsql} usefulfields={this.state.usefulfields} systemScripts={this.state.systemScripts} scriptsChange={this.scriptsChange} wrappedComponentRef={(inst) => this.scriptsForm = inst} @@ -1589,9 +1589,11 @@ </span> } key="6a"> <CallBackCustomScript dict={this.props.dict} btn={this.props.card} dict={this.props.dict} initsql={this.state.initsql} customScripts={verify.cbScripts} usefulfields={this.state.usefulfields} systemScripts={this.state.systemScripts} scriptsChange={this.cbScriptsChange} wrappedComponentRef={(inst) => this.cbscriptsForm = inst} src/utils/utils-datamanage.js
@@ -441,8 +441,17 @@ func: 'sPC_TableData_InUpDe', exec_type: 'y', } let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) Select @ErrorCode='',@retmsg='' let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' if (sessionStorage.getItem('isEditState') === 'true') { userName = sessionStorage.getItem('CloudUserName') || '' fullName = sessionStorage.getItem('CloudFullName') || '' } let _prevCustomScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50) Select @ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}' ${errSql} ` let _backCustomScript = ` @@ -490,4 +499,72 @@ return param } /** * @description 获取回调sql */ static getCallBackSql (setting, result) { let lines = [] let pre = setting.callbackType === 'script' ? '@' : '' let getDefaultSql = (obj, tb, bid, level) => { let keys = [] let vals = [] let subObjs = [] let id = Utils.getuuid() delete obj.$$key Object.keys(obj).forEach(key => { let val = obj[key] if (val === null || val === undefined) return if (typeof(val) === 'object') { if (Array.isArray(val)) { val.forEach(item => { if (typeof(item) !== 'object' || Array.isArray(item)) return if (Object.keys(item).length > 0) { item.$$key = tb + '_' + key subObjs.push(item) } }) } else if (Object.keys(val).length > 0) { val.$$key = tb + '_' + key subObjs.push(val) } } else { keys.push(key) vals.push(`'${val}'`) } }) lines.push({ table: tb, insert: `Insert into ${pre}${tb} (${keys.join(',')},mk_level,mk_id,mk_bid)`, select: `Select ${vals.join(',')},'${level}','${id}','${bid}'` }) subObjs.forEach(item => { getDefaultSql(item, item.$$key, id, level + 1) }) } getDefaultSql(result, setting.cbTable, '', 1) let lineMap = new Map() lines.forEach(line => { if (lineMap.has(line.table)) { let _line = lineMap.get(line.table) _line.selects.push(line.select) lineMap.set(line.table, _line) } else { lineMap.set(line.table, { table: line.table, insert: line.insert, selects: [line.select] }) } }) return [...lineMap.values()] } } src/utils/utils-update.js
@@ -1,169 +1,164 @@ import { fromJS } from 'immutable' import Utils from './utils.js' /** * @description 升级主表信息 * @param {Object} config 页面配置信息 * @return {Object} config */ export function updateCommonTable (config) { if (!config.version || config.version < '1.0') { config.version = '1.0' // 兼容标签 if (!config.tabgroups) { config.tabgroups = [{ uuid: 'tabs', sublist: [] }] } else if (typeof(config.tabgroups[0]) === 'string') { let _tabgroups = [] config.tabgroups.forEach(groupId => { let _group = { uuid: groupId, sublist: config[groupId] } export default class UpdateUtils { /** * @description 升级主表信息 * @param {Object} config 页面配置信息 * @return {Object} config */ static updateCommonTable (config) { if (!config.version || config.version < '1.0') { config.version = '1.0' // 兼容标签 if (!config.tabgroups) { config.tabgroups = [{ uuid: 'tabs', sublist: [] }] } else if (typeof(config.tabgroups[0]) === 'string') { let _tabgroups = [] config.tabgroups.forEach(groupId => { let _group = { uuid: groupId, sublist: fromJS(config[groupId]).toJS() } delete config[groupId] _tabgroups.push(_group) }) config.tabgroups = _tabgroups } // 兼容图表 if (!config.charts) { config.expand = true config.charts = [{ uuid: Utils.getuuid(), label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }] } else { config.charts.forEach(card => { if (card.chartType === 'card') { card.details = card.details.map(_cell => { _cell.fontSize = _cell.fontSize || 14 if (!_cell.width) { _cell.width = 100 } else if (_cell.width === 'helf') { _cell.width = 50 } else if (_cell.width === 'third') { _cell.width = 33 } if (!_cell.fontWeight && _cell.bold === 'true') { _cell.fontWeight = 'normal' } _cell.height = _cell.height || 1 return _cell }) } }) } delete config[groupId] _tabgroups.push(_group) }) config.tabgroups = _tabgroups } if (config.version < '1.1') { config.version = '1.1' if (config.setting.interType === 'inner' && !config.setting.innerFunc) { config.setting.interType = 'system' } // 兼容接口类型 config.action = config.action.map(item => { if (item.intertype === 'inner' && !item.innerFunc) { item.intertype = 'system' // 兼容图表 if (!config.charts) { config.expand = true config.charts = [{ uuid: '$$normaltable', label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }] } else { config.charts.forEach(card => { if (card.chartType === 'card') { card.details = card.details.map(_cell => { _cell.fontSize = _cell.fontSize || 14 if (!_cell.width) { _cell.width = 100 } else if (_cell.width === 'helf') { _cell.width = 50 } else if (_cell.width === 'third') { _cell.width = 33 } if (!_cell.fontWeight && _cell.bold === 'true') { _cell.fontWeight = 'normal' } _cell.height = _cell.height || 1 return _cell }) } return item }) } if (config.version < '1.2') { config.version = '1.2' // 兼容功能按钮 config.action = config.action.map(item => { if (item.execMode) { item.OpenType = 'funcbutton' } return item }) } config.Template = 'CommonTable' return config } /** * @description 升级子表信息 * @param {Object} config 页面配置信息 * @return {Object} config */ static updateSubTable (config) { if (!config.version || config.version < '1.0') { config.version = '1.0' // 兼容图表 if (!config.charts) { config.expand = false config.charts = [{ uuid: Utils.getuuid(), label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }] } else { config.charts.forEach(card => { if (card.chartType === 'card') { card.details = card.details.map(_cell => { if (!_cell.fontSize) { _cell.fontSize = 14 } if (!_cell.width) { _cell.width = 100 } else if (_cell.width === 'helf') { _cell.width = 50 } else if (_cell.width === 'third') { _cell.width = 33 } if (_cell.bold === 'true') { _cell.fontWeight = 'normal' } if (!_cell.height) { _cell.height = 1 } return _cell }) } }) if (config.version < '1.1') { config.version = '1.1' if (config.setting.interType === 'inner' && !config.setting.innerFunc) { config.setting.interType = 'system' } // 兼容接口类型 config.action = config.action.map(item => { if (item.intertype === 'inner' && !item.innerFunc) { item.intertype = 'system' } } if (config.version < '1.1') { config.version = '1.1' if (config.setting.interType === 'inner' && !config.setting.innerFunc) { config.setting.interType = 'system' } // 兼容接口类型 config.action = config.action.map(item => { if (item.intertype === 'inner' && !item.innerFunc) { item.intertype = 'system' } return item }) } if (config.version < '1.2') { config.version = '1.2' // 兼容功能按钮 config.action = config.action.map(item => { if (item.execMode) { item.OpenType = 'funcbutton' } return item }) } config.Template = 'SubTable' return config return item }) } if (config.version < '1.2') { config.version = '1.2' // 兼容功能按钮 config.action = config.action.map(item => { if (item.execMode) { item.OpenType = 'funcbutton' } return item }) } config.Template = 'CommonTable' return config } /** * @description 升级子表信息 * @param {Object} config 页面配置信息 * @return {Object} config */ export function updateSubTable (config) { if (!config.version || config.version < '1.0') { config.version = '1.0' // 兼容图表 if (!config.charts) { config.expand = false config.charts = [{ uuid: '$$normalsubtable', label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }] } else { config.charts.forEach(card => { if (card.chartType === 'card') { card.details = card.details.map(_cell => { if (!_cell.fontSize) { _cell.fontSize = 14 } if (!_cell.width) { _cell.width = 100 } else if (_cell.width === 'helf') { _cell.width = 50 } else if (_cell.width === 'third') { _cell.width = 33 } if (_cell.bold === 'true') { _cell.fontWeight = 'normal' } if (!_cell.height) { _cell.height = 1 } return _cell }) } }) } } if (config.version < '1.1') { config.version = '1.1' if (config.setting.interType === 'inner' && !config.setting.innerFunc) { config.setting.interType = 'system' } // 兼容接口类型 config.action = config.action.map(item => { if (item.intertype === 'inner' && !item.innerFunc) { item.intertype = 'system' } return item }) } if (config.version < '1.2') { config.version = '1.2' // 兼容功能按钮 config.action = config.action.map(item => { if (item.execMode) { item.OpenType = 'funcbutton' } return item }) } config.Template = 'SubTable' return config } src/utils/utils.js
@@ -723,947 +723,962 @@ field: arrfield } } } /** * @description 获取excel导入参数 * @return {String} btn 按钮 * @return {String} data excel数据 */ static getExcelInSql (item, data, dict, BID) { let btn = item.verify let keys = ['delete', 'drop', 'insert', 'truncate', 'update'] let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' /** * @description 获取excel导入参数 * @return {String} btn 按钮 * @return {String} data excel数据 */ export function getExcelInSql (item, data, dict, BID) { let btn = item.verify let keys = ['delete', 'drop', 'insert', 'truncate', 'update'] let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' if (sessionStorage.getItem('isEditState') === 'true') { userName = sessionStorage.getItem('CloudUserName') || '' fullName = sessionStorage.getItem('CloudFullName') || '' } let database = item.sheet.match(/(.*)\.(.*)\./ig) || '' let sheet = item.sheet.replace(/(.*)\.(.*)\./ig, '') let errors = [] let _topline = btn.range || 0 let upId = this.getuuid() let _initCustomScript = '' // 初始化脚本 let _prevCustomScript = '' // 默认sql前执行脚本 let _backCustomScript = '' // 默认sql后执行脚本 if (btn.scripts) { btn.scripts.forEach(script => { if (script.status === 'false') return if (script.position === 'init') { _initCustomScript += ` /* 自定义脚本 */ ${script.sql} ` } else if (script.position === 'front') { _prevCustomScript += ` /* 自定义脚本 */ ${script.sql} ` } else { _backCustomScript += ` /* 自定义脚本 */ ${script.sql} ` } }) } // 控制台打印数据 let conLtext = [] let _Ltext = data.map((item, lindex) => { let vals = [] let convals = [] btn.columns.forEach((col, cindex) => { if (col.import === 'false') return let val = item[col.Column] !== undefined ? item[col.Column] : '' let _position = (_topline + lindex + 1) + dict['main.excel.line'] + ' ' + (cindex + 1) + dict['main.excel.column'] + ' ' if (/^Nvarchar/ig.test(col.type)) { if (typeof(val) === 'number') { val = val.toString() } val = val.replace(/(^\s*$)|\t*|\v*/ig, '') if (!val && col.required === 'true') { // 必填校验 errors.push(_position + dict['main.excel.content.emptyerror']) } else if (col.limit && val.length > col.limit) { // 长度校验 errors.push(_position + dict['main.excel.content.maxlimit']) } else { // 关键字校验 keys.forEach(key => { let _patten = new RegExp('(^' + key + '\\s+)|(\\s+' + key + '\\s+)', 'ig') if (_patten.test(val)) { errors.push(_position + dict['main.excel.includekey'] + key) } }) } } else if (/^int/ig.test(col.type)) { if (!val && val !== 0) { errors.push(_position + dict['main.excel.content.emptyerror']) } else { let _val = val + '' if (!/^(([^0][0-9]+|0)$)|^(([1-9]+)$)/.test(_val)) { // 检验是否为整数 errors.push(_position + dict['main.excel.content.interror']) } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验 errors.push(_position + dict['main.excel.content.limitmin']) } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验 errors.push(_position + dict['main.excel.content.limitmax']) } } } else if (/^Decimal/ig.test(col.type)) { if (!val && val !== 0) { errors.push(_position + dict['main.excel.content.emptyerror']) } else { let _val = val + '' let _vals = _val.split('.') if (!/^(([^0][0-9]+|0)\.([0-9]+)$)|^(([^0][0-9]+|0)$)|^(([1-9]+)\.([0-9]+)$)|^(([1-9]+)$)/.test(_val)) { // 检验是否为浮点数 errors.push(_position + dict['main.excel.content.floaterror']) } else if (_vals[0].length > 18) { // 检验整数位 errors.push(_position + dict['main.excel.content.floatIntover']) } else if (_vals[1] && _vals[1].length > col.limit) { // 最小值检验 errors.push(_position + dict['main.excel.content.floatPointover']) } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验 errors.push(_position + dict['main.excel.content.limitmin']) } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验 errors.push(_position + dict['main.excel.content.limitmax']) } } } else if (col.type === 'date') { if (typeof(val) === 'number') { if (val > 2958465 || val <= 0) { // 时间过大或小于等于0 errors.push(_position + dict['main.excel.content.date.over']) } else { // 时间格式化 if (val < 60) { // 1900-2-29,excel中存在,实际不存在 val++ } val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD') } } else if (typeof(val) === 'string') { val = val.replace(/(^\s*$)|\t*|\v*/ig, '') if (!val && col.required === 'true') { // 时间必填校验 errors.push(_position + dict['main.excel.content.emptyerror']) } else if (val && !/^[1-9][0-9]{3}/.test(val)) { // 时间正则校验 errors.push(_position + dict['main.excel.content.date.formatError']) } } else { // 时间格式错误 errors.push(_position + dict['main.excel.content.date.formatError']) } } vals.push(`'${val}'`) if (lindex < 40) { convals.push(`'${val}' as ${col.Column}`) } }) let _lineIndex = '0000' + (lindex + 1) + '0' _lineIndex = _lineIndex.substring(_lineIndex.length - 6) 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 = '' if (item.intertype === 'system') { let _uniquesql = '' if (btn.uniques && btn.uniques.length > 0) { btn.uniques.forEach(unique => { if (unique.status === 'false') 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 ') 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 @${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=${_afields.join('+\' \'+')} from @${sheet} a Inner join ${sheet} b on ${_fields_} If @tbid!='' Begin select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 与已有数据重复' goto aaa end ` }) } let declarefields = [] let fields = [] btn.columns.forEach(col => { if (col.import === 'false') return if (col.type === 'date') { declarefields.push(`${col.Column} Nvarchar(50)`) } else { declarefields.push(`${col.Column} ${col.type}`) } fields.push(col.Column) }) fields = fields.join(',') let _insert = '' if (btn.default !== 'false') { _insert = ` /* 默认sql */ Insert into ${database}${sheet} (${fields},createuserid,createuser,createstaff,bid) Select ${fields},@userid@,@username,@fullname,@BID@ From @${sheet} ` } _sql = ` /* 系统生成 */ declare @${sheet} table (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50) ) Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}' ${_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 ${_uniquesql} ${_prevCustomScript} ${_insert} ${_backCustomScript} Delete @${sheet} aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { let fsql = ` ${_sql} ${_sqlInsert} /* excel数据(前40条) */ ${conLtext.join(' Union all ')} ${_sqlBottom} ` fsql = fsql.replace(/\n\s{8}/ig, '\n') console.info(fsql) } } else { // s_sDataDictb_excelIn 云端密钥验证参数 _sql = ` /* 系统生成 */ declare @${sheet} table (jskey nvarchar(50)) Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}' ` } return { 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('; ') } if (sessionStorage.getItem('isEditState') === 'true') { userName = sessionStorage.getItem('CloudUserName') || '' fullName = sessionStorage.getItem('CloudFullName') || '' } /** * @description 使用系统函数时(sPC_TableData_InUpDe ),生成sql语句 * @return {String} type 执行类型 * @return {String} table 表名 */ static getSysDefaultSql (btn, setting, formdata, param, data, columns, tab, retmsg) { let primaryId = param.ID let BID = param.BID let verify = btn.verify || {} let datavars = {} // 声明的变量,表单及显示列 let _actionType = null let appkey = window.GLOB.appkey || '' let sessionUid = localStorage.getItem('SessionUid') || '' let database = item.sheet.match(/(.*)\.(.*)\./ig) || '' let sheet = item.sheet.replace(/(.*)\.(.*)\./ig, '') if (verify.default !== 'false') { // 判断是否使用默认sql _actionType = btn.sqlType let getuuid = () => { let uuid = [] let timestamp = new Date().getTime() let _options = '0123456789abcdefghigklmnopqrstuv' for (let i = 0; i < 19; i++) { uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1)) } uuid = timestamp + uuid.join('') return uuid } let _initCustomScript = '' // 初始化脚本 let _prevCustomScript = '' // 默认sql前执行脚本 let _backCustomScript = '' // 默认sql后执行脚本 let errors = [] let _topline = btn.range || 0 let upId = getuuid() verify.scripts && verify.scripts.forEach(item => { if (item.status === 'false') return let _initCustomScript = '' // 初始化脚本 let _prevCustomScript = '' // 默认sql前执行脚本 let _backCustomScript = '' // 默认sql后执行脚本 if (item.position === 'init') { if (btn.scripts) { btn.scripts.forEach(script => { if (script.status === 'false') return if (script.position === 'init') { _initCustomScript += ` /* 自定义脚本 */ ${item.sql} ` } else if (item.position === 'front') { /* 自定义脚本 */ ${script.sql} ` } else if (script.position === 'front') { _prevCustomScript += ` /* 自定义脚本 */ ${item.sql} ` /* 自定义脚本 */ ${script.sql} ` } else { _backCustomScript += ` /* 自定义脚本 */ ${item.sql} ` /* 自定义脚本 */ ${script.sql} ` } }) } // 控制台打印数据 let conLtext = [] let _Ltext = data.map((item, lindex) => { let vals = [] let convals = [] btn.columns.forEach((col, cindex) => { if (col.import === 'false') return let val = item[col.Column] !== undefined ? item[col.Column] : '' let _position = (_topline + lindex + 1) + dict['main.excel.line'] + ' ' + (cindex + 1) + dict['main.excel.column'] + ' ' if (/^Nvarchar/ig.test(col.type)) { if (typeof(val) === 'number') { val = val.toString() } val = val.replace(/(^\s*$)|\t*|\v*/ig, '') if (!val && col.required === 'true') { // 必填校验 errors.push(_position + dict['main.excel.content.emptyerror']) } else if (col.limit && val.length > col.limit) { // 长度校验 errors.push(_position + dict['main.excel.content.maxlimit']) } else { // 关键字校验 keys.forEach(key => { let _patten = new RegExp('(^' + key + '\\s+)|(\\s+' + key + '\\s+)', 'ig') if (_patten.test(val)) { errors.push(_position + dict['main.excel.includekey'] + key) } }) } } else if (/^int/ig.test(col.type)) { if (!val && val !== 0) { errors.push(_position + dict['main.excel.content.emptyerror']) } else { let _val = val + '' if (!/^(([^0][0-9]+|0)$)|^(([1-9]+)$)/.test(_val)) { // 检验是否为整数 errors.push(_position + dict['main.excel.content.interror']) } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验 errors.push(_position + dict['main.excel.content.limitmin']) } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验 errors.push(_position + dict['main.excel.content.limitmax']) } } } else if (/^Decimal/ig.test(col.type)) { if (!val && val !== 0) { errors.push(_position + dict['main.excel.content.emptyerror']) } else { let _val = val + '' let _vals = _val.split('.') if (!/^(([^0][0-9]+|0)\.([0-9]+)$)|^(([^0][0-9]+|0)$)|^(([1-9]+)\.([0-9]+)$)|^(([1-9]+)$)/.test(_val)) { // 检验是否为浮点数 errors.push(_position + dict['main.excel.content.floaterror']) } else if (_vals[0].length > 18) { // 检验整数位 errors.push(_position + dict['main.excel.content.floatIntover']) } else if (_vals[1] && _vals[1].length > col.limit) { // 最小值检验 errors.push(_position + dict['main.excel.content.floatPointover']) } else if ((col.min || col.min === 0) && val < col.min) { // 最小值检验 errors.push(_position + dict['main.excel.content.limitmin']) } else if ((col.max || col.max === 0) && val > col.max) { // 最大值检验 errors.push(_position + dict['main.excel.content.limitmax']) } } } else if (col.type === 'date') { if (typeof(val) === 'number') { if (val > 2958465 || val <= 0) { // 时间过大或小于等于0 errors.push(_position + dict['main.excel.content.date.over']) } else { // 时间格式化 if (val < 60) { // 1900-2-29,excel中存在,实际不存在 val++ } val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD') } } else if (typeof(val) === 'string') { val = val.replace(/(^\s*$)|\t*|\v*/ig, '') if (!val && col.required === 'true') { // 时间必填校验 errors.push(_position + dict['main.excel.content.emptyerror']) } else if (val && !/^[1-9][0-9]{3}/.test(val)) { // 时间正则校验 errors.push(_position + dict['main.excel.content.date.formatError']) } } else { // 时间格式错误 errors.push(_position + dict['main.excel.content.date.formatError']) } } vals.push(`'${val}'`) if (lindex < 40) { convals.push(`'${val}' as ${col.Column}`) } }) // 需要声明的变量集 let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode'] let _lineIndex = '0000' + (lindex + 1) + '0' _lineIndex = _lineIndex.substring(_lineIndex.length - 6) // 主键字段 let primaryKey = setting.primaryKey || 'id' 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(',')}`) } // sql语句 let _sql = '' return `Select ${vals.join(',')}` }) let _initvars = [] // 已赋值字段集 let _initFormfields = [] let _initColfields = [] let _declarefields = [] let result = [] for(let i = 0; i < _Ltext.length; i += 20) { result.push(_Ltext.slice(i, i + 20)) } // 获取字段键值对 formdata && formdata.forEach(form => { if (form.type === 'text' && form.value) { // 特殊字段替换 form.value = form.value.replace(/^(\s*)@appkey@(\s*)$/ig, appkey) form.value = form.value.replace(/^(\s*)@SessionUid@(\s*)$/ig, sessionUid) form.value = form.value.replace(/^(\s*)@bid@(\s*)$/ig, BID) let _sql = '' let _sqlInsert = '' let _sqlBottom = '' if (item.intertype === 'system') { let _uniquesql = '' if (btn.uniques && btn.uniques.length > 0) { btn.uniques.forEach(unique => { if (unique.status === 'false') 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 ') 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 @${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=${_afields.join('+\' \'+')} from @${sheet} a Inner join ${sheet} b on ${_fields_} If @tbid!='' Begin select @ErrorCode='${unique.errorCode}',@retmsg=@tbid+' 与已有数据重复' goto aaa end ` }) } let declarefields = [] let fields = [] btn.columns.forEach(col => { if (col.import === 'false') return if (col.type === 'date') { declarefields.push(`${col.Column} Nvarchar(50)`) } else { declarefields.push(`${col.Column} ${col.type}`) } fields.push(col.Column) }) fields = fields.join(',') let _insert = '' if (btn.default !== 'false') { _insert = ` /* 默认sql */ Insert into ${database}${sheet} (${fields},createuserid,createuser,createstaff,bid) Select ${fields},@userid@,@username,@fullname,@BID@ From @${sheet} ` } _sql = ` /* 系统生成 */ declare @${sheet} table (${declarefields.join(',')},jskey nvarchar(50),BID nvarchar(50) ) Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}' ${_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 ${_uniquesql} ${_prevCustomScript} ${_insert} ${_backCustomScript} Delete @${sheet} aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { let fsql = ` ${_sql} ${_sqlInsert} /* excel数据(前40条) */ ${conLtext.join(' Union all ')} ${_sqlBottom} ` fsql = fsql.replace(/\n\s{8}/ig, '\n') console.info(fsql) } } else { // s_sDataDictb_excelIn 云端密钥验证参数 _sql = ` /* 系统生成 */ declare @${sheet} table (jskey nvarchar(50)) Declare @UserName nvarchar(50),@FullName nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@tbid Nvarchar(512) Select @ErrorCode='', @retmsg='', @UserName='${userName}', @FullName='${fullName}' ` } return { 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('; ') } } /** * @description 使用系统函数时(sPC_TableData_InUpDe ),生成sql语句 * @return {String} type 执行类型 * @return {String} table 表名 */ export function getSysDefaultSql (btn, setting, formdata, param, data, columns, tab, retmsg = false) { let primaryId = param.ID let BID = param.BID let verify = btn.verify || {} let datavars = {} // 声明的变量,表单及显示列 let _actionType = null let _callbacksql = '' if (verify.default !== 'false') { // 判断是否使用默认sql _actionType = btn.sqlType } let _initCustomScript = '' // 初始化脚本 let _prevCustomScript = '' // 默认sql前执行脚本 let _backCustomScript = '' // 默认sql后执行脚本 verify.scripts && verify.scripts.forEach(item => { if (item.status === 'false') return if (item.position === 'init') { _initCustomScript += ` /* 自定义脚本 */ ${item.sql} ` } else if (item.position === 'front') { _prevCustomScript += ` /* 自定义脚本 */ ${item.sql} ` } else { _backCustomScript += ` /* 自定义脚本 */ ${item.sql} ` } }) // 需要声明的变量集 let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode'] // 主键字段 let primaryKey = setting.primaryKey || 'id' // sql语句 let _sql = '' let _initvars = [] // 已赋值字段集 let _initFormfields = [] let _initColfields = [] let _declarefields = [] // 获取字段键值对 formdata && formdata.forEach(form => { let _key = form.key.toLowerCase() datavars[_key] = form.value if (!_initvars.includes(_key)) { _initvars.push(_key) if (form.type === 'number') { let val = form.value if (typeof(val) !== 'number') { val = parseFloat(val) if (isNaN(val)) { val = 0 } } _initFormfields.push(`@${_key}=${val}`) } else { _initFormfields.push(`@${_key}='${form.value}'`) } } if (!_vars.includes(_key)) { _vars.push(_key) if (form.fieldlen && form.fieldlen > 2048) { form.fieldlen = 'max' } let _key = form.key.toLowerCase() datavars[_key] = form.value let _type = `nvarchar(${form.fieldlen})` if (form.type.match(/date/ig)) { _type = 'datetime' } else if (form.type === 'number') { _type = `decimal(18,${form.fieldlen})` } _declarefields.push(`@${_key} ${_type}`) } }) if (data) { Object.keys(data).forEach(key => { data[key.toLowerCase()] = data[key] }) } // 添加数据中字段,表单值优先(按钮不选行或多行拼接时跳过) if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce') { datavars = {...data, ...datavars} const setField = (col) => { if (!col.field) return let _key = col.field.toLowerCase() if (!_initvars.includes(_key)) { _initvars.push(_key) let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : '' if (form.type === 'number') { let val = form.value if (typeof(val) !== 'number') { val = parseFloat(val) if (isNaN(val)) { val = 0 } } _initFormfields.push(`@${_key}=${val}`) } else { _initFormfields.push(`@${_key}='${form.value}'`) } _initvars.push(_key) _initColfields.push(`@${_key}='${_val}'`) } if (!_vars.includes(_key)) { _vars.push(_key) if (form.fieldlen && form.fieldlen > 2048) { form.fieldlen = 'max' if (col.datatype) { _declarefields.push(`@${_key} ${col.datatype}`) } else { if (col.fieldlength && col.fieldlength > 2048) { col.fieldlength = 'max' } let _type = `nvarchar(${col.fieldlength || 50})` if (col.type === 'number') { let _length = col.decimal ? col.decimal : 0 _type = `decimal(18,${_length})` } else if (col.type === 'picture' || col.type === 'textarea') { _type = `nvarchar(${col.fieldlength || 512})` } _declarefields.push(`@${_key} ${_type}`) } let _type = `nvarchar(${form.fieldlen})` if (form.type.match(/date/ig)) { _type = 'datetime' } else if (form.type === 'number') { _type = `decimal(18,${form.fieldlen})` } _declarefields.push(`@${_key} ${_type}`) } }) } if (data) { Object.keys(data).forEach(key => { data[key.toLowerCase()] = data[key] if (columns && columns.length > 0) { columns.forEach(col => { if (col.type === 'colspan' || col.type === 'old_colspan') { col.subcols.forEach(cell => { setField(cell) }) } else { setField(col) } }) } } // 添加数据中字段,表单值优先(按钮不选行或多行拼接时跳过) if (data && btn.Ot !== 'notRequired' && btn.Ot !== 'requiredOnce') { datavars = {...data, ...datavars} // 变量声明 _declarefields = _declarefields.join(',') if (_declarefields) { _declarefields = ',' + _declarefields } _sql = `/* 系统生成 */ Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields} ` const setField = (col) => { if (!col.field) return let _key = col.field.toLowerCase() if (!_initvars.includes(_key)) { let _val = datavars.hasOwnProperty(_key) ? datavars[_key] : '' _initvars.push(_key) _initColfields.push(`@${_key}='${_val}'`) } if (!_vars.includes(_key)) { _vars.push(_key) if (col.datatype) { _declarefields.push(`@${_key} ${col.datatype}`) } else { if (col.fieldlength && col.fieldlength > 2048) { col.fieldlength = 'max' } let _type = `nvarchar(${col.fieldlength || 50})` if (col.type === 'number') { let _length = col.decimal ? col.decimal : 0 _type = `decimal(18,${_length})` } else if (col.type === 'picture' || col.type === 'textarea') { _type = `nvarchar(${col.fieldlength || 512})` } _declarefields.push(`@${_key} ${_type}`) } } } if (columns && columns.length > 0) { columns.forEach(col => { if (col.type === 'colspan' || col.type === 'old_colspan') { col.subcols.forEach(cell => { setField(cell) }) } else { setField(col) } }) } } // 变量声明 _declarefields = _declarefields.join(',') if (_declarefields) { _declarefields = ',' + _declarefields } _sql = `/* 系统生成 */ Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields} ` // 表单变量赋值 if (_initFormfields.length > 0) { _sql += ` /* 表单变量赋值 */ select ${_initFormfields.join(',')} ` } // 显示列变量赋值 if (_initColfields.length > 0) { _sql += ` /* 显示列变量赋值 */ select ${_initColfields.join(',')} ` } // 去除禁用的验证 if (verify.contrasts) { verify.contrasts = verify.contrasts.filter(item => item.status !== 'false') } if (verify.uniques) { verify.uniques = verify.uniques.filter(item => item.status !== 'false') } if (verify.customverifys) { verify.customverifys = verify.customverifys.filter(item => item.status !== 'false') } if (verify.billcodes) { verify.billcodes = verify.billcodes.filter(item => item.status !== 'false') } let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' if (sessionStorage.getItem('isEditState') === 'true') { userName = sessionStorage.getItem('CloudUserName') || '' fullName = sessionStorage.getItem('CloudFullName') || '' } // 初始化凭证及用户信息字段 // 表单变量赋值 if (_initFormfields.length > 0) { _sql += ` /* 凭证及用户信息初始化赋值 */ select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @BillCode='', @ModularDetailCode='' ` /* 表单变量赋值 */ select ${_initFormfields.join(',')} ` } // 显示列变量赋值 if (_initColfields.length > 0) { _sql += ` /* 显示列变量赋值 */ select ${_initColfields.join(',')} ` } if (_initCustomScript) { _sql += _initCustomScript if (retmsg) { _callbacksql = _sql } // 去除禁用的验证 if (verify.contrasts) { verify.contrasts = verify.contrasts.filter(item => item.status !== 'false') } if (verify.uniques) { verify.uniques = verify.uniques.filter(item => item.status !== 'false') } if (verify.customverifys) { verify.customverifys = verify.customverifys.filter(item => item.status !== 'false') } if (verify.billcodes) { verify.billcodes = verify.billcodes.filter(item => item.status !== 'false') } let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' if (sessionStorage.getItem('isEditState') === 'true') { userName = sessionStorage.getItem('CloudUserName') || '' fullName = sessionStorage.getItem('CloudFullName') || '' } // 初始化凭证及用户信息字段 _sql += ` /* 凭证及用户信息初始化赋值 */ select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @BillCode='', @ModularDetailCode='' ` if (_initCustomScript) { _sql += _initCustomScript } // 启用账期验证 if (verify.accountdate === 'true') { let orgcode = `''` let date = `''` if (verify.accountfield && _initvars.includes(verify.accountfield.toLowerCase())) { orgcode = '@' + verify.accountfield } if (verify.voucherdate && _initvars.includes(verify.voucherdate.toLowerCase())) { date = '@' + verify.voucherdate } // 启用账期验证 if (verify.accountdate === 'true') { let orgcode = `''` let date = `''` if (verify.accountfield && _initvars.includes(verify.accountfield.toLowerCase())) { orgcode = '@' + verify.accountfield } if (verify.voucherdate && _initvars.includes(verify.voucherdate.toLowerCase())) { date = '@' + verify.voucherdate } _sql += ` /* 账期验证 */ exec s_FIBVoucherDateCheck @OrgCode=${orgcode},@FIBVoucherDate=${date},@ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT if @ErrorCode!='' GOTO aaa ` } // 失效验证,添加数据时不用 if (btn.sqlType !== 'insert' && verify.invalid === 'true' && setting.dataresource) { let datasource = setting.dataresource if (/\s/.test(datasource) && !/tb$/.test(datasource)) { // 拼接别名 datasource = '(' + datasource + ') tb' } if (setting.customScript) { _sql += ` /* 账期验证 */ exec s_FIBVoucherDateCheck @OrgCode=${orgcode},@FIBVoucherDate=${date},@ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT if @ErrorCode!='' GOTO aaa ` } // 失效验证,添加数据时不用 if (btn.sqlType !== 'insert' && verify.invalid === 'true' && setting.dataresource) { let datasource = setting.dataresource if (/\s/.test(datasource) && !/tb$/.test(datasource)) { // 拼接别名 datasource = '(' + datasource + ') tb' } if (setting.customScript) { _sql += ` /* 数据源自定义脚本,请注意变量定义是否重复 */ ${setting.customScript} ` } if (btn.Ot === 'requiredOnce') { _sql += ` /* 失效验证 */ select @tbid='', @ErrorCode='',@retmsg='' select @tbid='X' from ${datasource} right join (select ID from dbo.SplitComma(@ID@)) sp on tb.id =sp.id where tb.id is null If @tbid!='' Begin select @ErrorCode='E',@retmsg='数据已失效' goto aaa end ` } else { _sql += ` /* 失效验证 */ select @tbid='', @ErrorCode='',@retmsg='' select @tbid=${primaryKey} from ${datasource} where ${primaryKey}=@ID@ If @tbid='' Begin select @ErrorCode='E',@retmsg='数据已失效' goto aaa end ` } } // 比较验证 if (verify.contrasts && verify.contrasts.length > 0) { verify.contrasts.forEach(item => { _sql += ` /* 比较验证 */ If ${item.frontfield} ${item.operator} ${item.backfield} Begin select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' goto aaa end ` }) } // 自定义验证 verify.customverifys && verify.customverifys.forEach(item => { _sql += ` /* 自定义验证 */ select @tbid='', @ErrorCode='',@retmsg='' select top 1 @tbid='X' from (${item.sql}) a If @tbid ${item.result === 'true' ? '!=' : '='}'' Begin select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' goto aaa end ` }) // 单号生成,使用上级id(BID)或列表数据,声明变量(检验) let _billcodesSql = '' if (formdata && verify.billcodes && verify.billcodes.length > 0) { let keys = formdata.map(item => item.key.toLowerCase()) // 表单字段 verify.billcodes.forEach(item => { let _key = item.field.toLowerCase() let _linkKey = item.linkField ? item.linkField.toLowerCase() : '' if (!keys.includes(_key)) return // 表单中不含单号生成字段 let _ModularDetailCode = '' let _lpline = '' if (item.TypeCharOne === 'Lp') { if (_linkKey === 'bid' && BID) { // 替换bid _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)` } else { _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${_linkKey},48)` } _ModularDetailCode = '@ModularDetailCode' } else if (item.TypeCharOne === 'BN') { let _val = '' if (_linkKey === 'bid' && BID) { // 替换bid _val = BID } else if (data && data.hasOwnProperty(_linkKey)) { _val = data[_linkKey] } _ModularDetailCode = `'${item.TypeCharOne + _val}'` } else { _ModularDetailCode = `'${item.ModularDetailCode}'` } let _declare = '' if (!_vars.includes(_key)) { _declare = `Declare @${_key} nvarchar(50)` _vars.push(_key) } _billcodesSql += ` /* 单号生成 */ ${_declare} select @BillCode='', @${_key}='', @ModularDetailCode='' ${_lpline} exec s_get_BillCode @ModularDetailCode=${_ModularDetailCode}, @Type=${item.Type}, @TypeCharOne='${item.TypeCharOne}', @TypeCharTwo ='${item.TypeCharTwo}', @BillCode =@BillCode output, @ErrorCode =@ErrorCode output, @retmsg=@retmsg output if @ErrorCode!='' goto aaa set @${_key}=@BillCode ` }) if (_actionType !== 'insertOrUpdate') { _sql += _billcodesSql } } // 唯一性验证,必须存在表单(表单存在时,主键均为单值),必须填写数据源,多行拼接时不可用 if (formdata && verify.uniques && verify.uniques.length > 0 && btn.Ot !== 'requiredOnce') { verify.uniques.forEach(item => { let _fieldValue = [] // 表单键值对field=value let _value = [] // 表单值,用于错误提示 let _labels = item.fieldlabel.split(',') // 表单提示文字 let arr = [] // 验证主键 item.field.split(',').forEach((_field, index) => { let _key = _field.toLowerCase() let _val = datavars[_key] !== undefined ? datavars[_key] : '' let _fval = `'${_val}'` if (_key === 'bid' && !datavars.bid) { // 表单中没有bid则使用系统bid变量 _fval = '@BID@' } if (_key === 'bid' && tab && tab.foreignKey) { arr.push(tab.foreignKey.toLowerCase()) _fieldValue.push(`${tab.foreignKey}=${_fval}`) } else { arr.push(_key) _fieldValue.push(`${_key}=${_fval}`) } _value.push(`${_labels[index] || ''}:${_val || ''}`) }) let _verifyType = '' if (item.verifyType === 'logic') { _verifyType = ' and deleted=0' } if (!arr.includes(primaryKey.toLowerCase())) { _fieldValue.push(`${primaryKey} !='${primaryId}'`) } _sql += ` /* 唯一性验证 */ select @tbid='', @ErrorCode='',@retmsg='' select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${_verifyType} If @tbid!='' Begin select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 已存在' goto aaa end ` }) } else if (verify.uniques && verify.uniques.length > 0 && btn.Ot === 'requiredOnce' && setting.dataresource) { let datasource = setting.dataresource if (/\s/.test(datasource)) { // 拼接别名 if (!/tb$/.test(datasource)) { datasource = '(' + datasource + ') tb' } } else { datasource = datasource + ' tb' } if (setting.customScript) { _sql += ` /* 数据源自定义脚本,请注意变量定义是否重复 */ ${setting.customScript} ` } verify.uniques.forEach(item => { _sql += ` /* 同类数据验证 */ Set @tbid='' Select top 1 @tbid='X' from (select distinct ${item.field},1 as n from ${datasource} inner join (select ID from dbo.SplitComma(@ID@)) sp on tb.${primaryKey}=sp.ID ) a having sum(n)>1 If @tbid!='' Begin Set @ErrorCode='E' Set @retmsg='${item.fieldlabel} 值不唯一' goto aaa end ` }) } let hasvoucher = false // 凭证-显示列中选取,必须选行 if (verify.voucher && verify.voucher.enabled && data) { let _voucher = verify.voucher hasvoucher = true _sql += ` /* 创建凭证 */ exec s_BVoucher_Create @Bill ='${data[_voucher.linkField.toLowerCase()]}', @BVoucherType ='${_voucher.BVoucherType}', @VoucherTypeOne ='${_voucher.VoucherTypeOne}', @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}', @Type =${_voucher.Type}, @UserID=@UserID@, @Username=@Username, @FullName=@FullName, @BVoucher =@BVoucher OUTPUT , @FIBVoucherDate =@FIBVoucherDate OUTPUT , @FiYear =@FiYear OUTPUT , @ErrorCode =@ErrorCode OUTPUT, @retmsg=@retmsg OUTPUT if @ErrorCode!='' GOTO aaa ` } let _insertsql = '' if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { // 添加语句 let keys = [] let values = [] formdata.forEach(item => { if (item.writein === false) return let _key = item.key.toLowerCase() keys.push(_key) values.push('@' + _key) }) if (!keys.includes(primaryKey.toLowerCase())) { keys.push(primaryKey.toLowerCase()) values.push('\'' + primaryId + '\'') } if (!keys.includes('createuserid')) { keys.push('createuserid') values.push('@userid@') } if (!keys.includes('createuser')) { keys.push('createuser') values.push('@username') } if (!keys.includes('createstaff')) { keys.push('createstaff') values.push('@fullname') } if (!keys.includes('bid')) { if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) { keys.push(tab.foreignKey.toLowerCase()) } else { keys.push('bid') } values.push('@BID@') } else if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) { keys.push(tab.foreignKey.toLowerCase()) values.push('@BID@') } keys = keys.join(',') values = values.join(',') _insertsql = `insert into ${btn.sql} (${keys}) select ${values};` } let _updatesql = '' if (_actionType === 'update' || _actionType === 'audit' || _actionType === 'insertOrUpdate') { // 修改语句 let _form = [] let _arr = [] formdata.forEach(item => { if (item.writein === false) return let _key = item.key.toLowerCase() _arr.push(_key) _form.push(_key + '=@' + _key) }) if (_actionType === 'audit') { if (!_arr.includes('submitdate')) { _form.push('submitdate=getdate()') } if (!_arr.includes('submituserid')) { _form.push('submituserid=@userid@') } } else { if (!_arr.includes('modifydate')) { _form.push('modifydate=getdate()') } if (!_arr.includes('modifyuserid')) { _form.push('modifyuserid=@userid@') } } if (hasvoucher) { if (!_arr.includes('bvoucher')) { _form.push('BVoucher=@BVoucher') } if (!_arr.includes('fibvoucherdate')) { _form.push('FIBVoucherDate=@FIBVoucherDate') } if (!_arr.includes('fiyear')) { _form.push('FiYear=@FiYear') } } _form = _form.join(',') let _ID = '=@ID@' if (btn.Ot === 'requiredOnce') { _ID = ' in (select ID from dbo.SplitComma(@ID@))' } _updatesql = `update ${btn.sql} set ${_form} where ${primaryKey}${_ID};` } if (_prevCustomScript) { _sql += _prevCustomScript } // 添加、修改、逻辑删除、物理删除 if (_actionType === 'insert') { _sql += ` /* 默认sql */ ${_insertsql}` } else if (_actionType === 'update' || _actionType === 'audit') { _sql += ` /* 默认sql */ ${_updatesql}` } else if (_actionType === 'LogicDelete') { // 逻辑删除 let _ID = '=@ID@' if (btn.Ot === 'requiredOnce') { _ID = ' in (select ID from dbo.SplitComma(@ID@))' } _sql += ` /* 默认sql */ update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}${_ID};` } else if (_actionType === 'delete') { // 物理删除 let _msg = '' if (data && columns && columns.length > 0) { let _index = 0 columns.forEach(col => { if (col.Hide !== 'true' && col.type !== 'colspan' && col.type !== 'old_colspan' && _index < 4) { _msg += col.label + '=' + data[col.field] + ',' _index++ } }) } let _ID = '=@ID@' if (btn.Ot === 'requiredOnce') { _ID = ' in (select ID from dbo.SplitComma(@ID@))' } _sql += ` /* 默认sql */ insert into snote (remark,createuserid,CreateUser,CreateStaff) select left('删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@ID@,200),@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}${_ID};` } else if (_actionType === 'insertOrUpdate') { _sql += ` /* 默认sql */ select @tbid='' select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@ if @tbid='' begin ${_billcodesSql} ${_insertsql} end else begin ${_updatesql} end /* 数据源自定义脚本,请注意变量定义是否重复 */ ${setting.customScript} ` } if (_backCustomScript) { _sql += _backCustomScript } if (retmsg) { if (btn.Ot === 'requiredOnce') { _sql += ` aaa: if @ErrorCode!='' insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@` /* 失效验证 */ select @tbid='', @ErrorCode='',@retmsg='' select @tbid='X' from ${datasource} right join (select ID from dbo.SplitComma(@ID@)) sp on tb.id =sp.id where tb.id is null If @tbid!='' Begin select @ErrorCode='E',@retmsg='数据已失效' goto aaa end ` } else { _sql += ` aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` /* 失效验证 */ select @tbid='', @ErrorCode='',@retmsg='' select @tbid=${primaryKey} from ${datasource} where ${primaryKey}=@ID@ If @tbid='' Begin select @ErrorCode='E',@retmsg='数据已失效' goto aaa end ` } } // 比较验证 if (verify.contrasts && verify.contrasts.length > 0) { verify.contrasts.forEach(item => { _sql += ` /* 比较验证 */ If ${item.frontfield} ${item.operator} ${item.backfield} Begin select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' goto aaa end ` }) } // 自定义验证 verify.customverifys && verify.customverifys.forEach(item => { _sql += ` /* 自定义验证 */ select @tbid='', @ErrorCode='',@retmsg='' select top 1 @tbid='X' from (${item.sql}) a If @tbid ${item.result === 'true' ? '!=' : '='}'' Begin select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' goto aaa end ` }) // 单号生成,使用上级id(BID)或列表数据,声明变量(检验) let _billcodesSql = '' if (formdata && verify.billcodes && verify.billcodes.length > 0) { let keys = formdata.map(item => item.key.toLowerCase()) // 表单字段 verify.billcodes.forEach(item => { let _key = item.field.toLowerCase() let _linkKey = item.linkField ? item.linkField.toLowerCase() : '' if (!keys.includes(_key)) return // 表单中不含单号生成字段 let _ModularDetailCode = '' let _lpline = '' if (item.TypeCharOne === 'Lp') { if (_linkKey === 'bid' && BID) { // 替换bid _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)` } else { _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${_linkKey},48)` } _ModularDetailCode = '@ModularDetailCode' } else if (item.TypeCharOne === 'BN') { let _val = '' if (_linkKey === 'bid' && BID) { // 替换bid _val = BID } else if (data && data.hasOwnProperty(_linkKey)) { _val = data[_linkKey] } _ModularDetailCode = `'${item.TypeCharOne + _val}'` } else { _ModularDetailCode = `'${item.ModularDetailCode}'` } let _declare = '' if (!_vars.includes(_key)) { _declare = `Declare @${_key} nvarchar(50)` _vars.push(_key) } _billcodesSql += ` /* 单号生成 */ ${_declare} select @BillCode='', @${_key}='', @ModularDetailCode='' ${_lpline} exec s_get_BillCode @ModularDetailCode=${_ModularDetailCode}, @Type=${item.Type}, @TypeCharOne='${item.TypeCharOne}', @TypeCharTwo ='${item.TypeCharTwo}', @BillCode =@BillCode output, @ErrorCode =@ErrorCode output, @retmsg=@retmsg output if @ErrorCode!='' goto aaa set @${_key}=@BillCode ` }) if (_actionType !== 'insertOrUpdate') { _sql += _billcodesSql } } // 唯一性验证,必须存在表单(表单存在时,主键均为单值),必须填写数据源,多行拼接时不可用 if (formdata && verify.uniques && verify.uniques.length > 0 && btn.Ot !== 'requiredOnce') { verify.uniques.forEach(item => { let _fieldValue = [] // 表单键值对field=value let _value = [] // 表单值,用于错误提示 let _labels = item.fieldlabel.split(',') // 表单提示文字 let arr = [] // 验证主键 item.field.split(',').forEach((_field, index) => { let _key = _field.toLowerCase() let _val = datavars[_key] !== undefined ? datavars[_key] : '' let _fval = `'${_val}'` if (_key === 'bid' && !datavars.bid) { // 表单中没有bid则使用系统bid变量 _fval = '@BID@' } if (_key === 'bid' && tab && tab.foreignKey) { arr.push(tab.foreignKey.toLowerCase()) _fieldValue.push(`${tab.foreignKey}=${_fval}`) } else { arr.push(_key) _fieldValue.push(`${_key}=${_fval}`) } _value.push(`${_labels[index] || ''}:${_val || ''}`) }) let _verifyType = '' if (item.verifyType === 'logic') { _verifyType = ' and deleted=0' } if (!arr.includes(primaryKey.toLowerCase())) { _fieldValue.push(`${primaryKey} !='${primaryId}'`) } _sql += ` /* 唯一性验证 */ select @tbid='', @ErrorCode='',@retmsg='' select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')}${_verifyType} If @tbid!='' Begin select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 已存在' goto aaa end ` }) } else if (verify.uniques && verify.uniques.length > 0 && btn.Ot === 'requiredOnce' && setting.dataresource) { let datasource = setting.dataresource if (/\s/.test(datasource)) { // 拼接别名 if (!/tb$/.test(datasource)) { datasource = '(' + datasource + ') tb' } } else { datasource = datasource + ' tb' } if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { _sql = _sql.replace(/\n\s{8}/ig, '\n') console.info(_sql) if (setting.customScript) { _sql += ` /* 数据源自定义脚本,请注意变量定义是否重复 */ ${setting.customScript} ` } verify.uniques.forEach(item => { _sql += ` /* 同类数据验证 */ Set @tbid='' Select top 1 @tbid='X' from (select distinct ${item.field},1 as n from ${datasource} inner join (select ID from dbo.SplitComma(@ID@)) sp on tb.${primaryKey}=sp.ID ) a having sum(n)>1 If @tbid!='' Begin Set @ErrorCode='E' Set @retmsg='${item.fieldlabel} 值不唯一' goto aaa end ` }) } let hasvoucher = false // 凭证-显示列中选取,必须选行 if (verify.voucher && verify.voucher.enabled && data) { let _voucher = verify.voucher hasvoucher = true _sql += ` /* 创建凭证 */ exec s_BVoucher_Create @Bill ='${data[_voucher.linkField.toLowerCase()]}', @BVoucherType ='${_voucher.BVoucherType}', @VoucherTypeOne ='${_voucher.VoucherTypeOne}', @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}', @Type =${_voucher.Type}, @UserID=@UserID@, @Username=@Username, @FullName=@FullName, @BVoucher =@BVoucher OUTPUT , @FIBVoucherDate =@FIBVoucherDate OUTPUT , @FiYear =@FiYear OUTPUT , @ErrorCode =@ErrorCode OUTPUT, @retmsg=@retmsg OUTPUT if @ErrorCode!='' GOTO aaa ` } let _insertsql = '' if (_actionType === 'insert' || _actionType === 'insertOrUpdate') { // 添加语句 let keys = [] let values = [] formdata.forEach(item => { if (item.writein === false) return let _key = item.key.toLowerCase() keys.push(_key) values.push('@' + _key) }) if (!keys.includes(primaryKey.toLowerCase())) { keys.push(primaryKey.toLowerCase()) values.push('\'' + primaryId + '\'') } if (!keys.includes('createuserid')) { keys.push('createuserid') values.push('@userid@') } if (!keys.includes('createuser')) { keys.push('createuser') values.push('@username') } if (!keys.includes('createstaff')) { keys.push('createstaff') values.push('@fullname') } if (!keys.includes('bid')) { if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) { keys.push(tab.foreignKey.toLowerCase()) } else { keys.push('bid') } values.push('@BID@') } else if (tab && tab.foreignKey && !keys.includes(tab.foreignKey.toLowerCase())) { keys.push(tab.foreignKey.toLowerCase()) values.push('@BID@') } keys = keys.join(',') values = values.join(',') _insertsql = `insert into ${btn.sql} (${keys}) select ${values};` } let _updatesql = '' if (_actionType === 'update' || _actionType === 'audit' || _actionType === 'insertOrUpdate') { // 修改语句 let _form = [] let _arr = [] formdata.forEach(item => { if (item.writein === false) return let _key = item.key.toLowerCase() _arr.push(_key) _form.push(_key + '=@' + _key) }) if (_actionType === 'audit') { if (!_arr.includes('submitdate')) { _form.push('submitdate=getdate()') } if (!_arr.includes('submituserid')) { _form.push('submituserid=@userid@') } } else { if (!_arr.includes('modifydate')) { _form.push('modifydate=getdate()') } if (!_arr.includes('modifyuserid')) { _form.push('modifyuserid=@userid@') } } if (hasvoucher) { if (!_arr.includes('bvoucher')) { _form.push('BVoucher=@BVoucher') } if (!_arr.includes('fibvoucherdate')) { _form.push('FIBVoucherDate=@FIBVoucherDate') } if (!_arr.includes('fiyear')) { _form.push('FiYear=@FiYear') } } _form = _form.join(',') let _ID = '=@ID@' if (btn.Ot === 'requiredOnce') { _ID = ' in (select ID from dbo.SplitComma(@ID@))' } _updatesql = `update ${btn.sql} set ${_form} where ${primaryKey}${_ID};` } if (_prevCustomScript) { _sql += _prevCustomScript } // 添加、修改、逻辑删除、物理删除 if (_actionType === 'insert') { _sql += ` /* 默认sql */ ${_insertsql}` } else if (_actionType === 'update' || _actionType === 'audit') { _sql += ` /* 默认sql */ ${_updatesql}` } else if (_actionType === 'LogicDelete') { // 逻辑删除 let _ID = '=@ID@' if (btn.Ot === 'requiredOnce') { _ID = ' in (select ID from dbo.SplitComma(@ID@))' } _sql += ` /* 默认sql */ update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}${_ID};` } else if (_actionType === 'delete') { // 物理删除 let _msg = '' if (data && columns && columns.length > 0) { let _index = 0 columns.forEach(col => { if (col.Hide !== 'true' && col.type !== 'colspan' && col.type !== 'old_colspan' && _index < 4) { _msg += col.label + '=' + data[col.field] + ',' _index++ } }) } let _ID = '=@ID@' if (btn.Ot === 'requiredOnce') { _ID = ' in (select ID from dbo.SplitComma(@ID@))' } _sql += ` /* 默认sql */ insert into snote (remark,createuserid,CreateUser,CreateStaff) select left('删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@ID@,200),@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}${_ID};` } else if (_actionType === 'insertOrUpdate') { _sql += ` /* 默认sql */ select @tbid='' select @tbid='X' from ${btn.sql} where ${primaryKey}=@ID@ if @tbid='' begin ${_billcodesSql} ${_insertsql} end else begin ${_updatesql} end ` } if (_backCustomScript) { _sql += _backCustomScript } if (retmsg) { _sql += ` aaa: if @ErrorCode!='' insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@` } else { _sql += ` aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg` } if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { // _sql = _sql.replace(/\n\s{8}/ig, '\n') console.info(_sql) } if (retmsg) { return { sql: _sql, callbacksql: _callbacksql } } else { return _sql } } src/views/billprint/index.jsx
@@ -121,26 +121,26 @@ A4: { vertical: 980, horizontal: 1200, verticaldefault: 1.45789, verticalwithout: 1.41428, horizontaldefault: 0.683, horizontalwithout: 0.705, verticaldefault: 1.455, verticalwithout: 1.411, horizontaldefault: 0.679, horizontalwithout: 0.701, }, A3: { vertical: 1200, horizontal: 1600, verticaldefault: 1.44404, verticalwithout: 1.41414, horizontaldefault: 0.6923, horizontalwithout: 0.707, verticaldefault: 1.441, verticalwithout: 1.410, horizontaldefault: 0.688, horizontalwithout: 0.703, }, A5: { vertical: 700, horizontal: 1000, verticaldefault: 1.482, verticalwithout: 1.417, horizontaldefault: 0.6736, horizontalwithout: 0.7047, verticaldefault: 1.478, verticalwithout: 1.413, horizontaldefault: 0.669, horizontalwithout: 0.700, } } src/views/menudesign/index.jsx
@@ -34,6 +34,7 @@ const PasteController = asyncComponent(() => import('@/menu/pastecontroller')) const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) // const PictureController = asyncComponent(() => import('@/menu/picturecontroller')) const StyleCombController = asyncComponent(() => import('@/menu/stylecombcontroller')) const StyleCombControlButton = asyncComponent(() => import('@/menu/stylecombcontrolbutton')) const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) @@ -101,6 +102,7 @@ MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle) MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent) this.updateCustomComponent() // this.getAppPictures() } /** @@ -117,6 +119,19 @@ MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle) MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent) } // getAppPictures = () => { // Api.getSystemConfig({ // func: 's_url_db_adduptdel', // id: '', // PageIndex: 0, // 0 代表全部 // PageSize: 0, // 0 代表全部 // typecharone: 'image', // type: 'search' // }).then(res => { // }) // } updateCustomComponent = () => { Api.getSystemConfig({ @@ -900,10 +915,10 @@ {customComponents && customComponents.length ? <Panel header="自定义组件" key="cuscomponent"> <SourceWrap components={customComponents} MenuType={MenuType} /> </Panel> : null} <Panel header={'背景'} key="background"> <Panel header={'页面背景'} key="background"> {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null} </Panel> <Panel header={'内边距'} key="padding"> <Panel header={'页面内边距'} key="padding"> {config ? <PaddingController config={config} updateConfig={this.updateConfig} /> : null} </Panel> </Collapse> @@ -913,6 +928,7 @@ <div> {config && config.MenuName} </div> } bordered={false} extra={ <div> {/* <PictureController/> */} <StyleCombControlButton menu={config} /> <PasteController type="menu" Tab={null} insert={this.insert} /> {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null} src/views/menudesign/printmenuform/index.jsx
@@ -36,8 +36,12 @@ this.props.updateConfig({...this.props.config, pageSize: val}) } onRadioChange = (val) => { onLayoutChange = (val) => { this.props.updateConfig({...this.props.config, pageLayout: val}) } onPaddingChange = (val) => { this.props.updateConfig({...this.props.config, pagePadding: val}) } render() { @@ -87,7 +91,7 @@ } ] })( <Radio.Group onChange={(e) => {this.onRadioChange(e.target.value)}}> <Radio.Group onChange={(e) => {this.onLayoutChange(e.target.value)}}> <Radio value="vertical">纵向</Radio> <Radio value="horizontal">横向</Radio> </Radio.Group> @@ -105,7 +109,7 @@ } ] })( <Radio.Group onChange={(e) => {this.onRadioChange(e.target.value)}}> <Radio.Group onChange={(e) => {this.onPaddingChange(e.target.value)}}> <Radio value="default">默认</Radio> <Radio value="without">无</Radio> </Radio.Group>