shuifeizs.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view class="facilitystate-page">
  3. <custom-card>
  4. <block slot="backText">
  5. <view class="facilitystate-top__title">
  6. <text :class="devStatus == '1' ? 'online' : 'offline'">{{
  7. devStatus == '1' ? '在线' : '离线'
  8. }}</text>
  9. {{ devName }}
  10. </view>
  11. </block>
  12. </custom-card>
  13. <view class="facilitystate-top">
  14. <view
  15. class="facilitystate-top__item"
  16. v-for="(item, index) in deviceList"
  17. :key="index"
  18. @click="nativeTo(item)"
  19. >
  20. <image class="item-icon" :src="item.icon" />
  21. <view class="facilitystate-top__item-text">{{ item.title }}</view>
  22. </view>
  23. </view>
  24. <Base :dataList="dataList" />
  25. <facilitystate
  26. :ggbCurrent="ggbCurrent"
  27. :sfbCurrent="sfbCurrent"
  28. :irrigatedAreaList="irrigatedAreaList"
  29. :alreadyfertilizerBucketList="alreadyfertilizerBucketList"
  30. />
  31. </view>
  32. </template>
  33. <script>
  34. import manualControl from './assets/manualControl.png';
  35. import wheelIrrigation from './assets/wheelIrrigation.png';
  36. import timing from './assets/timing.png';
  37. import masterStop from './assets/masterStop.png';
  38. import fertilizationFormula from './assets/fertilizationFormula.png';
  39. import backwashControl from './assets/backwashControl.png';
  40. import basicSetting from './assets/basicSetting.png';
  41. import operatingRecord from './assets/operatingRecord.png';
  42. import Base from './components/base.vue';
  43. import facilitystate from './components/facilitystate.vue';
  44. export default {
  45. data() {
  46. return {
  47. title: '水肥一体机',
  48. manualControl,
  49. devBid: '',
  50. devName: '',
  51. devStatus: '1',
  52. dataList: [],
  53. irrigatedAreaList: [],
  54. alreadyfertilizerBucketList: [],
  55. deviceList: [
  56. {
  57. icon: manualControl,
  58. title: '手动控制',
  59. url: '/pages/cb/shuifeizsFirst/control',
  60. },
  61. // {
  62. // icon: wheelIrrigation,
  63. // title: '自动控制',
  64. // url: '',
  65. // },
  66. {
  67. icon: operatingRecord,
  68. title: '操作记录',
  69. url: '/pages/cb/shuifeizsFirst/history',
  70. },
  71. // {
  72. // icon: timing,
  73. // title: '定时计划',
  74. // url: '',
  75. // },
  76. // {
  77. // icon: masterStop,
  78. // title: '总停',
  79. // url: '',
  80. // },
  81. // {
  82. // icon: fertilizationFormula,
  83. // title: '施肥配方',
  84. // url: '',
  85. // },
  86. // {
  87. // icon: backwashControl,
  88. // title: '反冲洗控制',
  89. // url: '',
  90. // },
  91. // {
  92. // icon: basicSetting,
  93. // title: '基础设置',
  94. // url: '',
  95. // },
  96. ],
  97. ggbCurrent: {},
  98. sfbCurrent: {},
  99. };
  100. },
  101. components: {
  102. Base,
  103. facilitystate,
  104. },
  105. onLoad(options) {
  106. console.log(options, 'optionsoptions');
  107. /*
  108. 0 水源 泵类 负责水源进入管道的总泵或者阀
  109. 1 肥料 泵类 负责肥料进入管道的总阀或者泵
  110. 2 吸肥 泵类 控制肥料桶出肥的阀或者泵,每个肥料桶一个
  111. 3 搅拌 泵类 肥料桶的搅拌电机或者泵 每个肥料桶一个
  112. 4 肥料桶 泵类 肥料桶,每个施肥机有多个或者没有,不一定真实存在,只是逻辑上的概念
  113. 5 电磁阀 无 管道最末端每个田地里控制出水的阀门
  114. 6 传感器 无 水肥机上的 温度,压力,流速,PH EC等监测类要素
  115. 7 灌区 无 逻辑区域,电磁阀的分组
  116. */
  117. const { devBid, devName, devStatus } = options;
  118. this.devBid = devBid;
  119. this.devName = devName;
  120. this.devStatus = devStatus;
  121. this.deviceList[0].url = `/pages/cb/shuifeizsFirst/control?devBid=${options.devBid}`;
  122. this.deviceList[
  123. this.deviceList.length - 1
  124. ].url = `/pages/cb/shuifeizsFirst/history?devBid=${options.devBid}`;
  125. if (devBid) {
  126. this.init();
  127. }
  128. },
  129. methods: {
  130. async init() {
  131. this.getdeviceSfStatus();
  132. await this.getpeifangRefresh();
  133. await this.getRunStatus();
  134. },
  135. // iot/mobile/device/sf/peifang/refresh/
  136. async getpeifangRefresh() {
  137. const res = await this.$myRequest({
  138. url: '/api/v2/iot/mobile/device/sf/peifang/refresh/',
  139. method: 'post',
  140. data: {
  141. devBid: this.devBid,
  142. },
  143. });
  144. },
  145. async getRunStatus() {
  146. const res = await this.$myRequest({
  147. url: '/api/v2/iot/mobile/device/sf/zsrf/task/run/status/',
  148. method: 'post',
  149. data: {
  150. devBid: this.devBid,
  151. },
  152. });
  153. const data = JSON.stringify(res || {});
  154. if (data == '{}') {
  155. this.isRun = true;
  156. // this.deviceList[1].url = `/pages/cb/shuifeizsFirst/automation?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`;
  157. } else {
  158. this.isRun = false;
  159. // this.deviceList[1].url = `/pages/cb/shuifeizsFirst/rotationflow?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`;
  160. }
  161. },
  162. async getdeviceSfStatus() {
  163. const res = await this.$myRequest({
  164. url: '/api/v2/iot/mobile/device/sf/status/',
  165. method: 'post',
  166. data: {
  167. devBid: this.devBid,
  168. },
  169. });
  170. this.dataList = [];
  171. this.irrigatedAreaList = [];
  172. this.alreadyfertilizerBucketList = [];
  173. res?.forEach((item) => {
  174. if (item.sfType === '0') {
  175. this.ggbCurrent = item;
  176. } else if (item.sfType === '1') {
  177. this.sfbCurrent = item;
  178. } else if (item.sfType === '4') {
  179. this.alreadyfertilizerBucketList.push(item);
  180. } else if (item.sfType === '6') {
  181. this.dataList.push(item);
  182. } else if (item.sfType === '7') {
  183. this.irrigatedAreaList.push(item);
  184. }
  185. });
  186. },
  187. nativeTo(item) {
  188. uni.navigateTo({
  189. url: item.url,
  190. });
  191. },
  192. },
  193. };
  194. </script>
  195. <style scoped lang="scss">
  196. uni-page-body {
  197. position: relative;
  198. height: 100%;
  199. }
  200. .online {
  201. height: 32rpx;
  202. line-height: 32rpx;
  203. padding: 0 8rpx;
  204. border-radius: 4rpx;
  205. background: #14a478;
  206. color: #ffffff;
  207. font-family: 'Source Han Sans CN';
  208. font-size: 20rpx;
  209. font-weight: 500;
  210. margin-right: 8rpx;
  211. top: -4rpx;
  212. position: relative;
  213. }
  214. .offline {
  215. height: 32rpx;
  216. line-height: 32rpx;
  217. padding: 0 8rpx;
  218. border-radius: 4rpx;
  219. background: #ff4d4f;
  220. color: #ffffff;
  221. font-family: 'Source Han Sans CN';
  222. font-size: 20rpx;
  223. font-weight: 500;
  224. margin-right: 8rpx;
  225. top: -4rpx;
  226. position: relative;
  227. }
  228. .facilitystate-page {
  229. background: linear-gradient(180deg, #ffffff00 0%, #fff 23.64%, #fff 100%),
  230. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  231. height: 100%;
  232. width: 100%;
  233. overflow-x: hidden;
  234. overflow-y: scroll;
  235. .facilitystate-top {
  236. display: grid;
  237. grid-template-columns: repeat(4, 1fr);
  238. text-align: center;
  239. margin-top: 18rpx;
  240. &__item {
  241. margin-bottom: 32rpx;
  242. .item-icon {
  243. width: 96rpx;
  244. height: 96rpx;
  245. }
  246. }
  247. &__item-text {
  248. color: #042118;
  249. font-family: 'Source Han Sans CN VF';
  250. font-size: 28rpx;
  251. font-weight: 400;
  252. margin-top: 16rpx;
  253. }
  254. }
  255. }
  256. </style>