Browse Source

feat: 添加任务对接口

wrr
song 4 years ago
parent
commit
7fc959d4e2
  1. 3
      CHANGELOG.md
  2. BIN
      src/__MACOSX/components/._.DS_Store
  3. BIN
      src/__MACOSX/components/p-inputSearch/._.DS_Store
  4. 2
      src/apis/plugin.js
  5. 2
      src/apis/task.js
  6. 1
      src/components/Globals/Globals.vue
  7. 101
      src/components/InputSearch/InputSearch.vue
  8. 2
      src/components/Plugin/Plugin.vue
  9. 184
      src/components/TimeLine/component/TaskTools.vue
  10. 2
      src/components/TimeLine/component/TimeBox.vue
  11. 46
      src/components/TimeLine/component/TimeStatus.vue
  12. 12
      src/components/Title/Title.vue
  13. 106
      src/components/Title/components/CreateTask.vue
  14. 2
      src/pages/project/project.vue
  15. 1
      src/plugins/p-task-start-time-delay/p-task-start-time-delay.vue
  16. 41
      src/store/task/mutations.js
  17. 1
      src/utils/cacheAndRequest.js

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-09-06)
# 0.1.0 (2021-09-07)
### 🌟 新功能
范围|描述|commitId
@ -36,6 +36,7 @@
- | 提交到本地 | [9cbe411](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/9cbe411)
- | 插件参数处理调整 | [a3e68d3](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/a3e68d3)
- | 插件数据获取 | [5b91bdc](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/5b91bdc)
- | 新建任务 部分提交参数 | [25c78b8](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/25c78b8)
- | 新建任务 部分提交参数 | [6a422f6](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/6a422f6)
- | 新建任务,分享项目弹出层样式修改 | [efbc679](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/efbc679)
- | 新建形目 | [f7d7108](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/f7d7108)

BIN
src/__MACOSX/components/._.DS_Store

Binary file not shown.

BIN
src/__MACOSX/components/p-inputSearch/._.DS_Store

Binary file not shown.

2
src/apis/plugin.js

@ -4,7 +4,7 @@ const url = process.env.VUE_APP_API_URL;
const install = (Vue, vm) => {
vm.$u.api = { ...vm.$u.api } || {};
// 获取插件信息
vm.$u.api.getOtherPlugin = param => vm.$u.post(`${url}/pluginshop/plugin/query`, param);
vm.$u.api.getOtherPlugin = param => vm.$u.post(`${url}/pluginshop/plugin/query?pluginId=${param.pluginId}&styleType=${param.styleType}`);
// 查询子任务
vm.$u.api.findSonTask = param => vm.$u.post(`${uni.$t.domain}/task/findSonTask`, param);
// 查询子项目

2
src/apis/task.js

@ -10,6 +10,8 @@ const install = (Vue, vm) => {
vm.$u.api.saveTask = param => vm.$u.post(`${uni.$t.domain}/task/save`, param);
//克隆任务
vm.$u.api.cloneTask = param => vm.$u.post(`${uni.$t.domain}/task/clone`, param);
//模糊查询 查找项目下的任务
vm.$u.api.queryTaskOfProject = param => vm.$u.post(`${uni.$t.domain}/task/queryTaskOfProject`, param);
};
export default { install };

1
src/components/Globals/Globals.vue

@ -22,6 +22,7 @@
:key="plugin.pluginTaskId"
:plugin-task-id="plugin.pluginTaskId"
:plugin-id="plugin.pluginId"
:param="plugin.param"
:style-type="plugin.styleType || 0"
v-for="plugin in pluginArr"
/>

101
src/components/InputSearch/InputSearch.vue

@ -0,0 +1,101 @@
<template>
<view class="input-group flex-1">
<input :placeholder="placeholder" @input="search" @blur="hideList" v-model="backName" />
<view class="ul">
<view class="li" v-for="(item, index) in dataSource" :key="index" @tap="select(item)">{{ item.name }}</view>
</view>
</view>
</template>
<script>
export default {
props: {
placeholder: String, //
searchKey: String, //key
dataSource: {
type: Array,
default: function () {
//
return [];
},
},
},
data() {
return {
list: [],
name: '',
backName: '',
};
},
destroyed() {
clearTimeout(this.t);
},
methods: {
search(e) {
let val = e.detail.value;
console.log('val: ', val);
this.$emit('searchPrevTask', val);
// let arr = [];
// for (let i = 0; i < dataSource.length; i++) {
// if (dataSource[i].name.indexOf(val) !== -1) {
// arr.push(dataSource[i]);
// }
// }
// if (!val) {
// this.list = [];
// } else {
// this.list = arr;
// }
},
select(item) {
console.log('item: ', item);
this.backName = item.name;
this.$emit('select', item);
},
hideList() {
setTimeout(() => {
this.$emit('clearAllTasks');
}, 200);
},
},
};
</script>
<style lang="scss" scoped>
.input-group {
position: relative;
input {
border-bottom: 1upx solid #dcdfe6;
height: 90upx;
padding-left: 10upx;
font-size: 30upx;
box-sizing: border-box;
}
.uni-input-placeholder {
color: rgb(192, 196, 204);
font-size: 28upx;
}
.ul {
position: absolute;
left: 0;
top: 100%;
width: 100%;
z-index: 999;
background: #fff;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
max-height: 100px;
overflow-y: auto;
.li {
border-bottom: 1upx solid #f1f1f1;
padding: 16upx;
}
}
}
</style>

2
src/components/Plugin/Plugin.vue

@ -9,10 +9,10 @@
:data-pstart="task.planStart"
:data-rdu="task.realDuration"
:data-rid="roleId"
:data-rstart="task.realStart"
:data-tid="task.id"
:data-tname="task.name"
:data-token="token"
:data-rstart="task.realStart"
:data-uid="userId"
style="height: 100%"
v-html="pluginContent"

184
src/components/TimeLine/component/TaskTools.vue

@ -1,11 +1,185 @@
<template>
<view class="flex justify-between" style="min-width: 90px">
<u-icon custom-prefix="custom-icon" name="C-bxl-redux" size="17px"></u-icon>
<u-icon custom-prefix="custom-icon" name="attachment" size="21px"></u-icon>
<u-icon custom-prefix="custom-icon" name="moneycollect" size="20px"></u-icon>
<view>
<view class="flex justify-between" style="min-width: 90px; position: relative">
<u-icon custom-prefix="custom-icon" name="C-bxl-redux" size="17px"></u-icon>
<u-icon custom-prefix="custom-icon" name="attachment" size="21px"></u-icon>
<!-- <u-icon custom-prefix="custom-icon" name="moneycollect" size="20px"></u-icon> -->
<u-icon name="xuanxiang" custom-prefix="custom-icon" size="21px" @click="operation"></u-icon>
<!-- 右上角 ... 弹窗 -->
<view class="popup border shadow-md" v-if="show">
<view class="flex justify-center pb-3 border-b-1">
<span @click="createTask">新建任务</span>
</view>
<view class="flex pt-3 justify-center">
<span>克隆任务</span>
</view>
</view>
</view>
<!-- 遮罩 -->
<view class="mask" v-if="maskShow" @click="closeMask"></view>
<!-- 新建任务弹窗 -->
<CreateTask
:startTime="startTime"
:endTime="endTime"
:task="task"
@showTime="showTime"
@closeMask="closeMask"
class="thirdPopup flex transition-transform"
v-if="createTaskShow"
/>
<u-picker title="开始时间" mode="time" v-model="showStart" :params="params" @confirm="confirmStartTime"></u-picker>
<u-picker title="结束时间" mode="time" v-model="showEnd" :params="params" @confirm="confirmEndTime"></u-picker>
</view>
</template>
<script>
export default {};
import CreateTask from '../../Title/components/CreateTask.vue';
export default {
components: { CreateTask },
props: {
task: {
type: Object,
default: () => {},
},
},
data() {
return {
show: false, // ...
createTaskShow: false, //
secondShow: false, //
maskShow: false, //
showStart: false,
showEnd: false,
startTime: '', //
endTime: '', //
params: {
year: true,
month: true,
day: true,
hour: true,
minute: true,
second: true,
},
};
},
methods: {
//
operation() {
// this.$t.ui.showToast('');
this.show = !this.show;
},
//
createTask() {
// ...
this.show = false;
//
this.maskShow = true;
//
this.createTaskShow = true;
},
//
closeMask() {
//
this.maskShow = false;
//
this.secondShow = false;
//
this.createTaskShow = false;
},
showTime() {
this.showStart = !this.showStart;
},
//
confirmStartTime(e) {
this.startTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
this.showEnd = true;
},
//
confirmEndTime(e) {
this.endTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
},
},
};
</script>
<style lang="scss" scoped>
.mask {
width: 100%;
height: 100vh;
z-index: 21;
position: fixed;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.3);
}
.thirdPopup {
background: #ffffff;
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 33;
border-radius: 5px;
width: 90%;
}
.popup {
width: 110px;
background: #fff;
position: absolute;
right: 0;
top: 35px;
z-index: 99;
padding: 15px 0;
color: black;
animation: opacity 1s ease-in;
}
@keyframes opacity {
0% {
opacity: 0;
}
50% {
opacity: 0.8;
}
100% {
opacity: 1;
}
}
::v-deep .u-slot-content {
min-width: 0;
}
::v-deep .u-dropdown__content {
min-height: 120px !important;
height: auto !important;
overflow-y: auto;
background: #fff !important;
transition: none !important;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
::v-deep .u-dropdown__menu__item .u-flex {
justify-content: space-between;
width: 100%;
height: 100%;
flex-wrap: nowrap;
border: 1px solid #afbed1;
padding: 0 8px;
}
::v-deep .u-dropdown__content__mask {
display: none;
}
</style>

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

@ -10,7 +10,7 @@
<view v-else>{{ $moment(+task.planStart).format('D日') }}</view>
<!-- 任务功能菜单 -->
<TaskTools v-if="task.process !== 4" />
<TaskTools v-if="task.process !== 4" :task="task" />
</view>
</view>
<view class="border-l-2 border-gray-300 plugin">

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

@ -18,7 +18,7 @@
<view class="u-progress-dot"></view>
<view class="u-progress-info">
<u-icon :name="orderStyle.icon" v-if="orderStyle.icon" size="15px"></u-icon>
<template v-else>{{ computeDurationText() }}</template>
<template v-else>{{ durationText }}</template>
</view>
</view>
</u-circle-progress>
@ -31,7 +31,7 @@
<u-icon :name="orderStyle.icon" v-if="task.process !== 4" size="15px"></u-icon>
<u-icon :name="orderStyle.icon" v-else size="15px"></u-icon>
</span>
<template v-else>{{ computeDurationText() }}</template>
<template v-else>{{ durationText }}</template>
</view>
</view>
</view>
@ -54,6 +54,7 @@ export default {
proceed: [{ text: '暂停' }, { text: '重新开始任务', color: 'blue' }, { text: '结束' }],
again: [{ text: '重新开始任务', color: 'blue' }],
timer: null,
durationText: 0,
};
},
@ -110,6 +111,19 @@ export default {
},
},
mounted() {
// TODO:
const time = this.computeDurationText();
this.updateDurationText(time);
},
destroyed() {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
},
methods: {
...mapMutations('task', ['setTip']),
@ -167,20 +181,26 @@ export default {
// = -
// = realStart + planDuration - Date.now()
computeDurationText() {
if (this.timer) {
clearTimeout(this.timer);
this.timer = null;
}
const { realStart, planDuration } = this.task;
const leftTime = +realStart + +planDuration - Date.now(); //
const { num, time } = this.$t.time.computeDurationText(leftTime);
this.$nextTick(() => {
if (!time) return;
this.timer = setTimeout(() => {
this.computeDurationText();
}, time);
});
return num;
if (num <= 0) {
clearInterval(this.timer);
this.timer = null;
}
this.durationText = num;
return time;
},
updateDurationText(time) {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
if (!time) return;
setInterval(() => {
this.computeDurationText();
}, time);
},
},
};

12
src/components/Title/Title.vue

@ -1,6 +1,6 @@
<template>
<view>
<u-navbar :custom-back="onBack" class="overflow-hidden">
<u-navbar :is-back="false" :custom-back="onBack" class="overflow-hidden">
<view class="flex justify-start flex-1 px-3 font-bold min-0">
<view class="truncate">{{ project.name }}</view>
</view>
@ -21,7 +21,7 @@
<view class="popup border shadow-md" v-if="show">
<view class="flex pb-3 border-b-1">
<u-icon name="plus-circle" size="36" style="margin: 0 15px 3px 0"></u-icon>
<view @click="newprojects">新建任务</view>
<view @click="createTask">新建任务</view>
</view>
<view class="flex pt-3">
<u-icon name="share" size="32" style="margin: 0 15px 3px 0"></u-icon>
@ -69,7 +69,7 @@ export default {
day: true,
hour: true,
minute: true,
second: false,
second: true,
},
};
},
@ -86,13 +86,13 @@ export default {
//
confirmStartTime(e) {
this.startTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`;
this.startTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
this.showEnd = true;
},
//
confirmEndTime(e) {
this.endTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`;
this.endTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
},
//
@ -125,7 +125,7 @@ export default {
},
//
newprojects() {
createTask() {
// ...
this.show = false;
//

106
src/components/Title/components/CreateTask.vue

@ -5,20 +5,19 @@
<view class="mb-3 font-bold text-base flex justify-center">新建任务</view>
<div class="flex items-center mb-2">
<div>名称<span class="text-red-500">*</span></div>
<u-input v-model="name" :type="type" :border="border" />
<u-input max-length="5" v-model="name" :type="type" :border="border" />
</div>
<!-- 起止时间 -->
<div class="mb-2">
<div>起止时间</div>
<u-input placeholder="请选择起止时间" v-model="timeValue" :type="type" :border="border" @click="$emit('showTime')" />
<!-- <u-picker mode="time" v-model="showChooseTime"></u-picker> -->
<!-- <u-input v-model="timeValue" :type="type" :border="border" /> -->
</div>
<!-- 多选框 -->
<div class="flex justify-between items-center">
<div>负责人<span class="text-red-500">*</span></div>
<div label="负责人" class="flex-1">
<u-dropdown ref="uDropdown" placeholder="请选择负责人">
<div class="flex-1" v-if="hasRole">{{ roleName }}</div>
<div label="负责人" class="flex-1" v-else>
<u-dropdown disabled ref="uDropdown" placeholder="请选择负责人">
<u-dropdown-item :title="roleList">
<view class="slot-content bg-white">
<div
@ -45,7 +44,7 @@
<!-- 描述 -->
<div class="flex items-center mb-2">
<div>描述</div>
<u-input v-model="description" :type="type" :border="border" />
<u-input v-model="description" max-length="48" type="textarea" height="36" auto-height :border="border" />
</div>
<!-- 所属项目 -->
<div class="w flex items-center mb-2">
@ -53,14 +52,20 @@
<div>{{ project.name }}</div>
</div>
<!-- 所属任务 -->
<div class="w flex items-center mb-2">
<div class="w flex items-center mb-2" v-if="task && task.id">
<div>所属任务</div>
<div></div>
<div>{{ task.name }}</div>
</div>
<!-- 上道工序 -->
<div class="flex items-center mb-2">
<div>上道工序</div>
<u-input v-model="processTaskId" :type="type" :border="border" />
<InputSearch
@searchPrevTask="searchPrevTask"
:dataSource="allTasks"
@select="handleChange"
@clearAllTasks="clearAllTasks"
placeholder="请输入上道工序"
/>
</div>
<!-- 检查人多选框 -->
<div class="flex justify-between items-center">
@ -109,7 +114,7 @@
</template>
<script>
import { mapState, mapGetters } from 'vuex';
import { mapState, mapGetters, mapMutations } from 'vuex';
export default {
props: {
@ -121,11 +126,13 @@ export default {
type: String,
default: '',
},
task: {
type: Object,
default: null,
},
},
data() {
return {
projects: ['我是睡', '我叫什么', '我的名字是'],
title: 'tall1',
arrow: true,
show: false,
isGlobal: false, //
@ -145,12 +152,16 @@ export default {
checkerIdList: [], // id
deliverables: [], //
deliverSort: [{ name: '' }], //
allTasks: [],
roleName: '', //
hasRole: false, //
};
},
computed: {
...mapState('role', ['visibleRoles']),
...mapState('role', ['visibleRoles', 'roleId']),
...mapState('project', ['project']),
...mapState('task', ['tasks']),
...mapGetters('project', ['projectId']),
},
@ -172,9 +183,20 @@ export default {
}
this.roleOptions = this.$u.deepClone(this.visibleRoles);
this.checkoutOptions = this.$u.deepClone(this.visibleRoles);
//
if (this.roleId) {
const item = this.visibleRoles.find(r => r.id === this.roleId);
if (item) {
this.roleName = item.name;
this.hasRole = true;
}
}
},
methods: {
...mapMutations('task', ['addNewTasks']),
//
change(index) {
let arr = [...this.roleOptions];
@ -228,6 +250,32 @@ export default {
this.show = false;
},
/**
* 模糊查询 查找项目下的任务
* @param name 任务名
* @param projectId 项目id
*/
async searchPrevTask(val) {
try {
const params = { name: val, projectId: this.projectId };
const data = await this.$u.api.queryTaskOfProject(params);
this.allTasks = data;
return data;
} catch (error) {
console.error('error: ', error);
}
},
//
handleChange(data) {
console.log('data', data);
this.processTaskId = data.detailId;
},
//
clearAllTasks() {
this.allTasks = [];
},
//
addDeliverInput() {
if (this.deliverSort[this.deliverSort.length - 1].name) {
@ -237,12 +285,25 @@ export default {
//
async setParameters() {
const { projectId, name, startTime, endTime, roleIdList, description, processTaskId, checkerIdList, isGlobal } = this;
const {
projectId,
task,
name,
startTime,
endTime,
hasRole,
roleIdList,
roleId,
description,
processTaskId,
checkerIdList,
isGlobal,
} = this;
if (!name) {
this.$t.ui.showToast('请输入名称');
return;
}
if (!roleIdList || !roleIdList.length) {
if ((!roleIdList || !roleIdList.length) && !hasRole) {
this.$t.ui.showToast('请选择负责人');
return;
}
@ -260,16 +321,15 @@ export default {
name,
startTime: startTime ? this.$moment(startTime).format('x') - 0 : '',
endTime: endTime ? this.$moment(endTime).format('x') - 0 : '',
roleIdList,
roleIdList: hasRole ? [roleId] : roleIdList,
description,
projectId,
parentTaskId: '', //
parentTaskId: task && task.id ? task.id : '', //
processTaskId, // TODO
checkerIdList,
global: isGlobal ? 1 : 0,
deliverList,
};
console.log('params: ', params);
await this.handleSubmit(params);
},
@ -290,9 +350,17 @@ export default {
async handleSubmit(params) {
try {
const data = await this.$u.api.saveTask(params);
console.log('data: ', data);
// TODO or
this.$emit('closeMask');
const newTasks = {
data: data[0],
processTaskId: params.processTaskId,
};
// store
//
if (!this.task || !this.task.id) {
this.addNewTasks(newTasks);
}
} catch (error) {
this.$emit('closeMask');
console.error('error: ', error);

2
src/pages/project/project.vue

@ -37,10 +37,8 @@ export default {
onLoad(options) {
if (options.share && options.share === '1') {
console.log('是分享来的');
this.shareInit(options);
} else {
console.log('不是分享来的');
this.init(options);
}
},

1
src/plugins/p-task-start-time-delay/p-task-start-time-delay.vue

@ -1,4 +1,5 @@
<template>
<!-- <view>任务开始时间延迟插件</view> -->
<view v-if="realStart && planStart">
<!-- 任务开始时间延迟插件 -->
<!-- 超时 -->

41
src/store/task/mutations.js

@ -100,6 +100,47 @@ const mutations = {
}
},
/**
* 添加任务后更新tasks
* @param {Object} state
* @param {Array} data 新添加的task
*/
addNewTasks(state, data) {
let res = data.data;
// 判断有没有选择上道工序
if (data.processTaskId) {
const index = state.tasks.find(item => item.detailId === data.processTaskId);
if (index) {
state.tasks.splice(index + 1, 0, res);
}
} else {
console.log('res.planStart: ', res.planStart);
console.log('state.tasks[0].planStart: ', state.tasks[0].planStart);
if (res.planStart - 0 < state.tasks[0].planStart - 0) {
// 开始时间小于列表的第一个 插入最前面
state.tasks.splice(0, 0, res);
} else if (res.planStart - 0 === state.tasks[0].planStart - 0) {
// 开始时间等于列表的第一个 插入第二
state.tasks.splice(1, 0, res);
} else if (res.planStart - 0 >= state.tasks[state.tasks.length - 1].planStart - 0) {
// 开始时间大等于列表的最后一个 插入最后
state.tasks.splice(-1, 0, res);
} else {
// 判断开始时间在列表中的哪个位置
for (let i = 0; i < state.tasks.length; i++) {
const item = state.tasks[i];
if (res.planStart - 0 > item.planStart - 0) {
if (res.planStart - 0 <= state.tasks[i + 1].planStart - 0) {
state.tasks.splice(i + 1, 0, res);
console.log('res: ', res);
return;
}
}
}
}
}
},
/**
* 设置日常任务数据
* @param {Object} state

1
src/utils/cacheAndRequest.js

@ -65,7 +65,6 @@ export default {
uni.$u.api
.getRegularTask(params)
.then(data => {
console.log('api data: ', uni.$u.deepClone(data));
remote = true;
fn(null, uni.$u.deepClone(data));

Loading…
Cancel
Save