king
2021-09-29 7acac704eadabff7bab8f640f6035935f57e5381
2021-09-29
7个文件已修改
4个文件已添加
364 ■■■■ 已修改文件
src/assets/css/viewstyle.scss 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/baseScript/index.jsx 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/baseScript/index.scss 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/baseScript/settingform/index.jsx 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/baseScript/settingform/index.scss 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/replaceField/settingform/index.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/urlfieldcomponent/settingform/index.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/printbutton/index.jsx 196 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/mutilform/mkSelect/index.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/menudesign/index.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/menudesign/index.scss 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/css/viewstyle.scss
@@ -201,11 +201,11 @@
    .card-row-list {
      >.active >.card-item-box {
        border-color: $color6!important;
        box-shadow: 0 0 4px $color6;
        box-shadow: 0 0 4px $color6!important;
      }
      >.selected >.card-item-box {
        border-color: $color4!important;
        box-shadow: 0 0 4px $color4;
        box-shadow: 0 0 4px $color4!important;
      }
    }
  }
src/menu/baseScript/index.jsx
New file
@@ -0,0 +1,75 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Modal, Button, notification } from 'antd'
import SettingForm from './settingform'
import './index.scss'
class BaseScript extends Component {
  static propTpyes = {
    config: PropTypes.object,
    updateConfig: PropTypes.func
  }
  state = {
    visible: false,
    baseSql: null
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
  trigger = () => {
    const { config } = this.props
    this.setState({
      baseSql: config.baseSql || {enable: true, sql: ''},
      visible: true
    })
  }
  submit = () => {
    let config = fromJS(this.props.config).toJS()
    this.settingRef.handleConfirm().then(res => {
      if (res.enable && (!res.sql || /^\s+$/ig.test(res.sql))) {
        notification.warning({
          top: 92,
          message: '启用基础SQL时,请完善sql语句。',
          duration: 5
        })
        return
      }
      config.baseSql = res
      this.props.updateConfig(config)
      this.setState({ visible: false })
    })
  }
  render() {
    const { visible, baseSql } = this.state
    return (
      <div style={{display: 'inline-block'}}>
        <Button className="mk-border-danger" icon="database" onClick={this.trigger}>基础SQL</Button>
        <Modal
          title="基础SQL"
          wrapClassName="base-script-modal"
          visible={visible}
          width={800}
          maskClosable={false}
          onOk={this.submit}
          onCancel={() => { this.setState({ visible: false })}}
          destroyOnClose
        >
          <SettingForm baseSql={baseSql} wrappedComponentRef={(inst) => this.settingRef = inst}/>
        </Modal>
      </div>
    )
  }
}
export default BaseScript
src/menu/baseScript/index.scss
New file
@@ -0,0 +1,9 @@
.base-script-modal {
  .ant-modal {
    top: 70px;
  }
  .ant-modal-body {
    min-height: 150px;
    // padding-top: 40px;
  }
}
src/menu/baseScript/settingform/index.jsx
New file
@@ -0,0 +1,69 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Switch } from 'antd'
import CodeMirror from '@/templates/zshare/codemirror'
// import './index.scss'
class SettingForm extends Component {
  static propTpyes = {
    baseSql: PropTypes.object
  }
  state = {
    enable: this.props.baseSql.enable
  }
  handleConfirm = () => {
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          values.enable = this.state.enable
          resolve(values)
        } else {
          reject(err)
        }
      })
    })
  }
  render() {
    const { baseSql } = this.props
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 3 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 21 }
      }
    }
    return (
      <Form {...formItemLayout}>
        <Row gutter={24}>
          <Col span={24}>
            <Form.Item label="是否启用">
              <Switch defaultChecked={baseSql.enable} onChange={(val) => {this.setState({enable: val})}} checkedChildren="是" unCheckedChildren="否" />
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label="SQL">
              {getFieldDecorator('sql', {
                initialValue: baseSql.sql || ''
              })(
                <CodeMirror />
              )}
            </Form.Item>
          </Col>
        </Row>
      </Form>
    )
  }
}
export default Form.create()(SettingForm)
src/menu/baseScript/settingform/index.scss
src/menu/replaceField/settingform/index.jsx
@@ -2,7 +2,7 @@
import PropTypes from 'prop-types'
import { Form, Row, Col, Tooltip, Icon, Select } from 'antd'
import './index.scss'
// import './index.scss'
class SettingForm extends Component {
  static propTpyes = {
src/menu/urlfieldcomponent/settingform/index.jsx
@@ -2,7 +2,7 @@
import PropTypes from 'prop-types'
import { Form, Input } from 'antd'
import './index.scss'
// import './index.scss'
class SettingForm extends Component {
  static propTpyes = {
src/tabviews/zshare/actionList/printbutton/index.jsx
@@ -364,8 +364,8 @@
    try {
      // eslint-disable-next-line
      let func = new Function('data', 'form', 'printer', 'notification', btn.verify.printFunc)
      func(printlist, formdata, btn.verify, notification)
      let func = new Function('data', 'form', 'printer', 'notification', 'Api', 'systemType', btn.verify.printFunc)
      func(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType)
      // 自定义打印示例
      // let defaultPrinter = printer.defaultPrinter || 'lackprinter'
@@ -376,8 +376,7 @@
      //   for (let i = 0; i < 32; i++) {
      //     uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1))
      //   }
      //   uuid = uuid.join('')
      //   return uuid
      //   return uuid.join('')
      // }
      // if (printer.printerTypeList && printer.printerTypeList.length > 0) {
      //   printer.printerTypeList.forEach(cell => {
@@ -387,29 +386,43 @@
      //   })
      // }
      // let jdList = []
      // let otherList = []
      // data.forEach(item => {
      //   if (item.CustomData) {
      //     item.CustomData = JSON.parse(item.CustomData.replace(/\n/g,"\\n").replace(/\r/g,"\\r"))
      //   }
      //   if (item.PrintData) {
      //     item.PrintData = JSON.parse(item.PrintData.replace(/\n/g,"\\n").replace(/\r/g,"\\r"))
      //     item.PrintData.data = {...form, ...item.PrintData.data}
      //   }
      // let jdList = [];
      // let jdNewList = [];
      // let otherList = [];
      // let _map = new Map()
      // data.forEach(m => {
      //   if (!m.print_data || m.print_data.length === 0) return
        
      //   if (!item.PrintData) {
      //     return
      //   }
      //   m.print_data.forEach(n => {
      //     if (n.InsideBill) {
      //       if (_map.has(n.InsideBill)) {
      //         return
      //       }
      //       _map.set(n.InsideBill, true)
      //     }
      //     if (n.CustomData) {
      //       n.CustomData = JSON.parse(n.CustomData.replace(/\n/g,"\\n").replace(/\r/g,"\\r"))
      //     }
      //   if (item.PrintData.ectype === 'jdpop') {
      //     jdList.push(item)
      //   } else {
      //     otherList.push(item)
      //   }
      //     if (n.hasOwnProperty('StdTemplate')) {
      //       jdNewList.push(n);
      //       return
      //     } else if (!n.PrintData) {
      //       return
      //     }
      //     n.PrintData = JSON.parse(n.PrintData.replace(/\n/g,"\\n").replace(/\r/g,"\\r"))
      //     n.PrintData.data = {...form, ...n.PrintData.data}
      //     if (n.PrintData.ectype === 'jdpop') {
      //       jdList.push(n)
      //     } else {
      //       otherList.push(n)
      //     }
      //   })
      // })
      // if (jdList.length === 0 && otherList.length === 0) {
      // if (jdList.length === 0 && otherList.length === 0 && jdNewList.length === 0) {
      //   notification.warning({
      //     top: 92,
      //     message: '无打印数据!',
@@ -418,79 +431,88 @@
      //   return
      // }
      // let execPrint = (list, linkUrl) => {
      //   let printdata = {}
      // let execPrint = (list, linkUrl, type) => {
      //   let printdata = {};
      //   let printerList = [];
      //   list.forEach(res => {
      //     let _printer = defaultPrinter
      //   if (type === 'jd') {
      //     printerList = list.map(m => {
      //       let _printer = defaultPrinter;
      //     if (res.printType && printers[res.printType]) {
      //       _printer = printers[res.printType]
      //     }
      //     printdata[_printer] = printdata[_printer] || []
      //     printdata[_printer].push(res)
      //   })
      //   let printerList = []
      //   Object.keys(printdata).forEach(printer => {
      //     let _documents = []
      //     printdata[printer].forEach(item => {
      //       let _cell = {
      //         documentID: getuuid(),
      //         contents: []
      //       if (m.printType && printers[m.printType]) {
      //         _printer = printers[m.printType];
      //       }
      //       if (item.PrintData) {
      //         _cell.contents.push(item.PrintData)
      //       return {
      //         orderType: "print",
      //         parameters: {
      //           printName: _printer === 'lackprinter' ? '' : _printer,
      //           tempUrl: m.StdTemplate,
      //           customTempUrl: m.CusTemplate,
      //           customData: [m.CustomData],
      //           printData: [m.PrintData]
      //         }
      //       }
      //       if (item.CustomData) {
      //         _cell.contents.push(item.CustomData)
      //     })
      //   } else {
      //     list.forEach(res => {
      //       let _printer = defaultPrinter
      //       if (res.printType && printers[res.printType]) {
      //         _printer = printers[res.printType]
      //       }
      //       for (let i = 0; i < item.printCount; i++) {
      //       printdata[_printer] = printdata[_printer] || []
      //       printdata[_printer].push(res)
      //     })
      //     Object.keys(printdata).forEach(printer => {
      //       let _documents = []
      //       printdata[printer].forEach(item => {
      //         let _cell = {
      //           documentID: getuuid(),
      //           contents: []
      //         }
      //         if (item.PrintData) {
      //           _cell.contents.push(item.PrintData)
      //         }
      //         if (item.CustomData) {
      //           _cell.contents.push(item.CustomData)
      //         }
      //         _documents.push(_cell)
      //       }
      //       })
      //       printerList.push({
      //         cmd: 'print',
      //         requestID: '',
      //         version: '',
      //         task: {
      //           taskID: getuuid(),
      //           preview: false,
      //           printer: printer === 'lackprinter' ? '' : printer,
      //           documents: _documents
      //         }
      //       })
      //     })
      //     printerList.push({
      //       cmd: 'print',
      //       requestID: '',
      //       version: '',
      //       task: {
      //         taskID: getuuid(),
      //         preview: false,
      //         printer: printer,
      //         documents: _documents
      //       }
      //     })
      //   })
      //   let lackItems = printerList.filter(cell => cell.task.printer === 'lackprinter')[0]
      //   }
      //   let socket = new WebSocket('ws://' + linkUrl)
      //   // 打开Socket
      //   socket.onopen = () =>{
      //     if (lackItems) {
      //       let request  = {
      //         requestID: '',
      //         version: '',
      //         cmd: 'getPrinters'
      //       }
      //       socket.send(JSON.stringify(request))
      //     } else {
      //       printerList.forEach(cell => {
      //         socket.send(JSON.stringify(cell).replace(/\\r/g,"\r").replace(/\\n/g,"\n"))
      //       })
      //       printerList.forEach((cell, i) => {
      //         setTimeout(() => {
      //           socket.send(JSON.stringify(cell).replace(/\\r/g,"\r").replace(/\\n/g,"\n"))
      //       }, 1000 * i)
      //       });
      //       notification.success({
      //         top: 92,
      //         message: '打印请求已发出。',
      //         duration: 2
      //       })
      //     }
      //   }
      //   // 监听消息
      //   socket.onmessage = (event) => {
@@ -509,20 +531,7 @@
      //       }
      //     }
      //     if (data && data.cmd === 'getPrinters' && data.status) {
      //       printerList.forEach(cell => {
      //         if (cell.task.printer === 'lackprinter') {
      //           cell.task.printer = data.defaultPrinter
      //         }
      //         socket.send(JSON.stringify(cell).replace(/\\r/g,"\r").replace(/\\n/g,"\n"))
      //       })
      //       notification.success({
      //         top: 92,
      //         message: '打印请求已发出。',
      //         duration: 2
      //       })
      //     } else if (data && data.message && !data.status) {
      //     if (data && data.message && !data.status) {
      //       notification.warning({
      //         top: 92,
      //         message: data.message,
@@ -540,6 +549,9 @@
      //   }
      // }
      // if (jdNewList.length > 0) {
      //   execPrint(jdNewList, '127.0.0.1:9113', 'jd');
      // }
      // if (jdList.length > 0) {
      //   execPrint(jdList, '127.0.0.1:13529')
      // }
@@ -551,8 +563,8 @@
      try {
        // eslint-disable-next-line
        let evalfunc = eval('(true && function (data, form, printer, notification) {' + btn.verify.printFunc + '})')
        evalfunc(printlist, formdata, btn.verify, notification)
        let evalfunc = eval('(true && function (data, form, printer, notification, Api, systemType) {' + btn.verify.printFunc + '})')
        evalfunc(printlist, formdata, btn.verify, notification, Api, window.GLOB.systemType)
      } catch (error) {
        console.warn(error)
        notification.warning({
src/tabviews/zshare/mutilform/mkSelect/index.jsx
@@ -78,7 +78,7 @@
    const { config } = this.state
    let options = config.oriOptions.filter(option => option.ParentID === parentId || option.value === '')
    let _option = options[0] || null
    let _option = options[0] && !options[0].$disabled ? options[0] : null
    let val = _option ? _option.value : ''
    this.setState({
src/views/menudesign/index.jsx
@@ -36,6 +36,7 @@
const PaddingController = asyncComponent(() => import('@/menu/padcontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
// const BaseScript = asyncComponent(() => import('@/menu/baseScript'))
const Versions = asyncComponent(() => import('@/menu/versions'))
const SysInterface = asyncComponent(() => import('@/menu/sysinterface'))
const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent'))
@@ -987,6 +988,7 @@
                  <div> {config && config.MenuName} </div>
                } bordered={false} extra={
                  <div>
                    {/* <BaseScript config={config} updateConfig={this.updateConfig}/> */}
                    <Versions MenuId={MenuId} open_edition={config ? config.open_edition : ''}/>
                    <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/>
                    <SysInterface config={config} updateConfig={this.updateConfig}/>
src/views/menudesign/index.scss
@@ -119,6 +119,9 @@
            button {
              margin-left: 10px;
            }
            >div >div >button, .style-control-button {
              padding: 0px 7px;
            }
            .ant-switch.big {
              min-width: 60px;
              height: 28px;