首页标题
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
<template>
|
||||
<view class="device">
|
||||
<view class="nav">
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': select.engineeringName }" @click="openDrawer"
|
||||
<view class="nav" :style="{ top: navHeight + 'px' }">
|
||||
<!-- <view class="nav-menu" :class="{ 'nav-menu-active': select.engineeringName }" @click="openDrawer"
|
||||
>{{ select.engineeringName || '工程' }}
|
||||
</view>
|
||||
</view> -->
|
||||
<picker
|
||||
@change="projectNameChange"
|
||||
:value="select.projectNameIndex"
|
||||
:range="projectList"
|
||||
range-key="text"
|
||||
v-if="engineeringList.length"
|
||||
v-if="store.params.engineerId"
|
||||
>
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectName }"
|
||||
>{{ select.projectName || '项目' }}
|
||||
<view class="nav-menu" :class="{ 'nav-menu-active': select.projectName }">
|
||||
{{ select.projectName || '项目' }}
|
||||
<uni-icons type="bottom" size="14" color="#666"></uni-icons>
|
||||
</view>
|
||||
</picker>
|
||||
<!-- <picker @change="projectTypeChange" :value="select.projectTypeIndex" :range="projectType" range-key="text">
|
||||
@@ -40,21 +41,11 @@
|
||||
:status="store.status"
|
||||
></uni-load-more>
|
||||
</view>
|
||||
<uni-drawer ref="showRight" mode="right" :mask-click="false" :width="375">
|
||||
<uni-indexed-list
|
||||
:options="engineeringListFilter"
|
||||
:showSelect="false"
|
||||
@click="closeDrawer"
|
||||
></uni-indexed-list>
|
||||
</uni-drawer>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { getProjectList } from '@/common/api/project'
|
||||
import { queryDictData } from '@/common/api/dictionary'
|
||||
import { queryEngineering } from '@/common/api/engineering.js'
|
||||
import { pinyin } from 'pinyin-pro'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
store: {
|
||||
@@ -70,35 +61,15 @@ export default {
|
||||
projectNameIndex: 0,
|
||||
projectType: '',
|
||||
projectTypeIndex: 0,
|
||||
engineeringName: '',
|
||||
engineeringId: '',
|
||||
},
|
||||
navHeight: 0,
|
||||
minHeight: '',
|
||||
engineeringList: [],
|
||||
projectList: [],
|
||||
projectType: [],
|
||||
navHeight: 0,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
engineeringListFilter() {
|
||||
let result = []
|
||||
this.engineeringList.forEach((item) => {
|
||||
let arr = pinyin(item.name[0], { toneType: 'none', type: 'array' })
|
||||
let letter = arr[0][0].toUpperCase()
|
||||
console.log(letter)
|
||||
let index = result.findIndex((item) => item.letter === letter)
|
||||
if (index === -1) {
|
||||
result.push({
|
||||
letter,
|
||||
data: [item.name],
|
||||
})
|
||||
} else {
|
||||
result[index].data.push(item.name)
|
||||
}
|
||||
})
|
||||
return result
|
||||
},
|
||||
deviceListFilter() {
|
||||
return this.store.data.filter((item) => {
|
||||
if (this.select.projectName && this.select.projectType) {
|
||||
@@ -113,61 +84,46 @@ export default {
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.init()
|
||||
},
|
||||
mounted() {
|
||||
setTimeout(() => {
|
||||
// 获取nav高度
|
||||
uni.createSelectorQuery()
|
||||
.select('.nav')
|
||||
.boundingClientRect((rect) => {
|
||||
this.navHeight = rect.height
|
||||
// #ifdef H5
|
||||
this.minHeight = 'calc(100vh - env(safe-area-inset-bottom) - ' + (50 + this.navHeight) + 'px)'
|
||||
// #endif
|
||||
// #ifdef APP-PLUS
|
||||
this.minHeight = 'calc(100vh - ' + this.navHeight + 'px)'
|
||||
// #endif
|
||||
.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()
|
||||
})
|
||||
.exec()
|
||||
}, 1000)
|
||||
},
|
||||
methods: {
|
||||
async init() {
|
||||
let engineering = uni.getStorageSync('engineering')
|
||||
let res = await queryEngineering()
|
||||
this.engineeringList = res.data
|
||||
if (this.engineeringList.length === 0) {
|
||||
return
|
||||
}
|
||||
if (!engineering) {
|
||||
uni.setStorageSync('engineering', res.data[0])
|
||||
this.select.engineeringName = res.data[0].name
|
||||
this.select.engineeringId = res.data[0].id
|
||||
} else {
|
||||
if (this.engineeringList.findIndex((item) => item.id === engineering.id) === -1) {
|
||||
uni.setStorageSync('engineering', res.data[0])
|
||||
this.select.engineeringName = res.data[0].name
|
||||
this.select.engineeringId = res.data[0].id
|
||||
}else{
|
||||
this.select.engineeringName = engineering.name
|
||||
this.select.engineeringId = engineering.id
|
||||
}
|
||||
}
|
||||
this.getProjectList()
|
||||
this.getDeviceList()
|
||||
},
|
||||
getDeviceList() {
|
||||
this.store.params.pageSize = 999
|
||||
this.store.params.engineerId = this.select.engineeringId
|
||||
this.store.reload()
|
||||
},
|
||||
getProjectList() {
|
||||
getProjectList({
|
||||
pageNum: 1,
|
||||
pageSize: 9999,
|
||||
engineeringId: this.select.engineeringId,
|
||||
engineeringId: this.store.params.engineerId,
|
||||
}).then((res) => {
|
||||
console.log(res)
|
||||
let arr = [
|
||||
@@ -202,37 +158,6 @@ export default {
|
||||
]
|
||||
})
|
||||
},
|
||||
closeDrawer(e) {
|
||||
console.log(e)
|
||||
this.engineeringList.forEach((item) => {
|
||||
if (item.name === e.item.name) {
|
||||
uni.setStorageSync('engineering', item)
|
||||
this.select.engineeringName = item.name
|
||||
this.select.engineeringId = item.id
|
||||
}
|
||||
})
|
||||
this.getDeviceList()
|
||||
this.getProjectList()
|
||||
this.select.projectName = ''
|
||||
this.select.projectNameIndex = 0
|
||||
this.$refs.showRight.close()
|
||||
},
|
||||
openDrawer(item) {
|
||||
if (this.engineeringList.length === 0) {
|
||||
uni.showToast({
|
||||
title: '暂无工程',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
} else if (this.engineeringList.length === 1) {
|
||||
uni.showToast({
|
||||
title: '暂无其他工程',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
this.$refs.showRight.open()
|
||||
},
|
||||
submitFeedBack() {
|
||||
uni.navigateTo({ url: '/pages/home/feedback' })
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user