machineItemManage.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view>
  3. <view class="option-box">
  4. <view class="option-time ddflex">
  5. <view>更新时间: {{time}}</view>
  6. <view class="refresh ddflex" @click="getState()">
  7. <image src="../../static/pages/images/refresh.png"></image>
  8. <text>刷新</text>
  9. </view>
  10. </view>
  11. <view class="ddflex state">
  12. <view class="ddflex">
  13. <view>仓位状态:</view>
  14. <view style="color: #A8A5A5;">{{doorInfo.boxEnable==1?'启用':'禁用'}}</view>
  15. </view>
  16. <switch style="transform: scale(0.7);" :checked="doorInfo.boxEnable" color="#FF753A" @change="boxEnableChange"></switch>
  17. </view>
  18. </view>
  19. <view class="note">关闭后,仓门将禁用,用户无法打开</view>
  20. <view style="height: 165rpx;" class="savepadding"></view>
  21. <view class="bottom-btns savepadding">
  22. <view class="btn" @click="open">一键开门</view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. const app = getApp();
  28. const req = require("../../utils/request.js");
  29. const utils = require("../../utils/util");
  30. export default {
  31. components: {},
  32. props: {},
  33. data() {
  34. return {
  35. id:null,//仓门id
  36. devId:null,//机柜id
  37. doorInfo:{},
  38. time:''
  39. }
  40. },
  41. async onLoad(options) {
  42. this.id = options.id
  43. this.devId = options.devId
  44. await this.getState()
  45. },
  46. onShow() {
  47. },
  48. methods: {
  49. getState(){
  50. return new Promise((r,j)=>{
  51. uni.showLoading({
  52. title:'加载中'
  53. })
  54. req.getRequest('/admin/v2/door/info',{devId:this.devId,doorId:this.id},res=>{
  55. this.doorInfo = res
  56. this.time = utils.formatTime(new Date()).t1
  57. uni.hideLoading()
  58. })
  59. })
  60. },
  61. boxEnableChange(event){
  62. this.doorInfo.boxEnable = event.detail.value
  63. uni.showModal({
  64. title:'提示',
  65. content:event.detail.value?'确定启用该仓门?':'确定禁用该仓门?',
  66. success: (r) => {
  67. if(r.confirm){
  68. uni.showLoading({
  69. title:event.detail.value?'启用中':'禁用中',
  70. })
  71. req.postRequest('/admin/v2/cab/ableDoor',{devId:this.devId,doorId:this.id,cabEnable:event.detail.value?1:0},res=>{
  72. uni.hideLoading()
  73. if(res){
  74. req.msg(event.detail.value?'启用成功':'禁用成功')
  75. }else {
  76. req.msg(event.detail.value?'启用失败':'禁用失败')
  77. this.doorInfo.boxEnable = !this.doorInfo.boxEnable
  78. }
  79. })
  80. }else{
  81. this.doorInfo.boxEnable = !this.doorInfo.boxEnable
  82. }
  83. }
  84. })
  85. },
  86. open(){
  87. uni.showLoading({
  88. title:'开门中',
  89. })
  90. req.postRequest('/admin/v2/cab/openDoor',{devId:this.devId,doorId:this.id},res=>{
  91. uni.hideLoading()
  92. if(res){
  93. req.msg('操作成功')
  94. }else {
  95. req.msg('操作失败')
  96. }
  97. })
  98. }
  99. },
  100. mounted() {
  101. },
  102. onPageScroll: function(e) {
  103. }
  104. }
  105. </script>
  106. <style>
  107. @import "./machineItemManage.css";
  108. </style>