king
2019-12-14 2b84af9bed8f4b7da94a4bb85e7223d3b18e4fcb
2019-12-14
5个文件已修改
129 ■■■■■ 已修改文件
src/templates/comtableconfig/index.jsx 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/settingform/index.jsx 57 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/settingform/index.scss 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/source.jsx 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils.js 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/index.jsx
@@ -1085,11 +1085,13 @@
              }
              let _param = {
                funcName: btn.innerFunc,
                name: _config.setting.tableName || '',
                fields: fields
                fields: fields,
                menuNo: this.props.menu.MenuNo
              }
              LText = Utils.formatOptions(Utils.getfunc(_param))
              DelText = Utils.formatOptions(Utils.dropfunc(_param.name))
              DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName))
              resolve(true)
            } else {
              resolve(false)
@@ -1102,11 +1104,13 @@
          })
        } else {
          let _param = {
            funcName: btn.innerFunc,
            name: _config.setting.tableName || '',
            fields: ''
            fields: '',
            menuNo: this.props.menu.MenuNo
          }
          LText = Utils.formatOptions(Utils.getfunc(_param))
          DelText = Utils.formatOptions(Utils.dropfunc(_param.name))
          DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName))
          resolve(true)
        }
      }).then(res => {
@@ -1193,25 +1197,8 @@
        }
        _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
        _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
        return Api.getSystemConfig(_param)
      }).then(res => {
        console.log(res)
        if (res === false) return res
        if (!res.status) {
          notification.warning({
            top: 92,
            message: res.message,
            duration: 10
          })
          return false
        } else {
          notification.success({
            top: 92,
            message: '创建成功',
            duration: 5
          })
        }
        return Api.getSystemConfig(_param)
      }).then(res => {
        console.log(res)
        if (res === false) return res
@@ -1237,9 +1224,9 @@
        let isupdate = false
        _config.action = _config.action.map(item => {
          if (item.uuid === res.values.uuid) {
          if (item.uuid === btn.uuid) {
            isupdate = true
            return res.values
            return btn
          } else {
            return item
          }
@@ -1248,7 +1235,7 @@
        if (!isupdate) { // 操作不是修改,添加元素至列表
          _config.action.push(res.values)
          _config.action.push(btn)
        }
        let gridbtn = _config.action.filter(act => act.position === 'grid')
@@ -1449,6 +1436,7 @@
    const { config } = this.state
    new Promise(resolve => {
      // 内部请求
      if (param.LText) {
      Api.getSystemConfig(param).then(response => {
        if (response.status) {
          resolve('true')
@@ -1456,6 +1444,9 @@
          resolve(response)
        }
      })
      } else {
        resolve('true')
      }
    }).then(res => {
      console.log(res)
      if (res === 'true' && this.state.delActions.length > 0) {
src/templates/comtableconfig/settingform/index.jsx
@@ -1,6 +1,6 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon } from 'antd'
import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification } from 'antd'
import './index.scss'
const { TextArea } = Input
@@ -21,7 +21,16 @@
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          if (values.interType === 'inner' && !values.innerFunc && !values.dataresource) {
            notification.warning({
              top: 92,
              message: '请自定义函数或填写数据源!',
              duration: 10
            })
          } else {
          resolve(values)
          }
        } else {
          reject(err)
        }
@@ -30,12 +39,15 @@
  }
  onChange = (e) => {
    console.log(e.target.value)
    this.setState({
      interType: e.target.value
    })
  }
  render() {
    const { data, dict } = this.props
    const { getFieldDecorator } = this.props.form
    const { interType } = this.state
    const formItemLayout = {
      labelCol: {
@@ -66,7 +78,7 @@
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.input'] + '表名!'
                    message: dict['form.required.input'] + '表名!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" />)}
@@ -88,27 +100,47 @@
            </Form.Item>
          </Col>
          <Col span={12}>
            <Form.Item label="接口类型">
            <Form.Item label={dict['header.form.intertype']}>
              {getFieldDecorator('interType', {
                initialValue: data.interType || 'inner'
              })(
                <Radio.Group onChange={this.onChange}>
                  <Radio value="inner">内部</Radio>
                  <Radio value="outer">外部</Radio>
                  <Radio value="inner">{dict['header.form.interface.inner']}</Radio>
                  <Radio value="outer">{dict['header.form.interface.outer']}</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          <Col span={12}>
            <Form.Item label="内部函数">
          {interType === 'outer' ? <Col span={12}>
            <Form.Item label={dict['header.form.interface']}>
              {getFieldDecorator('interface', {
                initialValue: data.interface || '',
                rules: [
                  {
                    required: true,
                    message: dict['form.required.input'] + dict['header.form.interface'] + '!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col> : null}
          {interType === 'outer' ? <Col span={12}>
            <Form.Item label={dict['header.form.outerFunc']}>
              {getFieldDecorator('outerFunc', {
                initialValue: data.outerFunc || ''
              })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col> : null}
          {interType !== 'outer' ? <Col span={12}>
            <Form.Item label={dict['header.form.innerFunc']}>
              {getFieldDecorator('innerFunc', {
                initialValue: data.innerFunc || ''
              })(<Input placeholder="" autoComplete="off" />)}
            </Form.Item>
          </Col>
          </Col> : null}
          <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="">
              <Tooltip placement="topLeft" title="使用系统函数时,需填写数据源,自定义函数时,可忽略。">
                <Icon type="question-circle" />
                {'数据源'}
              </Tooltip>
@@ -145,12 +177,15 @@
          <Col span={12}>
            <Form.Item label="主键">
              {getFieldDecorator('primaryKey', {
                initialValue: primaryKey
                initialValue: primaryKey ? primaryKey : (this.props.columns.length === 0 ? 'ID' : '')
              })(
                <Select
                  getPopupContainer={() => document.getElementById('commontable-setting-form')}
                >
                  <Select.Option value="">不设置</Select.Option>
                  {this.props.columns.length === 0 ?
                    <Select.Option value="ID">ID</Select.Option> : null
                  }
                  {this.props.columns.map(option =>
                    <Select.Option id={option.uuid} title={option.label} key={option.uuid} value={option.field}>{option.label}</Select.Option>
                  )}
src/templates/comtableconfig/settingform/index.scss
@@ -7,4 +7,8 @@
      width: 83.33333333%;
    }
  }
  .anticon-question-circle {
    color: #c49f47;
    margin-right: 3px;
  }
}
src/templates/comtableconfig/source.jsx
@@ -17,7 +17,9 @@
      order: '',
      dataresource: '',
      interType: 'inner',
      innerFunc: ''
      innerFunc: '',
      interface: '',
      outerFunc: ''
    },
    tables: [],
    search: [
src/utils/utils.js
@@ -330,10 +330,22 @@
   */
  static getfunc (param) {
    let form = ''
    let formParam = ''
    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 is null'
          } else if (item.type === 'number') {
            type = `decimal(18,${item.decimal})=0`
          } else {
            type = 'nvarchar(50)=\'\''
          }
          formParam = formParam + `mchr13k@${item.field} ${type},`
          _fields.push(item.field)
        }
      })
@@ -348,18 +360,17 @@
      field3 = field3.join(',')
      form = `
        insert into ${param.name} (${field1}) select ${field2},@UserID
        insert into ${param.name} (${field1},createuserid) select ${field2},@UserID
        
        update ${param.name} set ${field3},modifydate=getdate(),modifyuserid=@UserID
      `
    }
    let Ltext = `create proc ${param.name}
    let Ltext = `create proc ${param.funcName}
    (
    @BID nvarchar(50)='',
    @ID nvarchar(50)='',
    表单传值,文本用nvarchar(50)='',日期用datetime is null ,数值用decimal(18,小数点位数)=0,
    @sEPTMenuNo='', --传菜单参数
    @ID nvarchar(50)='',${formParam}
    @sEPTMenuNo nvarchar(50)='${param.menuNo}',
    @lang nvarchar(50)='',
    @debug nvarchar(50)='',
    @LoginUID nvarchar(50)='',
@@ -425,8 +436,8 @@
      ROLLBACK TRAN
      
    END`
    Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k')
    console.log(Ltext)
    Ltext = Ltext.replace(/\n\s{4}/ig, 'mchr13k')
    return Ltext
  }
}