diff --git a/enp/migrations/0018_auto_20220517_1654.py b/enp/migrations/0018_auto_20220517_1654.py new file mode 100644 index 00000000..1aeab8a3 --- /dev/null +++ b/enp/migrations/0018_auto_20220517_1654.py @@ -0,0 +1,40 @@ +# Generated by Django 2.2.8 on 2022-05-17 16:54 + +import django.contrib.postgres.fields.jsonb +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('enp', '0017_auto_20220516_0858'), + ] + + operations = [ + migrations.RemoveField( + model_name='detection', + name='number', + ), + migrations.AddField( + model_name='detection', + name='drain', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='enp.Drain', verbose_name='关联排放口'), + preserve_default=False, + ), + migrations.AddField( + model_name='drain', + name='polygon', + field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True, verbose_name='点位坐标'), + ), + migrations.AddField( + model_name='drain', + name='type', + field=models.PositiveSmallIntegerField(choices=[(10, '排水'), (20, '排气')], default=10, verbose_name='排污口类型'), + ), + migrations.AlterField( + model_name='waterequipment', + name='count', + field=models.IntegerField(blank=True, null=True, verbose_name='监测次数'), + ), + ] diff --git a/enp/migrations/0019_auto_20220517_1717.py b/enp/migrations/0019_auto_20220517_1717.py new file mode 100644 index 00000000..04de8e39 --- /dev/null +++ b/enp/migrations/0019_auto_20220517_1717.py @@ -0,0 +1,29 @@ +# Generated by Django 2.2.8 on 2022-05-17 17:17 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('enp', '0018_auto_20220517_1654'), + ] + + operations = [ + migrations.RenameField( + model_name='drain', + old_name='polygon', + new_name='location', + ), + migrations.RemoveField( + model_name='waterequipment', + name='number', + ), + migrations.AddField( + model_name='waterequipment', + name='drain', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='enp.Drain', verbose_name='关联排放口'), + preserve_default=False, + ), + ] diff --git a/enp/models.py b/enp/models.py index 1ee756a3..5f76113a 100644 --- a/enp/models.py +++ b/enp/models.py @@ -1,6 +1,7 @@ from django.db import models from safesite.models import User, Partment from utils.models import CommonModel +from django.contrib.postgres.fields import JSONField # Create your models here. class Waste(CommonModel): @@ -90,8 +91,14 @@ class Drain(CommonModel): """ 排放口 """ + DRAIN_TYPE_CHOICES = ( + (10, '排水'), + (20, '排气') + ) + type = models.PositiveSmallIntegerField('排污口类型', default=10, choices=DRAIN_TYPE_CHOICES) number = models.CharField('编号', max_length=100) name = models.CharField('名称', max_length=100) + location = JSONField('点位坐标', null=True, blank=True) usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name='所属公司') class GasEmit(CommonModel): @@ -197,11 +204,12 @@ class abnormal(CommonModel): sfbg = models.CharField('是否报告', max_length=200, null=True, blank=True) ydcs = models.CharField('应对措施', max_length=200, null=True, blank=True) usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name='所属公司') + class Detection(CommonModel): """ 废水污染物检测结果表 """ - number = models.CharField('排放口编号', max_length=100) + drain = models.ForeignKey(Drain, verbose_name='关联排放口', on_delete=models.CASCADE) jcDate = models.DateTimeField('监测日期', null=True, blank=True) jctime = models.DateTimeField('监测时间', null=True, blank=True) ckhxxyl = models.FloatField('出口化学需氧量(mg/L)', max_length=200, null=True, blank=True) @@ -213,6 +221,7 @@ class Detection(CommonModel): jkad = models.FloatField('进口氨氮(mg/L)', max_length=200, null=True, blank=True) jkxfw = models.FloatField('进口悬浮物(mg/L)', max_length=200, null=True, blank=True) usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name='所属公司') + class Fuel(CommonModel): """ 燃料信息表 @@ -230,14 +239,15 @@ class Fuel(CommonModel): rqqt = models.CharField('燃气其他', max_length=100, null=True, blank=True) qtrlxgwzhl = models.CharField('其他燃料相关物质含量', max_length=400, null=True, blank=True) usecomp = models.ForeignKey(Partment, on_delete=models.CASCADE, verbose_name='所属公司') + class Waterequipment(CommonModel): """ 废水监测仪器信息表 """ - number = models.CharField('排放口编号', max_length=100) + drain = models.ForeignKey(Drain, verbose_name='关联排放口', on_delete=models.CASCADE) type = models.CharField('污染物种类', max_length=100, null=True, blank=True) methods = models.CharField('监测采样方法及个数', max_length=300, null=True, blank=True) - count = models.IntegerField('监测次数', max_length=100, null=True, blank=True) + count = models.IntegerField('监测次数', null=True, blank=True) identification = models.CharField('鉴定方法', max_length=200, null=True, blank=True) jcyqmodel = models.CharField('监测仪器型号', max_length=100, null=True, blank=True) note = models.CharField('备注', max_length=500, null=True, blank=True) diff --git a/enp/templates/drain_point.html b/enp/templates/drain_point.html new file mode 100644 index 00000000..e69de29b diff --git a/enp/templates/wwater.html b/enp/templates/wwater.html index 89bfb15d..ee4cb37a 100644 --- a/enp/templates/wwater.html +++ b/enp/templates/wwater.html @@ -1,68 +1,97 @@
-
-
- 新增 - 编辑 - 删除 +
+ -
+
-
-
-
-
+ -
- +
-
-
-
+ - - +
- +
- +
- +
- +
- +
- - 选择 + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
@@ -73,102 +102,103 @@ $('#operator__nameFormItem').textbox('setValue', top.$('#in').attr('show')); } } - var waste_action_url = '/api/enp/waste/create/'; - var record_action_url = '/api/enp/normalwasterecord/create/'; - $('#wasteTable').datagrid({ - url: '/api/enp/waste/list/?type=1', + var drain_action_url = '/api/enp/drain/create/'; + var record_action_url = '/api/enp/gasemit/create/'; + $('#drainTable').datagrid({ + url: '/api/enp/drain/list/', rownumbers: true, singleSelect: true, striped: true, method: 'get', - toolbar: '#wasteTableBar', + toolbar: '#drainTableBar', border: false, fitColumns: true, columns: [[ { field: 'id', title: 'ID', hidden: true }, - { field: 'number', title: '废物编号', width: 100 }, - { field: 'name', title: '废物名称', width: 100 }, + { field: 'number', title: '排放口编号', width: 100 }, + { field: 'name', title: '排放口名称', width: 100 }, ]], onClickRow: function (index, row) { - $('#normalWasteRecordTable').datagrid({ - url: '/api/enp/normalwasterecord/list/?waste=' + row.id + $('#gasEmitTable').datagrid({ + url: '/api/enp/gasemit/list/?drain=' + row.id }) } }); - $('#normalWasteRecordTable').datagrid({ - url: '/api/enp/normalwasterecord/list/', + $('#gasEmitTable').datagrid({ + url: '/api/enp/gasemit/list/', rownumbers: true, singleSelect: true, striped: true, method: 'get', - toolbar: '#normalWasteRecordTableBar', + toolbar: '#gasEmitTableBar', border: false, fitColumns: true, columns: [[ { field: 'id', title: 'ID', hidden: true }, - { field: 'operator', title: 'operator', hidden: true }, - { field: 'waste', title: 'waste', hidden: true }, - { field: 'waste__name', title: '废物名称', width: 100 }, - { field: 'gen_date', title: '产生日期', width: 100 }, - { field: 'gen_count', title: '产生数量(吨)', width: 100 }, - { field: 'dis_date', title: '处置日期', width: 100 }, - { field: 'dis_count', title: '委托处置量(吨)', width: 100 }, - { field: 'inv_count', title: '库存量(吨)', width: 100 }, - { field: 'operator__name', title: '经办人', width: 100 }, + { field: 'drain', title: 'drain', hidden: true }, + { field: 'drain__name', title: '排放口 ', width: 100 }, + { field: 'watch_time', title: '监测时间', width: 100 }, + { field: 'out_smoke', title: '出:干烟含量', width: 100 }, + { field: 'out_o2', title: '出:氧含量', width: 100 }, + { field: 'out_so2', title: '出:二氧化硫', width: 100 }, + { field: 'out_so2_s', title: '出:二氧化硫折标', width: 100 }, + { field: 'out_particle', title: '出:颗粒物', width: 100 }, + { field: 'out_particle_s', title: '出:颗粒物折标', width: 100 }, + { field: 'out_nox', title: '出:氮氧化物', width: 100 }, + { field: 'out_nox_s', title: '出:氮氧化物折标', width: 100 }, ]], onClickRow: function (index, row) { } }); - function addWaste() { - $('#wasteDialog').dialog('open').dialog('setTitle', '新增一般固废名').window('center'); - $('#wasteForm').form('clear'); - $('#typeFormItem').attr('value',1); - waste_action_url = '/api/enp/waste/create/' + function addDrain() { + $('#drainDialog').dialog('open').dialog('setTitle', '新增排放口').window('center'); + $('#drainForm').form('clear'); + drain_action_url = '/api/enp/drain/create/' } - function addNormalWasteRecord() { + function addGasEmitRecord() { - var row = $('#wasteTable').datagrid('getSelected'); + var row = $('#drainTable').datagrid('getSelected'); if(row){ - $('#normalWasteRecordDialog').dialog('open').dialog('setTitle', '新增记录').window('center'); - $('#normalWasteRecordForm').form('clear'); - $('#wasteFormItem').attr('value', row.id); - record_action_url = '/api/enp/normalwasterecord/create/'; + $('#gasEmitDialog').dialog('open').dialog('setTitle', '新增记录').window('center'); + $('#gasEmitForm').form('clear'); + $('#gasEmitForm_drain').attr('value', row.id); + record_action_url = '/api/enp/gasemit/create/'; }else{ - $.messager.alert('提示', '请先选择左侧废物!'); + $.messager.alert('提示', '请先选择左侧排放口!'); } } - function editWaste(){ - var row = $('#wasteTable').datagrid('getSelected'); + function editDrain(){ + var row = $('#draineTable').datagrid('getSelected'); if(row){ - $('#wasteDialog').dialog('open').dialog('setTitle', '编辑一般固废名').window('center'); - $('#wasteForm').form('load', row); - waste_action_url = '/api/enp/waste/update/'} + $('#drainDialog').dialog('open').dialog('setTitle', '编辑排放口').window('center'); + $('#drainForm').form('load', row); + drain_action_url = '/api/enp/drain/update/'} else{ $.messager.alert('提示', '请选择一条数据!'); } } - function saveWaste() { - var data = $('#wasteForm').serializeJSON(); + function saveDrain() { + var data = $('#drainForm').serializeJSON(); $.ajax({ type: "POST", - url: waste_action_url, + url: drain_action_url, data: JSON.stringify(data), datatype: "json", processData: false, contentType: "application/json;charset=utf-8", beforeSend: function () { - return $('#wasteForm').form('validate') + return $('#drainForm').form('validate') }, success: function (data) { - $("#wasteTable").datagrid('reload'); - $("#wasteDialog").dialog("close"); + $("#drainTable").datagrid('reload'); + $("#drainDialog").dialog("close"); }, }); } - function saveNormalWasteRecord() { - var data = $('#normalWasteRecordForm').serializeJSON(); + function saveGasEmitRecord() { + var data = $('#gasEmitForm').serializeJSON(); $.ajax({ type: "POST", url: record_action_url, @@ -177,30 +207,57 @@ processData: false, contentType: "application/json;charset=utf-8", beforeSend: function () { - return $('#normalWasteRecordForm').form('validate') + return $('#gasEmitForm').form('validate') }, success: function (data) { - $("#normalWasteRecordTable").datagrid('reload'); - $("#normalWasteRecordDialog").dialog("close"); + $("#gasEmitTable").datagrid('reload'); + $("#gasEmitDialog").dialog("close"); }, }); } - function delWaste() { - var row = $('#wasteTable').datagrid('getSelected'); + function delDrain() { + var row = $('#drainTable').datagrid('getSelected'); if (row) { $.messager.confirm('提示', '确定删除吗?', function (r) { if (r) { var data = { id: row.id } $.ajax({ type: "POST", - url: '/api/enp/waste/delete/', + url: '/api/enp/drain/delete/', data: JSON.stringify(data), datatype: "json", beforeSend: function () { }, success: function (data) { if (data.code == 1) { - $("#wasteTable").datagrid('reload'); - $("#normalWasteRecordTable").datagrid('reload'); + $("#drainTable").datagrid('reload'); + // $("#gasEmitTable").datagrid('reload'); + } + else { + $.messager.alert('提示', '操作失败!'); + } + }, + }); + } + }); + } + else { $.messager.alert('提示', '请选择一条数据!'); } + } + function delGasEmitRecord() { + var row = $('#gasEmitTable').datagrid('getSelected'); + if (row) { + $.messager.confirm('提示', '确定删除吗?', function (r) { + if (r) { + var data = { id: row.id } + $.ajax({ + type: "POST", + url: '/api/enp/gasemit/delete/', + data: JSON.stringify(data), + datatype: "json", + beforeSend: function () { }, + success: function (data) { + if (data.code == 1) { + $("#gasEmitTable").datagrid('reload'); + // $("#gasEmitTable").datagrid('reload'); } else { $.messager.alert('提示', '操作失败!'); diff --git a/enp/urls.py b/enp/urls.py index 00c6be10..439ff14c 100644 --- a/enp/urls.py +++ b/enp/urls.py @@ -12,7 +12,5 @@ urlpatterns = [ path('abnormal/', views.HtmlAbnormal), path('detection/', views.HtmlDetection), path('fuel/', views.HtmlFuel), - path('waterequipment/', views.HtmlWaterequipment), - - + path('waterequipment/', views.HtmlWaterequipment), ] \ No newline at end of file