Files
app-govern/pages/index/index.vue

281 lines
8.8 KiB
Vue
Raw Normal View History

2023-01-11 16:33:13 +08:00
<template>
2023-02-20 14:19:28 +08:00
<Cn-page :loading="loading" noPadding>
2023-01-13 16:32:56 +08:00
<view slot="body">
<view class="index">
2023-02-09 08:50:01 +08:00
<!-- 运维 -->
2023-04-04 08:47:19 +08:00
<YunWei v-if="userInfo.role == 1" :store="store" :projectList="projectList" :projectType="projectType" />
2023-02-09 08:50:01 +08:00
<!-- 专职 -->
2023-04-04 08:47:19 +08:00
<ZhuanZhi v-if="userInfo.role == 2" :store="store" :projectList="projectList" :projectType="projectType" />
2023-02-09 08:50:01 +08:00
<!-- 工程 -->
2023-05-24 08:58:48 +08:00
<GongCheng
v-if="userInfo.role == 3"
:store="store"
:gcList="gcList"
:projectList="projectList"
:projectType="projectType"
/>
2023-02-09 08:50:01 +08:00
<!-- 主用户 -->
2023-04-04 08:47:19 +08:00
<ZhuYongHu v-if="userInfo.role == 4" :store="store" :projectList="projectList" :projectType="projectType" />
2023-02-09 08:50:01 +08:00
<!-- 子用户 -->
2023-04-04 08:47:19 +08:00
<ZiYongHu v-if="userInfo.role == 5" :store="store" :projectList="projectList" :projectType="projectType" />
2023-02-28 16:39:58 +08:00
<YouKe v-if="userInfo.role == 6"> </YouKe>
2023-05-24 08:58:48 +08:00
<uni-fab ref="fab" direction="vertical" horizontal="right" vertical="bottom" :content="content" @trigger="trigger" />
2023-01-13 16:32:56 +08:00
</view>
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 ZiYongHu from './comp/indexZiYongHu.vue'
import ZhuanZhi from './comp/indexZhuanZhi.vue'
import YouKe from './comp/indexYouKe.vue'
2023-04-04 08:47:19 +08:00
import list from '../../common/js/list'
import { getProjectList } from '../../common/api/project'
2023-04-04 09:14:20 +08:00
import { queryDictData } from '../../common/api/dictionary'
2023-05-24 08:58:48 +08:00
import { queryEngineering } from '@/common/api/gc.js'
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,
ZiYongHu,
2023-02-28 16:39:58 +08:00
ZhuanZhi,
2023-05-24 08:58:48 +08:00
YouKe,
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-04-04 08:47:19 +08:00
loading: true,
2023-02-09 08:50:01 +08:00
userInfo: {
2023-05-24 08:58:48 +08:00
role: 4,
2023-04-04 08:47:19 +08:00
},
projectList: [],
2023-05-24 08:58:48 +08:00
gcList: [],
2023-04-04 08:47:19 +08:00
projectType: [
{
text: '全部类型',
2023-05-24 08:58:48 +08:00
value: 0,
2023-04-04 08:47:19 +08:00
},
{
text: '监测',
2023-05-24 08:58:48 +08:00
value: 1,
2023-04-04 08:47:19 +08:00
},
{
text: '用能',
2023-05-24 08:58:48 +08:00
value: 2,
2023-04-04 08:47:19 +08:00
},
{
text: '环境',
2023-05-24 08:58:48 +08:00
value: 3,
2023-04-04 08:47:19 +08:00
},
{
text: '安防',
2023-05-24 08:58:48 +08:00
value: 4,
2023-04-04 08:47:19 +08:00
},
{
text: '其他',
2023-05-24 08:58:48 +08:00
value: 5,
},
2023-04-04 08:47:19 +08:00
],
2023-02-09 08:50:01 +08:00
}
},
computed: {
2023-04-04 08:47:19 +08:00
content() {
2023-02-09 08:50:01 +08:00
let arr = [1, 3, 4]
2023-05-24 08:58:48 +08:00
let content = [
{
iconPath: '/static/mine3.png',
text: '运维管理',
},
{
iconPath: '/static/mine3.png',
text: '专职管理',
},
{
iconPath: '/static/mine3.png',
text: '工程',
},
{
iconPath: '/static/mine3.png',
text: '主用户',
},
{
iconPath: '/static/mine3.png',
text: '子用户',
},
{
iconPath: '/static/mine3.png',
text: '游客',
},
2023-02-06 13:34:15 +08:00
]
2023-02-09 08:50:01 +08:00
return content
2023-05-24 08:58:48 +08:00
},
2023-01-13 13:23:25 +08:00
},
methods: {
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-02-09 08:50:01 +08:00
2023-04-04 08:47:19 +08:00
trigger(e) {
2023-02-28 16:39:58 +08:00
if (e.index === 500) {
2023-02-06 13:34:15 +08:00
uni.navigateTo({
2023-05-24 08:58:48 +08:00
url: '/pages/device/new',
2023-02-06 13:34:15 +08:00
})
2023-02-09 08:50:01 +08:00
} else {
this.userInfo.role = e.index + 1
uni.setStorageSync('userInfo', {
2023-05-24 08:58:48 +08:00
role: e.index + 1,
2023-05-25 10:10:22 +08:00
id: 1,
2023-02-09 08:50:01 +08:00
})
let roleName = ''
switch (e.index + 1) {
case 1:
roleName = '运维管理'
2023-02-23 08:44:46 +08:00
uni.removeTabBarBadge({
2023-05-24 08:58:48 +08:00
index: 1,
2023-02-23 08:44:46 +08:00
})
2023-02-09 08:50:01 +08:00
break
case 2:
roleName = '专职管理'
2023-02-23 08:44:46 +08:00
uni.removeTabBarBadge({
2023-05-24 08:58:48 +08:00
index: 1,
2023-02-23 08:44:46 +08:00
})
2023-02-09 08:50:01 +08:00
break
case 3:
roleName = '工程'
2023-02-23 08:44:46 +08:00
uni.removeTabBarBadge({
2023-05-24 08:58:48 +08:00
index: 1,
2023-02-23 08:44:46 +08:00
})
2023-02-09 08:50:01 +08:00
break
case 4:
roleName = '主用户'
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-02-09 08:50:01 +08:00
break
case 5:
roleName = '子用户'
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-02-09 08:50:01 +08:00
break
2023-02-28 16:39:58 +08:00
case 6:
roleName = '游客'
uni.setTabBarBadge({
index: 1,
2023-05-24 08:58:48 +08:00
text: '6',
2023-02-28 16:39:58 +08:00
})
break
2023-02-09 08:50:01 +08:00
}
this.$util.toast(roleName + '角色切换成功')
2023-02-06 13:34:15 +08:00
}
2023-02-09 08:50:01 +08:00
this.$refs.fab.close()
2023-04-04 08:47:19 +08:00
},
init() {
this.store = this.DataSource('/EquipmentDelivery/queryEquipmentByProject')
this.store.reload()
this.store.firstCallBack = () => {
this.loading = false
2023-05-24 08:58:48 +08:00
console.log(this.store)
2023-04-04 08:47:19 +08:00
}
},
getProjectList() {
getProjectList({
2023-07-03 09:16:54 +08:00
pageNum: 1,
2023-05-24 08:58:48 +08:00
pageSize: 9999,
}).then((res) => {
2023-04-04 08:47:19 +08:00
console.log(res)
2023-05-24 08:58:48 +08:00
let arr = [
{
text: '全部项目',
value: '-1',
},
...res.data.records.map((item) => {
return {
text: item.name,
value: item.id,
2023-07-03 09:16:54 +08:00
...item,
2023-05-24 08:58:48 +08:00
}
}),
]
arr.forEach((item) => {
if (this.projectList.findIndex((item2) => item2.value == item.value) === -1) {
this.projectList.push(item)
2023-04-04 08:47:19 +08:00
}
2023-05-24 08:58:48 +08:00
})
})
},
getGcList() {
queryEngineering().then((res) => {
this.gcList = res.data
2023-04-04 08:47:19 +08:00
})
2023-04-04 09:14:20 +08:00
},
queryDictData() {
2023-05-24 08:58:48 +08:00
queryDictData('项目类型').then((res) => {
this.projectType = [
{
text: '全部类型',
value: '',
},
...res.data.map((item) => {
return {
text: item.anotherName,
value: item.id,
}
}),
]
2023-04-04 09:14:20 +08:00
})
},
2023-01-13 16:32:56 +08:00
},
2023-05-24 08:58:48 +08:00
onLoad() {
2023-04-04 08:47:19 +08:00
this.init()
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)
if (!this.userInfo) {
this.userInfo = {
2023-05-24 08:58:48 +08:00
role: 4,
2023-05-25 10:10:22 +08:00
id: 1,
2023-02-23 08:44:46 +08:00
}
uni.setStorageSync('userInfo', {
2023-04-10 09:48:03 +08:00
role: 4,
2023-05-24 08:58:48 +08:00
id: 1,
2023-02-23 08:44:46 +08:00
})
}
2023-02-28 16:39:58 +08:00
if (this.userInfo.role == 4 || this.userInfo.role == 5 || this.userInfo.role == 6) {
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-05-24 08:58:48 +08:00
this.getProjectList()
if (this.userInfo.role == 3) {
this.getGcList()
}
},
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-02-20 14:19:28 +08:00
padding: 34rpx 0 0;
2023-01-13 13:23:25 +08:00
}
2023-02-07 17:59:54 +08:00
/deep/ .uni-card {
background: $uni-theme-white;
}
2023-01-11 16:33:13 +08:00
</style>