work.py 7.0 KB

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