no message
This commit is contained in:
parent
11b4aea20c
commit
e54793ac79
@ -96,7 +96,7 @@ class ProjectController extends AbstractController
|
||||
*
|
||||
* @apiParam {String} name 项目名称
|
||||
* @apiParam {String} [desc] 项目介绍
|
||||
* @apiParam {Array} [columns] 列表,格式[列表1, 列表2]
|
||||
* @apiParam {String} [columns] 列表,格式:列表名称1,列表名称2
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
@ -113,8 +113,7 @@ class ProjectController extends AbstractController
|
||||
return Base::retError('项目介绍最多只能设置255个字');
|
||||
}
|
||||
// 列表
|
||||
$columns = Request::input('columns');
|
||||
if (!is_array($columns)) $columns = [];
|
||||
$columns = explode(",", Request::input('columns'));
|
||||
$insertColumns = [];
|
||||
$sort = 0;
|
||||
foreach ($columns AS $column) {
|
||||
@ -515,7 +514,7 @@ class ProjectController extends AbstractController
|
||||
{
|
||||
User::auth();
|
||||
//
|
||||
$builder = ProjectTask::with(['taskUser', 'taskTag']);
|
||||
$builder = ProjectTask::with(['taskUser', 'taskTag'])->whereNull('project_tasks.archived_at');
|
||||
//
|
||||
$parent_id = intval(Request::input('parent_id'));
|
||||
$project_id = intval(Request::input('project_id'));
|
||||
@ -525,10 +524,10 @@ class ProjectController extends AbstractController
|
||||
//
|
||||
if ($parent_id > 0) {
|
||||
ProjectTask::userTask($parent_id);
|
||||
$builder->where('parent_id', $parent_id)->whereNull('archived_at');
|
||||
$builder->where('parent_id', $parent_id);
|
||||
} elseif ($project_id > 0) {
|
||||
Project::userProject($project_id);
|
||||
$builder->where('project_id', $project_id)->whereNull('archived_at');
|
||||
$builder->where('project_id', $project_id);
|
||||
} else {
|
||||
$builder->authData();
|
||||
}
|
||||
@ -867,7 +866,7 @@ class ProjectController extends AbstractController
|
||||
}
|
||||
//
|
||||
$task->archivedTask(Carbon::now());
|
||||
return Base::retSuccess('保存成功', ['id' => $task->id]);
|
||||
return Base::retSuccess('设置成功', ['id' => $task->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,11 +84,6 @@ class ProjectTask extends AbstractModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
const taskSelect = [
|
||||
'project_tasks.*',
|
||||
'project_task_users.owner',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'file_num',
|
||||
'msg_num',
|
||||
@ -258,7 +253,7 @@ class ProjectTask extends AbstractModel
|
||||
{
|
||||
$pre = DB::getTablePrefix();
|
||||
$user = $user ?: User::auth();
|
||||
$query->select(ProjectTask::taskSelect)
|
||||
$query->select("project_tasks.*")
|
||||
->join('project_task_users', 'project_tasks.id', '=', 'project_task_users.task_pid')
|
||||
->whereExists(function ($der) use ($pre) {
|
||||
$der->select(DB::raw(1))
|
||||
@ -267,7 +262,6 @@ class ProjectTask extends AbstractModel
|
||||
->whereColumn('project_task_users.task_pid', '=', 'B.task_pid')
|
||||
->havingRaw("max({$pre}B.id) = {$pre}project_task_users.id");
|
||||
})
|
||||
->whereNull('project_tasks.archived_at')
|
||||
->where('project_task_users.userid', $user->userid);
|
||||
return $query;
|
||||
}
|
||||
@ -689,7 +683,7 @@ class ProjectTask extends AbstractModel
|
||||
*/
|
||||
public static function userTask($task_id, $with = [])
|
||||
{
|
||||
$task = self::with($with)->whereId(intval($task_id))->first();
|
||||
$task = self::with($with)->whereId(intval($task_id))->whereNull('archived_at')->first();
|
||||
if (empty($task)) {
|
||||
throw new ApiException('任务不存在');
|
||||
}
|
||||
|
@ -78,22 +78,14 @@
|
||||
<FormItem prop="name" :label="$L('项目名称')">
|
||||
<Input ref="projectName" type="text" v-model="addData.name"></Input>
|
||||
</FormItem>
|
||||
<FormItem prop="columns" :label="$L('项目模板')">
|
||||
<Select v-model="addData.template" @on-change="(res) => {$set(addData, 'columns', columns[res].value)}" :placeholder="$L('请选择模板')">
|
||||
<FormItem v-if="addData.columns" :label="$L('任务列表')">
|
||||
<TagInput v-model="addData.columns"/>
|
||||
</FormItem>
|
||||
<FormItem v-else :label="$L('项目模板')">
|
||||
<Select :value="0" @on-change="(i) => {$set(addData, 'columns', columns[i].value.join(','))}" :placeholder="$L('请选择模板')">
|
||||
<Option v-for="(item, index) in columns" :value="index" :key="index">{{ item.label }}</Option>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem v-if="addData.columns.length > 0" :label="$L('任务列表')">
|
||||
<div style="line-height:38px">
|
||||
<span v-for="(item, index) in addData.columns">
|
||||
<Tag @on-close="() => { addData.columns.splice(index, 1)}" closable size="large" color="primary">{{item}}</Tag>
|
||||
</span>
|
||||
</div>
|
||||
<div style="margin-top:4px;"></div>
|
||||
<div style="margin-bottom:-16px">
|
||||
<Button icon="ios-add" type="dashed" @click="addColumns">{{$L('添加列表')}}</Button>
|
||||
</div>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<div slot="footer">
|
||||
<Button type="default" @click="addShow=false">{{$L('取消')}}</Button>
|
||||
@ -131,8 +123,7 @@ export default {
|
||||
addShow: false,
|
||||
addData: {
|
||||
name: '',
|
||||
columns: [],
|
||||
template: 0,
|
||||
columns: '',
|
||||
},
|
||||
addRule: {},
|
||||
|
||||
@ -250,45 +241,6 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
addColumns() {
|
||||
this.columnsValue = "";
|
||||
$A.modalConfirm({
|
||||
render: (h) => {
|
||||
return h('div', [
|
||||
h('div', {
|
||||
style: {
|
||||
fontSize: '16px',
|
||||
fontWeight: '500',
|
||||
marginBottom: '20px',
|
||||
}
|
||||
}, this.$L('添加流程')),
|
||||
h('TagInput', {
|
||||
props: {
|
||||
value: this.columnsValue,
|
||||
autofocus: true,
|
||||
placeholder: this.$L('请输入流程名称,多个可用英文逗号分隔。')
|
||||
},
|
||||
on: {
|
||||
input: (val) => {
|
||||
this.columnsValue = val;
|
||||
}
|
||||
}
|
||||
})
|
||||
])
|
||||
},
|
||||
onOk: () => {
|
||||
if (this.columnsValue) {
|
||||
let array = $A.trim(this.columnsValue).split(",");
|
||||
array.forEach((name) => {
|
||||
if ($A.trim(name)) {
|
||||
this.addData.columns.push($A.trim(name));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
onAddShow() {
|
||||
this.addShow = true;
|
||||
this.$nextTick(() => {
|
||||
@ -308,7 +260,6 @@ export default {
|
||||
this.loadIng--;
|
||||
this.addShow = false;
|
||||
this.$refs.addProject.resetFields();
|
||||
this.$set(this.addData, 'template', 0);
|
||||
this.$store.dispatch("saveProject", data);
|
||||
this.toggleRoute('project/' + data.id)
|
||||
}).catch(({msg}) => {
|
||||
|
@ -76,7 +76,7 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapState(['projects', 'tasks']),
|
||||
...mapState(['userId', 'projects', 'tasks']),
|
||||
|
||||
list() {
|
||||
let datas = $A.cloneJSON(this.tasks);
|
||||
@ -90,7 +90,7 @@ export default {
|
||||
if (!data.start_at || !data.end_at) {
|
||||
return false;
|
||||
}
|
||||
return data.owner;
|
||||
return data.task_user.find(({userid}) => userid == this.userId);
|
||||
})
|
||||
return datas.map(data => {
|
||||
let task = {
|
||||
@ -287,10 +287,7 @@ export default {
|
||||
content: '你确定要删除任务【' + data.name + '】吗?',
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
this.$store.dispatch("taskArchivedOrRemove", {
|
||||
id: data.id,
|
||||
type: 'delete',
|
||||
}).then(({msg}) => {
|
||||
this.$store.dispatch("removeTask", data.id).then(({msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.$Modal.remove();
|
||||
}).catch(({msg}) => {
|
||||
|
@ -151,7 +151,7 @@
|
||||
<Icon type="ios-filing" />{{$L('归档')}}
|
||||
</div>
|
||||
</EDropdownItem>
|
||||
<EDropdownItem command="delete">
|
||||
<EDropdownItem command="remove">
|
||||
<div class="item">
|
||||
<Icon type="md-trash" />{{$L('删除')}}
|
||||
</div>
|
||||
@ -793,42 +793,30 @@ export default {
|
||||
},
|
||||
|
||||
dropTask(task, command) {
|
||||
if (command === 'complete') {
|
||||
if (task.complete_at) return;
|
||||
this.updateTask(task, {
|
||||
complete_at: $A.formatDate("Y-m-d H:i:s")
|
||||
})
|
||||
}
|
||||
else if (command === 'uncomplete') {
|
||||
if (!task.complete_at) return;
|
||||
this.updateTask(task, {
|
||||
complete_at: false
|
||||
})
|
||||
}
|
||||
else if (command === 'archived') {
|
||||
$A.modalConfirm({
|
||||
title: '归档任务',
|
||||
content: '你确定要归档任务【' + task.name + '】吗?',
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
this.archivedOrRemoveTask(task, 'archived');
|
||||
switch (command) {
|
||||
case 'complete':
|
||||
if (task.complete_at) return;
|
||||
this.updateTask(task, {
|
||||
complete_at: $A.formatDate("Y-m-d H:i:s")
|
||||
})
|
||||
break;
|
||||
case 'uncomplete':
|
||||
if (!task.complete_at) return;
|
||||
this.updateTask(task, {
|
||||
complete_at: false
|
||||
})
|
||||
break;
|
||||
case 'archived':
|
||||
case 'remove':
|
||||
this.archivedOrRemoveTask(task, command);
|
||||
break;
|
||||
default:
|
||||
if (command.name) {
|
||||
this.updateTask(task, {
|
||||
color: command.color
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (command === 'delete') {
|
||||
$A.modalConfirm({
|
||||
title: '删除任务',
|
||||
content: '你确定要删除任务【' + task.name + '】吗?',
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
this.archivedOrRemoveTask(task, 'delete');
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (command.name) {
|
||||
this.updateTask(task, {
|
||||
color: command.color
|
||||
})
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -850,19 +838,27 @@ export default {
|
||||
},
|
||||
|
||||
archivedOrRemoveTask(task, type) {
|
||||
if (task.loading === true) {
|
||||
return;
|
||||
}
|
||||
this.$set(task, 'loading', true);
|
||||
this.$store.dispatch("taskArchivedOrRemove", {
|
||||
task_id: task.id,
|
||||
type: type,
|
||||
}).then(({msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.$Modal.remove();
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg, 301);
|
||||
this.$Modal.remove();
|
||||
let typeDispatch = type == 'remove' ? 'removeTask' : 'archivedTask';
|
||||
let typeName = type == 'remove' ? '删除' : '归档';
|
||||
let typeTask = task.parent_id > 0 ? '子任务' : '任务';
|
||||
$A.modalConfirm({
|
||||
title: typeName + typeTask,
|
||||
content: '你确定要' + typeName + typeTask + '【' + task.name + '】吗?',
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
if (task.loading === true) {
|
||||
this.$Modal.remove();
|
||||
return;
|
||||
}
|
||||
this.$set(task, 'loading', true);
|
||||
this.$store.dispatch(typeDispatch, task.id).then(({msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.$Modal.remove();
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg, 301);
|
||||
this.$Modal.remove();
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@ -934,7 +930,7 @@ export default {
|
||||
}).then(({data, msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.$Modal.remove();
|
||||
this.$store.dispatch("removeProject", data);
|
||||
this.$store.dispatch("removeProject", data.id);
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg, 301);
|
||||
this.$Modal.remove();
|
||||
@ -957,7 +953,7 @@ export default {
|
||||
}).then(({data, msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.$Modal.remove();
|
||||
this.$store.dispatch("removeProject", data);
|
||||
this.$store.dispatch("removeProject", data.id);
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg, 301);
|
||||
this.$Modal.remove();
|
||||
|
@ -29,7 +29,7 @@
|
||||
<Icon type="md-time" />{{$L('时间')}}
|
||||
</div>
|
||||
</EDropdownItem>
|
||||
<EDropdownItem command="delete">
|
||||
<EDropdownItem command="remove">
|
||||
<div class="item">
|
||||
<Icon type="md-trash" />{{$L('删除')}}
|
||||
</div>
|
||||
@ -119,7 +119,7 @@
|
||||
<Icon type="ios-filing" />{{$L('归档')}}
|
||||
</div>
|
||||
</EDropdownItem>
|
||||
<EDropdownItem command="delete">
|
||||
<EDropdownItem command="remove">
|
||||
<div class="item">
|
||||
<Icon type="md-trash" />{{$L('删除')}}
|
||||
</div>
|
||||
@ -731,7 +731,7 @@ export default {
|
||||
this.openTime()
|
||||
break;
|
||||
case 'archived':
|
||||
case 'delete':
|
||||
case 'remove':
|
||||
this.archivedOrRemoveTask(command);
|
||||
break;
|
||||
}
|
||||
@ -778,21 +778,20 @@ export default {
|
||||
},
|
||||
|
||||
archivedOrRemoveTask(type) {
|
||||
let typeName = type == 'delete' ? '删除' : '归档';
|
||||
let typeTitle = this.taskDetail.parent_id > 0 ? '子任务' : '任务';
|
||||
let typeDispatch = type == 'remove' ? 'removeTask' : 'archivedTask';
|
||||
let typeName = type == 'remove' ? '删除' : '归档';
|
||||
let typeTask = this.taskDetail.parent_id > 0 ? '子任务' : '任务';
|
||||
$A.modalConfirm({
|
||||
title: typeName + typeTitle,
|
||||
content: '你确定要' + typeName + typeTitle + '【' + this.taskDetail.name + '】吗?',
|
||||
title: typeName + typeTask,
|
||||
content: '你确定要' + typeName + typeTask + '【' + this.taskDetail.name + '】吗?',
|
||||
loading: true,
|
||||
onOk: () => {
|
||||
if (this.taskDetail.loading === true) {
|
||||
this.$Modal.remove();
|
||||
return;
|
||||
}
|
||||
this.$set(this.taskDetail, 'loading', true);
|
||||
this.$store.dispatch("taskArchivedOrRemove", {
|
||||
task_id: this.taskDetail.id,
|
||||
type: type,
|
||||
}).then(({msg}) => {
|
||||
this.$store.dispatch(typeDispatch, this.taskDetail.id).then(({msg}) => {
|
||||
$A.messageSuccess(msg);
|
||||
this.$Modal.remove();
|
||||
}).catch(({msg}) => {
|
||||
|
@ -34,7 +34,7 @@
|
||||
<Icon type="ios-filing" />{{$L('归档')}}
|
||||
</div>
|
||||
</EDropdownItem>
|
||||
<EDropdownItem command="delete">
|
||||
<EDropdownItem command="remove">
|
||||
<div class="item">
|
||||
<Icon type="md-trash" />{{$L('删除')}}
|
||||
</div>
|
||||
|
@ -16,15 +16,16 @@ export default {
|
||||
project_id: 0,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.project_id = this.$route.params.id;
|
||||
},
|
||||
watch: {
|
||||
'$route' (route) {
|
||||
this.project_id = route.params.id;
|
||||
'$route': {
|
||||
handler(route) {
|
||||
this.project_id = route.params.id;
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
project_id(id) {
|
||||
this.$store.dispatch("getProjectDetail", {id});
|
||||
this.$store.state.projectId = id;
|
||||
this.$store.dispatch("getProjectOne", id);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
190
resources/assets/js/store/actions.js
vendored
190
resources/assets/js/store/actions.js
vendored
@ -287,6 +287,27 @@ export default {
|
||||
state.method.setStorage("cacheProjects", state.cacheProjects = state.projects);
|
||||
},
|
||||
|
||||
/**
|
||||
* 忘记项目数据
|
||||
* @param state
|
||||
* @param project_id
|
||||
*/
|
||||
forgetProject({state}, project_id) {
|
||||
let index = state.projects.findIndex(({id}) => id == project_id);
|
||||
if (index > -1) {
|
||||
state.projects.splice(index, 1);
|
||||
}
|
||||
if (state.projectId == project_id) {
|
||||
const project = state.projects.find(({id}) => id && id != project_id);
|
||||
if (project) {
|
||||
$A.goForward({path: '/manage/project/' + project.id});
|
||||
} else {
|
||||
$A.goForward({path: '/manage/dashboard'});
|
||||
}
|
||||
}
|
||||
state.method.setStorage("cacheProjects", state.cacheProjects = state.projects);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取项目
|
||||
* @param state
|
||||
@ -313,16 +334,13 @@ export default {
|
||||
* 获取单个项目
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @param data {id}
|
||||
* @param project_id
|
||||
*/
|
||||
getProjectOne({state, dispatch}, data) {
|
||||
if (state.method.runNum(data.id) === 0) {
|
||||
return;
|
||||
}
|
||||
getProjectOne({state, dispatch}, project_id) {
|
||||
dispatch("call", {
|
||||
url: 'project/one',
|
||||
data: {
|
||||
project_id: data.id,
|
||||
project_id,
|
||||
},
|
||||
}).then(result => {
|
||||
dispatch("saveProject", result.data);
|
||||
@ -333,35 +351,23 @@ export default {
|
||||
|
||||
/**
|
||||
* 删除项目
|
||||
* @param state
|
||||
* @param data {id}
|
||||
* @param dispatch
|
||||
* @param project_id
|
||||
*/
|
||||
removeProject({state}, data) {
|
||||
if (state.method.runNum(data.id) === 0) {
|
||||
return;
|
||||
}
|
||||
let index = state.projects.findIndex(({id}) => id == data.id);
|
||||
if (index > -1) {
|
||||
state.projects.splice(index, 1);
|
||||
}
|
||||
if (state.projectId == data.id) {
|
||||
const project = state.projects.find(({id}) => id && id != data.id);
|
||||
if (project) {
|
||||
$A.goForward({path: '/manage/project/' + project.id});
|
||||
} else {
|
||||
$A.goForward({path: '/manage/dashboard'});
|
||||
}
|
||||
}
|
||||
//
|
||||
dispatch("call", {
|
||||
url: 'project/delete',
|
||||
data: {
|
||||
project_id: data.id,
|
||||
},
|
||||
}).then(result => {
|
||||
state.method.setStorage("cacheProjects", state.cacheProjects = state.projects);
|
||||
}).catch(result => {
|
||||
//
|
||||
removeProject({dispatch}, project_id) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
dispatch("call", {
|
||||
url: 'project/delete',
|
||||
data: {
|
||||
project_id,
|
||||
},
|
||||
}).then(result => {
|
||||
dispatch("forgetProject", project_id)
|
||||
resolve(result)
|
||||
}).catch(result => {
|
||||
dispatch("getProjectOne", project_id);
|
||||
reject(result)
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@ -405,13 +411,26 @@ export default {
|
||||
state.method.setStorage("cacheColumns", state.cacheColumns = state.columns);
|
||||
},
|
||||
|
||||
/**
|
||||
* 忘记列表数据
|
||||
* @param state
|
||||
* @param column_id
|
||||
*/
|
||||
forgetColumn({state}, column_id) {
|
||||
let index = state.columns.findIndex(({id}) => id == column_id);
|
||||
if (index > -1) {
|
||||
state.columns.splice(index, 1);
|
||||
}
|
||||
state.method.setStorage("cacheColumns", state.cacheColumns = state.columns);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @param data {project_id}
|
||||
* @param project_id
|
||||
*/
|
||||
getColumns({state, dispatch}, data) {
|
||||
getColumns({state, dispatch}, project_id) {
|
||||
if (state.userId === 0) {
|
||||
state.columns = [];
|
||||
return;
|
||||
@ -422,7 +441,7 @@ export default {
|
||||
dispatch("call", {
|
||||
url: 'project/column/lists',
|
||||
data: {
|
||||
project_id: data.project_id
|
||||
project_id
|
||||
}
|
||||
}).then(result => {
|
||||
dispatch("saveColumn", result.data.data);
|
||||
@ -433,27 +452,20 @@ export default {
|
||||
|
||||
/**
|
||||
* 删除列表
|
||||
* @param state
|
||||
* @param data {id}
|
||||
* @param dispatch
|
||||
* @param column_id
|
||||
*/
|
||||
removeColumn({state}, data) {
|
||||
if (state.method.runNum(data.id) === 0) {
|
||||
return;
|
||||
}
|
||||
let index = state.columns.findIndex(({id}) => id == data.id);
|
||||
if (index > -1) {
|
||||
state.columns.splice(index, 1);
|
||||
}
|
||||
//
|
||||
dispatch("call", {
|
||||
url: 'project/column/delete',
|
||||
data: {
|
||||
column_id: data.id,
|
||||
},
|
||||
}).then(result => {
|
||||
state.method.setStorage("cacheColumns", state.cacheColumns = state.columns);
|
||||
}).catch(result => {
|
||||
//
|
||||
removeColumn({dispatch}, column_id) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
dispatch("call", {
|
||||
url: 'project/column/delete',
|
||||
data: {
|
||||
column_id,
|
||||
},
|
||||
}).then(result => {
|
||||
dispatch("forgetColumn", column_id)
|
||||
resolve(result)
|
||||
}).catch(reject);
|
||||
});
|
||||
},
|
||||
|
||||
@ -485,11 +497,27 @@ export default {
|
||||
state.method.setStorage("cacheTasks", state.cacheTasks = state.tasks);
|
||||
},
|
||||
|
||||
/**
|
||||
* 忘记任务数据
|
||||
* @param state
|
||||
* @param task_id
|
||||
*/
|
||||
forgetTask({state}, task_id) {
|
||||
let index = state.tasks.findIndex(({id}) => id == task_id);
|
||||
if (index > -1) {
|
||||
state.tasks.splice(index, 1);
|
||||
}
|
||||
if (state.taskId == task_id) {
|
||||
state.taskId = 0;
|
||||
}
|
||||
state.method.setStorage("cacheTasks", state.cacheTasks = state.tasks);
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取任务
|
||||
* @param state
|
||||
* @param dispatch
|
||||
* @param data {project_id, parent_id}
|
||||
* @param data {?project_id, ?parent_id}
|
||||
*/
|
||||
getTasks({state, dispatch}, data) {
|
||||
if (state.userId === 0) {
|
||||
@ -532,32 +560,46 @@ export default {
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除或归档任务
|
||||
* @param state
|
||||
* 删除任务
|
||||
* @param dispatch
|
||||
* @param data {id, type}
|
||||
* @param task_id
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
taskArchivedOrRemove({state, dispatch}, data) {
|
||||
removeTask({dispatch}, task_id) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (state.method.runNum(data.id) === 0) {
|
||||
return;
|
||||
}
|
||||
let index = state.tasks.findIndex(({id}) => id == data.id);
|
||||
if (index > -1) {
|
||||
state.tasks.splice(index, 1);
|
||||
}
|
||||
//
|
||||
dispatch("call", {
|
||||
url: 'project/task/' + data.type,
|
||||
url: 'project/task/delete',
|
||||
data: {
|
||||
task_id: data.id,
|
||||
task_id: task_id,
|
||||
},
|
||||
}).then(result => {
|
||||
state.method.setStorage("cacheTasks", state.cacheTasks = state.tasks);
|
||||
dispatch("forgetTask", task_id)
|
||||
resolve(result)
|
||||
}).catch(result => {
|
||||
dispatch("getTaskOne", data.id);
|
||||
dispatch("getTaskOne", task_id);
|
||||
reject(result)
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 归档任务
|
||||
* @param dispatch
|
||||
* @param task_id
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
archivedTask({dispatch}, task_id) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
dispatch("call", {
|
||||
url: 'project/task/archived',
|
||||
data: {
|
||||
task_id: task_id,
|
||||
},
|
||||
}).then(result => {
|
||||
dispatch("forgetTask", task_id)
|
||||
resolve(result)
|
||||
}).catch(result => {
|
||||
dispatch("getTaskOne", task_id);
|
||||
reject(result)
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user