healthAlarm.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <view class="home-warpTwo">
  3. <view class="airbody">
  4. <view class="module">
  5. <view class="device-bottom" v-if="selectedPlan.length > 0">
  6. <view
  7. class="info-box"
  8. v-for="(item, index) in selectedPlan"
  9. :key="index"
  10. >
  11. <view class="info-text">
  12. <text>{{ item.name }}</text>
  13. </view>
  14. <view class="edit_del">
  15. <image
  16. @click="deleteItem(item)"
  17. src="../../static/delete.png"
  18. alt=""
  19. ></image>
  20. <image
  21. @click="editItem(item)"
  22. style="margin-left: 30rpx"
  23. src="../../static/edit.png"
  24. alt=""
  25. ></image>
  26. </view>
  27. </view>
  28. </view>
  29. <view v-else>
  30. <view class="noPlan">暂无守护计划</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="bottomTwo">
  35. <picker
  36. mode="selector"
  37. :range="planListName"
  38. @change="bindPickerChange"
  39. :value="selectedIndex"
  40. >
  41. <text>新增守护计划 </text>
  42. </picker>
  43. </view>
  44. <alarModel />
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. devInfo: {},
  52. planList: [],
  53. planListName: [],
  54. selectedIndex: null,
  55. // 已经新增的守护计划
  56. selectedPlan: [],
  57. changFlage: false,
  58. };
  59. },
  60. computed: {},
  61. methods: {
  62. getPlanList() {
  63. this.$http
  64. .post("wap/alarm/plan/queryTpl", {
  65. eventVal: "",
  66. name: "",
  67. })
  68. .then((res) => {
  69. if (res.data.code == 200) {
  70. if (res.data.data.length > 0) {
  71. this.planList = res.data.data;
  72. this.planListName = res.data.data.map(
  73. (ele) => ele.name
  74. );
  75. }
  76. }
  77. });
  78. },
  79. confirmSelect() {
  80. if (this.selectedIndex !== null) {
  81. let selectePlans = this.planList.find(
  82. (plan) => plan.name == this.planListName[this.selectedIndex]
  83. );
  84. let selectedPlan = {};
  85. selectedPlan.clientId = this.devInfo.clientId;
  86. if (!selectedPlan.alarmTimePlan) {
  87. this.$set(selectedPlan, "alarmTimePlan", {});
  88. }
  89. selectedPlan.alarmTimePlan.startDate = this.$time(
  90. new Date(),
  91. 1
  92. );
  93. selectedPlan.alarmTimePlan.stopDate = this.$time(
  94. new Date(
  95. new Date().setFullYear(new Date().getFullYear() + 1)
  96. ),
  97. 1
  98. );
  99. selectedPlan.alarmTimePlan.timeRange =
  100. selectePlans.alarmTimePlanTpl.timeRange;
  101. selectedPlan.alarmTimePlan.monthDays =
  102. selectePlans.alarmTimePlanTpl.monthDays;
  103. selectedPlan.alarmTimePlan.weekdays =
  104. selectePlans.alarmTimePlanTpl.weekdays;
  105. selectedPlan.name = selectePlans.name;
  106. selectedPlan.enable = 1;
  107. selectedPlan.linkagePushWechatService = 1;
  108. selectedPlan.eventVal = selectePlans.eventVal;
  109. // selectedPlan.alarmPlanId = selectePlans.id;
  110. // console.log(selectedPlan, 888888888);
  111. this.$http
  112. .post(
  113. "wap/alarm/plan/save",
  114. {
  115. ...selectedPlan,
  116. },
  117. {
  118. header: {
  119. "Content-Type":
  120. "application/json;charset=UTF-8",
  121. token: uni.getStorageSync("tokenValue") || "",
  122. },
  123. }
  124. )
  125. .then((res) => {
  126. if (res.data.code == 200) {
  127. uni.showToast({
  128. title: "添加计划成功",
  129. icon: "success",
  130. duration: 1500,
  131. });
  132. } else {
  133. uni.showToast({
  134. title: res.data.message,
  135. icon: "none",
  136. duration: 1500,
  137. });
  138. }
  139. this.getSelectPlan();
  140. });
  141. }
  142. this.changFlage = true;
  143. },
  144. bindPickerChange(e) {
  145. this.selectedIndex = e.detail.value;
  146. this.confirmSelect();
  147. },
  148. getSelectPlan() {
  149. this.$http
  150. .post(
  151. "wap/alarm/plan/query",
  152. {
  153. clientId: this.devInfo.clientId,
  154. },
  155. {
  156. header: {
  157. "Content-Type": "application/json;charset=UTF-8",
  158. token: uni.getStorageSync("tokenValue") || "",
  159. },
  160. }
  161. )
  162. .then((res) => {
  163. if (res.data.code == 200) {
  164. this.selectedPlan = res.data.data;
  165. if (this.changFlage) {
  166. this.changFlage = false;
  167. this.editItem(
  168. this.selectedPlan[this.selectedPlan.length - 1]
  169. );
  170. }
  171. }
  172. });
  173. },
  174. deleteItem(item) {
  175. uni.showModal({
  176. content: "是否删除该计划",
  177. complete: (res) => {
  178. if (res.confirm) {
  179. this.$http
  180. .post(
  181. "wap/alarm/plan/del",
  182. {
  183. id: item.id,
  184. },
  185. {
  186. header: {
  187. "Content-Type":
  188. "application/json;charset=UTF-8",
  189. token:
  190. uni.getStorageSync("tokenValue") ||
  191. "",
  192. },
  193. }
  194. )
  195. .then((res) => {
  196. if (res.data.code == 200) {
  197. uni.showToast({
  198. title: "守护计划删除成功",
  199. icon: "success",
  200. duration: 1500,
  201. });
  202. } else {
  203. uni.showToast({
  204. title: res.data.message,
  205. icon: "none",
  206. duration: 1500,
  207. });
  208. }
  209. this.getSelectPlan();
  210. });
  211. }
  212. if (res.cancel) {
  213. }
  214. return;
  215. },
  216. });
  217. },
  218. editItem(item) {
  219. uni.navigateTo({
  220. url:
  221. "/pagesA/playSetting/playSetting?planInfo=" +
  222. JSON.stringify(item),
  223. });
  224. },
  225. },
  226. onLoad(options) {
  227. this.devInfo = JSON.parse(options.devInfo);
  228. },
  229. onShow() {
  230. this.getPlanList();
  231. this.getSelectPlan();
  232. },
  233. onHide() {},
  234. onUnload() {},
  235. };
  236. </script>
  237. <style lang="less" scoped>
  238. .home-warpTwo {
  239. position: relative;
  240. height: 100vh;
  241. background: linear-gradient(180deg, #ffdfdf 0%, #ffffff 30.3%);
  242. box-sizing: border-box;
  243. width: 750rpx;
  244. border-bottom-left-radius: 35rpx;
  245. border-bottom-right-radius: 35rpx;
  246. background: linear-gradient(180deg, #faede2 0%, #ffffff 100%);
  247. .airCantInfo {
  248. margin: 30rpx auto 0 auto;
  249. border: 18rpx solid #1f1f1f;
  250. position: relative;
  251. }
  252. .airbody {
  253. box-sizing: border-box;
  254. .header_top {
  255. // padding: 0rpx 40rpx;
  256. display: flex;
  257. justify-content: space-between;
  258. align-items: center;
  259. .airTitle {
  260. font-weight: 500;
  261. color: #784c41;
  262. font-size: 32rpx;
  263. padding-left: 20rpx;
  264. padding-top: 20rpx;
  265. }
  266. .addfnt {
  267. display: flex;
  268. align-items: center;
  269. image {
  270. margin-top: 7rpx;
  271. width: 25rpx;
  272. height: 25rpx;
  273. }
  274. .add_btn {
  275. margin-left: 10rpx;
  276. font-size: 32rpx;
  277. }
  278. }
  279. }
  280. .module {
  281. bottom: 0;
  282. box-sizing: border-box;
  283. width: 100%;
  284. background: #ffffff;
  285. border-radius: 20rpx 20rpx 20rpx 20rpx;
  286. .device-bottom {
  287. .no-data {
  288. text-align: center;
  289. }
  290. .info-box {
  291. display: flex;
  292. align-items: center;
  293. // width: 620rpx;
  294. padding: 0 30rpx;
  295. height: 110rpx;
  296. background: #f8f8f8;
  297. border-radius: 38rpx;
  298. border-radius: 20rpx 20rpx 20rpx 20rpx;
  299. font-family: PingFang SC, PingFang SC;
  300. font-weight: 400;
  301. font-size: 26rpx;
  302. .info-text {
  303. display: flex;
  304. flex-direction: column;
  305. margin-left: 20rpx;
  306. }
  307. image {
  308. margin-bottom: 10rpx;
  309. width: 75rpx;
  310. height: 75rpx;
  311. }
  312. .edit_del {
  313. margin-left: auto;
  314. image {
  315. width: 40rpx;
  316. height: 40rpx;
  317. }
  318. }
  319. }
  320. .info-box:not(:first-child) {
  321. margin-top: 20rpx;
  322. }
  323. }
  324. .noPlan {
  325. background-color: #f9efe5;
  326. padding-top: 30rpx;
  327. color: #999;
  328. font-size: 28rpx;
  329. text-align: center;
  330. }
  331. }
  332. }
  333. .bottomTwo {
  334. width: 750rpx;
  335. height: 120rpx;
  336. position: fixed;
  337. display: flex;
  338. justify-content: center;
  339. align-items: center;
  340. bottom: 0;
  341. left: 0;
  342. line-height: 120rpx;
  343. background: #f3e2dd;
  344. }
  345. .mask {
  346. position: fixed;
  347. top: 0;
  348. left: 0;
  349. right: 0;
  350. bottom: 0;
  351. background: rgba(0, 0, 0, 0.4);
  352. z-index: 99;
  353. }
  354. .popup {
  355. position: fixed;
  356. left: 50%;
  357. top: 50%;
  358. transform: translate(-50%, -50%);
  359. width: 500rpx;
  360. background: #fff;
  361. border-radius: 16rpx;
  362. padding: 20rpx;
  363. z-index: 100;
  364. .popup-body {
  365. text-align: center;
  366. margin-bottom: 20rpx;
  367. .picker-text {
  368. padding: 20rpx;
  369. border-radius: 8rpx;
  370. }
  371. }
  372. .popup-footer {
  373. display: flex;
  374. justify-content: space-around;
  375. margin-top: 40rpx;
  376. .cancel-btn {
  377. width: 200rpx;
  378. height: 75rpx;
  379. background: #ffebe4;
  380. line-height: 75rpx;
  381. border-radius: 28rpx;
  382. font-weight: 500;
  383. color: #111111;
  384. font-size: 32rpx;
  385. text-align: center;
  386. }
  387. .sure-btn {
  388. width: 200rpx;
  389. height: 75rpx;
  390. background: #4f372e;
  391. line-height: 75rpx;
  392. border-radius: 28rpx;
  393. font-weight: 500;
  394. color: #ffffff;
  395. font-size: 32rpx;
  396. text-align: center;
  397. }
  398. }
  399. }
  400. }
  401. </style>