From 85951fc65b0e1f329a98e7c709bf710828036367 Mon Sep 17 00:00:00 2001 From: "2309368887@qq.com" <2309368887@qq.com> Date: Thu, 19 May 2022 11:37:42 +0800 Subject: [PATCH] ceshijiacedian --- enp/templates/wgas.html | 4 +- enp/templates/wwater.html | 219 +++++++------- enp/urls_api.py | 5 +- enp/views.py | 91 ++++-- safesite/static/safesite/mystatic/js/util.js | 16 + safesite/templates/areajiance.html | 289 +++++++++++++++++++ safesite/templates/jianceditu.html | 209 ++++++++++++++ safesite/templates/main.html | 23 ++ safesite/urls.py | 2 + safesite/views.py | 12 +- 10 files changed, 732 insertions(+), 138 deletions(-) create mode 100644 safesite/templates/areajiance.html create mode 100644 safesite/templates/jianceditu.html diff --git a/enp/templates/wgas.html b/enp/templates/wgas.html index ee4cb37a..4979930c 100644 --- a/enp/templates/wgas.html +++ b/enp/templates/wgas.html @@ -1,6 +1,6 @@
-
+
新增 编辑 @@ -8,7 +8,7 @@
-
+
新增 diff --git a/enp/templates/wwater.html b/enp/templates/wwater.html index ee4cb37a..ca66c03c 100644 --- a/enp/templates/wwater.html +++ b/enp/templates/wwater.html @@ -1,6 +1,6 @@
-
+
新增 编辑 @@ -8,14 +8,12 @@
-
-
- 新增 - 删除 +
+ -
+
-
-
+ +
- + + +
+ +
+ + +
- + + +
- + + +
- + + +
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- + + +
+
@@ -102,10 +81,10 @@ $('#operator__nameFormItem').textbox('setValue', top.$('#in').attr('show')); } } - var drain_action_url = '/api/enp/drain/create/'; + var drain_action_url = '/api/enp/drains/create/'; var record_action_url = '/api/enp/gasemit/create/'; $('#drainTable').datagrid({ - url: '/api/enp/drain/list/', + url: '/api/enp/drains/list/', rownumbers: true, singleSelect: true, striped: true, @@ -119,33 +98,33 @@ { field: 'name', title: '排放口名称', width: 100 }, ]], onClickRow: function (index, row) { - $('#gasEmitTable').datagrid({ - url: '/api/enp/gasemit/list/?drain=' + row.id + $('#detectionTable').datagrid({ + url: '/api/enp/detection/list/?drain=' + row.id }) } }); - $('#gasEmitTable').datagrid({ - url: '/api/enp/gasemit/list/', + $('#detectionTable').datagrid({ + url: '/api/enp/detection/list/', rownumbers: true, singleSelect: true, striped: true, method: 'get', - toolbar: '#gasEmitTableBar', + toolbar: '#detectionTableBar', border: false, - fitColumns: true, columns: [[ - { field: 'id', title: 'ID', hidden: true }, + { field: 'id', title: 'ID', hidden: true }, { 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 }, + { field: 'drain__name', title: '排放口 ', width: 200 }, + { field: 'jcDate', title: '监测日期', width: 200 }, + { field: 'jctime', title: '监测时间', width: 200 }, + { field: 'ckhxxyl', title: '出:化学需氧量(mg/L)', width: 200 }, + { field: 'ckshxll', title: '出:生化需氧量(mg/L)', width: 200 }, + { field: 'ckad', title: '出:氨氮(mg/L)', width: 200 }, + { field: 'ckxfw', title: '出:悬浮物(mg/L)', width: 200 }, + { field: 'jkhxxyl', title: '进:化学需氧量(mg/L)', width: 200 }, + { field: 'jkshxll', title: '进:生化需氧量(mg/L)', width: 200 }, + { field: 'jkad', title: '进:氨氮(mg/L)', width: 200 }, + { field: 'jkxfw', title: '进:悬浮物(mg/L)', width: 200 }, ]], onClickRow: function (index, row) { @@ -154,27 +133,15 @@ function addDrain() { $('#drainDialog').dialog('open').dialog('setTitle', '新增排放口').window('center'); $('#drainForm').form('clear'); - drain_action_url = '/api/enp/drain/create/' - } - function addGasEmitRecord() { - - var row = $('#drainTable').datagrid('getSelected'); - if(row){ - $('#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('提示', '请先选择左侧排放口!'); - } - + drain_action_url = '/api/enp/drains/create/' } + function editDrain(){ var row = $('#draineTable').datagrid('getSelected'); if(row){ $('#drainDialog').dialog('open').dialog('setTitle', '编辑排放口').window('center'); $('#drainForm').form('load', row); - drain_action_url = '/api/enp/drain/update/'} + drain_action_url = '/api/enp/drains/update/'} else{ $.messager.alert('提示', '请选择一条数据!'); } @@ -197,24 +164,7 @@ }, }); } - function saveGasEmitRecord() { - var data = $('#gasEmitForm').serializeJSON(); - $.ajax({ - type: "POST", - url: record_action_url, - data: JSON.stringify(data), - datatype: "json", - processData: false, - contentType: "application/json;charset=utf-8", - beforeSend: function () { - return $('#gasEmitForm').form('validate') - }, - success: function (data) { - $("#gasEmitTable").datagrid('reload'); - $("#gasEmitDialog").dialog("close"); - }, - }); - } + function delDrain() { var row = $('#drainTable').datagrid('getSelected'); if (row) { @@ -223,7 +173,7 @@ var data = { id: row.id } $.ajax({ type: "POST", - url: '/api/enp/drain/delete/', + url: '/api/enp/drains/delete/', data: JSON.stringify(data), datatype: "json", beforeSend: function () { }, @@ -242,22 +192,70 @@ } else { $.messager.alert('提示', '请选择一条数据!'); } } - function delGasEmitRecord() { - var row = $('#gasEmitTable').datagrid('getSelected'); + //新增 + function adddetection() { + var row = $('#drainTable').datagrid('getSelected'); + if(row){ + $('#detectionDialog').dialog('open').dialog('setTitle', '新增记录').window('center'); + $('#detectionForm').form('clear'); + $('#gasEmitForm_drain').attr('value', row.id); + record_action_url = '/api/enp/detection/create/'; + }else{ + $.messager.alert('提示', '请先选择左侧排放口!'); + } + + + + } + var detection_action_url = '/api/enp/detection/create/'; + //保存数据 + function savedetection() { + var data = $('#detectionForm').serializeJSON(); + $.ajax({ + type: "POST", + url: detection_action_url, + data: JSON.stringify(data), + datatype: "json", + processData: false, + contentType: "application/json;charset=utf-8", + beforeSend: function () { + return $('#detectionForm').form('validate') + }, + success: function (data) { + $("#detectionTable").datagrid('reload'); + $("#detectionDialog").dialog("close"); + + }, + }); + } + //编辑数据 + function edidetection(){ + var row = $('#detectionTable').datagrid('getSelected'); + if(row){ + $('#detectionDialog').dialog('open').dialog('setTitle', '编辑废水污染物检测结').window('center'); + $('#detectionForm').form('load', row); + detection_action_url = '/api/enp/detection/update/'} + else{ + $.messager.alert('提示', '请选择一条数据!'); + } + } + //删除数据 + function deldetection(){ + var row = $('#detectionTable').datagrid('getSelected'); if (row) { $.messager.confirm('提示', '确定删除吗?', function (r) { if (r) { var data = { id: row.id } $.ajax({ type: "POST", - url: '/api/enp/gasemit/delete/', + url: '/api/enp/detection/delete/', data: JSON.stringify(data), datatype: "json", beforeSend: function () { }, success: function (data) { if (data.code == 1) { - $("#gasEmitTable").datagrid('reload'); - // $("#gasEmitTable").datagrid('reload'); + $("#detectionTable").datagrid('reload'); + $("#detectionTable").datagrid('reload'); } else { $.messager.alert('提示', '操作失败!'); @@ -268,5 +266,6 @@ }); } else { $.messager.alert('提示', '请选择一条数据!'); } + } \ No newline at end of file diff --git a/enp/urls_api.py b/enp/urls_api.py index 65a58e2d..63b41bcd 100644 --- a/enp/urls_api.py +++ b/enp/urls_api.py @@ -3,7 +3,10 @@ from . import views urlpatterns = [ path('waste//', views.ApiWaste), - path('drain//', views.ApiDrain), + path('drain//', views.ApiDrainq),#排气口 + path('drains//', views.ApiDrains),#排水口 + path('draindt//', views.ApiDraindt),#排口地图 + path('normalwasterecord//', views.ApiNormalWasteRecord), path('dwastemakelist//', views.ApiDWasteMakeList), path('dwastemakerecord//', views.ApiDWasteMakeRecord), diff --git a/enp/views.py b/enp/views.py index 2a9b7146..e3a205e7 100644 --- a/enp/views.py +++ b/enp/views.py @@ -404,9 +404,11 @@ def ApiDetection(request, action): user = User.objects.get(userid=request.session['userid']) if action == 'list': objs = Detection.objects.filter(usecomp=user.usecomp, is_deleted=False) + if request.GET.get('drain', None): + objs = objs.filter(drain=request.GET.get('drain')) total = objs.count() startnum, endnum = fenye(request) - objs = objs.order_by('-create_time')[startnum:endnum].values('id', 'number', 'jcDate', 'jctime', 'ckhxxyl', 'ckshxll', + objs = objs.order_by('-create_time')[startnum:endnum].values('id', 'drain' , 'drain__name', 'drain__number','jcDate', 'jctime', 'ckhxxyl', 'ckshxll', 'ckad', 'ckxfw', 'jkhxxyl', 'jkshxll', 'jkad', 'jkxfw') return HttpResponse(transjson(total, objs), content_type="application/json") elif action == 'create': @@ -415,7 +417,7 @@ def ApiDetection(request, action): obj.create_by = user obj.update_by = user obj.usecomp = user.usecomp - obj.number = data['number'] + obj.drain = Drain.objects.get(id=data['drain']) obj.jcDate = data['jcDate'] obj.jctime = data['jctime'] obj.ckhxxyl = data['ckhxxyl'] @@ -429,25 +431,7 @@ def ApiDetection(request, action): obj.save() return JsonResponse({"code":1}) - elif action == 'update': - data = json.loads(request.body.decode('utf-8')) - obj = Detection.objects.get(id=data['id']) - obj.create_by = user - obj.update_by = user - obj.usecomp = user.usecomp - obj.number = data['number'] - obj.jcDate = data['jcDate'] - obj.jctime = data['jctime'] - obj.ckhxxyl = data['ckhxxyl'] - obj.ckshxll = data['ckshxll'] - obj.ckad = data['ckad'] - obj.ckxfw = data['ckxfw'] - obj.jkhxxyl = data['jkhxxyl'] - obj.jkshxll = data['jkshxll'] - obj.jkad = data['jkad'] - obj.jkxfw = data['jkxfw'] - obj.save() - return JsonResponse({"code":1}) + elif action == 'delete': data = json.loads(request.body.decode('utf-8')) obj = Detection.objects.get(id=data['id']) @@ -685,11 +669,11 @@ def ApiDWasteHandleRecord(request,action): obj = DWasteHandleRecord.objects.get(id=data['id']) obj.delete() return JsonResponse({"code":1}) - -def ApiDrain(request, action): +#排气排放口 +def ApiDrainq(request, action): user = User.objects.get(userid=request.session['userid']) if action == 'list': - objs = Drain.objects.filter(usecomp=user.usecomp, is_deleted=False) + objs = Drain.objects.filter(usecomp=user.usecomp, is_deleted=False,type=20) total = objs.count() startnum, endnum = fenye(request) objs = objs.order_by('id')[startnum:endnum].values('id', 'number', 'name') @@ -702,6 +686,7 @@ def ApiDrain(request, action): data = json.loads(request.body.decode('utf-8')) obj= Drain() obj.number = data['number'] + obj.type = 20 obj.name = data['name'] obj.create_by = user obj.update_by = user @@ -717,11 +702,69 @@ def ApiDrain(request, action): data = json.loads(request.body.decode('utf-8')) obj = Drain.objects.get(id=data['id']) obj.number = data['number'] + obj.type = 20 obj.name = data['name'] obj.update_by=user obj.save() return JsonResponse({"code":1}) +#排水排放口 +def ApiDrains(request, action): + user = User.objects.get(userid=request.session['userid']) + if action == 'list': + objs = Drain.objects.filter(usecomp=user.usecomp, is_deleted=False,type=10) + total = objs.count() + startnum, endnum = fenye(request) + objs = objs.order_by('id')[startnum:endnum].values('id', 'number', 'name') + return HttpResponse(transjson(total, objs), content_type="application/json") + elif action == 'combobox': + objs = Drain.objects.filter(usecomp=user.usecomp, is_deleted=False).order_by('id') + data = objs.values('id', 'number', 'name') + return JsonResponse(list(data), safe=False) + elif action == 'create': + data = json.loads(request.body.decode('utf-8')) + obj= Drain() + obj.number = data['number'] + obj.name = data['name'] + obj.type = 10 + 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 = Drain.objects.get(id=data['id']) + obj.delete() + return JsonResponse({"code":1}) + elif action == 'update': + data = json.loads(request.body.decode('utf-8')) + obj = Drain.objects.get(id=data['id']) + obj.number = data['number'] + obj.type = 10 + obj.name = data['name'] + obj.update_by=user + obj.save() + return JsonResponse({"code":1}) +#排口用于地图 +def ApiDraindt(request, action): + user = User.objects.get(userid=request.session['userid']) + + if action == 'list': + objs = Drain.objects.filter(usecomp=user.usecomp, is_deleted=False) + total = objs.count() + startnum, endnum = fenye(request) + objs = objs.order_by('id')[startnum:endnum].values('id', 'number', 'name','type','location') + return HttpResponse(transjson(total, objs), content_type="application/json") +#首页展示地图 + elif action == 'allmap': + objs = Drain.objects.filter(usecomp=user.usecomp, is_deleted=False).values('id', 'number', 'name','type','location') + return HttpResponse(json.dumps(list(objs)), content_type="application/json") + elif action == 'bind': + data = json.loads(request.body.decode('utf-8')) + Drain.objects.filter(id=data['id']).update(location=data['polygon']) + return JsonResponse({"code": 1}) +#排气监测数据 def ApiGasEmit(request,action): user = User.objects.get(userid=request.session['userid']) if action == 'list': diff --git a/safesite/static/safesite/mystatic/js/util.js b/safesite/static/safesite/mystatic/js/util.js index 2508d228..748ffdd5 100644 --- a/safesite/static/safesite/mystatic/js/util.js +++ b/safesite/static/safesite/mystatic/js/util.js @@ -602,6 +602,7 @@ function mapupdate() { } }) $.get('/api/mapshow?a=trouble', function (res) { + for (let i = 0, len = res.length; i < len; i++) { var data = res[i] data.id = data.yhqy__id @@ -635,6 +636,21 @@ function mapupdate() { setPoint(data) } }) + //监测地图,排口获取 + $.get('/api/enp/draindt/allmap', function (res) { + console.log(res); + for (let i = 0; i < res.length; i++) { + + var data = res[i] + data.id = data.id + data.number = data.number + data.location = data.location + data.name = data.name + data.type = 'pk' + setPoint(data) + + } + }) } } function checksession(){ diff --git a/safesite/templates/areajiance.html b/safesite/templates/areajiance.html new file mode 100644 index 00000000..08f5a325 --- /dev/null +++ b/safesite/templates/areajiance.html @@ -0,0 +1,289 @@ +
+
+
+
    +
    + +
    + +
      +
      +
      + +
      + + +
      +
      +
      +
      + \ No newline at end of file diff --git a/safesite/templates/jianceditu.html b/safesite/templates/jianceditu.html new file mode 100644 index 00000000..31ce57be --- /dev/null +++ b/safesite/templates/jianceditu.html @@ -0,0 +1,209 @@ +
      +
      +
      + + + diff --git a/safesite/templates/main.html b/safesite/templates/main.html index 1ca4a69f..f1ac33a8 100644 --- a/safesite/templates/main.html +++ b/safesite/templates/main.html @@ -260,6 +260,13 @@ float: left;">
      + + +
      @@ -333,6 +340,7 @@ float: left;">
      + + {% endif %}