首页标题
This commit is contained in:
@@ -1,6 +1,24 @@
|
||||
<template>
|
||||
<Cn-page :loading="loading" noPadding>
|
||||
<view slot="body">
|
||||
<view slot="body" class="canneng-index">
|
||||
<uni-nav-bar
|
||||
rightWidth="300rpx"
|
||||
leftWidth="300rpx"
|
||||
dark
|
||||
:fixed="true"
|
||||
status-bar
|
||||
background-color="#376cf3"
|
||||
color="#fff"
|
||||
@clickRight="openDrawer"
|
||||
>
|
||||
<template slot="left">
|
||||
<text style="font-size: 32rpx; font-weight: 500">灿能物联</text>
|
||||
</template>
|
||||
<template slot="right">
|
||||
<text class="hide-txt mr5" style="font-size: 28rpx">{{ select.engineeringName }}</text>
|
||||
<uni-icons type="bottom" size="16" color="#fff"></uni-icons>
|
||||
</template>
|
||||
</uni-nav-bar>
|
||||
<view class="index">
|
||||
<!-- 运维 -->
|
||||
<YunWei :devCount="devCount" v-if="userInfo.authorities === 'operation_manager'" />
|
||||
@@ -11,8 +29,20 @@
|
||||
<!-- 主用户 -->
|
||||
<ZhuYongHu :devCount="devCount" v-if="userInfo.authorities === 'app_vip_user'" />
|
||||
<YouKe :devCount="devCount" v-if="userInfo.authorities === 'tourist'"> </YouKe>
|
||||
<view class="canneng-index-title mt20">设备列表</view>
|
||||
<Device ref="device" :store="store" />
|
||||
</view>
|
||||
<uni-drawer ref="showRight" mode="right" :mask-click="false">
|
||||
<uni-nav-bar :fixed="true" status-bar title="选择工程" color="#111"> </uni-nav-bar>
|
||||
<view style="height: 200px"></view>
|
||||
<view>
|
||||
<uni-indexed-list
|
||||
:options="engineeringListFilter"
|
||||
:showSelect="false"
|
||||
@click="closeDrawer"
|
||||
></uni-indexed-list>
|
||||
</view>
|
||||
</uni-drawer>
|
||||
</view>
|
||||
</Cn-page>
|
||||
</template>
|
||||
@@ -25,6 +55,9 @@ import YouKe from './comp/indexYouKe.vue'
|
||||
import Device from './comp/device.vue'
|
||||
import list from '../../common/js/list'
|
||||
import { getDevCount } from '../../common/api/device.js'
|
||||
import { queryEngineering } from '@/common/api/engineering.js'
|
||||
import { pinyin } from 'pinyin-pro'
|
||||
|
||||
export default {
|
||||
mixins: [list],
|
||||
components: {
|
||||
@@ -40,9 +73,76 @@ export default {
|
||||
loading: false,
|
||||
userInfo: {},
|
||||
devCount: {},
|
||||
select: {
|
||||
engineeringName: '',
|
||||
engineeringId: '',
|
||||
},
|
||||
engineeringList: [],
|
||||
}
|
||||
},
|
||||
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
|
||||
},
|
||||
},
|
||||
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.store.params.engineerId = this.select.engineeringId
|
||||
getDevCount(this.select.engineeringId).then((res) => {
|
||||
this.devCount = res.data
|
||||
})
|
||||
this.$refs.device && this.$refs.device.init()
|
||||
},
|
||||
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.store.params.engineerId = item.id
|
||||
}
|
||||
})
|
||||
this.$refs.device.select.projectName = ''
|
||||
this.$refs.device.select.projectNameIndex = 0
|
||||
this.$refs.device.init()
|
||||
this.$refs.showRight.close()
|
||||
},
|
||||
send() {
|
||||
uni.createPushMessage({
|
||||
title: '灿能',
|
||||
@@ -58,14 +158,25 @@ export default {
|
||||
loadingChange(e) {
|
||||
this.loading = e
|
||||
},
|
||||
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()
|
||||
},
|
||||
},
|
||||
onLoad() {
|
||||
this.store = this.DataSource('/cs-device-boot/EquipmentDelivery/queryEquipmentByProject')
|
||||
this.store.firstCallBack = () => {
|
||||
getDevCount(this.store.params.engineerId).then((res) => {
|
||||
this.devCount = res.data
|
||||
})
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
|
||||
@@ -79,16 +190,24 @@ export default {
|
||||
text: '6',
|
||||
})
|
||||
}
|
||||
this.$refs.device && this.$refs.device.init()
|
||||
this.init()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.index {
|
||||
padding: 34rpx 0 0;
|
||||
padding: 20rpx 0 0;
|
||||
}
|
||||
.canneng-index-title {
|
||||
padding: 0 20rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/deep/ .uni-card {
|
||||
background: $uni-theme-white;
|
||||
}
|
||||
|
||||
/deep/ .uni-drawer__content {
|
||||
width: 100vw !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user