rabin 7 years ago
parent
commit
8997f9c98d

+ 25 - 32
admin/page/__load__.py

@@ -17,53 +17,46 @@ class Load(Base):
 		admin = 1
 		self.data['auth'] = True
 		
-		if 'admin' in Demeter.config['setting'] and Demeter.config['setting']['admin'] > 0:
-			if 'adminInfo' not in Demeter.config['setting'] or ('adminInfo' in Demeter.config['setting'] and Demeter.config['setting']['admin'] != Demeter.config['setting']['adminInfo']):
-				Demeter.config['setting']['adminInfo'] = self.service('common').one('manage_admin', id=Demeter.config['setting']['admin'])
-				if Demeter.config['setting']['adminInfo']:
-					Demeter.config['setting']['roleInfo'] = self.service('common').one('manage_role', id=Demeter.config['setting']['adminInfo']['role_id'])
+		if 'admin' in self.data['setting'] and self.data['setting']['admin'] > 0:
+			self.data['setting']['adminInfo'] = self.service('common').one('manage_admin', id=self.data['setting']['admin'])
+			if self.data['setting']['adminInfo']:
+				self.data['setting']['roleInfo'] = self.service('common').one('manage_role', id=self.data['setting']['adminInfo']['role_id'])
 		else:
 			#self.redirect('/user/login')
 			return
 
-		if 'farm' in Demeter.config['setting'] and Demeter.config['setting']['farm'] > 0:
-			if 'farmInfo' not in Demeter.config['setting'] or ('farmInfo' in Demeter.config['setting'] and Demeter.config['setting']['farm'] != Demeter.config['setting']['farmInfo']):
-				Demeter.config['setting']['farmInfo'] = self.service('common').one('farm', id=Demeter.config['setting']['farm'])
-				if not Demeter.config['setting']['farmInfo']:
-					Demeter.config['setting']['farmInfo']['name'] = '默认'
+		if 'farm' in self.data['setting'] and self.data['setting']['farm'] > 0:
+			self.data['setting']['farmInfo'] = self.service('common').one('farm', id=self.data['setting']['farm'])
 
-		if 'menuList' not in Demeter.config['setting']:
-			Demeter.config['setting']['menuList'] = self.menu()
+		self.data['setting']['menuList'] = self.menu()
 
-		if Demeter.config['setting']['adminInfo']['id'] == admin:
-			if 'menu' in Demeter.config['setting']:
-				del Demeter.config['setting']['menu']
+		if self.data['setting']['adminInfo']['id'] == admin:
+			if 'menu' in self.data['setting']:
+				del self.data['setting']['menu']
 		else:
-			if 'menu' not in Demeter.config['setting'] and 'roleInfo' in Demeter.config['setting']:
-				Demeter.config['setting']['menu'] = ['_/', '_/login', '_/main', '_/admin/log_update']
-				menu = Demeter.config['setting']['roleInfo']['auth'] + ','
-				for i,j in enumerate(Demeter.config['setting']['menuList'][1]):
-					m = 0
-					for n in j[0]:
-						if n+',' in menu:
-							l = str(i)+'_'+str(n)
-							Demeter.config['setting']['menu'].append(l)
-							Demeter.config['setting']['menu'].append(l + '_update')
-						m = m + 1
-				Demeter.config['setting']['menu'] = ',' + ",".join(Demeter.config['setting']['menu'])+','
+			self.data['setting']['menu'] = ['_/', '_/login', '_/main', '_/admin/log_update']
+			menu = self.data['setting']['roleInfo']['auth'] + ','
+			for i,j in enumerate(self.data['setting']['menuList'][1]):
+				m = 0
+				for n in j[0]:
+					if n+',' in menu:
+						l = str(i)+'_'+str(n)
+						self.data['setting']['menu'].append(l)
+						self.data['setting']['menu'].append(l + '_update')
+					m = m + 1
+			self.data['setting']['menu'] = ',' + ",".join(self.data['setting']['menu'])+','
 
 			uri = '_' + self.request.uri + ','
-			if Demeter.config['setting']['admin'] != admin and uri not in Demeter.config['setting']['menu']:
+			if self.data['setting']['admin'] != admin and uri not in self.data['setting']['menu']:
 				self.data['auth'] = False
-
-		if 'farmList' not in Demeter.config['setting']:
-			Demeter.config['setting']['farmList'] = self.service('common').list('farm')
+		self.data['setting']['web'] = Demeter.config['web']['url']
+		self.data['setting']['farmList'] = self.service('common').list('farm')
 
 	def menu(self):
 		parent = [['农场与设备管理', '网站管理', '基础设置'],['', '', '']]
 		child = [
 			[['/farm/farm','/device/gateway','/device/info','/work/work','/work/category','/work/land','/origin/batch','/farm/user','/device/printer','/msg/msg'],['农场列表', '网关管理', '设备管理', '农场农事管理', '农场农事方式', '农场地块管理', '溯源批次管理','农场用户管理','农场打印机','消息提醒']]
-			,[['/content/info','/content/article','/content/category', '/content/set', '/sms/sms'],['首页内容管理', '文章管理', '文章分类', '网站基础设置', '短信通知']]
+			,[['/web/set','/web/category','/web/article','/web/menu', 'sms/sms'],['网站资料设置', '文章分类', '发布内容文章', '菜单管理', '短信通知']]
 			,[['/device/type','/hardware/type','/msg/type','/admin/admin','/admin/role','/hardware/hardware', '/admin/log'],['设备类型管理','硬件类型管理', '消息类型设置', '管理员设置', '管理权限设置','硬件设备记录', '系统日志']]
 			]
 		return (parent,child)

+ 0 - 95
admin/page/content.py

@@ -1,95 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-"""
-    demeter web page
-    name:content.py 内容相关页面
-    author:rabin
-"""
-from __load__ import *
-
-class article_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			name = u'文章'
-			,path = '/content/article'
-			,width = '800'
-			,height = '400'
-			,search = (('label-1','cdate-time-start','cdate-time-end','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'文章分类',u'文章标题'))
-			,thead = (u'文章标题', u'文章分类', u'更新时间')
-			,tbody = ('name', 'category', 'cdate')
-			,state = True
-		)
-		self.data['common']['search_category_id-select-'] = self.service('common').list('article_category')
-		self.commonList('article')
-		if self.data['list']:
-			for key, value in enumerate(self.data['list']):
-				category = self.service('common').one('article_category', id=value['category_id'])
-				self.data['list'][key]['category'] = category['name']
-		self.commonView('list')
-
-class article_update_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			path = '/content/article'
-			,label = (u'文章标题',u'文章分类',u'文章内容')
-			,update = ('name-input-required','category_id-select-required',u'content-editor--请输入内容')
-			,update_category_id = self.service('common').list('article_category')
-		)
-		self.commonOne('article')
-		self.commonView('update')
-	@Web.auth
-	def post(self):
-		self.commonUpdate('article')
-	@Web.auth
-	def delete(self):
-		self.commonDelete('article')
-
-
-class category_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			name = u'分类'
-			,path = '/content/category'
-			,width = '600'
-			,height = '200'
-			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'分类名称'))
-			,thead = (u'分类名称', u'更新时间')
-			,tbody = ('name', 'cdate')
-			,state = True
-		)
-		self.commonList('article_category')
-		self.commonView('list')
-
-class category_update_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			path = '/content/category'
-			,label = (u'分类名称',)
-			,update = ('name-input-required',)
-		)
-		self.commonOne('article_category')
-		self.commonView('update')
-	@Web.auth
-	def post(self):
-		self.commonUpdate('article_category')
-	@Web.auth
-	def delete(self):
-		self.commonDelete('article_category')
-
-class info_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			path = '/content/info'
-			,label = (u'首页大标题',u'首页小标题',u'网站头部图片',u'产品功能',u'微信管理',u'客户案例')
-			,update = ('name-input-required','subname-input-required','pic-pic-required',u'product-editor-required-请输入内容',u'weixin-editor-required-请输入内容',u'demo-editor-required-请输入内容')
-		)
-		self.commonOne('content', id=1)
-		self.commonView('set')
-	@Web.auth
-	def post(self):
-		self.commonUpdate('content',id=1)

+ 171 - 200
admin/page/device.py

@@ -7,144 +7,6 @@
 """
 from __load__ import *
 
-class page_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			name = u'页面' #中文名
-			,path = 'page' #路径
-			,width = '600' # 新增页面的宽度
-			,height = '200' # 新增页面的高度
-			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'页面名称')) #搜索
-			,thead = (u'页面名称', '子页面', u'更新时间') #表头
-			,tbody = ('name', 'group', 'cdate') #表内容
-			,state = True #启用回收站
-		)
-		self.commonList('device_page')
-		if self.data['list']:
-			for key, value in enumerate(self.data['list']):
-				self.data['list'][key]['group'] = '<a href="/device/group?search_page_id-select-='+value['id']+'">分组</a>'
-		self.commonView('list')
-
-class page_update_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			path = 'page'
-			,label = (u'标题',)
-			,update = ('name-input-required',)
-		)
-		self.commonOne('device_page')
-		self.commonView('update')
-	@Web.auth
-	def post(self):
-		self.commonUpdate('device_page')
-	@Web.auth
-	def delete(self):
-		self.commonDelete('device_page')
-
-class group_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			name = u'分组'
-			,path = 'group'
-			,width = '600'
-			,height = '250'
-			,full = True
-			,search = (('label-1','cdate-time-start','cdate-time-end','page_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择页面',u'分组名称'))
-			,thead = (u'页面名称', u'分组名称', '设备', u'更新时间')
-			,tbody = ('page', 'name', 'device', 'cdate')
-			,state = True
-		)
-		self.data['common']['search_page_id-select-'] = self.service('common').list('device_page')
-		self.commonList('device_group')
-		if self.data['list']:
-			for key, value in enumerate(self.data['list']):
-				page = self.service('common').one('device_page', id=value['page_id'])
-				self.data['list'][key]['page'] = page['name']
-				if value['devices']:
-					#self.data['list'][key]['device'] = '<a href="/device/info?search_id-input-ins='+value['devices']+'">查看设备</a>'
-					self.data['list'][key]['device'] = '<a>查看设备</a>'
-				else:
-					self.data['list'][key]['device'] = '暂无设备'
-		self.commonView('list')
-
-class group_update_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			path = 'group'
-			,label = (u'所属页面', u'标题', u'选择设备')
-			,update = ('page_id-select-required','name-input-required', 'devices-checkboxs-')
-			,update_page_id = self.service('common').list('device_page')
-			,update_devices = self.getDevice()
-		)
-		self.commonOne('device_group')
-		self.commonView('update')
-	@Web.auth
-	def post(self):
-		self.commonUpdate('device_group')
-	@Web.auth
-	def delete(self):
-		self.commonDelete('device_group')
-
-	def getDevice(self):
-		gateway = self.service('common').list('device_gateway')
-		if gateway:
-			for key, value in enumerate(gateway):
-				gateway[key]['child'] = self.service('common').list('device_info', True, {'gateway_id-input-':value['id']})
-		return gateway
-
-class mul_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			name = u'批量控制'
-			,path = 'mul'
-			,width = '600'
-			,height = '250'
-			,full = True
-			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'分组名称'))
-			,thead = (u'分组名称', '设备', u'更新时间')
-			,tbody = ('name', 'device', 'cdate')
-			,state = True
-		)
-		self.commonList('device_mul')
-		if self.data['list']:
-			for key, value in enumerate(self.data['list']):
-				if value['devices']:
-					#self.data['list'][key]['device'] = '<a href="/device/info?search_id-input-ins='+value['devices']+'">设备</a>'
-					self.data['list'][key]['device'] = '<a>查看设备</a>'
-				else:
-					self.data['list'][key]['device'] = '暂无设备'
-		self.commonView('list')
-
-class mul_update_path(Load):
-	@Web.auth
-	def get(self):
-		self.common(
-			path = 'mul'
-			,label = (u'标题', u'选择设备')
-			,update = ('name-input-required', 'devices-checkboxs-')
-			,update_devices = self.getDevice()
-		)
-		self.commonOne('device_mul')
-		self.commonView('update')
-	@Web.auth
-	def post(self):
-		self.commonUpdate('device_mul')
-	@Web.auth
-	def delete(self):
-		self.commonDelete('device_mul')
-
-	def getDevice(self):
-		gateway = self.service('common').list('device_gateway')
-		if gateway:
-			for key, value in enumerate(gateway):
-				gateway[key]['child'] = self.service('common').list('device_info', True, {'gateway_id-input-':value['id']})
-		return gateway
-
 class gateway_path(Load):
 	@Web.auth
 	def get(self):
@@ -152,7 +14,7 @@ class gateway_path(Load):
 			name = u'网关'
 			,path = 'gateway'
 			,width = '600'
-			,height = '300'
+			,height = '500'
 			#,add = False
 			#,edit = False
 			,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'网关名称'))
@@ -166,26 +28,33 @@ class gateway_path(Load):
 			for key, value in enumerate(self.data['list']):
 				farm = self.service('common').one('farm', id=value['farm_id'])
 				self.data['list'][key]['farm'] = farm['name']
-				if value['status']:
-					self.data['list'][key]['status'] = '开启'
-				else:
-					self.data['list'][key]['status'] = '关闭'
-
-				if value['power_status']:
-					self.data['list'][key]['power_status'] = '连接'
-				else:
-					self.data['list'][key]['power_status'] = '断开'
+				device = self.service('common').list('device_info', search={'hardware_id':value['hardware_id']})
+				self.data['list'][key]['status'] = '断开'
+				self.data['list'][key]['power_status'] = '断开'
+				self.data['list'][key]['power_num'] = 0
+				if device:
+					for v in device:
+						if v['value']:
+							v['value'] = float(v['value'])
+							if v['hardware_type'] == 5 and v['value'] == 1:
+								self.data['list'][key]['status'] = '连接'
+							elif v['hardware_type'] == 4 and v['value']:
+								self.data['list'][key]['power_status'] = '连接'
+								self.data['list'][key]['power_num'] = v['value']
 		self.commonView('list')
 
 class gateway_update_path(Load):
 	@Web.auth
 	def get(self):
+		id = self.input('id')
+		if id:
+			hardware_id = 'hardware_id-show-required'
+		else:
+			hardware_id = 'hardware_id-input-required'
 		self.common(
 			path = 'gateway'
-			#,label = (u'网关名称', u'设备id',u'网关连接状态',u'电源数值',u'电源连接状态')
-			,label = (u'所属农场', u'网关名称', u'设备id')
-			,update = ('farm_id-select-required', 'name-input-required','hardware_id-input-required')
-			#,update = ('name-input-required','hardware_id-input-required','status-switch--开启|关闭','power_num-input-','power_status-switch--连接|断开')
+			,label = (u'所属农场', u'网关名称', u'设备id', u'设备分布图纸')
+			,update = ('farm_id-select-required', 'name-input-required',hardware_id, 'pic-pic-')
 			,update_farm_id = Demeter.config['setting']['farmList']
 		)
 		self.commonOne('device_gateway')
@@ -193,26 +62,18 @@ class gateway_update_path(Load):
 	@Web.auth
 	def post(self):
 		id = self.commonUpdate('device_gateway')
-		self.hardware(id)
+		self.device(id)
 
 	@Web.auth
 	def delete(self):
 		self.commonDelete('device_gateway')
 
 	@Web.auth
-	def hardware(self, id):
-		hardware_id = self.data['update']['hardware_id']
-		if hardware_id and id > 0:
-			info = self.service('common').one('hardware', hardware_id=hardware_id)
-			if not info:
-				insert = {}
-				insert['farm_id'] = self.data['update']['farm_id']
-				insert['hardware_id'] = hardware_id
-				insert['gateway_id'] = id
-				insert['hardware_type'] = 1
-				self.service('common').update('hardware', None, insert)
-				
-
+	def device(self, id):
+		info = self.service('common').one('device_gateway', id=id)
+		hardware_id = info['hardware_id']
+		self.service('device').upGatewayStatus(self.data['update']['farm_id'], id, hardware_id)
+		
 class info_path(Load):
 	@Web.auth
 	def get(self):
@@ -220,43 +81,69 @@ class info_path(Load):
 			name = u'设备'
 			,path = 'info'
 			,width = '600'
-			,height = '300'
+			,height = '400'
+			#,button = ({'name':'添加摄像机','link':'/device/camera_update'},{'name':'添加摄像头','link':'/device/camera_pic_update'})
+			,button = ({'name':'添加摄像头','link':'/device/camera_pic_update'},)
 			,add = False
 			#,edit = False
-			,search = (('farm_id-select-','type_id-select-', 'gateway_id-select-', 'hardware_type-select-'), (u'选择农场',u'设备类型',u'网关',u'硬件类型'))
-			,thead = (u'所属农场', u'设备名称', u'设备id', u'连接状态', u'值', u'设备类型', u'网关',u'硬件类型')
-			,tbody = ('farm','name', 'hardware_id', 'status', 'show', 'type', 'gateway', 'hardware_type')
+			,search = (('farm_id-select--gateway_id', 'hardware_type-select-','type_id-select-', 'status-hidden-'), (u'选择农场',u'硬件类型',u'设备类型', '设备状态'))
+			,thead = (u'所属农场', u'设备名称', u'设备id', u'当前值', u'设备类型', u'网关',u'硬件类型')
+			,tbody = ('farm','name', 'hardware_id', 'value', 'type', 'gateway', 'hardware_type')
 			,state = False
 		)
-		self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
+		self.data['common']['search_farm_id-select--gateway_id'] = Demeter.config['setting']['farmList']
 		self.data['common']['search_type_id-select-'] = self.service('common').list('device_type')
-		self.data['common']['search_gateway_id-select-'] = self.service('common').list('device_gateway')
+		self.data['common']['search_gateway_id-select---farm_id'] = self.service('common').list('device_gateway')
 		self.data['common']['search_hardware_type-select-'] = self.service('common').list('hardware_type')
-		del self.data['common']['search_hardware_type-select-'][0]
-		self.commonList('device_info')
+		"""
+		if self.data['common']['search_hardware_type-select-']:
+			del self.data['common']['search_hardware_type-select-'][0]
+		"""
+		status = self.input('search_status-hidden-', False)
+		if status:
+			self.data['search']['status-hidden-'] = False
+
+		self.commonList('device_info', order='id desc')
 		if self.data['list']:
 			for key, value in enumerate(self.data['list']):
 				farm = self.service('common').one('farm', id=value['farm_id'])
 				self.data['list'][key]['farm'] = farm['name']
 				self.data['list'][key]['type'] = '无'
-				if value['type_id']:
-					info = self.service('common').one('device_type', id=value['type_id'])
-					if info:
-						self.data['list'][key]['type'] = info['name']
+				if value['type_id'] > 0:
+					type_info = self.service('common').one('device_type', id=value['type_id'])
+					if type_info:
+						self.data['list'][key]['type'] = type_info['name']
 				info = self.service('common').one('device_gateway', id=value['gateway_id'])
 				self.data['list'][key]['gateway'] = info['name']
 				if value['status']:
-					self.data['list'][key]['status'] = '连接'
+					self.data['list'][key]['status'] = '连接'
 				else:
-					self.data['list'][key]['status'] = '断开'
-				if value['num'] and value['show']:
-					value['show'] = str(value['show'])
-					# 根据设备类型type_id得到单位和计算公式
-					self.data['list'][key]['show'] = '<a href="/device/stat?id='+value['id']+'&search_date-select-=1&method=list">'+value['show'] + '</a><br />更新时间:' + Demeter.date(value['cdate']) + '<br /><a href="/device/stat?id='+value['id']+'&search_date-select-=1&method=avg">[平均值统计]</a> <a href="/device/stat?id='+value['id']+'&search_date-select-=1&method=maxmin">[高低值统计]</a>'
-				elif value['show']:
-					self.data['list'][key]['show'] = '<a href="/device/pic?id='+value['id']+'"><img src="'+value['show']+'" width="200px"/></a><br />更新时间:' + Demeter.date(value['cdate'])
-				else:
-					self.data['list'][key]['show'] = ''
+					self.data['list'][key]['status'] = '已断开'
+
+				if not value['value']:
+					value['value'] = ''
+				if value['hardware_type'] == 2 or value['hardware_type'] == 4:
+					if value['type_id'] > 0 and type_info:
+						value['value'] = value['value'] + ' ' + type_info['unit']
+					self.data['list'][key]['value'] = '<a href="/device/stat?id='+value['id']+'&search_date-select-=1&method=list">'+value['value'] + '</a><br />更新时间:' + Demeter.date(value['cdate']) + '<br /><a href="/device/stat?id='+value['id']+'&search_date-select-=1&method=avg">[平均值统计]</a> <a href="/device/stat?id='+value['id']+'&search_date-select-=1&method=maxmin">[高低值统计]</a>'
+				elif value['hardware_type'] == 6:
+					self.data['list'][key]['value'] = '<a href="/device/pic?id='+value['id']+'"><img src="'+value['value']+'" width="200px"/></a><br />更新时间:' + Demeter.date(value['cdate'])
+				elif value['hardware_type'] == 3:
+					if value['status']:
+						status = ''
+					else:
+						status = 'disabled'
+					url = '/device/info'
+					if value['value'] == '1':
+						#disabled
+						self.data['list'][key]['value'] = '<input type="checkbox" name="switch" lay-filter="switch" lay-skin="switch" checked '+status+' value="1" data-value="0" data-id="'+value['id']+'" data-url="'+url+'">'
+					else:
+						self.data['list'][key]['value'] = '<input type="checkbox" lay-filter="switch" name="switch" lay-skin="switch" '+status+' value="0" data-value="1" data-id="'+value['id']+'" data-url="'+url+'">'
+				elif value['hardware_type'] == 5:
+					if value['value'] == '1':
+						self.data['list'][key]['value'] = '已连接'
+					else:
+						self.data['list'][key]['value'] = '已断开'
 
 				hardware_type = self.service('common').one('hardware_type', id=value['hardware_type'])
 				self.data['list'][key]['hardware_type'] = hardware_type['name']
@@ -264,21 +151,105 @@ class info_path(Load):
 
 		self.commonView('list')
 
+	@Web.auth
+	def post(self):
+		id = self.input('id')
+		value = self.input('value')
+		if id:
+			Demeter.service('device').switch(id, value)
+			self.out('yes', {'state':id})
+		else:
+			self.out('no')
+
 class info_update_path(Load):
+	@Web.auth
+	def get(self):
+		self.commonOne('device_info')
+		if self.data['info']['hardware_type'] == 7:
+			self.common(
+				path = 'camera'
+				#,label = (u'摄像机名称', u'摄像机id', u'所属农场', u'选择网关', u'选择硬件类型', u'摄像机地址')
+				#,update = ('name-input-required','hardware_id-show-','farm_id-select-required','gateway_id-select-required','hardware_type-select-required','value-text-required')
+				,label = (u'摄像机名称', u'摄像机id', u'所属农场', u'选择网关', u'摄像机地址')
+				,update = ('name-input-required','hardware_id-show-','farm_id-select-required-gateway_id','gateway_id-select-required--farm_id','value-text-required')
+				,update_farm_id = Demeter.config['setting']['farmList']
+				,update_gateway_id = self.service('common').list('device_gateway')
+				#,update_hardware_type = self.service('common').list('hardware_type')
+			)
+		elif self.data['info']['hardware_type'] == 6:
+			self.common(
+				path = 'camera_pic'
+				,label = (u'摄像头名称', u'摄像头id', u'所属农场', u'选择网关', u'摄像头地址')
+				,update = ('name-input-required','hardware_id-show-','farm_id-select-required-gateway_id','gateway_id-select-required--farm_id','value-text-required')
+				,update_farm_id = Demeter.config['setting']['farmList']
+				,update_gateway_id = self.service('common').list('device_gateway')
+			)
+		else:
+			self.common(
+				path = 'info'
+				,label = (u'设备名称', u'设备id')
+				,update = ('name-input-required','hardware_id-show-')
+			)
+		self.commonView('update')
+	@Web.auth
+	def post(self):
+		self.commonUpdate('device_info')
+	@Web.auth
+	def delete(self):
+		self.commonOne('device_info')
+		if self.input('state') == 'True' or (self.data['info'] and 'hardware_type' in self.data['info'] and self.data['info']['hardware_type'] == 7):
+			self.commonDelete('device_info')
+		else:
+			#除摄像机之外,其余设备不允许删除
+			self.out('no')
+
+class camera_path(Load):
+	@Web.auth
+	def get(self):
+		self.redirect('/device/info?search_hardware_type=7')
+
+class camera_update_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			path = 'camera'
+			,label = (u'摄像机名称', u'摄像机id', u'所属农场', u'选择网关', u'摄像机地址')
+			,update = ('name-input-required','hardware_id-input-required','farm_id-select-required-gateway_id','gateway_id-select-required--farm_id','value-text-required')
+			,update_farm_id = Demeter.config['setting']['farmList']
+			,update_gateway_id = self.service('common').list('device_gateway')
+		)
+		self.commonOne('device_info')
+		self.commonView('update')
+	@Web.auth
+	def post(self):
+		self.data['update']['hardware_type'] = 7
+		self.data['update']['type_id'] = 0
+		self.commonUpdate('device_info')
+	@Web.auth
+	def delete(self):
+		self.commonDelete('device_info')
+
+class camera_pic_path(Load):
+	@Web.auth
+	def get(self):
+		self.redirect('/device/info?search_hardware_type=6')
+
+class camera_pic_update_path(Load):
 	@Web.auth
 	def get(self):
 		self.common(
-			path = 'info'
-			#,label = (u'网关名称', u'设备id',u'网关连接状态',u'电源数值',u'电源连接状态')
-			,label = (u'设备名称', u'设备id')
-			,update = ('name-input-required','hardware_id-show-')
-			#,update = ('name-input-required','hardware_id-input-required','status-switch--开启|关闭','power_num-input-','power_status-switch--连接|断开')
+			path = 'camera_pic'
+			,label = (u'摄像头名称', u'摄像头id', u'所属农场', u'选择网关', u'摄像头地址')
+			,update = ('name-input-required','hardware_id-input-required','farm_id-select-required-gateway_id','gateway_id-select-required--farm_id','value-text-required')
 			,update_farm_id = Demeter.config['setting']['farmList']
+			,update_gateway_id = self.service('common').list('device_gateway')
 		)
 		self.commonOne('device_info')
 		self.commonView('update')
 	@Web.auth
 	def post(self):
+		self.data['update']['hardware_type'] = 6
+		self.data['update']['type_id'] = 0
 		self.commonUpdate('device_info')
 	@Web.auth
 	def delete(self):
@@ -292,15 +263,15 @@ class pic_path(Load):
 			,path = 'pic'
 			,width = '600'
 			,height = '300'
-			#,add = False
-			#,edit = False
-			,search = (('label-1','cdate-time-start','cdate-time-end'), (u'日期范围',u'开始时间',u'截止时间'))
+			,add = False
+			,edit = False
+			,search = (('label-1','sdate-time-start','sdate-time-end'), (u'日期范围',u'开始时间',u'截止时间'))
 			,thead = (u'图片地址', u'更新时间')
-			,tbody = ('pic', 'cdate')
+			,tbody = ('pic', 'sdate')
 			,state = False
 		)
 
-		self.commonList('device_pic')
+		self.commonList('device_pic', order='sdate desc')
 		if self.data['list']:
 			for key, value in enumerate(self.data['list']):
 				self.data['list'][key]['pic'] = '<img src="'+value['pic']+'" width="200px" />'
@@ -347,8 +318,8 @@ class type_path(Load):
 			,width = '600'
 			,height = '400'
 			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'类型名称'))
-			,thead = (u'类型名称', u'类型标识', u'类型单位', u'表达式', u'更新时间')
-			,tbody = ('name', 'key', 'unit', 'exp', 'cdate')
+			,thead = (u'类型ID', u'类型名称', u'类型标识', u'类型单位', u'更新时间')
+			,tbody = ('id', 'name', 'key', 'unit', 'cdate')
 			,state = True
 		)
 		self.commonList('device_type')

+ 18 - 1
admin/page/farm.py

@@ -21,7 +21,8 @@ class farm_path(Load):
 			,state = False #启用回收站
 		)
 		menu = (
-			{'name':'网关管理', 'url':'/device/gateway'}
+			{'name':'基础资料', 'url':'/farm/info'}
+			,{'name':'网关管理', 'url':'/device/gateway'}
 			,{'name':'设备管理', 'url':'/device/info'}
 			,{'name':'农事管理', 'url':'/work/work'}
 			,{'name':'农事分类', 'url':'/work/category'}
@@ -56,6 +57,22 @@ class farm_update_path(Load):
 		id = self.commonUpdate('farm')
 		Demeter.config['setting']['farmList'] = self.service('common').list('farm')
 
+class info_path(Load):
+	@Web.auth
+	def get(self):
+		id = str(Demeter.config['setting']['farm'])
+		param = '?farm=' + id + '&search_farm_id-select-=' + id
+		self.common(
+			path = '/farm/info' + param
+			,label = (u'农场名称',u'农场图片',u'联系电话',u'农场地址',u'联系人',u'农场介绍')
+			,update = ('name-input-required','pic-pic-required-1000px*300~450px','tel-input-required','address-input-required','master_name-input-required',u'info-text-required-请输入农场介绍')
+		)
+		self.commonOne('farm', id=Demeter.config['setting']['farm'])
+		self.commonView('set')
+	@Web.auth
+	def post(self):
+		self.commonUpdate('farm', id=Demeter.config['setting']['farm'])
+
 class user_path(Load):
 	@Web.auth
 	def get(self):

+ 200 - 0
admin/page/web.py

@@ -0,0 +1,200 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+    demeter web page
+    name:content.py 内容相关页面
+    author:rabin
+"""
+from __load__ import *
+
+class set_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			path = '/web/set'
+			,label = (u'标题',u'子标题',u'关键词',u'描述',u'icp备案号',u'联系电话',u'微信管理')
+			,update = ('name-input-required','subname-input-required','keywords-input-required','description-input-required','icp-input-required','tel-input-required',u'mobile-pic--')
+		)
+		self.commonOne('web_set', id=1)
+		self.commonView('set')
+	@Web.auth
+	def post(self):
+		self.commonUpdate('web_set',id=1)
+
+class article_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			name = u'文章'
+			,path = '/web/article'
+			,width = '800'
+			,height = '700'
+			,search = (('label-1','cdate-time-start','cdate-time-end','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'文章分类',u'文章标题'))
+			,thead = (u'文章标题', u'文章分类', u'更新时间')
+			,tbody = ('name', 'category', 'cdate')
+			,state = True
+		)
+		self.data['common']['search_category_id-select-'] = self.service('common').list('web_article_category')
+		self.commonList('web_article')
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				category = self.service('common').one('web_article_category', id=value['category_id'])
+				self.data['list'][key]['category'] = category['name']
+		self.commonView('list')
+
+class article_update_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			path = '/web/article'
+			,label = (u'文章标题',u'文章分类',u'文章链接',u'文章图片',u'文章内容')
+			,update = ('name-input-required','category_id-select-required','link-input-','pic-pic-',u'content-editor--请输入内容')
+			,update_category_id = self.service('common').list('web_article_category')
+		)
+		self.commonOne('web_article')
+		self.commonView('update')
+	@Web.auth
+	def post(self):
+		self.commonUpdate('web_article')
+	@Web.auth
+	def delete(self):
+		self.commonDelete('web_article')
+
+
+class category_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			name = u'分类'
+			,path = '/web/category'
+			,width = '600'
+			,height = '300'
+			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'分类名称'))
+			,thead = (u'分类名称', u'更新时间')
+			,tbody = ('name', 'cdate')
+			,state = True
+		)
+		self.commonList('web_article_category')
+		self.commonView('list')
+
+class category_update_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			path = '/web/category'
+			,label = (u'分类名称',)
+			,update = ('name-input-required',)
+		)
+		self.commonOne('web_article_category')
+		self.commonView('update')
+	@Web.auth
+	def post(self):
+		self.commonUpdate('web_article_category')
+	@Web.auth
+	def delete(self):
+		self.commonDelete('web_article_category')
+
+class help_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			name = u'帮助'
+			,path = '/web/help'
+			,width = '800'
+			,height = '600'
+			,search = (('label-1','cdate-time-start','cdate-time-end','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'帮助分类',u'帮助标题'))
+			,thead = (u'帮助标题', u'帮助分类', u'更新时间')
+			,tbody = ('name', 'category', 'cdate')
+			,state = True
+		)
+		self.data['common']['search_category_id-select-'] = self.service('common').list('web_help_category')
+		self.commonList('web_help')
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				category = self.service('common').one('web_help_category', id=value['category_id'])
+				self.data['list'][key]['category'] = category['name']
+		self.commonView('list')
+
+class help_update_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			path = '/web/help'
+			,label = (u'帮助标题',u'帮助分类',u'帮助内容')
+			,update = ('name-input-required','category_id-select-required',u'content-editor--请输入内容')
+			,update_category_id = self.service('common').list('web_help_category')
+		)
+		self.commonOne('web_help')
+		self.commonView('update')
+	@Web.auth
+	def post(self):
+		self.commonUpdate('web_help')
+	@Web.auth
+	def delete(self):
+		self.commonDelete('web_help')
+
+class help_category_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			name = u'分类'
+			,path = '/web/help_category'
+			,width = '600'
+			,height = '300'
+			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'分类名称'))
+			,thead = (u'帮助分类名称', u'更新时间')
+			,tbody = ('name', 'cdate')
+			,state = True
+		)
+		self.commonList('web_help_category')
+		self.commonView('list')
+
+class help_category_update_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			path = '/web/help_category'
+			,label = (u'帮助分类名称',)
+			,update = ('name-input-required',)
+		)
+		self.commonOne('web_help_category')
+		self.commonView('update')
+	@Web.auth
+	def post(self):
+		self.commonUpdate('web_help_category')
+	@Web.auth
+	def delete(self):
+		self.commonDelete('web_help_category')
+
+class menu_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			name = u'菜单'
+			,path = '/web/menu'
+			,width = '600'
+			,height = '300'
+			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'菜单名称'))
+			,thead = (u'菜单名称',u'菜单链接', u'更新时间')
+			,tbody = ('name', 'link', 'cdate')
+			,state = True
+		)
+		self.commonList('web_menu')
+		self.commonView('list')
+
+class menu_update_path(Load):
+	@Web.auth
+	def get(self):
+		self.common(
+			path = '/web/menu'
+			,label = (u'菜单名称',u'菜单链接')
+			,update = ('name-input-required','link-input-required')
+		)
+		self.commonOne('web_menu')
+		self.commonView('update')
+	@Web.auth
+	def post(self):
+		self.commonUpdate('web_menu')
+	@Web.auth
+	def delete(self):
+		self.commonDelete('web_menu')

+ 5 - 2
admin/static/js/main.js

@@ -29,8 +29,11 @@ function msg(value) {
 	
 	return;
 }
-function selectShow(e, id) {
-	id = '#update_' + id
+function selectShow(e, id, prefix) {
+	if (!prefix) {
+		prefix = 'update';
+	}
+ 	id = '#'+prefix+'_' + id
 	if ($(id).length) {
 		$(id).find('option').each(function()
 		{

+ 13 - 2
admin/templates/common/list.html

@@ -4,12 +4,17 @@
   {% for index,key in enumerate(data['common']['search'][0]) %}
     {%set value = data['common']['search'][1][index] %}
     {%set param = key.split('-') %}
+    {%set length = len(param) %}
     {% if 'label' in key %}
     <label class="layui-form-label">{{value}}</label>
     {% elif param[1] == 'input' %}
     <div class="layui-input-inline"  style="width:auto" >
       <input type="text" name="search_{{key}}"id="search_{{key}}" placeholder="{{value}}" autocomplete="off" class="layui-input" value="{% if data['search'] and key in data['search'] %}{{data['search'][key]}}{% end %}">
     </div>
+    {% elif param[1] == 'hidden' %}
+    <div class="layui-input-inline"  style="width:auto" >
+      <input type="hidden" name="search_{{key}}"id="search_{{key}}" placeholder="{{value}}" autocomplete="off" class="layui-input" value="{% if data['search'] and key in data['search'] %}{{data['search'][key]}}{% end %}">
+    </div>
     {% elif param[1] == 'time' %}
     <div class="layui-input-inline"  style="width:auto">
       <input type="text" name="search_{{key}}" id="search_{{key}}" placeholder="{{value}}" autocomplete="off" class="layui-input time" value="{% if data['search'] and key in data['search'] %}{{data['search'][key]}}{% end %}">
@@ -20,10 +25,10 @@
         {%set option = 'search_' + key %}
         {% if option in data['common'] %}
         {%set select = data['common'][option] %}
-        <select name="search_{{key}}" id="search_{{key}}" lay-verify="" lay-search>
+        <select class="layui-select selectLoad" name="search_{{key}}" id="search_{{key}}" lay-verify="" lay-search="" {% if length > 3 and param[3]%} change="{{param[3]}}" lay-filter="yes"{% end %}>
               <option value="">请选择一项</option>
           {% for v in select %}
-              <option value="{{v['id']}}" {% if data['search'] and key in data['search'] and data['search'][key] == str(v['id']) %}selected{% end %}>{{v['name']}}</option>
+              <option value="{{v['id']}}" {% if length > 4 and param[4] %}parent="{% if param[4] in v %}{{v[param[4]]}}{% end %}"{% end %} {% if data['search'] and key in data['search'] and data['search'][key] == str(v['id']) %}selected{% end %}>{{v['name']}}</option>
               {% end %}
         </select>
         {% end %}
@@ -42,6 +47,12 @@
     {% if data['common']['state'] == True %}
     <button class="layui-btn layui-btn-danger" onclick="showPage('{{data['common']['path']}}?state=False{{data['common']['argvs']}}')"><i class="layui-icon"></i>回收站</button>
     {% end %}
+
+    {% if 'button' in data['common'] %}
+    {% for value in data['common']['button'] %}
+    <button class="layui-btn" onclick="show('{{value['name']}}','{{value['link']}}','{{data['common']['width']}}','{{data['common']['height']}}'{% if 'full' in data['common'] %},'{{data['common']['full']}}'{% end %})"><i class="layui-icon">&#xe608;</i>{{value['name']}}</button>
+    {% end %}
+    {% end %}
   {% else %}
     <button class="layui-btn" onclick="showPage('{{data['common']['path']}}?{{data['common']['argvs']}}')"><i class="layui-icon"></i>返回</button>
   {% end %}

+ 2 - 1
admin/templates/common/set.html

@@ -7,6 +7,7 @@
 {% for index,name in enumerate(data['common']['label']) %}
   {%set value = data['common']['update'][index] %}
   {%set value = value.split('-') %}
+  {%set length = len(value) %}
   <div class="layui-form-item {% if value[1] in ('text',)  %}layui-form-text{% end %}">
       <label for="{{value[0]}}" class="layui-form-label">
         {% if value[2] or (value[1] == 'password'  and not data['info']) %}<span class="x-red">*</span>{% end %}
@@ -29,7 +30,7 @@
       {% elif value[1] == 'pic' %}
           <div class="site-demo-upbar">
             <img id="upload_{{value[0]}}_show" width="200" src="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}" style="{% if  data['info'] and value[0] in data['info'] and data['info'][value[0]] %}display:;{% else %}display:none;{% end %}margin-left:10px;"/>
-            <input type="file" class="layui-upload-file" lay-type="images" name="file" id="upload_{{value[0]}}"/>
+            <input type="file" class="layui-upload-file" lay-type="images" name="file" id="upload_{{value[0]}}"/>{% if length > 3 %}(建议图片尺寸:{{value[3]}}){% end %}
             <input type="hidden" id="update_{{value[0]}}" name="update_{{value[0]}}" lay-verify="{{value[2]}}" value="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}"/>
           </div>
       {% elif value[1] == 'select' %}

+ 3 - 3
admin/templates/common/update.html

@@ -32,7 +32,7 @@
           <textarea {% if length > 3 %}placeholder="{{value[3]}}"{% end %} class="layui-form layui-textarea layui-editor" id="update_{{value[0]}}" name="update_{{value[0]}}" value="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}" lay-verify="{{value[2]}}">{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}</textarea>
       {% elif value[1] == 'pic' %}
           <div class="site-demo-upbar">
-            <img id="upload_{{value[0]}}_show" width="200" src="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}" style="{% if  data['info'] and value[0] in data['info'] and data['info'][value[0]] %}display:;{% else %}display:none;{% end %}margin-left:10px;"/>
+            <img id="upload_{{value[0]}}_show" width="200" src="{% if data['info'] and value[0] in data['info'] and data['info'][value[0]] %}{{data['info'][value[0]]}}{% end %}" style="{% if  data['info'] and value[0] in data['info'] and data['info'][value[0]] %}display:;{% else %}display:none;{% end %}margin-left:10px;"/>
             <input type="file" class="layui-upload-file" lay-type="images" name="file" id="upload_{{value[0]}}"/>
             <input class="layui-input" type="hidden" id="update_{{value[0]}}" name="update_{{value[0]}}" lay-verify="{{value[2]}}" value="{% if data['info'] and value[0] in data['info'] %}{{data['info'][value[0]]}}{% end %}"/>
           </div>
@@ -102,10 +102,10 @@
         {%set option = 'update_' + value[0] %}
         {% if option in data['common'] %}
         {%set select = data['common'][option] %}
-          <select class="layui-select selectLoad" name="update_{{value[0]}}" id="update_{{value[0]}}" lay-verify="{{value[2]}}" lay-search="" {% if length > 3 %} change="{{value[3]}}" lay-filter="yes"{% end %}>
+          <select class="layui-select selectLoad" name="update_{{value[0]}}" id="update_{{value[0]}}" lay-verify="{{value[2]}}" lay-search="" {% if length > 3 and value[3] %} change="{{value[3]}}" lay-filter="yes"{% end %}>
                 <option value="">请选择</option>
             {% for v in select %}
-                <option value="{{v['id']}}" {% if length > 3 %}parent="{% if value[3] in v %}{{v[value[3]]}}{% end %}"{% end %} name="{{v['name']}}" {% if data['info'] and value[0] in data['info'] and int(data['info'][value[0]]) == v['id'] %}selected{% end %}>{{v['name']}}</option>
+                <option value="{{v['id']}}" {% if length > 4 and value[4] %}parent="{% if value[4] in v %}{{v[value[4]]}}{% end %}"{% end %} name="{{v['name']}}" {% if data['info'] and value[0] in data['info'] and data['info'][value[0]] == v['id'] %}selected{% end %}>{{v['name']}}</option>
                 {% end %}
             </select>
             {% end %}

+ 1 - 1
admin/templates/inc/footer.html

@@ -1,4 +1,4 @@
-<div class="layui-footer footer footer-demo">
+<div class="layui-footer footer footer-demo" style="display:none;">
 	<div class="layui-main">
 	    <p>
 	        <a href="{{data['setting']['site']}}" target="_blank">

+ 1 - 1
admin/templates/inc/top.html

@@ -20,7 +20,7 @@
 	          <dd><a href="/user/loginout">退出</a></dd>
 	        </dl>
 	      </li>
-	      <li class="layui-nav-item x-index"><a href="/">前台首页</a></li>
+	      <li class="layui-nav-item x-index"><a href="{{data['setting']['web']}}" target="_blank">前台首页</a></li>
 	    </ul>
 	</div>
 </div>

+ 51 - 7
admin/templates/theme/list.html

@@ -46,8 +46,10 @@
                     </div>
                   </div>
                 </div> 
-            
+            </form>
             <xblock>{% block button %}<button class="layui-btn" onclick="show('添加问题','question-add.html','600','500')"><i class="layui-icon">&#xe608;</i>添加</button><button class="layui-btn layui-btn-danger" onclick="showDel('')"><i class="layui-icon"></i>回收站</button>{% end %}<span class="x-right" style="line-height:40px">{% block total %}共有数据:{{data['page']['totalNum']}} 条 [每页数据:{{data['page']['num']}} 条{% end %}]</span></xblock>
+
+            <form class="layui-form">
             <table class="layui-table">
                 <thead>
                     <tr>
@@ -118,7 +120,9 @@
                         </td>
                     </tr>
                     {% end %}
+                    <script>var current = {{data['page']['current']}}</script>
                     {% if data['page']['ajax'] == False %}
+                
                 </tbody>
             </table>
             </form>
@@ -130,9 +134,10 @@
 <script>
 layui.use(['laydate','element','laypage','layer', 'form'], function(){
 $ = layui.jquery;//jquery
-lement = layui.element();//面包导航
-laypage = layui.laypage;//分页
-layer = layui.layer;//弹出层
+var lement = layui.element();//面包导航
+var laypage = layui.laypage;//分页
+var layer = layui.layer;//弹出层
+var form = layui.form();
 layer.ready(function(){ //为了layer.ext.js加载完毕再执行
   layer.photos({
     photos: '#tbody'
@@ -145,6 +150,44 @@ if ($('.load').length) {
         load($(this))
     })
 }
+
+if ($(".selectLoad").length) {
+    $(".selectLoad").each(function()
+    {
+        if ($(this).attr('lay-filter')) {
+            var e = $(this);
+            selectShow(e, e.attr('change'),'search');
+            form.render();
+        }
+    })
+}
+
+form.on('select(yes)', function(data){
+  var e = $(data.elem);
+  selectShow(e, e.attr('change'), 'search');
+  form.render();
+}); 
+
+form.on('switch(switch)', function(data){
+  //console.log(data.elem); //得到checkbox原始DOM对象
+  //console.log(data.elem.checked); //开关是否开启,true或者false
+  //console.log(data.value); //开关value值,也可以通过data.elem.value得到
+  //console.log(data.othis); //得到美化后的DOM对象
+  var e = $(data.elem)
+  var id = e.attr('data-id')
+  var value = e.attr('data-value')
+  var send = {
+    id : id
+    ,value:value
+  }
+  var url = e.attr('data-url')
+  var index = layer.msg('loading...', {icon: 4});
+  request('post', url, send, function(msg)
+  {
+    layer.close(index);
+  })
+});
+
 if ($('.time').length) {
     laydate = layui.laydate;//日期插件
     var start = {
@@ -187,7 +230,7 @@ if ($('.time').length) {
 laypage({
   cont: 'page'
   ,pages: {{data['page']['total']}}
-  ,curr: {{data['page']['current']}}
+  ,curr: current
   ,first: 1
   ,last: {{data['page']['total']}}
   ,prev: '<em><</em>'
@@ -223,13 +266,14 @@ laypage({
     url = url + link;
     url = url.replace('&&', '&')
     
-    if (curr) {
+    if (curr != current) {
       url = url + 'page=' + curr
       var index = layer.msg('loading...', {icon: 4});
       request('get', url, {}, function(msg)
       {
         layer.close(index);
-        $('#tbody').html(msg)
+        $('#tbody').html(msg);
+        form.render();
       })
     }
   }

+ 12 - 3
conf/dev.conf

@@ -31,7 +31,7 @@ host				= 0.0.0.0
 port				= 5432
 username			= postgres
 password			= 123456
-dbname				= nongxiaohe
+dbname				= nongxiaohev1
 prefix				= demeter
 ;允许自动建表
 create				= True
@@ -41,7 +41,7 @@ host				= 0.0.0.0
 port				= 8086
 username			= root
 password			= root
-dbname				= nongxiaohe
+dbname				= nongxiaohev1
 prefix				= demeter
 
 ;后台配置
@@ -62,4 +62,13 @@ debug				= True
 ;请求的buffersize
 max_buffer_size		= 210763776
 ;子进程
-process				= 0
+process				= 0
+url					= http://192.168.15.10:8088/device
+
+;网站前台配置
+[web]
+port				= 8089
+debug				= True
+max_buffer_size		= 210763776
+process				= 0
+url					= http://192.168.15.10:8089/

+ 1 - 1
front/api/device.py

@@ -68,7 +68,7 @@ class index_path(Load):
 						self.data['device'][key]['max'] = 0
 						self.data['device'][key]['min'] = 0
 
-			self.data['pic'] = self.service('common').list('device_info', state=True, search={'hardware_type':5, 'gateway_id':id})
+			self.data['pic'] = self.service('common').list('device_info', state=True, search={'hardware_type':6, 'gateway_id':id})
 			if self.data['pic']:
 				for key, value in enumerate(self.data['pic']):
 					self.data['pic'][key]['cdates'] = Demeter.date(value['cdate'])

+ 2 - 2
front/api/main.py

@@ -32,11 +32,11 @@ class index_path(Load):
 	@auth
 	def get(self):
 		# 获取网关
-		self.data['gateway'] = self.service('common').list('device_gateway', state=True)
+		self.data['gateway'] = self.service('common').list('device_gateway', search={'farm_id': Demeter.config['setting']['farm']})
 
 		# 获取农场信息
 		self.data['farm'] = self.service('common').one('farm', id=Demeter.config['setting']['farm'])
 
 		# 获取消息数量
-		self.data['msg'] = len(self.service('common').list('msg', state=True))
+		self.data['msg'] = len(self.service('common').list('msg', search={'farm_id': Demeter.config['setting']['farm']})
 		self.out('yes', self.data)

+ 5 - 9
install.py

@@ -37,7 +37,7 @@ def web():
 		model.insert()
 
 	model = Demeter.model('web_article_category')
-	data = ('站点介绍', '焦点图', '系统优势')
+	data = ('站点介绍','日志','首页焦点图', '产品功能', '客户案例')
 	for value in data:
 		model.name = value
 		info = model.select(type='fetchone')
@@ -46,22 +46,20 @@ def web():
 			model.insert()
 
 	model = Demeter.model('web_article')
-	data = ('合作伙伴', '免责声明', '联系我们', '帮助文档', '团队介绍')
+	data = ('联系我们',)
 	for value in data:
 		model.name = value
 		info = model.select(type='fetchone')
 		if not info:
 			model.category_id = 1
 			model.name = value
-			if model.name == '帮助文档':
-				model.link = '/help'
 			model.insert()
 
 	model = Demeter.model('web_menu')
 	data = (
-		{'name':'新农宝盒首页','link':'/main'}
-		,{'name':'灌溉商城','link':'http://www.guangaishangcheng.com/'}
-		,{'name':'帮助中心','link':'/help'}
+		{'name':'首页','link':'/main'}
+		,{'name':'农小盒日志','link':'/article'}
+		,{'name':'联系我们','link':'/article/view?id=1'}
 		)
 	for value in data:
 		model.link = value['link']
@@ -104,8 +102,6 @@ def device():
 		,{'name':'风向', 'key':'direction','unit':''}
 		,{'name':'PM2.5', 'key':'pm2.5','unit':'μg/m3'}
 		,{'name':'电源', 'key':'power','unit':'V'}
-		,{'name':'阀门', 'key':'valve','unit':''}
-		,{'name':'放风机', 'key':'blower','unit':''}
 		)
 	model = Demeter.model('device_type')
 	for value in device_type:

+ 2 - 2
pub.py

@@ -31,8 +31,8 @@ def push():
 		,{'hard':'sensor','type':'humidity','device':100010,'value':(30, 80)}
 		,{'hard':'sensor','type':'light','device':100020,'value':(3000, 13000)}
 		,{'hard':'power','type':'power','device':100090,'value':(1, 50)}
-		,{'hard':'control','type':'valve','device':100100}
-		,{'hard':'control','type':'blower','device':100110}
+		#,{'hard':'control','type':'valve','device':100100}
+		#,{'hard':'control','type':'blower','device':100110}
 		,{'hard':'power','type':'power','device':10086,'value':(1, 50)}
 		)
 	pub = Pub()