<template>
  <div>
    <DeeAsCom
      v-if="basicData"
      ref="list"
      :basic-data="basicData"
      :lay-config="{
        typeName: 'OutStorageScrap',
        layKey: 'flowTable'
      }"
      @tb-printCode="tbPrintCode"
    />
    <!-- <DeeAsCom
      v-if="basicData"
      ref="list"
      :basic-data="basicData"
      :lay-config="{
        typeName: 'OutStorageExpireItem',
        layKey: 'OutStorageExpireFlow'
      }"
      @tb-printCode="tbPrintCode"
    /> -->
    <PrintTag ref="print" :config="printConfig" />
  </div>
</template>

<script>
import PrintTag from './PrintTag.vue'
export default {
  componentName: '报废出库申请单',
  name: 'OutStorageScrappedFlow',
  components: { PrintTag },
  props: {
    basicData: {
      type: Object,
      default: () => null
    }
  },
  data() {
    return {
      // 打印标签
      printConfig: {
        visible: false,
        width: 300,
        prints: [],
        dic: []
      }
    }
  },

  mounted() {
    this.$utils.getDicListByCode('ObjStatus').then(res => {
      this.dic = res
    })

    // 	defaultQueryParams = [{
    //   items: [{
    //     'fieldName': 'id',
    //     'operator': 'EQ',
    //     'value': obtainedParams.basicData.id
    //   }],
    //   operator: 'AND'
    // }]
  },

  methods: {
    tbPrintCode() {
      const selection = this.$refs['list'].$refs['asCom'].selectedData
      // 获取需要打印的数据
      this.printConfig.prints = []
      selection.forEach((row) => {
        this.printConfig = Object.assign({}, this.printConfig, {
          visible: true
        })
        const state = this.dic.find(item => item.value === row.state)
        this.printConfig.prints.push({
          text: row.id,
          propertys: [
            { label: '状态', value: state ? state.label : row.state },
            { label: '申请单编号', value: row.reqNo },
            { label: '申请依据', value: row.reqBill },
            { label: '申请部门', value: row.reqDept },
            { label: '创建人', value: row.creator.userName },
            { label: '创建时间', value: row.createTime }
            // { label: '名称', value: row.extMaterial.resName },
            // { label: '型号/牌号/件号', value: row.extMaterial.modelNo },
            // { label: '规格', value: row.extMaterial.spec },
            // { label: '批号', value: row.lotNo },
            // { label: '系列号/序列号', value: row.serialNo },
            // { label: '机型', value: row.airModel },
            // { label: '验收单号', value: row.purchaseOrderNo },
            // { label: '保证保管期', value: '' },
            // { label: '出库数量', value: row.reqAmount },
            // { label: '贮存期', value: '' },
            // { label: '库位号', value: '' },
            // { label: '计量单位', value: row.extMaterial.extUnit.unitName },
            // { label: 'AO号', value: '' },
            // { label: '备注', value: row.remark || '' }
          ]
        })
      })
      this.$refs.print.print()
    }
  }
}
</script>

<style lang="scss" scoped>

</style>