<template>
  <div id="card-1">
    <el-row>
      <!-- 平台订单待发货列表 -->
      <el-col :span="24" class="main">
        <detail-1 v-if="num == '1'" @toDeliver="toDeliver" :statusList="statusList" @toDetails="toDetails" @toSaless="toSaless"></detail-1>
        <detail-2 v-else-if="num == '2'" :deliverList="list" @toBack="toBack"></detail-2>
      </el-col>
    </el-row>
  </div>
</template>

<script>
const _ = require('lodash');
import { mapState, createNamespacedHelpers } from 'vuex';
export default {
  name: 'card-1',
  props: { statusList: { type: Array } },
  components: {
    detail1: () => import('./parts/detail-1.vue'),
    detail2: () => import('./parts/detail-2.vue'),
  },
  data: function () {
    return {
      num: '1',
      list: [],
    };
  },
  async created() {},
  methods: {
    // 生成发货清单
    toDeliver({ data }) {
      if (data.length == '0') this.$message('请选择订单');
      else {
        this.$set(this, 'list', data);
        this.$set(this, 'num', '2');
      }
    },
    toBack() {
      this.$set(this, 'num', '1');
    },
    toDetails(val) {
      this.$emit('toDetails', val);
    },
    toSaless(val) {
      this.$emit('toSaless', { id: val.id, status: val.status });
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.one {
  margin: 0 0 10px 0;
}
</style>
