2023-01-11 16:33:13 +08:00
|
|
|
<template>
|
2023-02-20 14:19:28 +08:00
|
|
|
<Cn-page :loading="loading" noPadding>
|
2023-08-03 14:51:36 +08:00
|
|
|
<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>
|
2023-01-13 16:32:56 +08:00
|
|
|
<view class="index">
|
2023-02-09 08:50:01 +08:00
|
|
|
<!-- 运维 -->
|
2023-07-06 14:24:03 +08:00
|
|
|
<YunWei :devCount="devCount" v-if="userInfo.authorities === 'operation_manager'" />
|
2023-02-09 08:50:01 +08:00
|
|
|
<!-- 专职 -->
|
2023-07-06 14:24:03 +08:00
|
|
|
<ZhuanZhi :devCount="devCount" v-if="userInfo.authorities === 'market_user'" />
|
2023-02-09 08:50:01 +08:00
|
|
|
<!-- 工程 -->
|
2023-07-06 14:24:03 +08:00
|
|
|
<GongCheng :devCount="devCount" v-if="userInfo.authorities === 'engineering_user'" />
|
2023-02-09 08:50:01 +08:00
|
|
|
<!-- 主用户 -->
|
2023-07-06 14:24:03 +08:00
|
|
|
<ZhuYongHu :devCount="devCount" v-if="userInfo.authorities === 'app_vip_user'" />
|
|
|
|
|
<YouKe :devCount="devCount" v-if="userInfo.authorities === 'tourist'"> </YouKe>
|
2023-08-03 14:51:36 +08:00
|
|
|
<view class="canneng-index-title mt20">设备列表</view>
|
2023-07-03 20:29:24 +08:00
|
|
|
<Device ref="device" :store="store" />
|
2023-01-13 16:32:56 +08:00
|
|
|
</view>
|
2023-08-03 14:51:36 +08:00
|
|
|
<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>
|
2023-01-13 13:23:25 +08:00
|
|
|
</view>
|
2023-02-23 08:44:46 +08:00
|
|
|
</Cn-page>
|
2023-01-11 16:33:13 +08:00
|
|
|
</template>
|
|
|
|
|
<script>
|
2023-05-24 08:58:48 +08:00
|
|
|
import YunWei from './comp/indexYunWei.vue'
|
|
|
|
|
import GongCheng from './comp/indexGongCheng.vue'
|
|
|
|
|
import ZhuYongHu from './comp/indexZhuYongHu.vue'
|
|
|
|
|
import ZhuanZhi from './comp/indexZhuanZhi.vue'
|
|
|
|
|
import YouKe from './comp/indexYouKe.vue'
|
2023-07-03 20:29:24 +08:00
|
|
|
import Device from './comp/device.vue'
|
2023-04-04 08:47:19 +08:00
|
|
|
import list from '../../common/js/list'
|
2023-07-06 14:24:03 +08:00
|
|
|
import { getDevCount } from '../../common/api/device.js'
|
2023-08-03 14:51:36 +08:00
|
|
|
import { queryEngineering } from '@/common/api/engineering.js'
|
|
|
|
|
import { pinyin } from 'pinyin-pro'
|
|
|
|
|
|
2023-01-13 13:23:25 +08:00
|
|
|
export default {
|
2023-04-04 08:47:19 +08:00
|
|
|
mixins: [list],
|
2023-02-09 08:50:01 +08:00
|
|
|
components: {
|
|
|
|
|
YunWei,
|
|
|
|
|
GongCheng,
|
|
|
|
|
ZhuYongHu,
|
2023-02-28 16:39:58 +08:00
|
|
|
ZhuanZhi,
|
2023-05-24 08:58:48 +08:00
|
|
|
YouKe,
|
2023-07-03 20:29:24 +08:00
|
|
|
Device,
|
2023-02-09 08:50:01 +08:00
|
|
|
},
|
2023-04-04 08:47:19 +08:00
|
|
|
data() {
|
2023-01-13 13:23:25 +08:00
|
|
|
return {
|
2023-07-03 20:29:24 +08:00
|
|
|
loading: false,
|
|
|
|
|
userInfo: {},
|
2023-07-06 14:24:03 +08:00
|
|
|
devCount: {},
|
2023-08-03 14:51:36 +08:00
|
|
|
select: {
|
|
|
|
|
engineeringName: '',
|
|
|
|
|
engineeringId: '',
|
|
|
|
|
},
|
|
|
|
|
engineeringList: [],
|
2023-02-09 08:50:01 +08:00
|
|
|
}
|
|
|
|
|
},
|
2023-08-03 14:51:36 +08:00
|
|
|
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
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-01-13 13:23:25 +08:00
|
|
|
methods: {
|
2023-08-03 14:51:36 +08:00
|
|
|
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()
|
|
|
|
|
},
|
2023-04-04 08:47:19 +08:00
|
|
|
send() {
|
2023-02-01 16:59:32 +08:00
|
|
|
uni.createPushMessage({
|
|
|
|
|
title: '灿能',
|
|
|
|
|
content: '灿能推送',
|
|
|
|
|
success: function (res) {
|
|
|
|
|
console.log('推送成功')
|
|
|
|
|
},
|
|
|
|
|
fail: function (res) {
|
|
|
|
|
console.log('推送失败')
|
2023-05-24 08:58:48 +08:00
|
|
|
},
|
2023-02-01 16:59:32 +08:00
|
|
|
})
|
|
|
|
|
},
|
2023-07-03 20:29:24 +08:00
|
|
|
loadingChange(e) {
|
|
|
|
|
this.loading = e
|
2023-04-04 09:14:20 +08:00
|
|
|
},
|
2023-08-03 14:51:36 +08:00
|
|
|
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()
|
|
|
|
|
},
|
2023-01-13 16:32:56 +08:00
|
|
|
},
|
2023-05-24 08:58:48 +08:00
|
|
|
onLoad() {
|
2023-07-03 20:29:24 +08:00
|
|
|
this.store = this.DataSource('/cs-device-boot/EquipmentDelivery/queryEquipmentByProject')
|
2023-02-09 08:50:01 +08:00
|
|
|
},
|
2023-04-04 08:47:19 +08:00
|
|
|
onShow() {
|
2023-02-23 08:44:46 +08:00
|
|
|
this.userInfo = uni.getStorageSync(this.$cacheKey.userInfo)
|
2023-07-03 20:29:24 +08:00
|
|
|
if (
|
|
|
|
|
this.userInfo.authorities === 'app_vip_user' ||
|
|
|
|
|
this.userInfo.authorities == 5 ||
|
|
|
|
|
this.userInfo.authorities === 'tourist'
|
|
|
|
|
) {
|
2023-02-23 08:44:46 +08:00
|
|
|
uni.setTabBarBadge({
|
|
|
|
|
index: 1,
|
2023-05-24 08:58:48 +08:00
|
|
|
text: '6',
|
2023-02-23 08:44:46 +08:00
|
|
|
})
|
|
|
|
|
}
|
2023-08-03 14:51:36 +08:00
|
|
|
this.init()
|
2023-05-24 08:58:48 +08:00
|
|
|
},
|
2023-01-13 13:23:25 +08:00
|
|
|
}
|
2023-01-11 16:33:13 +08:00
|
|
|
</script>
|
2023-01-13 16:32:56 +08:00
|
|
|
<style lang="scss">
|
|
|
|
|
.index {
|
2023-08-03 14:51:36 +08:00
|
|
|
padding: 20rpx 0 0;
|
|
|
|
|
}
|
|
|
|
|
.canneng-index-title {
|
|
|
|
|
padding: 0 20rpx;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
font-weight: 500;
|
2023-01-13 13:23:25 +08:00
|
|
|
}
|
2023-02-07 17:59:54 +08:00
|
|
|
/deep/ .uni-card {
|
|
|
|
|
background: $uni-theme-white;
|
|
|
|
|
}
|
2023-08-03 14:51:36 +08:00
|
|
|
|
|
|
|
|
/deep/ .uni-drawer__content {
|
|
|
|
|
width: 100vw !important;
|
|
|
|
|
}
|
2023-01-11 16:33:13 +08:00
|
|
|
</style>
|