CycleCountDetailChildSubTable.vue 8.29 KB
<template>
  <a-card :bordered="false">
    <a-table
      rowKey="id"
      size="middle"
      bordered
      :loading="loading"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="false"
    >
      <span slot="companyCode_dictText" slot-scope="companyCode_dictText">
        <a-tag :key="companyCode_dictText" color=blue>
          {{ companyCode_dictText }}
        </a-tag>
      </span>
      <span slot="inventoryStatus_dictText" slot-scope="text, record">
        <a-tag color="#87d068" v-if="!record.inventoryStatus_dictText">?</a-tag>
        <a-tag v-else :key="record.inventoryStatus_dictText" :color="getInvStatusColor(record.inventoryStatus_dictText)">
          {{ record.inventoryStatus_dictText }}
        </a-tag>
      </span>
      <span slot="childStatus_dictText" slot-scope="childStatus_dictText">
            <a-tag :key="childStatus_dictText" :color="getStatusColor(childStatus_dictText)">
              {{ childStatus_dictText }}
            </a-tag>
        </span>
      <template slot="locationCode" slot-scope="text, record">
        <a-tag color="#87d068" v-if="!record.locationCode">?</a-tag>
        <span v-else>{{ record.locationCode }}</span>
      </template>
      <template slot="containerCode" slot-scope="text, record">
        <a-tag color="#87d068" v-if="!record.containerCode">?</a-tag>
        <span v-else>{{ record.containerCode }}</span>
      </template>
      <template slot="materialCode" slot-scope="text, record">
        <a-tag color="#87d068" v-if="!record.materialCode">?</a-tag>
        <span v-else>{{ record.materialCode }}</span>
      </template>
      <template slot="materialName" slot-scope="text, record">
        <a-tag color="#87d068" v-if="!record.materialName">?</a-tag>
        <span v-else>{{ record.materialName }}</span>
      </template>
      <template slot="materialSpec" slot-scope="text, record">
        <a-tag color="#87d068" v-if="record.materialSpec === ''">?</a-tag>
        <span v-else>{{ record.materialSpec }}</span>
      </template>
      <template slot="materialUnit" slot-scope="text, record">
        <a-tag color="#87d068" v-if="record.materialUnit === ''">?</a-tag>
        <span v-else>{{ record.materialUnit }}</span>
      </template>
      <template slot="batch" slot-scope="text, record">
        <a-tag color="#87d068" v-if="record.batch === ''">?</a-tag>
        <span v-else>{{ record.batch }}</span>
      </template>
      <template slot="systemQty" slot-scope="text, record">
        <a-tag color="#87d068" v-if="record.systemQty === null">?</a-tag>
        <span v-else>{{ record.systemQty }}</span>
      </template>
      <template slot="gapQty" slot-scope="text, record">
        <a-tag color="#87d068" v-if="record.gapQty === null">?</a-tag>
        <span v-else>{{ record.gapQty }}</span>
      </template>
      <template slot="htmlSlot" slot-scope="text">
        <div v-html="text"></div>
      </template>
      <template slot="imgSlot" slot-scope="text">
        <div style="font-size: 12px;font-style: italic;">
          <span v-if="!text">无图片</span>
          <img v-else :src="getImgView(text)" alt="" style="max-width:80px;height:25px;"/>
        </div>
      </template>
      <template slot="action" slot-scope="text, record">
        <!--      <a v-if="record.childStatus != 1" @click="createMany(record.id)"><a-icon />实盘登记</a>-->
        <a v-if="record.childStatus < 100" @click="createMany(record)">实盘登记</a>
      </template>
      <template slot="fileSlot" slot-scope="text">
        <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
        <a-button
          v-else
          ghost
          type="primary"
          icon="download"
          size="small"
          @click="downloadFile(text)"
        >
          <span>下载</span>
        </a-button>
      </template>
    </a-table>
    <adjustment-doc-modal ref="adjustmentModal" @ok="modalFormOk"/>
  </a-card>
</template>

<script>
import {getAction} from '@api/manage'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import AdjustmentDocModal from "../modules/AdjustmentDocModal";

export default {
  name: 'CycleCountDetailChildSubTable',
  mixins: [JeecgListMixin],
  components: {
    AdjustmentDocModal,
  },
  props: {
    record: {
      type: Object,
      default: null,
    }
  },
  data() {
    return {
      description: '盘点容器明细表内嵌列表',
      disableMixinCreated: true,
      loading: false,
      dataSource: [],
      columns: [
        {
          title: '盘点主单编码',
          align: 'center',
          dataIndex: 'cycleCountHeadCode',
        },
        {
          title: '货主',
          align: 'center',
          dataIndex: 'companyCode_dictText',
          scopedSlots: {customRender: 'companyCode_dictText'},
        },
        {
          title: '库位',
          align: 'center',
          dataIndex: 'locationCode',
          scopedSlots: {customRender: 'locationCode'},
        },
        {
          title: '容器',
          align: 'center',
          dataIndex: 'containerCode',
          scopedSlots: {customRender: 'containerCode'},
        },
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'materialCode',
          scopedSlots: {customRender: 'materialCode'},
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName',
          scopedSlots: {customRender: 'materialName'},
        },
        {
          title: '物料规格',
          align: 'center',
          dataIndex: 'materialSpec',
          scopedSlots: {customRender: 'materialSpec'},
        },
        {
          title: '物料单位',
          align: 'center',
          dataIndex: 'materialUnit',
          scopedSlots: {customRender: 'materialUnit'},
        },
        {
          title: '库存状态',
          align: 'center',
          dataIndex: 'inventoryStatus_dictText',
          scopedSlots: {customRender: 'inventoryStatus_dictText'},
        },
        {
          title: '系统数量',
          align: 'center',
          dataIndex: 'systemQty',
          scopedSlots: {customRender: 'systemQty'},
        },
        {
          title: '批次',
          align: 'center',
          dataIndex: 'batch',
          scopedSlots: {customRender: 'batch'},
        },
        {
          title: '实盘数量',
          align: 'center',
          dataIndex: 'countedQty',
        },
        {
          title: '差异数量',
          align: 'center',
          dataIndex: 'gapQty',
          scopedSlots: {customRender: 'gapQty'},
        },
        {
          title: '明细状态',
          align: 'center',
          dataIndex: 'childStatus_dictText',
          scopedSlots: {customRender: 'childStatus_dictText'}
        },
        {
          title: '库存明细ID',
          align: 'center',
          dataIndex: 'inventoryDetailId',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 147,
          scopedSlots: {customRender: 'action'},
        },
      ],
      url: {
        listByMainId: '/cycleCountDetail/cycleCountDetail/queryCycleCountDetailChildByMainId',
      },
    }
  },
  watch: {
    record: {
      immediate: true,
      handler() {
        if (this.record !== undefined && this.record != null) {
          this.loadData(this.record,"")
        }
      }
    }
  },
  methods: {
    loadData(record,code) {
      this.loading = true
      getAction(this.url.listByMainId, {
        id: record.id,
        code:code
      }).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
        }
      }).finally(() => {
        this.loading = false
      })
    },
    createMany(record) {
      this.$refs.adjustmentModal.edit(record);
      this.$refs.adjustmentModal.title = "实盘登记";
    },
    getInvStatusColor(status) {
      const colors = {
        '良品': 'green',
        '报废品': 'purple',
        '待确认	': 'grey',
        '次品': 'red',
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
    getStatusColor(status) {
      const colors = {
        '新建': 'green',
        '已登记': 'orange',
        '盘点完成': 'grey',
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
  },
}
</script>

<style scoped>

</style>