forked from ccsens_fe/tall-mui-3
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
1.9 KiB
86 lines
1.9 KiB
<template>
|
|
<view>
|
|
<view @tap="handleUpload" v-if="task.name === '导入WBS新建项目'">{{ task.name }}</view>
|
|
<view @tap="handleUpdate" v-if="task.name === '导入WBS更新项目'">{{ task.name }}</view>
|
|
<!-- 全局提示框 -->
|
|
<u-top-tips ref="uTips"></u-top-tips>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapGetters, mapMutations } from 'vuex';
|
|
|
|
export default {
|
|
name: 'p-wbs-import',
|
|
props: {
|
|
task: {
|
|
type: Object,
|
|
default: () => {},
|
|
},
|
|
},
|
|
data() {
|
|
return {};
|
|
},
|
|
|
|
computed: {
|
|
...mapGetters('user', ['userId']),
|
|
...mapGetters('project', ['projectId']),
|
|
},
|
|
|
|
methods: {
|
|
...mapMutations('project', ['setShowAlert']),
|
|
|
|
// 导入wbs
|
|
async handleUpload() {
|
|
try {
|
|
const data = await this.$u.api.import();
|
|
// 导入WBS成功后
|
|
// 直接打开导入的项目
|
|
this.onUploadSuccess();
|
|
setTimeout(() => {
|
|
this.$u.route('/pages/project/project', {
|
|
u: this.userId,
|
|
p: data.id,
|
|
pname: data.pname,
|
|
url: data.url,
|
|
});
|
|
}, 2000);
|
|
} catch (error) {
|
|
this.onUploadError(error);
|
|
}
|
|
},
|
|
|
|
// 更新项目
|
|
// TODO: 更新接口没写完
|
|
async handleUpdate() {
|
|
try {
|
|
const data = await this.$u.api.import({ projectId: this.projectId });
|
|
console.log('data: ', data);
|
|
// 导入WBS成功后
|
|
// 直接打开导入的项目
|
|
this.onUploadSuccess();
|
|
} catch (error) {
|
|
this.onUploadError(error);
|
|
}
|
|
},
|
|
|
|
// 导入成功
|
|
onUploadSuccess() {
|
|
this.$refs.uTips.show({
|
|
title: '导入成功,即将打开新项目',
|
|
type: 'success',
|
|
duration: '3000',
|
|
});
|
|
},
|
|
|
|
// 导入失败
|
|
onUploadError(error) {
|
|
this.$refs.uTips.show({
|
|
title: error || '导入失败',
|
|
type: 'error',
|
|
duration: '6000',
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|