PurchaseInPrintModal.vue 3.32 KB
<template>
  <a-modal
    :visible="visible"
    :confirm-loading="confirmLoading"
    @cancel="handleCancel"
    width="50%"
  >
    <div>
      <a-row>
        <div class="noprint container" style="text-align:right; padding: 20px;float: right">
          <a-button v-print="'#content'" ghost type="primary" >打印</a-button>
        </div>

      </a-row>
      <div id="content">
        <a-row type="flex">
          <a-col :span="21">
            <h2 class="center">送货单</h2>
            <span>采购单号:{{dataSource[0].code}}</span>
            <span>供应商:{{dataSource[0].supplier}}</span>
            <span>联系人:{{dataSource[0].contact}}</span>
            <span>电话:{{dataSource[0].phone}}</span>
          </a-col>
          <a-col :span="3">
            <vue-qr :text="qrText()" :size="80" :margin="0"></vue-qr>
          </a-col>
        </a-row>
        <a-row>
          <a-table
            ref="table"
            bordered
            size="middle"
            rowKey="id"
            :pagination="false"
            :dataSource="dataSource"
            :loading="loading"
            :columns="columns">
            <span slot="barcode" slot-scope="text, record">
              <barcode  :value="record.materialCode+';'+record.qty" :height="30" :displayValue="false" width="1"></barcode>
            </span>
          </a-table>
        </a-row>
      </div>

    </div>
    <template slot="footer">
      <a-button @click="handleCancel" v-show="false"></a-button>
    </template>
  </a-modal>
</template>

<script>
import { getPurchaseByIds } from '../../../api/api'
import VueQr from 'vue-qr'
import VueBarcode from 'vue-barcode';

export default {
  name: 'PurchaseInPrintModal',
  components: {
    VueQr,
    'barcode': VueBarcode
  },
  data() {
    return {
      confirmLoading: false,
      visible: false,
      loading: false,
      dataSource: [],
      ids: [],
      columns: [
        {
          title: '工作令号',
          dataIndex: 'workNo',
          key: 'workNo'
        },
        {
          title: '物料编码',
          dataIndex: 'materialCode',
          key: 'materialCode'
        }, {
          title: '物料名称',
          dataIndex: 'materialName',
          key: 'materialName'
        }, {
          title: '物料单位',
          dataIndex: 'unit',
          key: 'unit'
        }, {
          title: '规格',
          dataIndex: 'spec',
          key: 'spec'
        }, {
          title: '数量',
          dataIndex: 'qty',
          key: 'qty'
        }, {
          title: '条码',
          dataIndex: 'qr',
          scopedSlots: { customRender: 'barcode' },
          align: 'center',
        }
      ]
    }
  },
  methods: {
    handleCancel(e) {
      this.visible = false
    },
    open(ids) {
      this.loading = true
      this.visible = true
      this.ids = ids
      let params = {
        'ids': ids
      }
      getPurchaseByIds(params).then(res => {
        if (res.success) {
          this.dataSource = res.result
          this.loading = false
        } else {
          this.$message.warning('不是同一供应商!')
        }
      })
    },
    print() {
      window.print()
    },
    doPrint() { //方法

    },
    qrText() {
      return "http://localhost:8080/jeecg-boot/material/purchase/qrInfo?ids="+this.ids
    }
  }
}
</script>

<style scoped>
</style>