Browse Source

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

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

6
src/components/Calendar/Calendar.vue

@ -83,7 +83,7 @@
</view> --> </view> -->
</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> </view>
</template> </template>
mb-3 mb-3
@ -231,6 +231,7 @@ export default {
let date = ''; let date = '';
if (cur) { if (cur) {
date = new Date(cur); date = new Date(cur);
console.log('date: ', date);
} else { } else {
date = new Date(); date = new Date();
} }
@ -330,7 +331,8 @@ export default {
}, },
// //
goback() { goToday() {
console.log(1);
const d = new Date(); const d = new Date();
this.initDate(d); this.initDate(d);
}, },

26
src/components/Upload/Upload.vue

@ -1,31 +1,33 @@
<template> <template>
<view class="upload"> <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> <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> </view>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex';
export default { export default {
data() { computed: mapGetters('user', ['userId']),
return { loading: false };
},
methods: { methods: {
// wbs // wbs
async handleUpload() { async handleUpload() {
try { try {
this.loading = true;
const data = await this.$u.api.import(); const data = await this.$u.api.import();
this.loading = false; console.log('data: ', data);
// WBS // 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) { } catch (error) {
this.loading = false; this.$emit('error', error);
this.$emit('show-alert', error);
} }
}, },
}, },

49
src/pages/index/index.vue

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

Loading…
Cancel
Save