farm.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web page
  5. name:farm.py 农场相关页面
  6. author:rabin
  7. """
  8. from __load__ import *
  9. class farm_path(Load):
  10. @Web.auth
  11. @Web.setting
  12. def get(self):
  13. self.common(
  14. name = u'农场' #中文名
  15. ,path = '/farm/farm' #路径
  16. ,width = '600' # 新增页面的宽度
  17. ,height = '600' # 新增页面的高度
  18. ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'农场名称')) #搜索
  19. ,thead = (u'农场名称', u'功能列表') #表头
  20. ,tbody = ('name', 'func') #表内容
  21. ,state = False #启用回收站
  22. )
  23. menu = (
  24. {'name':'基础资料', 'url':'/farm/info'}
  25. ,{'name':'网关管理', 'url':'/device/gateway'}
  26. ,{'name':'设备管理', 'url':'/device/info'}
  27. ,{'name':'农事管理', 'url':'/work/work'}
  28. ,{'name':'农事分类', 'url':'/work/category'}
  29. ,{'name':'地块管理', 'url':'/work/land'}
  30. ,{'name':'批次管理', 'url':'/origin/batch'}
  31. ,{'name':'用户管理', 'url':'/farm/user'}
  32. ,{'name':'打印机管理', 'url':'/device/printer'}
  33. ,{'name':'消息提醒', 'url':'/msg/msg'}
  34. )
  35. self.commonList('farm')
  36. if self.data['list']:
  37. for key, value in enumerate(self.data['list']):
  38. id = str(value['id'])
  39. param = '?farm=' + id + '&search_farm_id-select-=' + id
  40. self.data['list'][key]['func'] = ''
  41. for i in menu:
  42. self.data['list'][key]['func'] = self.data['list'][key]['func'] + '<a href="'+i['url']+''+param+'">'+i['name']+'</a>&nbsp;&nbsp;&nbsp;&nbsp;'
  43. self.commonView('list')
  44. class farm_update_path(Load):
  45. @Web.auth
  46. @Web.setting
  47. def get(self):
  48. self.common(
  49. path = '/farm/farm'
  50. ,label = (u'农场名称',u'农场地址',u'联系人',u'联系电话')
  51. ,update = ('name-input-required','address-input-required','master_name-input-required','tel-input-required')
  52. )
  53. self.commonOne('farm')
  54. self.commonView('update')
  55. @Web.auth
  56. @Web.setting
  57. def post(self):
  58. id = self.commonUpdate('farm')
  59. Demeter.config['setting']['farmList'] = self.service('common').list('farm')
  60. class info_path(Load):
  61. @Web.auth
  62. @Web.setting
  63. def get(self):
  64. id = str(Demeter.config['setting']['farm'])
  65. param = '?farm=' + id + '&search_farm_id-select-=' + id
  66. self.common(
  67. path = '/farm/info' + param
  68. ,label = (u'农场名称',u'农场图片',u'联系电话',u'农场地址',u'联系人',u'农场介绍')
  69. ,update = ('name-input-required','pic-pic-required-1000px*300~450px','tel-input-required','address-input-required','master_name-input-required',u'info-text-required-请输入农场介绍')
  70. )
  71. self.commonOne('farm', id=Demeter.config['setting']['farm'])
  72. self.commonView('set')
  73. @Web.auth
  74. @Web.setting
  75. def post(self):
  76. self.commonUpdate('farm', id=Demeter.config['setting']['farm'])
  77. class user_path(Load):
  78. @Web.auth
  79. @Web.setting
  80. def get(self):
  81. self.common(
  82. name = u'用户'
  83. ,path = '/farm/user'
  84. ,width = '600'
  85. ,height = '400'
  86. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间','选择农场',u'用户名称'))
  87. ,thead = (u'所属农场', u'用户名称', u'绑定列表', u'用户手机号', u'更新时间')
  88. ,tbody = ('farm','username','wechat', 'mobile', 'cdate')
  89. ,state = True
  90. )
  91. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  92. self.commonList('farm_user')
  93. if self.data['list']:
  94. for key, value in enumerate(self.data['list']):
  95. farm = self.service('common').one('farm', id=value['farm_id'])
  96. self.data['list'][key]['farm'] = farm['name']
  97. param = '?farm=' + id + '&search_uid-input-=' + value['id']
  98. self.data['list'][key]['wechat'] = '<a href="/farm/user_wechat'+param+'">点此查看</a>'
  99. self.commonView('list')
  100. class user_update_path(Load):
  101. @Web.auth
  102. @Web.setting
  103. def get(self):
  104. self.common(
  105. path = '/farm/user'
  106. ,label = (u'所属农场',u'账号姓名',u'手机号',u'安全码')
  107. ,update = ('farm_id-select-required','username-input-required','mobile-input-phone','password-password-')
  108. ,update_farm_id = Demeter.config['setting']['farmList']
  109. )
  110. self.commonOne('farm_user')
  111. self.commonView('update')
  112. @Web.auth
  113. @Web.setting
  114. def post(self):
  115. self.commonUpdate('farm_user', '手机号已经被注册', mobile=self.data['update']['mobile'])
  116. @Web.auth
  117. @Web.setting
  118. def delete(self):
  119. self.commonDelete('farm_user')
  120. class user_wechat_path(Load):
  121. @Web.auth
  122. @Web.setting
  123. def get(self):
  124. self.common(
  125. name = u'微信绑定列表'
  126. ,path = '/farm/user_wechat'
  127. ,width = '600'
  128. ,height = '400'
  129. ,add = False,
  130. ,edit = False,
  131. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','uid-input-'), (u'日期范围',u'开始时间',u'截止时间','选择农场',u'用户id'))
  132. ,thead = (u'所属农场', u'用户id', u'微信openid', u'更新时间')
  133. ,tbody = ('farm','uid','openid', 'cdate')
  134. ,state = True
  135. )
  136. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  137. self.commonList('farm_user_wechat')
  138. if self.data['list']:
  139. for key, value in enumerate(self.data['list']):
  140. farm = self.service('common').one('farm', id=value['farm_id'])
  141. self.data['list'][key]['farm'] = farm['name']
  142. self.commonView('list')