king
2020-03-21 4a18149d7ca9a0ea3ad569297f34e928c59e2025
2020-03-21
1 文件已重命名
9个文件已修改
1个文件已删除
269 ■■■■ 已修改文件
package-lock.json 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/tabmanage/config.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/index.jsx 115 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/modalconfig/index.jsx 22 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/modalconfig/source.jsx 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/formconfig.jsx 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/verifycardprint/index.jsx 73 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/zshare/verifycardprint/index.scss 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/printTemplate/index.jsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/printTemplate/option.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package-lock.json
@@ -3548,6 +3548,11 @@
      "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
      "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
    },
    "codemirror": {
      "version": "5.52.2",
      "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.52.2.tgz",
      "integrity": "sha512-WCGCixNUck2HGvY8/ZNI1jYfxPG5cRHv0VjmWuNzbtCLz8qYA5d+je4QhSSCtCaagyeOwMi/HmmPTjBgiTm2lQ=="
    },
    "codepage": {
      "version": "1.14.0",
      "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.14.0.tgz",
@@ -13393,6 +13398,11 @@
        }
      }
    },
    "react-codemirror2": {
      "version": "7.1.0",
      "resolved": "https://registry.npmjs.org/react-codemirror2/-/react-codemirror2-7.1.0.tgz",
      "integrity": "sha512-Rel0QbPnCTjHxgZYt6TkGw4icSZXNyONHb72a+1wWA+PlYJIvzFAv4pZlDPG0rpKpKmy4kSUlkoWgneH7w3A0g=="
    },
    "react-dev-utils": {
      "version": "9.0.3",
      "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-9.0.3.tgz",
package.json
@@ -17,6 +17,7 @@
    "babel-preset-react-app": "9.0.0",
    "camelcase": "^5.2.0",
    "case-sensitive-paths-webpack-plugin": "2.2.0",
    "codemirror": "^5.52.2",
    "css-loader": "2.1.1",
    "dotenv": "6.2.0",
    "dotenv-expand": "4.2.0",
@@ -57,6 +58,7 @@
    "prop-types": "^15.7.2",
    "react": "^16.9.0",
    "react-app-polyfill": "^1.0.2",
    "react-codemirror2": "^7.1.0",
    "react-dev-utils": "^9.0.3",
    "react-dnd": "^9.4.0",
    "react-dnd-html5-backend": "^9.4.0",
src/tabviews/tabmanage/config.js
File was deleted
src/tabviews/zshare/actionList/index.jsx
@@ -225,7 +225,61 @@
      formdata[_data.key] = _data.value
    })
    if (!btn.verify || !btn.verify.Template || !btn.verify.linkUrl) {
    // btn.verify.printFunc = `
    //   let _data = data[0]
    //   _data = JSON.parse(_data)
    //   let socket = new WebSocket(_data.wsaddr)
    //   // 打开Socket
    //   socket.onopen = () => {
    //     notification.success({
    //       top: 92,
    //       message: '打印请求已发出。',
    //       duration: 2
    //     })
    //     socket.send(JSON.stringify(_data.data))
    //   }
    //   // 监听消息
    //   socket.onmessage = (event) => {
    //     let data = ''
    //     if (event.data) {
    //       try {
    //         data = JSON.parse(event.data)
    //       } catch {
    //         notification.warning({
    //           top: 92,
    //           message: event.data,
    //           duration: 10
    //         })
    //         data = ''
    //       }
    //     }
    //     if (data && data.message && !data.status) {
    //       notification.warning({
    //         top: 92,
    //         message: data.message,
    //         duration: 10
    //       })
    //     }
    //   }
    //   socket.onerror = () => {
    //     notification.warning({
    //       top: 92,
    //       message: '无法连接到:' + _data.wsaddr,
    //       duration: 10
    //     })
    //   }
    // `
    if (
      !btn.verify ||
      (btn.verify.printMode === 'normal' && (!btn.verify.Template || !btn.verify.linkUrl)) ||
      (btn.verify.printMode === 'custom' && !btn.verify.printFunc)
    ) {
      notification.warning({
        top: 92,
        message: '请完善打印验证信息!',
@@ -235,7 +289,7 @@
    }
    let printlist = []
    let templates = [btn.verify.Template]
    let templates = [btn.verify.Template || '']
    let printCount = 1
    if (formdata.printCount && typeof(formdata.printCount) === 'number' && formdata.printCount >= 1) {
@@ -263,9 +317,15 @@
            }
          })
        }
        if (btn.verify.printMode === 'custom') {
          this.execCustomPrint(btn, printlist)
        } else {
        resolve('getTemp')
        }
      } else {
        this.getprintdata(btn, data, formdata, formlist).then(result => {
          if (result.next === 'getTemp') {
          result.list.forEach(item => {
            let _cell = item.data
@@ -285,12 +345,17 @@
              printlist.push({...formdata, ..._cell})
            }
          })
          } else if (result.next === 'customPrint') {
            this.execCustomPrint(btn, result.list)
          }
          
          resolve(result.next)
        })
      }
    }).then(res => {
      // 获取打印模板 getTemp
      if (!res) return
      if (res !== 'getTemp') return false
      templates = Array.from(new Set(templates)) // 去重
@@ -345,6 +410,18 @@
        this.execError(errorMsg, btn)
      }
    })
  }
  execCustomPrint = (btn, printdata) => {
    this.setState({loadingUuid: ''})
    try {
      // eslint-disable-next-line
      let func = new Function('data', 'notification', btn.verify.printFunc)  // 最后一个参数当函数体来执行,前面的参数当成函数体的参数。
      func(printdata, notification)
    } catch (e) {
      console.warn(e)
    }
  }
  getprintdata = (btn, data, formdata, formlist) => {
@@ -411,15 +488,20 @@
            let errorMsg = ''
            result.forEach(res => {
              if (res.status) {
                if (btn.verify.printMode === 'custom') {
                  // _list.push(res.data)
                  _list.push('{"status": true,"message": "","ErrCode": "","ErrMesg": "", "wsaddr": "ws://127.0.0.1:13529","wstype": "local/server","data": [{"cmd": "print","requestID": "202003091036391803ACEAAE08DF7454599AEA243D8959F","version": "1.0","task": {"taskID": "202003091036391803ACEAAE08DF7454599AEA243D8959F","preview": false,"printer": "Microsoft Print To PDF", "documents": [{"documentID": "05512003090002A243D8959F","contents": [{"data": {"Bill": "05512003090002","ReturnProduct": ""},"templateURL": "http://css.positecgroup.com/template/warespaceprint01/2020010810525789956968_U000000001.srt","ectype": "jdpop"}]}]}}    ]}')
                } else {
                res.data.forEach(_item => {
                  _list.push({data: _item, count: res.printCount})
                })
                }
              } else {
                errorMsg = res
              }
            })
            if (!errorMsg) {
              resolve({next: 'getTemp', list: _list})
              resolve({next: btn.verify.printMode === 'custom' ? 'customPrint' : 'getTemp', list: _list})
            } else {
              this.execError(errorMsg, btn)
              resolve({next: false, list: _list})
@@ -507,13 +589,17 @@
        return Api.genericInterface(_callbackparam)
      } else if (response.status) {
        if (btn.verify.printMode === 'custom') {
          _list.push(response.data)
        } else {
        response.data.forEach(_item => {
          _list.push({data: _item, count: response.printCount})
        })
        }
        // 一次请求成功,进行下一项请求
        if (params.length === 0) {
          _resolve({next: 'getTemp', list: _list})
          _resolve({next: btn.verify.printMode === 'custom' ? 'customPrint' : 'getTemp', list: _list})
        } else {
          this.printOuterLoopRequest(params, btn, _list, _resolve)
        }
@@ -525,13 +611,17 @@
      if (!response) return
      if (response.status) {
        if (btn.verify.printMode === 'custom') {
          _list.push(response.data)
        } else {
        response.data.forEach(_item => {
          _list.push({data: _item, count: response.printCount})
        })
        }
        // 一次请求成功,进行下一项请求
        if (params.length === 0) {
          _resolve({next: 'getTemp', list: _list})
          _resolve({next: btn.verify.printMode === 'custom' ? 'customPrint' : 'getTemp', list: _list})
        } else {
          this.printOuterLoopRequest(params, btn, _list, _resolve)
        }
@@ -550,12 +640,16 @@
    Api.genericInterface(param).then(res => {
      if (res.status) {
        if (btn.verify.printMode === 'custom') {
          _list.push(res.data)
        } else {
        res.data.forEach(_item => {
          _list.push({data: _item, count: res.printCount})
        })
        }
        if (params.length === 0) {
          _resolve({next: 'getTemp', list: _list})
          _resolve({next: btn.verify.printMode === 'custom' ? 'customPrint' : 'getTemp', list: _list})
        } else {
          this.printInnerLoopRequest(params, btn, _list, _resolve)
        }
@@ -1353,15 +1447,6 @@
      })
    } else if (res && res.ErrCode === '-1') { // 完成后不提示
    // } else if (res.Relogin === 'true') { // 切换用户功能
    //   sessionStorage.setItem('avatar', res.icon || '')
    //   sessionStorage.setItem('UserID', res.UserID)
    //   sessionStorage.setItem('SessionUid', Utils.getuuid())
    //   sessionStorage.setItem('LoginUID', res.LoginUID)
    //   sessionStorage.setItem('User_Name', res.UserName)
    //   window.location.reload()
    //   return
    }
    
    if (btn.OpenType === 'pop' && btn.setting && btn.setting.finish !== 'unclose') {
src/templates/modalconfig/index.jsx
@@ -20,7 +20,7 @@
import GroupForm from './groupform'
import EditCard from './editcard'
import MenuForm from './menuform'
import Source from './source'
import { BaseConfig, SearchItems } from './source'
import './index.scss'
const { Panel } = Collapse
@@ -64,7 +64,8 @@
    originConfig: null,    // 原始菜单
    groupVisible: false,   // 全局配置模态框
    curgroup: null,        // 当前组,新建或编辑
    optionLibs: null       // 自定义下拉选项库
    optionLibs: null,      // 自定义下拉选项库
    sources: null          // 表单类型
  }
  /**
@@ -127,7 +128,7 @@
        })
      }
    } else {
      _config = JSON.parse(JSON.stringify((Source.baseConfig)))
      _config = JSON.parse(JSON.stringify(BaseConfig))
    }
    if (!_config.setting.title) {
@@ -137,8 +138,19 @@
    // 主菜单已有选择的表名,模态框没有表名时,复制主菜单表名
    _config.tables = _config.tables.length === 0 ? _menu.tables : _config.tables
    let _source = JSON.parse(JSON.stringify(SearchItems))
    if (!!this.props.editTab) {
      _source.push({
        type: 'form',
        label: this.state.dict['header.form.linkMain'],
        subType: 'linkMain',
        url: ''
      })
    }
    this.setState({
      menu: _menu,
      source: _source,
      optionLibs: optionLibs,
      config: _config,
      selectedTables: _config.tables || [],
@@ -1126,7 +1138,7 @@
  }
  render () {
    const { config } = this.state
    const { config, source } = this.state
    return (
      <div className="modal-form-board">
@@ -1173,7 +1185,7 @@
              </Panel>
              <Panel header={this.state.dict['header.menu.form']} key="1">
                <div className="search-element">
                  {Source.searchItems.map((item, index) => {
                  {source.map((item, index) => {
                    return (<SourceElement key={index} content={item}/>)
                  })}
                </div>
src/templates/modalconfig/source.jsx
@@ -4,8 +4,7 @@
const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS
class CommonTableBaseData {
  baseConfig = {
export const BaseConfig = {
    type: 'Modal',
    setting: {
      title: '',
@@ -72,7 +71,7 @@
    ]
  }
  searchItems = [
export const SearchItems = [
    {
      type: 'form',
      label: CommonDict['header.form.text'],
@@ -140,6 +139,4 @@
      url: ''
    }
  ]
}
export default new CommonTableBaseData()
src/templates/zshare/formconfig.jsx
src/templates/zshare/verifycardprint/index.jsx
@@ -2,9 +2,15 @@
import PropTypes from 'prop-types'
import { Form, Tabs, Row, Col, Button, notification, Modal, message, InputNumber, Input, Select, Radio } from 'antd'
import moment from 'moment'
import {UnControlled as CodeMirror} from 'react-codemirror2'
import 'codemirror/mode/javascript/javascript'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import 'codemirror/lib/codemirror.css'
// import 'codemirror/theme/solarized.css'
import 'codemirror/theme/cobalt.css'
import './index.scss'
@@ -24,6 +30,7 @@
    verify: {},
    templates: [],
    selectimg: '',
    printMode: 'normal'
  }
  UNSAFE_componentWillMount() {
@@ -34,7 +41,9 @@
        ..._verify,
        Template: _verify.Template || ''
      },
      linkType: _verify.linkType || 'system'
      linkType: _verify.linkType || 'system',
      printMode: _verify.printMode || 'normal',
      printFunc: _verify.printFunc || '// Function(data, notification) // data-打印数据列表,notification-信息提示控件',
    })
  }
@@ -167,6 +176,14 @@
    })
  }
  changePrintMode = (e) => {
    let value = e.target.value
    this.setState({
      printMode: value
    })
  }
  changeLinkType = (e) => {
    let value = e.target.value
@@ -184,7 +201,7 @@
  render() {
    const { getFieldDecorator } = this.props.form
    const { verify, linkType } = this.state
    const { verify, linkType, printMode, printFunc } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -203,6 +220,42 @@
            <Form {...formItemLayout}>
              <Row gutter={24}>
                <Col span={8}>
                  <Form.Item label={'打印模式'}>
                    {getFieldDecorator('printMode', {
                      initialValue: printMode || 'normal'
                    })(
                      <Radio.Group onChange={this.changePrintMode}>
                        <Radio value="normal">标准</Radio>
                        <Radio value="custom">自定义</Radio>
                      </Radio.Group>
                    )}
                  </Form.Item>
                </Col>
                {printMode === 'custom' ? <Col span={24}>
                  <Form.Item label={'处理函数'} className="printFunc">
                    {getFieldDecorator('printFunc', {
                      initialValue: printFunc || '',
                      rules: [
                        {
                          required: true,
                          message: this.props.dict['form.required.input'] + '处理函数!'
                        }
                      ]
                    })(
                      <CodeMirror
                        className="code-mirror-area"
                        options={{
                          mode: 'text/javascript',
                          theme: 'cobalt',
                          lineNumbers: true,
                          lineWrapping: true
                        }}
                        onBeforeChange={() => {}}
                      />
                    )}
                  </Form.Item>
                </Col> : null}
                {printMode === 'normal' ? <Col span={8}>
                  <Form.Item label={'链接类型'}>
                    {getFieldDecorator('linkType', {
                      initialValue: linkType || 'system'
@@ -213,8 +266,8 @@
                      </Radio.Group>
                    )}
                  </Form.Item>
                </Col>
                <Col span={8}>
                </Col> : null}
                {printMode === 'normal' ? <Col span={8}>
                  <Form.Item label={'链接地址'}>
                    {getFieldDecorator('linkUrl', {
                      initialValue: verify.linkUrl || '127.0.0.1:13529',
@@ -226,8 +279,8 @@
                      ]
                    })(<Input placeholder="" autoComplete="off" disabled={linkType === 'system'} />)}
                  </Form.Item>
                </Col>
                <Col span={8}>
                </Col> : null }
                {printMode === 'normal' ? <Col span={8}>
                  <Form.Item label={'打印模板'}>
                    {getFieldDecorator('Template', {
                      initialValue: verify.Template || '',
@@ -247,10 +300,10 @@
                      </Select>
                    )}
                  </Form.Item>
                </Col>
                <Col span={9}>
                  <img style={{width: '90%', marginBottom: '25px'}} src={this.state.selectimg} alt=""/>
                </Col>
                </Col> : null }
                {printMode === 'normal' ? <Col span={8} offset={8}>
                  <img className="legend" src={this.state.selectimg} alt=""/>
                </Col> : null }
              </Row>
            </Form>
          </TabPane>
src/templates/zshare/verifycardprint/index.scss
@@ -19,4 +19,22 @@
    padding: 0 5px;
    cursor: pointer;
  }
  .legend {
    width: 100%;
    margin-bottom: 25px;
    margin-left: -2px;
    box-shadow: 0px 0px 2px #bcbcbc;
  }
  .printFunc {
    .ant-form-item-label {
      width: 10.7%;
    }
    .ant-form-item-control-wrapper {
      width: 89.3%;
    }
  }
  .code-mirror-area {
    font-size : 14px;
    line-height : 25px;
  }
}
src/views/printTemplate/index.jsx
@@ -305,6 +305,16 @@
    window.addEventListener('resize', this.handleResize)
    this.loadconfig()
    document.onkeydown = (event) => {
      const { editItemId, editItemType } = this.state
      let e = event || window.event
      let keyCode = e.keyCode || e.which || e.charCode
      if (keyCode === 46 && editItemId && editItemType !== 'Template') {
        this.deleteItem()
      }
    }
  }
  handleResize = () => {
src/views/printTemplate/option.js
@@ -803,6 +803,14 @@
      options: fields
    },
    {
      type: 'text',
      key: 'cusfield',
      label: '自定义',
      initval: item.cusfield || '',
      required: true,
      hidden: true
    },
    {
      type: 'number',
      key: 'left',
      label: '距左',