智能安全检查移动端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

344 lines
13 KiB

<template>
<view class="custom-content">
<z-paging ref="paging" v-model="dataList" @query="queryList">
<!-- 需要固定在顶部不滚动的view放在slot="top"的view中,如果需要跟着滚动,则不要设置slot="top" -->
<!-- 注意!此处的z-tabs为独立的组件,可替换为第三方的tabs,若需要使用z-tabs,请在插件市场搜索z-tabs并引入,否则会报插件找不到的错误 -->
<template #top>
<uni-nav-bar :fontSizes="17" left-icon="left" @clickLeft="back" :fixed="true" :border="false"
background-color="transparent" status-bar title="历史案例库" />
<view class="search-box">
<uni-easyinput :inputBorder="false" :styles="inputStyles" class="search-input" prefixIcon="search"
v-model="caseName" placeholder="请输入搜索内容" @confirm="confirm">
</uni-easyinput>
<view class="search-btn-box" @click="openPop">
<view class="shaixuan-icon">
<!-- <image src="https://mp-df79fe8b-b924-41b0-bcb1-960be6b4a619.cdn.bspapp.com/images/common/shaixuan@2x.png" /> -->
<image src="https://i.postimg.cc/qvbhdmZR/shaixuan-2x.png" />
</view>
<text>筛选</text>
</view>
</view>
</template>
<!-- 自定义下拉刷新view(如果use-custom-refresher为true且不设置下面的slot="refresher",此时不用获取refresherStatus,会自动使用z-paging自带的下拉刷新view) -->
<!-- 注意注意注意!!字节跳动小程序中自定义下拉刷新不支持slot-scope,将导致custom-refresher无法显示 -->
<!-- 如果是字节跳动小程序,请参照sticky-demo.vue中的写法,此处使用slot-scope是为了减少data中无关变量声明,降低依赖 -->
<template #refresher="{ refresherStatus }">
<!-- 此处的custom-refresh为demo中自定义的组件,非z-paging的内置组件,请在实际项目中自行创建。这里插入什么view,下拉刷新就显示什么view -->
<custom-refresher :status="refresherStatus" />
</template>
<!-- 自定义没有更多数据view -->
<template #loadingMoreNoMore>
<!-- 此处的custom-nomore为demo中自定义的组件,非z-paging的内置组件,请在实际项目中自行创建。这里插入什么view,没有更多数据就显示什么view -->
<custom-nomore></custom-nomore>
</template>
<!-- 如果希望其他view跟着页面滚动,可以放在z-paging标签内 -->
<view class="list-item" v-for="(item, index) in dataList" :key="index" @click="itemClick(item)">
<view class="list-item-header">
<view class="list-item-header-title">
<view class="header-title-icon aci-icon">
<!-- <image src="https://mp-df79fe8b-b924-41b0-bcb1-960be6b4a619.cdn.bspapp.com/images/common/konwloge@2x.png"></image> -->
<image src="https://i.postimg.cc/5235QqKd/konwloge-2x.png"></image>
</view>
<text>
{{ item.caseName }}
</text>
</view>
<view class="list-item-header-index">#{{ index + 1 }}</view>
</view>
<view class="list-item-body">
<view class="list-item-body-desc">
<text class="list-item-body-desc-label">事故等级</text>
<text class="list-item-body-desc-value">{{ getLabelByValue(item.caseLevel, caseLevelList) }}</text>
</view>
<view class="list-item-body-desc">
<text class="list-item-body-desc-label">事故类型</text>
<text class="list-item-body-desc-value">{{ getLabelByValue(item.caseType, caseTypeList) }}</text>
</view>
<view class="list-item-body-desc">
<text class="list-item-body-desc-label">事故时间</text>
<text class="list-item-body-desc-value">{{ parseTime(item.createTime) }}</text>
</view>
</view>
<view class="list-item-feet border-top" v-if="item.filePath">
<view class="list-item-feet-btn" @click="goFilePage(item.filePath)">
<!-- <image src="https://mp-df79fe8b-b924-41b0-bcb1-960be6b4a619.cdn.bspapp.com/images/common/fujian@2x.png"></image> -->
<image src="https://i.postimg.cc/cH6cSgmq/fujian-2x.png"></image>
<text class="list-item-feet-btn-label">查看附件</text>
</view>
</view>
</view>
</z-paging>
<!-- <view class="top-fixed" :style="{ top: autoTop }">
<view class="search-box">
<uni-easyinput prefixIcon="search" v-model="value" placeholder="请输入搜索内容" @iconClick="iconClick">
</uni-easyinput>
<view class="search-btn-box">
<view class="shaixuan-icon">
<image src="https://mp-df79fe8b-b924-41b0-bcb1-960be6b4a619.cdn.bspapp.com/images/common/shaixuan@2x.png" />
</view>
<text>筛选</text>
</view>
</view>
</view>
<view class=""></view> -->
<uni-popup ref="popup" type="bottom" background-color="#fff">
<view class="popup-box">
<view class="popup-box-content">
<view class="popup-box-content-item">
<text>事件等级</text>
<view>
<uni-data-checkbox :map="maps" v-model="caseLevel"
:localdata="caseLevelList"></uni-data-checkbox>
</view>
</view>
<view class="popup-box-content-item">
<text>事件类型</text>
<view>
<uni-data-checkbox :map="maps" v-model="caseType" :localdata="caseTypeList"></uni-data-checkbox>
</view>
</view>
</view>
<view class="popup-box-btn-box">
<view class="popup-box-btn-box-item" @click="reset">重置</view>
<view class="popup-box-btn-box-item" @click="confirm">确定</view>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import { getDicts } from '@/api/system/user'
import CustomNomore from '@/components/custom-nomore/custom-nomore'
import CustomRefresher from '@/components/custom-refresher/custom-refresher'
import { parseTime } from '@/utils/ruoyi'
import * as Api from '@/api/index/index'
import { getLabelByValue } from '@/utils/showDictLabel.js' // 导入工具函数
export default {
components: {
CustomNomore,
CustomRefresher
},
data() {
return {
dataList: [],
inputStyles: {
borderRadius: '20rpx',
backgroundColor: '#ffffff',
},
caseTypeList: [],
caseLevelList: [],
caseType: '',
caseLevel: '',
caseName: '',
maps: {
text: 'label',
value: 'value'
}
}
},
computed: {
autoTop() {
return this.getVal()
},
},
mounted() {
this.getDicts('case_level')
this.getDicts('case_type')
},
methods: {
reset() {
this.caseType = ''
this.caseLevel = ''
},
confirm() {
this.$refs.paging.refresh()
this.$refs.popup.close()
},
getDicts(type) {
const params = {
type: type
}
getDicts(params).then(res => {
if (type === 'case_level') {
this.caseLevelList = res.data
} else if (type === 'case_type') {
this.caseTypeList = res.data
}
}).catch(err => {
console.log(err)
})
},
getLabelByValue() {
return getLabelByValue.apply(this, arguments)
},
openPop() {
this.$refs.popup.open()
},
goFilePage(url) {
// 获取文件后缀名
const fileExtension = url.split(".").pop()?.toLowerCase();
if (!fileExtension) {
uni.showToast({ title: "无法识别文件类型", icon: "none" });
return;
}
// 判断文件类型
if (["jpg", "jpeg", "png", "gif"].includes(fileExtension)) {
// 图片预览
uni.previewImage({
urls: [url],
});
} else {
// 文档预览
uni.downloadFile({
url: url,
// filePath: filePath,
success: (res) => {
if (res.statusCode === 200) {
uni.openDocument({
filePath: res.tempFilePath,
success: () => console.log("文档预览成功 路径: ", res.tempFilePath),
fail: (err) => {
console.error("文档预览失败", err);
uni.showToast({
title: "预览失败",
icon: "error",
});
},
});
} else {
uni.showToast({
title: "文件下载失败",
icon: "error",
});
}
},
fail: (err) => {
console.error("文件下载失败", err);
uni.showToast({
title: "文件下载失败",
icon: "error",
});
},
});
}
},
parseTime(time) {
return parseTime(time)
},
back() {
uni.navigateBack()
},
getVal() {
return uni.getSystemInfoSync().statusBarHeight + 44 + 'px'
},
queryList(pageNo, pageSize) {
//组件加载时会自动触发此方法,因此默认页面加载时会自动触发,无需手动调用
//这里的pageNo和pageSize会自动计算好,直接传给服务器即可
//模拟请求服务器获取分页数据,请替换成自己的网络请求
const params = {
pageNo: pageNo,
pageSize: pageSize,
caseName: this.caseName,
caseType: this.caseType,
caseLevel: this.caseLevel
}
Api.getCaselibrary(params).then(res => {
//将请求的结果数组传递给z-paging
this.$refs.paging.complete(res.data.list);
}).catch(res => {
//如果请求失败写this.$refs.paging.complete(false);
//注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
//在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
this.$refs.paging.complete(false);
})
},
}
}
</script>
<style lang="scss">
.uni-easyinput,
.uni-easyinput__content {
border-radius: 20rpx;
}
.popup-box {
padding: 30rpx;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
&-content {
&-item {
margin-bottom: 40rpx;
&:last-child {
margin-bottom: 0;
}
>text {
display: block;
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
}
.uni-data-checkbox {
display: flex;
flex-wrap: wrap;
::v-deep .uni-checkbox-group {
display: flex;
flex-wrap: wrap;
.uni-label {
width: 50%;
margin-bottom: 20rpx;
display: flex;
align-items: center;
.uni-checkbox-input {
transform: scale(0.8);
margin-right: 10rpx;
}
}
}
}
}
}
&-btn-box {
display: flex;
justify-content: space-between;
margin-top: 30rpx;
&-item {
flex: 1;
height: 80rpx;
line-height: 80rpx;
text-align: center;
border-radius: 10rpx;
font-size: 30rpx;
&:first-child {
background-color: #f5f5f5;
color: #666;
margin-right: 20rpx;
}
&:last-child {
background-color: #007AFF;
color: #fff;
margin-left: 20rpx;
}
}
}
}
</style>