king
2023-08-27 d340a56429b12c3c893762730638631e147e047c
2023-08-27
19个文件已修改
1个文件已添加
1794 ■■■■ 已修改文件
src/menu/components/card/cardcellcomponent/index.jsx 75 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/share/actioncomponent/actionform/index.jsx 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/share/actioncomponent/formconfig.jsx 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/share/actioncomponent/index.jsx 84 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/datasource/index.jsx 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/datasource/verifycard/index.jsx 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/datasource/verifycard/settingform/index.jsx 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/module/voucher/index.jsx 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/excelInbutton/index.jsx 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/exceloutbutton/index.jsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/normalbutton/index.jsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/printbutton/index.jsx 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/actioncomponent/verifyexcelin/columnform/index.jsx 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/settingcomponent/index.jsx 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/createfunc/index.jsx 256 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/createfunc/utils.js 454 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils-datamanage.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils.js 638 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
            ]}
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') {
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' : ''),
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>
          ]}
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>
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>
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={
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 => {
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)
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)
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') { // 表单
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
          })
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: ''
        })
      }
    })
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}>
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%',
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>
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}
      >
        创建存储过程
src/templates/zshare/createfunc/utils.js
New file
@@ -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
  }
}
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) {
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
  }
}