king
2020-06-29 0c9972b68aaee5ce0d536bb418ebcd2887012a28
2020-06-29
12个文件已修改
305 ■■■■■ 已修改文件
src/api/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/index.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/options.js 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/excelInbutton/index.jsx 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/exceloutbutton/index.jsx 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/fileupload/index.jsx 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/mutilform/index.jsx 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/menuconfig/editsecmenu/index.scss 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/menuconfig/editthdmenu/index.scss 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/actioncomponent/index.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx 205 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/settingcomponent/settingform/index.jsx 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/index.js
@@ -13,7 +13,7 @@
  config.method = 'post'
  if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult')) {
    config.data = qs.stringify(config.data)
  } else if (config.url.includes('Upload') || config.url.includes('doupload')) {
  } else if (config.url.includes('Upload') || config.url.includes('doupload') || config.url.includes('dopreload')) {
    config.headers = { 'Content-Type': 'multipart/form-data' }
  } else {
    // config.headers.token = sessionStorage.getItem('TOKEN') || ''
src/index.js
@@ -14,6 +14,11 @@
  window.location.replace(window.location.href.split(/(index.html)+/ig)[0] + 'mob/index.html')
}
options.sysType = window.atob(options.sysType.replace('$mk', ''))
options.caId = window.atob(options.caId.replace('$mk', ''))
options.cakey = window.atob(options.cakey.replace('$mk', ''))
options.cdomain = window.atob(options.cdomain.replace('$mk', ''))
if (options.cdomain) {
  options.cloudServiceApi = options.cdomain + '/webapi/dostars'
}
src/store/options.js
@@ -1,7 +1,7 @@
// 系统配置
export default {
  sysType: 'local', // cloud 、 SSO 、 local
  caId: '',
  cakey: '2020011612400464367D38162115B417895C1',
  cdomain: 'http://cloud.mk9h.cn'
  sysType: 'bG9j$mkYWw=', // yun ( Y2xvdWQ= ) 、 dandian ( U1NP ) 、 yewu ( bG9jYWw= )
  caId: 'MjAyMDAxMTYxMjMzMzU1MDd$mkGQzkyMzI1Rjk4MDY0QUNGQjQ2Mg==', // mk
  cakey: 'MjAyMDAxMTYxMjQwMDQ2NDM$mk2N0QzODE2MjExNUI0MTc4OTVDMQ==', // mk
  cdomain: 'aHR0cDovL2Nsb3V$mkkLm1rOWguY24=' // mk
}
src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -261,6 +261,7 @@
        result.bottom = result.bottom.replace(/@\$|\$@/ig, '')
      }
      
      param.excel_in = 'true'
      param.LText_insert = Utils.formatOptions(result.insert)
      param.LText_bottom = Utils.formatOptions(result.bottom)
      param.LText = Utils.formatOptions(result.sql)
src/tabviews/zshare/actionList/exceloutbutton/index.jsx
@@ -31,6 +31,7 @@
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    excelName: '',
    search: '',     // 搜索条件
    loading: false
  }
@@ -131,6 +132,8 @@
        duration: 5
      })
      return
    } else if (btn.intertype === 'inner' && !btn.innerFunc && btn.verify && btn.verify.enable === 'true') {
      this.setState({search: fromJS(viewParam.search).toJS()})
    }
    
    this.updateStatus('start', name)
@@ -312,8 +315,6 @@
      }
      param = this.getExcelDefaultParam(viewParam.arr_field, viewParam.orderBy, viewParam.search, true, pageIndex, pageSize)
    } else if (btn.intertype === 'inner' && btn.innerFunc) { // 使用内部函数
      param = this.getExcelCustomParam(viewParam.orderBy, viewParam.search, true, pageIndex, pageSize)
      param.func = btn.innerFunc
@@ -456,7 +457,11 @@
        XLSX.writeFile(wb, this.state.excelName)
        if (btn.verify && btn.verify.enable === 'true' && btn.verify.script) {
          this.execCustomScript()
        } else {
        this.execSuccess({ErrCode: 'S', ErrMesg: '导出成功!'})
        }
      } catch {
        this.execError({ErrCode: 'N', message: 'Excel生成失败!'})
      }
@@ -466,6 +471,60 @@
  }
  /**
   * @description 执行自定义脚本
   */
  execCustomScript = () => {
    const { btn } = this.props
    const { search } = this.state
    let script = btn.verify.script
    if (this.props.dataManager) { // 数据权限
      script = script.replace(/\$@/ig, '/*')
      script = script.replace(/@\$/ig, '*/')
    } else {
      script = script.replace(/@\$|\$@/ig, '')
    }
    let allSearch = Utils.getAllSearchOptions(search)
    let regoptions = allSearch.map(item => {
      return {
        reg: new RegExp('@' + item.key + '@', 'ig'),
        value: `'${item.value}'`
      }
    })
    regoptions.forEach(item => {
      script = script.replace(item.reg, item.value)
    })
    let param = {
      func: 'sPC_TableData_InUpDe'
    }
    if (this.props.BID) {
      param.BID = this.props.BID
    }
    param.LText = Utils.formatOptions(script)
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证
      param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true)
    }
    Api.genericInterface(param).then((res) => {
      if (res.status) {
        this.execSuccess({ErrCode: 'S', ErrMesg: '导出成功!'})
      } else {
        this.execError(res)
      }
    }, () => {
      this.updateStatus('over')
    })
  }
  /**
   * @description 获取用户自定义存储过程传参
   */
  getExcelCustomParam = (orderBy, search, pagination = false, pageIndex = 1, pageSize = 100) => {
src/tabviews/zshare/fileupload/index.jsx
@@ -157,7 +157,10 @@
      spark.append(e.target.result)
      params.file.fileMd5 = spark.end() // 计算整个文件的fileMd5
      Api.getFilePreUpload({fileMd5: params.file.fileMd5}).then(res => {
      let _param = new FormData()
      _param.append('fileMd5', params.file.fileMd5)
      Api.getFilePreUpload(_param).then(res => {
        if (res.status && res.urlPath) {
          this.onUpdate(res.urlPath)
          this.setState({
src/tabviews/zshare/mutilform/index.jsx
@@ -137,9 +137,9 @@
      let newval = ''
      if (item.type === 'linkMain' && BData && BData.hasOwnProperty(item.field)) {
        newval = BData[item.field]
      } else if (item.type !== 'linkMain' && _readin && !/^date/.test(item.type) && this.props.data && this.props.data.hasOwnProperty(item.field)) {
      if (item.type === 'linkMain') {
        newval = BData && BData[item.field] ? BData[item.field] : ''
      } else if (_readin && !/^date/.test(item.type) && this.props.data && this.props.data.hasOwnProperty(item.field)) {
        newval = this.props.data[item.field]
      } else if (item.type === 'date') { // 时间搜索
        if (_readin && this.props.data && this.props.data.hasOwnProperty(item.field)) {
src/templates/menuconfig/editsecmenu/index.scss
@@ -1,4 +1,6 @@
.second-edit-box {
  position: relative;
  z-index: 1060;
  .mask {
    position: fixed;
    top: 0px;
src/templates/menuconfig/editthdmenu/index.scss
@@ -1,4 +1,6 @@
.third-edit-box {
  position: relative;
  z-index: 1060;
  .mask {
    position: fixed;
    top: 0px;
src/templates/sharecomponent/actioncomponent/index.jsx
@@ -606,7 +606,6 @@
    
    this.verifyRef.handleConfirm().then(res => {
      let _actionlist = fromJS(this.state.actionlist).toJS()
      _actionlist = _actionlist.filter(item => !item.origin || item.uuid === card.uuid)
      _actionlist = _actionlist.map(item => {
@@ -949,6 +948,7 @@
            <VerifyExcelOut
              card={card}
              dict={dict}
              config={config}
              wrappedComponentRef={(inst) => this.verifyRef = inst}
            /> : null
          }
src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx
@@ -1,22 +1,28 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Tabs, Row, Col, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber } from 'antd'
import { fromJS } from 'immutable'
import { Form, Tabs, Row, Col, Button, Table, Popconfirm, Icon, notification, Modal, message, InputNumber, Radio, Input } from 'antd'
import moment from 'moment'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import ColumnForm from './columnform'
import './index.scss'
const { TabPane } = Tabs
const { TextArea } = Input
class VerifyCard extends Component {
  static propTpyes = {
    dict: PropTypes.object,    // 字典项
    config: PropTypes.object,
    card: PropTypes.object,
  }
  state = {
    verify: {},
    defaultscript: '', // 自定义脚本
    excelColumns: [
      {
        title: this.props.dict['model.form.field'],
@@ -65,21 +71,84 @@
  }
  UNSAFE_componentWillMount() {
    let _verify = this.props.card.verify || {}
    const { config, card } = this.props
    let _verify = {}
    let _columns = _verify.columns || []
    _columns = _columns.map(col => {
    if (card.verify) {
      _verify = fromJS(card.verify).toJS()
    }
    _verify.enable = _verify.enable || 'false'
    _verify.columns = _verify.columns || []
    _verify.columns = _verify.columns.map(col => {
      col.Width = col.Width || 20
      return col
    })
    this.setState({
      verify: {
        ..._verify,
        columns: _columns,
    if (card.intertype !== 'inner' || card.innerFunc) {
      _verify.enable = 'false'
      }
    let defaultscript = ''
    if (!_verify.script && card.intertype === 'inner' && !card.innerFunc) {
      let search = this.formatSearch(config.search)
      search = Utils.joinMainSearchkey(search)
      search = search ? 'where ' + search : ''
      defaultscript = `update ${config.setting.tableName || ''} set idefine5= idefine5+1 ,modifydate=getdate(),cdefine5='已导出',modifyuserid=@userid@ ${search}`
    }
    this.setState({
      verify: _verify,
      defaultscript: defaultscript
    })
  }
  /**
   * @description 获取全部搜索条件
   * @param {Array} searches 搜索条件数组
   */
  formatSearch (searches) {
    if (!searches || searches.length === 0) return []
    let newsearches = []
    searches.forEach(search => {
      let item = {
        key: search.field,
        match: search.match,
        type: search.type,
        label: search.label,
        value: `@${search.field}@`,
        required: search.required === 'true'
      }
      if (item.type === 'group') {
        let copy = fromJS(item).toJS()
        copy.key = search.datefield
        item.value = `@${search.field}@`
        item.match = '='
        copy.type = 'daterange'
        copy.match = 'between'
        copy.value = [`@${search.datefield}@`, `@${search.datefield}1@`]
        if (search.transfer === 'true') {
          newsearches.push(item)
        }
        newsearches.push(copy)
        return
      } else if (item.type === 'dateweek') {
        item.value = [`@${search.field}@`, `@${search.field}1@`]
      } else if (item.type === 'daterange') {
        item.value = [`@${search.field}@`, `@${search.field}1@`]
      } else if (item.type === 'multiselect') {
        item.value = [`@${search.field}@`]
      }
      newsearches.push(item)
    })
    return newsearches
  }
  columnChange = (values) => {
@@ -198,7 +267,7 @@
  }
  handleConfirm = () => {
    let verify = JSON.parse(JSON.stringify(this.state.verify))
    let verify = fromJS(this.state.verify).toJS()
    
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
@@ -215,12 +284,99 @@
        return
      }
      if (verify.enable === 'true') {
        this.props.form.validateFieldsAndScroll((err, values) => {
          if (!err) {
            values.sql = values.sql || ''
            let _quot = values.sql.match(/'{1}/g)
            let _lparen = values.sql.match(/\({1}/g)
            let _rparen = values.sql.match(/\){1}/g)
            _quot = _quot ? _quot.length : 0
            _lparen = _lparen ? _lparen.length : 0
            _rparen = _rparen ? _rparen.length : 0
            if (_quot % 2 !== 0) {
              notification.warning({
                top: 92,
                message: 'sql中\'必须成对出现',
                duration: 5
              })
              return
            } else if (_lparen !== _rparen) {
              notification.warning({
                top: 92,
                message: 'sql中()必须成对出现',
                duration: 5
              })
              return
            } else if (/--/ig.test(values.sql)) {
              notification.warning({
                top: 92,
                message: '自定义sql语句中,不可出现字符 -- ,注释请用 /*内容*/',
                duration: 5
              })
              return
            }
            let error = Utils.verifySql(values.sql, 'customscript')
            if (error) {
              notification.warning({
                top: 92,
                message: 'sql中不可使用' + error,
                duration: 5
              })
              return
            }
            let param = {
              func: 's_debug_sql',
              LText: values.sql
            }
            param.LText = param.LText.replace(/@\$|\$@/ig, '')
            param.LText = Utils.formatOptions(param.LText)
            param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
            param.secretkey = Utils.encrypt(param.LText, param.timestamp)
            Api.getLocalConfig(param).then(res => {
              if (res.status) {
                resolve({...verify, script: values.sql})
              } else {
                Modal.error({
                  title: res.message
                })
              }
            })
          } else {
            notification.warning({
              top: 92,
              message: '自定义脚本不可为空!',
              duration: 5
            })
          }
        })
      } else {
      resolve(verify)
      }
    })
  }
  changeEnable = (e) => {
    const { verify } = this.state
    this.setState({
      verify: {...verify, enable: e.target.value}
    })
  }
  render() {
    const { verify, excelColumns } = this.state
    const { card } = this.props
    const { verify, excelColumns, defaultscript } = this.state
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -250,6 +406,33 @@
              pagination={false}
            />
          </TabPane>
          {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="自定义脚本" key="6">
            <Form {...formItemLayout} className="verify-form">
              <Row gutter={24}>
                <Col span={8}>
                  <Form.Item style={{marginBottom: 10}} label={'启用'}>
                    <Radio.Group defaultValue={verify.enable || 'false'} onChange={this.changeEnable}>
                      <Radio value="true">是</Radio>
                      <Radio value="false">否</Radio>
                    </Radio.Group>
                  </Form.Item>
                </Col>
                <Col span={24} className="sql">
                  <Form.Item label={'sql'}>
                    {getFieldDecorator('sql', {
                      initialValue: verify.script || defaultscript,
                      rules: [
                        {
                          required: true,
                          message: this.props.dict['form.required.input'] + 'sql!'
                        }
                      ]
                    })(<TextArea rows={15} />)}
                  </Form.Item>
                </Col>
              </Row>
            </Form>
          </TabPane> : null}
          <TabPane tab="信息提示" key="7">
            <Form {...formItemLayout}>
              <Row gutter={24}>
src/templates/sharecomponent/settingcomponent/settingform/index.jsx
@@ -421,6 +421,10 @@
    }
  }
  /**
   * @description 获取全部搜索条件
   * @param {Array} searches 搜索条件数组
   */
  formatSearch (searches) {
    if (!searches || searches.length === 0) return []