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