Browse Source

feat: 导入项目后提示并打开项目详情页

pull/1/head
wally 4 years ago
parent
commit
410f52766e
  1. 1
      CHANGELOG.md
  2. 6
      src/components/Calendar/Calendar.vue
  3. 26
      src/components/Upload/Upload.vue
  4. 49
      src/pages/index/index.vue
  5. 3
      src/utils/upload.js

1
CHANGELOG.md

@ -3,6 +3,7 @@
### 🌟 新功能
范围|描述|commitId
--|--|--
calendar, tall.js | 上下滑动切换日历的模式,tall.js中domain根据环境变量切换 | 364e25d
- | db store | 6414c4f
default plugin | 添加默认插件;项目列表;全局项目最大高度设置 | ed1d87b
- | indexedDB | 687394e

6
src/components/Calendar/Calendar.vue

@ -83,7 +83,7 @@
</view> -->
</view>
<view class="flex justify-center u-font-18" style="color: #3b82f6" @click="goback"> 今日 </view>
<view class="flex justify-center u-font-18" style="color: #3b82f6" @click="goToday"> 今日 </view>
</view>
</template>
mb-3
@ -231,6 +231,7 @@ export default {
let date = '';
if (cur) {
date = new Date(cur);
console.log('date: ', date);
} else {
date = new Date();
}
@ -330,7 +331,8 @@ export default {
},
//
goback() {
goToday() {
console.log(1);
const d = new Date();
this.initDate(d);
},

26
src/components/Upload/Upload.vue

@ -1,31 +1,33 @@
<template>
<view class="upload">
<!-- <view class="flex items-center justify-center w-12 h-12 bg-blue-100 rounded-full shadow-md" v-if="loading">
<u-loading size="24px" color="primary" mode="circle"></u-loading>
</view> -->
<u-icon name="plus" size="24px" class="flex justify-center w-12 h-12 bg-blue-100 rounded-full shadow-md" @tap="handleUpload"></u-icon>
</view>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
data() {
return { loading: false };
},
computed: mapGetters('user', ['userId']),
methods: {
// wbs
async handleUpload() {
try {
this.loading = true;
const data = await this.$u.api.import();
this.loading = false;
console.log('data: ', data);
// WBS
//
console.log('data: ', data);
this.$emit('success');
setTimeout(() => {
this.$u.route('/pages/project/project', {
u: this.userId,
p: data.id,
pname: data.pname,
url: data.url,
});
}, 2000);
} catch (error) {
this.loading = false;
this.$emit('show-alert', error);
this.$emit('error', error);
}
},
},

49
src/pages/index/index.vue

@ -4,14 +4,16 @@
<!-- 日历 -->
<Calendar @selected-change="onDateChange" :show-back="true" :dot-list="days" ref="calendar" />
<!-- 上传 导入wbs -->
<Upload @show-alert="onShowAlert" />
<Upload @success="onUploadSuccess" @error="onUploadError" />
</view>
<!-- 项目列表 -->
<Projects />
<!-- 全局提示框 -->
<u-alert-tips
<u-top-tips ref="uTips"></u-top-tips>
<!-- <u-alert-tips
class="top-0 -inset-x-0"
style="position: fixed !important"
type="error"
@ -20,7 +22,7 @@
:show="alert.show"
:description="alert.description"
@close="alert.show = false"
></u-alert-tips>
></u-alert-tips> -->
</view>
</template>
@ -38,11 +40,11 @@ export default {
{ date: '2020-08-09' },
// {date: '2020-08-16'}
],
alert: {
show: false,
title: '',
description: '',
},
// alert: {
// show: false,
// title: '',
// description: '',
// },
calendar: null,
};
},
@ -74,7 +76,7 @@ export default {
const data = await this.$u.api.getProjects(start, end);
this.setProjects(data);
} catch (error) {
console.log('error: ', error);
console.error('error: ', error);
}
},
@ -91,11 +93,11 @@ export default {
},
// alert
onShowAlert(event) {
this.alert.description = event || '发生了点小意外';
this.alert.show = true;
setTimeout(() => (this.alert.show = false), 10000);
},
// onShowAlert(event) {
// this.alert.description = event || '';
// this.alert.show = true;
// setTimeout(() => (this.alert.show = false), 10000);
// },
// /
onMove(event) {
@ -108,6 +110,25 @@ export default {
!this.calendar.weekMode && (this.calendar.weekMode = true);
}
prevY = y;
this.calendar.initDate();
},
//
onUploadSuccess() {
this.$refs.uTips.show({
title: '导入成功,即将打开新项目',
type: 'success',
duration: '3000',
});
},
//
onUploadError(error) {
this.$refs.uTips.show({
title: error || '导入失败',
type: 'error',
duration: '6000',
});
},
},
};

3
src/utils/upload.js

@ -42,7 +42,8 @@ export default {
if (code !== 200) {
reject(msg);
} else {
resolve(data.data);
console.log('data.data: ', JSON.parse(data).data);
resolve(JSON.parse(data).data);
}
} else {
reject('上传失败');

Loading…
Cancel
Save