处理冲突

This commit is contained in:
caoqianming 2021-03-16 16:13:11 +08:00
commit ec2499a147
3 changed files with 108 additions and 59 deletions

View File

@ -1,21 +1,19 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-card
style="margin-top: 10px"
>
<div> <div>
<el-input <el-input
v-model="listQuery.content__name" v-model="listQuery.content_name"
placeholder="材料名称" placeholder="材料名称"
style="width: 200px" style="width: 200px"
class="filter-item" class="filter-item"
@keyup.enter.native="handleFilter" @keyup.enter.native="handleFilter"
/> />
<el-date-picker
v-model="listQuery.up_date"
align="right"
type="date"
placeholder="上报时间"
:picker-options="pickerOptions1"
@change="handleFilter">
</el-date-picker>
<el-select <el-select
v-model="listQuery.state" v-model="listQuery.state"
placeholder="记录状态" placeholder="记录状态"
@ -31,25 +29,37 @@
:value="item.key" :value="item.key"
/> />
</el-select> </el-select>
<el-input
placeholder="所属部门" <el-select
style="width: 200px" v-model="listQuery.belong_dept"
placeholder="上报部门"
clearable
style="width:140px"
class="filter-item" class="filter-item"
/> @change="handleFilter"
<el-button
class="filter-item"
type="primary"
icon="el-icon-search"
>搜索</el-button
> >
<el-button <el-option
class="filter-item" v-for="item in orgData"
style="margin-left: 10px" :key="item.id"
type="primary" :label="item.name"
icon="el-icon-refresh-left" :value="item.id"
>刷新重置</el-button />
> </el-select>
</div> <el-date-picker
v-model="listQuery.date_gt"
type="date"
value-format="yyyy-MM-dd"
placeholder="上报时间">
</el-date-picker>
<el-date-picker
v-model="listQuery.date_lt"
type="date"
value-format="yyyy-MM-dd"
@change="handleFilter"
placeholder="上报时间">
</el-date-picker>
</div>
</el-card>
<el-card <el-card
style="margin-top: 10px" style="margin-top: 10px"
> >
@ -61,23 +71,37 @@
stripe stripe
highlight-current-row highlight-current-row
max-height="600" max-height="600"
:default-sort = "{prop: 'date', order: 'descending'}"
> >
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="任务标题"> <el-table-column label="任务标题">
<template slot-scope="scope">{{ scope.row.task_.name }}</template> <template slot-scope="scope">{{ scope.row.task_.name }}</template>
</el-table-column> </el-table-column>
<el-table-column label="材料名称"> <el-table-column label="材料名称">
<template slot-scope="scope">{{ scope.row.content_.name }}</template> <template slot-scope="scope">{{ scope.row.content_.name }}</template>
</el-table-column> </el-table-column>
<el-table-column label="上报时间"> <el-table-column sortable label="上报时间">
<template slot-scope="scope">{{ scope.row.up_date }}</template> <template slot-scope="scope">{{ scope.row.up_date }}</template>
</el-table-column> </el-table-column>
<el-table-column label="上报人"> <el-table-column label="上报人">
<template slot-scope="scope">{{ scope.row.up_user }}</template> <template slot-scope="scope">{{ scope.row.up_user }}</template>
</el-table-column> </el-table-column>
<el-table-column label="截止时间"> <el-table-column sortable label="截止时间">
<template slot-scope="scope">{{ scope.row.end_date }}</template> <template slot-scope="scope">{{ scope.row.end_date }}</template>
</el-table-column> </el-table-column>
<el-table-column label="上报备注">
<template slot-scope="scope">{{ scope.row.note }}</template>
</el-table-column>
<el-table-column label="上报说明">
<template slot-scope="scope">{{ scope.row.noteb }}</template>
</el-table-column>
<el-table-column label="上报单位">
<template slot-scope="scope">{{ scope.row.dept_.name }}</template>
</el-table-column>
<el-table-column label="记录状态"> <el-table-column label="记录状态">
<template slot-scope="scope">{{ scope.row.state }}</template> <template slot-scope="scope">{{ scope.row.state }}</template>
</el-table-column> </el-table-column>
@ -86,19 +110,6 @@
<el-tag type="success" v-if="scope.row.is_yes"></el-tag> <el-tag type="success" v-if="scope.row.is_yes"></el-tag>
<el-tag type="danger" v-else></el-tag></template> <el-tag type="danger" v-else></el-tag></template>
</el-table-column> </el-table-column>
<el-table-column label="上报备注">
<template slot-scope="scope">{{ scope.row.note }}</template>
</el-table-column>
<el-table-column label="上报说明">
<template slot-scope="scope">{{ scope.row.noteb }}</template>
</el-table-column>
<el-table-column label="上报文件">
<template slot-scope="scope">{{ scope.row.files }}</template>
</el-table-column>
</el-table-column>
<el-table-column label="上报单位">
<template slot-scope="scope">{{ scope.row.dept_.name }}</template>
</el-table-column>
</el-table> </el-table>
<pagination <pagination
v-show="recordList.count > 0" v-show="recordList.count > 0"
@ -112,7 +123,9 @@
</div> </div>
</template> </template>
<script> <script>
import { getOrgList } from "@/api/org";
import {getRecordList} from "@/api/record"; import {getRecordList} from "@/api/record";
import { genTree } from "@/utils";
import checkPermission from "@/utils/permission"; import checkPermission from "@/utils/permission";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
const defaultrecord = { const defaultrecord = {
@ -126,37 +139,42 @@ export default {
recordList: { recordList: {
count: 0, count: 0,
}, },
orgData: [],
stateOptions: [ stateOptions: [
{ key: "待上报", name: "待上报" }, { key: "待上报", name: "待上报" },
{ key: "已上报", name: "已上报" }, { key: "已上报", name: "已上报" },
{ key: "已确认", name: "已确认" }, { key: "已确认", name: "已确认" },
{ key: "待整改", name: "待整改" }, { key: "待整改", name: "待整改" },
], ],
pickerOptions1: { pickerOptions2: {
disabledDate(time) {
return time.getTime() > Date.now();
},
shortcuts: [{ shortcuts: [{
text: '今天', text: '最近一周',
onClick(picker) { onClick(picker) {
picker.$emit('pick', new Date()); const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
} }
}, { }, {
text: '昨天', text: '最近一个月',
onClick(picker) { onClick(picker) {
const date = new Date(); const end = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24); const start = new Date();
picker.$emit('pick', date); start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
} }
}, { }, {
text: '一周前', text: '最近三个月',
onClick(picker) { onClick(picker) {
const date = new Date(); const end = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7); const start = new Date();
picker.$emit('pick', date); start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
} }
}] }]
}, },
value7: '',
listQuery: { listQuery: {
page: 1, page: 1,
page_size: 20, page_size: 20,
@ -174,9 +192,11 @@ export default {
}, },
created() { created() {
this.getList(); this.getList();
this.getOrgList();
}, },
methods: { methods: {
getList(){ getList(){
getRecordList(this.listQuery).then((response)=>{ getRecordList(this.listQuery).then((response)=>{
this.recordList=response.data this.recordList=response.data
@ -185,7 +205,19 @@ export default {
}) })
} }
, ,
getOrgList() {
getOrgList({ pid: 1 }).then((res) => {
this.orgData = genTree(res.data)
});
},
handleOrgClick(obj, node, vue) {
this.listQuery.page = 1;
this.listQuery.dept_id = obj.id;
this.getList();
},
handleFilter() { handleFilter() {
this.listQuery.page = 1; this.listQuery.page = 1;
this.getList(); this.getList();
}, },

View File

@ -0,0 +1,13 @@
from django_filters import rest_framework as filters
from .models import Record
class RecordFilter(filters.FilterSet):
date_lt = filters.DateFilter(field_name='up_date',lookup_expr="lt")
date_gt = filters.DateFilter(field_name='up_date',lookup_expr="gt")
belong_dept=filters.NumberFilter(field_name='belong_dept')
content_name = filters.CharFilter(field_name='content',lookup_expr='icontains')
state = filters.CharFilter(field_name='state',lookup_expr='icontains')
class Meta:
model = Record
fields = ['up_date','content','belong_dept','state', 'task']

View File

@ -13,6 +13,8 @@ from utils.pagination import PageOrNot
from apps.system.mixins import OptimizationMixin from apps.system.mixins import OptimizationMixin
from apps.system.mixins import CreateUpdateCustomMixin from apps.system.mixins import CreateUpdateCustomMixin
from django.utils import timezone from django.utils import timezone
from .filters import RecordFilter
# Create your views here. # Create your views here.
class ContentViewSet(CreateUpdateCustomMixin, ModelViewSet): class ContentViewSet(CreateUpdateCustomMixin, ModelViewSet):
@ -100,9 +102,9 @@ class RecordViewSet(OptimizationMixin,PageOrNot, CreateUpdateCustomMixin, ModelV
'put': 'record_update', 'delete': 'record_delete'} 'put': 'record_update', 'delete': 'record_delete'}
queryset = Record.objects.all() queryset = Record.objects.all()
serializer_class = RecordSerializer serializer_class = RecordSerializer
search_fields = ['content','task','up_date','state'] search_fields = ['content__name','task__name']
ordering = ['-create_time'] ordering = ['-create_time']
filterset_fields = ['content', 'belong_dept', 'task'] filter_class = RecordFilter # 过滤类
def update(self, request, *args, **kwargs): def update(self, request, *args, **kwargs):
instance = self.get_object() instance = self.get_object()
@ -155,4 +157,6 @@ class RecordViewSet(OptimizationMixin,PageOrNot, CreateUpdateCustomMixin, ModelV
obj.state = '已确认' obj.state = '已确认'
obj.save() obj.save()
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)