work.py 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web page
  5. name:work.py 农事相关页面
  6. author:rabin
  7. """
  8. from __load__ import *
  9. class work_path(Load):
  10. @Web.auth
  11. @Web.setting
  12. def get(self):
  13. self.common(
  14. name = u'农事'
  15. ,path = '/work/work'
  16. ,width = '600'
  17. ,height = '600'
  18. ,add = False
  19. ,edit = False
  20. ,search = (('label-1','workdate-time-start','workdate-time-end','farm_id-select-','category_id-select-'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'劳作分类'))
  21. ,thead = (u'所属农场', u'劳作时间', u'劳作分类', u'劳作方式', u'劳作地块', u'劳作用量', u'更新时间')
  22. ,tbody = ('farm','workdate', 'category', 'method', 'land', 'amount', 'cdate')
  23. ,state = False
  24. )
  25. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  26. self.commonList('device_gateway')
  27. self.data['common']['search_category_id-select-'] = self.service('common').list('farm_work_category')
  28. self.commonList('farm_work')
  29. if self.data['list']:
  30. for key, value in enumerate(self.data['list']):
  31. farm = self.service('common').one('farm', id=value['farm_id'])
  32. #self.data['list'][key]['workdate'] = Demeter.date(value['workdate'])
  33. self.data['list'][key]['farm'] = farm['name']
  34. category = self.service('common').one('farm_work_category', id=value['category_id'])
  35. self.data['list'][key]['category'] = category['name']
  36. method = self.service('common').one('farm_work_method', id=value['method_id'])
  37. self.data['list'][key]['method'] = method['name']
  38. land = self.service('common').one('farm_work_land', id=value['land_id'])
  39. self.data['list'][key]['land'] = land['name']
  40. self.commonView('list')
  41. class work_update_path(Load):
  42. @Web.auth
  43. @Web.setting
  44. def get(self):
  45. self.common(
  46. path = '/work/work'
  47. ,label = (u'所属农场',u'劳作时间',u'劳作类别',u'劳作方式',u'劳作用量',u'劳作地块',u'图像记录')
  48. ,update = ('farm_id-select-required', 'workdate-date-required','category_id-select-required-method_id','method_id-select-required--category_id','amount-input-required','land_id-select-required','pic-pic-required')
  49. ,update_category_id = self.service('common').list('farm_work_category')
  50. ,update_method_id = self.service('common').list('farm_work_method')
  51. ,update_land_id = self.service('common').list('farm_work_land')
  52. ,update_farm_id = Demeter.config['setting']['farmList']
  53. )
  54. self.commonOne('farm_work')
  55. self.commonView('update')
  56. @Web.auth
  57. @Web.setting
  58. def post(self):
  59. self.commonUpdate('farm_work')
  60. @Web.auth
  61. @Web.setting
  62. def delete(self):
  63. self.commonDelete('farm_work')
  64. class method_path(Load):
  65. @Web.auth
  66. @Web.setting
  67. def get(self):
  68. self.common(
  69. name = u'劳作方法'
  70. ,path = '/work/method'
  71. ,width = '800'
  72. ,height = '300'
  73. ,add = False
  74. ,edit = False
  75. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'劳作分类',u'劳作内容'))
  76. ,thead = (u'所属农场',u'劳作内容', u'劳作分类', u'更新时间')
  77. ,tbody = ('farm','name', 'category', 'cdate')
  78. ,state = False
  79. )
  80. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  81. self.data['common']['search_category_id-select-'] = self.service('common').list('farm_work_category')
  82. self.commonList('farm_work_method')
  83. if self.data['list']:
  84. for key, value in enumerate(self.data['list']):
  85. farm = self.service('common').one('farm', id=value['farm_id'])
  86. self.data['list'][key]['farm'] = farm['name']
  87. category = self.service('common').one('farm_work_category', id=value['category_id'])
  88. self.data['list'][key]['category'] = category['name']
  89. self.commonView('list')
  90. class method_update_path(Load):
  91. @Web.auth
  92. @Web.setting
  93. def get(self):
  94. self.common(
  95. path = '/work/method'
  96. ,label = (u'所属农场', u'劳作内容',u'劳作分类')
  97. ,update = ('farm_id-select-required', 'name-input-required','category_id-select-required')
  98. ,update_category_id = self.service('common').list('farm_work_category')
  99. ,update_farm_id = Demeter.config['setting']['farmList']
  100. )
  101. self.commonOne('farm_work_method')
  102. self.commonView('update')
  103. @Web.auth
  104. @Web.setting
  105. def post(self):
  106. self.commonUpdate('farm_work_method')
  107. @Web.auth
  108. @Web.setting
  109. def delete(self):
  110. self.commonDelete('farm_work_method')
  111. class category_path(Load):
  112. @Web.auth
  113. @Web.setting
  114. def get(self):
  115. self.common(
  116. name = u'劳作分类'
  117. ,path = '/work/category'
  118. ,width = '600'
  119. ,height = '300'
  120. ,add = False
  121. ,edit = False
  122. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'分类名称'))
  123. ,thead = (u'所属农场',u'分类名称', u'更新时间')
  124. ,tbody = ('farm', 'name', 'cdate')
  125. ,state = False
  126. )
  127. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  128. self.commonList('farm_work_category')
  129. if self.data['list']:
  130. for key, value in enumerate(self.data['list']):
  131. farm = self.service('common').one('farm', id=value['farm_id'])
  132. self.data['list'][key]['farm'] = farm['name']
  133. self.commonView('list')
  134. class category_update_path(Load):
  135. @Web.auth
  136. @Web.setting
  137. def get(self):
  138. self.common(
  139. path = '/work/category'
  140. ,label = (u'所属农场', u'分类名称')
  141. ,update = ('farm_id-select-required', 'name-input-required')
  142. ,update_farm_id = Demeter.config['setting']['farmList']
  143. )
  144. self.commonOne('farm_work_category')
  145. self.commonView('update')
  146. @Web.auth
  147. @Web.setting
  148. def post(self):
  149. self.commonUpdate('farm_work_category')
  150. @Web.auth
  151. @Web.setting
  152. def delete(self):
  153. self.commonDelete('farm_work_category')
  154. class land_path(Load):
  155. @Web.auth
  156. @Web.setting
  157. def get(self):
  158. self.common(
  159. name = u'地块'
  160. ,path = '/work/land'
  161. ,width = '600'
  162. ,height = '300'
  163. ,add = False
  164. ,edit = False
  165. ,search = (('label-1','cdate-time-start','cdate-time-end','farm_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'地块名称'))
  166. ,thead = (u'所属农场',u'地块名称', u'更新时间')
  167. ,tbody = ('farm', 'name', 'cdate')
  168. ,state = False
  169. )
  170. self.data['common']['search_farm_id-select-'] = Demeter.config['setting']['farmList']
  171. self.commonList('farm_work_land')
  172. if self.data['list']:
  173. for key, value in enumerate(self.data['list']):
  174. farm = self.service('common').one('farm', id=value['farm_id'])
  175. self.data['list'][key]['farm'] = farm['name']
  176. self.commonView('list')
  177. class land_update_path(Load):
  178. @Web.auth
  179. @Web.setting
  180. def get(self):
  181. self.common(
  182. path = '/work/land'
  183. ,label = (u'所属农场', u'地块名称')
  184. ,update = ('farm_id-select-required','name-input-required')
  185. ,update_farm_id = Demeter.config['setting']['farmList']
  186. )
  187. self.commonOne('farm_work_land')
  188. self.commonView('update')
  189. @Web.auth
  190. @Web.setting
  191. def post(self):
  192. self.commonUpdate('farm_work_land')
  193. @Web.auth
  194. @Web.setting
  195. def delete(self):
  196. self.commonDelete('farm_work_land')