mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-15 05:12:49 +00:00
perf: 添加任务模板
This commit is contained in:
parent
e78d850138
commit
902844e008
@ -12,6 +12,11 @@
|
|||||||
@on-visible-change="cascaderShow=!cascaderShow"
|
@on-visible-change="cascaderShow=!cascaderShow"
|
||||||
filterable/>
|
filterable/>
|
||||||
</div>
|
</div>
|
||||||
|
<ul v-if="taskTemplateList.length > 0" class="task-add-template">
|
||||||
|
<li v-for="item in taskTemplateList" :key="item.id" @click="setTaskTemplate(item)">
|
||||||
|
{{ item.name }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
<div class="task-add-form">
|
<div class="task-add-form">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<Input
|
<Input
|
||||||
@ -211,6 +216,7 @@ import {mapState} from "vuex";
|
|||||||
import UserSelect from "../../../components/UserSelect.vue";
|
import UserSelect from "../../../components/UserSelect.vue";
|
||||||
import TaskExistTips from "./TaskExistTips.vue";
|
import TaskExistTips from "./TaskExistTips.vue";
|
||||||
import TEditorTask from "../../../components/TEditorTask.vue";
|
import TEditorTask from "../../../components/TEditorTask.vue";
|
||||||
|
import nostyle from "../../../components/VMEditor/engine/nostyle";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TaskAdd",
|
name: "TaskAdd",
|
||||||
@ -285,7 +291,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['cacheProjects', 'projectId', 'cacheColumns', 'taskPriority', 'formOptions']),
|
...mapState(['cacheProjects', 'projectId', 'cacheColumns', 'taskPriority', 'taskTemplates', 'formOptions']),
|
||||||
|
|
||||||
taskDays() {
|
taskDays() {
|
||||||
const {times} = this.addData;
|
const {times} = this.addData;
|
||||||
@ -297,6 +303,10 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
taskTemplateList() {
|
||||||
|
return this.taskTemplates.filter(({project_id}) => project_id == this.addData.project_id) || []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -315,6 +325,12 @@ export default {
|
|||||||
'addData.project_id'(projectId) {
|
'addData.project_id'(projectId) {
|
||||||
if (projectId > 0) {
|
if (projectId > 0) {
|
||||||
$A.IDBSave("cacheAddTaskProjectId", projectId);
|
$A.IDBSave("cacheAddTaskProjectId", projectId);
|
||||||
|
this.$store.dispatch("updateTaskTemplates", projectId).then(() => {
|
||||||
|
const defaultTemplate = this.taskTemplateList.find(({is_default}) => is_default);
|
||||||
|
if (defaultTemplate) {
|
||||||
|
this.setTaskTemplate(defaultTemplate);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'addData.column_id'(columnId) {
|
'addData.column_id'(columnId) {
|
||||||
@ -609,6 +625,13 @@ export default {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setTaskTemplate(item) {
|
||||||
|
this.addData.name = item.title
|
||||||
|
this.addData.content = nostyle(item.content, {
|
||||||
|
sanitize: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
17
resources/assets/js/store/actions.js
vendored
17
resources/assets/js/store/actions.js
vendored
@ -2506,6 +2506,23 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新任务模板
|
||||||
|
* @param state
|
||||||
|
* @param dispatch
|
||||||
|
* @param projectId
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async updateTaskTemplates({state, dispatch}, projectId) {
|
||||||
|
const {data} = await dispatch("call", {
|
||||||
|
url: 'project/task/template_list',
|
||||||
|
data: {
|
||||||
|
project_id: projectId
|
||||||
|
},
|
||||||
|
})
|
||||||
|
state.taskTemplates = state.taskTemplates.filter(template => template.project_id !== projectId).concat(data || [])
|
||||||
|
},
|
||||||
|
|
||||||
/** *****************************************************************************************/
|
/** *****************************************************************************************/
|
||||||
/** ************************************** 会话 **********************************************/
|
/** ************************************** 会话 **********************************************/
|
||||||
/** *****************************************************************************************/
|
/** *****************************************************************************************/
|
||||||
|
|||||||
1
resources/assets/js/store/state.js
vendored
1
resources/assets/js/store/state.js
vendored
@ -149,6 +149,7 @@ export default {
|
|||||||
taskLogs: [],
|
taskLogs: [],
|
||||||
taskOperation: {},
|
taskOperation: {},
|
||||||
taskArchiveView: 0,
|
taskArchiveView: 0,
|
||||||
|
taskTemplates: [],
|
||||||
|
|
||||||
// 任务等待状态
|
// 任务等待状态
|
||||||
taskOneLoad: {},
|
taskOneLoad: {},
|
||||||
|
|||||||
10
resources/assets/sass/dark.scss
vendored
10
resources/assets/sass/dark.scss
vendored
@ -621,4 +621,14 @@ body.dark-mode-reverse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.task-add {
|
||||||
|
.task-add-template {
|
||||||
|
> li {
|
||||||
|
&.active {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,6 +68,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.task-add-template {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
> li {
|
||||||
|
list-style: none;
|
||||||
|
padding: 7px 15px;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
border-radius: 20px;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: $primary-color;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.task-add-form,
|
.task-add-form,
|
||||||
.task-add-advanced {
|
.task-add-advanced {
|
||||||
.calculate-dropdown {
|
.calculate-dropdown {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user