warnset.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <view>
  3. <view class="basesel">
  4. <view class="basesel_list">
  5. <view class="basesel_list_tilte">
  6. 预警设备选择:
  7. </view>
  8. <view class="basesel_list_sel" @click="baseshow = true">
  9. <view class="basesel_list_sel_left" v-show="selbaselist==''">
  10. 请选择预警
  11. </view>
  12. <view class="basesel_list_sel_left" v-show="selbaselist!=''">
  13. {{selbaselist}}
  14. </view>
  15. <u-icon name="arrow-down" class="icon" color="#999999"></u-icon>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="usersel">
  20. <view class="warmissue_itemone">
  21. <view class="warmissue_itemone_title">
  22. 短信接受人:
  23. </view>
  24. <view class="" style="color: #14A478;" @click="tobook">
  25. 预警通讯录编辑
  26. </view>
  27. </view>
  28. <view class="warmissue_itemtwo" @click="accServiceShowphone = true">
  29. <view class="itemtwo_left" v-show="!userphone.length">
  30. 请选择短信接收人
  31. </view>
  32. <view class="itemtwo_left" v-show="userphone.length">
  33. <view class="" style="margin-right: 20rpx;" v-for="item in userphone" :key="item">
  34. {{item}}
  35. </view>
  36. </view>
  37. <u-icon name="arrow-down" class="icon" color="#999999"></u-icon>
  38. </view>
  39. </view>
  40. <view class="tongdao" v-for="item,index in tongdaolist" :key="index">
  41. <view class="tongdao_title">
  42. <view class="">
  43. {{item.key}}
  44. </view>
  45. <view class="">
  46. <u-switch v-model="item.type" size="40" style="margin-top: 13rpx;"></u-switch>
  47. </view>
  48. </view>
  49. <view class="tongdao_item">
  50. <view class="">
  51. 通道名称
  52. </view>
  53. <view class="">
  54. {{item.name}}
  55. </view>
  56. </view>
  57. <view class="tongdao_item">
  58. <view class="">
  59. 运算符
  60. </view>
  61. <view class="target_text_item_sel" @click="selindex = index;operationshow=true">
  62. <view class="itemtwo_left" v-show="item.value==''">
  63. 请选择运算符
  64. </view>
  65. <view class="itemtwo_left" v-show="item.value!=''">
  66. {{item.value}}
  67. </view>
  68. <u-icon name="arrow-down" class="icon" color="#999999"></u-icon>
  69. </view>
  70. </view>
  71. <view class="tongdao_item">
  72. <view class="">
  73. 阈值
  74. </view>
  75. <view class="" style="display: flex;">
  76. <u-input v-model="item.num[0]" type="number" @blur="numyanzheng(index)" />
  77. <view class="" style="width: 60rpx;text-align: center;" v-show="item.valuenum == 2">
  78. -
  79. </view>
  80. <u-input v-model="item.num[1]" type="number" v-show="item.valuenum == 2"
  81. @blur="numyanzheng(index)" />
  82. </view>
  83. </view>
  84. </view>
  85. <view class="sendbox" @click="send">
  86. 保存预警设置
  87. </view>
  88. <view class="">
  89. <u-mask :show="accServiceShowphone" z-index="998"></u-mask>
  90. <u-select v-model="baseshow" :list="baselist" @confirm="selconfirm"></u-select>
  91. <u-select v-model="operationshow" :list="operationlist" @confirm="operationconfirm"></u-select>
  92. <multiple-select v-model="accServiceShowphone" :value="accServiceShowphone" :data="serviceListphone"
  93. :default-selected="defaultSelectedphone" @confirm="accServiceConfirmphone"></multiple-select>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. import multipleSelect from "../../components/multiple-select.vue";
  99. export default {
  100. components: {
  101. multipleSelect,
  102. },
  103. data() {
  104. return {
  105. fanxianid: '',
  106. fanxianconf: "",
  107. warning_id: "",
  108. accServiceShowphone: false,
  109. userphone: [],
  110. send_user: [],
  111. defaultSelectedphone: [],
  112. serviceListphone: [],
  113. selbaselist: [],
  114. baselist: [],
  115. baseshow: false,
  116. statustf: false,
  117. operationshow: false,
  118. operationlist: [{
  119. value: 0,
  120. label: "小于"
  121. },
  122. {
  123. value: 1,
  124. label: "大于"
  125. },
  126. {
  127. value: 2,
  128. label: '介于'
  129. }
  130. ],
  131. tongdaolist: [],
  132. selindex: 0
  133. }
  134. },
  135. methods: {
  136. tobook() {
  137. uni.navigateTo({
  138. url: "../cbqxyj/addressbook"
  139. })
  140. },
  141. accServiceConfirmphone(e) {
  142. this.userphone = []
  143. this.send_user = []
  144. for (var i = 0; i < e.length; i++) {
  145. this.userphone.push(e[i].name)
  146. this.send_user.push(e[i].value)
  147. }
  148. },
  149. async getuseriphonelist() {
  150. const res = await this.$myRequest({
  151. url: '/api/api_gateway?method=device.device_sms_alert.user_warning_liaisons_list',
  152. data: {
  153. page: 1,
  154. page_size: 9999999,
  155. }
  156. })
  157. // console.log(res)
  158. this.serviceListphone = []
  159. for (var i = 0; i < res.data.length; i++) {
  160. var obj = {
  161. value: res.data[i].d_id,
  162. name: res.data[i].liaisons + "/" + res.data[i].phone,
  163. }
  164. this.serviceListphone.push(obj)
  165. }
  166. },
  167. async getbaselist() {
  168. const res = await this.$myRequest({
  169. url: '/api/api_gateway?method=device.device_sms_alert.user_warning_device_list',
  170. data: {
  171. device_type_id: "5",
  172. page: "1",
  173. page_size: "999999999"
  174. }
  175. })
  176. // console.log(res.data)
  177. for (var i = 0; i < res.data.length; i++) {
  178. var obj = {
  179. value: res.data[i].d_id,
  180. label: res.data[i].device_id
  181. }
  182. this.baselist.push(obj)
  183. }
  184. },
  185. selconfirm(e) {
  186. console.log(e)
  187. this.selbaselist = e[0].label
  188. this.getbasetongdao(e[0].label)
  189. },
  190. operationconfirm(e) {
  191. console.log(e)
  192. console.log(this.selindex)
  193. this.tongdaolist[this.selindex].value = e[0].label
  194. this.tongdaolist[this.selindex].valuenum = e[0].value
  195. },
  196. async getbasetongdao(device_id) {
  197. const res = await this.$myRequest({
  198. url: '/api/api_gateway?method=weather.weather.qxz_early_warning',
  199. data: {
  200. device_id: device_id,
  201. status: "see"
  202. }
  203. })
  204. console.log(res.conf)
  205. this.tongdaolist = []
  206. for (var key in res.conf) {
  207. var obj = {
  208. key: key,
  209. name: res.conf[key],
  210. type: false,
  211. value: "",
  212. valuenum: "",
  213. num: []
  214. }
  215. if (this.fanxianid == device_id) {
  216. console.log(this.fanxianconf)
  217. for (var i = 0; i < this.fanxianconf.length; i++) {
  218. if (Object.keys(this.fanxianconf[i]) == key) {
  219. obj.type = true;
  220. var arr = this.fanxianconf[i][key].split('#');
  221. if (arr[1].indexOf('&')) {
  222. arr[1] = arr[1].split('&');
  223. obj.num[1] = arr[1][1];
  224. obj.num[0] = arr[1][0];
  225. }
  226. obj.value = this.operationlist[arr[0]].label;
  227. obj.valuenum = arr[0];
  228. }
  229. }
  230. }
  231. this.tongdaolist.push(obj)
  232. }
  233. // console.log(this.tongdaolist)
  234. },
  235. yanzheng() {
  236. for (var i = 0; i < this.tongdaolist.length; i++) {
  237. if (this.tongdaolist[i].type) {
  238. return false
  239. }
  240. }
  241. return true
  242. },
  243. yanzheng2() {
  244. for (var i = 0; i < this.tongdaolist.length; i++) {
  245. if (this.tongdaolist[i].type) {
  246. if (!this.tongdaolist[i].value || !this.tongdaolist[i].num[0]) {
  247. return true
  248. } else if (this.tongdaolist[i].value == "介于" && !this.tongdaolist[i].num[1]) {
  249. return true
  250. }
  251. }
  252. }
  253. return false
  254. },
  255. numyanzheng(index) {
  256. if (this.tongdaolist[index].num[1]) {
  257. // console.log(Number(this.tongdaolist[index].num[0]) > Number(this.tongdaolist[index].num[1]))
  258. if (Number(this.tongdaolist[index].num[0]) >= Number(this.tongdaolist[index].num[1])) {
  259. this.tongdaolist[index].num = [this.tongdaolist[index].num[0], ""]
  260. }
  261. }
  262. },
  263. async send() {
  264. console.log(this.selbaselist)
  265. if (this.selbaselist == '') {
  266. uni.showToast({
  267. title: "请选择预警设备",
  268. icon: "none"
  269. })
  270. } else if (this.userphone.length == 0) {
  271. uni.showToast({
  272. title: "请选择预警短信接收人",
  273. icon: "none"
  274. })
  275. } else if (this.yanzheng()) {
  276. // console.log(this.tongdaolist)
  277. uni.showToast({
  278. title: "请开启至少一个通道预警",
  279. icon: "none"
  280. })
  281. } else if (this.yanzheng2()) {
  282. uni.showToast({
  283. title: "请将开启的通道信息填写完成",
  284. icon: "none"
  285. })
  286. } else {
  287. var conf = [
  288. ]
  289. for (var i = 0; i < this.tongdaolist.length; i++) {
  290. if (this.tongdaolist[i].type) {
  291. var obj = {}
  292. obj[this.tongdaolist[i].key] = this.tongdaolist[i].valuenum + "#" + this.tongdaolist[i].num
  293. .join("&")
  294. conf.push(obj)
  295. }
  296. }
  297. // console.log(conf)
  298. const res = await this.$myRequest({
  299. url: '/api/api_gateway?method=device.device_sms_alert.create_qxz_warning_config',
  300. data: {
  301. conf: JSON.stringify(conf),
  302. device_id: this.selbaselist,
  303. send_user_id: this.send_user.join(","),
  304. warning_id: this.warning_id,
  305. }
  306. })
  307. if (res) {
  308. uni.showToast({
  309. title: "预警设置成功",
  310. icon: "none"
  311. })
  312. uni.navigateBack({
  313. delta: 1
  314. })
  315. }
  316. // console.log(res)
  317. }
  318. },
  319. //返现
  320. async getstatsu() {
  321. const res = await this.$myRequest({
  322. url: '/api/api_gateway?method=device.device_sms_alert.user_qxz_warning_statsu',
  323. data: {
  324. warning_id: this.warning_id,
  325. }
  326. })
  327. console.log(res)
  328. this.selbaselist = res.device_ids
  329. this.fanxianid = res.device_ids
  330. this.defaultSelectedphone = []
  331. this.userphone = []
  332. this.send_user = []
  333. this.fanxianconf = res.conf;
  334. for (var key in res.send_user) {
  335. this.defaultSelectedphone.push(Number(key))
  336. this.userphone.push(res.send_user[key][0] + "/" + res.send_user[key][1])
  337. this.send_user.push(Number(key))
  338. }
  339. this.getbasetongdao(res.device_ids)
  340. }
  341. },
  342. onLoad(option) {
  343. this.warning_id = option.id
  344. this.getbaselist()
  345. this.getuseriphonelist()
  346. this.getstatsu()
  347. }
  348. }
  349. </script>
  350. <style lang="less">
  351. page {
  352. background-color: #F6F6FB;
  353. }
  354. .basesel {
  355. width: 95%;
  356. margin: 20rpx auto;
  357. padding: 30rpx 20rpx;
  358. box-sizing: border-box;
  359. background-color: #fff;
  360. border-radius: 10rpx;
  361. .basesel_list {
  362. width: 100%;
  363. .basesel_list_tilte {
  364. margin-bottom: 60rpx;
  365. font-size: 32rpx;
  366. }
  367. .basesel_list_sel {
  368. display: flex;
  369. margin-bottom: 60rpx;
  370. .basesel_list_sel_left {
  371. width: calc(100% - 40rpx);
  372. display: flex;
  373. flex-wrap: wrap;
  374. color: #999999;
  375. }
  376. .icon {
  377. width: 40rpx;
  378. }
  379. }
  380. }
  381. }
  382. .usersel {
  383. width: 95%;
  384. margin: 20rpx auto;
  385. padding: 30rpx 20rpx;
  386. box-sizing: border-box;
  387. background-color: #fff;
  388. border-radius: 10rpx;
  389. .warmissue_itemone {
  390. margin-bottom: 60rpx;
  391. display: flex;
  392. justify-content: space-between;
  393. .warmissue_itemone_title {
  394. font-size: 32rpx;
  395. }
  396. }
  397. .warmissue_item {
  398. margin-bottom: 60rpx;
  399. display: flex;
  400. .warmissue_item_title {
  401. width: 160rpx;
  402. }
  403. .warmissue_item_text {
  404. width: calc(100% - 160rpx);
  405. }
  406. }
  407. .warmissue_itemtwo {
  408. display: flex;
  409. .itemtwo_left {
  410. width: calc(100% - 40rpx);
  411. display: flex;
  412. flex-wrap: wrap;
  413. color: #999999;
  414. }
  415. .icon {
  416. width: 40rpx;
  417. }
  418. }
  419. }
  420. .tongdao {
  421. width: 95%;
  422. margin: 20rpx auto;
  423. padding: 30rpx 0rpx;
  424. box-sizing: border-box;
  425. background-color: #fff;
  426. border-radius: 10rpx;
  427. .tongdao_title {
  428. padding: 0 20rpx;
  429. display: flex;
  430. line-height: 60rpx;
  431. justify-content: space-between;
  432. height: 60rpx;
  433. border-left: 8rpx solid #14A478;
  434. }
  435. .tongdao_item {
  436. padding: 0 20rpx;
  437. display: flex;
  438. justify-content: space-between;
  439. margin-top: 30rpx;
  440. line-height: 70rpx;
  441. .target_text_item_sel {
  442. display: flex;
  443. border-bottom: 1px solid #aaaaad;
  444. height: 70rpx;
  445. line-height: 70rpx;
  446. .itemtwo_left {
  447. color: #999999;
  448. }
  449. }
  450. /deep/.uni-input-input {
  451. border-bottom: 1px solid #aaaaad;
  452. text-align: right;
  453. width: 200rpx;
  454. }
  455. /deep/.u-input__right-icon {
  456. line-height: 35px;
  457. }
  458. }
  459. }
  460. .sendbox {
  461. margin: 40rpx auto;
  462. width: 80%;
  463. background-color: #14A478;
  464. padding: 20rpx 0;
  465. border-radius: 59px;
  466. text-align: center;
  467. color: #fff;
  468. }
  469. </style>