Browse Source

feat: 日常任务增加默认插件显示

develop
aBin 4 years ago
parent
commit
ce29e5b4cd
  1. 1
      CHANGELOG.md
  2. 30
      src/components/Globals/Globals.vue
  3. 41
      src/components/Plugin/Plugin.vue
  4. 2
      src/components/Roles/Roles.vue
  5. 46
      src/components/TimeLine/component/TimeBox.vue
  6. 31
      src/pages/project/project.vue
  7. 35
      src/store/home/mutations.js
  8. 18
      src/store/home/state.js

1
CHANGELOG.md

@ -50,6 +50,7 @@
- | 定期任务接口 | [aa4981c](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/aa4981c) - | 定期任务接口 | [aa4981c](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/aa4981c)
- | 骨架屏替换 | [e9fdd71](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/e9fdd71) - | 骨架屏替换 | [e9fdd71](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/e9fdd71)
- | 角色栏修改 | [19228d6](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/19228d6) - | 角色栏修改 | [19228d6](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/19228d6)
- | 日常任务html数据查验 | [880ce5c](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/880ce5c)
- | 上下滚动时间轴 | [d533a01](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/d533a01) - | 上下滚动时间轴 | [d533a01](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/d533a01)
- | 上下滑动加载定期任务 | [4090d89](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/4090d89) - | 上下滑动加载定期任务 | [4090d89](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/4090d89)
- | 时间轴上下滚动数据加载bug修改 | [e82ede4](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/e82ede4) - | 时间轴上下滚动数据加载bug修改 | [e82ede4](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/e82ede4)

30
src/components/Globals/Globals.vue

@ -3,16 +3,22 @@
<u-card :show-foot="false" :show-head="false" :style="{ height: isShrink ? '96rpx' : '300rpx' }" border-radius="25" margin="0"> <u-card :show-foot="false" :show-head="false" :style="{ height: isShrink ? '96rpx' : '300rpx' }" border-radius="25" margin="0">
<view slot="body"> <view slot="body">
<scroll-view :scrollY="true" :style="{ height: isShrink ? '40rpx' : '240rpx' }"> <scroll-view :scrollY="true" :style="{ height: isShrink ? '40rpx' : '240rpx' }">
<skeleton :banner="false" :loading="!plugins.length" :row="4" animate class="mt-2 u-line-2 skeleton"></skeleton> <skeleton :banner="false" :loading="!tasks.length" :row="4" animate class="mt-2 u-line-2 skeleton"></skeleton>
<view class="p-0 u-col-between"> <view v-for="item in tasks" :key="item.id">
<view class="grid grid-cols-3 gap-2 h-auto" v-if="plugins.length"> <view v-if="item.plugins">
<Plugin <view class="p-0 u-col-between">
:class="getClass(plugin.col, plugin.row)" <view class="grid grid-cols-3 gap-2 h-auto">
:key="pluginIndex" <!-- ++{{ plugins }} -->
:pluginId="plugin.pluginId" <Plugin
:styleType="plugin.styleType || 0" :item="item"
v-for="(plugin, pluginIndex) in plugins" :class="getClass(plugin.colspan, plugin.rowspan)"
/> :key="plugin.pluginTaskId"
:pluginId="plugin.pluginId"
:styleType="plugin.styleType || 0"
v-for="plugin in item.plugins"
/>
</view>
</view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
@ -28,12 +34,10 @@ import Skeleton from '@/components/Skeleton/Skeleton';
export default { export default {
name: 'Global', name: 'Global',
components: { Skeleton }, components: { Skeleton },
props: { plugins: { type: Array, default: () => [] } }, props: { tasks: { type: Array, default: () => [] } },
data() { data() {
return { return {
// loading: true, // loading: true,
pluginId: 0,
styleType: 0,
task: null, task: null,
}; };
}, },

41
src/components/Plugin/Plugin.vue

@ -1,16 +1,22 @@
<template> <template>
<view v-if="pluginContent && pluginContent.html" style="height: 100%"> <view>
<view v-if="item && item.name"> <view style="height: 100%" v-if="pluginContent">
<p-task-title :item="item" v-if="pluginId === '1'" /> <view v-if="pluginContent && pluginContent.html">
<p-task-description :item="item" v-if="pluginId === '2'" /> <view style="height: 100%" v-html="pluginContent.html"></view>
<p-task-duration-delay :item="item" v-if="pluginId === '3'" /> </view>
<p-task-start-time-delay :item="item" v-if="pluginId === '4'" /> <view v-else>
<p-deliverable :item="item" v-if="pluginId === '5'" /> <view v-if="item && item.name">
<p-subtasks :item="item" v-if="pluginId === '6'" /> <p-task-title :item="item" v-if="pluginId === '1'" />
<p-subproject :item="item" v-if="pluginId === '7'" /> <p-task-description :item="item" v-if="pluginId === '2'" />
<p-task-countdown :item="item" v-if="pluginId === '8'" /> <p-task-duration-delay :item="item" v-if="pluginId === '3'" />
<p-task-start-time-delay :item="item" v-if="pluginId === '4'" />
<p-deliverable :item="item" v-if="pluginId === '5'" />
<p-subtasks :item="item" v-if="pluginId === '6'" />
<p-subproject :item="item" v-if="pluginId === '7'" />
<p-task-countdown :item="item" v-if="pluginId === '8'" />
</view>
</view>
</view> </view>
<view v-html="pluginContent.html" style="height: 100%"> </view>
</view> </view>
</template> </template>
@ -23,21 +29,26 @@ export default {
type: Object, type: Object,
}, },
pluginId: { pluginId: {
default: '0', default: '1',
type: String, type: String,
}, },
styleType: { styleType: {
default: 0, default: 0,
type: Number, type: Number,
}, },
pluginTaskId: {
default: '0',
type: String,
},
}, },
data() { data() {
return { pluginContent: null }; return { pluginContent: null };
}, },
async created() { async created() {
await this.getPlugin(); await this.getPlugin();
console.log(this.pluginContent.js); let domList = Array.from(document.getElementsByTagName('script'));
if (this.pluginContent.js) { const index = domList.findIndex(item => item.id === `p${this.pluginContent.pluginId}`);
if (this.pluginContent.js && index === -1) {
var scriptDom = document.createElement('script'); var scriptDom = document.createElement('script');
scriptDom.id = `p${this.pluginContent.pluginId}`; scriptDom.id = `p${this.pluginContent.pluginId}`;
scriptDom.innerHTML = this.pluginContent.js; scriptDom.innerHTML = this.pluginContent.js;
@ -51,8 +62,8 @@ export default {
pluginId, pluginId,
styleType, styleType,
}); });
this.$emit('changeLoading', false);
this.pluginContent = res; this.pluginContent = res;
console.log(this.pluginContent);
}, },
}, },
}; };

2
src/components/Roles/Roles.vue

@ -93,7 +93,7 @@ export default {
//index //index
this.setCurrentRole(index); this.setCurrentRole(index);
// //
this.setTasks([]); this.setTasks();
// //
await this.$emit('getTasksByRole'); await this.$emit('getTasksByRole');
} catch (error) { } catch (error) {

46
src/components/TimeLine/component/TimeBox.vue

@ -4,7 +4,9 @@
<view class="flex"> <view class="flex">
<TimeStatus :content="JSON.stringify(item.process)" :status="item.process" /> <TimeStatus :content="JSON.stringify(item.process)" :status="item.process" />
<view class="flex justify-between items-center flex-1 ml-2"> <view class="flex justify-between items-center flex-1 ml-2">
<view>{{ $moment(+item.planStart).format('MM-DD HH:mm') }} {{ $t.time.formatDuration(item.planDuration) }}</view> <view>
<span>{{ $moment(+item.planStart).format('MM-DD HH:mm') }}</span>
</view>
<view> <view>
<view class="flex justify-between" style="min-width: 180rpx"> <view class="flex justify-between" style="min-width: 180rpx">
<u-icon custom-prefix="custom-icon" name="C-bxl-redux" size="34"></u-icon> <u-icon custom-prefix="custom-icon" name="C-bxl-redux" size="34"></u-icon>
@ -23,33 +25,28 @@
@click="changeTimeNode(item.planStart)" @click="changeTimeNode(item.planStart)"
class="h-16" class="h-16"
margin="0" margin="0"
v-if="item.plugins && item.plugins.length"
> >
<!-- 任务面板插件 --> <!-- 任务面板插件 -->
<view slot="body"> <view slot="body">
<skeleton :banner="false" :loading="!item.plugins.length" :row="4" animate class="mt-2 u-line-2 skeleton"></skeleton> <view v-if="!item.plugins && !item.plugins.length && taskLoading">
<view class="p-0 u-col-between"> <skeleton :banner="false" :loading="true" :row="4" animate class="mt-2 u-line-2 skeleton"></skeleton>
<view class="grid grid-cols-3 gap-2 h-36" v-if="item.plugins.length">
<Plugin
:class="getClass(plugin.col, plugin.row)"
:key="pluginIndex"
:pluginId="plugin.pluginId"
:styleType="styleType"
v-for="(plugin, pluginIndex) in item.plugins"
/>
</view>
</view> </view>
<!-- <view :key="pluginIndex" class="p-0 u-col-between u-skeleton" v-for="(plugin, pluginIndex) in item.plugins"> <view class="p-0 u-col-between" v-else>
<view :key="p.pluginId" v-for="p in plugin"> <view :key="pIndex" v-for="(p, pIndex) in item.plugins">
<p-task-title :item="item" v-if="p.pluginId === 1" /> <view class="grid gap-2" v-if="p.length">
<p-task-description :item="item" v-if="p.pluginId === 2" /> <Plugin
<p-task-duration-delay :item="item" v-if="p.pluginId === 3" /> :class="getClass(plugin.col, plugin.row)"
<p-task-start-time-delay :item="item" v-if="p.pluginId === 4" /> :item="item"
<p-deliverable :item="item" v-if="p.pluginId === 5" /> :key="pluginIndex"
<p-subtasks :item="item" v-if="p.pluginId === 6" /> :pluginId="plugin.pluginId"
<p-subproject :item="item" v-if="p.pluginId === 7" /> :styleType="styleType"
<p-task-countdown :item="item" v-if="p.pluginId === 8" /> @changeLoading="taskLoading = false"
v-for="(plugin, pluginIndex) in p"
/>
</view>
</view> </view>
</view>--> </view>
</view> </view>
</u-card> </u-card>
</view> </view>
@ -68,7 +65,7 @@ export default {
name: 'TimeBox', name: 'TimeBox',
components: { TimeStatus, Skeleton }, components: { TimeStatus, Skeleton },
data() { data() {
return { currentComponent: '', styleType: 0 }; return { currentComponent: '', styleType: 0, taskLoading: true };
}, },
computed: mapState('home', ['roleId', 'timeNode', 'timeUnit', 'tasks']), computed: mapState('home', ['roleId', 'timeNode', 'timeUnit', 'tasks']),
@ -92,6 +89,7 @@ export default {
this.setTimeNode(time); this.setTimeNode(time);
}, },
//
getClass(col, row) { getClass(col, row) {
return [`row-span-${row}`, `col-span-${col}`]; return [`row-span-${row}`, `col-span-${col}`];
}, },

31
src/pages/project/project.vue

@ -3,7 +3,7 @@
<Title /> <Title />
<view class="container flex flex-col flex-1 overflow-hidden bg-gray-100"> <view class="container flex flex-col flex-1 overflow-hidden bg-gray-100">
<Roles @getTasksByRole="getTasksByRole" /> <Roles @getTasksByRole="getTasksByRole" />
<Globals :plugins="allPlugins.concat(timePlugins)" /> <Globals :tasks="allPlugins.concat(timePlugins)" />
<TimeLine @getTasks="getTasks" class="flex-1 overflow-hidden" ref="child" /> <TimeLine @getTasks="getTasks" class="flex-1 overflow-hidden" ref="child" />
</view> </view>
</view> </view>
@ -136,9 +136,12 @@ export default {
try { try {
this.allPlugins = []; this.allPlugins = [];
const res = await this.$u.api.getPermanent({ roleId: this.roleId }); const res = await this.$u.api.getPermanent({ roleId: this.roleId });
for (let item of res) { // for (let item of res) {
this.allPlugins = this.allPlugins.concat(item.plugins); // if (item.plugins) {
} // this.allPlugins = this.allPlugins.concat(item.plugins);
// }
// }
this.allPlugins = res;
console.log('allPlugins', this.allPlugins); console.log('allPlugins', this.allPlugins);
} catch (error) { } catch (error) {
console.log('error: ', error); console.log('error: ', error);
@ -157,11 +160,12 @@ export default {
const { roleId, timeNode, timeUnit } = this; const { roleId, timeNode, timeUnit } = this;
const params = { roleId, timeNode, timeUnit }; const params = { roleId, timeNode, timeUnit };
const res = await this.$u.api.getGlobal(params); const res = await this.$u.api.getGlobal(params);
for (let task of res) { // for (let task of res) {
for (let item of task.plugins) { // for (let item of task.plugins) {
this.timePlugins.push(...item); // this.timePlugins.push(...item);
} // }
} // }
this.timePlugins = res;
this.setDailyTasks(res); this.setDailyTasks(res);
} catch (error) { } catch (error) {
console.log('error: ', error); console.log('error: ', error);
@ -173,15 +177,20 @@ export default {
try { try {
await this.getTasks({ queryType: 0 }); await this.getTasks({ queryType: 0 });
await this.getTasks({ queryType: 1 }); await this.getTasks({ queryType: 1 });
// //
const upQuery = { const upQuery = {
timeNode: +this.tasks[0].planStart, timeNode: +this.tasks[0].planStart,
queryType: 0, queryType: 0,
queryNum: 6, queryNum: 6,
}; };
await this.getTasks(upQuery); await this.getTasks(upQuery);
//
// =+
const cycle = this.$t.time.computeCycle('天');
const timeNode = this.$t.time.add(+this.tasks[this.tasks.length - 1].planStart, 1, cycle).valueOf();
const downQuery = { const downQuery = {
timeNode: +this.tasks[this.tasks.length - 1].planStart, timeNode,
queryType: 1, queryType: 1,
queryNum: 6, queryNum: 6,
}; };

35
src/store/home/mutations.js

@ -125,7 +125,12 @@ const mutations = {
if (!data || !data.length) { if (!data || !data.length) {
state.topEnd = true; state.topEnd = true;
} }
state.tasks = [...data.concat(state.tasks)] || []; console.log('!state.tasks.plugins.length: ', !state.tasks[0].name);
if (!state.tasks[0].name) {
state.tasks = [...data];
} else {
state.tasks = [...data.concat(state.tasks)];
}
}, },
/** /**
@ -137,16 +142,36 @@ const mutations = {
if (!data || !data.length) { if (!data || !data.length) {
state.bottomEnd = true; state.bottomEnd = true;
} }
state.tasks = [...state.tasks.concat(data)] || []; if (!state.tasks[0].name) {
state.tasks = [...data];
} else {
state.tasks = [...state.tasks.concat(data)];
}
}, },
/** /**
* 清空定期任务数据 * 清空定期任务数据
* @param {Object} state * @param {Object} state
* @param {Array} data 服务端返回的模板数组
*/ */
setTasks(state, data) { setTasks(state) {
state.tasks = data || []; const data = [
{
panel: {},
plugins: [],
planStart: new Date().getTime(),
},
{
panel: {},
plugins: [],
planStart: new Date().getTime(),
},
{
panel: {},
plugins: [],
planStart: new Date().getTime(),
},
];
state.tasks = data;
}, },
/** /**

18
src/store/home/state.js

@ -14,7 +14,23 @@ const state = {
roleId: '', // 当前展示查看的角色id roleId: '', // 当前展示查看的角色id
timeNode: new Date().getTime(), // 时间基准点 timeNode: new Date().getTime(), // 时间基准点
timeUnit: 4, // // 时间颗粒度 timeUnit: 4, // // 时间颗粒度
tasks: [], // 定期任务 tasks: [
{
panel: {},
plugins: [],
planStart: new Date().getTime(),
},
{
panel: {},
plugins: [],
planStart: new Date().getTime(),
},
{
panel: {},
plugins: [],
planStart: new Date().getTime(),
},
], // 定期任务
topEnd: false, // 时间轴向上查任务到顶了 topEnd: false, // 时间轴向上查任务到顶了
bottomEnd: false, // 时间轴向下查任务到底了 bottomEnd: false, // 时间轴向下查任务到底了
dailyTasks: [], // 日常任务 dailyTasks: [], // 日常任务

Loading…
Cancel
Save