| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <template>
- <view>
- <view class="option-box">
- <view class="option-time ddflex">
- <view>更新时间: {{time}}</view>
- <view class="refresh ddflex" @click="getState()">
- <image src="../../static/pages/images/refresh.png"></image>
- <text>刷新</text>
- </view>
- </view>
- <view class="ddflex state">
- <view class="ddflex">
- <view>仓位状态:</view>
- <view style="color: #A8A5A5;">{{doorInfo.boxEnable==1?'启用':'禁用'}}</view>
- </view>
- <switch style="transform: scale(0.7);" :checked="doorInfo.boxEnable" color="#FF753A" @change="boxEnableChange"></switch>
- </view>
- </view>
- <view class="note">关闭后,仓门将禁用,用户无法打开</view>
-
-
- <view style="height: 165rpx;" class="savepadding"></view>
- <view class="bottom-btns savepadding">
- <view class="btn" @click="open">一键开门</view>
- </view>
- </view>
- </template>
- <script>
- const app = getApp();
- const req = require("../../utils/request.js");
- const utils = require("../../utils/util");
- export default {
- components: {},
- props: {},
- data() {
- return {
- id:null,//仓门id
- devId:null,//机柜id
- doorInfo:{},
- time:''
- }
- },
- async onLoad(options) {
- this.id = options.id
- this.devId = options.devId
- await this.getState()
- },
- onShow() {
-
- },
- methods: {
- getState(){
- return new Promise((r,j)=>{
- uni.showLoading({
- title:'加载中'
- })
- req.getRequest('/admin/v2/door/info',{devId:this.devId,doorId:this.id},res=>{
- this.doorInfo = res
- this.time = utils.formatTime(new Date()).t1
- uni.hideLoading()
- })
- })
- },
- boxEnableChange(event){
- this.doorInfo.boxEnable = event.detail.value
- uni.showModal({
- title:'提示',
- content:event.detail.value?'确定启用该仓门?':'确定禁用该仓门?',
- success: (r) => {
- if(r.confirm){
- uni.showLoading({
- title:event.detail.value?'启用中':'禁用中',
- })
- req.postRequest('/admin/v2/cab/ableDoor',{devId:this.devId,doorId:this.id,cabEnable:event.detail.value?1:0},res=>{
- uni.hideLoading()
- if(res){
- req.msg(event.detail.value?'启用成功':'禁用成功')
- }else {
- req.msg(event.detail.value?'启用失败':'禁用失败')
- this.doorInfo.boxEnable = !this.doorInfo.boxEnable
- }
- })
- }else{
- this.doorInfo.boxEnable = !this.doorInfo.boxEnable
- }
-
- }
- })
- },
- open(){
- uni.showLoading({
- title:'开门中',
- })
- req.postRequest('/admin/v2/cab/openDoor',{devId:this.devId,doorId:this.id},res=>{
- uni.hideLoading()
- if(res){
- req.msg('操作成功')
- }else {
- req.msg('操作失败')
- }
- })
- }
- },
- mounted() {
-
- },
- onPageScroll: function(e) {
-
- }
- }
- </script>
- <style>
- @import "./machineItemManage.css";
- </style>
|