king
2024-06-17 675de8166eba668c30fd1587a8ffbc11ddc2f919
2024-06-17
6个文件已修改
465 ■■■■■ 已修改文件
src/tabviews/zshare/actionList/newpagebutton/index.jsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/design/header/index.jsx 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/design/header/transmenu/index.jsx 376 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/design/header/transmenu/index.scss 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/menudesign/index.jsx 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/printTemplate/index.jsx 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/zshare/actionList/newpagebutton/index.jsx
@@ -145,12 +145,12 @@
    let Id = ''
    let name = ''
    let MenuNo = ''
    let Remark = ''
    let lang = ''
    if (btn.Ot === 'requiredSgl' && data[0]) {
      Id = data[0].$$uuid || ''
      name = data[0].PrintTempName || ''
      MenuNo = data[0].PrintTempNO || ''
      Remark = data[0].Remark || ''
      lang = data[0].lang_s || ''
    }
    let _name = '新页面'
@@ -228,12 +228,10 @@
        }
      }
    } else if (btn.pageTemplate === 'billprintTemp') {
      let src = '#/menudesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'billPrint', MenuId: Id, MenuNo: MenuNo, MenuName: name || '打印', Remark: Remark })))
      let src = '#/menudesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({ MenuType: 'billPrint', MenuId: Id, MenuNo: MenuNo, MenuName: name || '打印', lang })))
      window.open(src)
    } else if (btn.pageTemplate === 'print') {
      let cloudmsg = '&cuid=' + (sessionStorage.getItem('CloudUserID') || '') + '&clid=' + (sessionStorage.getItem('CloudLoginUID') || '') + '&cun=' + (sessionStorage.getItem('CloudUserName') || '')
      let msg = '&uid=' + sessionStorage.getItem('UserID') + '&lid=' + sessionStorage.getItem('LoginUID') + '&un=' + sessionStorage.getItem('User_Name')
      let src = '#/print/' + window.btoa('ID=' + Id + msg + cloudmsg)
      let src = '#/print/' + window.btoa(window.encodeURIComponent(JSON.stringify({ ID: Id, lang })))
      window.open(src)
    } else if (btn.pageTemplate === 'pay') {
      let _p = `ID=${Id}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID')}&logo=${window.GLOB.doclogo}&name=${sessionStorage.getItem('Full_Name')}&icp=${window.GLOB.ICP}&copyRight=${window.GLOB.copyRight}`
src/views/design/header/index.jsx
@@ -499,8 +499,8 @@
          </div> : null}
          {window.GLOB.systemType !== 'production' && subLang ? <div className="entrance">
            <div className="icon"><PlusOutlined /></div>
            <div className="title">添加菜单</div>
            <div className="detail">可选择母语系统的菜单,快速转换为当前语言。</div>
            <div className="title">菜单转换</div>
            <div className="detail">可选择母语系统的菜单,快速转换到当前语言。打印模板请在HS下复制后,在此处选择指定模板进行语言转换。</div>
            <TransMenu reload={this.reload} menulist={menulist}/>
          </div> : null}
        </div>
src/views/design/header/transmenu/index.jsx
@@ -1,6 +1,6 @@
import React, { Component } from 'react'
import { is, fromJS } from 'immutable'
import { Modal, notification, Button, Spin, Cascader } from 'antd'
import { Modal, Radio, notification, Button, Spin, Select, Cascader } from 'antd'
// import { ClockCircleOutlined, SyncOutlined, WarningOutlined, CheckCircleOutlined } from '@ant-design/icons'
import moment from 'moment'
import md5 from 'md5'
@@ -18,9 +18,13 @@
    loading: false,
    saveing: false,
    lang: '',
    type: '',
    dicts: [],
    menus: [],
    values: []
    billMenus: [],
    tabMenus: [],
    values: '',
    images: '',
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -36,7 +40,9 @@
      loading: true,
      visible: true,
      saveing: false,
      values: []
      type: 'menu',
      images: '',
      values: ''
    })
    
    this.getDicts()
@@ -74,6 +80,11 @@
  }
  getMenus = (lang) => {
    if (this.state.menus.length > 0) {
      this.setState({loading: false})
      return
    }
    let _param = {
      func: 's_get_pc_menus',
      systemType: window.GLOB.sysType,
@@ -151,9 +162,26 @@
  }
  submit = () => {
    const { values } = this.state
    const { values, type } = this.state
    if (!values || (values.length !== 3 && values[0] !== 'home_page_id')) {
    if (!values) {
      notification.warning({
        top: 92,
        message: type === 'menu' ? '请选择菜单!' : '请选择模板!',
        duration: 5
      })
      return
    }
    if (type === 'bill') {
      this.billSubmit()
      return
    } else if (type === 'tab') {
      this.tabSubmit()
      return
    }
    if (values.length !== 3 && values[0] !== 'home_page_id') {
      notification.warning({
        top: 92,
        message: '请选择菜单!',
@@ -395,6 +423,7 @@
        config.style = config.style || {}
      }
      config.enabled = false
      config.MenuName = menu.label
      config.fstMenuId = menu.fstMenuId || ''
      config.parentId = menu.parentId || ''
@@ -498,19 +527,322 @@
    })
  }
  onChange = (e) => {
    this.setState({
      type: e.target.value,
      images: '',
      values: ''
    })
    if (e.target.value === 'bill') {
      this.getBillMenus()
    } else if (e.target.value === 'tab') {
      this.getTabMenus()
    }
  }
  getBillMenus = () => {
    const { billMenus } = this.state
    if (billMenus.length) return
    let _param = {
      func: 's_get_sPrintTemplate_web',
      OrderCol: 'ID desc',
      lang_s: sessionStorage.getItem('lang'),
      dataM: 'Y',
      PageIndex: 1,
      PageSize: 1000
    }
    Api.getCloudConfig(_param).then(res => {
      if (!res.status) {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 5
        })
        return
      }
      this.setState({billMenus: res.data || []})
    })
  }
  getTabMenus = () => {
    const { tabMenus } = this.state
    if (tabMenus.length) return
    let _param = {
      func: 's_get_sPrintTemplate',
      OrderCol: 'ID desc',
      lang_s: sessionStorage.getItem('lang'),
      dataM: 'Y',
      PageIndex: 1,
      PageSize: 1000
    }
    Api.getCloudConfig(_param).then(res => {
      if (!res.status) {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 5
        })
        return
      }
      this.setState({tabMenus: res.data || []})
    })
  }
  billSubmit = () => {
    const { dicts, values, billMenus } = this.state
    let _param = {
      func: 'sPC_Get_LongParam',
      MenuID: values
    }
    this.setState({saveing: true})
    let temp = billMenus.filter(item => item.ID === values)[0]
    Api.getCloudConfig(_param).then(res => {
      if (!res.status) {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 5
        })
        this.setState({saveing: false})
        return
      }
      let config = null
      if (res.LongParam) {
        try {
          config = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
        } catch (e) {
          console.warn('Parse Failure')
          config = ''
        }
      }
      if (!config) {
        notification.warning({
          top: 92,
          message: '未获取到模板配置信息',
          duration: 5
        })
        this.setState({saveing: false})
        return
      }
      let btnDict = {}
      let titDict = {}
      let lisDict = {}
      let regs = []
      dicts.forEach(item => {
        if (item.type === 'button') {
          btnDict[item.reg] = item.value
        } else if (item.type === 'title') {
          titDict[item.reg] = item.value
        } else if (item.type === 'list') {
          lisDict[item.reg] = item.value
        } else if (item.type === 'text') {
          regs.push({reg: new RegExp(item.reg, 'g'), value: item.value, sort: item.reg.length})
        }
      })
      regs.sort((a, b) => b.sort - a.sort)
      let tail = md5(window.GLOB.appkey + sessionStorage.getItem('lang')).toLowerCase()
      tail = tail.slice(-8)
      setLangTrans(config, btnDict, titDict, lisDict, regs, tail)
      if (config.components) {
        let commonId = Utils.getuuid()
        if (config.interfaces && config.interfaces.length > 0) {
          config.interfaces = config.interfaces.map(inter => {
            inter.uuid = md5(commonId + inter.uuid)
            return inter
          })
        }
        config.components = MenuUtils.resetConfig(config.components, commonId, false)
        config.tables = config.tables || []
        config.style = config.style || {}
      }
      config.enabled = false
      config.MenuNo = temp.PrintTempNO || ''
      config.MenuName = temp.PrintTempName || ''
      config.fstMenuId = 'BillPrintTemp'
      config.parentId = 'BillPrintTemp'
      config.uuid = values
      config.MenuID = config.uuid
      config.open_edition = res.open_edition || ''
      let param = {
        func: 'sPC_TrdMenu_AddUpt',
        FstID: config.fstMenuId,
        SndID: config.parentId,
        ParentID: config.parentId,
        MenuID: config.uuid,
        MenuNo: config.MenuNo || '',
        EasyCode: config.easyCode || '',
        Template: config.Template,
        MenuName: config.MenuName || '',
        open_edition: config.open_edition,
        PageParam: JSON.stringify({Template: config.Template, OpenType: config.OpenType || 'newtab'})
      }
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      param.secretkey = Utils.encrypt('', param.timestamp)
      Api.getCloudConfig(param).then(res => {
        if (!res.status) {
          notification.warning({
            top: 92,
            message: res.message,
            duration: 5
          })
          this.setState({saveing: false})
          return
        }
        notification.success({
          top: 92,
          message: '转换成功。',
          duration: 5
        })
        this.setState({
          saveing: false,
          visible: false
        })
      })
    })
  }
  tabSubmit = () => {
    const { values, dicts, tabMenus } = this.state
    let param = {
      func: 's_PrintTemplateMGetData',
      Type: 'Y',
      ID: values
    }
    this.setState({saveing: true})
    let temp = tabMenus.filter(item => item.ID === values)[0]
    Api.getCloudConfig(param).then(result => {
      if (!result.status) {
        notification.warning({
          top: 92,
          message: result.message,
          duration: 5
        })
        this.setState({saveing: false})
      } else if (!result.ConfigParam) {
        notification.warning({
          top: 92,
          message: '未获取到打印模板信息!',
          duration: 5
        })
        this.setState({saveing: false})
      } else {
        let config = ''
        try {
          config = JSON.parse(window.decodeURIComponent(window.atob(result.ConfigParam)))
        } catch (e) {
          config = ''
        }
        if (!config) {
          notification.warning({
            top: 92,
            message: '未获取到打印模板信息!',
            duration: 5
          })
          this.setState({saveing: false})
          return
        }
        let titDict = {}
        dicts.forEach(item => {
          if (item.type === 'title') {
            titDict[item.reg] = item.value
          }
        })
        config.elements.forEach(item => {
          if (item.type === 'text' && item.value && titDict[item.value]) {
            item.value = titDict[item.value]
          }
        })
        config.name = temp.PrintTempName || ''
        config.remark = temp.Remark || ''
        config.PrintTempNO = temp.PrintTempNO || ''
        let _param = {
          func: 's_PrintTemplateMSub',
          ID: values,
          ConfigParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))),
          Images: temp.Images || '',
          PrintTempName: config.name,
          Remark: config.remark,
          PrintTempNO: config.PrintTempNO
        }
        Api.getCloudConfig(_param).then(result => {
          if (!result.status) {
            notification.warning({
              top: 92,
              message: result.message,
              duration: 5
            })
            this.setState({saveing: false})
            return
          }
          notification.success({
            top: 92,
            message: '转换成功。',
            duration: 5
          })
          this.setState({
            saveing: false,
            visible: false
          })
        })
      }
    })
  }
  render () {
    const { visible, loading, saveing, menus } = this.state
    const { visible, loading, saveing, menus, type, billMenus, tabMenus, images } = this.state
    return (
      <>
        <Button type="primary" onClick={this.trigger}>
          添加
          转换
        </Button>
        <Modal
          wrapClassName="sync-menu-modal"
          title="添加菜单"
          title="菜单转换"
          visible={visible}
          width={800}
          width={600}
          closable={false}
          maskClosable={false}
          onOk={this.submit}
@@ -519,7 +851,31 @@
          destroyOnClose
        >
          {loading ? <Spin /> : <div>
            <Cascader onChange={(val) => this.setState({values: val})} options={menus} expandTrigger="hover" placeholder="请选择模板菜单"/>
            <Radio.Group defaultValue="menu" onChange={this.onChange}>
              <Radio.Button value="menu">菜单</Radio.Button>
              <Radio.Button value="bill">单据打印模板</Radio.Button>
              <Radio.Button value="tab">标签打印模板</Radio.Button>
            </Radio.Group>
            {type === 'menu' ? <Cascader popupClassName="sync-cascader" onChange={(val) => this.setState({values: val})} options={menus} expandTrigger="hover" placeholder="请选择菜单"/> : null}
            {type === 'bill' ? <Select
              showSearch
              placeholder="请选择单据模板"
              dropdownMatchSelectWidth={false}
              onChange={(val, option) => this.setState({values: val, images: option.props.images || ''})}
              filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
            >
              {billMenus.map((item, i) => (<Select.Option key={i} images={item.Images || ''} value={item.ID}>{`${item.PrintTempName}(${item.PrintTempNO})`}</Select.Option>))}
            </Select> : null}
            {type === 'tab' ? <Select
              showSearch
              placeholder="请选择标签模板"
              dropdownMatchSelectWidth={false}
              onChange={(val, option) => this.setState({values: val, images: option.props.images || ''})}
              filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
            >
              {tabMenus.map((item, i) => (<Select.Option key={i} images={item.Images || ''} value={item.ID}>{`${item.PrintTempName}(${item.PrintTempNO})`}</Select.Option>))}
            </Select> : null}
            {images ? <img src={images} alt=""/> : null}
          </div>}
        </Modal>
      </>
src/views/design/header/transmenu/index.scss
@@ -2,15 +2,35 @@
  .ant-modal-body {
    position: relative;
    padding: 24px 50px;
    min-height: 200px;
    min-height: 250px;
    max-height: calc(100vh - 210px);
    .ant-cascader-picker {
    .ant-cascader-picker, .ant-select {
      width: 300px;
    }
    .ant-radio-group {
      display: block;
      margin-bottom: 20px;
      .ant-radio-button-wrapper {
        width: 150px;
        text-align: center;
      }
    }
    img {
      max-width: 300px;
      max-height: 150px;
      display: block;
      margin: 10px;
    }
    .ant-spin {
      position: absolute;
      left: 50%;
      left: calc(50% - 10px);
      top: 75px;
    }
  }
}
.sync-cascader {
  .ant-cascader-menu {
    height: 200px;
    min-width: 120px;
  }
}
src/views/menudesign/index.jsx
@@ -98,6 +98,10 @@
      sessionStorage.setItem('MenuType', param.MenuType || 'custom')
      if (param.MenuType === 'billPrint' && param.lang) {
        sessionStorage.setItem('lang', param.lang)
      }
      this.setState({
        MenuType: param.MenuType,
        MenuId: param.MenuId || param.MenuID,
src/views/printTemplate/index.jsx
@@ -35,6 +35,7 @@
class PrintTemplate extends Component {
  state = {
    config: null,
    oriConfig: null,
    ID: null,
    editItemId: '',
    editItemType: '',
@@ -67,16 +68,23 @@
  }
  UNSAFE_componentWillMount () {
    let _param = window.atob(this.props.match.params.param)
    let _params = {}
    _param.split('&').forEach(cell => {
      let _cell = cell.split('=')
      _params[_cell[0]] = _cell[1]
    })
    try {
      let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
      if (param.lang) {
        sessionStorage.setItem('lang', param.lang)
      }
    this.setState({
      ID: _params.ID
        ID: param.ID
    })
    } catch (e) {
      notification.warning({
        top: 92,
        message: '模板信息解析错误!',
        duration: 5
      })
    }
  }
  componentDidMount () {
@@ -88,7 +96,7 @@
      let cy = position.cy
      let _selectItem = null
      let _config = JSON.parse(JSON.stringify(this.state.config))
      let _config = fromJS(this.state.config).toJS()
      _config.elements.forEach(element => {
        let x = +element.left
@@ -156,8 +164,8 @@
        return
      }
      let _selectItem = JSON.parse(JSON.stringify(this.state.config.elements.filter(ele => ele.uuid === this.state.editItemId)[0]))
      let _preItem = JSON.parse(JSON.stringify(_selectItem))
      let _selectItem = fromJS(this.state.config.elements.filter(ele => ele.uuid === this.state.editItemId)[0]).toJS()
      let _preItem = fromJS(_selectItem).toJS()
      let position = this.getclickpoint(e)
      let cx = position.cx
@@ -214,7 +222,7 @@
              let result = this.resetItem(_selectItem)
              if (!is(fromJS(result), fromJS(_preItem))) {
                _preItem = JSON.parse(JSON.stringify(result))
                _preItem = fromJS(result).toJS()
                this.FormRef.resetForm(result)
                config.elements = config.elements.map(item => {
@@ -261,7 +269,7 @@
              let result = this.resetItem(fromJS(_selectItem).toJS())
              if (!is(fromJS(result), fromJS(_preItem))) {
                _preItem = JSON.parse(JSON.stringify(result))
                _preItem = fromJS(result).toJS()
                this.FormRef.resetForm(result)
                config.elements = config.elements.map(item => {
@@ -407,6 +415,7 @@
      this.handleResize()
      this.setState({
        config: _config,
        oriConfig: fromJS(_config).toJS(),
        editItemId: _config.uuid,
        editItemType: _config.type,
        formlist: getpageform(_config)
@@ -779,9 +788,16 @@
  }
  submitConfig = () => {
    const { config } = this.state
    const { config, oriConfig } = this.state
    if (config.height / config.width > 10 || config.width / config.height > 10) {
    if (is(fromJS(config), fromJS(oriConfig))) {
      notification.success({
        top: 92,
        message: '当前模板未修改,无需保存。',
        duration: 5
      })
      return
    } else if (config.height / config.width > 10 || config.width / config.height > 10) {
      notification.warning({
        top: 92,
        message: '纸张纵横比不可超过10!',
@@ -878,6 +894,7 @@
        })
      }
      this.setState({
        oriConfig: fromJS(config).toJS(),
        saveloading: false
      })
    })