Files
jnpf_app/components/CommonPane/indexSystem.vue

233 lines
5.1 KiB
Vue
Raw Normal View History

2026-01-19 17:34:15 +08:00
<template>
<view class="card">
<view class="card-content">
<view class="card-tabs u-flex">
<view class="u-flex card-left">
<view class="card-title">{{title}}</view>
</view>
2026-01-20 18:07:35 +08:00
<view @click="openPage" class="morebtn">更多<u-icon name="arrow-right" class="u-p-r-10"
color="#666"></u-icon></view>
2026-01-19 17:34:15 +08:00
</view>
<view class="card-item">
<!-- 遍历渲染业务图标 -->
<view class="item u-flex-col" v-for="(item,index) in cardData" :key="index" @click="clickItem(item)">
<view class="item-icon" :style="{ background: item.iconBackground || '#008cff' }">
2026-01-30 20:07:18 +08:00
{{ console.log(imgId[item.id],'imgId[item.id]判断') }}
{{ console.log(imgId,'imgId') }}
{{ console.log(item.id,'item.id') }}
2026-01-29 22:45:47 +08:00
<image v-show="!!imgId[item.id]" class="item-img" :src="`/static/image/${item.id}.png`"></image>
2026-01-19 17:34:15 +08:00
<!-- 使用 iconify-icon 渲染 ep 系列图标 -->
2026-01-29 11:43:02 +08:00
<!-- <iconify-icon
2026-01-19 17:34:15 +08:00
:icon="item.icon"
color="#ffffff"
width="24"
height="24"
2026-01-29 11:43:02 +08:00
></iconify-icon> -->
2026-01-19 17:34:15 +08:00
</view>
<view class="item-title u-m-t-8">{{item.name}}</view>
</view>
<view v-if="showAdd" class="item u-flex-col u-col-center" @click="add">
<text class="u-font-40 item-icon more">+</text>
<text class="u-m-t-8 item-title">添加</text>
</view>
</view>
<JnpfEmpty v-if="!cardData.length && type != 'collect' "></JnpfEmpty>
</view>
</view>
</template>
<script>
export default {
props: {
title: {
type: String,
default: "我的收藏"
},
menuList: {
type: Array,
default: () => []
},
2026-02-02 09:14:54 +08:00
// flowList: {
// type: Array,
// default: () => []
// },
2026-01-19 17:34:15 +08:00
showAdd: {
type: Boolean,
default: false
},
type: {
type: String,
default: "collect"
},
flowEnabled: {
type: Boolean,
default: false
}
},
data() {
return {
tabList: [{
name: '应用功能',
type: 'menu'
}],
current: 0,
cardData: [],
userInfo: {}
}
},
computed: {
tabType() {
return this.tabList[this.current].type
2026-01-29 22:45:47 +08:00
},
imgId(){
return {
2026-01-30 09:33:42 +08:00
'1963446794006355970' : '动土作业',
'1963872316314165250' : '动火作业',
'1964898396173070337' : '有限空间',
'1964261054499336194' : '临时用电',
'1964253329070571521' : '高处作业',
'1964210049770401793' : '吊装作业'
2026-01-29 22:45:47 +08:00
}
2026-01-19 17:34:15 +08:00
}
},
watch: {
menuList: {
handler(val) {
2026-01-30 20:24:06 +08:00
console.log(this.current,'this.current---')
this.cardData = this.menuList
2026-01-19 17:34:15 +08:00
},
immediate: true
2026-02-02 09:14:54 +08:00
},
// flowList: {
// handler(val) {
// console.log(this.current,'this.current---')
// console.log(this.menuList,'this.menuList---')
// // if (this.current == 0) this.cardData = this.menuList
// this.cardData = this.menuList
// },
// immediate: true
// }
2026-01-19 17:34:15 +08:00
},
created() {
this.userInfo = uni.getStorageSync('userInfo') || {}
this.handleTabList()
},
methods: {
handleTabList() {
if (this.flowEnabled) {
this.tabList.push({
name: '发起审批',
type: 'flow'
})
}
},
tabChange(index) {
this.current = index;
2026-02-02 09:14:54 +08:00
// if (this.tabType === 'menu')
this.cardData = this.menuList
// if (this.tabType === 'flow') this.cardData = this.flowList
2026-01-19 17:34:15 +08:00
},
clickItem(item) {
this.$emit('launch', {
...item,
tabType: this.tabType
})
},
openPage() {
2026-01-20 18:07:35 +08:00
this.$emit('openPage', '/pages/apply/menu/index')
2026-01-19 17:34:15 +08:00
},
add() {
let url = this.tabType === 'menu' ? '/pages/apply/allAppApply/index' :
'/pages/workFlow/allAppWorkFlow/index'
this.$emit('addApp', url)
}
}
}
</script>
<style lang="scss">
.card {
margin-top: 20rpx;
&-title {
padding: 0 20rpx;
color: #303133;
font-size: 36rpx;
margin-bottom: 10rpx;
font-weight: 500;
}
&-content {
width: 100%;
height: 100%;
background-color: #fff;
2026-01-22 11:01:19 +08:00
padding-top: 15rpx;
2026-01-19 17:34:15 +08:00
.card-tabs {
width: 100%;
justify-content: space-between;
.card-left {}
.morebtn {
color: #666;
}
}
.card-item {
width: 100%;
display: flex;
flex-wrap: wrap;
flex-direction: row;
.item {
width: 33.33%;
padding: 10px;
justify-content: center;
align-items: center;
padding: 30rpx 0;
.item-icon {
width: 50px;
height: 50px;
/* 关键:改为 flex 布局,让图标居中 */
display: flex;
align-items: center;
justify-content: center;
color: #fff;
border-radius: 18px;
font-size: 24px;
background-color: #f0f2f6;
/* 移除原有伪类样式,避免干扰 */
&:before {
margin: 0;
}
}
2026-01-29 11:43:02 +08:00
.item-img {
width: 60%;
height: 60%;
}
2026-01-19 17:34:15 +08:00
.more {
background: #ececec;
color: #666;
font-size: 1.5625rem;
/* 保持添加按钮的居中 */
display: flex;
align-items: center;
justify-content: center;
}
.item-title {
width: 92px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
font-size: 24rpx;
}
}
}
}
}
</style>