Files
hht-doushan-uni/pages/manage/sb-point-manage.vue
2024-07-31 09:00:33 +08:00

79 lines
2.2 KiB
Vue

<template>
<view class="zd_container">
<nav-bar :title="title"></nav-bar>
<view class="zd_content">
<view class="zd_wrapper grid-wraper">
<view class="zd-row flexstart flexwrap">
<view class="zd-col-12 site_item" v-for="(e, i) in pointArr" :key="i" @tap="toCheck(e)">
<view class="site_item_box" :class="{'isChecked': pkId === e.device_code}">
<view class="point_title_1">{{e.device_name}}</view>
<view class="point_title_2">{{e.device_code}}</view>
</view>
</view>
</view>
</view>
</view>
<view class="zd-row submit-bar">
<button class="zd-col-7 button-primary button-primary1" :class="{'button-info': !pkId}" :disabled="disabled" @tap="_updateDeviceStatus('0')">禁止进入</button>
<button class="zd-col-7 button-primary button-primary2" :class="{'button-info': !pkId}" :disabled="disabled" @tap="_updateDeviceStatus('1')">允许进入</button>
<button class="zd-col-7 button-primary button-primary3" :class="{'button-info': !pkId}" :disabled="disabled" @tap="_updateDeviceStatus('2')">允许离开</button>
</view>
</view>
</template>
<script>
import NavBar from '@/components/NavBar.vue'
// import {queryDevices} from '@/utils/mork2.js'
import {queryDevices, updateDeviceStatus} from '@/utils/getData2.js'
export default {
components: {
NavBar
},
data() {
return {
title: '',
pointArr: [],
disabled: false,
pkId: ''
};
},
onLoad (options) {
this.title = options.title
},
created () {
this._queryDevices()
},
methods: {
async _queryDevices () {
let res = await queryDevices()
this.pointArr = [...res.data]
},
toCheck (e) {
this.pkId = this.pkId === e.device_code ? '' : e.device_code
},
async _updateDeviceStatus (type) {
this.disabled = true
if (!this.pkId) {
this.disabled = false
return
}
try {
let res = await updateDeviceStatus(this.pkId, type)
this.pkId = ''
this._queryDevices()
uni.showToast({
title: res.desc,
icon: 'none'
})
} catch (err) {
this.disabled = false
}
}
}
}
</script>
<style lang="stylus">
@import '../../common/style/mixin.styl';
</style>