qtest
This commit is contained in:
parent
ef564842a0
commit
4c1edc9f9c
|
@ -0,0 +1,15 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
export function getConsultList(query) {
|
||||
return request({
|
||||
url: '/qtest/consult/',
|
||||
method: 'get',
|
||||
params:query
|
||||
})
|
||||
}
|
||||
export function deleteConsult(id) {
|
||||
return request({
|
||||
url: `/qtest/consult/${id}/`,
|
||||
method: 'delete',
|
||||
})
|
||||
}
|
|
@ -268,7 +268,21 @@ export const asyncRoutes = [
|
|||
},
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
path: '/qtest',
|
||||
component: Layout,
|
||||
redirect: '/qtest/consult',
|
||||
name: 'Qtest',
|
||||
meta: { title: '铅当量检测', icon: '', perms: ['qtest_view']},
|
||||
children: [
|
||||
{
|
||||
path: 'consult',
|
||||
name: 'Consult',
|
||||
component: () => import('@/views/qtest/consult.vue'),
|
||||
meta: { title: '铅当量检测', icon: 'eye-open', perms: ['qtest_view'] }
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/system',
|
||||
component: Layout,
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<div style="margin-top:10px">
|
||||
<el-input
|
||||
v-model="listQuery.search"
|
||||
placeholder="搜索"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="handleSearch"
|
||||
/>
|
||||
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
|
||||
<el-button
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-refresh-left"
|
||||
@click="resetFilter"
|
||||
>刷新重置</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
:data="tableData.results"
|
||||
style="width: 100%;margin-top:10px;"
|
||||
border
|
||||
stripe
|
||||
fit
|
||||
v-loading="listLoading"
|
||||
highlight-current-row
|
||||
max-height="600"
|
||||
>
|
||||
<el-table-column type="index" width="50"></el-table-column>
|
||||
<el-table-column align="left" label="姓名">
|
||||
<template slot-scope="scope">{{ scope.row.name }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="left" label="手机号">
|
||||
<template slot-scope="scope">{{ scope.row.phone }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="left" label="邮寄地址">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.address }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="left" label="检测内容">
|
||||
<template slot-scope="scope">{{ scope.row.tests }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="left" label="提交时间">
|
||||
<template slot-scope="scope">{{ scope.row.create_time }}</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="操作" >
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
@click="handleDelete(scope)"
|
||||
icon="el-icon-delete"
|
||||
:disabled="!checkPermission(['consult_delete'])"
|
||||
></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="tableData.count>0"
|
||||
:total="tableData.count"
|
||||
:page.sync="listQuery.page"
|
||||
:limit.sync="listQuery.limit"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getConsultList, deleteConsult } from "@/api/consult";
|
||||
import checkPermission from "@/utils/permission";
|
||||
import Pagination from "@/components/Pagination";
|
||||
|
||||
const listQuery = {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
search:''
|
||||
};
|
||||
export default {
|
||||
components: { Pagination },
|
||||
data() {
|
||||
return {
|
||||
listQuery: Object.assign({}, listQuery),
|
||||
tableData: {
|
||||
count:0,
|
||||
results:[],
|
||||
},
|
||||
listLoading: true,
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
checkPermission,
|
||||
getList(query = this.listQuery) {
|
||||
this.listLoading = true;
|
||||
getConsultList(query).then(response => {
|
||||
if(response.data.results){
|
||||
this.tableData = response.data;
|
||||
}
|
||||
this.listLoading = false;
|
||||
});
|
||||
},
|
||||
resetFilter() {
|
||||
this.listQuery = {
|
||||
page: 1,
|
||||
limit: 20,
|
||||
search:''
|
||||
};
|
||||
this.getList();
|
||||
},
|
||||
handleSearch() {
|
||||
this.listQuery.page = 1;
|
||||
this.getList();
|
||||
},
|
||||
handleDelete(scope) {
|
||||
this.$confirm('确认删除?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
deleteConsult(scope.row.id).then(response => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: '删除成功!'
|
||||
});
|
||||
this.getList()
|
||||
});
|
||||
|
||||
}).catch(() => {
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -27,7 +27,8 @@
|
|||
"pages/question/detail",
|
||||
"pages/candidate/index",
|
||||
"pages/candidate/detail",
|
||||
"pages/material/video"
|
||||
"pages/material/video",
|
||||
"pages/qtest/form"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
|
|
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 15 KiB |
|
@ -37,6 +37,15 @@
|
|||
<!-- <span wx:if="{{to_read}}">{{to_read}}条未读</span> -->
|
||||
</view>
|
||||
</navigator>
|
||||
<navigator url="/pages/qtest/form" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
|
||||
<view class="weui-cell__hd">
|
||||
<image src="/images/qtest.svg" style="margin-right: 16px;vertical-align: middle;width:20px; height: 20px;"></image>
|
||||
</view>
|
||||
<view class="weui-cell__bd">铅当量检测</view>
|
||||
<view class="weui-cell__ft weui-cell__ft_in-access" style="color:red">
|
||||
<!-- <span wx:if="{{to_read}}">{{to_read}}条未读</span> -->
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
<view class="weui-cells weui-cells_after-title">
|
||||
<view class="weui-grids">
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
// pages/qtest/form.js
|
||||
const api = require("../../utils/request.js");
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
items: [
|
||||
{ name: '铅衣', value: '铅衣' },
|
||||
{ name: '铅帽', value: '铅帽' },
|
||||
{ name: '铅围裙', value: '铅围裙' },
|
||||
{ name: '铅围脖', value: '铅围脖' },
|
||||
{ name: '一整套防护用品', value: '一整套防护用品' },
|
||||
]
|
||||
},
|
||||
checkboxChange: function (e) {
|
||||
this.data.tests = e.detail.value
|
||||
},
|
||||
addressInput: function(e){
|
||||
this.data.address = e.detail.value
|
||||
},
|
||||
nameInput: function(e){
|
||||
this.data.name = e.detail.value
|
||||
},
|
||||
phoneInput: function(e){
|
||||
this.data.phone = e.detail.value
|
||||
},
|
||||
submit: function(){
|
||||
if(this.data.name&&this.data.phone&&this.data.address){
|
||||
let data = {
|
||||
name:this.data.name,
|
||||
phone:this.data.phone,
|
||||
address:this.data.address,
|
||||
tests:this.data.tests
|
||||
}
|
||||
api.request('/qtest/consult/','POST', data).then(res=>{
|
||||
wx.showModal({
|
||||
title: '提示!',
|
||||
content: '已提交信息.',
|
||||
confirmText: '好的',
|
||||
showCancel:false,
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
wx.navigateBack({
|
||||
delta: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: '填写不完整',
|
||||
icon:'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"usingComponents": {}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
<view class="page">
|
||||
<view class="weui-form">
|
||||
<view class="weui-form__text-area">
|
||||
<h2 class="weui-form__title">铅当量检测</h2>
|
||||
<view class="weui-form__desc">我司开展铅当量检测业务,如有需要,请留下您的信息,我们工作人员将及时与您联系。</view>
|
||||
</view>
|
||||
<view>
|
||||
<view class="weui-cells__title">基本信息</view>
|
||||
<view class="weui-cells weui-cells_form">
|
||||
<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="nameInput"/>
|
||||
</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" type="number" bindinput="phoneInput"/>
|
||||
</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="addressInput"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-cells__title">检测内容</view>
|
||||
<view class="weui-cells weui-cells_checkbox">
|
||||
<checkbox-group bindchange="checkboxChange">
|
||||
<label class="weui-cell weui-cell_active weui-check__label" wx:for="{{items}}" wx:key="name">
|
||||
<view class="weui-cell__hd">
|
||||
<checkbox
|
||||
class="weui-check"
|
||||
value="{{item.name}}"
|
||||
checked="{{item.checked}}"
|
||||
/>
|
||||
<i class="weui-icon-checked"></i>
|
||||
</view>
|
||||
<view class="weui-cell__bd">
|
||||
<view>{{item.value}}</view>
|
||||
</view>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-form__tips-area">
|
||||
<!-- <view class="weui-form__tips">
|
||||
表单页提示,居中对齐
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="weui-form__opr-area">
|
||||
<a class="weui-btn weui-btn_primary" bindtap="submit">提交</a>
|
||||
</view>
|
||||
<!-- <view class="weui-form__tips-area">
|
||||
<view class="weui-form__tips">
|
||||
表单页提示,居中对齐
|
||||
</view>
|
||||
</view>
|
||||
<view class="weui-form__extra-area">
|
||||
<view class="weui-footer">
|
||||
<view class="weui-footer__links">
|
||||
<a href="javascript:" class="weui-footer__link">底部链接文本</a>
|
||||
</view>
|
||||
<view class="weui-footer__text">Copyright © 2008-2019 weui.io</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
/* pages/qtest/form.wxss */
|
||||
.page{height:100%}.weui-label{width:4.1em}
|
|
@ -1,59 +1,65 @@
|
|||
{
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"enhance": true,
|
||||
"postcss": true,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"coverView": true,
|
||||
"nodeModules": true,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"useCompilerModule": true,
|
||||
"userConfirmedUseCompilerModuleSwitch": false,
|
||||
"compileHotReLoad": false,
|
||||
"useIsolateContext": true
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.10.3",
|
||||
"appid": "wxf1e9471c93f05ad6",
|
||||
"projectname": "test_mini",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
},
|
||||
"isGameTourist": false,
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"condition": {
|
||||
"search": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"conversation": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"game": {
|
||||
"currentL": -1,
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
}
|
||||
}
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"enhance": true,
|
||||
"postcss": true,
|
||||
"preloadBackgroundData": false,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"coverView": true,
|
||||
"nodeModules": true,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"uglifyFileName": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"compileHotReLoad": false,
|
||||
"useMultiFrameRuntime": true,
|
||||
"useApiHook": false,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"useIsolateContext": true,
|
||||
"useCompilerModule": true,
|
||||
"userConfirmedUseCompilerModuleSwitch": false,
|
||||
"packNpmManually": false,
|
||||
"packNpmRelationList": []
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.10.3",
|
||||
"appid": "wxf1e9471c93f05ad6",
|
||||
"projectname": "test_mini",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
},
|
||||
"isGameTourist": false,
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"condition": {
|
||||
"search": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"conversation": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"game": {
|
||||
"currentL": -1,
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,3 +37,4 @@ class Material(CommonModel):
|
|||
poster = models.CharField(max_length=10000, verbose_name='封面地址', null=True, blank=True)
|
||||
type = models.CharField('格式', default='文档', max_length=50)
|
||||
down_count = models.IntegerField('阅读量', default=0)
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class QtestConfig(AppConfig):
|
||||
name = 'qtest'
|
|
@ -0,0 +1,33 @@
|
|||
# Generated by Django 3.0.4 on 2020-09-13 14:53
|
||||
|
||||
import django.contrib.postgres.fields
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Consult',
|
||||
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_delete', models.BooleanField(default=False, help_text='删除标记', verbose_name='删除标记')),
|
||||
('name', models.CharField(max_length=100, verbose_name='姓名')),
|
||||
('phone', models.CharField(max_length=100, verbose_name='手机号')),
|
||||
('address', models.CharField(blank=True, max_length=1000, null=True, verbose_name='邮寄地址')),
|
||||
('tests', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(max_length=2000, verbose_name='检测内容'), size=None)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '咨询',
|
||||
'verbose_name_plural': '咨询',
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
from django.db import models
|
||||
import django.utils.timezone as timezone
|
||||
from rbac.models import SoftCommonModel, CommonModel
|
||||
from django.contrib.postgres.fields import ArrayField
|
||||
# Create your models here.
|
||||
|
||||
class Consult(CommonModel):
|
||||
name = models.CharField('姓名', max_length=100)
|
||||
phone = models.CharField('手机号', max_length=100)
|
||||
address = models.CharField('邮寄地址', max_length=1000, null=True, blank=True)
|
||||
tests = ArrayField(models.CharField('检测内容', max_length=2000))
|
||||
|
||||
class Meta:
|
||||
verbose_name = '咨询'
|
||||
verbose_name_plural = verbose_name
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,11 @@
|
|||
from django.urls import path,include
|
||||
from .views import ConsultViewSet
|
||||
from rest_framework import routers
|
||||
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register('consult', ConsultViewSet, basename="consult")
|
||||
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
]
|
|
@ -0,0 +1,29 @@
|
|||
from django.shortcuts import render
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
from .models import Consult
|
||||
# Create your views here.
|
||||
from rest_framework import serializers
|
||||
from utils.custom import CommonPagination
|
||||
from .models import Consult
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from rest_framework.filters import OrderingFilter, SearchFilter
|
||||
class ConsultSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
咨询序列化
|
||||
"""
|
||||
class Meta:
|
||||
model = Consult
|
||||
fields = '__all__'
|
||||
|
||||
class ConsultViewSet(ModelViewSet):
|
||||
"""
|
||||
咨询 增删改查
|
||||
"""
|
||||
perms_map = [
|
||||
{'get': '*'}, {'post': '*'},
|
||||
{'put': 'consult_update'}, {'delete': 'consult_delete'}]
|
||||
queryset = Consult.objects.filter(is_delete=0)
|
||||
serializer_class = ConsultSerializer
|
||||
pagination_class = CommonPagination
|
||||
filter_backends = [DjangoFilterBackend,SearchFilter, OrderingFilter]
|
||||
search_fields = ['name','tests', 'phone']
|
|
@ -47,7 +47,8 @@ INSTALLED_APPS = [
|
|||
'question',
|
||||
'examtest',
|
||||
'analyse',
|
||||
'cms'
|
||||
'cms',
|
||||
'qtest'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
|
@ -30,6 +30,7 @@ urlpatterns = [
|
|||
path('examtest/', include('examtest.urls')),
|
||||
path('cms/', include('cms.urls')),
|
||||
path('analyse/', include('analyse.urls')),
|
||||
path('qtest/', include('qtest.urls')),
|
||||
path('token/', obtain_jwt_token),
|
||||
path('token/refresh/', refresh_jwt_token),
|
||||
path('token/verify/', verify_jwt_token),
|
||||
|
|
Loading…
Reference in New Issue