防护用品检测提交

This commit is contained in:
caoqianming 2020-10-19 17:47:41 +08:00
parent a958f8892f
commit 37169f1f56
6 changed files with 153 additions and 3 deletions

View File

@ -26,13 +26,127 @@ Page({
phoneInput: function(e){ phoneInput: function(e){
this.data.phone = e.detail.value this.data.phone = e.detail.value
}, },
kdInput: function(e){
this.data.kdd = e.detail.value
},
tap1:function(){
api.request('/cms/material/','get', {name:'个人防护用品检测介绍和案例'}).then(res=>{
var res1 = res.data
if(res1.count){
var fileurl = getApp().globalData.host + res1.results[0].path
wx.showLoading({
title: '正在下载...',
})
wx.downloadFile({
url: fileurl,
success(res) {
wx.showLoading({
title: '成功,正在打开...',
})
const filePath = res.tempFilePath
var filetype
if (fileurl.indexOf(".docx") != -1) {
filetype = 'docx'
}
else if (fileurl.indexOf(".doc") != -1) {
filetype = 'doc'
}
else if (fileurl.indexOf(".xlsx") != -1) {
filetype = 'xlsx'
}
else if (fileurl.indexOf(".xls") != -1) {
filetype = 'xls'
}
else if (fileurl.indexOf(".pptx") != -1) {
filetype = 'pptx'
}
else if (fileurl.indexOf(".ppt") != -1) {
filetype = 'ppt'
}
else if (fileurl.indexOf(".pdf") != -1) {
filetype = 'pdf'
} else {
wx.hideLoading()
return
}
wx.openDocument({
filePath,
fileType: filetype,
success(res) {
wx.hideLoading()
console.log('打开文档成功')
}, fail: function (e) {
wx.hideLoading()
}
})
}
})
}
})
},
tap2:function(){
api.request('/cms/material/','get', {name:'个人防护用品检测申请单'}).then(res=>{
var res1 = res.data
if(res1.count){
var fileurl = getApp().globalData.host + res1[0].path
wx.showLoading({
title: '正在下载...',
})
wx.downloadFile({
url: fileurl,
success(res) {
wx.showLoading({
title: '成功,正在打开...',
})
const filePath = res.tempFilePath
var filetype
if (fileurl.indexOf(".docx") != -1) {
filetype = 'docx'
}
else if (fileurl.indexOf(".doc") != -1) {
filetype = 'doc'
}
else if (fileurl.indexOf(".xlsx") != -1) {
filetype = 'xlsx'
}
else if (fileurl.indexOf(".xls") != -1) {
filetype = 'xls'
}
else if (fileurl.indexOf(".pptx") != -1) {
filetype = 'pptx'
}
else if (fileurl.indexOf(".ppt") != -1) {
filetype = 'ppt'
}
else if (fileurl.indexOf(".pdf") != -1) {
filetype = 'pdf'
} else {
wx.hideLoading()
return
}
wx.openDocument({
filePath,
fileType: filetype,
success(res) {
wx.hideLoading()
console.log('打开文档成功')
}, fail: function (e) {
wx.hideLoading()
}
})
}
})
}
})
},
submit: function(){ submit: function(){
if(this.data.name&&this.data.phone&&this.data.address){ if(this.data.name&&this.data.phone&&this.data.address){
let data = { let data = {
name:this.data.name, name:this.data.name,
phone:this.data.phone, phone:this.data.phone,
address:this.data.address, address:this.data.address,
tests:this.data.tests tests:this.data.tests,
kdd:this.data.kdd
} }
api.request('/qtest/consult/','POST', data).then(res=>{ api.request('/qtest/consult/','POST', data).then(res=>{
wx.showModal({ wx.showModal({

View File

@ -3,6 +3,10 @@
<h2 class="weui-form__title">个人防护用品检测(铅当量)</h2> <h2 class="weui-form__title">个人防护用品检测(铅当量)</h2>
<view class="weui-form__desc">中科辐射学堂和国家建材工业安防工程产品质量监督检验中心推出个人防护用品合格检测限每个核技术利用单位在10月31日之前免费检测一套个人防护用品,如有需要请提交您的申请。</view> <view class="weui-form__desc">中科辐射学堂和国家建材工业安防工程产品质量监督检验中心推出个人防护用品合格检测限每个核技术利用单位在10月31日之前免费检测一套个人防护用品,如有需要请提交您的申请。</view>
</view> </view>
<view style="text-align:center">
<button class="mini-btn" type="default" size="mini" bindtap="tap1">介绍和案例</button>
<button class="mini-btn" type="default" size="mini" style="margin-left:20px" bindtap="tap2">申请单</button>
</view>
<view> <view>
<view class="weui-cells__title">基本信息</view> <view class="weui-cells__title">基本信息</view>
<view class="weui-cells weui-cells_form"> <view class="weui-cells weui-cells_form">
@ -20,6 +24,14 @@
<input class="weui-input" placeholder="填写您的联系方式" placeholder-class="weui-input__placeholder" type="number" bindinput="phoneInput" /> <input class="weui-input" placeholder="填写您的联系方式" placeholder-class="weui-input__placeholder" type="number" bindinput="phoneInput" />
</view> </view>
</view> </view>
<view class="weui-cell weui-cell_active">
<view class="weui-cell__hd">
<label class="weui-label">快递单号</label>
</view>
<view class="weui-cell__bd">
<input class="weui-input" placeholder="填写您的快递单号" placeholder-class="weui-input__placeholder" bindinput="kdInput" />
</view>
</view>
<view class="weui-cell weui-cell_active"> <view class="weui-cell weui-cell_active">
<view class="weui-cell__hd"> <view class="weui-cell__hd">
<label class="weui-label">邮寄地址</label> <label class="weui-label">邮寄地址</label>

View File

@ -69,7 +69,7 @@ class MaterialViewSet(ModelViewSet):
search_fields = ['name','description'] search_fields = ['name','description']
ordering_fields = ['update_time', 'down_count'] ordering_fields = ['update_time', 'down_count']
ordering = ['-down_count'] ordering = ['-down_count']
filterset_fields = ['type'] filterset_fields = ['type', 'name']
@action(methods=['get'], detail=True, url_name='down_material', perms_map=[{'*':'down_material'}]) @action(methods=['get'], detail=True, url_name='down_material', perms_map=[{'*':'down_material'}])
def down(self, request, *args, **kwargs): def down(self, request, *args, **kwargs):

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.4 on 2020-10-19 09:47
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('qtest', '0002_consult_feedback'),
]
operations = [
migrations.AddField(
model_name='consult',
name='kdd',
field=models.TextField(blank=True, null=True, verbose_name='快递单号'),
),
]

View File

@ -8,6 +8,7 @@ class Consult(CommonModel):
name = models.CharField('姓名', max_length=100) name = models.CharField('姓名', max_length=100)
phone = models.CharField('手机号', max_length=100) phone = models.CharField('手机号', max_length=100)
address = models.CharField('邮寄地址', max_length=1000, null=True, blank=True) address = models.CharField('邮寄地址', max_length=1000, null=True, blank=True)
kdd = models.TextField('快递单号', null=True, blank=True)
tests = ArrayField(models.CharField('检测内容', max_length=2000)) tests = ArrayField(models.CharField('检测内容', max_length=2000))
feedback = models.TextField('反馈记录', null=True, blank=True) feedback = models.TextField('反馈记录', null=True, blank=True)
class Meta: class Meta:

View File

@ -1,4 +1,5 @@
from django.shortcuts import render from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet from rest_framework.viewsets import ModelViewSet
from .models import Consult from .models import Consult
# Create your views here. # Create your views here.
@ -7,6 +8,9 @@ from utils.custom import CommonPagination
from .models import Consult from .models import Consult
from django_filters.rest_framework import DjangoFilterBackend from django_filters.rest_framework import DjangoFilterBackend
from rest_framework.filters import OrderingFilter, SearchFilter from rest_framework.filters import OrderingFilter, SearchFilter
from rest_framework.decorators import action
from cms.models import Material
from rest_framework.response import Response
class ConsultSerializer(serializers.ModelSerializer): class ConsultSerializer(serializers.ModelSerializer):
""" """
咨询序列化 咨询序列化
@ -27,4 +31,5 @@ class ConsultViewSet(ModelViewSet):
pagination_class = CommonPagination pagination_class = CommonPagination
filter_backends = [DjangoFilterBackend,SearchFilter, OrderingFilter] filter_backends = [DjangoFilterBackend,SearchFilter, OrderingFilter]
search_fields = ['name','tests', 'phone'] search_fields = ['name','tests', 'phone']
ordering=['-pk'] ordering=['-pk']