Merge branch 'master' of https://e.coding.net/ctcdevteam/cma_search
This commit is contained in:
		
						commit
						a1bf6d8254
					
				|  | @ -11,7 +11,7 @@ const install = (Vue, vm) => { | ||||||
| 		// header: {
 | 		// header: {
 | ||||||
| 		// 	'content-type': 'xxx'
 | 		// 	'content-type': 'xxx'
 | ||||||
| 		// }
 | 		// }
 | ||||||
| 		showLoading: false, | 		showLoading: true, | ||||||
| 		loadingText: '请求中..', | 		loadingText: '请求中..', | ||||||
| 		originalData: true, | 		originalData: true, | ||||||
| 		loadingTime: 800, | 		loadingTime: 800, | ||||||
|  |  | ||||||
|  | @ -1,7 +1,8 @@ | ||||||
| <template> | <template> | ||||||
| 	<view> | 	<view> | ||||||
| 		<u-swiper @change="change" :height="250" :list="swiper_list" :title="swtitle" :effect3d="effect3d" | 		<u-image :src="imageURL" mode="widthFix"></u-image> | ||||||
| 			:indicator-pos="indicatorPos" :mode="mode" :interval="3000" @click="click"></u-swiper> | 		<!-- <u-swiper @change="change" :height="250" :list="swiper_list" :title="swtitle" :effect3d="effect3d" | ||||||
|  | 			:indicator-pos="indicatorPos" :mode="mode" :interval="3000" @click="click"></u-swiper> --> | ||||||
| 		<view style="margin-top:12rpx;margin-bottom: 12rpx;"> | 		<view style="margin-top:12rpx;margin-bottom: 12rpx;"> | ||||||
| 		<u-grid :col="3" :border="false"> | 		<u-grid :col="3" :border="false"> | ||||||
| 			<u-grid-item v-for="(item, index) in grids" v-bind:key="index" @click="clickGrid(item)"> | 			<u-grid-item v-for="(item, index) in grids" v-bind:key="index" @click="clickGrid(item)"> | ||||||
|  | @ -13,7 +14,7 @@ | ||||||
| 		<view style="margin-bottom: 12rpx;margin-left: 6rpx;"> | 		<view style="margin-bottom: 12rpx;margin-left: 6rpx;"> | ||||||
| 		<u-section title="最近任务" :right="false" ></u-section> | 		<u-section title="最近任务" :right="false" ></u-section> | ||||||
| 		</view> | 		</view> | ||||||
| 		<u-card v-for="(item, index) in myinspecttaskList" v-bind:key="index" :title="item.name" margin="6rpx" | 		<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="2rpx" :head-style="headstyle" | ||||||
| 			@body-click="taskClick" :index="item.id" padding="10"> | 			@body-click="taskClick" :index="item.id" padding="10"> | ||||||
| 			<view class="" slot="body"> | 			<view class="" slot="body"> | ||||||
|  | @ -45,6 +46,7 @@ | ||||||
| 	export default { | 	export default { | ||||||
| 		data() { | 		data() { | ||||||
| 			return { | 			return { | ||||||
|  | 				imageURL: 'https://cdn.uviewui.com/uview/swiper/1.jpg', | ||||||
| 				swiper_list: [{ | 				swiper_list: [{ | ||||||
| 						image: 'https://cdn.uviewui.com/uview/swiper/1.jpg', | 						image: 'https://cdn.uviewui.com/uview/swiper/1.jpg', | ||||||
| 						title: '昨夜星辰昨夜风,画楼西畔桂堂东' | 						title: '昨夜星辰昨夜风,画楼西畔桂堂东' | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| <template> | <template> | ||||||
| 	<view class="wrap"> | 	<view class="wrap"> | ||||||
| 		<u-card :title="initData.dept__name" margin="6rpx" :border="false" :foot-border-top="false" border-radius="2rpx" | 		<u-card :title="initData.dept__name" margin="12rpx" :border="false" :foot-border-top="false" border-radius="2rpx" | ||||||
| 			:head-style="headstyle" padding="10"> | 			:head-style="headstyle" padding="10"> | ||||||
| 			<view class="" slot="body"> | 			<view class="" slot="body"> | ||||||
| 				<view class="u-body-item-title"> | 				<view class="u-body-item-title"> | ||||||
|  |  | ||||||
|  | @ -2,11 +2,11 @@ | ||||||
| 	<view style="padding-left: 24rpx;padding-right: 24rpx;padding-bottom: 16rpx;"> | 	<view style="padding-left: 24rpx;padding-right: 24rpx;padding-bottom: 16rpx;"> | ||||||
| 		<u-form :model="form" label-position="top" :label-style="labelStyle" ref="uForm" :rules="rules" | 		<u-form :model="form" label-position="top" :label-style="labelStyle" ref="uForm" :rules="rules" | ||||||
| 			:errorType="errorType"> | 			:errorType="errorType"> | ||||||
| 			<u-form-item label="检查事项"> | 			<u-form-item label="检查事项" v-if="form.item_"> | ||||||
| 				<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>{{form.item_.sortnum}}.{{form.item_.name}}</view> | ||||||
| 			</u-form-item> | 			</u-form-item> | ||||||
| 			<u-form-item label="取证要求"> | 			<u-form-item label="取证要求" v-if="form.item_"> | ||||||
| 				<span>{{form.item_.require}}</span> | 				<span>{{form.item_.require}}</span> | ||||||
| 			</u-form-item> | 			</u-form-item> | ||||||
| 			<u-form-item label="检查结果" prop="result"> | 			<u-form-item label="检查结果" prop="result"> | ||||||
|  |  | ||||||
|  | @ -2,11 +2,13 @@ | ||||||
| 	<view style="padding-left: 24rpx;padding-right: 24rpx;padding-bottom: 16rpx;"> | 	<view style="padding-left: 24rpx;padding-right: 24rpx;padding-bottom: 16rpx;"> | ||||||
| 		<u-form :model="form" label-position="top" :label-style="labelStyle" ref="uForm" :rules="rules" | 		<u-form :model="form" label-position="top" :label-style="labelStyle" ref="uForm" :rules="rules" | ||||||
| 			:errorType="errorType"> | 			:errorType="errorType"> | ||||||
| 			<u-form-item label="检查事项"> | 			<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>{{form.item_.sortnum}}.{{form.item_.name}}</view> | ||||||
|  | 				</view> | ||||||
| 			</u-form-item> | 			</u-form-item> | ||||||
| 			<u-form-item label="取证要求"> | 			<u-form-item label="取证要求" v-if="form.item_"> | ||||||
| 				<span>{{form.item_.require}}</span> | 				<span>{{form.item_.require}}</span> | ||||||
| 			</u-form-item> | 			</u-form-item> | ||||||
| 			<u-form-item label="检查结果" prop="result"> | 			<u-form-item label="检查结果" prop="result"> | ||||||
|  | @ -107,7 +109,9 @@ | ||||||
| 
 | 
 | ||||||
| 						} | 						} | ||||||
| 						// console.log(sData.imgs) | 						// console.log(sData.imgs) | ||||||
|  | 						 | ||||||
| 						this.$u.api.checkInspectRecord(sData.id, sData).then(res => { | 						this.$u.api.checkInspectRecord(sData.id, sData).then(res => { | ||||||
|  | 							 | ||||||
| 							uni.navigateBack({ | 							uni.navigateBack({ | ||||||
| 
 | 
 | ||||||
| 							}) | 							}) | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| 	<view class="wrap"> | 	<view class="wrap"> | ||||||
| 		<view class="top"></view> | 		<view class="top"></view> | ||||||
| 		<view class="content"> | 		<view class="content"> | ||||||
|  | 			<view style="text-align: center;font-weight: 500;font-size: 40rpx;">国检集团</view> | ||||||
| 			<view class="title">能力共享和质量监督平台</view> | 			<view class="title">能力共享和质量监督平台</view> | ||||||
| 			<u-form :model="loginForm" :rules="rules" ref="uForm" :errorType="errorType"> | 			<u-form :model="loginForm" :rules="rules" ref="uForm" :errorType="errorType"> | ||||||
| 				<u-form-item label="邮箱号" prop="mail" label-width="150"> | 				<u-form-item label="邮箱号" prop="mail" label-width="150"> | ||||||
|  | @ -13,7 +14,11 @@ | ||||||
| 					<u-button slot="right" type="success" size="mini" @click="getCode">{{codeTips}}</u-button> | 					<u-button slot="right" type="success" size="mini" @click="getCode">{{codeTips}}</u-button> | ||||||
| 				</u-form-item> | 				</u-form-item> | ||||||
| 			</u-form> | 			</u-form> | ||||||
| 			<button @tap="submit" :style="[inputStyle]" class="getCaptcha">登录</button> | 			<!-- <button  :style="[inputStyle]" class="getCaptcha">登录</button> --> | ||||||
|  | <!-- 			<u-gap height="1" bg-color="#bbb"></u-gap> --> | ||||||
|  | <view style="margin-top: 16rpx;"> | ||||||
|  | 			<u-button @click="submit" type="warning" >登录</u-button> | ||||||
|  | 			</view> | ||||||
| 			<view class="alternative"> | 			<view class="alternative"> | ||||||
| 				<navigator url="login_password" class="password" open-type="redirect">密码登录</navigator> | 				<navigator url="login_password" class="password" open-type="redirect">密码登录</navigator> | ||||||
| 			</view> | 			</view> | ||||||
|  | @ -89,21 +94,30 @@ export default { | ||||||
| 				style.backgroundColor = this.$u.color['warning']; | 				style.backgroundColor = this.$u.color['warning']; | ||||||
| 			} | 			} | ||||||
| 			return style; | 			return style; | ||||||
|  | 		}, | ||||||
|  | 		submitEnable(){ | ||||||
|  | 			if(this.loginForm.mail && this.loginForm.msg) { | ||||||
|  | 				return false; | ||||||
|  | 			} | ||||||
|  | 			return true; | ||||||
| 		} | 		} | ||||||
| 	}, | 	}, | ||||||
| 	methods: { | 	methods: { | ||||||
| 		submit() { | 		submit() { | ||||||
| 			this.$refs.uForm.validate(valid => { | 			this.$refs.uForm.validate(valid => { | ||||||
| 				if (valid) { | 				if (valid) { | ||||||
|  | 					uni.showLoading({ | ||||||
|  | 					}) | ||||||
| 					this.$u.api.codeLogin(this.loginForm).then(res=>{ | 					this.$u.api.codeLogin(this.loginForm).then(res=>{ | ||||||
| 						this.$u.vuex('vuex_token', res.data.access) | 						this.$u.vuex('vuex_token', res.data.access) | ||||||
| 						this.$u.api.getUserInfo().then(res=>{ | 						this.$u.api.getUserInfo().then(res=>{ | ||||||
| 							this.$u.vuex('vuex_user', res.data) | 							this.$u.vuex('vuex_user', res.data) | ||||||
|  | 							uni.hideLoading() | ||||||
| 						}) | 						}) | ||||||
| 						uni.reLaunch({ | 						uni.reLaunch({ | ||||||
| 							url:'/pages/home/home' | 							url:'/pages/home/home' | ||||||
| 						}) | 						}) | ||||||
| 					}).catch(e=>{}) | 					}).catch(e=>{uni.hideLoading()}) | ||||||
| 				}  | 				}  | ||||||
| 			}); | 			}); | ||||||
| 		}, | 		}, | ||||||
|  | @ -142,7 +156,7 @@ export default { | ||||||
| 		margin: 40rpx auto 0; | 		margin: 40rpx auto 0; | ||||||
| 
 | 
 | ||||||
| 		.title { | 		.title { | ||||||
| 			text-align: left; | 			text-align: center; | ||||||
| 			font-size: 40rpx; | 			font-size: 40rpx; | ||||||
| 			font-weight: 500; | 			font-weight: 500; | ||||||
| 			margin-bottom: 100rpx; | 			margin-bottom: 100rpx; | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| 	<view class="wrap"> | 	<view class="wrap"> | ||||||
| 		<view class="top"></view> | 		<view class="top"></view> | ||||||
| 		<view class="content"> | 		<view class="content"> | ||||||
|  | 			<view style="text-align: center;font-weight: 500;font-size: 40rpx;">国检集团</view> | ||||||
| 			<view class="title">能力共享和质量监督平台</view> | 			<view class="title">能力共享和质量监督平台</view> | ||||||
| 			<u-form :model="loginForm" :rules="rules" ref="uForm" :errorType="errorType"> | 			<u-form :model="loginForm" :rules="rules" ref="uForm" :errorType="errorType"> | ||||||
| 				<u-form-item label="账户" prop="username" label-width="150"> | 				<u-form-item label="账户" prop="username" label-width="150"> | ||||||
|  | @ -11,7 +12,9 @@ | ||||||
| 					<u-input placeholder="请输入密码" v-model="loginForm.password" type="password"></u-input> | 					<u-input placeholder="请输入密码" v-model="loginForm.password" type="password"></u-input> | ||||||
| 				</u-form-item> | 				</u-form-item> | ||||||
| 			</u-form> | 			</u-form> | ||||||
| 			<button @click="submit" :style="[inputStyle]" class="getCaptcha">登陆</button> | 			<view style="margin-top: 16rpx;"> | ||||||
|  | 						<u-button @click="submit" type="warning" >登录</u-button> | ||||||
|  | 						</view> | ||||||
| 		</view> | 		</view> | ||||||
| 	</view> | 	</view> | ||||||
| </template> | </template> | ||||||
|  | @ -99,7 +102,7 @@ export default { | ||||||
| 		margin: 80rpx auto 0; | 		margin: 80rpx auto 0; | ||||||
| 
 | 
 | ||||||
| 		.title { | 		.title { | ||||||
| 			text-align: left; | 			text-align: center; | ||||||
| 			font-size: 40rpx; | 			font-size: 40rpx; | ||||||
| 			font-weight: 500; | 			font-weight: 500; | ||||||
| 			margin-bottom: 100rpx; | 			margin-bottom: 100rpx; | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| <template> | <template> | ||||||
| 	<view class="wrap"> | 	<view class="wrap"> | ||||||
| 		<u-card :title="subtask.name" margin="6rpx" :border="false" :foot-border-top="false" border-radius="2rpx" | 		<u-card :title="subtask.name" margin="12rpx" :border="false" :foot-border-top="false" border-radius="2rpx" | ||||||
| 			:head-style="headstyle" padding="10"> | 			:head-style="headstyle" padding="10"> | ||||||
| 			<view class="" slot="body"> | 			<view class="" slot="body"> | ||||||
| 				<view class="u-body-item-title"> | 				<view class="u-body-item-title"> | ||||||
|  | @ -9,18 +9,18 @@ | ||||||
| 				</view> | 				</view> | ||||||
| 				<view class="u-body-item"> | 				<view class="u-body-item"> | ||||||
| 					所属任务: | 					所属任务: | ||||||
| 					<span>{{subtask.inspecttask_.name}}</span> | 					<span v-if="subtask.inspecttask_">{{subtask.inspecttask_.name}}</span> | ||||||
| 				</view> | 				</view> | ||||||
| 				<view class="u-body-item"> | 				<view class="u-body-item"> | ||||||
| 					检查期限: | 					检查期限: | ||||||
| 					<span>{{subtask.inspecttask_.start_date}} </span>至 | 					<span v-if="subtask.inspecttask_">{{subtask.inspecttask_.start_date}} </span>至 | ||||||
| 					<span> {{subtask.inspecttask_.end_date}}</span> | 					<span v-if="subtask.inspecttask_"> {{subtask.inspecttask_.end_date}}</span> | ||||||
| 				</view> | 				</view> | ||||||
| 				<view class="u-body-item"> | 				<view class="u-body-item"> | ||||||
| 					涉及单位: | 					涉及单位: | ||||||
| 					<span style="color:blue;">{{subtask.depts_count}}</span>家 | 					<span style="color:blue;">{{subtask.depts_count}}</span>家 | ||||||
| 					巡查组: | 					巡查组: | ||||||
| 					<span style="color:blue;">{{subtask.members.length}}</span>人 | 					<span style="color:blue;" v-if="subtask.members">{{subtask.members.length}}</span>人 | ||||||
| 				</view> | 				</view> | ||||||
| 				<view style="margin-top: 6rpx;"> | 				<view style="margin-top: 6rpx;"> | ||||||
| 					<u-gap height="1" bg-color="#bbb"></u-gap> | 					<u-gap height="1" bg-color="#bbb"></u-gap> | ||||||
|  | @ -70,7 +70,7 @@ | ||||||
| 						name: '检查中' | 						name: '检查中' | ||||||
| 					}, | 					}, | ||||||
| 					{ | 					{ | ||||||
| 						name: '已完成' | 						name: '已提交' | ||||||
| 					} | 					} | ||||||
| 				], | 				], | ||||||
| 				taskdepts: [], | 				taskdepts: [], | ||||||
|  |  | ||||||
|  | @ -0,0 +1,32 @@ | ||||||
|  | # Generated by Django 3.0.5 on 2021-04-23 09:10 | ||||||
|  | 
 | ||||||
|  | from django.conf import settings | ||||||
|  | from django.db import migrations, models | ||||||
|  | import django.db.models.deletion | ||||||
|  | import django.utils.timezone | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  | 
 | ||||||
|  |     dependencies = [ | ||||||
|  |         migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||||||
|  |         ('quality', '0011_auto_20210422_1328'), | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     operations = [ | ||||||
|  |         migrations.CreateModel( | ||||||
|  |             name='InspectTemplate', | ||||||
|  |             fields=[ | ||||||
|  |                 ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||||||
|  |                 ('create_time', models.DateTimeField(default=django.utils.timezone.now, help_text='创建时间', verbose_name='创建时间')), | ||||||
|  |                 ('update_time', models.DateTimeField(auto_now=True, help_text='修改时间', verbose_name='修改时间')), | ||||||
|  |                 ('is_deleted', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')), | ||||||
|  |                 ('name', models.CharField(max_length=200, verbose_name='模板名称')), | ||||||
|  |                 ('create_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inspecttemplate_create_by', to=settings.AUTH_USER_MODEL, verbose_name='创建人')), | ||||||
|  |                 ('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inspecttemplate_update_by', to=settings.AUTH_USER_MODEL, verbose_name='最后编辑人')), | ||||||
|  |             ], | ||||||
|  |             options={ | ||||||
|  |                 'abstract': False, | ||||||
|  |             }, | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
|  | @ -0,0 +1,20 @@ | ||||||
|  | # Generated by Django 3.0.5 on 2021-04-25 00:28 | ||||||
|  | 
 | ||||||
|  | from django.db import migrations, models | ||||||
|  | import django.db.models.deletion | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class Migration(migrations.Migration): | ||||||
|  | 
 | ||||||
|  |     dependencies = [ | ||||||
|  |         ('quality', '0012_inspecttemplate'), | ||||||
|  |     ] | ||||||
|  | 
 | ||||||
|  |     operations = [ | ||||||
|  |         migrations.AddField( | ||||||
|  |             model_name='inspectitem', | ||||||
|  |             name='template', | ||||||
|  |             field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='quality.InspectTemplate', verbose_name='所属模板'), | ||||||
|  |             preserve_default=False, | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
|  | @ -2,11 +2,11 @@ from django.db import models | ||||||
| from utils.model import BaseModel | from utils.model import BaseModel | ||||||
| from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File | from apps.system.models import CommonAModel, CommonBModel, Organization, User, Dict, File | ||||||
| # Create your models here. | # Create your models here. | ||||||
| # class InspectTemplate(CommonAModel): | class InspectTemplate(CommonAModel): | ||||||
| #     """ |     """ | ||||||
| #     检查模板 |     检查模板 | ||||||
| #     """ |     """ | ||||||
| #     name = models.CharField('模板名称', max_length=200) |     name = models.CharField('模板名称', max_length=200) | ||||||
| 
 | 
 | ||||||
| class InspectItem(CommonAModel): | class InspectItem(CommonAModel): | ||||||
|     """ |     """ | ||||||
|  | @ -21,7 +21,7 @@ class InspectItem(CommonAModel): | ||||||
|     type = models.CharField('类型', max_length=50, choices=type_choices, default='合规') |     type = models.CharField('类型', max_length=50, choices=type_choices, default='合规') | ||||||
|     require = models.TextField('取证要求', null=True, blank=True) |     require = models.TextField('取证要求', null=True, blank=True) | ||||||
|     sortnum = models.IntegerField('序号', default=1) |     sortnum = models.IntegerField('序号', default=1) | ||||||
|     # template =  |     template = models.ForeignKey(InspectTemplate, on_delete=models.CASCADE, verbose_name='所属模板') | ||||||
|     class Meta: |     class Meta: | ||||||
|         verbose_name = '检查清单' |         verbose_name = '检查清单' | ||||||
|         verbose_name_plural = verbose_name |         verbose_name_plural = verbose_name | ||||||
|  |  | ||||||
|  | @ -127,3 +127,7 @@ class InspectRecordCheckSerializer(serializers.ModelSerializer): | ||||||
|             raise ParseError('未填写检查结果') |             raise ParseError('未填写检查结果') | ||||||
|         return result |         return result | ||||||
|      |      | ||||||
|  | class InspectTemplateSerializer(serializers.ModelSerializer): | ||||||
|  |     class Meta: | ||||||
|  |         model = InspectTemplate | ||||||
|  |         fields = '__all__' | ||||||
|  |  | ||||||
|  | @ -23,7 +23,17 @@ from .serializers import * | ||||||
| from .permission import IsSubInspectTaskLeader, IsInspectRecordChecker | from .permission import IsSubInspectTaskLeader, IsInspectRecordChecker | ||||||
| # Create your views here. | # Create your views here. | ||||||
| 
 | 
 | ||||||
| class InspectItemViewSet(CreateUpdateCustomMixin, ModelViewSet): | class InspectTemplateViewSet(PageOrNot, CreateUpdateCustomMixin, ModelViewSet): | ||||||
|  |     """ | ||||||
|  |     检查表模板 | ||||||
|  |     """ | ||||||
|  |     perms_map = {'get': '*', 'post': 'inspectitem', | ||||||
|  |                  'put': 'inspectitem', 'delete': 'inspectitem'} | ||||||
|  |     queryset = InspectTemplate.objects.all() | ||||||
|  |     serializer_class = InspectTemplateSerializer | ||||||
|  |     ordering = ['id'] | ||||||
|  | 
 | ||||||
|  | class InspectItemViewSet(PageOrNot, CreateUpdateCustomMixin, ModelViewSet): | ||||||
|     """ |     """ | ||||||
|     检查表清单:增删改查 |     检查表清单:增删改查 | ||||||
|     """ |     """ | ||||||
|  | @ -31,9 +41,8 @@ class InspectItemViewSet(CreateUpdateCustomMixin, ModelViewSet): | ||||||
|                  'put': 'inspectitem', 'delete': 'inspectitem'} |                  'put': 'inspectitem', 'delete': 'inspectitem'} | ||||||
|     queryset = InspectItem.objects.all() |     queryset = InspectItem.objects.all() | ||||||
|     serializer_class = InspectItemSerializer |     serializer_class = InspectItemSerializer | ||||||
|     pagination_class = None |  | ||||||
|     search_fields = ['name', 'require'] |     search_fields = ['name', 'require'] | ||||||
|     filterset_fields = ['type','cate'] |     filterset_fields = ['type','cate', 'template'] | ||||||
|     ordering = ['sortnum', 'cate__sort', 'create_time'] |     ordering = ['sortnum', 'cate__sort', 'create_time'] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -124,8 +133,13 @@ class SubtaskViewSet(PageOrNot, CreateUpdateCustomMixin, OptimizationMixin, Mode | ||||||
|         return Response(data) |         return Response(data) | ||||||
| 
 | 
 | ||||||
|     def create(self, request, *args, **kwargs): |     def create(self, request, *args, **kwargs): | ||||||
|  |         """ | ||||||
|  |         创建子任务 | ||||||
|  |         form:{inspecttask:id, name:'', leader:id, members:[id]} | ||||||
|  |         """ | ||||||
|         obj = SubInspectTask() |         obj = SubInspectTask() | ||||||
|         obj.inspecttask = InspectTask.objects.get(pk=request.data['inspecttask']) |         inspecttask = InspectTask.objects.get(pk=request.data['inspecttask']) | ||||||
|  |         obj.inspecttask = inspecttask | ||||||
|         obj.name = request.data['name'] |         obj.name = request.data['name'] | ||||||
|         obj.create_by = request.user |         obj.create_by = request.user | ||||||
|         obj.save() |         obj.save() | ||||||
|  | @ -141,7 +155,7 @@ class SubtaskViewSet(PageOrNot, CreateUpdateCustomMixin, OptimizationMixin, Mode | ||||||
|                     data['dept'] = mdept |                     data['dept'] = mdept | ||||||
|                     data['subtask'] = obj |                     data['subtask'] = obj | ||||||
|                     depts.append(InspectDept(**data)) |                     depts.append(InspectDept(**data)) | ||||||
|                     for i in InspectItem.objects.filter(is_deleted=False): |                     for i in InspectItem.objects.filter(is_deleted=False, template=inspecttask.template): | ||||||
|                         r = {} |                         r = {} | ||||||
|                         r['dept'] = mdept |                         r['dept'] = mdept | ||||||
|                         r['item'] = i |                         r['item'] = i | ||||||
|  | @ -184,7 +198,7 @@ class InspectDeptViewSet(ListModelMixin, RetrieveModelMixin, GenericViewSet): | ||||||
|             obj.state = '已提交' |             obj.state = '已提交' | ||||||
|             obj.save() |             obj.save() | ||||||
|             # 更新主任务和子任务状态 |             # 更新主任务和子任务状态 | ||||||
|             if not InspectDept.objects.filter(subtask=obj.subtask).exlude(state='已提交').exists(): |             if not InspectDept.objects.filter(subtask=obj.subtask).exclude(state='已提交').exists(): | ||||||
|                 obj.subtask.state = '已完成' |                 obj.subtask.state = '已完成' | ||||||
|                 obj.subtask.save() |                 obj.subtask.save() | ||||||
|                 if not SubInspectTask.objects.filter(inspecttask=obj.subtask.inspecttask).exclude(state='已完成').exists(): |                 if not SubInspectTask.objects.filter(inspecttask=obj.subtask.inspecttask).exclude(state='已完成').exists(): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue