equip-set-new.vue 12 KB

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