|
|
@@ -15,61 +15,95 @@
|
|
|
<uni-section title="工作台" type="line"></uni-section>
|
|
|
<view class="grid-body">
|
|
|
<uni-grid :column="3" :showBorder="false" >
|
|
|
- <uni-grid-item>
|
|
|
- <view class="grid-item-box" @click="goPage('user')" v-if="hasRole('admin')">
|
|
|
- <uni-icons type="person-filled" color="#2979ff" size="28"></uni-icons>
|
|
|
+ <uni-grid-item v-if="hasRole(['admin'])">
|
|
|
+ <view class="grid-item-box" @click="goPage('user')">
|
|
|
+ <u--image :showLoading="true" src="/static/images/icons/user.png" width="50rpx" height="50rpx" ></u--image>
|
|
|
<text class="text">客户列表</text>
|
|
|
</view>
|
|
|
</uni-grid-item>
|
|
|
- <uni-grid-item>
|
|
|
+ <uni-grid-item v-if="hasRole(['companymgr'])">
|
|
|
<view class="grid-item-box" @click="goPage('device')">
|
|
|
- <uni-icons type="cloud-upload" color="#2979ff" size="28"></uni-icons>
|
|
|
- <text class="text">设备查看</text>
|
|
|
+ <u--image :showLoading="true" src="/static/images/icons/device.png" width="50rpx" height="50rpx" ></u--image>
|
|
|
+ <text class="text">设备列表</text>
|
|
|
</view>
|
|
|
</uni-grid-item>
|
|
|
<uni-grid-item>
|
|
|
<view class="grid-item-box" @click="goPage('wifi')">
|
|
|
- <u-icon name="wifi" color="#2979ff" size="28"></u-icon>
|
|
|
+ <u--image :showLoading="true" src="/static/images/icons/wifi.png" width="50rpx" height="50rpx" ></u--image>
|
|
|
<text class="text">设备配网</text>
|
|
|
</view>
|
|
|
</uni-grid-item>
|
|
|
-
|
|
|
- <uni-grid-item>
|
|
|
+ <uni-grid-item v-if="hasRole(['admin'])">
|
|
|
<view class="grid-item-box" @click="goPage('scan')">
|
|
|
- <u-icon name="scan" color="#2979ff" size="28"></u-icon>
|
|
|
- <text class="text">扫码绑定</text>
|
|
|
+ <u--image :showLoading="true" src="/static/images/icons/code.png" width="50rpx" height="50rpx" ></u--image>
|
|
|
+ <text class="text">绑码激活</text>
|
|
|
</view>
|
|
|
</uni-grid-item>
|
|
|
- <uni-grid-item>
|
|
|
- <view class="grid-item-box" @click="goPage('scan')">
|
|
|
- <u-icon name="scan" color="#2979ff" size="28"></u-icon>
|
|
|
- <text class="text">扫码激活</text>
|
|
|
+
|
|
|
+
|
|
|
+ <uni-grid-item v-if="hasRole(['companymgr'])">
|
|
|
+ <view class="grid-item-box" @click="scanCode()">
|
|
|
+ <u--image :showLoading="true" src="/static/images/icons/scan.png" width="50rpx" height="50rpx" ></u--image>
|
|
|
+ <text class="text">用户绑定</text>
|
|
|
</view>
|
|
|
</uni-grid-item>
|
|
|
+
|
|
|
<uni-grid-item>
|
|
|
- <view class="grid-item-box" @click="goPage('scan')">
|
|
|
- <u-icon name="scan" color="#2979ff" size="28"></u-icon>
|
|
|
- <text class="text">设备报警</text>
|
|
|
+ <view class="grid-item-box" @click="watchDevice()">
|
|
|
+ <u--image :showLoading="true" src="/static/images/icons/scan.png" width="50rpx" height="50rpx" ></u--image>
|
|
|
+ <text class="text">查看设备</text>
|
|
|
</view>
|
|
|
</uni-grid-item>
|
|
|
- <uni-grid-item>
|
|
|
- <view class="grid-item-box" @click="goPage('scan')">
|
|
|
- <u-icon name="scan" color="#2979ff" size="28"></u-icon>
|
|
|
- <text class="text">设备报警</text>
|
|
|
+
|
|
|
+ <uni-grid-item v-if="hasRole(['companymgr'])">
|
|
|
+ <view class="grid-item-box" @click="goPage('alert')">
|
|
|
+ <u--image :showLoading="true" src="/static/images/icons/alert.png" width="50rpx" height="50rpx" ></u--image>
|
|
|
+ <text class="text">设备告警</text>
|
|
|
+ </view>
|
|
|
+ </uni-grid-item>
|
|
|
+
|
|
|
+ <uni-grid-item v-if="hasRole(['companymgr'])">
|
|
|
+ <view class="grid-item-box" @click="goPage('error')">
|
|
|
+ <u--image :showLoading="true" src="/static/images/icons/error.png" width="50rpx" height="50rpx" ></u--image>
|
|
|
+ <text class="text">异常列表</text>
|
|
|
+ </view>
|
|
|
+ </uni-grid-item>
|
|
|
+
|
|
|
+ <uni-grid-item v-if="hasRole(['admin'])">
|
|
|
+ <view class="grid-item-box" @click="scanCode()">
|
|
|
+ <u--image :showLoading="true" src="/static/images/icons/scan.png" width="50rpx" height="50rpx" ></u--image>
|
|
|
+ <text class="text">注销设备</text>
|
|
|
</view>
|
|
|
</uni-grid-item>
|
|
|
+
|
|
|
</uni-grid>
|
|
|
+
|
|
|
+ <u-modal :show="show" title="绑定设备" :showCancelButton="true" @confirm="bingDevice" >
|
|
|
+ <view class="slot-content">
|
|
|
+
|
|
|
+ <view>设备名称:{{ scanDevice.deviceName }}</view>
|
|
|
+ <view>产品名称:{{ scanDevice.productName }}</view>
|
|
|
+ <view>设备编号:{{ scanDevice.serialNumber }}</view>
|
|
|
+ <view>激活日期:{{ scanDevice.activeTime }}</view>
|
|
|
+
|
|
|
+ </view>
|
|
|
+ </u-modal>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import authObj from '@/plugins/auth.js';
|
|
|
+import {getDevcieByQrcode,bingDeviceDept} from '@/api/device/device';
|
|
|
+import UImage from "../../uni_modules/uview-ui/components/u--image/u--image";
|
|
|
export default {
|
|
|
- data() {
|
|
|
+ components: {UImage},
|
|
|
+ data() {
|
|
|
return {
|
|
|
current: 0,
|
|
|
swiperDotIndex: 0,
|
|
|
+ show:false,
|
|
|
+ scanDevice:{},
|
|
|
data: [{
|
|
|
image: '/static/images/banner/banner01.jpg'
|
|
|
},
|
|
|
@@ -83,11 +117,26 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ bingDevice(){
|
|
|
+ this.show = false;
|
|
|
+ bingDeviceDept(this.scanDevice).then(res=>{
|
|
|
+ if(res.code == 200){
|
|
|
+ this.$modal.showToast('绑定成功')
|
|
|
+ }else{
|
|
|
+ this.$modal.showToast(res.msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ cancel(){
|
|
|
+ this.scanDevice = {};
|
|
|
+ this.show = false;
|
|
|
+ },
|
|
|
clickBannerItem(item) {
|
|
|
console.log();
|
|
|
},
|
|
|
hasRole(role){
|
|
|
- return authObj.hasRole(role);
|
|
|
+ return authObj.authRoleAdmin(role);
|
|
|
},
|
|
|
changeSwiper(e) {
|
|
|
this.current = e.detail.current
|
|
|
@@ -95,6 +144,46 @@ export default {
|
|
|
changeGrid(e) {
|
|
|
this.$modal.showToast('模块建设中~')
|
|
|
},
|
|
|
+ watchDevice(){
|
|
|
+ let self = this;
|
|
|
+ uni.scanCode({
|
|
|
+ success: function (res) {
|
|
|
+ console.log('条码内容:' + res.result);
|
|
|
+ getDevcieByQrcode(res.result).then(res=>{
|
|
|
+ let device = res.data;
|
|
|
+ if(device != null){
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/device/detail?id='+device.deviceId
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ self.$modal.showToast('设备不存在或无权限')
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ scanCode(){
|
|
|
+ let self = this;
|
|
|
+ uni.scanCode({
|
|
|
+ success: function (res) {
|
|
|
+ console.log('条码内容:' + res.result);
|
|
|
+ getDevcieByQrcode(res.result).then(res=>{
|
|
|
+ let device = res.data;
|
|
|
+ if(!device){
|
|
|
+ self.$modal.showToast('未查到设备信息')
|
|
|
+ }else{
|
|
|
+ if(device.deptId != null){
|
|
|
+ self.$modal.showToast('该设备已经绑定了用户')
|
|
|
+ }else{
|
|
|
+ self.scanDevice = device;
|
|
|
+ self.show = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
goPage(path){
|
|
|
if('device' == path){
|
|
|
uni.navigateTo({
|
|
|
@@ -116,6 +205,17 @@ export default {
|
|
|
url: '/pages/user/index'
|
|
|
});
|
|
|
}
|
|
|
+ if('alert' == path){
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/device/alert'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if('error' == path){
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/device/error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|