<template>
  <view>
    <view @tap="handleUpload">{{ task.name }}</view>
  </view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';

export default {
  name: 'p-wbs-import',
  props: {
    task: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {};
  },

  computed: mapState('project', ['alert']),

  methods: {
    ...mapMutations('project', ['setShowAlert']),

    // 导入wbs
    async handleUpload() {
      try {
        const data = await this.$u.api.import();
        // 导入WBS成功后
        // 直接打开导入的项目
        console.log('data: ', data);
      } catch (error) {
        this.setShowAlert(error);
      }
    },
  },
};
</script>
