Merge branch 'master' of https://e.coding.net/ctcdevteam/cma_search
This commit is contained in:
commit
7ec83e0585
|
|
@ -3,10 +3,10 @@ ENV = 'development'
|
||||||
|
|
||||||
# base api
|
# base api
|
||||||
#VUE_APP_BASE_API = 'http://10.0.11.127:8000/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 = '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,
|
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -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 |
|
|
@ -23,7 +23,7 @@
|
||||||
</u-radio-group>
|
</u-radio-group>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
<u-form-item label="检查说明">
|
<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>
|
||||||
<u-form-item label="拍照取证">
|
<u-form-item label="拍照取证">
|
||||||
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" :file-list="fileList"></u-upload>
|
<u-upload :action="vuex_apifile" :header="header" ref="uUpload" :file-list="fileList"></u-upload>
|
||||||
|
|
|
||||||
|
|
@ -151,9 +151,6 @@
|
||||||
// 点击导航切换swiper
|
// 点击导航切换swiper
|
||||||
taggleNav(val) {
|
taggleNav(val) {
|
||||||
this.swiperIndex = val;
|
this.swiperIndex = val;
|
||||||
if (this.list[val].content.length == 0) {
|
|
||||||
this.getVideos()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
// 滚动tabs以及移动下划线
|
// 滚动tabs以及移动下划线
|
||||||
scrollDom() {
|
scrollDom() {
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ const store = new Vuex.Store({
|
||||||
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
|
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
|
||||||
// vuex_host: 'http://127.0.0.1:8000',
|
// vuex_host: 'http://127.0.0.1:8000',
|
||||||
//vuex_api: 'http://47.95.0.242:9101/api',
|
//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_apifile: 'http://127.0.0.1:8000/api/file/',
|
||||||
|
|
||||||
vuex_host: 'https://testsearch.ctc.ac.cn',
|
vuex_host: 'https://testsearch.ctc.ac.cn',
|
||||||
|
|
|
||||||
|
|
@ -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': '记录合并',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -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',
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -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='地点'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
# Generated by Django 3.0.5 on 2021-07-28 01:02
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('system', '0018_auto_20210430_1156'),
|
||||||
|
('ability', '0022_auto_20210719_1411'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='qualification',
|
||||||
|
name='ssbm',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='qualification_ssbm', to='system.Organization'),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Correct',
|
||||||
|
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='类别名称')),
|
||||||
|
('bclxh', models.TextField(blank=True, null=True, verbose_name='被测量序号')),
|
||||||
|
('bclmc', models.TextField(blank=True, null=True, verbose_name='被测量名称')),
|
||||||
|
('jzgc', models.TextField(blank=True, null=True, verbose_name='校准规程')),
|
||||||
|
('clfw', models.TextField(blank=True, null=True, verbose_name='测量范围')),
|
||||||
|
('zqddj', models.TextField(blank=True, null=True, verbose_name='准确度等级')),
|
||||||
|
('note', models.TextField(blank=True, null=True, verbose_name='说明')),
|
||||||
|
('ssgs', models.TextField(blank=True, null=True, verbose_name='所属公司')),
|
||||||
|
('ssbm', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='correct_ssbm', to='system.Organization')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': '校验能力',
|
||||||
|
'verbose_name_plural': '校验能力',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -6,6 +6,27 @@ from apps.system.models import Organization, User
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
from django.contrib.postgres.fields import JSONField
|
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):
|
class QueryRecord(BaseModel):
|
||||||
user = models.ForeignKey(User, related_name='record_user', on_delete=models.CASCADE)
|
user = models.ForeignKey(User, related_name='record_user', on_delete=models.CASCADE)
|
||||||
path = models.CharField('访问地址', max_length=200)
|
path = models.CharField('访问地址', max_length=200)
|
||||||
|
|
@ -18,6 +39,23 @@ class QueryRecord(BaseModel):
|
||||||
verbose_name = '查询记录'
|
verbose_name = '查询记录'
|
||||||
verbose_name_plural = verbose_name
|
verbose_name_plural = verbose_name
|
||||||
|
|
||||||
|
class Correct(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)
|
||||||
|
bclxh = models.TextField('被测量序号', null=True,blank=True)
|
||||||
|
bclmc = models.TextField('被测量名称', null=True,blank=True)
|
||||||
|
jzgc = models.TextField('校准规程', null=True, blank=True)
|
||||||
|
clfw = models.TextField('测量范围', null=True, blank=True)
|
||||||
|
zqddj = models.TextField('准确度等级', null=True, blank=True)
|
||||||
|
note = models.TextField('说明', null=True, blank=True)
|
||||||
|
ssgs = models.TextField('所属公司', null=True, blank=True)
|
||||||
|
ssbm = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True, related_name='correct_ssbm')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name='校验能力'
|
||||||
|
verbose_name_plural=verbose_name
|
||||||
|
|
||||||
class CMA(BaseModel):
|
class CMA(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
@ -71,7 +109,7 @@ class CNAS(BaseModel):
|
||||||
|
|
||||||
class Qualification(BaseModel):
|
class Qualification(BaseModel):
|
||||||
sszx = models.TextField('所属中心', null=True, blank=True)
|
sszx = models.TextField('所属中心', null=True, blank=True)
|
||||||
ssbm = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True, related_name='system_ssbm')
|
ssbm = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True, related_name='qualification_ssbm')
|
||||||
cma = models.TextField('cma资质', null=True, blank=True)
|
cma = models.TextField('cma资质', null=True, blank=True)
|
||||||
cnas = models.TextField('cnas资质', null=True, blank=True)
|
cnas = models.TextField('cnas资质', null=True, blank=True)
|
||||||
other = models.TextField('检验检测相关其它资质', null=True, blank=True)
|
other = models.TextField('检验检测相关其它资质', null=True, blank=True)
|
||||||
|
|
|
||||||
|
|
@ -66,4 +66,18 @@ class QualificationotherSerializer(serializers.ModelSerializer):
|
||||||
def setup_eager_loading(queryset):
|
def setup_eager_loading(queryset):
|
||||||
""" Perform necessary eager loading of data. """
|
""" Perform necessary eager loading of data. """
|
||||||
queryset = queryset.select_related('qualification')
|
queryset = queryset.select_related('qualification')
|
||||||
|
return queryset
|
||||||
|
|
||||||
|
class CorrectSerializer(serializers.ModelSerializer):
|
||||||
|
"""
|
||||||
|
校验能力序列化
|
||||||
|
"""
|
||||||
|
bm_ =OrganizationSerializer(source = 'ssbm', read_only=True)
|
||||||
|
class Meta:
|
||||||
|
model = Correct
|
||||||
|
fields = '__all__'
|
||||||
|
@staticmethod
|
||||||
|
def setup_eager_loading(queryset):
|
||||||
|
""" Perform necessary eager loading of data. """
|
||||||
|
queryset = queryset.select_related('ssbm')
|
||||||
return queryset
|
return queryset
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
|
from django.db.models import base
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from rest_framework import routers
|
from rest_framework import routers
|
||||||
from .views import CMAViewSet, CNASViewSet, QualificationViewSet,InspectionViewSet,QualificationotherViewSet, QueryRecordListViewSet
|
from .views import CMAViewSet, CNASViewSet, CorrectViewSet, QualificationViewSet,InspectionViewSet,QualificationotherViewSet, QueryRecordListViewSet, correct_ability, merge_cma, merge_cnas
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register('cma', CMAViewSet, basename="cma")
|
router.register('cma', CMAViewSet, basename="cma")
|
||||||
|
|
@ -9,6 +10,10 @@ router.register('qualification', QualificationViewSet, basename="qualification")
|
||||||
router.register('qualificationother', QualificationotherViewSet, basename="qualificationother")
|
router.register('qualificationother', QualificationotherViewSet, basename="qualificationother")
|
||||||
router.register('inspection', InspectionViewSet, basename="inspection")
|
router.register('inspection', InspectionViewSet, basename="inspection")
|
||||||
router.register('queryrecord', QueryRecordListViewSet, basename="queryrecord")
|
router.register('queryrecord', QueryRecordListViewSet, basename="queryrecord")
|
||||||
|
router.register('correct', CorrectViewSet, basename="correct")
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path('merge/cma/', merge_cma),
|
||||||
|
path('merge/cnas/', merge_cnas),
|
||||||
|
# path('correct/', correct_ability),
|
||||||
path('', include(router.urls))
|
path('', include(router.urls))
|
||||||
]
|
]
|
||||||
|
|
@ -14,6 +14,7 @@ from apps.system.models import Organization
|
||||||
from openpyxl import Workbook, load_workbook
|
from openpyxl import Workbook, load_workbook
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
from utils.pagination import PageOrNot
|
from utils.pagination import PageOrNot
|
||||||
|
from rest_framework.views import APIView
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
@ -26,8 +27,7 @@ class RecordMixin():
|
||||||
will instead be performed lazily, the first time either
|
will instead be performed lazily, the first time either
|
||||||
`request.user` or `request.auth` is accessed.
|
`request.user` or `request.auth` is accessed.
|
||||||
"""
|
"""
|
||||||
user = request.user
|
if request.user and request.method == 'GET' and request.user.username != 'admin':
|
||||||
if request.method == 'GET' and user.username != 'admin':
|
|
||||||
QueryRecord.objects.create(user=user,path=request.path,ip=request.META.get('HTTP_X_FORWARDED_FOR'),method=\
|
QueryRecord.objects.create(user=user,path=request.path,ip=request.META.get('HTTP_X_FORWARDED_FOR'),method=\
|
||||||
request.method,search=request.query_params.get('search',None),query=request.query_params)
|
request.method,search=request.query_params.get('search',None),query=request.query_params)
|
||||||
|
|
||||||
|
|
@ -364,6 +364,55 @@ class CNASViewSet(RecordMixin, ModelViewSet):
|
||||||
return Response(status = status.HTTP_200_OK)
|
return Response(status = status.HTTP_200_OK)
|
||||||
|
|
||||||
|
|
||||||
|
class CorrectViewSet(RecordMixin, ModelViewSet):
|
||||||
|
"""
|
||||||
|
校验能力:增删改查
|
||||||
|
"""
|
||||||
|
perms_map = {'get': 'correct_view', 'post': 'correct_create',
|
||||||
|
'put': 'correct_update', 'delete': 'correct_delete'}
|
||||||
|
queryset = Correct.objects.all()
|
||||||
|
serializer_class = CorrectSerializer
|
||||||
|
search_fields = ['dlmc', 'lbmc', 'bclmc','jzgc']
|
||||||
|
ordering_fields = ['dlmc']
|
||||||
|
ordering = ['create_time', 'dlmc']
|
||||||
|
filterset_fields = ['ssbm']
|
||||||
|
|
||||||
|
@action(methods=['post'], detail=False, perms_map = {'post':'correct_delete'})
|
||||||
|
def deletes(self, request):
|
||||||
|
array = request.data['ids']
|
||||||
|
Correct.objects.filter(pk__in=array).delete()
|
||||||
|
return Response(status = status.HTTP_200_OK)
|
||||||
|
|
||||||
|
@action(methods=['get'], detail=False, perms_map = {'*':'*'})
|
||||||
|
def group(self, request, pk=None):
|
||||||
|
"""
|
||||||
|
聚合查询列
|
||||||
|
"""
|
||||||
|
queryset = self.filter_queryset(self.get_queryset())
|
||||||
|
ret = []
|
||||||
|
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']:
|
||||||
|
ret.append({'text':i[group_by]+'('+ str(i['count']) +')','value':i[group_by]})
|
||||||
|
return Response(ret)
|
||||||
|
|
||||||
|
@action(methods=['post'], detail=False, url_path="import")
|
||||||
|
def correct_import(self, request, pk=None):
|
||||||
|
"""
|
||||||
|
导入校验能力
|
||||||
|
"""
|
||||||
|
filepath = request.data['path']
|
||||||
|
fullpath = settings.BASE_DIR + filepath
|
||||||
|
if fullpath.endswith('.xlsx'):
|
||||||
|
ret = import_correct(fullpath)
|
||||||
|
if ret[0]:
|
||||||
|
return Response()
|
||||||
|
return Response(ret[1], status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
else:
|
||||||
|
return Response('不支持非xlsx格式', status = status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
def import_qualification(path):
|
def import_qualification(path):
|
||||||
wb = load_workbook(path)
|
wb = load_workbook(path)
|
||||||
sheet = wb.worksheets[0]
|
sheet = wb.worksheets[0]
|
||||||
|
|
@ -593,4 +642,165 @@ def import_inspection(filename, path):
|
||||||
data['sszx'] = sszx
|
data['sszx'] = sszx
|
||||||
datalist.append(Inspection(**data))
|
datalist.append(Inspection(**data))
|
||||||
i = i + 1
|
i = i + 1
|
||||||
Inspection.objects.bulk_create(datalist)
|
Inspection.objects.bulk_create(datalist)
|
||||||
|
|
||||||
|
def import_correct(path):
|
||||||
|
wb = load_workbook(path,data_only=True)
|
||||||
|
sheet = wb.worksheets[0]
|
||||||
|
datalist = []
|
||||||
|
ssgs = sheet['k3'].value
|
||||||
|
try:
|
||||||
|
ssbm = Organization.objects.get(name=ssgs)
|
||||||
|
except:
|
||||||
|
return False , ssgs+'不存在'
|
||||||
|
if Correct.objects.filter(ssbm=ssbm).exists():
|
||||||
|
Correct.objects.filter(ssbm=ssbm).delete()
|
||||||
|
i = 3
|
||||||
|
max_row = sheet.max_row
|
||||||
|
defaultv = {}
|
||||||
|
while i<max_row+1:
|
||||||
|
data = {}
|
||||||
|
if sheet['a'+str(i)].value:
|
||||||
|
data['dlxh'] = sheet['a'+str(i)].value
|
||||||
|
defaultv['dlxh'] = data['dlxh']
|
||||||
|
else:
|
||||||
|
data['dlxh'] = defaultv['dlxh']
|
||||||
|
if sheet['b'+str(i)].value:
|
||||||
|
data['dlmc'] = sheet['b'+str(i)].value
|
||||||
|
defaultv['dlmc'] = data['dlmc']
|
||||||
|
else:
|
||||||
|
data['dlmc'] = defaultv['dlmc']
|
||||||
|
if sheet['c'+str(i)].value:
|
||||||
|
data['lbxh'] = sheet['c'+str(i)].value
|
||||||
|
defaultv['lbxh'] = data['lbxh']
|
||||||
|
else:
|
||||||
|
data['lbxh'] = defaultv['lbxh']
|
||||||
|
if sheet['d'+str(i)].value:
|
||||||
|
data['lbmc'] = sheet['d'+str(i)].value
|
||||||
|
defaultv['lbmc'] = data['lbmc']
|
||||||
|
else:
|
||||||
|
data['lbmc'] = defaultv['lbmc']
|
||||||
|
if sheet['e'+str(i)].value:
|
||||||
|
data['bclxh'] = sheet['e'+str(i)].value
|
||||||
|
defaultv['bclxh'] = data['bclxh']
|
||||||
|
else:
|
||||||
|
data['bclxh'] = defaultv['bclxh']
|
||||||
|
if sheet['f'+str(i)].value:
|
||||||
|
data['bclmc'] = sheet['f'+str(i)].value
|
||||||
|
defaultv['bclmc'] = data['bclmc']
|
||||||
|
else:
|
||||||
|
data['bclmc'] = defaultv['bclmc']
|
||||||
|
if sheet['g'+str(i)].value:
|
||||||
|
data['jzgc'] = sheet['g'+str(i)].value
|
||||||
|
defaultv['jzgc'] = data['jzgc']
|
||||||
|
else:
|
||||||
|
data['jzgc'] = defaultv['jzgc']
|
||||||
|
if sheet['h'+str(i)].value:
|
||||||
|
data['clfw'] = sheet['h'+str(i)].value
|
||||||
|
defaultv['clfw'] = data['clfw']
|
||||||
|
else:
|
||||||
|
data['clfw'] = defaultv['clfw']
|
||||||
|
data['zqddj'] = sheet['i'+str(i)].value if (sheet['i'+str(i)].value and sheet['i'+str(i)].value !='无') else None
|
||||||
|
data['note'] = sheet['j'+str(i)].value if (sheet['j'+str(i)].value and sheet['j'+str(i)].value !='无') else None
|
||||||
|
data['ssgs'] = ssgs
|
||||||
|
data['ssbm'] = ssbm
|
||||||
|
datalist.append(Correct(**data))
|
||||||
|
i = i + 1
|
||||||
|
Correct.objects.bulk_create(datalist)
|
||||||
|
return True, ''
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,12 @@ DATABASES = {
|
||||||
'HOST': '47.95.0.242',
|
'HOST': '47.95.0.242',
|
||||||
'PORT': '5432',
|
'PORT': '5432',
|
||||||
}
|
}
|
||||||
|
# 'default': {
|
||||||
|
# 'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
# 'NAME': 'cma',
|
||||||
|
# 'USER': 'cma',
|
||||||
|
# 'PASSWORD': 'cma123',
|
||||||
|
# 'HOST': '172.16.80.102',
|
||||||
|
# 'PORT': '5432',
|
||||||
|
# }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue