修改提交
This commit is contained in:
parent
d6c9ee2580
commit
2a0a069d38
|
@ -0,0 +1,36 @@
|
|||
# Generated by Django 2.2.8 on 2022-11-01 12:51
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('safesite', '0396_auto_20220304_1648'),
|
||||
('enp', '0029_auto_20221031_1707'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='GasTestEquipment',
|
||||
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='删除标记')),
|
||||
('contaminant', models.CharField(max_length=100, verbose_name='污染物')),
|
||||
('model', models.CharField(max_length=100, verbose_name='仪器型号')),
|
||||
('state', models.CharField(default='正常', max_length=100, verbose_name='设备状态')),
|
||||
('remark', 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='gastestequipment_create_by', to='safesite.User', verbose_name='创建人')),
|
||||
('drain', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='enp.Drain', verbose_name='关联排放口')),
|
||||
('update_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='gastestequipment_update_by', to='safesite.User', verbose_name='最后编辑人')),
|
||||
('usecomp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='safesite.Partment', verbose_name='所属公司')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -266,6 +266,18 @@ class Waterequipment(CommonModel):
|
|||
jcyqmodel = models.CharField('监测仪器型号', max_length=100, null=True, blank=True)
|
||||
note = models.CharField('备注', max_length=500, null=True, blank=True)
|
||||
usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name='所属公司')
|
||||
|
||||
class GasTestEquipment(CommonModel):
|
||||
"""
|
||||
废气检测仪器
|
||||
"""
|
||||
drain = models.ForeignKey(Drain, verbose_name='关联排放口', on_delete=models.CASCADE)
|
||||
contaminant = models.CharField('污染物', max_length=100)
|
||||
model = models.CharField('仪器型号', max_length=100)
|
||||
state = models.CharField('设备状态', default='正常', max_length=100)
|
||||
remark = models.CharField('备注', max_length=200)
|
||||
usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name='所属公司')
|
||||
|
||||
class Archives(CommonModel):
|
||||
"""
|
||||
档案管理
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
<div class="easyui-layout" style="width:100%;height:100%;">
|
||||
|
||||
|
||||
<div data-options="region:'center',split:true,border:false" style="height:100%;">
|
||||
<div id="waterequipmentTableBar">
|
||||
<a onclick="addwaterequipment()" class="easyui-linkbutton" data-options="iconCls: 'fa-plus',plain: true">新增</a>
|
||||
<a onclick="ediwaterequipment()" class="easyui-linkbutton" data-options="iconCls: 'fa-pencil',plain: true">编辑</a>
|
||||
<a onclick="delwaterequipment()" class="easyui-linkbutton" data-options="iconCls: 'fa-trash',plain: true">删除</a>
|
||||
</div>
|
||||
<table id="waterequipmentTable" style="height:100%"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="waterequipmentDialog" class="easyui-dialog" style="width:700px;height:600px;padding:20px 25px;"
|
||||
data-options="resizable:true,modal:true,closed:true,border:false">
|
||||
<form method="post" id="waterequipmentForm">
|
||||
<input name="id" type="hidden">
|
||||
<div style="margin-bottom:10px">
|
||||
<input name="number" data-options="label:'排放口编号', labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input name="type" data-options="label:'污染物种类',labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input name="methods" data-options="label:'监测采样方法及个数',labelWidth:150" class="easyui-textbox" style="width:600px;" ></input>
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input name="count" data-options="label:'监测次数',labelWidth:100" class="easyui-numberbox" style="width:600px;" ></input>
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input name="identification" data-options="label:'鉴定方法',labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input name="jcyqmodel" data-options="label:'监测仪器型号', labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
|
||||
|
||||
</div>
|
||||
<div style="margin-bottom:10px">
|
||||
<input name="note" data-options="label:'备注', labelWidth:100" class="easyui-textbox" style="width:600px;" ></input>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="text-align: center;">
|
||||
<a class="easyui-linkbutton" iconCls="fa-floppy-o" onclick="savewaterequipment()">保存</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
var waterequipment_action_url = '/api/enp/gastestequipment/create/';
|
||||
|
||||
$('#waterequipmentTable').datagrid({
|
||||
url: '/api/enp/gastestequipment/list/',
|
||||
rownumbers: true,
|
||||
singleSelect: true,
|
||||
striped: true,
|
||||
method: 'get',
|
||||
toolbar: '#waterequipmentTableBar',
|
||||
border: false,
|
||||
columns: [[
|
||||
{ field: 'id', title: 'ID', hidden: true },
|
||||
{ field: 'drain__name', title: '排放口', width: 200 },
|
||||
{ field: 'contaminant', title: '污染物', width: 200 },
|
||||
{ field: 'model', title: '仪器型号', width: 200 },
|
||||
{ field: 'state', title: '设备状态', width: 200 },
|
||||
{ field: 'remark', title: '备注', width: 200 },
|
||||
]],
|
||||
onClickRow: function (index, row) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
//新增
|
||||
function addwaterequipment() {
|
||||
$('#waterequipmentDialog').dialog('open').dialog('setTitle', '新增').window('center');
|
||||
$('#waterequipmentForm').form('clear');
|
||||
waterequipment_action_url = '/api/enp/gastestequipment/create/'
|
||||
}
|
||||
//保存数据
|
||||
function savewaterequipment() {
|
||||
var data = $('#waterequipmentForm').serializeJSON();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: waterequipment_action_url,
|
||||
data: JSON.stringify(data),
|
||||
datatype: "json",
|
||||
processData: false,
|
||||
contentType: "application/json;charset=utf-8",
|
||||
beforeSend: function () {
|
||||
return $('#waterequipmentForm').form('validate')
|
||||
},
|
||||
success: function (data) {
|
||||
$("#waterequipmentTable").datagrid('reload');
|
||||
$("#waterequipmentDialog").dialog("close");
|
||||
|
||||
},
|
||||
});
|
||||
}
|
||||
//编辑数据
|
||||
function ediwaterequipment(){
|
||||
var row = $('#waterequipmentTable').datagrid('getSelected');
|
||||
if(row){
|
||||
$('#waterequipmentDialog').dialog('open').dialog('setTitle', '编辑').window('center');
|
||||
$('#waterequipmentForm').form('load', row);
|
||||
waterequipment_action_url = '/api/enp/gastestequipment/update/'}
|
||||
else{
|
||||
$.messager.alert('提示', '请选择一条数据!');
|
||||
}
|
||||
}
|
||||
//删除数据
|
||||
function delwaterequipment(){
|
||||
var row = $('#waterequipmentTable').datagrid('getSelected');
|
||||
if (row) {
|
||||
$.messager.confirm('提示', '确定删除吗?', function (r) {
|
||||
if (r) {
|
||||
var data = { id: row.id }
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/api/enp/gastestequipment/delete/',
|
||||
data: JSON.stringify(data),
|
||||
datatype: "json",
|
||||
beforeSend: function () { },
|
||||
success: function (data) {
|
||||
if (data.code == 1) {
|
||||
$("#waterequipmentTable").datagrid('reload');
|
||||
$("#waterequipmentTable").datagrid('reload');
|
||||
}
|
||||
else {
|
||||
$.messager.alert('提示', '操作失败!');
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else { $.messager.alert('提示', '请选择一条数据!'); }
|
||||
|
||||
}
|
||||
</script>
|
|
@ -13,6 +13,7 @@ urlpatterns = [
|
|||
path('detection/', views.HtmlDetection),
|
||||
path('fuel/', views.HtmlFuel),
|
||||
path('waterequipment/', views.HtmlWaterequipment),
|
||||
path('gastestequipment/', views.HtmlGasTestEquipment),
|
||||
path('archives/', views.HtmlArchives),
|
||||
path('zprevention/', views.HtmlZprevention),
|
||||
|
||||
|
|
|
@ -21,11 +21,7 @@ urlpatterns = [
|
|||
path('detection/<str:action>/', views.ApiDetection),#废水污染物检测
|
||||
path('fuel/<str:action>/', views.ApiFuel),#燃料信息表
|
||||
path('waterequipment/<str:action>/', views.ApiWaterequipment),#废水监测仪器信息表
|
||||
path('gastestequipment/<str:action>/', views.ApiGasTestEquipment),#废气监测仪器信息表
|
||||
path('archives/<str:action>/', views.ApiArchives),#档案管理表
|
||||
path('zprevention/<str:action>/', views.ApiZprevention),#噪声防治设施
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
]
|
43
enp/views.py
43
enp/views.py
|
@ -5,7 +5,7 @@ from rest_framework.views import APIView
|
|||
from rest_framework.authentication import BaseAuthentication
|
||||
from safesite.models import User,Dickey,Partment
|
||||
from rest_framework.exceptions import AuthenticationFailed
|
||||
from .models import DWasteHandleRecord, DWasteKeepRecord, DWasteMakeList, DWasteMakeRecord, Drain, GasEmit, NormalWasteRecord, Waste, Facilities,Prevention,abnormal,Detection,Fuel,Waterequipment,Archives
|
||||
from .models import DWasteHandleRecord, DWasteKeepRecord, DWasteMakeList, DWasteMakeRecord, Drain, GasEmit, GasTestEquipment, NormalWasteRecord, Waste, Facilities,Prevention,abnormal,Detection,Fuel,Waterequipment,Archives
|
||||
from safesite.views import transjson, fenye, MyEncoder
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
import json
|
||||
|
@ -44,6 +44,8 @@ def HtmlFuel(request):
|
|||
return render(request, 'fuel.html')
|
||||
def HtmlWaterequipment(request):
|
||||
return render(request, 'waterequipment.html')
|
||||
def HtmlGasTestEquipment(request):
|
||||
return render(request, 'gastestequipment.html')
|
||||
def HtmlGprevention(request):
|
||||
return render(request, 'gprevention.html')
|
||||
def HtmlArchives(request):
|
||||
|
@ -975,4 +977,41 @@ def ApiGasPredict(request, element, drainId):
|
|||
return JsonResponse(ret)
|
||||
else:
|
||||
return JsonResponse({"code":0, "msg":'至少需要三条记录'})
|
||||
|
||||
|
||||
|
||||
def ApiGasTestEquipment(request, action):
|
||||
user = User.objects.get(userid=request.session['userid'])
|
||||
if action == 'list':
|
||||
objs = GasTestEquipment.objects.filter(usecomp=user.usecomp, is_deleted=False)
|
||||
total = objs.count()
|
||||
startnum, endnum = fenye(request)
|
||||
objs = objs.order_by('id')[startnum:endnum].values('id', 'drain', 'drain__name', 'contaminant', 'model', 'state', 'remark')
|
||||
return HttpResponse(transjson(total, objs), content_type="application/json")
|
||||
elif action == 'create':
|
||||
data = json.loads(request.body.decode('utf-8'))
|
||||
obj= GasTestEquipment()
|
||||
obj.drain = Drain.objects.get(id=data['drain'])
|
||||
obj.contaminant = data['contaminant']
|
||||
obj.model = data['model']
|
||||
obj.state = data['state']
|
||||
obj.remark = data['remark']
|
||||
obj.create_by = user
|
||||
obj.update_by = user
|
||||
obj.usecomp = user.usecomp
|
||||
obj.save()
|
||||
return JsonResponse({"code":1})
|
||||
elif action == 'delete':
|
||||
data = json.loads(request.body.decode('utf-8'))
|
||||
obj = GasTestEquipment.objects.get(id=data['id'])
|
||||
obj.delete()
|
||||
return JsonResponse({"code":1})
|
||||
elif action == 'update':
|
||||
data = json.loads(request.body.decode('utf-8'))
|
||||
obj = GasTestEquipment.objects.get(id=data['id'])
|
||||
obj.contaminant = data['contaminant']
|
||||
obj.model = data['model']
|
||||
obj.state = data['state']
|
||||
obj.remark = data['remark']
|
||||
obj.update_by=user
|
||||
obj.save()
|
||||
return JsonResponse({"code":1})
|
Loading…
Reference in New Issue