Files
app-govern/pages/project/detail.vue

356 lines
12 KiB
Vue
Raw Normal View History

2023-02-20 14:19:28 +08:00
<template>
2023-05-25 10:10:22 +08:00
<Cn-page :loading="loading" noPadding>
<view slot="body">
<view class="detail">
2023-02-20 14:19:28 +08:00
<view class="header">
2023-05-25 10:10:22 +08:00
<view class="header-title"
>{{ project.name }}
<!-- <view class="header-title-extra">用能</view> -->
2023-02-28 14:03:38 +08:00
</view>
2023-05-25 10:10:22 +08:00
<view class="header-des">{{ project.description }}</view>
2023-02-20 14:19:28 +08:00
</view>
<view class="nav">
2023-05-25 10:10:22 +08:00
<view
class="nav-menu"
:class="{ 'nav-menu-active': navMenuActive == index }"
v-for="(item, index) in navMenuList"
:key="index"
@click="navMenuClick(index)"
>{{ item.text }}
2023-02-20 14:19:28 +08:00
</view>
</view>
2023-02-23 08:44:46 +08:00
<view class="content device" :style="{ minHeight: 'calc(100vh - ' + navHeight + 'px)' }">
2023-02-20 14:19:28 +08:00
<view v-show="navMenuActive == 0">
2023-05-25 10:10:22 +08:00
<uni-card
:title="item.equipmentName"
2023-08-17 09:24:59 +08:00
:sub-title="'创建时间:' + item.createTime"
2023-05-25 10:10:22 +08:00
v-for="item in store.data"
:key="item.equipmentId"
2023-07-24 08:47:20 +08:00
@click="goDevice(item)"
2023-05-25 10:10:22 +08:00
padding="0"
2023-08-11 11:03:31 +08:00
:thumbnail="deviceIcon(item.runStatus)"
2023-05-25 10:10:22 +08:00
>
2023-02-20 14:19:28 +08:00
</uni-card>
2023-05-25 10:10:22 +08:00
<Cn-empty v-if="store.empty"></Cn-empty>
2023-07-24 08:47:20 +08:00
<uni-load-more
v-if="store.data && store.data.length > 0"
:status="store.status"
></uni-load-more>
2023-02-20 14:19:28 +08:00
</view>
<view style="padding: 0 20rpx" v-show="navMenuActive == 1">
<uni-list>
2023-07-24 08:47:20 +08:00
<uni-list-item
title="张三"
note="2023-02-10 14:55"
thumb="/static/head.png"
thumb-size="lg"
>
2023-02-20 14:19:28 +08:00
</uni-list-item>
2023-07-24 08:47:20 +08:00
<uni-list-item
title="李四"
note="2023-02-10 14:55"
thumb="/static/head.png"
thumb-size="lg"
>
2023-02-20 14:19:28 +08:00
</uni-list-item>
</uni-list>
</view>
2023-03-30 09:04:07 +08:00
<view style="padding: 0 20rpx" v-show="navMenuActive == 2">
2023-05-25 10:10:22 +08:00
<!-- <image
class="gplot gplot-box"
mode="aspectFill"
:src="item.filePath"
v-for="(item, key) in topologyDiagramPage"
:key="key"
/> -->
<uni-file-picker
2023-07-03 09:16:54 +08:00
ref="filePicker"
2023-05-25 10:10:22 +08:00
v-model="topologyDiagramPage"
:sourceType="['album']"
2023-07-03 09:16:54 +08:00
:auto-upload="false"
2023-05-25 10:10:22 +08:00
@select="addAppTopologyDiagram"
@delete="deleteTopologyDiagramPage"
2023-07-24 08:47:20 +08:00
readonly
2023-05-25 10:10:22 +08:00
></uni-file-picker>
2023-03-30 09:04:07 +08:00
</view>
2023-02-20 14:19:28 +08:00
</view>
2023-05-25 10:10:22 +08:00
<uni-fab
ref="fab"
direction="vertical"
horizontal="right"
vertical="bottom"
:content="content"
@trigger="trigger"
2023-08-10 09:18:17 +08:00
v-if="content.length"
2023-05-25 10:10:22 +08:00
/>
2023-02-23 08:44:46 +08:00
<uni-popup ref="share" type="share" background-color="#fff">
<uni-popup-share title="分享到"></uni-popup-share>
</uni-popup>
2023-02-20 14:19:28 +08:00
</view>
</view>
</Cn-page>
</template>
<script>
2023-05-25 10:10:22 +08:00
import list from '../../common/js/list'
2023-07-31 09:00:30 +08:00
import {
queryTopologyDiagramPage,
deleteAppTopologyDiagram,
addAppTopologyDiagram,
deleteProject,
} from '../../common/api/project'
2023-02-20 14:19:28 +08:00
export default {
2023-05-25 10:10:22 +08:00
mixins: [list],
data() {
2023-02-20 14:19:28 +08:00
return {
loading: false,
2023-05-25 10:10:22 +08:00
project: {},
navMenuList: [
{
text: '设备',
},
{
2023-08-10 09:18:17 +08:00
text: '用户',
2023-05-25 10:10:22 +08:00
},
{
text: '拓扑图',
},
],
2023-02-28 14:03:38 +08:00
content: [],
2023-02-23 08:44:46 +08:00
navHeight: 0,
2023-05-25 10:10:22 +08:00
navMenuActive: 0,
topologyDiagramPage: [],
2023-02-20 14:19:28 +08:00
}
},
methods: {
2023-08-11 11:03:31 +08:00
deviceIcon(e) {
let str = ''
switch (e) {
case 1:
str = '/static/device_bad.png'
break
case 2:
str = '/static/device.png'
break
default:
str = '/static/device.png'
break
}
return str
},
2023-05-25 10:10:22 +08:00
addAppTopologyDiagram(e) {
console.log(e)
addAppTopologyDiagram(
{
projectId: this.project.id,
topologyDiagramName: e.tempFiles[0].name,
},
2023-07-24 08:47:20 +08:00
e.tempFiles[0].path,
2023-05-25 10:10:22 +08:00
).then((res) => {
console.log(res)
2023-07-03 09:16:54 +08:00
if (res.length > 1) {
const result = JSON.parse(res[1].data)
console.log(result)
if (result.code === 'A0000') {
this.topologyDiagramPage.push({
name: result.name,
extname: 'img',
url: result.filePath,
...result,
})
} else {
this.$refs.filePicker.clearFiles(this.topologyDiagramPage.length - 1)
uni.showToast({
title: result.message,
icon: 'none',
})
}
} else {
uni.showToast({
title: '上传失败',
icon: 'none',
})
this.$refs.filePicker.clearFiles(this.topologyDiagramPage.length - 1)
}
2023-05-25 10:10:22 +08:00
})
},
deleteTopologyDiagramPage(e) {
console.log(e)
deleteAppTopologyDiagram(e.tempFile.id).then((res) => {
console.log(res)
})
},
trigger(e) {
console.log(this.$refs)
2023-02-28 14:03:38 +08:00
if (e.item.text == '移交') {
uni.navigateTo({
2023-05-25 10:10:22 +08:00
url: '/pages/project/transfer',
2023-02-28 14:03:38 +08:00
})
} else if (e.item.text == '分享') {
this.$refs.share.open()
2023-07-24 08:47:20 +08:00
} else if (e.item.text == '编辑') {
uni.navigateTo({
url: '/pages/project/new?project=' + encodeURIComponent(JSON.stringify(this.project)),
})
2023-07-31 09:00:30 +08:00
} else if (e.item.text == '删除') {
uni.showModal({
title: '提示',
content: '删除项目后不可恢复,是否继续?',
success: (res) => {
if (res.confirm) {
deleteProject(this.project.id).then((res) => {
this.$util.toast('删除成功')
this.$util.refreshPrePage()
})
} else if (res.cancel) {
console.log('用户点击取消')
}
},
})
2023-02-28 14:03:38 +08:00
}
2023-02-23 08:44:46 +08:00
},
2023-05-25 10:10:22 +08:00
navMenuClick(index) {
2023-02-20 14:19:28 +08:00
this.navMenuActive = index
},
2023-05-25 10:10:22 +08:00
goUserDetail() {
2023-02-20 14:19:28 +08:00
uni.navigateTo({
2023-05-25 10:10:22 +08:00
url: '/pages/mine/userDetail',
2023-02-20 14:19:28 +08:00
})
},
2023-05-25 10:10:22 +08:00
del() {
console.log('del')
2023-02-20 14:19:28 +08:00
uni.showModal({
title: '提示',
content: '确定要移除该成员吗?',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
2023-05-25 10:10:22 +08:00
},
2023-02-20 14:19:28 +08:00
})
2023-02-23 08:44:46 +08:00
},
2023-07-24 08:47:20 +08:00
goDevice(item) {
2023-02-23 08:44:46 +08:00
uni.navigateTo({
2023-07-24 08:47:20 +08:00
url: '/pages/device/APF/detail?id=' + item.equipmentId,
2023-02-23 08:44:46 +08:00
})
},
2023-05-25 10:10:22 +08:00
init() {
2023-07-03 20:29:24 +08:00
this.store = this.DataSource('/cs-device-boot/EquipmentDelivery/queryEquipmentByProject')
2023-05-25 10:10:22 +08:00
this.store.params.projectId = this.project.id
this.store.reload()
2023-02-23 08:44:46 +08:00
2023-05-25 10:10:22 +08:00
queryTopologyDiagramPage({
projectId: this.project.id,
}).then((res) => {
console.log(res)
this.topologyDiagramPage = res.data.records.map((item) => {
return {
name: item.name,
extname: 'img',
url: item.filePath,
...item,
}
})
})
},
2023-02-20 14:19:28 +08:00
},
2023-05-25 10:10:22 +08:00
onLoad(option) {
2023-02-28 14:03:38 +08:00
let userInfo = uni.getStorageSync('userInfo')
2023-08-10 09:18:17 +08:00
// this.content.push({
// iconPath: '/static/share.png',
// text: '编辑',
// })
// this.content.push({
// iconPath: '/static/delate.png',
// text: '删除',
// })
// this.content.push({
// iconPath: '/static/transfer.png',
// text: '移交',
// })
// this.content.push({
// iconPath: '/static/share.png',
// text: '分享',
// })
if (userInfo.authorities == 'engineering_user' || userInfo.authorities == 'app_vip_user') {
this.content.push(
{
iconPath: '/static/share.png',
text: '编辑',
},
{
iconPath: '/static/delate.png',
text: '删除',
},
)
2023-02-28 14:03:38 +08:00
}
2023-02-20 14:19:28 +08:00
setTimeout(() => {
// 获取nav高度
2023-05-25 10:10:22 +08:00
uni.createSelectorQuery()
.select('.nav')
.boundingClientRect((rect) => {
this.navHeight = rect.height
})
.exec()
}, 1000)
2023-07-24 08:47:20 +08:00
console.log(option.project)
this.project = JSON.parse(decodeURIComponent(option.project))
2023-05-25 10:10:22 +08:00
this.init()
2023-02-20 14:19:28 +08:00
// uni.setNavigationBarTitle({ title: this.project })
2023-05-25 10:10:22 +08:00
},
2023-02-20 14:19:28 +08:00
}
</script>
2023-05-25 10:10:22 +08:00
<style lang="scss">
2023-02-20 14:19:28 +08:00
.detail {
.content {
box-sizing: border-box;
padding-bottom: 20rpx;
}
.header {
padding: 20rpx 20rpx 0;
.header-title {
2023-02-28 14:03:38 +08:00
display: flex;
justify-content: space-between;
align-items: center;
2023-02-20 14:19:28 +08:00
font-size: 40rpx;
margin-bottom: 10rpx;
2023-02-28 14:03:38 +08:00
.header-title-extra {
font-size: 24rpx;
color: #666;
padding-right: 10rpx;
}
2023-02-20 14:19:28 +08:00
}
.header-des {
font-size: 28rpx;
color: #666;
}
}
.footer-btn {
padding: 0 20rpx;
height: 50rpx;
background-color: #007aff;
font-size: 24rpx;
color: #fff;
text-align: center;
line-height: 50rpx;
border-radius: 10rpx;
}
2023-05-25 10:10:22 +08:00
/deep/ .is-add {
background-color: #fff;
}
2023-02-20 14:19:28 +08:00
}
2023-03-30 09:04:07 +08:00
.gplot {
2023-05-25 10:10:22 +08:00
box-sizing: border-box;
2023-03-30 09:04:07 +08:00
position: relative;
width: 100%;
border: 8rpx solid #ccc;
}
2023-05-25 10:10:22 +08:00
</style>