<template>
<el-dialog
  class="creator"
  title="盘点任务"
  width="70%"
  :visible="show"
  @close="close"
>
  <div class="creator__info creator__info--senior">
    <el-collapse v-model="activeNames">
      <el-collapse-item title="基本信息" name="1">
        <template v-for="item in detailFields">
          <div class="detail-item" :key="item.prop">
            <span class="detail-item__label">{{item.label}} :&nbsp;&nbsp;</span>
            <span class="detail-item__value">{{item.key ? $utils.keyMatcher(detailData[item.prop], $keys.inventory.count[item.key]).name : detailData[item.prop]}}</span>
          </div>
        </template>
      </el-collapse-item>
      <el-collapse-item title="批次属性" name="2">
        <LotAttrs
          type="text"
          :formData="detailData"
          :queryParams="lotAttrsParams"
        ></LotAttrs>
      </el-collapse-item>
    </el-collapse>
  </div>
</el-dialog>
</template>

<script>
export default {
  props: ['show', 'detailData'],
  watch: {
    detailData: {
      immediate: true,
      handler (val) {
        this.lotAttrsParams = {
          ownerCode: val.ownerCode,
          skuCode: val.skuCode,
        }
      }
    },
  },
  created () {
  },
  mounted () {
  },

  data () {
    return {
      lotAttrsParams: {}, // 批次属性查询条件
      // 输入框
      detailFields: [
        { label: '任务ID', prop: 'countId' },
        { label: '盘点状态', prop: 'status', key: 'status' },
        { label: '货主', prop: 'ownerName' },
        { label: '商品', prop: 'skuName' },
        { label: '批次号', prop: 'lotNum' },
        { label: '跟踪号', prop: 'traceId' },
        { label: '库存数EA', prop: 'qty' },
        { label: '盘点数EA', prop: 'qtyCountEa' },
        { label: '损益EA', prop: 'qtyDiff' },
        { label: '库存重量', prop: 'countWeight' },
        { label: '盘点重量', prop: 'weight' },
        { label: '损益重量', prop: 'diffWeight' },
      ],
      activeNames: ['1', '2'],
    }
  },
  methods: {
    // 关闭
    close () {
      this.$emit('close')
    },
  },
}
</script>

<style lang="scss" scoped>
  .el-collapse-item {
    margin-bottom: 20px;
  }
  .detail-item {
    display: inline-table;
    width: 25%;
    font-size: 14px;
    padding: 7px;
  }
</style>
