king
2023-02-15 42abb412ad6305fedffb81ce5af1d0e49218a0ec
2023-02-15
2个文件已修改
158 ■■■■ 已修改文件
src/tabviews/custom/components/module/voucher/loadFromTemp/index.jsx 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/module/voucher/loadFromTemp/index.scss 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/module/voucher/loadFromTemp/index.jsx
@@ -1,28 +1,65 @@
import React, {Component} from 'react'
import { Button, Modal } from 'antd'
import { Button, Modal, notification, Empty, Input } from 'antd'
import './index.scss'
const { Search } = Input
class LoadFromTemp extends Component {
  state = {
    visible: false,
    tempId: '',
    searchkey: '',
    temps: []
  }
  submit = () => {
    const { name, typeChar, typeName } = this.state
    const { tempId } = this.state
    if (!tempId) {
      notification.warning({
        top: 92,
        message: '请选择模板!',
        duration: 5
      })
      return
    }
    this.setState({visible: false})
    this.props.onChange(name, typeChar, typeName)
    this.props.onChange(tempId)
  }
  trigger = () => {
    this.setState({visible: true, tempId: ''})
    const { tempTypes } = this.props
    let temps = []
    tempTypes.forEach(item => {
      if (item.temp_list && item.temp_list.length > 0) {
        item.temp_list.forEach(cell => {
          temps.push({
            id: cell.temp_id,
            voucher_text: cell.voucher_text || '',
            data_name: item.data_name || ''
          })
        })
      }
    })
    this.setState({visible: true, tempId: '', temps, searchkey: ''})
  }
  checkItem = (id) => {
    this.setState({tempId: id})
  }
  render() {
    const { tempTypes } = this.props
    const { visible, tempId } = this.state
    const { visible, tempId, temps, searchkey } = this.state
    let _temps = temps
    if (searchkey) {
      _temps = temps.filter(item => item.voucher_text.indexOf(searchkey) > -1 || item.data_name.indexOf(searchkey) > -1)
    }
    return (
      <>
@@ -31,28 +68,30 @@
          title="从模板中加载"
          wrapClassName="mk-temp-list-wrap"
          visible={visible}
          width={600}
          width={700}
          maskClosable={false}
          onOk={this.submit}
          onCancel={() => { this.setState({ visible: false })}}
          destroyOnClose
        >
          {visible ? <div className="document-wrap">
            <Search placeholder="" defaultValue="" style={{ minWidth: '200px' }} onSearch={(val) => this.setState({searchkey: val, tempId: ''})}/>
            <div className="document-title">
              <div className="folder-box">文件夹</div>
              <div className="folder-box">模板类型</div>
              <div className="folder">
                <span>文件</span>
                模板名称
              </div>
            </div>
            <div className="document-body">
              <div className="file-wrap">
                {tempTypes.map(doc => {
                  return <div className="file-item" key={doc.id}>
                    <span onClick={() => this.checkItem(doc.id)} className={'square-select' + (tempId === doc.id ? ' active' : '')}></span>
                    <span className="file-name">{doc.attachments_title}</span>
              {_temps.length ? <div className="file-wrap">
                {_temps.map(doc => {
                  return <div className="file-item" onClick={() => this.checkItem(doc.id)} key={doc.id}>
                    <span className={'square-select' + (tempId === doc.id ? ' active' : '')}></span>
                    <span className="folder-name">{doc.data_name}</span>
                    <span className="file-name">{doc.voucher_text}</span>
                  </div>
                })}
              </div>
              </div> : <Empty style={{padding: '10px 0px'}} description={null}/>}
            </div>
          </div> : null}
        </Modal>
src/tabviews/custom/components/module/voucher/loadFromTemp/index.scss
@@ -1,87 +1,79 @@
.mk-temp-list-wrap {
  .ant-modal-body {
    padding: 15px;
    padding: 15px 20px;
  }
  .document-wrap {
    .ant-input-search {
      width: 200px;
      margin-bottom: 5px;
    }
    .document-title {
      display: flex;
      background: #e8e8e8;
      line-height: 38px;
      border: 1px solid #d8d8d8;
      border-bottom: none;
      padding-left: 38px;
      .folder-box {
        width: 200px;
        text-align: center;
        border-right: 1px solid #d8d8d8;
      }
      .folder {
        flex: 1;
        .square-select {
          top: 3px;
          margin: 0 10px;
        }
        text-align: center;
      }
    }
    .document-body {
      border: 1px solid #d8d8d8;
      height: 300px;
      display: flex;
      .doc-name {
        width: 200px;
        text-align: center;
        border-right: 1px solid #d8d8d8;
        height: 100%;
        overflow-y: auto;
        div {
          border-bottom: 1px solid #e8e8e8;
          height: 40px;
          line-height: 40px;
        }
        .active {
          background: var(--mk-sys-color1);
        }
      }
      .file-wrap {
        flex: 1;
        width: calc(100% - 200px);
        width: 100%;
        height: 100%;
        overflow-y: auto;
        .file-item {
          border-bottom: 1px solid #e8e8e8;
          height: 40px;
          line-height: 40px;
          display: flex;
          .square-select {
            top: 4px;
            top: 12px;
            margin: 0 10px;
          }
          img {
            width: 20px;
            height: 20px;
            margin-top: -2px;
            margin-right: 5px;
          }
          .file-name {
          .folder-name {
            display: inline-block;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            vertical-align: top;
            width: calc(100% - 90px);
            text-align: center;
            width: 200px;
            padding: 0 5px;
          }
          .file-name {
            flex: 1;
            display: inline-block;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            vertical-align: top;
            text-align: center;
            width: calc(100% - 200px);
            padding: 0 5px;
          }
        }
      }
    }
    .doc-name::-webkit-scrollbar, .file-wrap::-webkit-scrollbar {
    .file-wrap::-webkit-scrollbar {
      width: 7px;
    }
    .doc-name::-webkit-scrollbar-thumb, .file-wrap::-webkit-scrollbar-thumb {
    .file-wrap::-webkit-scrollbar-thumb {
      border-radius: 5px;
      box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.13);
      background: rgba(0, 0, 0, 0.13);
    }
    .doc-name::-webkit-scrollbar-track, .file-wrap::-webkit-scrollbar-track {
    .file-wrap::-webkit-scrollbar-track {
      box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
      border-radius: 3px;
      border: 1px solid rgba(0, 0, 0, 0.07);
@@ -95,6 +87,7 @@
      height: 16px;
      border: 1px solid #cccccc;
      box-sizing: content-box;
      border-radius: 16px;
      margin: auto;
      margin-right: 5px;
      background-color: #ffffff;
@@ -104,30 +97,6 @@
    .square-select.active {
      border-color: var(--mk-sys-color);
      background: var(--mk-sys-color);
    }
    .square-select.half {
      border-color: var(--mk-sys-color);
    }
    .square-select.disabled {
      border-color: #e8e8e8;
      background: #e8e8e8;
      cursor: default;
    }
    .square-select.disabled::before {
      border-color: #e8e8e8;
    }
    .square-select.half::before {
      display: none;
    }
    .square-select.half::after {
      position: absolute;
      top: 4px;
      left: 4px;
      content: ' ';
      display: block;
      width: 8px;
      height: 8px;
      background: var(--mk-sys-color);
    }