django cache 有问题

This commit is contained in:
caoqianming 2021-07-20 16:52:32 +08:00
parent 720a27ca5e
commit e11447b800
16 changed files with 404 additions and 11 deletions

View File

@ -3,10 +3,10 @@ ENV = 'development'
# base api
#VUE_APP_BASE_API = 'http://10.0.11.127:8000/api'
#VUE_APP_BASE_API = 'http://127.0.0.1:8000/api'
VUE_APP_BASE_API = 'http://127.0.0.1:8000/api'
#VUE_APP_BASE_API = 'https://testsearch.ctc.ac.cn/api'
VUE_APP_BASE_API = 'http://47.95.0.242:9101/api'
#VUE_APP_BASE_API = 'http://47.95.0.242:9101/api'
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,

BIN
client_mp/components/.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,183 @@
<template>
<view>
<view class="fanku_con">
<view class="img_z">
<view class="imgadf center" @click="ongetimg()">
<image style="width: 58rpx;height: 58rpx;" src="./tupianadd.png" mode=""></image>
<text style="margin-top: 5rpx;">上传图片</text>
</view>
<view style="position: relative;" v-for="(item,index) in img_list" :key="index">
<image @click="preview(index,img_list)" style="width: 120rpx;height: 120rpx;margin-left: 20rpx;margin-bottom: 20rpx;background-color:rgba(0,0,0,0.1);border-radius: 10rpx;"
:src="item"></image>
<image class="shancs" src="./shanchus2.png" mode="" @click="selec(index)"></image>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
img_list: []
}
},
props: {
// 最多上数量 1-9
count: {
type: Number,
default: false
},
//图片上传地址
url: {
type: String,
default: ''
},
//文件对应的 key
name: {
type: String,
default: ''
},
//请求头
header: {
type: Object,
default: {}
}
},
computed: {},
methods: {
ongetimg() { //上传图片方法
var that = this
if (!that.url) {
return uni.showToast({
title: '请填写上传地址',
icon: 'none',
position: 'bottom'
});
}
uni.chooseImage({ //选中本地图片
count: that.count,
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图默认二者都有
sourceType: ['album'], //从相册选择
success: res => {
uni.showLoading({ //加载框
title: '加载中...'
})
const tempFilePaths = res.tempFilePaths;
res.tempFilePaths.forEach((item, index) => { //本地选中的图片组
console.log(that.url)
uni.uploadFile({ //上传图片
url: that.url, //上传接口地址
filePath: item, //一张图
name: that.name,
header: that.header,
success: res => {
if (that.img_list.length >= that.count) //限制
return uni.showToast({
title: '最多上传' + that.count + '张图片',
icon: 'none',
position: 'bottom'
});
that.img_list.push(JSON.parse(res.data).data.url); //plus数组
that.$emit('obtain_img', that.img_list)
}
});
uni.hideLoading() //关闭加载框
});
}
});
},
//删除
selec(index) {
this.img_list.splice(index, 1)
this.$emit('obtain_img', this.img_list)
},
//预览
preview(index, urls) {
console.log(index)
console.log(urls)
uni.previewImage({
urls: urls,
current: index,
longPressActions: {
itemList: ['发送给朋友', '保存图片', '收藏'],
success: function(data) {
console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
},
fail: function(err) {
console.log(err.errMsg);
}
}
});
}
}
}
</script>
<style>
page {
background-color: #181E38;
padding-top: 66rpx;
box-sizing: border-box;
}
.fanku_con {
width: 690rpx;
background: rgba(0, 0, 0, 0.1);
border-radius: 10rpx;
margin-left: 30rpx;
padding-top: 20rpx;
padding-bottom: 70rpx;
box-sizing: border-box;
}
.imgadf {
width: 120rpx;
height: 120rpx;
background-color: rgba(255, 255, 255, 0.5);
/* margin-left: 29rpx; */
margin-left: 20rpx;
border-radius: 10rpx;
margin-bottom: 20rpx;
font-size: 20rpx;
color: #666666;
flex-direction: column;
}
.img_z {
display: flex;
flex-wrap: wrap;
margin-top: 90rpx;
padding-right: 10rpx;
box-sizing: border-box;
}
.shancs {
width: 35rpx;
height: 35rpx;
position: absolute;
top: -10rpx;
right: -10rpx;
background-color: #FFFFFF;
border-radius: 100%;
}
.dianhua_on {
width: 364rpx;
height: 74rpx;
background: linear-gradient(to right, #F55C63, #F78361);
border-radius: 38rpx;
font-size: 28rpx;
color: #FFFFFF;
margin-top: 130rpx;
margin-left: 192rpx;
}
.center {
display: flex;
justify-content: center;
align-items: center;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -23,7 +23,7 @@
</u-radio-group>
</u-form-item>
<u-form-item label="检查说明">
<u-input v-model="form.note" type="textarea" :border="true" />
<u-input v-model="form.note" type="textarea" :border="true" :maxlength="-1"/>
</u-form-item>
<u-form-item label="拍照取证">
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" :file-list="fileList"></u-upload>

View File

@ -151,9 +151,6 @@
// 点击导航切换swiper
taggleNav(val) {
this.swiperIndex = val;
if (this.list[val].content.length == 0) {
this.getVideos()
}
},
// 滚动tabs以及移动下划线
scrollDom() {

View File

@ -35,6 +35,7 @@ const store = new Vuex.Store({
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
// vuex_host: 'http://127.0.0.1:8000',
//vuex_api: 'http://47.95.0.242:9101/api',
//vuex_api: 'http://127.0.0.1:8000/api',
// vuex_apifile: 'http://127.0.0.1:8000/api/file/',
vuex_host: 'https://testsearch.ctc.ac.cn',

View File

@ -0,0 +1,39 @@
# Generated by Django 3.0.5 on 2021-07-19 02:38
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('ability', '0019_auto_20210129_0957'),
]
operations = [
migrations.CreateModel(
name='Ability',
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='删除标记')),
('dlxh', models.TextField(blank=True, null=True, verbose_name='大类序号')),
('dlmc', models.TextField(blank=True, null=True, verbose_name='大类')),
('lbxh', models.TextField(blank=True, null=True, verbose_name='类别序号')),
('lbmc', models.TextField(blank=True, null=True, verbose_name='类别名称')),
('xmxh', models.TextField(blank=True, null=True, verbose_name='项目序号')),
('xmmc', models.TextField(blank=True, null=True, verbose_name='项目名称')),
('bzmc', models.TextField(blank=True, null=True, verbose_name='标准名称')),
('bzbh', models.TextField(blank=True, null=True, verbose_name='标准编号')),
('bztk', models.TextField(blank=True, null=True, verbose_name='标准条款')),
('xzfw', models.TextField(blank=True, null=True, verbose_name='限制范围')),
('bz', models.TextField(blank=True, null=True, verbose_name='备注')),
('cma', models.TextField(blank=True, null=True, verbose_name='CMA中心')),
('cna', models.TextField(blank=True, null=True, verbose_name='CNAS中心')),
],
options={
'verbose_name': '记录合并',
},
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.0.5 on 2021-07-19 04:37
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('ability', '0020_ability'),
]
operations = [
migrations.RenameField(
model_name='ability',
old_name='cna',
new_name='cnas',
),
]

View File

@ -0,0 +1,23 @@
# Generated by Django 3.0.5 on 2021-07-19 06:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ability', '0021_auto_20210719_1237'),
]
operations = [
migrations.AddField(
model_name='ability',
name='cma_o',
field=models.TextField(blank=True, null=True, verbose_name='中心'),
),
migrations.AddField(
model_name='ability',
name='cma_oplace',
field=models.TextField(blank=True, null=True, verbose_name='地点'),
),
]

View File

@ -6,6 +6,27 @@ from apps.system.models import Organization, User
# Create your models here.
from django.contrib.postgres.fields import JSONField
class Ability(BaseModel):
dlxh = models.TextField('大类序号', null=True, blank=True)
dlmc = models.TextField('大类', null=True, blank=True)
lbxh = models.TextField('类别序号', null=True,blank=True)
lbmc = models.TextField('类别名称', null=True,blank=True)
xmxh = models.TextField('项目序号', null=True,blank=True)
xmmc = models.TextField('项目名称', null=True,blank=True)
bzmc = models.TextField('标准名称', null=True,blank=True)
bzbh = models.TextField('标准编号', null=True,blank=True)
bztk = models.TextField('标准条款', null=True,blank=True)
xzfw = models.TextField('限制范围',null=True,blank=True)
bz = models.TextField('备注',null=True,blank=True)
cma = models.TextField('CMA中心',null=True,blank=True)
cnas = models.TextField('CNAS中心',null=True,blank=True)
cma_o = models.TextField('中心',null=True,blank=True)
cma_oplace = models.TextField('地点',null=True,blank=True)
class Meta:
verbose_name='记录合并'
class QueryRecord(BaseModel):
user = models.ForeignKey(User, related_name='record_user', on_delete=models.CASCADE)
path = models.CharField('访问地址', max_length=200)

View File

@ -1,6 +1,6 @@
from django.urls import path, include
from rest_framework import routers
from .views import CMAViewSet, CNASViewSet, QualificationViewSet,InspectionViewSet,QualificationotherViewSet, QueryRecordListViewSet
from .views import CMAViewSet, CNASViewSet, QualificationViewSet,InspectionViewSet,QualificationotherViewSet, QueryRecordListViewSet, correct_ability, merge_cma, merge_cnas
router = routers.DefaultRouter()
router.register('cma', CMAViewSet, basename="cma")
@ -10,5 +10,8 @@ router.register('qualificationother', QualificationotherViewSet, basename="quali
router.register('inspection', InspectionViewSet, basename="inspection")
router.register('queryrecord', QueryRecordListViewSet, basename="queryrecord")
urlpatterns = [
path('merge/cma/', merge_cma),
path('merge/cnas/', merge_cnas),
path('correct/', correct_ability),
path('', include(router.urls))
]

View File

@ -14,6 +14,7 @@ from apps.system.models import Organization
from openpyxl import Workbook, load_workbook
from django.db.models import Count
from utils.pagination import PageOrNot
from rest_framework.views import APIView
# Create your views here.
import json
@ -58,12 +59,15 @@ class CMAViewSet(RecordMixin, ModelViewSet):
"""
queryset = self.filter_queryset(self.get_queryset())
ret = []
ret2 = {}
if request.query_params.get('group_by', None):
group_by = request.query_params.get('group_by')
group_by_data = list(queryset.values(group_by).annotate(count=Count(group_by)).order_by(group_by))
for i in group_by_data:
if i[group_by] and i['count']:
ret2[i[group_by]] = "A"
ret.append({'text':i[group_by]+'('+ str(i['count']) +')','value':i[group_by]})
print(ret2)
return Response(ret)
@action(methods=['post'], detail=False, url_path='deletes', url_name='cma_deletes', perms_map = {'post':'cma_deletes'})
def deletes(self, request):
@ -594,3 +598,99 @@ def import_inspection(filename, path):
datalist.append(Inspection(**data))
i = i + 1
Inspection.objects.bulk_create(datalist)
from django.db.models.functions import Cast
def merge_cnas(request):
for i in CNAS.objects.all():
objs = Ability.objects.filter(lbmc=i.lbmc,xmmc=i.xmmc, bzbh=i.bzbh, bztk=i.bztk)
if objs.exists():
obj = objs[0]
if obj.cnas:
obj.cnas = obj.cnas + ',' + i.sszx
obj.save()
else:
obj.cnas = i.sszx
obj.save()
print('已修改--'+obj.xmmc+ '-' + obj.cnas)
def merge_cma(request):
for i in CMA.objects.filter(type='center'):
bztk = i.bzbh.split(' ')[-1]
bzbh = i.bzbh.rstrip(bztk).strip()
if len(bzbh)<8:
bzbh = i.bzbh
bztk = ''
objs = Ability.objects.filter(lbmc=i.lbmc, xmmc=i.xmmc, bzbh = bzbh, bztk=bztk)
if objs.exists():
obj = objs[0]
obj.cma = obj.cma + ',' + i.sszx
obj.save()
print('已修改--'+obj.xmmc+ '-' + obj.cma)
else:
obj = Ability()
obj.dlxh = i.dlxh
obj.dlmc = i.dlmc
obj.lbxh = i.lbxh
obj.lbmc = i.lbmc
obj.xmxh = i.xmxh
obj.xmmc = i.xmmc
obj.bzmc = i.bzmc
obj.bzbh = bzbh
obj.bztk = bztk
obj.xzfw = i.xzfw
obj.bz = i.bz
obj.cma = i.sszx
obj.save()
print('已添加--'+obj.xmmc+obj.bzmc)
def correct_ability(request):
zxdict = {
"测试中心":"B",
"玻璃中心":"E",
"腐蚀中心":"P",
"光伏中心":"L",
"耐火中心":"Q",
"石材中心":"R",
"水泥中心":"D",
"质检中心":"C"
}
placedict = {
"玻璃中心-管庄": "E",
"玻璃中心-密云": "E",
"玻璃中心-永顺": "E",
"测试中心-管庄": "B",
"测试中心-光华路": "B",
"测试中心-国检三层": "B",
"测试中心-密云": "B",
"测试中心-顺义种植园": "B",
"测试中心-宋庄": "B",
"测试中心-通州种植园": "B",
"测试中心-永顺": "B",
"腐蚀中心": "P",
"光伏中心-管庄": "L",
"光伏中心-密云": "L",
"耐火中心": "Q",
"石材中心": "R",
"水泥中心": "D",
"质检中心-管庄": "C",
"质检中心-光华路": "C",
"质检中心-国检三层": "c",
"质检中心-密云": "C",
"质检中心-顺义种植园": "C",
"质检中心-宋庄": "C",
"质检中心-通州种植园": "C",
"质检中心-永顺": "C"
}
for i in Ability.objects.all():
# i.cma_o = i.cma
i.cma = i.cma_o
i.cma_oplace = i.cma_o
for key in zxdict:
if key in i.cma_o:
i.cma = i.cma.replace(key, zxdict[key])
for key in placedict:
if key in i.cma_o:
i.cma_oplace = i.cma_oplace.replace(key, placedict[key])
i.save()
print('已修改' + i.cma)

View File

@ -1,12 +1,20 @@
from .settings import *
DEBUG = True
DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': 'cma',
# 'USER': 'postgres',
# 'PASSWORD': 'zctest1234',
# 'HOST': '47.95.0.242',
# 'PORT': '5432',
# }
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'cma',
'USER': 'postgres',
'PASSWORD': 'zctest1234',
'HOST': '47.95.0.242',
'USER': 'cma',
'PASSWORD': 'cma123',
'HOST': '172.16.80.102',
'PORT': '5432',
}
}