work.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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','category_id-select-'), (u'日期范围',u'开始时间',u'截止时间',u'劳作分类'))
  20. ,thead = (u'劳作时间', u'劳作分类', u'劳作方式', u'劳作地块', u'劳作用量', u'更新时间')
  21. ,tbody = ('workdate', 'category', 'method', 'land', 'amount', 'cdate')
  22. ,state = False
  23. )
  24. self.list('device_gateway')
  25. self.data['common']['search_category_id-select-'] = self.service('common').list('farm_work_category')
  26. self.list('farm_work')
  27. if self.data['list']:
  28. for key, value in enumerate(self.data['list']):
  29. category = self.service('common').one('farm_work_category', id=value['category_id'])
  30. self.data['list'][key]['category'] = category['name']
  31. method = self.service('common').one('farm_work_method', id=value['method_id'])
  32. self.data['list'][key]['method'] = method['name']
  33. land = self.service('common').one('farm_work_land', id=value['land_id'])
  34. self.data['list'][key]['land'] = land['name']
  35. self.show('list')
  36. class work_update_path(Load):
  37. @Web.auth
  38. @Web.setting
  39. def get(self):
  40. self.set(
  41. path = '/work/work'
  42. ,label = (u'劳作时间',u'劳作类别',u'劳作方式',u'劳作用量',u'劳作地块',u'图像记录')
  43. ,update = ('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')
  44. ,update_category_id = self.service('common').list('farm_work_category')
  45. ,update_method_id = self.service('common').list('farm_work_method')
  46. ,update_land_id = self.service('common').list('farm_work_land')
  47. )
  48. self.one('farm_work')
  49. self.show('update')
  50. @Web.auth
  51. @Web.setting
  52. def post(self):
  53. self.update('farm_work')
  54. @Web.auth
  55. @Web.setting
  56. def delete(self):
  57. self.drop('farm_work')
  58. class method_path(Load):
  59. @Web.auth
  60. @Web.setting
  61. def get(self):
  62. self.set(
  63. name = u'劳作方法'
  64. ,path = '/work/method'
  65. ,width = '800'
  66. ,height = '300'
  67. ,add = False
  68. ,edit = False
  69. ,search = (('label-1','cdate-time-start','cdate-time-end','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'劳作分类',u'劳作内容'))
  70. ,thead = (u'劳作内容', u'劳作分类', u'更新时间')
  71. ,tbody = ('name', 'category', 'cdate')
  72. ,state = False
  73. )
  74. self.data['common']['search_category_id-select-'] = self.service('common').list('farm_work_category')
  75. self.list('farm_work_method')
  76. if self.data['list']:
  77. for key, value in enumerate(self.data['list']):
  78. category = self.service('common').one('farm_work_category', id=value['category_id'])
  79. self.data['list'][key]['category'] = category['name']
  80. self.show('list')
  81. class method_update_path(Load):
  82. @Web.auth
  83. @Web.setting
  84. def get(self):
  85. self.set(
  86. path = '/work/method'
  87. ,label = (u'劳作内容',u'劳作分类')
  88. ,update = ('name-input-required','category_id-select-required')
  89. ,update_category_id = self.service('common').list('farm_work_category')
  90. )
  91. self.one('farm_work_method')
  92. self.show('update')
  93. @Web.auth
  94. @Web.setting
  95. def post(self):
  96. self.update('farm_work_method')
  97. @Web.auth
  98. @Web.setting
  99. def delete(self):
  100. self.drop('farm_work_method')
  101. class category_path(Load):
  102. @Web.auth
  103. @Web.setting
  104. def get(self):
  105. self.set(
  106. name = u'劳作分类'
  107. ,path = '/work/category'
  108. ,width = '600'
  109. ,height = '300'
  110. ,add = False
  111. ,edit = False
  112. ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择农场',u'分类名称'))
  113. ,thead = (u'分类名称', u'更新时间')
  114. ,tbody = ('name', 'cdate')
  115. ,state = False
  116. )
  117. self.list('farm_work_category')
  118. self.show('list')
  119. class category_update_path(Load):
  120. @Web.auth
  121. @Web.setting
  122. def get(self):
  123. self.set(
  124. path = '/work/category'
  125. ,label = (u'分类名称')
  126. ,update = ('name-input-required')
  127. )
  128. self.one('farm_work_category')
  129. self.show('update')
  130. @Web.auth
  131. @Web.setting
  132. def post(self):
  133. self.update('farm_work_category')
  134. @Web.auth
  135. @Web.setting
  136. def delete(self):
  137. self.drop('farm_work_category')
  138. class land_path(Load):
  139. @Web.auth
  140. @Web.setting
  141. def get(self):
  142. self.set(
  143. name = u'地块'
  144. ,path = '/work/land'
  145. ,width = '600'
  146. ,height = '300'
  147. ,add = False
  148. ,edit = False
  149. ,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'地块名称'))
  150. ,thead = (u'地块名称', u'更新时间')
  151. ,tbody = ('name', 'cdate')
  152. ,state = False
  153. )
  154. self.list('farm_work_land')
  155. self.show('list')
  156. class land_update_path(Load):
  157. @Web.auth
  158. @Web.setting
  159. def get(self):
  160. self.set(
  161. path = '/work/land'
  162. ,label = (u'地块名称',)
  163. ,update = ('name-input-required',)
  164. )
  165. self.one('farm_work_land')
  166. self.show('update')
  167. @Web.auth
  168. @Web.setting
  169. def post(self):
  170. self.update('farm_work_land')
  171. @Web.auth
  172. @Web.setting
  173. def delete(self):
  174. self.drop('farm_work_land')