This commit is contained in:
shilixia 2021-03-15 09:04:04 +08:00
parent 3475acae63
commit 68280e13af
7 changed files with 304 additions and 5 deletions

15
client/src/api/record.js Normal file
View File

@ -0,0 +1,15 @@
import request from '@/utils/request'
export function getRecordList(query) {
return request({
url: '/supervision/content/',
method: 'get',
params: query
})
}

View File

@ -125,7 +125,14 @@ export const asyncRoutes = [
name: 'STask', name: 'STask',
component: () => import('@/views/supervision/task.vue'), component: () => import('@/views/supervision/task.vue'),
meta: { title: '报送任务', icon: 'guide', perms: ['task_manage'] } meta: { title: '报送任务', icon: 'guide', perms: ['task_manage'] }
}] },
{
path: 'record',
name: 'Record',
component: () => import('@/views/supervision/record.vue'),
meta: { title: '材料列表', icon: 'guide', perms: ['record_manage'] }
}
]
}, },
{ {

View File

@ -0,0 +1,251 @@
<template>
<div class="app-container">
<el-card
style="margin-top: 10px"
>
<el-table
v-loading="listLoading"
:data="contentList"
border
fit
stripe
highlight-current-row
max-height="600"
>
<el-table-column type="index" width="50" />
<el-table-column label="任务标题">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="材料内容">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="上报时间">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="上报人">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="截止时间">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="记录状态">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="是否适用">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="上报备注">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="上报说明">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="上报文件">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
</el-table>
</el-card>
<el-dialog
:visible.sync="dialogVisible"
:title="dialogType === 'edit' ? '编辑资料' : '新增资料'"
>
<el-form
ref="Form"
:model="Content"
label-width="80px"
label-position="right"
:rules="rule1"
>
<el-form-item label="名称" prop="name">
<el-input v-model="Content.name" placeholder="名称" />
</el-form-item>
<el-form-item label="材料类型" prop="type" >
<el-cascader
v-model = "Content.type"
:options="typeOptions"
:props="{ emitPath : false , }"
clearable
style="width:100%"
></el-cascader>
</el-form-item>
<el-form-item label="详情" prop="desc">
<el-input
type="textarea"
:rows="4"
v-model="Content.desc"
placeholder="详情"
/>
</el-form-item>
<el-form-item label="是否可主动报送" prop="can_doself" label-width="120px">
<el-switch v-model="Content.can_doself" ></el-switch>
</el-form-item>
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirm('Form')">确认</el-button>
</div>
</el-dialog>
</div>
</template>
<style>
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409eff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
}
.avatar {
width: 100px;
height: 100px;
display: block;
}
</style>
<script>
import {
getContentList,
createContent,
deleteContent,
updateContent,
} from "@/api/content";
import { genTree } from "@/utils";
import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { getDictList, getDictTypeList } from "@/api/dict";
const defaultContent = {
name: "",
desc: "",
type: null,
can_doself: false,
};
export default {
components: { Pagination, Treeselect },
data() {
return {
Content: defaultContent,
contentList: [],
typeOptions: [],
listLoading: true,
dialogVisible: false,
dialogType: "new",
rule1: {
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
},
filterOrgText: "",
treeLoding: false,
};
},
computed: {},
watch: {
filterOrgText(val) {
this.$refs.tree.filter(val);
},
},
created() {
this.getList();
this.getTypeAll();
},
methods: {
checkPermission,
filterNode(value, data) {
if (!value) return true;
return data.label.indexOf(value) !== -1;
},
getList() {
this.listLoading = true;
getContentList().then((response) => {
if (response.data) {
this.contentList = response.data;
}
this.listLoading = false;
});
},
getTypeAll() {
getDictList({ type__code: "data_type" }).then((res) => {
this.typeOptions = genTree(res.data);
});
},
handleFilter() {
this.listQuery.page = 1;
this.getList();
},
handleAddContent() {
this.Content = Object.assign({}, defaultContent);
this.dialogType = "new";
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["Form"].clearValidate();
});
},
handleEdit(scope) {
this.Content = Object.assign({}, scope.row); // copy obj
this.dialogType = "edit";
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["Form"].clearValidate();
});
},
handleDelete(scope) {
this.$confirm("确认删除?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",
})
.then(async () => {
await deleteContent(scope.row.id);
this.getList();
this.$message.success("成功");
})
.catch((err) => {
console.error(err);
});
},
async confirm(form) {
this.$refs[form].validate((valid) => {
if (valid) {
const isEdit = this.dialogType === "edit";
if (isEdit) {
updateContent(this.Content.id, this.Content).then((res) => {
if (res.code >= 200) {
this.getList();
this.dialogVisible = false;
this.$message.success("成功");
}
});
} else {
createContent(this.Content).then((res) => {
if (res.code >= 200) {
this.getList();
this.dialogVisible = false;
this.$message.success("成功");
}
});
}
} else {
return false;
}
});
},
},
};
</script>

View File

@ -1,6 +1,6 @@
from rest_framework import serializers from rest_framework import serializers
from .models import * from .models import *
from apps.system.serializers import OrganizationSerializer from apps.system.serializers import OrganizationSerializer,FileListSerializer
class ContentSerializer(serializers.ModelSerializer): class ContentSerializer(serializers.ModelSerializer):
type_ = serializers.SerializerMethodField() type_ = serializers.SerializerMethodField()
@ -19,6 +19,10 @@ class ContentSerializer(serializers.ModelSerializer):
if obj.type.pid: if obj.type.pid:
data = obj.type.pid.name + '/' + data data = obj.type.pid.name + '/' + data
return data return data
class ContentListSerializer(serializers.ModelSerializer):
class Meta:
model = Content
fields = ['name', 'desc']
class TaskCreateUpdateSerializer(serializers.ModelSerializer): class TaskCreateUpdateSerializer(serializers.ModelSerializer):
class Meta: class Meta:
@ -28,4 +32,15 @@ class TaskCreateUpdateSerializer(serializers.ModelSerializer):
class TaskListSerializer(serializers.ModelSerializer): class TaskListSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Task model = Task
fields = ['name', 'is_self', 'end_date', 'note', 'complete_rate'] fields = ['name', 'is_self', 'end_date', 'note', 'complete_rate']
class RecordSerializer(serializers.ModelSerializer):
files_ = FileListSerializer(source='files', many=True, read_only=True)
task_ = TaskListSerializer(source='task')
content_=ContentListSerializer(source='content')
class Meta:
model = Record
fields = ('id', 'up_date', 'up_user', 'end_date', 'state',
'is_yes', 'note', 'noteb','content','content_','task_','task', 'files', 'files_')

View File

@ -1,9 +1,10 @@
from django.urls import path, include from django.urls import path, include
from rest_framework import routers from rest_framework import routers
from .views import ContentViewSet from .views import ContentViewSet,RecordViewSet
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.register('content', ContentViewSet, basename="content") router.register('content', ContentViewSet, basename="content")
router.register('record', RecordViewSet, basename="record")
urlpatterns = [ urlpatterns = [
path('', include(router.urls)) path('', include(router.urls))
] ]

View File

@ -38,4 +38,10 @@ class TaskViewSet(CreateUpdateCustomMixin, ModelViewSet):
if self.action in ['create', 'update']: if self.action in ['create', 'update']:
return TaskCreateUpdateSerializer return TaskCreateUpdateSerializer
return TaskListSerializer return TaskListSerializer
class RecordViewSet(CreateUpdateCustomMixin,ModelViewSet):
perms_map = {'get': '*', 'post': 'record_create',
'put': 'record_update', 'delete': 'record_delete'}
queryset = Record.objects.all()
serializer_class = RecordSerializer
search_fields = ['name']
ordering = ['-create_time']

View File

@ -9,6 +9,10 @@ class FileSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = File model = File
fields = "__all__" fields = "__all__"
class FileListSerializer(serializers.ModelSerializer):
class Meta:
model = File
fields = ['name']
class DictTypeSerializer(serializers.ModelSerializer): class DictTypeSerializer(serializers.ModelSerializer):
""" """