小程序调整
This commit is contained in:
parent
57f6ab09a7
commit
ca96758438
|
@ -34,7 +34,9 @@ const install = (Vue, vm) => {
|
|||
|
||||
let checkInspectRecord = (id, params)=> vm.$u.put(`/quality/inspectrecord/${id}/check/`, params);
|
||||
|
||||
let upInspectDept = (id, params)=>vm.$u.put(`/quality/inspectdept/${id}/up/`, params);
|
||||
let upInspectDept = (id, params)=>vm.$u.put(`/quality/inspectdept/${id}/up/`, params);//提交记录
|
||||
|
||||
let appointChecker = (params) => vm.$u.post('/quality/inspectrecord/appoint/', params);//检查指派
|
||||
vm.$u.api = {getUserInfo,
|
||||
getCode,
|
||||
codeLogin,
|
||||
|
@ -46,7 +48,8 @@ const install = (Vue, vm) => {
|
|||
getSubtaskDept,
|
||||
getInspectRecord,
|
||||
checkInspectRecord,
|
||||
upInspectDept
|
||||
upInspectDept,
|
||||
appointChecker,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,9 @@ const install = (Vue, vm) => {
|
|||
}
|
||||
else if(res.code === 401){
|
||||
vm.$u.toast('验证失败,请重新登录');
|
||||
// uni.reLaunch({
|
||||
// url:'/pages/login/login'
|
||||
// })
|
||||
uni.reLaunch({
|
||||
url:'/pages/login/login'
|
||||
})
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"path" : "pages/home/home",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText": "主页",
|
||||
"navigationBarTitleText": "",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
|
||||
|
|
|
@ -13,17 +13,17 @@
|
|||
<view style="margin-bottom: 12rpx;">
|
||||
<u-grid :col="3" :border="false">
|
||||
<u-grid-item v-for="(item, index) in grids" v-bind:key="index" @click="clickGrid(item)">
|
||||
<u-icon :name="item.icon" :size="60"></u-icon>
|
||||
<u-icon :name="item.icon" :size="60" color="#2b85e4" size="72"></u-icon>
|
||||
<view class="grid-text">{{item.name}}</view>
|
||||
</u-grid-item>
|
||||
</u-grid>
|
||||
</view>
|
||||
|
||||
<view style="margin-bottom: 12rpx;margin-left: 6rpx;">
|
||||
<view style="margin-bottom: 12rpx;margin-left: 6rpx;" v-if="myinspecttaskList.length>0">
|
||||
<u-section title="最近任务" :right="false" ></u-section>
|
||||
</view>
|
||||
<u-card v-for="(item, index) in myinspecttaskList" v-bind:key="index" :title="item.name" margin="12rpx"
|
||||
:border="false" :foot-border-top="false" border-radius="2rpx" :head-style="headstyle"
|
||||
:border="false" :foot-border-top="false" border-radius="8rpx" :head-style="headstyle"
|
||||
@body-click="taskClick" :index="item.id" padding="10">
|
||||
<view class="" slot="body">
|
||||
<view class="u-body-item-title">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<view class="wrap">
|
||||
<u-card :title="initData.dept__name" margin="12rpx" :border="false" :foot-border-top="false" border-radius="2rpx"
|
||||
:head-style="headstyle" padding="10">
|
||||
<u-card :title="initData.dept__name" margin="12rpx" :border="false" :foot-border-top="false" border-radius="8rpx"
|
||||
:head-style="headstyle" padding="10" >
|
||||
<view class="" slot="body">
|
||||
<view class="u-body-item-title">
|
||||
<span class="itemstate">{{initData.state}}</span>
|
||||
|
@ -10,7 +10,7 @@
|
|||
<view class="" slot="foot">
|
||||
<view style="flex:true;text-align: right;">
|
||||
<u-checkbox @change="selfChange" v-model="is_self">只看我的</u-checkbox>
|
||||
<u-button type="primary" size="mini" style="margin-left:6rpx" @click="upReport" v-if="initData.state=='检查中'&&initData.leader==vuex_user.id">提交结果</u-button>
|
||||
<u-button type="warning" size="mini" style="margin-left:6rpx" @click="upReport" v-if="initData.state=='检查中'&&initData.leader==vuex_user.id">提交结果</u-button>
|
||||
<u-button size="mini" style="margin-left:6rpx" @click="goReport" v-if="initData.state=='已提交'">查看报告</u-button>
|
||||
</view>
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
|||
<view style="background-color: #ffffff;padding: 8rpx;">
|
||||
<u-tabs :list="list" :is-scroll="false" :current="currentIndex" @change="sectionChange"></u-tabs>
|
||||
<!-- <u-card v-for="(item, index) in records" v-bind:key="index" margin="6rpx"
|
||||
:border="false" :foot-border-top="false" border-radius="2rpx" :head-style="headstyle"
|
||||
:border="false" :foot-border-top="false" border-radius="8rpx" :head-style="headstyle"
|
||||
@body-click="clickRow" :index="item.id" padding="10" v-if="getShow(item.checked)">
|
||||
<view class="" slot="body">
|
||||
<view class="u-body-item-title">
|
||||
|
@ -38,9 +38,20 @@
|
|||
</view>
|
||||
</view>
|
||||
</u-card> -->
|
||||
|
||||
<view v-if="currentIndex==0" style="text-align: right;">
|
||||
<u-checkbox v-model="mutiSelect" @change="mutiSelectChange">多选</u-checkbox>
|
||||
<u-button type="primary" size="mini" style="margin-left:6rpx" @click="membersShow" v-if="initData.leader==vuex_user.id && mutiSelect">指派给</u-button>
|
||||
</view>
|
||||
<view style="margin-top:6rpx">
|
||||
<u-gap height="1" bg-color="#bbb"></u-gap>
|
||||
</view>
|
||||
<view v-for="(item, index) in records" v-bind:key="index" v-if="getShow(item.checked)"
|
||||
style="padding: 12rpx;">
|
||||
<view class="u-body-item-title">{{item.item_.sortnum}}.{{item.item_.name}}</view>
|
||||
style="padding: 12rpx;" @click="clickRow2(item)">
|
||||
<view class="u-body-item-title">
|
||||
<u-checkbox v-model="item.selected" v-if="mutiSelect"></u-checkbox>
|
||||
{{item.item_.sortnum}}.{{item.item_.name}}
|
||||
</view>
|
||||
<view class="u-body-item">
|
||||
<span v-if="item.checker_">{{item.checker_.name}}</span>--
|
||||
<span v-if="item.result=='发现'" style="color:red">{{item.result}}</span>
|
||||
|
@ -83,6 +94,7 @@
|
|||
<view style="margin-top:16rpx">
|
||||
<u-divider bg-color="#ededed">没有更多了</u-divider>
|
||||
</view>
|
||||
<u-picker mode="selector" v-model="showMembers" :default-selector="[0]" :range="members" range-key="member__name" @confirm="pickerConfirm"></u-picker>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
@ -110,30 +122,50 @@
|
|||
// records1:[],
|
||||
// records2:[],
|
||||
is_self: false,
|
||||
showNo: false
|
||||
showNo: false,
|
||||
mutiSelect:false,
|
||||
showMembers:false,
|
||||
members:[],
|
||||
selects:[]
|
||||
}
|
||||
},
|
||||
onLoad(options) {
|
||||
this.initData = options;
|
||||
let pages = getCurrentPages();
|
||||
let prePage = pages[pages.length - 2];
|
||||
if(prePage && prePage.subtask){
|
||||
this.members = prePage.subtask.members
|
||||
}else{
|
||||
this.$u.api.getSubinspectTask(this.initData.subtask).then(res=>{
|
||||
this.members = res.data.members
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
onShow() {
|
||||
this.getSubtaskDept();
|
||||
this.$u.api.getInspectRecords({
|
||||
subtask: this.initData.subtask,
|
||||
dept: this.initData.dept,
|
||||
pageoff: true
|
||||
}).then(res => {
|
||||
this.records_ = res.data
|
||||
this.records = res.data
|
||||
this.sectionChange(this.currentIndex)
|
||||
// this.setCollapse(this.records_)
|
||||
})
|
||||
this.getRecords()
|
||||
},
|
||||
methods: {
|
||||
getSubtaskDept() {
|
||||
this.$u.api.getSubtaskDept(this.initData.id).then(res => {
|
||||
this.initData = res.data
|
||||
if(this.initData.state == '已提交'){
|
||||
this.sectionChange(1)
|
||||
}
|
||||
})
|
||||
},
|
||||
getRecords(){
|
||||
this.$u.api.getInspectRecords({
|
||||
subtask: this.initData.subtask,
|
||||
dept: this.initData.dept,
|
||||
pageoff: true
|
||||
}).then(res => {
|
||||
this.records_ = res.data
|
||||
this.records = res.data
|
||||
this.mutiSelect = false
|
||||
this.sectionChange(this.currentIndex)
|
||||
// this.setCollapse(this.records_)
|
||||
})
|
||||
},
|
||||
selfChange(val) {
|
||||
|
@ -153,6 +185,13 @@
|
|||
sectionChange(index) {
|
||||
this.currentIndex = index;
|
||||
},
|
||||
mutiSelectChange(){
|
||||
if(this.mutiSelect){
|
||||
for(var i=0;i<this.records.length;i++){
|
||||
this.records[i].selected = false
|
||||
}
|
||||
}
|
||||
},
|
||||
getShow(val) {
|
||||
if (val && this.currentIndex == 1) {
|
||||
return true
|
||||
|
@ -183,7 +222,7 @@
|
|||
// uni.navigateTo({
|
||||
// url:'/pages/inspectrecord/recorddo'
|
||||
// })
|
||||
if((item.checker!= this.vuex_user.id && item.checker == null) || this.initData.leader==this.vuex_user.id ){
|
||||
if((item.checker!= this.vuex_user.id && item.checker == null) || this.initData.leader==this.vuex_user.id || item.checker == this.vuex_user.id){
|
||||
this.$u.route({
|
||||
url: '/pages/inspectrecord/recorddo',
|
||||
params: {
|
||||
|
@ -209,6 +248,39 @@
|
|||
goReport(){
|
||||
this.$u.toast('暂未开通')
|
||||
},
|
||||
membersShow(){
|
||||
let selects= []
|
||||
for(var i=0;i<this.records.length;i++){
|
||||
if(this.records[i].selected){
|
||||
selects.push(this.records[i].id)
|
||||
}
|
||||
}
|
||||
if(selects.length>0){
|
||||
this.showMembers=true
|
||||
this.selects = selects
|
||||
}else{
|
||||
this.$u.toast('请选择检查项')
|
||||
}
|
||||
|
||||
},
|
||||
pickerConfirm(index){
|
||||
var that = this
|
||||
let checker = that.members[index].member
|
||||
uni.showModal({
|
||||
title: '提交',
|
||||
content: '确认将'+ that.selects.length +'个检查指派给'+ that.members[index].member__name +'吗?',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
that.$u.api.appointChecker({records:that.selects, checker:checker}).then(res=>{
|
||||
that.$u.toast('成功')
|
||||
that.getRecords()
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
upReport(){
|
||||
let that = this
|
||||
uni.showModal({
|
||||
|
@ -217,8 +289,8 @@
|
|||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
that.$u.api.upInspectDept(that.initData.id).then(res=>{
|
||||
this.initData = res.data
|
||||
this.$u.toast('提交成功')
|
||||
that.initData = res.data
|
||||
that.$u.toast('提交成功')
|
||||
}).catch(e=>{})
|
||||
} else if (res.cancel) {
|
||||
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
<u-form :model="form" label-position="top" :label-style="labelStyle" ref="uForm" :rules="rules"
|
||||
:errorType="errorType">
|
||||
<u-form-item label="检查事项" v-if="form.item_">
|
||||
<view >类别:<span style="color:darkblue;font-weight: bold;">{{form.item_.type}}</span></view>
|
||||
<view>
|
||||
<view>类别:<span style="color:darkblue;font-weight: bold;">{{form.item_.type}}</span></view>
|
||||
<view>{{form.item_.sortnum}}.{{form.item_.name}}</view>
|
||||
</view>
|
||||
</u-form-item>
|
||||
<u-form-item label="取证要求" v-if="form.item_">
|
||||
<span>{{form.item_.require}}</span>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
:errorType="errorType">
|
||||
<u-form-item label="检查事项" v-if="form.item_">
|
||||
<view>
|
||||
<view >类别:<span style="color:darkblue;font-weight: bold;">{{form.item_.type}}</span></view>
|
||||
<view>类别:<span style="color:darkblue;font-weight: bold;">{{form.item_.type}}</span></view>
|
||||
<view>{{form.item_.sortnum}}.{{form.item_.name}}</view>
|
||||
</view>
|
||||
</u-form-item>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<view class="wrap">
|
||||
<u-card v-for="(item, index) in myinspecttaskList" v-bind:key="index" :title="item.name" margin="12rpx"
|
||||
:border="false" :foot-border-top="false" border-radius="2rpx" :head-style="headstyle"
|
||||
:border="false" :foot-border-top="false" border-radius="8rpx" :head-style="headstyle"
|
||||
@body-click="taskClick" :index="item.id">
|
||||
<view class="" slot="body">
|
||||
<view class="u-body-item-title">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<view class="wrap">
|
||||
<u-card :title="subtask.name" margin="12rpx" :border="false" :foot-border-top="false" border-radius="2rpx"
|
||||
<u-card :title="subtask.name" margin="12rpx" :border="false" :foot-border-top="false" border-radius="8rpx"
|
||||
:head-style="headstyle" padding="10">
|
||||
<view class="" slot="body">
|
||||
<view class="u-body-item-title">
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 3.0.5 on 2021-04-26 03:28
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('quality', '0013_inspectitem_template'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='inspecttask',
|
||||
name='template',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='quality.InspectTemplate', verbose_name='使用模板'),
|
||||
),
|
||||
]
|
|
@ -40,6 +40,7 @@ class InspectTask(CommonAModel):
|
|||
start_date = models.DateField('巡查开始日期')
|
||||
end_date = models.DateField('巡查结束日期')
|
||||
state = models.CharField('任务状态', max_length=50, choices=state_choices, default='待发布')
|
||||
template = models.ForeignKey(InspectTemplate, on_delete=models.CASCADE, verbose_name='使用模板', null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = '巡查任务'
|
||||
|
|
|
@ -36,10 +36,10 @@ class InspectTaskSerializer(serializers.ModelSerializer):
|
|||
fields = '__all__'
|
||||
|
||||
def get_dept_count(self, obj):
|
||||
return InspectDept.objects.filter(subtask__inspecttask=obj, is_deleted=True).count()
|
||||
return InspectDept.objects.filter(subtask__inspecttask=obj, is_deleted=False).count()
|
||||
|
||||
def get_subtask_count(self, obj):
|
||||
return SubInspectTask.objects.filter(inspecttask=obj, is_deleted=True).count()
|
||||
return SubInspectTask.objects.filter(inspecttask=obj, is_deleted=False).count()
|
||||
|
||||
class InspectTaskSimpleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
|
|
|
@ -244,13 +244,15 @@ class InspectRecordViewSet(PageOrNot, ModelViewSet):
|
|||
提交单条记录检查结果
|
||||
"""
|
||||
instance = self.get_object()
|
||||
serializer = InspectRecordCheckSerializer(instance, data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
serializer.save(checker=request.user, checked=True, check_time=timezone.now())
|
||||
# 修改状态
|
||||
insd = InspectDept.objects.get(subtask=instance.subtask, dept=instance.dept)
|
||||
if insd.state == '待检查':
|
||||
insd.state = '检查中'
|
||||
insd.start_date = timezone.now()
|
||||
insd.save()
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
if instance.subtask.state == '执行中':
|
||||
serializer = InspectRecordCheckSerializer(instance, data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
serializer.save(checker=request.user, checked=True, check_time=timezone.now())
|
||||
# 修改状态
|
||||
insd = InspectDept.objects.get(subtask=instance.subtask, dept=instance.dept)
|
||||
if insd.state == '待检查':
|
||||
insd.state = '检查中'
|
||||
insd.start_date = timezone.now()
|
||||
insd.save()
|
||||
return Response(status=status.HTTP_200_OK)
|
||||
return Response('任务状态错误', status=status.HTTP_400_BAD_REQUEST)
|
Loading…
Reference in New Issue