<template>
<el-dialog
  class="creator"
  title="移动任务"
  width="70%"
  :visible="showDetail"
  @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 baseInfos">
          <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">
        <template v-for="item in mvInfos">
          <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="3">
        <LotAttrs
          type="text"
          :formData="detailData"
          :queryParams="lotAttrsParams"
        ></LotAttrs>
      </el-collapse-item>
    </el-collapse>
  </div>
</el-dialog>
</template>

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

  data () {
    return {
      lotAttrsParams: {}, // 批次属性查询条件
      // 输入框
      baseInfos: [
        { label: '任务ID', prop: 'mvId' },
        { label: '行号', prop: 'lineNo' },
        { label: '移动明细行号', prop: 'mvLineNo' },
        { label: '状态', prop: 'status', key: 'status' },
        { label: '货主', prop: 'ebcuNameCn' },
        { label: '商品编码', prop: 'skuCode' },
        { label: '商品名称', prop: 'skuName' },
        { label: '包装规格', prop: 'packDesc' },
        { label: '批次号', prop: 'lotNum' },
      ],
      // 移动信息
      mvInfos: [
        { label: '源库位', prop: 'fmLoc' },
        { label: '源跟踪号', prop: 'fmId' },
        { label: '计划目标库位', prop: 'planToLoc' },
        { label: '计划目标跟踪号', prop: 'planToId' },
        { label: '移动数', prop: 'toQtyMvUom' },
        { label: '移动数EA', prop: 'toQtyMvEa' },
        { label: '移动重量', prop: 'toMvWeight' },
        { label: '包装单位', prop: 'uomDesc' },
        { label: '目标库位', prop: 'toLoc' },
        { label: '目标跟踪号', prop: 'toId' },
        { label: '移动操作人', prop: 'mvOp' },
        { label: '移动时间', prop: 'mvTime' },
      ],
      activeNames: ['1', '2', '3'],
    }
  },
  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>
