equip-set-new.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <template>
  2. <view style="padding: 0 24rpx;">
  3. <view class="" v-if="myuser_type">
  4. <view class="tit adminTit">
  5. 联网模块
  6. </view>
  7. <view class="btns">
  8. <button v-for="(item,index) in controlInfo.netControl" type="warn" @click="equipBtnControl(item.cmd)" size="mini">{{item.name}}</button>
  9. </view>
  10. <view class="tit adminTit">
  11. 强制操作
  12. </view>
  13. <view class="btns">
  14. <button v-for="(item,index) in controlInfo.forceControl" type="warn" @click="equipBtnControl(item.cmd)" size="mini">{{item.name}}</button>
  15. </view>
  16. <view class="tit adminTit">
  17. 设备操作
  18. </view>
  19. <view class="btns">
  20. <button v-for="(item,index) in controlInfo.equipControl" type="warn" @click="equipBtnControl(item.cmd)" size="mini">{{item.name}}</button>
  21. </view>
  22. </view>
  23. <view style="margin:40rpx 0 20rpx 0;">
  24. <u-line color="#E5EBE9" />
  25. </view>
  26. <view class="uni-list-cell" v-if="device_type==32" @click="modeShow = true">
  27. <span class="tit">定时模式</span>
  28. <view class="right-data" style="float: right;">
  29. <span>{{tsArrLabel}}</span>
  30. <u-icon class="arrow" name="arrow-right"></u-icon>
  31. </view>
  32. </view>
  33. <view class="uni-list-cell" v-if="device_type==33||device_type==34" @click="syModeShow = true">
  34. <span class="tit">控制模式</span>
  35. <view class="right-data" style="float: right;">
  36. <span>{{tsArrLabel}}</span>
  37. <u-icon class="arrow" name="arrow-right"></u-icon>
  38. </view>
  39. </view>
  40. <view class="uni-list-cell" @click="shikongshow = true" v-if="equipContrlForm.CONTROL==0">
  41. <span class="tit">
  42. 时控时长
  43. </span>
  44. <view class="right-data" style="float: right;">
  45. <span>{{shikongLabel}}</span>
  46. <u-icon class="arrow" name="arrow-right"></u-icon>
  47. </view>
  48. </view>
  49. <view class="uni-list-cell" @click="gkongShow = true" v-if="equipContrlForm.CONTROL==1">
  50. <span class="tit">
  51. 光控时长
  52. </span>
  53. <view class="right-data" style="float: right;">
  54. <span>{{gkongLabel}}</span>
  55. <u-icon class="arrow" name="arrow-right"></u-icon>
  56. </view>
  57. </view>
  58. <view class="uni-list-cell" @click="photoShow = true" v-if="device_type==33||device_type==34">
  59. <span class="tit">
  60. 拍照时间
  61. </span>
  62. <view class="right-data" style="float: right;">
  63. <span>{{photoLabel}}</span>
  64. <u-icon class="arrow" name="arrow-right"></u-icon>
  65. </view>
  66. </view>
  67. <view class="uni-list-cell" v-if="device_type==33||device_type==34" @click="selectOperate(5,1440,'P_DATT')">
  68. <span class="tit">
  69. 拍照频率(min)
  70. </span>
  71. <view class="right-data" style="float: right;">
  72. <span>{{equipContrlForm.P_DATT}}</span>
  73. <u-icon class="arrow" name="arrow-right"></u-icon>
  74. </view>
  75. </view>
  76. <view class="uni-list-cell" @click="selectOperate(5,device_type==32?60:1440,'DATT')">
  77. <span class="tit">
  78. 数据上传频率(min)
  79. </span>
  80. <view class="right-data" style="float: right;">
  81. <span>{{equipContrlForm.DATT}}</span>
  82. <u-icon class="arrow" name="arrow-right"></u-icon>
  83. </view>
  84. </view>
  85. <view v-if="device_type==32" class="uni-list-cell" @click="selectOperate(5,180,'PHO_T')">
  86. <span class="tit">
  87. 照片上传频率(min)
  88. </span>
  89. <view class="right-data" style="float: right;">
  90. <span>{{equipContrlForm.PHO_T}}</span>
  91. <u-icon class="arrow" name="arrow-right"></u-icon>
  92. </view>
  93. </view>
  94. <view >
  95. <u-select v-model="modeShow" :list="tsArr" @confirm="tsArrConfirm"></u-select>
  96. <u-select v-model="syModeShow" :list="syArr" @confirm="tsArrConfirm"></u-select>
  97. <u-select v-model="shikongshow" mode="mutil-column" :list="shikonglist" @confirm="shikongconfirm"></u-select>
  98. <u-select v-model="photoShow" mode="mutil-column" :list="shikonglist" @confirm="photoConfirm"></u-select>
  99. <u-select v-model="gkongShow" :list="gkongArr" @confirm="gkArrConfirm"></u-select>
  100. <u-select v-model="dataSelectShow" :list="singleSelectList" @confirm="dataconfirm"></u-select>
  101. </view>
  102. <view class="submit-box">
  103. <u-button :custom-style="customStyle" @click="submit" :disabled="submitBtnDisabled" >确定</u-button>
  104. </view>
  105. <u-toast ref="toast" />
  106. <u-popup v-model="mqttShow">
  107. <view class="mqtt-popup">
  108. <u-field required v-model="mqttConfig.muid" label="MQTT用户名" label-width="180">
  109. </u-field>
  110. <u-field required v-model="mqttConfig.mpwd" label="MQTT密码" label-width="180">
  111. </u-field>
  112. <u-field required v-model="mqttConfig.mpi" label="MQTT地址" label-width="180">
  113. </u-field>
  114. <u-field required v-model="mqttConfig.mport" label="MQTT端口" label-width="180">
  115. </u-field>
  116. <u-field required v-model="mqttConfig.mpub" label="上传地址" label-width="180">
  117. </u-field>
  118. <u-field required v-model="mqttConfig.msub" label="下发地址" label-width="180">
  119. </u-field>
  120. <u-field v-model="mqttConfig.fuid" label="FTP用户名" label-width="180">
  121. </u-field>
  122. <u-field v-model="mqttConfig.fpwd" label="FTP密码" label-width="180">
  123. </u-field>
  124. <u-field required v-model="mqttConfig.fip" label="图片上传地址" label-width="180">
  125. </u-field>
  126. <u-field required v-model="mqttConfig.fport" label="图片上传接口" label-width="180">
  127. </u-field>
  128. </view>
  129. <view class="mqtt-btn-box">
  130. <u-button @click="" size="medium" type="success">确定</u-button>
  131. </view>
  132. </u-popup>
  133. </view>
  134. </template>
  135. <script>
  136. export default {
  137. data() {
  138. return {
  139. d_id: '',
  140. device_id:'',
  141. device_type:'',
  142. dsArr: ['关机', '开机'],
  143. dsIndex: 0,
  144. wsArr: ['待机', '工作'],
  145. wsIndex: 0,
  146. tsArr: [
  147. { value: 1, label: '时控触发' },
  148. { value: 0, label: '时控模式' },
  149. ],
  150. syArr:[
  151. { value: 1, label: '光控模式' },
  152. { value: 0, label: '时控模式' }
  153. ],
  154. tsIndex: 0,
  155. imgresArr: ['高', '中', '低'],
  156. imgresIndex: "",
  157. wsModelShow: false,
  158. equipContrlForm: {
  159. END_TIME: '',
  160. CONTROL: 0,
  161. DATT: 5,
  162. START_TIME: '',
  163. PHO_T: 5,
  164. P_DATT:1,
  165. TT: '',
  166. P_START:'',
  167. P_END:''
  168. },
  169. shikongLabel:'00:00-00:00',
  170. list: [{
  171. value: '00:00',
  172. label: '00:00'
  173. },
  174. {
  175. value: '01:00',
  176. label: '01:00'
  177. },
  178. {
  179. value: '02:00',
  180. label: '02:00'
  181. },
  182. {
  183. value: '03:00',
  184. label: '03:00'
  185. },
  186. {
  187. value: '04:00',
  188. label: '04:00'
  189. },
  190. {
  191. value: '05:00',
  192. label: '05:00'
  193. },
  194. {
  195. value: '06:00',
  196. label: '06:00'
  197. },
  198. {
  199. value: '07:00',
  200. label: '07:00'
  201. }, {
  202. value: '08:00',
  203. label: '08:00'
  204. },
  205. {
  206. value: '09:00',
  207. label: '09:00'
  208. },
  209. {
  210. value: '10:00',
  211. label: '10:00'
  212. },
  213. {
  214. value: '11:00',
  215. label: '11:00'
  216. },
  217. {
  218. value:'12:00',
  219. label: '12:00'
  220. },
  221. {
  222. value: '13:00',
  223. label: '13:00'
  224. },
  225. {
  226. value: '14:00',
  227. label: '14:00'
  228. }, {
  229. value: '15:00',
  230. label: '15:00'
  231. },
  232. {
  233. value: '16:00',
  234. label: '16:00'
  235. },
  236. {
  237. value: '17:00',
  238. label: '17:00'
  239. },
  240. {
  241. value: '18:00',
  242. label: '18:00'
  243. },
  244. {
  245. value: '19:00',
  246. label: '19:00'
  247. },
  248. {
  249. value: '20:00',
  250. label: '20:00'
  251. },
  252. {
  253. value: '21:00',
  254. label: '21:00'
  255. }, {
  256. value: '22:00',
  257. label: '22:00'
  258. },
  259. {
  260. value: '23:00',
  261. label: '23:00'
  262. },
  263. ],
  264. mqttShow: false,
  265. shikongshow:false,
  266. gkongLabel:'0h',
  267. gkongShow:false,
  268. mqttConfig: {
  269. muid: '',
  270. mpwd: '',
  271. mip: '',
  272. mport: '',
  273. mpub: '',
  274. msub: '',
  275. fuid: '',
  276. fpwd: '',
  277. fip: '',
  278. fport: ''
  279. },
  280. myuser_type: false,
  281. singleSelectList:[],
  282. dataSelectShow:false,
  283. currentFormKey:'',
  284. tsArrLabel:'时控模式',
  285. modeShow:false,
  286. syModeShow:false,
  287. submitBtnDisabled:false,
  288. photoShow:false,
  289. photoLabel:'00:00-00:00'
  290. }
  291. },
  292. computed:{
  293. gkongArr(){
  294. const list = []
  295. const count = 24
  296. for (let i = 0; i < count; i++) {
  297. list.push({
  298. value: i + 1 + '',
  299. label: i + 1 + 'h'
  300. })
  301. }
  302. return list
  303. },
  304. customStyle(){
  305. return {
  306. background: '#14A478',
  307. borderRadius:'90rpx',
  308. border:'none',
  309. color:'#fff'
  310. }
  311. },
  312. shikonglist(){
  313. return[
  314. [...this.list],
  315. [...this.list]
  316. ]
  317. },
  318. controlInfo(){
  319. const netControl = [{
  320. name: '数据单元重启',
  321. cmd: 'dtu_reboot'
  322. },
  323. {
  324. name: '数据单元升级',
  325. cmd: 'dtu_update'
  326. }]
  327. const forceControl = [
  328. {
  329. name: '控制单元重启',
  330. cmd: 'reboot'
  331. },
  332. {
  333. name: '控制单元升级',
  334. cmd: 'update'
  335. }
  336. ]
  337. const equipControl = [
  338. {
  339. name: '开启补光灯',
  340. cmd: 'led_on'
  341. },
  342. {
  343. name: '关闭补光灯',
  344. cmd: 'led_off'
  345. },
  346. {
  347. name: '测试拍照',
  348. cmd: 'takephoto'
  349. },
  350. {
  351. name: '翻版测试',
  352. cmd: 'FB_Test'
  353. }
  354. ]
  355. switch (this.device_type){
  356. case 32://天牛
  357. break;
  358. case 33:
  359. break;
  360. case 34:
  361. break;
  362. case 35:
  363. break;
  364. default:
  365. break;
  366. }
  367. return {
  368. netControl,forceControl,equipControl
  369. }
  370. }
  371. },
  372. onLoad(option) {
  373. this.d_id = option.d_id
  374. this.device_id = option.device_id
  375. this.device_type = option.device_type
  376. this.getInfo()
  377. uni.getStorage({
  378. key: "myuser_type",
  379. success: (res) => {
  380. if (Number(res.data) == 1) {
  381. this.myuser_type = true
  382. }
  383. }
  384. })
  385. },
  386. methods: {
  387. selectOperate(min,max,formKey){
  388. this.dataSelectShow = true
  389. this.singleSelectList = []
  390. for (let i = min; i < max; i+=5) {
  391. this.singleSelectList.push({
  392. value:i,
  393. label:i.toString()
  394. })
  395. }
  396. console.log(this.singleSelectList,'--')
  397. this.currentFormKey = formKey
  398. },
  399. tsArrConfirm(e){
  400. this.tsArrLabel = e[0].label
  401. this.equipContrlForm.CONTROL = e[0].value
  402. },
  403. gkArrConfirm(e){
  404. this.gkongLabel = e[0].label
  405. this.equipContrlForm.TT = e[0].value
  406. },
  407. dataconfirm(e){
  408. this.equipContrlForm[this.currentFormKey] = e[0].value
  409. },
  410. shikongconfirm(e){
  411. console.log(e)
  412. this.shikongLabel = e[0].label+'-'+e[1].label
  413. this.equipContrlForm.START_TIME = e[0].value
  414. this.equipContrlForm.END_TIME = e[1].value
  415. },
  416. photoConfirm(e){
  417. this.photoLabel = e[0].label+'-'+e[1].label
  418. this.equipContrlForm.P_START = e[0].value
  419. this.equipContrlForm.P_END = e[1].value
  420. },
  421. turnChange(e, a) {
  422. this.equipContrlForm.ts = e.target.value
  423. },
  424. async getInfo() {
  425. let res = await this.$myRequest({
  426. url: '/api/api_gateway?method=new_gateway.device_info.get_device_config',
  427. data: {
  428. device_type_id:this.device_type,
  429. id: this.d_id
  430. }
  431. })
  432. if(res.code==4000){
  433. this.submitBtnDisabled = true
  434. this.$refs.toast.show({
  435. title: res.msg,
  436. type: 'warning'
  437. })
  438. return
  439. }
  440. this.equipContrlForm = res
  441. this.photoLabel = (res.P_START||'00:00')+' - '+ (res.P_END||'00:00')
  442. this.shikongLabel = res.START_TIME + ':00' + ' - '+res.END_TIME + ':00'
  443. console.log(this.equipContrlForm)
  444. },
  445. async submit() {
  446. console.log(this.equipContrlForm)
  447. let res = await this.$myRequest({
  448. url: '/api/api_gateway?method=new_gateway.device_info.update_device_config',
  449. data: {
  450. device_type_id: this.device_type,
  451. id: this.d_id,
  452. ...this.equipContrlForm
  453. }
  454. })
  455. if(res){
  456. this.$refs.toast.show({
  457. title: '修改成功!',
  458. type: 'success',
  459. })
  460. }
  461. if(res.code==4000){
  462. this.$refs.toast.show({
  463. title: res.msg+'无法修改',
  464. type: 'warning'
  465. })
  466. }
  467. },
  468. async equipBtnControl(cmd) {
  469. let res = await this.$myRequest({
  470. url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
  471. data: {
  472. cmd,
  473. device_type_id: this.device_type,
  474. d_id: this.d_id
  475. }
  476. })
  477. if (res) {
  478. this.$refs.toast.show({
  479. title: '指令下发成功!',
  480. type: 'success',
  481. })
  482. }
  483. },
  484. async mqttInfo() {
  485. let res = await this.$myRequest({
  486. url: '/api/api_gateway?method=forecast.send_control.device_control_info',
  487. data: {
  488. cmd: 'netconf',
  489. d_id: this.d_id
  490. }
  491. })
  492. if (res) {
  493. let {
  494. ftp,
  495. mqtt
  496. } = res
  497. this.mqttConfig = {
  498. muid: mqtt.uid,
  499. mpwd: mqtt.pwd,
  500. mip: mqtt.ip,
  501. mport: mqtt.port,
  502. mpub: mqtt.pub,
  503. msub: mqtt.sub,
  504. fuid: ftp.uid,
  505. fpwd: ftp.pwd,
  506. fip: ftp.ip,
  507. fport: ftp.port
  508. }
  509. }
  510. this.mqttShow = true
  511. },
  512. async mqttSubm() {
  513. let obj = {
  514. mqtt: {
  515. uid: this.mqttConfig.muid,
  516. pwd: this.mqttConfig.mpwd,
  517. ip: this.mqttConfig.mip,
  518. port: this.mqttConfig.mport,
  519. pub: this.mqttConfig.mpub,
  520. sub: this.mqttConfig.msub,
  521. keepalive: 60,
  522. lastwill: '/yfkj/cbd/offline/'
  523. },
  524. ftp: {
  525. uid: this.mqttConfig.fuid,
  526. pwd: this.mqttConfig.fpwd,
  527. ip: this.mqttConfig.fip,
  528. port: this.mqttConfig.fport
  529. }
  530. }
  531. let res = await this.$myRequest({
  532. url: '/api/api_gateway?method=forecast.send_control.device_control',
  533. data: {
  534. device_type_id: 3,
  535. d_id: this.d_id,
  536. cmd: 'setnet',
  537. config: JSON.stringify(obj)
  538. }
  539. })
  540. }
  541. }
  542. }
  543. </script>
  544. <style lang="scss" scoped>
  545. page {
  546. padding: 20rpx;
  547. box-sizing: border-box;
  548. .tit {
  549. line-height: 30rpx;
  550. font-size: 28rpx;
  551. margin: 30rpx 0;
  552. color: #666666;
  553. }
  554. .adminTit {
  555. border-left-color: #e64340;
  556. }
  557. .btns {
  558. display: flex;
  559. justify-content: flex-start;
  560. flex-wrap: wrap;
  561. gap: 16rpx;
  562. button {
  563. margin: 0;
  564. margin-right: 10rpx;
  565. padding: 0 25rpx;
  566. }
  567. }
  568. .uni-list-cell {
  569. // background: #F7F8FA;
  570. // padding: 10rpx 40rpx;
  571. height: 80rpx;
  572. line-height: 80rpx;
  573. font-size: 28rpx;
  574. box-sizing: border-box;
  575. .arrow{
  576. margin-left: 30rpx;
  577. }
  578. .right-data{
  579. color: #CCCCCC;
  580. }
  581. }
  582. .selectTime {
  583. display: flex;
  584. float: right;
  585. width: 30%;
  586. color: #CCCCCC;
  587. justify-content: space-between;
  588. .time {
  589. // width: 350rpx;
  590. // display: flex;
  591. // justify-content: space-between;
  592. }
  593. .line {
  594. width: 50rpx;
  595. text-align: center;
  596. }
  597. }
  598. .submit-box {
  599. margin-top: 60rpx
  600. }
  601. .mqtt-popup {
  602. width: 580rpx;
  603. }
  604. .mqtt-btn-box {
  605. margin-top: 50rpx;
  606. text-align: center;
  607. }
  608. }
  609. </style>