增加追加任务
This commit is contained in:
parent
6cffb4bf26
commit
3cfd346873
|
@ -48,6 +48,13 @@ export function inittask(id, data) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function appendtask(id, data) {
|
||||||
|
return request({
|
||||||
|
url: `/supervision/task/${id}/append/`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function gettaskcontents(id) {
|
export function gettaskcontents(id) {
|
||||||
return request({
|
return request({
|
||||||
|
|
|
@ -74,6 +74,13 @@
|
||||||
size="small"
|
size="small"
|
||||||
>初始化任务</el-button
|
>初始化任务</el-button
|
||||||
>
|
>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
@click="append()"
|
||||||
|
v-if="task.state == '执行中'"
|
||||||
|
size="small"
|
||||||
|
>追加任务</el-button
|
||||||
|
>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="starttask()"
|
@click="starttask()"
|
||||||
|
@ -258,7 +265,7 @@
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
:visible.sync="dialogVisible"
|
:visible.sync="dialogVisible"
|
||||||
title="初始化任务"
|
:title="dgaction.name"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
width="70%"
|
width="70%"
|
||||||
>
|
>
|
||||||
|
@ -298,7 +305,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
import { gettask, inittask, gettaskdeptall, starttask } from "@/api/task";
|
import { gettask, inittask, gettaskdeptall, starttask, appendtask } from "@/api/task";
|
||||||
import { getRecordList, updateRecords } from "@/api/record";
|
import { getRecordList, updateRecords } from "@/api/record";
|
||||||
import Pagination from "@/components/Pagination";
|
import Pagination from "@/components/Pagination";
|
||||||
import taskinit from "@/views/supervision/taskinit";
|
import taskinit from "@/views/supervision/taskinit";
|
||||||
|
@ -322,7 +329,11 @@ export default {
|
||||||
data: {},
|
data: {},
|
||||||
taskdeptall: [],
|
taskdeptall: [],
|
||||||
listQuery:{},
|
listQuery:{},
|
||||||
selectRecords:[]
|
selectRecords:[],
|
||||||
|
dgaction:{
|
||||||
|
action:'init',
|
||||||
|
name:'初始化任务'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -352,16 +363,37 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
|
this.dgaction ={
|
||||||
|
action:'init',
|
||||||
|
name:'初始化任务'
|
||||||
|
}
|
||||||
|
this.dialogVisible = true;
|
||||||
|
},
|
||||||
|
append() {
|
||||||
|
this.dgaction ={
|
||||||
|
action:'append',
|
||||||
|
name:'追加任务'
|
||||||
|
}
|
||||||
this.dialogVisible = true;
|
this.dialogVisible = true;
|
||||||
},
|
},
|
||||||
chooseComplete(data) {
|
chooseComplete(data) {
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
|
if(this.dgaction.action == 'init'){
|
||||||
const rLoading = this.openLoading("正在初始化任务,请稍等...");
|
const rLoading = this.openLoading("正在初始化任务,请稍等...");
|
||||||
inittask(this.task.id, data).then((res) => {
|
inittask(this.task.id, data).then((res) => {
|
||||||
rLoading.close();
|
rLoading.close();
|
||||||
this.$message.success("成功");
|
this.$message.success("成功");
|
||||||
this.$router.go(0);
|
this.$router.go(0);
|
||||||
});
|
}).catch(e=>{rLoading.close();});
|
||||||
|
}else if(this.dgaction.action == 'append'){
|
||||||
|
const rLoading = this.openLoading("正在追加任务,请稍等...");
|
||||||
|
appendtask(this.task.id, data).then((res) => {
|
||||||
|
rLoading.close();
|
||||||
|
this.$message.success("成功");
|
||||||
|
this.$router.go(0);
|
||||||
|
}).catch(e=>{rLoading.close();});
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
starttask() {
|
starttask() {
|
||||||
this.$confirm("确认发布任务吗?", "提示")
|
this.$confirm("确认发布任务吗?", "提示")
|
||||||
|
|
|
@ -91,6 +91,38 @@ class TaskViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
||||||
return Response(status=status.HTTP_200_OK)
|
return Response(status=status.HTTP_200_OK)
|
||||||
return Response('单位或清单不能为空', status=status.HTTP_400_BAD_REQUEST)
|
return Response('单位或清单不能为空', status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
@action(methods=['post'], detail=True, perms_map = {'post':'task_append'})
|
||||||
|
def append(self, request, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
追加任务,生成记录
|
||||||
|
"""
|
||||||
|
obj = self.get_object()
|
||||||
|
depts = request.data['depts']
|
||||||
|
contents = request.data['contents']
|
||||||
|
if obj.state !='执行中':
|
||||||
|
return Response('任务状态错误', status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
if depts and contents:
|
||||||
|
for m in depts:
|
||||||
|
m = Organization.objects.get(pk=m)
|
||||||
|
TaskDept.objects.get_or_create(task=obj, dept=m, defaults={'task':obj, 'dept':m})
|
||||||
|
for n in contents:
|
||||||
|
n = Content.objects.get(pk=n)
|
||||||
|
if not Record.objects.filter(belong_dept=m, content=n, task=obj).exists():
|
||||||
|
r = Record()
|
||||||
|
r.content = n
|
||||||
|
r.content_name = n.name
|
||||||
|
r.content_desc = n.desc
|
||||||
|
r.belong_dept = m
|
||||||
|
r.task = obj
|
||||||
|
r.end_date = obj.end_date
|
||||||
|
r.create_by = request.user
|
||||||
|
r.state = '待上报'
|
||||||
|
r.save()
|
||||||
|
obj.save()
|
||||||
|
return Response(status=status.HTTP_200_OK)
|
||||||
|
return Response('单位或清单不能为空', status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
@action(methods=['get'], detail=True, perms_map = {'get':'*'})
|
@action(methods=['get'], detail=True, perms_map = {'get':'*'})
|
||||||
def contents(self, request, *args, **kwargs):
|
def contents(self, request, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue