|
|
|
@ -1,41 +1,69 @@ |
|
|
|
<template> |
|
|
|
<view class="upload"> |
|
|
|
<u-icon name="plus" size="24px" class="flex justify-center w-12 h-12 bg-blue-100 rounded-full shadow-md" @click="handleUpload"></u-icon> |
|
|
|
<u-icon name="plus" size="24px" class="flex justify-center w-12 h-12 bg-blue-100 rounded-full shadow-md" |
|
|
|
@click="handleUpload"></u-icon> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import { computed } from 'vue'; |
|
|
|
import { useStore } from 'vuex'; |
|
|
|
import { |
|
|
|
computed, |
|
|
|
ref |
|
|
|
} from 'vue'; |
|
|
|
import { |
|
|
|
useStore |
|
|
|
} from 'vuex'; |
|
|
|
import Config from '@/common/js/config.js'; |
|
|
|
|
|
|
|
const emit = defineEmits(['success', 'error']); |
|
|
|
|
|
|
|
const store = useStore(); |
|
|
|
const userId = computed(() => store.getters['user/userId']); |
|
|
|
const list = ref([]); |
|
|
|
|
|
|
|
getList(); |
|
|
|
|
|
|
|
// 导入wbs |
|
|
|
const handleUpload = async cur => { |
|
|
|
if (list.value.length === 1) { |
|
|
|
uni.showModal({ |
|
|
|
content: '是否上传到' + list.value[0].name, |
|
|
|
showCancel: true, |
|
|
|
success: async ({ confirm }) => { |
|
|
|
if (confirm) { |
|
|
|
try { |
|
|
|
const res = await uni.$u.api.import(); |
|
|
|
// 导入WBS成功后 |
|
|
|
// 直接打开导入的项目 |
|
|
|
emit('success'); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
|
} else { |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/pages/business/business' |
|
|
|
}) |
|
|
|
// try { |
|
|
|
// const res = await uni.$u.api.import(); |
|
|
|
// // 导入WBS成功后 |
|
|
|
// // 直接打开导入的项目 |
|
|
|
// emit('success'); |
|
|
|
// 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); |
|
|
|
// } |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
async function getList() { |
|
|
|
try { |
|
|
|
const res = await uni.$u.api.getBusinessList(); |
|
|
|
list.value = res; |
|
|
|
} catch (error) { |
|
|
|
console.error('error: ', error); |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
|