king
2024-03-08 1bec8d69cf14bd88591eee5b0320c5c8f6c25a08
src/views/printTemplate/index.jsx
@@ -320,6 +320,9 @@
      if (keyCode === 46 && editItemId && editItemType !== 'Template') {
        this.deleteItem()
      }
      if (e.ctrlKey && keyCode === 81 && editItemId && editItemType !== 'Template') {
        this.copyItem()
      }
    }
  }
@@ -706,6 +709,51 @@
    })
  }
  copyItem = () => {
    const { editItemId, config, fields } = this.state
    let cell = config.elements.filter(item => item.uuid === editItemId)[0]
    if (!cell) return
    let item = {...cell}
    item.left = item.left + parseInt(item.width / 4)
    item.top = item.top + parseInt(item.height / 4)
    item.uuid = Utils.getuuid()
    if (item.left + item.width > config.width) {
      item.left = config.width - item.width
    }
    if (item.top + item.height > config.height) {
      item.top = config.height - item.height
    }
    let _config = fromJS(config).toJS()
    _config.elements.push(item)
    let _formlist = []
    if (item.type === 'text') {
      _formlist = getTextForm(item, fields)
    } else if (item.type === 'barcode') {
      _formlist = getBarcodeForm(item, fields)
    } else if (item.type === 'qrcode') {
      _formlist = getQrcodeForm(item, fields)
    } else if (item.type === 'image') {
      _formlist = getImageForm(item, fields)
    }
    this.setState({
      config: _config,
      editItemId: item.uuid,
      editItemType: item.type,
      formlist: _formlist
    }, () => {
      this.resetview()
    })
  }
  deleteItem = () => {
    const _this = this
    const { editItemId, config } = this.state
@@ -896,7 +944,10 @@
    return (
      <div className="print-template">
        <DndProvider backend={HTML5Backend}>
          <header className="print-header-container ant-menu-dark">模板制作</header>
          <header className="print-header-container ant-menu-dark">
            模板制作
            <div>快捷键:Delete(删除元素)、ctrl + q(复制元素)</div>
          </header>
          <aside className="tools">
            <Card className="tool-bar" title="工具栏">
              {printItems.map((item, index) => {