2023-07-03 20:29:24 +08:00
|
|
|
<template>
|
|
|
|
|
<view class="device">
|
2023-08-03 14:51:36 +08:00
|
|
|
<view class="nav" :style="{ top: navHeight + 'px' }">
|
|
|
|
|
<!-- <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"
|
|
|
|
|
: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-03 14:51:36 +08:00
|
|
|
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectName }">
|
|
|
|
|
{{ select.projectName || '项目' }}
|
|
|
|
|
<uni-icons type="bottom" size="14" color="#666"></uni-icons>
|
2023-07-03 20:29:24 +08:00
|
|
|
</view>
|
|
|
|
|
</picker>
|
|
|
|
|
<!-- <picker @change="projectTypeChange" :value="select.projectTypeIndex" :range="projectType" range-key="text">
|
|
|
|
|
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectType }"
|
|
|
|
|
>{{ select.projectType || '类型' }}
|
|
|
|
|
</view>
|
|
|
|
|
</picker> -->
|
|
|
|
|
</view>
|
|
|
|
|
<view class="content device" :style="{ minHeight: minHeight }">
|
|
|
|
|
<uni-card
|
|
|
|
|
:title="item.equipmentName"
|
|
|
|
|
:sub-title="item.projectName"
|
|
|
|
|
:extra="item.projectType"
|
|
|
|
|
padding="0"
|
|
|
|
|
v-for="(item, index) in deviceListFilter"
|
|
|
|
|
:key="index"
|
|
|
|
|
@click="jump(item)"
|
|
|
|
|
thumbnail="/static/device.png"
|
|
|
|
|
>
|
|
|
|
|
<!-- <text>{{ item.project }} {{ item.type }}</text> -->
|
|
|
|
|
</uni-card>
|
|
|
|
|
<Cn-empty v-if="store.empty || deviceListFilter.length == 0"></Cn-empty>
|
|
|
|
|
<uni-load-more
|
|
|
|
|
v-if="deviceListFilter && deviceListFilter.length > 0"
|
|
|
|
|
:status="store.status"
|
|
|
|
|
></uni-load-more>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import { getProjectList } from '@/common/api/project'
|
|
|
|
|
import { queryDictData } from '@/common/api/dictionary'
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
store: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: {},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
loading: false,
|
|
|
|
|
select: {
|
|
|
|
|
projectName: '',
|
|
|
|
|
projectNameIndex: 0,
|
|
|
|
|
projectType: '',
|
|
|
|
|
projectTypeIndex: 0,
|
|
|
|
|
},
|
|
|
|
|
minHeight: '',
|
|
|
|
|
engineeringList: [],
|
|
|
|
|
projectList: [],
|
|
|
|
|
projectType: [],
|
2023-08-03 14:51:36 +08:00
|
|
|
navHeight: 0,
|
2023-07-03 20:29:24 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
deviceListFilter() {
|
|
|
|
|
return this.store.data.filter((item) => {
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
// 获取nav高度
|
|
|
|
|
uni.createSelectorQuery()
|
2023-08-03 14:51:36 +08:00
|
|
|
.select('.uni-navbar')
|
|
|
|
|
.boundingClientRect((rect1) => {
|
|
|
|
|
this.navHeight = rect1.height
|
|
|
|
|
// 获取nav高度
|
|
|
|
|
uni.createSelectorQuery()
|
|
|
|
|
.select('.nav')
|
|
|
|
|
.boundingClientRect((rect2) => {
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
this.minHeight =
|
|
|
|
|
'calc(100vh - env(safe-area-inset-bottom) - ' +
|
|
|
|
|
(50 + (rect2.height + rect1.height)) +
|
|
|
|
|
'px)'
|
|
|
|
|
// #endif
|
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
|
this.minHeight = 'calc(100vh - ' + (rect2.height + rect1.height) + 'px)'
|
|
|
|
|
// #endif
|
|
|
|
|
})
|
|
|
|
|
.exec()
|
2023-07-03 20:29:24 +08:00
|
|
|
})
|
|
|
|
|
.exec()
|
|
|
|
|
}, 1000)
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2023-07-31 09:00:30 +08:00
|
|
|
async init() {
|
|
|
|
|
this.getProjectList()
|
|
|
|
|
this.getDeviceList()
|
2023-07-03 20:29:24 +08:00
|
|
|
},
|
|
|
|
|
getDeviceList() {
|
|
|
|
|
this.store.params.pageSize = 999
|
|
|
|
|
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
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
queryDictData() {
|
|
|
|
|
queryDictData('项目类型').then((res) => {
|
|
|
|
|
this.projectType = [
|
|
|
|
|
{
|
|
|
|
|
text: '全部类型',
|
|
|
|
|
value: '',
|
|
|
|
|
},
|
|
|
|
|
...res.data.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
text: item.anotherName,
|
|
|
|
|
value: item.id,
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
submitFeedBack() {
|
|
|
|
|
uni.navigateTo({ url: '/pages/home/feedback' })
|
|
|
|
|
},
|
|
|
|
|
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) {
|
|
|
|
|
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: '请选择设备类型',
|
|
|
|
|
confirmText: '直连装置',
|
|
|
|
|
cancelText: '网关接入',
|
|
|
|
|
cancelColor: '#007aff',
|
|
|
|
|
success: ({ confirm, cancel }) => {
|
|
|
|
|
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>
|
|
|
|
|
<style lang="scss"></style>
|