no message

This commit is contained in:
kuaifan 2021-06-21 10:52:20 +08:00
parent fd523479df
commit c294807b28
8 changed files with 395 additions and 293 deletions

View File

@ -4,11 +4,11 @@
<div slot="head"> <div slot="head">
<div class="dialog-user"> <div class="dialog-user">
<div class="member-head"> <div class="member-head">
<div class="member-title">{{$L('项目成员')}}<span>({{projectDetail.project_user.length}})</span></div> <div class="member-title">{{$L('项目成员')}}<span>({{projectData.project_user.length}})</span></div>
<div class="member-view-all" @click="memberShowAll=!memberShowAll">{{$L('查看所有')}}</div> <div class="member-view-all" @click="memberShowAll=!memberShowAll">{{$L('查看所有')}}</div>
</div> </div>
<ul :class="['member-list', memberShowAll ? 'member-all' : '']"> <ul :class="['member-list', memberShowAll ? 'member-all' : '']">
<li v-for="item in projectDetail.project_user"> <li v-for="item in projectData.project_user">
<UserAvatar :userid="item.userid" :size="36"/> <UserAvatar :userid="item.userid" :size="36"/>
</li> </li>
</ul> </ul>
@ -22,7 +22,7 @@
</template> </template>
<script> <script>
import {mapState} from "vuex"; import {mapGetters, mapState} from "vuex";
import DialogWrapper from "./DialogWrapper"; import DialogWrapper from "./DialogWrapper";
export default { export default {
@ -35,11 +35,13 @@ export default {
}, },
computed: { computed: {
...mapState(['projectDetail', 'projectChatShow']), ...mapState(['projectChatShow']),
...mapGetters(['projectData'])
}, },
watch: { watch: {
'projectDetail.dialog_id' () { 'projectData.dialog_id' () {
this.getMsgList() this.getMsgList()
}, },
projectChatShow: { projectChatShow: {
@ -52,8 +54,8 @@ export default {
methods: { methods: {
getMsgList() { getMsgList() {
if (this.projectChatShow && this.projectDetail.dialog_id) { if (this.projectChatShow && this.projectData.dialog_id) {
this.$store.dispatch("getDialogMsgList", this.projectDetail.dialog_id); this.$store.dispatch("getDialogMsgList", this.projectData.dialog_id);
} }
} }
} }

View File

@ -3,12 +3,12 @@
<div class="project-head"> <div class="project-head">
<div class="project-titbox"> <div class="project-titbox">
<div class="project-title"> <div class="project-title">
<h1>{{projectDetail.name}}</h1> <h1>{{projectData.name}}</h1>
<div v-if="projectLoad > 0" class="project-load"><Loading/></div> <!--<div class="project-load"><Loading/></div>-->
</div> </div>
<ul class="project-icons"> <ul class="project-icons">
<li> <li>
<UserAvatar :userid="projectDetail.owner_userid" :size="36"> <UserAvatar :userid="projectData.owner_userid" :size="36">
<p>{{$L('项目负责人')}}</p> <p>{{$L('项目负责人')}}</p>
</UserAvatar> </UserAvatar>
</li> </li>
@ -30,7 +30,7 @@
<li class="project-icon"> <li class="project-icon">
<EDropdown @command="projectDropdown" trigger="click" transfer> <EDropdown @command="projectDropdown" trigger="click" transfer>
<Icon class="menu-icon" type="ios-more" /> <Icon class="menu-icon" type="ios-more" />
<EDropdownMenu v-if="projectDetail.owner_userid === userId" slot="dropdown"> <EDropdownMenu v-if="projectData.owner_userid === userId" slot="dropdown">
<EDropdownItem command="setting">{{$L('项目设置')}}</EDropdownItem> <EDropdownItem command="setting">{{$L('项目设置')}}</EDropdownItem>
<EDropdownItem command="user">{{$L('成员管理')}}</EDropdownItem> <EDropdownItem command="user">{{$L('成员管理')}}</EDropdownItem>
<EDropdownItem command="transfer" divided>{{$L('移交项目')}}</EDropdownItem> <EDropdownItem command="transfer" divided>{{$L('移交项目')}}</EDropdownItem>
@ -43,7 +43,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<div v-if="projectDetail.desc" class="project-subtitle">{{projectDetail.desc}}</div> <div v-if="projectData.desc" class="project-subtitle">{{projectData.desc}}</div>
<div class="project-switch"> <div class="project-switch">
<div v-if="completedCount > 0" class="project-checkbox"> <div v-if="completedCount > 0" class="project-checkbox">
<Checkbox :value="projectCompleteShow" @on-change="toggleBoolean('projectCompleteShow', $event)">{{$L('显示已完成')}}</Checkbox> <Checkbox :value="projectCompleteShow" @on-change="toggleBoolean('projectCompleteShow', $event)">{{$L('显示已完成')}}</Checkbox>
@ -56,23 +56,23 @@
</div> </div>
<div v-if="projectTablePanel" class="project-column overlay-x"> <div v-if="projectTablePanel" class="project-column overlay-x">
<Draggable <Draggable
:list="projectDetail.project_column" :list="projectData.columns"
:animation="150" :animation="150"
:disabled="sortDisabled" :disabled="sortDisabled"
class="column-list" class="column-list"
tag="ul" tag="ul"
draggable=".column-item" draggable=".column-item"
@sort="sortUpdate(true)"> @sort="sortUpdate(true)">
<li v-for="column in projectDetail.project_column" class="column-item"> <li v-for="column in projectData.columns" class="column-item">
<div <div
:class="['column-head', column.color ? 'custom-color' : '']" :class="['column-head', column.color ? 'custom-color' : '']"
:style="column.color ? {backgroundColor: column.color} : {}"> :style="column.color ? {backgroundColor: column.color} : {}">
<div class="column-head-title"> <div class="column-head-title">
<AutoTip>{{column.name}}</AutoTip> <AutoTip>{{column.name}}</AutoTip>
<em>({{panelTask(column.project_task).length}})</em> <em>({{panelTask(column.tasks).length}})</em>
</div> </div>
<div class="column-head-icon"> <div class="column-head-icon">
<div v-if="column.loading === true" class="loading"><Loading /></div> <div v-if="columnLoad[column.id] === true" class="loading"><Loading /></div>
<EDropdown <EDropdown
v-else v-else
trigger="click" trigger="click"
@ -85,7 +85,7 @@
<Icon type="md-create" />{{$L('修改')}} <Icon type="md-create" />{{$L('修改')}}
</div> </div>
</EDropdownItem> </EDropdownItem>
<EDropdownItem command="delete"> <EDropdownItem command="remove">
<div class="item"> <div class="item">
<Icon type="md-trash" />{{$L('删除')}} <Icon type="md-trash" />{{$L('删除')}}
</div> </div>
@ -105,14 +105,14 @@
<div v-if="column.addTopShow===true" class="task-item additem"> <div v-if="column.addTopShow===true" class="task-item additem">
<TaskAddSimple <TaskAddSimple
:column-id="column.id" :column-id="column.id"
:project-id="projectDetail.id" :project-id="projectId"
:add-top="true" :add-top="true"
@on-close="column.addTopShow=false" @on-close="column.addTopShow=false"
@on-priority="addTaskOpen" @on-priority="addTaskOpen"
auto-active/> auto-active/>
</div> </div>
<Draggable <Draggable
:list="column.project_task" :list="column.tasks"
:animation="150" :animation="150"
:disabled="sortDisabled" :disabled="sortDisabled"
class="task-list" class="task-list"
@ -121,14 +121,14 @@
@sort="sortUpdate" @sort="sortUpdate"
@remove="sortUpdate"> @remove="sortUpdate">
<div <div
v-for="item in column.project_task" v-for="item in column.tasks"
:class="['task-item task-draggable', item.complete_at ? 'complete' : '', taskHidden(item) ? 'hidden' : '']" :class="['task-item task-draggable', item.complete_at ? 'complete' : '', taskIsHidden(item) ? 'hidden' : '']"
:style="item.color ? {backgroundColor: item.color} : {}" :style="item.color ? {backgroundColor: item.color} : {}"
@click="openTask(item)"> @click="openTask(item)">
<div :class="['task-head', item.desc ? 'has-desc' : '']"> <div :class="['task-head', item.desc ? 'has-desc' : '']">
<div class="task-title"><pre>{{item.name}}</pre></div> <div class="task-title"><pre>{{item.name}}</pre></div>
<div class="task-menu" @click.stop=""> <div class="task-menu" @click.stop="">
<div v-if="item.loading === true" class="loading"><Loading /></div> <div v-if="taskLoad[item.id] === true" class="loading"><Loading /></div>
<EDropdown <EDropdown
v-else v-else
trigger="click" trigger="click"
@ -195,7 +195,7 @@
<div class="task-item additem"> <div class="task-item additem">
<TaskAddSimple <TaskAddSimple
:column-id="column.id" :column-id="column.id"
:project-id="projectDetail.id" :project-id="projectId"
@on-priority="addTaskOpen"/> @on-priority="addTaskOpen"/>
</div> </div>
</Draggable> </Draggable>
@ -244,7 +244,7 @@
<TaskRow :list="myList" open-key="my" :color-list="taskColorList" @command="dropTask" fast-add-task/> <TaskRow :list="myList" open-key="my" :color-list="taskColorList" @command="dropTask" fast-add-task/>
</div> </div>
<!--未完成任务--> <!--未完成任务-->
<div v-if="projectDetail.task_num > 0" :class="['project-table-body', !taskUndoneShow ? 'project-table-hide' : '']"> <div v-if="projectData.task_num > 0" :class="['project-table-body', !taskUndoneShow ? 'project-table-hide' : '']">
<Row class="task-row"> <Row class="task-row">
<Col span="12" class="row-title"> <Col span="12" class="row-title">
<i class="iconfont" @click="toggleBoolean('taskUndoneShow')">&#xe689;</i> <i class="iconfont" @click="toggleBoolean('taskUndoneShow')">&#xe689;</i>
@ -259,7 +259,7 @@
<TaskRow :list="undoneList" open-key="undone" :color-list="taskColorList" @command="dropTask"/> <TaskRow :list="undoneList" open-key="undone" :color-list="taskColorList" @command="dropTask"/>
</div> </div>
<!--已完成任务--> <!--已完成任务-->
<div v-if="projectDetail.task_num > 0" :class="['project-table-body', !taskCompletedShow ? 'project-table-hide' : '']"> <div v-if="projectData.task_num > 0" :class="['project-table-body', !taskCompletedShow ? 'project-table-hide' : '']">
<Row class="task-row"> <Row class="task-row">
<Col span="12" class="row-title"> <Col span="12" class="row-title">
<i class="iconfont" @click="toggleBoolean('taskCompletedShow')">&#xe689;</i> <i class="iconfont" @click="toggleBoolean('taskCompletedShow')">&#xe689;</i>
@ -284,10 +284,10 @@
maxWidth: '640px' maxWidth: '640px'
}" }"
:mask-closable="false"> :mask-closable="false">
<TaskAdd ref="add" v-model="addData" @on-add="onAddTask"/> <TaskAdd ref="add" @on-add="onAddTask"/>
<div slot="footer"> <div slot="footer">
<Button type="default" @click="addShow=false">{{$L('取消')}}</Button> <Button type="default" @click="addShow=false">{{$L('取消')}}</Button>
<Button type="primary" :loading="taskLoad > 0" @click="onAddTask">{{$L('添加')}}</Button> <Button type="primary" :loading="addLoad > 0" @click="onAddTask">{{$L('添加')}}</Button>
</div> </div>
</Modal> </Modal>
@ -348,7 +348,7 @@
import Draggable from 'vuedraggable' import Draggable from 'vuedraggable'
import TaskPriority from "./TaskPriority"; import TaskPriority from "./TaskPriority";
import TaskAdd from "./TaskAdd"; import TaskAdd from "./TaskAdd";
import {mapState} from "vuex"; import {mapGetters, mapState} from "vuex";
import UserInput from "../../../components/UserInput"; import UserInput from "../../../components/UserInput";
import TaskAddSimple from "./TaskAddSimple"; import TaskAddSimple from "./TaskAddSimple";
import TaskRow from "./TaskRow"; import TaskRow from "./TaskRow";
@ -360,19 +360,13 @@ export default {
nowTime: Math.round(new Date().getTime() / 1000), nowTime: Math.round(new Date().getTime() / 1000),
nowInterval: null, nowInterval: null,
columnLoad: {},
taskLoad: {},
searchText: '', searchText: '',
addShow: false, addShow: false,
addData: { addLoad: 0,
owner: 0,
column_id: 0,
times: [],
subtasks: [],
p_level: 0,
p_name: '',
p_color: '',
},
taskLoad: 0,
addColumnShow: false, addColumnShow: false,
addColumnName: '', addColumnName: '',
@ -432,61 +426,64 @@ export default {
'userId', 'userId',
'dialogList', 'dialogList',
'projectList', 'projectId',
'projectDetail', 'tasks',
'projectLoad', 'columns',
'projectChatShow', 'projectChatShow',
'projectTablePanel', 'projectTablePanel',
'projectCompleteShow', 'projectCompleteShow',
'taskMyShow', 'taskMyShow',
'taskUndoneShow', 'taskUndoneShow',
'taskCompletedShow' 'taskCompletedShow'
]), ]),
...mapGetters(['projectData']),
msgUnread() { msgUnread() {
const {dialogList, projectDetail} = this; const {dialogList, projectData} = this;
const dialog = dialogList.find(({id}) => id === projectDetail.dialog_id); const dialog = dialogList.find(({id}) => id === projectData.dialog_id);
return dialog ? dialog.unread : 0; return dialog ? dialog.unread : 0;
}, },
panelTask() { panelTask() {
const {searchText, projectCompleteShow} = this; const {searchText, projectCompleteShow} = this;
return function (project_task) { return function (list) {
if (!projectCompleteShow) { if (!projectCompleteShow) {
project_task = project_task.filter(({complete_at}) => { list = list.filter(({complete_at}) => {
return !complete_at; return !complete_at;
}); });
} }
if (searchText) { if (searchText) {
project_task = project_task.filter(({name, desc}) => { list = list.filter(({name, desc}) => {
return $A.strExists(name, searchText) || $A.strExists(desc, searchText); return $A.strExists(name, searchText) || $A.strExists(desc, searchText);
}); });
} }
return project_task; return list;
} }
}, },
myList() { myList() {
const {searchText, projectCompleteShow, userId, projectDetail} = this; const {projectId, tasks, searchText, projectCompleteShow, userId} = this;
const array = []; const array = tasks.filter((task) => {
projectDetail.project_column.forEach(({project_task, name}) => { if (task.parent_id > 0) {
project_task.some((task) => { return false;
if (!projectCompleteShow) { }
if (task.complete_at) { if (task.project_id != projectId) {
return false; return false;
} }
if (!projectCompleteShow) {
if (task.complete_at) {
return false;
} }
if (searchText) { }
if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) { if (searchText) {
return false; if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) {
} return false;
} }
if (task.task_user.find(({userid}) => userid == userId)) { }
task.column_name = name; return task.task_user.find(({userid}) => userid == userId);
array.push(task);
}
});
}); });
return array.sort((a, b) => { return array.sort((a, b) => {
if (a.p_level != b.p_level) { if (a.p_level != b.p_level) {
@ -500,25 +497,25 @@ export default {
}, },
undoneList() { undoneList() {
const {searchText, projectCompleteShow, projectDetail} = this; const {projectId, tasks, searchText, projectCompleteShow} = this;
const array = []; const array = tasks.filter((task) => {
projectDetail.project_column.forEach(({project_task, name}) => { if (task.parent_id > 0) {
project_task.some((task) => { return false;
if (!projectCompleteShow) { }
if (task.complete_at) { if (task.project_id != projectId) {
return false; return false;
} }
if (!projectCompleteShow) {
if (task.complete_at) {
return false;
} }
if (searchText) { }
if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) { if (searchText) {
return false; if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) {
} return false;
} }
if (!task.complete_at) { }
task.column_name = name; return !task.complete_at;
array.push(task);
}
});
}); });
return array.sort((a, b) => { return array.sort((a, b) => {
if (a.p_level != b.p_level) { if (a.p_level != b.p_level) {
@ -532,34 +529,38 @@ export default {
}, },
completedCount() { completedCount() {
const {projectDetail} = this; const {projectId, tasks} = this;
let count = 0; return tasks.filter((task) => {
projectDetail.project_column.forEach(({project_task, name}) => { if (task.parent_id > 0) {
count += project_task.filter(({complete_at}) => !!complete_at).length; return false;
}); }
return count; if (task.project_id != projectId) {
return false;
}
return task.complete_at;
}).length;
}, },
completedList() { completedList() {
const {searchText, projectCompleteShow, projectDetail} = this; const {projectId, tasks, searchText, projectCompleteShow} = this;
const array = []; const array = tasks.filter((task) => {
projectDetail.project_column.forEach(({project_task, name}) => { if (task.parent_id > 0) {
project_task.some((task) => { return false;
if (!projectCompleteShow) { }
if (task.complete_at) { if (task.project_id != projectId) {
return false; return false;
} }
} if (!projectCompleteShow) {
if (searchText) {
if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) {
return false;
}
}
if (task.complete_at) { if (task.complete_at) {
task.column_name = name; return false;
array.push(task);
} }
}); }
if (searchText) {
if (!$A.strExists(task.name, searchText) && !$A.strExists(task.desc, searchText)) {
return false;
}
}
return task.complete_at;
}); });
return array.sort((a, b) => { return array.sort((a, b) => {
if (a.p_level != b.p_level) { if (a.p_level != b.p_level) {
@ -587,7 +588,7 @@ export default {
}, },
watch: { watch: {
projectDetail() { projectData() {
this.sortData = this.getSort(); this.sortData = this.getSort();
} }
}, },
@ -595,12 +596,12 @@ export default {
methods: { methods: {
getSort() { getSort() {
const sortData = []; const sortData = [];
this.projectDetail.project_column.forEach((column) => { this.projectData.columns.forEach((column) => {
sortData.push({ sortData.push({
id: column.id, id: column.id,
task: column.project_task.map(({id}) => id) task: column.tasks.map(({id}) => id)
}); });
}); })
return sortData; return sortData;
}, },
@ -616,7 +617,7 @@ export default {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'project/sort', url: 'project/sort',
data: { data: {
project_id: this.projectDetail.id, project_id: this.projectId,
sort: this.sortData, sort: this.sortData,
only_column: only_column === true ? 1 : 0 only_column: only_column === true ? 1 : 0
}, },
@ -626,33 +627,19 @@ export default {
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.sortDisabled = false; this.sortDisabled = false;
this.$store.dispatch("getProjectDetail", this.projectDetail); this.$store.state.tasks = this.tasks.filter(({project_id}) => project_id != this.projectId);
this.$store.dispatch("getTasks", {project_id: this.projectId})
}); });
}, },
onAddTask() { onAddTask() {
if (!this.addData.name) { this.addLoad++;
$A.messageError("任务描述不能为空"); this.$refs.add.onAdd((success) => {
return; this.addLoad--;
} if (success) {
this.taskLoad++; this.addShow = false;
this.$store.dispatch("taskAdd", this.addData).then(({msg}) => { }
$A.messageSuccess(msg); })
this.taskLoad--;
this.addShow = false;
this.addData = {
owner: 0,
column_id: 0,
times: [],
subtasks: [],
p_level: 0,
p_name: '',
p_color: '',
};
}).catch(({msg}) => {
$A.modalError(msg);
this.taskLoad--;
});
}, },
addTopShow(column) { addTopShow(column) {
@ -661,14 +648,11 @@ export default {
}, },
addTaskOpen(column_id) { addTaskOpen(column_id) {
if ($A.isJson(column_id)) {
this.addData = Object.assign({}, this.addData, column_id);
} else {
this.$set(this.addData, 'owner', this.userId);
this.$set(this.addData, 'column_id', column_id);
this.$set(this.addData, 'project_id', this.projectDetail.id);
}
this.$refs.add.defaultPriority(); this.$refs.add.defaultPriority();
this.$refs.add.setData($A.isJson(column_id) ? column_id : {
'owner': this.userId,
'column_id': column_id,
});
this.addShow = true; this.addShow = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.add.$refs.input.focus(); this.$refs.add.$refs.input.focus();
@ -696,13 +680,13 @@ export default {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'project/column/add', url: 'project/column/add',
data: { data: {
project_id: this.projectDetail.id, project_id: this.projectId,
name: name, name: name,
}, },
}).then(({data, msg}) => { }).then(({data, msg}) => {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.addColumnName = ''; this.addColumnName = '';
this.$store.commit("columnAddSuccess", data); this.$store.dispatch("saveColumn", data);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
}); });
@ -712,7 +696,7 @@ export default {
if (command === 'title') { if (command === 'title') {
this.titleColumn(column); this.titleColumn(column);
} }
else if (command === 'delete') { else if (command === 'remove') {
this.removeColumn(column); this.removeColumn(column);
} }
else if (command.name) { else if (command.name) {
@ -739,12 +723,11 @@ export default {
}, },
updateColumn(column, updata) { updateColumn(column, updata) {
if (column.loading === true) { if (this.columnLoad[column.id] === true) {
return; return;
} }
this.$set(column, 'loading', true); this.$set(this.columnLoad, column.id, true);
// //
const backup = $A.cloneJSON(column);
Object.keys(updata).forEach(key => this.$set(column, key, updata[key])); Object.keys(updata).forEach(key => this.$set(column, key, updata[key]));
// //
this.$store.dispatch("call", { this.$store.dispatch("call", {
@ -753,11 +736,11 @@ export default {
column_id: column.id, column_id: column.id,
}), }),
}).then(({data}) => { }).then(({data}) => {
this.$set(column, 'loading', false); this.$set(this.columnLoad, column.id, false);
this.$store.commit("columnUpdateSuccess", data); this.$store.dispatch("saveColumn", data);
}).catch(({msg}) => { }).catch(({msg}) => {
this.$set(column, 'loading', false); this.$set(this.columnLoad, column.id, false);
Object.keys(updata).forEach(key => this.$set(column, key, backup[key])); this.$store.dispatch("getColumns", {project_id: this.projectId})
$A.modalError(msg); $A.modalError(msg);
}); });
}, },
@ -768,10 +751,10 @@ export default {
content: '你确定要删除列表【' + column.name + '】及列表内的任务吗?', content: '你确定要删除列表【' + column.name + '】及列表内的任务吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
if (column.loading === true) { if (this.columnLoad[column.id] === true) {
return; return;
} }
this.$set(column, 'loading', true); this.$set(this.columnLoad, column.id, true);
// //
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'project/column/remove', url: 'project/column/remove',
@ -780,12 +763,12 @@ export default {
}, },
}).then(({data, msg}) => { }).then(({data, msg}) => {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.$set(column, 'loading', false); this.$set(this.columnLoad, column.id, false);
this.$Modal.remove(); this.$Modal.remove();
this.$store.commit("columnDeleteSuccess", data); this.$store.dispatch("forgetColumn", data.id);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg, 301);
this.$set(column, 'loading', false); this.$set(this.columnLoad, column.id, false);
this.$Modal.remove(); this.$Modal.remove();
}); });
} }
@ -821,19 +804,21 @@ export default {
}, },
updateTask(task, updata) { updateTask(task, updata) {
if (task.loading === true) { if (this.taskLoad[task.id] === true) {
return; return;
} }
this.$set(task, 'loading', true); this.$set(this.taskLoad, task.id, true);
// //
Object.keys(updata).forEach(key => this.$set(task, key, updata[key])); Object.keys(updata).forEach(key => this.$set(task, key, updata[key]));
//
this.$store.dispatch("taskUpdate", Object.assign(updata, { this.$store.dispatch("taskUpdate", Object.assign(updata, {
task_id: task.id, task_id: task.id,
})).then(() => { })).then(() => {
this.$set(task, 'loading', false); this.$set(this.taskLoad, task.id, false);
}).catch(({msg}) => { }).catch(({msg}) => {
this.$set(task, 'loading', false);
$A.modalError(msg); $A.modalError(msg);
this.$set(this.taskLoad, task.id, false);
this.$store.dispatch("getTaskOne", task.id);
}); });
}, },
@ -846,17 +831,19 @@ export default {
content: '你确定要' + typeName + typeTask + '【' + task.name + '】吗?', content: '你确定要' + typeName + typeTask + '【' + task.name + '】吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
if (task.loading === true) { if (this.taskLoad[task.id] === true) {
this.$Modal.remove(); this.$Modal.remove();
return; return;
} }
this.$set(task, 'loading', true); this.$set(this.taskLoad, task.id, true);
this.$store.dispatch(typeDispatch, task.id).then(({msg}) => { this.$store.dispatch(typeDispatch, task.id).then(({msg}) => {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.$Modal.remove(); this.$Modal.remove();
this.$set(this.taskLoad, task.id, false);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg, 301);
this.$Modal.remove(); this.$Modal.remove();
this.$set(this.taskLoad, task.id, false);
}); });
} }
}); });
@ -866,7 +853,9 @@ export default {
this.settingLoad++; this.settingLoad++;
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'project/update', url: 'project/update',
data: this.settingData, data: Object.assign(this.settingData, {
project_id: this.projectId
}),
}).then(({data, msg}) => { }).then(({data, msg}) => {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.settingLoad--; this.settingLoad--;
@ -883,14 +872,14 @@ export default {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'project/user', url: 'project/user',
data: { data: {
project_id: this.userData.project_id, project_id: this.projectId,
userid: this.userData.userids, userid: this.userData.userids,
}, },
}).then(({data, msg}) => { }).then(({msg}) => {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.userLoad--; this.userLoad--;
this.userShow = false; this.userShow = false;
this.$store.dispatch("getProjectDetail", data); this.$store.dispatch("getProjectOne", this.projectId);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.userLoad--; this.userLoad--;
@ -902,14 +891,14 @@ export default {
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'project/transfer', url: 'project/transfer',
data: { data: {
project_id: this.transferData.project_id, project_id: this.projectId,
owner_userid: this.transferData.owner_userid[0], owner_userid: this.transferData.owner_userid[0],
}, },
}).then(({data, msg}) => { }).then(({msg}) => {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.transferLoad--; this.transferLoad--;
this.transferShow = false; this.transferShow = false;
this.$store.dispatch("getProjectDetail", data); this.$store.dispatch("getProjectOne", this.projectId);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.transferLoad--; this.transferLoad--;
@ -919,18 +908,12 @@ export default {
onDelete() { onDelete() {
$A.modalConfirm({ $A.modalConfirm({
title: '删除项目', title: '删除项目',
content: '你确定要删除项目【' + this.projectDetail.name + '】吗?', content: '你确定要删除项目【' + this.projectData.name + '】吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
this.$store.dispatch("call", { this.$store.dispatch("removeProject", this.projectId).then(({msg}) => {
url: 'project/remove',
data: {
project_id: this.projectDetail.id,
},
}).then(({data, msg}) => {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.$Modal.remove(); this.$Modal.remove();
this.$store.dispatch("removeProject", data.id);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg, 301);
this.$Modal.remove(); this.$Modal.remove();
@ -942,18 +925,12 @@ export default {
onExit() { onExit() {
$A.modalConfirm({ $A.modalConfirm({
title: '退出项目', title: '退出项目',
content: '你确定要退出项目【' + this.projectDetail.name + '】吗?', content: '你确定要退出项目【' + this.projectData.name + '】吗?',
loading: true, loading: true,
onOk: () => { onOk: () => {
this.$store.dispatch("call", { this.$store.dispatch("exitProject", this.projectId).then(({msg}) => {
url: 'project/exit',
data: {
project_id: this.projectDetail.id,
},
}).then(({data, msg}) => {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.$Modal.remove(); this.$Modal.remove();
this.$store.dispatch("removeProject", data.id);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg, 301);
this.$Modal.remove(); this.$Modal.remove();
@ -965,9 +942,8 @@ export default {
projectDropdown(name) { projectDropdown(name) {
switch (name) { switch (name) {
case "setting": case "setting":
this.$set(this.settingData, 'project_id', this.projectDetail.id); this.$set(this.settingData, 'name', this.projectData.name);
this.$set(this.settingData, 'name', this.projectDetail.name); this.$set(this.settingData, 'desc', this.projectData.desc);
this.$set(this.settingData, 'desc', this.projectDetail.desc);
this.settingShow = true; this.settingShow = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.projectName.focus(); this.$refs.projectName.focus();
@ -975,15 +951,13 @@ export default {
break; break;
case "user": case "user":
this.$set(this.userData, 'project_id', this.projectDetail.id); this.$set(this.userData, 'userids', this.projectData.project_user.map(({userid}) => userid));
this.$set(this.userData, 'userids', this.projectDetail.project_user.map(({userid}) => userid)); this.$set(this.userData, 'uncancelable', [this.projectData.owner_userid]);
this.$set(this.userData, 'uncancelable', [this.projectDetail.owner_userid]);
this.userShow = true; this.userShow = true;
break; break;
case "transfer": case "transfer":
this.$set(this.transferData, 'project_id', this.projectDetail.id); this.$set(this.transferData, 'owner_userid', [this.projectData.owner_userid]);
this.$set(this.transferData, 'owner_userid', [this.projectDetail.owner_userid]);
this.transferShow = true; this.transferShow = true;
break; break;
@ -1009,7 +983,7 @@ export default {
this.$store.dispatch("toggleBoolean", type); this.$store.dispatch("toggleBoolean", type);
}, },
taskHidden(task) { taskIsHidden(task) {
const {name, desc, complete_at} = task; const {name, desc, complete_at} = task;
const {searchText, projectCompleteShow} = this; const {searchText, projectCompleteShow} = this;
if (!projectCompleteShow) { if (!projectCompleteShow) {
@ -1025,12 +999,6 @@ export default {
return false; return false;
}, },
sortBy(field) {
return function (a, b) {
return a[field] - b[field];
}
},
formatTime(date) { formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000), let time = Math.round(new Date(date).getTime() / 1000),
string = ''; string = '';

View File

@ -3,7 +3,7 @@
<Form class="task-add-form" label-position="top" @submit.native.prevent> <Form class="task-add-form" label-position="top" @submit.native.prevent>
<FormItem :label="$L('任务描述')"> <FormItem :label="$L('任务描述')">
<Input <Input
v-model="value.name" v-model="addData.name"
ref="input" ref="input"
type="textarea" type="textarea"
:rows="1" :rows="1"
@ -14,7 +14,7 @@
</FormItem> </FormItem>
<FormItem :label="$L('任务详情')"> <FormItem :label="$L('任务详情')">
<TEditor <TEditor
v-model="value.content" v-model="addData.content"
:plugins="taskPlugins" :plugins="taskPlugins"
:options="taskOptions" :options="taskOptions"
:option-full="taskOptionFull" :option-full="taskOptionFull"
@ -28,7 +28,7 @@
<i <i
class="iconfont" class="iconfont"
:style="{color:item.color}" :style="{color:item.color}"
v-html="value.p_name == item.name ? '&#xe61d;' : '&#xe61c;'" v-html="addData.p_name == item.name ? '&#xe61d;' : '&#xe61c;'"
@click="choosePriority(item)"></i> @click="choosePriority(item)"></i>
</ETooltip> </ETooltip>
</li> </li>
@ -38,7 +38,7 @@
<Form v-if="advanced" class="task-add-advanced" label-width="auto" @submit.native.prevent> <Form v-if="advanced" class="task-add-advanced" label-width="auto" @submit.native.prevent>
<FormItem :label="$L('任务列表')"> <FormItem :label="$L('任务列表')">
<Select <Select
v-model="value.column_id" v-model="addData.column_id"
:placeholder="$L('选择任务列表')" :placeholder="$L('选择任务列表')"
:multipleMax="1" :multipleMax="1"
multiple multiple
@ -48,36 +48,37 @@
transfer-class-name="task-add-advanced-transfer" transfer-class-name="task-add-advanced-transfer"
@on-create="columnCreate"> @on-create="columnCreate">
<div slot="drop-prepend" class="task-drop-prepend">{{$L('最多只能选择1项')}}</div> <div slot="drop-prepend" class="task-drop-prepend">{{$L('最多只能选择1项')}}</div>
<Option v-for="(item, key) in columns" :value="item.id" :key="key">{{ item.name }}</Option> <Option v-for="(item, key) in columnList" :value="item.id" :key="key">{{ item.name }}</Option>
<Option v-for="(item, key) in columnAdd" :value="item.id" :key="'_' + key">{{ item.name }}</Option>
</Select> </Select>
</FormItem> </FormItem>
<FormItem :label="$L('计划时间')"> <FormItem :label="$L('计划时间')">
<DatePicker <DatePicker
v-model="value.times" v-model="addData.times"
:options="timeOptions" :options="timeOptions"
:editable="false" :editable="false"
:placeholder="$L('选择计划范围')" :placeholder="$L('选择计划范围')"
format="yyyy-MM-dd HH:mm" format="yyyy-MM-dd HH:mm"
type="datetimerange" type="datetimerange"
@on-change="taskTimeChange(value.times)"/> @on-change="taskTimeChange(addData.times)"/>
</FormItem> </FormItem>
<FormItem :label="$L('任务负责人')"> <FormItem :label="$L('任务负责人')">
<UserInput v-model="value.owner" :multiple-max="1" :placeholder="$L('选择任务负责人')"/> <UserInput v-model="addData.owner" :multiple-max="1" :placeholder="$L('选择任务负责人')"/>
</FormItem> </FormItem>
<div class="subtasks"> <div class="subtasks">
<div v-if="value.subtasks.length > 0" class="sublist"> <div v-if="addData.subtasks.length > 0" class="sublist">
<Row> <Row>
<Col span="12">{{$L('任务描述')}}</Col> <Col span="12">{{$L('任务描述')}}</Col>
<Col span="6">{{$L('计划时间')}}</Col> <Col span="6">{{$L('计划时间')}}</Col>
<Col span="6">{{$L('负责人')}}</Col> <Col span="6">{{$L('负责人')}}</Col>
</Row> </Row>
<Row v-for="(item, key) in value.subtasks" :key="key"> <Row v-for="(item, key) in addData.subtasks" :key="key">
<Col span="12"> <Col span="12">
<Input <Input
v-model="item.name" v-model="item.name"
:maxlength="255" :maxlength="255"
clearable clearable
@on-clear="value.subtasks.splice(key, 1)"/> @on-clear="addData.subtasks.splice(key, 1)"/>
</Col> </Col>
<Col span="6"> <Col span="6">
<DatePicker <DatePicker
@ -116,19 +117,21 @@ import UserInput from "../../../components/UserInput";
export default { export default {
name: "TaskAdd", name: "TaskAdd",
components: {UserInput, TEditor}, components: {UserInput, TEditor},
props: {
value: {
type: Object,
default: () => {
return {};
}
},
},
data() { data() {
return { return {
addData: {
owner: 0,
column_id: 0,
times: [],
subtasks: [],
p_level: 0,
p_name: '',
p_color: '',
},
advanced: false, advanced: false,
columns: [],
subName: '', subName: '',
columnAdd: [],
taskPlugins: [ taskPlugins: [
'advlist autolink lists link image charmap print preview hr anchor pagebreak imagetools', 'advlist autolink lists link image charmap print preview hr anchor pagebreak imagetools',
@ -162,12 +165,11 @@ export default {
} }
}, },
computed: { computed: {
...mapState(['userId', 'projectDetail', 'taskPriority']), ...mapState(['userId', 'projectId', 'columns', 'taskPriority']),
},
watch: { columnList() {
projectDetail(detail) { return this.columns.filter(({project_id}) => project_id == this.projectId)
this.columns = $A.cloneJSON(detail.project_column); },
}
}, },
methods: { methods: {
initLanguage() { initLanguage() {
@ -222,8 +224,8 @@ export default {
}; };
}, },
columnCreate(val) { columnCreate(val) {
if (!this.columns.find(({id}) => id == val)) { if (!this.columnAdd.find(({id}) => id == val)) {
this.columns.push({ this.columnAdd.push({
id: val, id: val,
name: val name: val
}); });
@ -248,7 +250,7 @@ export default {
}, },
addSubTask() { addSubTask() {
if (this.subName.trim() !== '') { if (this.subName.trim() !== '') {
this.value.subtasks.push({ this.addData.subtasks.push({
name: this.subName.trim(), name: this.subName.trim(),
times: [], times: [],
owner: this.userId owner: this.userId
@ -259,19 +261,47 @@ export default {
choosePriority(item) { choosePriority(item) {
let start = new Date(); let start = new Date();
let end = new Date(new Date().setDate(start.getDate() + $A.runNum(item.days))); let end = new Date(new Date().setDate(start.getDate() + $A.runNum(item.days)));
this.$set(this.value, 'times', $A.date2string([start, end])) this.$set(this.addData, 'times', $A.date2string([start, end]))
this.$set(this.value, 'p_level', item.priority) this.$set(this.addData, 'p_level', item.priority)
this.$set(this.value, 'p_name', item.name) this.$set(this.addData, 'p_name', item.name)
this.$set(this.value, 'p_color', item.color) this.$set(this.addData, 'p_color', item.color)
}, },
defaultPriority() { defaultPriority() {
if (this.taskPriority.length === 0) { if (this.taskPriority.length === 0) {
return; return;
} }
if (this.value.p_name) { if (this.addData.p_name) {
return; return;
} }
this.choosePriority(this.taskPriority[0]); this.choosePriority(this.taskPriority[0]);
},
setData(data) {
this.addData = Object.assign({}, this.addData, data);
},
onAdd(callback) {
if (!this.addData.name) {
$A.messageError("任务描述不能为空");
callback(false)
return;
}
this.$store.dispatch("taskAdd", Object.assign(this.addData, {
project_id: this.projectId
})).then(({msg}) => {
$A.messageSuccess(msg);
this.addData = {
owner: 0,
column_id: 0,
times: [],
subtasks: [],
p_level: 0,
p_name: '',
p_color: '',
};
callback(true)
}).catch(({msg}) => {
$A.modalError(msg);
callback(false)
});
} }
} }
} }

View File

@ -70,7 +70,7 @@
</template> </template>
<script> <script>
import {mapState} from "vuex"; import {mapGetters, mapState} from "vuex";
export default { export default {
name: "TaskAddSimple", name: "TaskAddSimple",
@ -125,7 +125,7 @@ export default {
}, },
computed: { computed: {
...mapState(['userId', 'taskPriority', 'projectDetail']), ...mapState(['userId', 'taskPriority']),
typeName() { typeName() {
return (this.parentId > 0 ? '子任务' : '任务'); return (this.parentId > 0 ? '子任务' : '任务');
@ -154,7 +154,7 @@ export default {
name: this.addData.name, name: this.addData.name,
} }
} else { } else {
this.addData.project_id = this.projectId || this.projectDetail.id; this.addData.project_id = this.projectId || this.$store.state.projectId;
this.addData.column_id = this.columnId || ''; this.addData.column_id = this.columnId || '';
this.addData.owner = [this.userId]; this.addData.owner = [this.userId];
this.addData.top = this.addTop ? 1 : 0; this.addData.top = this.addTop ? 1 : 0;

View File

@ -6,7 +6,7 @@
<Col span="12" :class="['row-name', item.complete_at ? 'complete' : '']"> <Col span="12" :class="['row-name', item.complete_at ? 'complete' : '']">
<Icon <Icon
v-if="item.sub_num > 0 || (item.parent_id===0 && fastAddTask)" v-if="item.sub_num > 0 || (item.parent_id===0 && fastAddTask)"
:class="['sub-icon', item[openName] ? 'active' : '']" :class="['sub-icon', taskOpen[item.id] ? 'active' : '']"
type="ios-arrow-forward" type="ios-arrow-forward"
@click="getSublist(item)"/> @click="getSublist(item)"/>
<EDropdown <EDropdown
@ -16,7 +16,7 @@
<div class="drop-icon"> <div class="drop-icon">
<Icon v-if="item.complete_at" class="completed" type="md-checkmark-circle" /> <Icon v-if="item.complete_at" class="completed" type="md-checkmark-circle" />
<Icon v-else type="md-radio-button-off" /> <Icon v-else type="md-radio-button-off" />
<div v-if="item.loading === true" class="loading"><Loading /></div> <div v-if="taskLoad[item.id] === true" class="loading"><Loading /></div>
</div> </div>
<EDropdownMenu slot="dropdown" class="project-list-more-dropdown-menu"> <EDropdownMenu slot="dropdown" class="project-list-more-dropdown-menu">
<EDropdownItem v-if="item.complete_at" command="uncomplete"> <EDropdownItem v-if="item.complete_at" command="uncomplete">
@ -83,8 +83,8 @@
</Col> </Col>
</Row> </Row>
<TaskRow <TaskRow
v-if="item[openName]===true" v-if="taskOpen[item.id]===true"
:list="item.sub_task" :list="subTask(item.id)"
:parent-id="item.id" :parent-id="item.id"
:fast-add-task="item.parent_id===0 && fastAddTask" :fast-add-task="item.parent_id===0 && fastAddTask"
:color-list="colorList" :color-list="colorList"
@ -98,6 +98,7 @@
<script> <script>
import TaskPriority from "./TaskPriority"; import TaskPriority from "./TaskPriority";
import TaskAddSimple from "./TaskAddSimple"; import TaskAddSimple from "./TaskAddSimple";
import {mapState} from "vuex";
export default { export default {
name: "TaskRow", name: "TaskRow",
@ -132,6 +133,9 @@ export default {
return { return {
nowTime: Math.round(new Date().getTime() / 1000), nowTime: Math.round(new Date().getTime() / 1000),
nowInterval: null, nowInterval: null,
taskLoad: {},
taskOpen: {}
} }
}, },
mounted() { mounted() {
@ -143,10 +147,16 @@ export default {
destroyed() { destroyed() {
clearInterval(this.nowInterval) clearInterval(this.nowInterval)
}, },
computed: { computed: {
openName() { ...mapState(['tasks']),
return 'sub_open_' + this.openKey
subTask() {
return function(task_id) {
return this.tasks.filter(({parent_id}) => parent_id == task_id);
}
}, },
expiresFormat() { expiresFormat() {
const {nowTime} = this; const {nowTime} = this;
return function (date) { return function (date) {
@ -166,20 +176,22 @@ export default {
}, },
getSublist(task) { getSublist(task) {
if (task[this.openName] === true) { if (this.taskOpen[task.id] === true) {
this.$set(task, this.openName, false); this.$set(this.taskOpen, task.id, false);
return; return;
} }
if (task.loading === true) { if (this.taskLoad[task.id] === true) {
return; return;
} }
this.$set(task, 'loading', true); this.$set(this.taskLoad, task.id, true);
this.$store.dispatch("getSubTask", task.id).then(({data}) => { //
this.$set(task, 'loading', false); this.$store.dispatch("getTasks", {
this.$set(task, 'sub_task', data); parent_id: task.id
this.$set(task, this.openName, true); }).then(() => {
this.$set(this.taskLoad, task.id, false);
this.$set(this.taskOpen, task.id, true);
}).catch(({msg}) => { }).catch(({msg}) => {
this.$set(task, 'loading', false); this.$set(this.taskLoad, task.id, false);
$A.modalError(msg); $A.modalError(msg);
}); });
}, },

View File

@ -16,16 +16,18 @@ export default {
project_id: 0, project_id: 0,
} }
}, },
mounted() {
this.project_id = this.$route.params.id;
},
watch: { watch: {
'$route': { '$route' (route) {
handler(route) { this.project_id = route.params.id;
this.project_id = route.params.id;
},
immediate: true
}, },
project_id(id) { project_id(id) {
this.$store.state.projectId = id; this.$store.state.projectId = $A.runNum(id);
this.$store.dispatch("getProjectOne", id); this.$store.dispatch("getProjectOne", id);
this.$store.dispatch("getColumns", id);
this.$store.dispatch("getTasks", {project_id: id});
} }
}, },
} }

View File

@ -144,9 +144,9 @@ export default {
}).then(result => { }).then(result => {
dispatch("saveUserInfo", result.data); dispatch("saveUserInfo", result.data);
resolve(result) resolve(result)
}).catch(result => { }).catch(e => {
dispatch("logout"); !e.ret && console.error(e);
reject(result) reject(e)
}); });
}); });
}, },
@ -242,10 +242,10 @@ export default {
dispatch("saveUserOnlineStatus", item); dispatch("saveUserOnlineStatus", item);
typeof success === "function" && success(item, true) typeof success === "function" && success(item, true)
}); });
}).catch(result => { }).catch(e => {
!e.ret && console.error(e);
state.cacheUserBasic["::load"] = false; state.cacheUserBasic["::load"] = false;
typeof complete === "function" && complete() typeof complete === "function" && complete()
$A.modalError(result.msg);
}); });
}, },
@ -324,9 +324,10 @@ export default {
dispatch("call", { dispatch("call", {
url: 'project/lists', url: 'project/lists',
}).then(result => { }).then(result => {
state.projects = [];
dispatch("saveProject", result.data.data); dispatch("saveProject", result.data.data);
}).catch(result => { }).catch(e => {
// !e.ret && console.error(e);
}); });
}, },
@ -344,8 +345,8 @@ export default {
}, },
}).then(result => { }).then(result => {
dispatch("saveProject", result.data); dispatch("saveProject", result.data);
}).catch(result => { }).catch(e => {
// !e.ret && console.error(e);
}); });
}, },
@ -364,9 +365,33 @@ export default {
}).then(result => { }).then(result => {
dispatch("forgetProject", project_id) dispatch("forgetProject", project_id)
resolve(result) resolve(result)
}).catch(result => { }).catch(e => {
!e.ret && console.error(e);
dispatch("getProjectOne", project_id); dispatch("getProjectOne", project_id);
reject(result) reject(e)
});
});
},
/**
* 退出项目
* @param dispatch
* @param project_id
*/
exitProject({dispatch}, project_id) {
return new Promise(function (resolve, reject) {
dispatch("call", {
url: 'project/exit',
data: {
project_id,
},
}).then(result => {
dispatch("forgetProject", project_id)
resolve(result)
}).catch(e => {
!e.ret && console.error(e);
dispatch("getProjectOne", project_id);
reject(e)
}); });
}); });
}, },
@ -444,9 +469,10 @@ export default {
project_id project_id
} }
}).then(result => { }).then(result => {
state.columns = state.columns.filter((item) => item.project_id != project_id);
dispatch("saveColumn", result.data.data); dispatch("saveColumn", result.data.data);
}).catch(result => { }).catch(e => {
// !e.ret && console.error(e);
}); });
}, },
@ -465,7 +491,9 @@ export default {
}).then(result => { }).then(result => {
dispatch("forgetColumn", column_id) dispatch("forgetColumn", column_id)
resolve(result) resolve(result)
}).catch(reject); }).catch(e => {
!e.ret && console.error(e);
});
}); });
}, },
@ -531,9 +559,15 @@ export default {
url: 'project/task/lists', url: 'project/task/lists',
data: data data: data
}).then(result => { }).then(result => {
if (data.project_id) {
state.tasks = state.tasks.filter((item) => item.project_id != data.project_id);
}
if (data.parent_id) {
state.tasks = state.tasks.filter((item) => item.parent_id != data.parent_id);
}
dispatch("saveTask", result.data.data); dispatch("saveTask", result.data.data);
}).catch(result => { }).catch(e => {
// !e.ret && console.error(e);
}); });
}, },
@ -554,8 +588,8 @@ export default {
}, },
}).then(result => { }).then(result => {
dispatch("saveTask", result.data); dispatch("saveTask", result.data);
}).catch(result => { }).catch(e => {
// !e.ret && console.error(e);
}); });
}, },
@ -575,9 +609,10 @@ export default {
}).then(result => { }).then(result => {
dispatch("forgetTask", task_id) dispatch("forgetTask", task_id)
resolve(result) resolve(result)
}).catch(result => { }).catch(e => {
!e.ret && console.error(e);
dispatch("getTaskOne", task_id); dispatch("getTaskOne", task_id);
reject(result) reject(e)
}); });
}); });
}, },
@ -598,9 +633,10 @@ export default {
}).then(result => { }).then(result => {
dispatch("forgetTask", task_id) dispatch("forgetTask", task_id)
resolve(result) resolve(result)
}).catch(result => { }).catch(e => {
!e.ret && console.error(e);
dispatch("getTaskOne", task_id); dispatch("getTaskOne", task_id);
reject(result) reject(e)
}); });
}); });
}, },
@ -627,7 +663,9 @@ export default {
state.taskContents.push(result.data) state.taskContents.push(result.data)
} }
resolve(result) resolve(result)
}).catch(reject); }).catch(e => {
!e.ret && console.error(e);
});
}); });
}, },
@ -655,7 +693,9 @@ export default {
} }
}) })
resolve(result) resolve(result)
}).catch(reject); }).catch(e => {
!e.ret && console.error(e);
});
}); });
}, },
@ -697,7 +737,9 @@ export default {
dispatch("saveColumn", new_column) dispatch("saveColumn", new_column)
dispatch("saveTask", task) dispatch("saveTask", task)
resolve(result) resolve(result)
}).catch(reject); }).catch(e => {
!e.ret && console.error(e);
});
}); });
}, },
@ -717,7 +759,9 @@ export default {
dispatch("saveColumn", new_column) dispatch("saveColumn", new_column)
dispatch("saveTask", task) dispatch("saveTask", task)
resolve(result) resolve(result)
}).catch(reject); }).catch(e => {
!e.ret && console.error(e);
});
}); });
}, },
@ -740,9 +784,10 @@ export default {
}).then(result => { }).then(result => {
dispatch("saveTask", result.data) dispatch("saveTask", result.data)
resolve(result) resolve(result)
}).catch(result => { }).catch(e => {
!e.ret && console.error(e);
dispatch("getTaskOne", post.task_id); dispatch("getTaskOne", post.task_id);
reject(result) reject(e)
}); });
}); });
}, },
@ -760,7 +805,9 @@ export default {
}).then(result => { }).then(result => {
state.taskPriority = result.data; state.taskPriority = result.data;
resolve(result) resolve(result)
}).catch(reject); }).catch(e => {
!e.ret && console.error(e);
});
}); });
}, },
@ -810,8 +857,9 @@ export default {
}); });
} }
resolve(result); resolve(result);
}).catch(result => { }).catch(e => {
reject(result); !e.ret && console.error(e);
reject(e);
}); });
}); });
}, },
@ -855,9 +903,9 @@ export default {
dispatch("getDialogMsgList", result.data.id); dispatch("getDialogMsgList", result.data.id);
dispatch("saveDialog", result.data); dispatch("saveDialog", result.data);
resolve(result); resolve(result);
}).catch(result => { }).catch(e => {
$A.modalError(result.msg); !e.ret && console.error(e);
reject(result); reject(e);
}); });
}); });
}, },
@ -914,7 +962,8 @@ export default {
state.method.setStorage("cacheDialogMsg", state.cacheDialogMsg); state.method.setStorage("cacheDialogMsg", state.cacheDialogMsg);
// 更新当前会话消息 // 更新当前会话消息
commit("dialogMsgListSuccess", data); commit("dialogMsgListSuccess", data);
}).catch(() => { }).catch(e => {
!e.ret && console.error(e);
state.dialogMsgLoad--; state.dialogMsgLoad--;
state.cacheDialogMsg[dialog_id + "::load"] = false; state.cacheDialogMsg[dialog_id + "::load"] = false;
}); });
@ -948,9 +997,10 @@ export default {
state.dialogMsgLoad--; state.dialogMsgLoad--;
commit("dialogMsgListSuccess", result.data); commit("dialogMsgListSuccess", result.data);
resolve(result) resolve(result)
}).catch((result) => { }).catch(e => {
!e.ret && console.error(e);
state.dialogMsgLoad--; state.dialogMsgLoad--;
reject(result) reject(e)
}); });
}); });
}, },

View File

@ -1,4 +1,42 @@
export default { export default {
projectData(state) {
let projectId = state.projectId;
if (projectId == 0) {
projectId = state.method.runNum(window.__projectId);
}
if (projectId > 0) {
window.__projectId = projectId;
const project = state.method.cloneJSON(state.projects.find(({id}) => id == projectId));
if (project) {
project.columns = state.method.cloneJSON(state.columns.filter(({project_id}) => {
return project_id == project.id
})).sort((a, b) => {
if (a.sort != b.sort) {
return a.sort - b.sort;
}
return a.id - b.id;
});
project.columns.forEach((column) => {
column.tasks = state.method.cloneJSON(state.tasks.filter((task) => {
if (task.parent_id > 0) {
return false;
}
return task.column_id == column.id;
})).sort((a, b) => {
if (a.sort != b.sort) {
return a.sort - b.sort;
}
return a.id - b.id;
});
})
return project;
}
}
return {
columns: []
};
},
taskData(state) { taskData(state) {
let taskId = state.taskId; let taskId = state.taskId;
if (taskId == 0) { if (taskId == 0) {