<template>
  <view class="business-box">
    <view class="business-wrap" v-for="(item, index) in 15" :key="index" @click="toUpload">
      <view class="name">业务{{item}}</view>
      <view class="desc">业务{{item}}</view>
    </view>
  </view>
</template>

<script setup>
  async function toUpload() {
    try {
      const res = await uni.$u.api.import();
      // 导入WBS成功后
      // 直接打开导入的项目
      // emit('success');
      uni.$ui.showToast('导入成功，即将打开新项目', 3000);
      const { apiUrl } = Config;
      const defaultwbs = `${apiUrl}/defaultwbs`;
      res.url && (defaultwbs = res.url);
      setTimeout(() => {
        uni.navigateTo({
          url: `/pages/project/project?u=${userId.value}&p=${res.id}&pname=${res.pname}&url=${res.url}`
        });
      }, 2000);
    } catch (error) {
      console.error('error: ', error);
      // emit('error', error);
      uni.$ui.showToast('导入失败', 6000);
    }
  }
</script>

<style lang="scss" scoped>
  .business-box {
    padding: 0 16px;
  }

  .business-wrap {
    padding: 10px 20px;
    border-bottom: 1px solid #eeeeee;
    width: 100%;
    box-sizing: border-box;

    .name {
      line-height: 36px;
    }

    .desc {
      font-size: 12px;
      color: #999;
    }
  }
</style>
