YNUtdPlatform/pages/workPlan/index/components/home-notice-bar.vue

147 lines
3.8 KiB
Vue
Raw Normal View History

2024-10-12 16:03:45 +08:00
<template>
<view class="notice-container">
<!-- <uni-notice-bar :showClose="showClose" :showIcon="showIcon" scrollable :text="noticeContent" /> -->
<image class="warning-img" src="../../../../static/images/img-phase-two/index_news.png" mode=""></image>
2024-12-10 09:19:55 +08:00
<view style="width: 200rpx">今日风险</view>
<!-- <MultiColorNoticeBar :speed="30" backgroundColor="#fff" @tap="onViewRiskDetails">
<text style="color: red">重要通知</text>
<text style="color: blue">这是一条</text>
<text style="color: green">多彩的</text>
<text style="color: orange">滚动公告</text>
<text style="color: orange">滚动公告</text>
<text style="color: orange">滚动公告</text>
<text style="color: orange">滚动公告</text>
</MultiColorNoticeBar> -->
<view @tap="onViewRiskDetails" style="width: 70%">
<MultiColorNoticeBar
:textArray="[
`风险总数:${tfx} `,
`可接受风险:${kjs} `,
`低风险:${dfx} `,
`中风险:${zfx} `,
`高风险:${gfx} `,
`特高风险:${tfx} `
]"
:textStyle="[
{ color: '#000000' },
{ color: '#7dda76' },
{ color: '#7dda76' },
{ color: '#ffed51' },
{ color: '#bc2843' },
{ color: '#bc2843' }
]"
:scrollSpeed="1"
/>
2024-10-12 16:03:45 +08:00
</view>
2024-12-10 09:19:55 +08:00
<!-- <view class="uni-notice-bar" >
</view> -->
2024-10-12 16:03:45 +08:00
</view>
</template>
<script>
2024-11-03 14:42:17 +08:00
import { getTitleRiskApi } from '../../../../api/workPlan/homePage'
2024-12-10 09:19:55 +08:00
import MultiColorNoticeBar from '../../../../components/MultiColorNoticeBar/index.vue'
2024-10-12 16:03:45 +08:00
export default {
props: {
2024-11-03 14:42:17 +08:00
// /* 提示内容 */
// noticeContent: {
// type: String,
// default: '中风险35 低风险153 可接收风险153 高风险126'
// },
2024-10-12 16:03:45 +08:00
/* 是否显示关闭按钮 */
showClose: {
type: Boolean,
default: false
},
/* 是否显示提示图标 */
showIcon: {
type: Boolean,
default: false
}
2024-11-03 14:42:17 +08:00
},
2024-12-10 09:19:55 +08:00
components: {
MultiColorNoticeBar
},
2024-11-03 14:42:17 +08:00
data() {
return {
kjs: 0,
dfx: 0,
zfx: 0,
gfx: 0,
2024-12-10 09:19:55 +08:00
tfx: 0,
amount: 0
2024-11-03 14:42:17 +08:00
}
},
computed: {
noticeContent() {
const amount = this.kjs + this.dfx + +this.zfx + this.gfx + this.tfx
return `风险总数${amount} 可接受风险${this.kjs} 低风险${this.dfx} 中风险${this.zfx} 高风险${this.gfx} 特高风险${this.tfx}`
}
},
methods: {
async getRiskNumData() {
const res = await getTitleRiskApi()
console.log('风险数据---', res)
if (res.resMsg == '数据获取成功') {
res.obj.list.forEach(e => {
if (e.type == '可1') {
this.kjs = e.num * 1
}
if (e.type == '低1') {
this.dfx = e.num * 1
}
if (e.type == '中1') {
this.zfx = e.num * 1
}
if (e.type == '高1') {
this.gfx = e.num * 1
}
if (e.type == '特高1') {
this.tfx = e.num * 1
}
})
2024-12-10 09:19:55 +08:00
this.amount = this.kjs + this.dfx + +this.zfx + this.gfx + this.tfx
2024-11-03 14:42:17 +08:00
}
2024-11-03 15:24:43 +08:00
},
onViewRiskDetails() {
uni.navigateTo({ url: '/pages/workPlan/workPlan/index' })
// uni.navigateTo({ url: `/pages/workPlan/workPlan/index?day=${this.$moment().format('YYYY-MM-DD')}` })
2024-11-03 14:42:17 +08:00
}
},
mounted() {
this.getRiskNumData()
2024-10-12 16:03:45 +08:00
}
}
</script>
<style lang="scss" scoped>
.notice-container {
2024-12-10 09:19:55 +08:00
width: 100vw;
2024-10-12 16:03:45 +08:00
height: 56rpx;
margin: 20rpx 0;
display: flex;
align-items: center;
box-shadow: 6rpx -8rpx 0 8rpx #f0f4f7;
.warning-img {
width: 48rpx;
height: 48rpx;
2024-12-10 09:19:55 +08:00
margin: 0 10rpx;
2024-10-12 16:03:45 +08:00
}
2024-12-10 09:19:55 +08:00
// .uni-notice-bar {
// flex: 1;
// }
2024-10-12 16:03:45 +08:00
2024-12-10 09:19:55 +08:00
// text {
// margin: 0 10rpx;
// }
2024-10-12 16:03:45 +08:00
}
</style>