创建上报记录
This commit is contained in:
parent
19ea893549
commit
9c3190cad6
|
@ -40,3 +40,11 @@ export function deletetask(id, data) {
|
|||
})
|
||||
}
|
||||
|
||||
export function inittask(id, data) {
|
||||
return request({
|
||||
url: `/supervision/task/${id}/init/`,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@ if (process.env.NODE_ENV === 'production') {
|
|||
Vue.use(ElementUI, { size: 'medium' })
|
||||
|
||||
Vue.config.productionTip = false
|
||||
Vue.prototype.openLoading = function() {
|
||||
Vue.prototype.openLoading = function(msg) {
|
||||
const loading = this.$loading({ // 声明一个loading对象
|
||||
lock: true, // 是否锁屏
|
||||
text: '正在加载...', // 加载动画的文字
|
||||
text: msg, // 加载动画的文字
|
||||
body: true,
|
||||
})
|
||||
setTimeout(function () { // 设定定时器,超时5S后自动关闭遮罩层,避免请求失败时,遮罩层一直存在的问题
|
||||
|
|
|
@ -110,7 +110,7 @@ export const asyncRoutes = [
|
|||
{
|
||||
path: '/supervision',
|
||||
component: Layout,
|
||||
redirect: '/supervision/content',
|
||||
redirect: '/supervision/task',
|
||||
name:'Supervision',
|
||||
meta: { title: '日常监督', icon: 'table', perms: ['supervision_manage'] },
|
||||
children: [
|
||||
|
@ -122,10 +122,18 @@ export const asyncRoutes = [
|
|||
},
|
||||
{
|
||||
path: 'task',
|
||||
name: 'STask',
|
||||
name: 'Task',
|
||||
component: () => import('@/views/supervision/task.vue'),
|
||||
meta: { title: '报送任务', icon: 'guide', perms: ['task_manage'] }
|
||||
}]
|
||||
meta: { title: '报送任务', icon: 'guide', perms: ['task_view'] }
|
||||
},
|
||||
{
|
||||
path: 'taskdo/:id',
|
||||
name: 'Taskdo',
|
||||
component: () => import('@/views/supervision/taskdo.vue'),
|
||||
meta: { title: '报送任务执行', perms: ['task_view'] },
|
||||
hidden: true
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
|
|
|
@ -75,6 +75,7 @@ div:focus {
|
|||
border-radius: 0px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.el-card__body {
|
||||
padding: 6px;
|
||||
}
|
||||
|
@ -90,18 +91,14 @@ div:focus {
|
|||
.el-dialog__body {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
// .el-form-item--medium .el-form-item__label {
|
||||
// line-height: 16px;
|
||||
// }
|
||||
|
||||
.el-form--label-top .el-form-item__label {
|
||||
line-height: 16px;
|
||||
}
|
||||
.el-button+.el-button {
|
||||
margin-left: 1px;
|
||||
}
|
||||
.el-button {
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.el-table--medium td, .el-table--medium th {
|
||||
|
@ -111,9 +108,4 @@ div:focus {
|
|||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.el-card__body {
|
||||
padding: 10px;
|
||||
}
|
||||
.el-card__header {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@
|
|||
type="primary"
|
||||
:disabled="!checkPermission(['task_view'])"
|
||||
size="small"
|
||||
@click="handleDetail(scope)"
|
||||
>详情</el-button>
|
||||
@click="handleDo(scope)"
|
||||
>执行</el-button>
|
||||
<el-button
|
||||
:disabled="!checkPermission(['task_update'])"
|
||||
size="small"
|
||||
|
@ -209,6 +209,9 @@ export default {
|
|||
},
|
||||
handleCreate2() {
|
||||
|
||||
},
|
||||
handleDo(scope) {
|
||||
this.$router.push({name: "Taskdo", params: { id: scope.row.id }, })
|
||||
},
|
||||
handleEdit(scope) {
|
||||
this.task = Object.assign({}, scope.row); // copy obj
|
||||
|
@ -232,9 +235,6 @@ export default {
|
|||
.catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
},
|
||||
handleDetail(scope){
|
||||
|
||||
},
|
||||
async confirm(form) {
|
||||
this.$refs[form].validate((valid) => {
|
||||
|
@ -253,6 +253,7 @@ export default {
|
|||
if (res.code >= 200) {
|
||||
this.getList();
|
||||
this.dialogVisible = false;
|
||||
this.$router.push({name: "Taskdo", params: { id: res.data.id }, })
|
||||
this.$message.success("成功");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<el-card>
|
||||
<div slot="header" class="clearfix">
|
||||
<span>任务详情</span>
|
||||
</div>
|
||||
<div style="margin-left:10px;margin-right:10px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<div style="margin-bottom:6px">
|
||||
<span class="term">任务名称</span>
|
||||
<span class="desc"> {{ task.name}}</span>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div style="margin-bottom:6px">
|
||||
<span class="term">截止日期</span>
|
||||
<span class="desc"> {{ task.end_date}}</span>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div style="margin-bottom:6px">
|
||||
<span class="term">创建人</span>
|
||||
<span class="desc" v-if="task.create_by_"> {{ task.create_by_.name}}/</span>
|
||||
<span v-if="task.belong_dept_">{{ task.belong_dept_.name }}</span>
|
||||
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div style="margin-bottom:6px">
|
||||
<span class="term">任务状态</span>
|
||||
<span class="desc"> {{ task.state}}</span>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div style="margin-bottom:6px">
|
||||
<span class="term">完成度</span>
|
||||
<span class="desc"> {{ task.complete_rate}}%</span>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div style="margin-bottom:6px">
|
||||
<span class="term">备注</span>
|
||||
<span class="desc"> {{ task.note}}</span>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div style="margin-top:4px">
|
||||
<el-button type="primary" @click="init()" v-if="task.state=='创建中'" size="small">初始化任务</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
|
||||
<el-card style="margin-top:2px">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>执行详情</span>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-dialog
|
||||
:visible.sync="dialogVisible"
|
||||
title="初始化任务"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<taskinit ref="taskinit" @handleChose="chooseComplete"></taskinit>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<style >
|
||||
.term{
|
||||
color: rgba(0,0,0,.85);
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
.desc{
|
||||
color: rgba(0, 0, 0, 0.65);
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
import {gettask, inittask} from "@/api/task"
|
||||
import Pagination from "@/components/Pagination";
|
||||
import taskinit from "@/views/supervision/taskinit";
|
||||
export default {
|
||||
components: {Pagination, taskinit},
|
||||
data(){
|
||||
return {
|
||||
task:{id:0},
|
||||
dialogVisible:false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.task.id = this.$route.params.id
|
||||
this.gettask()
|
||||
},
|
||||
methods:{
|
||||
gettask(){
|
||||
gettask(this.task.id).then(res=>{
|
||||
this.task = res.data
|
||||
if(this.task.state=='创建中'){
|
||||
this.dialogVisible = true
|
||||
}
|
||||
})
|
||||
},
|
||||
init(){
|
||||
this.dialogVisible = true
|
||||
},
|
||||
chooseComplete(data){
|
||||
this.dialogVisible = false;
|
||||
const rLoading = this.openLoading('正在初始化任务,请稍等...');
|
||||
inittask(this.task.id, data).then(res=>{
|
||||
rLoading.close()
|
||||
this.$message.success('成功')
|
||||
this.$router.go(0);
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,65 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-transfer
|
||||
v-model="contents"
|
||||
:data="contentOptions"
|
||||
:titles="['材料清单', '选择的清单']"
|
||||
:props="{ key : 'id' , label: 'name' }"
|
||||
/>
|
||||
<el-transfer
|
||||
v-model="depts"
|
||||
:data="deptOptions"
|
||||
:titles="['单位列表', '选择的单位']"
|
||||
:props="{ key : 'id' , label: 'name' }"
|
||||
/>
|
||||
|
||||
<div style="text-align: right">
|
||||
<el-button type="primary" @click="confirm()">确认</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<style >
|
||||
</style>
|
||||
<script>
|
||||
import { getOrgList } from "@/api/org";
|
||||
import { getContentList } from "@/api/content";
|
||||
export default {
|
||||
name: "taskinit",
|
||||
data() {
|
||||
return {
|
||||
depts: [],
|
||||
deptOptions: [],
|
||||
contents: [],
|
||||
contentOptions: [],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getOrgList();
|
||||
this.getContentList();
|
||||
},
|
||||
methods: {
|
||||
getOrgList() {
|
||||
getOrgList({ pid: 1 }).then((res) => {
|
||||
this.deptOptions = res.data;
|
||||
});
|
||||
},
|
||||
getContentList() {
|
||||
getContentList().then(res=>{
|
||||
this.contentOptions = res.data
|
||||
})
|
||||
},
|
||||
confirm(){
|
||||
if(this.contents.length>0 && this.depts.length>0){
|
||||
var data = {
|
||||
depts:this.depts,
|
||||
contents: this.contents
|
||||
}
|
||||
this.$emit('handleChose', data)
|
||||
}else{
|
||||
this.$message.error('请选择清单和单位!')
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,43 @@
|
|||
# Generated by Django 3.0.5 on 2021-03-15 06:12
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('system', '0008_auto_20210311_0919'),
|
||||
('supervision', '0006_auto_20210312_1440'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='record',
|
||||
name='belong_to',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='task',
|
||||
name='belong_to',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='record',
|
||||
name='belong_dept',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='record_belong_dept', to='system.Organization', verbose_name='所属部门'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='record',
|
||||
name='up_date',
|
||||
field=models.DateField(blank=True, null=True, verbose_name='上报时间'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='task',
|
||||
name='belong_dept',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='task_belong_dept', to='system.Organization', verbose_name='所属部门'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='task',
|
||||
name='is_self',
|
||||
field=models.BooleanField(default=False, verbose_name='是否主动报送'),
|
||||
),
|
||||
]
|
|
@ -1,6 +1,7 @@
|
|||
from django.db.models.base import Model
|
||||
from rest_framework import serializers
|
||||
from .models import *
|
||||
from apps.system.serializers import OrganizationSerializer
|
||||
from apps.system.serializers import OrganizationSimpleSerializer, UserSimpleSerializer
|
||||
|
||||
class ContentSerializer(serializers.ModelSerializer):
|
||||
type_ = serializers.SerializerMethodField()
|
||||
|
@ -23,9 +24,17 @@ class ContentSerializer(serializers.ModelSerializer):
|
|||
class TaskCreateUpdateSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Task
|
||||
fields = ['name', 'end_date', 'note']
|
||||
fields = ['name', 'end_date', 'note', 'id']
|
||||
|
||||
class TaskListSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Task
|
||||
fields = ['name', 'is_self', 'end_date', 'note', 'complete_rate', 'state']
|
||||
fields = ['name', 'is_self', 'end_date', 'note', 'complete_rate', 'state', 'id']
|
||||
|
||||
|
||||
class TaksDetailSerializer(serializers.ModelSerializer):
|
||||
create_by_ = UserSimpleSerializer(source='create_by', read_only = True)
|
||||
belong_dept_ = OrganizationSimpleSerializer(source='belong_dept', read_only=True)
|
||||
class Meta:
|
||||
model = Task
|
||||
fields = '__all__'
|
|
@ -36,6 +36,8 @@ class TaskViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
|||
def get_serializer_class(self):
|
||||
if self.action in ['create', 'update']:
|
||||
return TaskCreateUpdateSerializer
|
||||
elif self.action == 'retrieve':
|
||||
return TaksDetailSerializer
|
||||
return TaskListSerializer
|
||||
|
||||
@action(methods=['post'], detail=False, perms_map = {'post':'task_createself'})
|
||||
|
@ -47,4 +49,30 @@ class TaskViewSet(CreateUpdateCustomMixin, ModelViewSet):
|
|||
serializer.is_valid(raise_exception=True)
|
||||
serializer.save(is_self=True, create_by=request.user, belong_dept=request.user.dept)
|
||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||
|
||||
@action(methods=['post'], detail=True, perms_map = {'post':'task_init'})
|
||||
def init(self, request, *args, **kwargs):
|
||||
"""
|
||||
初始化任务,生成记录
|
||||
"""
|
||||
obj = self.get_object()
|
||||
depts = request.data['depts']
|
||||
contents = request.data['contents']
|
||||
if depts and contents:
|
||||
record_list = []
|
||||
for m in depts:
|
||||
for n in contents:
|
||||
data={}
|
||||
data['content'] = Content.objects.get(pk=n)
|
||||
data['belong_dept'] = Organization.objects.get(pk=m)
|
||||
data['task'] = obj
|
||||
data['end_date'] = obj.end_date
|
||||
data['create_by'] = request.user
|
||||
record_list.append(Record(**data))
|
||||
Record.objects.bulk_create(record_list)
|
||||
obj.state = '执行中'
|
||||
obj.save()
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
return Response('单位或清单不能为空', status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
|
@ -134,3 +134,13 @@ class UserCreateSerializer(serializers.ModelSerializer):
|
|||
if User.objects.filter(phone=phone):
|
||||
raise serializers.ValidationError('手机号已经被注册')
|
||||
return phone
|
||||
|
||||
class UserSimpleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['id', 'name', 'username']
|
||||
|
||||
class OrganizationSimpleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Organization
|
||||
fields = ['id', 'name']
|
||||
|
|
|
@ -198,6 +198,7 @@ class OrganizationViewSet(PageOrNot,ModelViewSet):
|
|||
serializer_class = OrganizationSerializer
|
||||
pagination_class = None
|
||||
search_fields = ['name']
|
||||
filterset_fields = ['pid','name']
|
||||
ordering_fields = ['sort']
|
||||
ordering = ['sort', 'pk']
|
||||
|
||||
|
|
Loading…
Reference in New Issue