plant.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <div style="cursor: default">
  3. <img style="width: 100%; margin: 0 0 0 -20px;" src="../../../../static/img/3.jpg" alt="" class="">
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. itemId: '',
  11. btnindex: '',
  12. page: 1,
  13. totalNum: null,
  14. base: '',
  15. pickcode: '',
  16. farmThingAddDialogVisible: false,
  17. farmThingEditDialogVisible: false,
  18. fieldsList: [],
  19. bases: [
  20. { value: '1', label: '基地一' },
  21. { value: '2', label: '基地二' },
  22. { value: '3', label: '基地三' },
  23. { value: '4', label: '基地四' }
  24. ],
  25. fields: [
  26. { value: '1', label: '地块一' },
  27. { value: '2', label: '地块二' },
  28. { value: '3', label: '地块三' },
  29. { value: '4', label: '地块四' }
  30. ],
  31. usefor: [
  32. { value: '1', label: '种植' },
  33. { value: '2', label: '种植' },
  34. { value: '3', label: '种植' },
  35. { value: '4', label: '种植' }
  36. ],
  37. addForm: {
  38. pro_name: '',
  39. batch_name: '', //批次名称
  40. pro_type: '',
  41. pro_cascader: []
  42. },
  43. editForm: {
  44. pro_name: '',
  45. batch_name: '', //批次名称
  46. pro_type: '',
  47. pro_cascader: []
  48. },
  49. addFormRules: {
  50. pro_name: [
  51. { required: true, message: '请填写产品名称', trigger: 'blur' }
  52. ],
  53. pro_type: [
  54. { required: true, message: '请填写产品类别', trigger: 'blur' }
  55. ],
  56. batch_name: [
  57. { required: true, message: '请填写批次名称', trigger: 'blur' }
  58. ],
  59. pro_cascader: [
  60. { required: true, message: '请选择地块', trigger: 'change' }
  61. ]
  62. },
  63. FieldCascader: []
  64. }
  65. },
  66. mounted() {
  67. this.getAllFieldsCascader()
  68. this.getplant()
  69. },
  70. methods: {
  71. getAllFieldsCascader() {
  72. this.$axios({
  73. method: 'POST',
  74. url: '/api/api_gateway?method=ascend.ascend_manage.all_base'
  75. }).then((res) => {
  76. if (res.data.message == '') {
  77. this.FieldCascader = res.data.data.data
  78. }
  79. })
  80. },
  81. getplant() {
  82. this.$axios({
  83. method: 'POST',
  84. url: '/api/api_gateway?method=ascend.ascend_manage.plant_info',
  85. data: this.qs.stringify({
  86. page: this.page,
  87. farmname: this.base,
  88. pickcode: this.pickcode
  89. })
  90. }).then((res) => {
  91. if (res.data.message == '') {
  92. this.totalNum = res.data.data.counts
  93. this.fieldsList = res.data.data.data
  94. }
  95. })
  96. },
  97. selChange(){
  98. this.page=1
  99. this.getplant()
  100. },
  101. plantAdd() {
  102. this.farmThingAddDialogVisible = true
  103. },
  104. plantEdit(item) {
  105. if (item.pickcode == '0') {
  106. //未采收
  107. this.editForm.pro_name = item.plantname
  108. this.editForm.batch_name = item.batch
  109. this.editForm.pro_type = item.planttype
  110. this.editForm.pro_cascader = [item.farm, item.land]
  111. this.itemId = item.id
  112. this.btnindex = 1
  113. this.farmThingEditDialogVisible = true
  114. } else {
  115. this.$message.warning('此地块已采收,禁止编辑!')
  116. }
  117. },
  118. plantDelet(id, backcode) {
  119. this.itemId = id
  120. this.btnindex = 2
  121. this.$confirm('确定要删除此作物么?', '提示', {
  122. confirmButtonText: '确定',
  123. cancelButtonText: '取消',
  124. type: 'warning'
  125. })
  126. .then(() => {
  127. this.$axios({
  128. method: 'POST',
  129. url: '/api/api_gateway?method=ascend.ascend_manage.del_plant',
  130. data: this.qs.stringify({
  131. backcode: backcode
  132. })
  133. }).then((res) => {
  134. if (res.data.message == '') {
  135. this.$message({
  136. type: 'success',
  137. message: '删除成功!'
  138. })
  139. this.getplant()
  140. }
  141. })
  142. })
  143. .catch(() => {
  144. this.$message({
  145. type: 'info',
  146. message: '已取消删除'
  147. })
  148. })
  149. },
  150. AddDialogClosed() {
  151. this.$refs.addFormRef.resetFields()
  152. },
  153. EditDialogClosed() {
  154. this.$refs.editFormRef.resetFields()
  155. },
  156. addSubm() {
  157. this.$refs.addFormRef.validate((valid) => {
  158. if (!valid) return
  159. let farm = this.addForm.pro_cascader[0]
  160. let land = this.addForm.pro_cascader[1]
  161. this.$axios({
  162. method: 'POST',
  163. url: '/api/api_gateway?method=ascend.ascend_manage.add_plant',
  164. data: this.qs.stringify({
  165. farm: farm,
  166. land: land,
  167. planttype: this.addForm.pro_type,
  168. batch: this.addForm.batch_name,
  169. plantname: this.addForm.pro_name
  170. })
  171. }).then((res) => {
  172. if (res.data.message == '') {
  173. this.getplant()
  174. } else {
  175. this.$message.warning(res.data.message)
  176. }
  177. this.farmThingAddDialogVisible = false
  178. })
  179. })
  180. },
  181. editSubm() {
  182. this.$refs.editFormRef.validate((valid) => {
  183. if (!valid) return
  184. this.$axios({
  185. method: 'POST',
  186. url: '/api/api_gateway?method=ascend.ascend_manage.edit_plant',
  187. data: this.qs.stringify({
  188. id: this.itemId,
  189. planttype: this.editForm.pro_type,
  190. batch: this.editForm.batch_name,
  191. plantname: this.editForm.pro_name
  192. })
  193. }).then((res) => {
  194. if (res.data.message == '') {
  195. this.getplant()
  196. } else {
  197. this.$message.warning(res.data.message)
  198. }
  199. })
  200. this.farmThingEditDialogVisible = false
  201. })
  202. },
  203. changePage(val) {
  204. this.page = val
  205. this.getplant()
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang='less' scoped>
  211. .search-box {
  212. display: flex;
  213. justify-content: space-between;
  214. margin-bottom: 10px;
  215. .el-input {
  216. width: 200px;
  217. }
  218. }
  219. .el-card {
  220. /deep/.el-card__body {
  221. position: relative;
  222. }
  223. .tag {
  224. position: absolute;
  225. top: 0;
  226. right: 20px;
  227. }
  228. text-align: center;
  229. color: #555;
  230. font-size: 13px;
  231. .borderLine {
  232. border: #eee;
  233. border-radius: 5px;
  234. -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  235. box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  236. padding: 8px 0;
  237. margin: 10px 0;
  238. }
  239. .btns {
  240. display: flex;
  241. width: 180px;
  242. border-radius: 30px;
  243. box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
  244. margin: 20px auto 0;
  245. a.bg {
  246. background: #17bb89;
  247. color: #fff;
  248. }
  249. a {
  250. width: 50%;
  251. height: 30px;
  252. line-height: 30px;
  253. cursor: pointer;
  254. &:first-child {
  255. border-top-left-radius: 30px;
  256. border-bottom-left-radius: 30px;
  257. }
  258. &:last-child {
  259. border-top-right-radius: 30px;
  260. border-bottom-right-radius: 30px;
  261. }
  262. }
  263. a:hover {
  264. background: #14a478;
  265. color: #fff;
  266. }
  267. }
  268. }
  269. .el-cascader {
  270. width: 100%;
  271. }
  272. </style>