Browse Source

style: 删除mock,console;upload添加loading

pull/1/head
wally 4 years ago
parent
commit
99d42e2887
  1. 1
      CHANGELOG.md
  2. 4
      src/components/Plugin/Plugin.vue
  3. 5
      src/components/Roles/Roles.vue
  4. 4
      src/components/TimeLine/TimeLine.vue
  5. 1
      src/components/TimeLine/component/TimeStatus.vue
  6. 2
      src/components/Tips/Tips.vue
  7. 14
      src/components/Upload/Upload.vue
  8. 401
      src/mock/mock.js
  9. 2
      src/pages/project/project.vue
  10. 2
      src/utils/tall.js
  11. 2
      src/utils/ui.js
  12. 19
      src/utils/upload.js

1
CHANGELOG.md

@ -37,6 +37,7 @@
- | 距调整pc端 | 5069aa1
- | 配置默认插件接口 | f0c177d
- | 面变化首页变化 | 5e860f1
- | 项目api url设置 | 6cd5245
- | 项目列表, 项目url | 32e005b
- | 首页项目样式改变 | 8514c85

4
src/components/Plugin/Plugin.vue

@ -87,7 +87,6 @@ export default {
});
if (!data || !data.id) return;
const reg = /data-root=["|']?(\w+)["|']?/gi;
// console.log(data.html);
let uuid = '';
// FIXME: js, html
if (data.html) {
@ -95,8 +94,6 @@ export default {
if (reg.test(data.html)) {
uuid = RegExp.$1;
// console.log('uuid: ', uuid, `p${this.pluginTaskId}`);
const str = data.html.replace(new RegExp(uuid, 'g'), `p${this.pluginTaskId}`);
this.pluginContent = str;
} else {
@ -106,7 +103,6 @@ export default {
const str = data.js.replace(new RegExp(uuid, 'g'), `p${this.pluginTaskId}`);
this.handleDom(str);
}
// console.log(this.pluginContent);
// if (data.js) {
// if (reg.test(data.js)) {

5
src/components/Roles/Roles.vue

@ -111,13 +111,12 @@ export default {
this.clearEndFlag();
});
} catch (error) {
console.log('role.vue changeRole error: ', error);
console.error('role.vue changeRole error: ', error);
}
},
// script
clearPluginScript() {
console.log('clearPluginScript: ');
try {
const scripts = document.querySelectorAll('script[data-type=plugin]');
@ -125,7 +124,7 @@ export default {
document.body.removeChild(scripts[i]);
}
} catch (error) {
console.log('clearPluginScript error: ', error);
console.error('clearPluginScript error: ', error);
}
},

4
src/components/TimeLine/TimeLine.vue

@ -60,7 +60,7 @@ export default {
const startTime = this.tasks[0].planStart - 0;
if (this.tasks[0].plugins && this.tasks[0].plugins.length === 0 && !this.topEnd) {
//
console.log('没有数据时: ');
console.warn('没有数据时: ');
const addTasks = [
{
panel: {},
@ -81,7 +81,7 @@ export default {
this.setUpTasks([...addTasks.concat(this.tasks)]);
} else {
//
console.log('有数据时: ');
console.warn('有数据时: ');
const upQuery = {
timeNode: startTime,
queryType: 0,

1
src/components/TimeLine/component/TimeStatus.vue

@ -109,7 +109,6 @@ export default {
computeCyclePersent() {
if (!this.task || !this.task.realStart || !this.task.planDuration) return 100;
const { realStart, planDuration } = this.task;
console.log((((Date.now() - +realStart) * 100) / +planDuration).toFixed(2));
return (((Date.now() - +realStart) * 100) / +planDuration).toFixed(2);
},

2
src/components/Tips/Tips.vue

@ -80,7 +80,7 @@ export default {
location.reload();
// this.$router.go(0);
} catch (error) {
console.log(error);
console.error(error);
}
},

14
src/components/Upload/Upload.vue

@ -1,22 +1,30 @@
<template>
<view class="upload">
<view @tap="handleUpload">
<u-icon name="plus" color="#ffffff" size="24px" class="flex justify-center w-12 h-12 bg-blue-100 rounded-full shadow-md"></u-icon>
</view>
<!-- <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>
export default {
data() {
return { loading: false };
},
methods: {
// wbs
async handleUpload() {
try {
this.loading = true;
const data = await this.$u.api.import();
this.loading = false;
// WBS
//
console.log('data: ', data);
} catch (error) {
this.loading = false;
this.$emit('show-alert', error);
}
},

401
src/mock/mock.js

@ -1,401 +0,0 @@
export default [
{
path: '/tasks',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: {
plugins: [
`<button onclick="location.href='https://www.tall.wiki/wl/1'">js打开物流页面</button>`,
`<a href="https://www.tall.wiki/wl/5">a链接打开现海园区</a>`,
`<div class="p-3 my-4 text-2xl bg-yellow-400 text-white" onclick="alert(123)">样式继承及简单脚本</div>`,
`<div class="p-3 my-4 text-2xl bg-red-400 text-white" onclick="openModal()">先是modal, 函数执行</div>
<div style="display: none" id="modal">modal</div>
<script>
function openModal() {
const modal = document.getElementById('modal');
if (modal.style.display === 'block') {
modal.style.display = 'none';
} else {
modal.style.display = 'block';
}
console.log('modal显示了');
}
</script>`,
],
},
});
},
},
//根据id获取token
{
path: '/tall/v1.0/users/userId',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: {
account: 'wally',
id: 123,
phone: '18603454788',
refresh_token: 'string',
token: 'string',
wxInfo: {
city: 'string',
country: 'string',
headImgUrl: 'string',
language: 'string',
nickname: 'string',
province: 'string',
sex: 0,
},
},
});
},
},
//根据id获取项目信息
{
path: '/defaultwbs/project/findProjectById',
method: 'post',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: {
name: '默认项目',
projectId: 1235555,
},
});
},
},
//查询角色栏展示的角色
{
path: '/defaultwbs/role/show',
method: 'post',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: {
//不展示的角色
invisibleList: [
{
id: 123456789,
mine: 1,
name: 'string',
pm: 0,
sequence: 33,
},
], //展示的角色
visibleList: [
{
id: 1,
name: '项目经理',
mine: 0,
pm: 1,
sequence: 1,
},
{
id: 2,
name: '运维',
mine: 0,
pm: 0,
sequence: 2,
},
{
id: 3,
name: '导师一',
mine: 1,
pm: 0,
sequence: 3,
},
{
id: 4,
name: '导师二',
mine: 1,
pm: 0,
sequence: 4,
},
{
id: 5,
name: '导师三',
mine: 1,
pm: 0,
sequence: 5,
},
],
},
});
},
},
//配置角色栏展示的角色
{
path: '/defaultwbs/role/updateShow',
method: 'post',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: { description: 'data数据' },
});
},
},
//根据角色查找永久的日常任务
{
path: '/defaultwbs/task/permanent',
method: 'post',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: [
{
description: 'string',
detailId: 147258,
id: 258147,
name: 'string',
panel: {
backgroundColor: 'string',
border: 'string',
borderRadius: 'string',
col: 132,
height: 'string',
row: 147,
shadow: 'string',
width: 'string',
},
planDuration: 123,
planStart: 123456789,
plugins: [
[
{
col: 1,
colspan: 123,
param: 123,
pluginId: 13,
row: 2,
rowspan: 123,
},
],
],
process: 0,
realDuration: 123456789,
realStart: 123456789,
skip: -1,
skipTaskId: 123456789,
},
],
});
},
},
//根据时间和角色查找日常任务
{
path: '/defaultwbs/task/global',
method: 'post',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: [
{
description: 'string',
detailId: 147258,
id: 258147,
name: 'string',
panel: {
backgroundColor: 'string',
border: 'string',
borderRadius: 'string',
col: 132,
height: 'string',
row: 147,
shadow: 'string',
width: 'string',
},
planDuration: 123,
planStart: 123456789,
plugins: [
[
{
col: 1,
colspan: 123,
param: 123,
pluginId: 13,
row: 1,
rowspan: 123,
},
],
],
process: 0,
realDuration: 123456789,
realStart: 123456789,
skip: -1,
skipTaskId: 123456789,
},
],
});
},
},
//根据时间基准点和角色查找定期任务
{
path: '/defaultwbs/task/regular',
method: 'post',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: [
{
description: 'string',
detailId: 147258,
id: 258147,
name: 'string',
panel: {
backgroundColor: 'string',
border: 'string',
borderRadius: 'string',
col: 132,
height: '100',
row: 147,
shadow: 'string',
width: 'string',
},
planDuration: 123,
planStart: 123456789,
plugins: [
[
{
col: 123,
colspan: 123,
param: 123,
pluginId: 1,
row: 123,
rowspan: 123,
},
],
],
process: 0,
realDuration: 123456789,
realStart: 123456789,
skip: -1,
skipTaskId: 123456789,
},
{
description: 'string',
detailId: 147258,
id: 254565,
name: 'string',
panel: {
backgroundColor: 'string',
border: 'string',
borderRadius: 'string',
col: 132,
height: '100',
row: 147,
shadow: 'string',
width: 'string',
},
planDuration: 123,
planStart: 123456789,
plugins: [
[
{
col: 123,
colspan: 123,
param: 123,
pluginId: 2,
row: 123,
rowspan: 123,
},
],
],
process: 0,
realDuration: 123456789,
realStart: 123456789,
skip: -1,
skipTaskId: 123456789,
},
{
description: 'string',
detailId: 147258,
id: 111125,
name: 'string',
panel: {
backgroundColor: 'string',
border: 'string',
borderRadius: 'string',
col: 132,
height: '100',
row: 147,
shadow: 'string',
width: 'string',
},
planDuration: 123,
planStart: 123456789,
plugins: [
[
{
col: 123,
colspan: 123,
param: 123,
pluginId: 3,
row: 123,
rowspan: 123,
},
],
],
process: 0,
realDuration: 123456789,
realStart: 123456789,
skip: -1,
skipTaskId: 123456789,
},
],
});
},
},
//修改任务状态
{
path: '/defaultwbs/task/type',
method: 'post',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: { description: 'data数据' },
});
},
},
//根据id查询插件信息
{
path: '/defaultwbs/plugin',
method: 'post',
handler: (req, res) => {
return res.json({
code: 200,
msg: 'ok',
success: true,
data: {
html: '<div style="background:#0f0;height:100%"></div>',
id: 13,
intro: 'string',
js: 'string',
name: 'string',
styleType: -1,
version: 'string',
},
});
},
},
];

2
src/pages/project/project.vue

@ -161,7 +161,7 @@ export default {
await this.getRegulars(params);
} catch (error) {
console.log('error: ', error);
console.error('error: ', error);
}
},

2
src/utils/tall.js

@ -16,7 +16,7 @@ const $t = {
timeConfig, // 时间相关配置
ui, // ui界面提示相关
chooseAndUpload: upload.chooseAndUpload, // 选择并上传单个文件相关的封装
domain: 'https://www.tall.wiki/tall3/v3.0.0/defaultwbs',
domain: 'https://www.tall.wiki/gateway/defaultwbs',
};
uni.$t = $t;

2
src/utils/ui.js

@ -22,7 +22,7 @@ export default {
* 显示加载雪花
* @param {string} title
*/
showLoading(title) {
showLoading(title = '玩命加载中...') {
return uni.showLoading({
title,
mask: true,

19
src/utils/upload.js

@ -8,6 +8,9 @@ export default {
* @returns
*/
chooseAndUpload(url, formData = {}, extension = ['.xls', '.xlsx'], name = 'param') {
uni.hideLoading();
clearTimeout(timer);
let timer = null;
return new Promise((resolve, reject) => {
const token = uni.$t.storage.getStorageSync(uni.$t.app.tokenKey);
if (!token) {
@ -17,6 +20,13 @@ export default {
count: 1, //默认100
extension,
success: res => {
if (!timer) {
timer = setTimeout(() => {
uni.$t.ui.showLoading('正在上传...');
timer = null;
}, 800);
}
// 开始上传
uni.uploadFile({
url,
filePath: res.tempFilePaths[0],
@ -24,7 +34,10 @@ export default {
formData,
header: { Authorization: `Bearer ${token}` },
success: ({ data, statusCode }) => {
console.log('data, statusCode: ', data, statusCode);
console.log('s');
clearTimeout(timer);
uni.hideLoading();
if (statusCode === 200 && data) {
const { code, msg } = JSON.parse(data);
if (code !== 200) {
@ -37,11 +50,15 @@ export default {
}
},
fail: error => {
clearTimeout(timer);
uni.hideLoading();
reject(error);
},
});
},
fail: error => {
clearTimeout(timer);
uni.hideLoading();
reject(error);
},
});

Loading…
Cancel
Save