2023-07-03 20:29:24 +08:00
|
|
|
<template>
|
|
|
|
|
<view class="device">
|
2023-08-23 16:22:08 +08:00
|
|
|
<view class="nav" :style="{ top: navTabHeight + 'px' }">
|
2023-08-03 14:51:36 +08:00
|
|
|
<!-- <view class="nav-menu" :class="{ 'nav-menu-active': select.engineeringName }" @click="openDrawer"
|
2023-07-03 20:29:24 +08:00
|
|
|
>{{ select.engineeringName || '工程' }}
|
2023-08-03 14:51:36 +08:00
|
|
|
</view> -->
|
2023-07-24 08:47:20 +08:00
|
|
|
<picker
|
|
|
|
|
@change="projectNameChange"
|
2023-08-11 11:03:31 +08:00
|
|
|
@cancel="selectProject = false"
|
2023-07-24 08:47:20 +08:00
|
|
|
:value="select.projectNameIndex"
|
|
|
|
|
:range="projectList"
|
|
|
|
|
range-key="text"
|
2023-08-03 14:51:36 +08:00
|
|
|
v-if="store.params.engineerId"
|
2023-07-24 08:47:20 +08:00
|
|
|
>
|
2023-08-11 11:03:31 +08:00
|
|
|
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectName }" @click="selectProject = true">
|
|
|
|
|
{{
|
|
|
|
|
select.projectName
|
|
|
|
|
? select.projectName.length > 4
|
|
|
|
|
? select.projectName.substring(0, 4) + '...'
|
|
|
|
|
: select.projectName
|
|
|
|
|
: '全部项目'
|
|
|
|
|
}}
|
|
|
|
|
<uni-icons
|
|
|
|
|
type="top"
|
|
|
|
|
size="14"
|
|
|
|
|
:color="select.projectName ? '#376cf3' : '#666'"
|
|
|
|
|
v-if="selectProject"
|
|
|
|
|
></uni-icons>
|
|
|
|
|
<uni-icons
|
|
|
|
|
type="bottom"
|
|
|
|
|
size="14"
|
|
|
|
|
:color="select.projectName ? '#376cf3' : '#666'"
|
|
|
|
|
v-else
|
|
|
|
|
></uni-icons>
|
2023-07-03 20:29:24 +08:00
|
|
|
</view>
|
|
|
|
|
</picker>
|
2023-08-10 09:18:17 +08:00
|
|
|
<view style="flex: 1"></view>
|
|
|
|
|
<template v-if="deviceListFilter.length">
|
|
|
|
|
<template v-if="transfer || share">
|
2023-08-23 16:22:08 +08:00
|
|
|
<view class="nav-menu nav-menu-btn" @click="cancel">取消</view>
|
|
|
|
|
<view class="nav-menu nav-menu-btn" @click="submit">确定</view>
|
2023-08-10 09:18:17 +08:00
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<view
|
|
|
|
|
class="nav-menu nav-menu-btn"
|
2023-08-23 16:22:08 +08:00
|
|
|
@click="selectDevice('transfer')"
|
2023-08-10 09:18:17 +08:00
|
|
|
v-if="userInfo.authorities === 'app_vip_user' || userInfo.authorities === 'engineering_user'"
|
2023-08-23 16:22:08 +08:00
|
|
|
>移交
|
2023-08-10 09:18:17 +08:00
|
|
|
</view>
|
|
|
|
|
<view
|
|
|
|
|
class="nav-menu nav-menu-btn"
|
2023-08-23 16:22:08 +08:00
|
|
|
@click="selectDevice('share')"
|
2023-08-10 09:18:17 +08:00
|
|
|
v-if="userInfo.authorities === 'app_vip_user'"
|
2023-08-23 16:22:08 +08:00
|
|
|
>分享
|
2023-08-10 09:18:17 +08:00
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
</template>
|
2023-07-03 20:29:24 +08:00
|
|
|
<!-- <picker @change="projectTypeChange" :value="select.projectTypeIndex" :range="projectType" range-key="text">
|
|
|
|
|
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectType }"
|
|
|
|
|
>{{ select.projectType || '类型' }}
|
2023-08-24 15:35:45 +08:00
|
|
|
</view>
|
2023-07-03 20:29:24 +08:00
|
|
|
</picker> -->
|
|
|
|
|
</view>
|
|
|
|
|
<view class="content device" :style="{ minHeight: minHeight }">
|
2023-09-06 10:56:10 +08:00
|
|
|
<Cn-device-card v-for="(item, index) in deviceListFilter" :device="item" :key="index">
|
2023-08-10 09:18:17 +08:00
|
|
|
<template v-slot:title v-if="transfer || share">
|
2023-09-06 10:56:10 +08:00
|
|
|
<!-- 卡片标题 -->
|
|
|
|
|
<view class="uni-card__header">
|
|
|
|
|
<view class="uni-card__header-box">
|
|
|
|
|
<view class="uni-card__header-avatar">
|
|
|
|
|
<image class="uni-card__header-avatar-image" :src="deviceIcon(item.runStatus)"
|
|
|
|
|
mode="aspectFit"/>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="uni-card__header-content">
|
|
|
|
|
<text class="uni-card__header-content-title uni-ellipsis">
|
|
|
|
|
{{ item.equipmentName }}
|
|
|
|
|
</text>
|
|
|
|
|
<text class="uni-card__header-content-subtitle uni-ellipsis">
|
|
|
|
|
{{ item.mac }}
|
|
|
|
|
</text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="uni-card__header-extra" style="position: relative">
|
|
|
|
|
<switch
|
|
|
|
|
:checked="checkList.indexOf(item.equipmentId) > -1"
|
|
|
|
|
style="transform: scale(0.8);position: relative;left: 20rpx;"
|
|
|
|
|
@change="switchChange(item)"
|
|
|
|
|
/>
|
|
|
|
|
</view>
|
2023-08-10 09:18:17 +08:00
|
|
|
</view>
|
|
|
|
|
</template>
|
2023-09-06 10:56:10 +08:00
|
|
|
</Cn-device-card>
|
2023-07-03 20:29:24 +08:00
|
|
|
<uni-load-more
|
2023-08-10 09:18:17 +08:00
|
|
|
v-if="store.status == 'loading' || deviceListFilter.length > 0"
|
2023-07-03 20:29:24 +08:00
|
|
|
:status="store.status"
|
|
|
|
|
></uni-load-more>
|
2023-08-10 09:18:17 +08:00
|
|
|
<Cn-empty v-else></Cn-empty>
|
2023-07-03 20:29:24 +08:00
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
2023-08-23 16:22:08 +08:00
|
|
|
import {getProjectList} from '@/common/api/project'
|
|
|
|
|
import {queryDictData} from '@/common/api/dictionary'
|
|
|
|
|
|
2023-07-03 20:29:24 +08:00
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
store: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: {},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
loading: false,
|
2023-08-10 09:18:17 +08:00
|
|
|
transfer: false,
|
|
|
|
|
share: false,
|
|
|
|
|
checkList: [],
|
2023-07-03 20:29:24 +08:00
|
|
|
select: {
|
|
|
|
|
projectName: '',
|
|
|
|
|
projectNameIndex: 0,
|
|
|
|
|
projectType: '',
|
|
|
|
|
projectTypeIndex: 0,
|
|
|
|
|
},
|
2023-08-23 16:22:08 +08:00
|
|
|
minHeight: 0,
|
|
|
|
|
navTabHeight: 0,
|
2023-07-03 20:29:24 +08:00
|
|
|
engineeringList: [],
|
|
|
|
|
projectList: [],
|
|
|
|
|
projectType: [],
|
2023-08-10 09:18:17 +08:00
|
|
|
userInfo: {},
|
2023-08-11 11:03:31 +08:00
|
|
|
selectProject: false,
|
2023-07-03 20:29:24 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
deviceListFilter() {
|
2023-08-23 16:22:08 +08:00
|
|
|
let arr = this.store.data.filter((item) => {
|
2023-07-03 20:29:24 +08:00
|
|
|
if (this.select.projectName && this.select.projectType) {
|
|
|
|
|
return item.project === this.select.projectName && item.type === this.select.projectType
|
|
|
|
|
} else if (this.select.projectName) {
|
|
|
|
|
return item.projectId === this.projectList[this.select.projectNameIndex].id
|
|
|
|
|
} else if (this.select.projectType) {
|
|
|
|
|
return item.projectType === this.projectType[this.select.projectTypeIndex].id
|
|
|
|
|
} else {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-08-23 16:22:08 +08:00
|
|
|
if (this.transfer || this.share) {
|
|
|
|
|
return arr.filter((item) => {
|
|
|
|
|
return item.isPrimaryUser === '1'
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
return arr
|
|
|
|
|
}
|
2023-07-03 20:29:24 +08:00
|
|
|
},
|
|
|
|
|
},
|
2023-08-10 09:18:17 +08:00
|
|
|
created() {
|
|
|
|
|
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
|
2023-08-23 16:22:08 +08:00
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
|
|
|
|
|
|
2023-07-03 20:29:24 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2023-08-23 16:22:08 +08:00
|
|
|
selectDevice(type) {
|
|
|
|
|
if (this.deviceListFilter.findIndex(item => item.isPrimaryUser === '1') === -1) {
|
|
|
|
|
this.$util.toast('没有可操作的设备')
|
|
|
|
|
} else {
|
|
|
|
|
this[type] = true
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-08-10 09:18:17 +08:00
|
|
|
deviceIcon(e) {
|
|
|
|
|
let str = ''
|
|
|
|
|
switch (e) {
|
|
|
|
|
case 1:
|
|
|
|
|
str = '/static/device_bad.png'
|
|
|
|
|
break
|
|
|
|
|
case 2:
|
|
|
|
|
str = '/static/device.png'
|
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
|
str = '/static/device.png'
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
return str
|
|
|
|
|
},
|
|
|
|
|
switchChange(e) {
|
|
|
|
|
console.log(e)
|
|
|
|
|
let index = this.checkList.indexOf(e.equipmentId)
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
this.checkList.splice(index, 1)
|
|
|
|
|
} else {
|
|
|
|
|
this.checkList.push(e.equipmentId)
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-08-23 16:22:08 +08:00
|
|
|
cancel() {
|
|
|
|
|
this.transfer = false
|
|
|
|
|
this.share = false
|
|
|
|
|
this.checkList = []
|
|
|
|
|
},
|
2023-08-10 09:18:17 +08:00
|
|
|
submit() {
|
|
|
|
|
console.log(this.checkList)
|
2023-08-23 16:22:08 +08:00
|
|
|
if (this.checkList.length === 0) {
|
|
|
|
|
this.$util.toast('请选择设备')
|
|
|
|
|
return
|
|
|
|
|
}
|
2023-08-10 09:18:17 +08:00
|
|
|
if (this.transfer) {
|
2023-08-23 16:22:08 +08:00
|
|
|
uni.navigateTo({url: '/pages/device/transfer?id=' + this.checkList.join(',')})
|
2023-08-10 09:18:17 +08:00
|
|
|
} else if (this.share) {
|
2023-08-23 16:22:08 +08:00
|
|
|
uni.navigateTo({url: '/pages/device/share?id=' + this.checkList.join(',')})
|
2023-08-10 09:18:17 +08:00
|
|
|
}
|
2023-08-23 16:22:08 +08:00
|
|
|
this.cancel()
|
2023-08-10 09:18:17 +08:00
|
|
|
},
|
2023-07-31 09:00:30 +08:00
|
|
|
async init() {
|
2023-08-23 16:22:08 +08:00
|
|
|
console.warn('init')
|
2023-07-31 09:00:30 +08:00
|
|
|
this.getProjectList()
|
|
|
|
|
this.getDeviceList()
|
2023-07-03 20:29:24 +08:00
|
|
|
},
|
|
|
|
|
getDeviceList() {
|
2023-08-23 16:22:08 +08:00
|
|
|
this.store.params.pageSize = 50
|
|
|
|
|
this.store.firstCallBack = (res) => {
|
2023-08-10 09:18:17 +08:00
|
|
|
uni.createSelectorQuery()
|
2023-08-23 16:22:08 +08:00
|
|
|
.select('.uni-navbar')
|
|
|
|
|
.boundingClientRect((rect1) => {
|
|
|
|
|
if (!rect1) return
|
|
|
|
|
this.navTabHeight = rect1.height
|
|
|
|
|
uni.createSelectorQuery()
|
|
|
|
|
.select('.nav')
|
|
|
|
|
.boundingClientRect((rect2) => {
|
|
|
|
|
if (!rect2) return
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
this.minHeight = 'calc(100vh - ' + (this.navTabHeight + rect2.height + 50) + 'px)'
|
|
|
|
|
// #endif
|
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
|
this.minHeight = 'calc(100vh - ' + (this.navTabHeight + rect2.height) + 'px)'
|
|
|
|
|
console.log(this.minHeight)
|
|
|
|
|
// #endif
|
|
|
|
|
})
|
|
|
|
|
.exec()
|
2023-08-10 09:18:17 +08:00
|
|
|
})
|
|
|
|
|
.exec()
|
|
|
|
|
}
|
2023-07-03 20:29:24 +08:00
|
|
|
this.store.reload()
|
|
|
|
|
},
|
|
|
|
|
getProjectList() {
|
|
|
|
|
getProjectList({
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 9999,
|
2023-08-03 14:51:36 +08:00
|
|
|
engineeringId: this.store.params.engineerId,
|
2023-07-03 20:29:24 +08:00
|
|
|
}).then((res) => {
|
|
|
|
|
console.log(res)
|
|
|
|
|
let arr = [
|
|
|
|
|
{
|
|
|
|
|
text: '全部项目',
|
|
|
|
|
value: '-1',
|
|
|
|
|
},
|
|
|
|
|
...res.data.records.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
text: item.name,
|
|
|
|
|
value: item.id,
|
|
|
|
|
...item,
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
]
|
|
|
|
|
this.projectList = arr
|
2023-09-06 10:56:10 +08:00
|
|
|
uni.setStorageSync('projectList', arr)
|
2023-07-03 20:29:24 +08:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
queryDictData() {
|
|
|
|
|
queryDictData('项目类型').then((res) => {
|
|
|
|
|
this.projectType = [
|
|
|
|
|
{
|
|
|
|
|
text: '全部类型',
|
|
|
|
|
value: '',
|
|
|
|
|
},
|
|
|
|
|
...res.data.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
text: item.anotherName,
|
|
|
|
|
value: item.id,
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
submitFeedBack() {
|
2023-08-23 16:22:08 +08:00
|
|
|
uni.navigateTo({url: '/pages/home/feedback'})
|
2023-07-03 20:29:24 +08:00
|
|
|
},
|
|
|
|
|
projectTypeChange(e) {
|
|
|
|
|
this.select.projectTypeIndex = e.detail.value
|
|
|
|
|
if (e.detail.value === 0) {
|
|
|
|
|
this.select.projectType = ''
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.select.projectType = this.projectType[e.detail.value].text
|
|
|
|
|
},
|
|
|
|
|
projectNameChange(e) {
|
2023-08-11 11:03:31 +08:00
|
|
|
this.selectProject = false
|
2023-07-03 20:29:24 +08:00
|
|
|
console.log(e)
|
|
|
|
|
this.select.projectNameIndex = e.detail.value
|
|
|
|
|
if (e.detail.value === 0) {
|
|
|
|
|
this.select.projectName = ''
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.select.projectName = this.projectList[e.detail.value].text
|
|
|
|
|
},
|
|
|
|
|
registerDevice() {
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '请选择设备类型',
|
2023-08-24 15:35:45 +08:00
|
|
|
confirmText: '直连设备',
|
2023-07-03 20:29:24 +08:00
|
|
|
cancelText: '网关接入',
|
|
|
|
|
cancelColor: '#007aff',
|
2023-08-23 16:22:08 +08:00
|
|
|
success: ({confirm, cancel}) => {
|
2023-07-03 20:29:24 +08:00
|
|
|
if (confirm) {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/device/new',
|
|
|
|
|
})
|
|
|
|
|
} else if (cancel) {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/gateway/list',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
registerGateway() {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/gateway/new',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
navMenuClick(index) {
|
|
|
|
|
this.navMenuActive = index
|
|
|
|
|
},
|
|
|
|
|
jump(item) {
|
|
|
|
|
uni.navigateTo({
|
2023-07-31 09:00:30 +08:00
|
|
|
url: '/pages/device/APF/detail?id=' + item.equipmentId + '&isPrimaryUser=' + item.isPrimaryUser,
|
2023-07-03 20:29:24 +08:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2023-08-10 09:18:17 +08:00
|
|
|
<style lang="scss">
|
2023-08-23 16:22:08 +08:00
|
|
|
|
2023-08-10 09:18:17 +08:00
|
|
|
</style>
|