zhgdyunapp_vue3/pages/contractors/qualification.vue

326 lines
8.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<view class="barBox" ref="barBox" :style="{height: barBoxHeight + 'px'}">
<view class="fixedheader">
<headers :themeType="'white'" :showBack="true">
<view class="headerName">
资质文件
</view>
<view class="searchBox">
<form>
<view class="uni-form-item">
<input class="uni-input" name="searchName" v-model="searchForm.fileName" placeholder="请搜索文件名称"
@input="handleInput" />
</view>
</form>
</view>
</headers>
</view>
</view>
<scroll-view :scroll-y="true" class="scrollBox" :style="{height: scrollHeight + 'px'}" v-if="listData.length > 0">
<view v-for="(item,index) in listData" :key="index">
<view class="itemBox">
<view class="file-info">
<image :src="item.logoUrl" class="icon-image" v-if="fileTypeCondition(item.logoUrl)"></image>
<!-- <image v-else-if="getFileSuffix(item.logoUrl) == 'zip'" :src="'/static/documentIcon/ZIP.png'" class="icon-image"></image> -->
<image v-else :src="getFileSuffix(item.logoUrl)" class="icon-image"></image>
<view class="info">
<view class="info-inner">{{item.fileName}}</view>
<view class="info-inner">{{item.createTime}}</view>
</view>
</view>
<view class="optration" @click="previewImage(item)">· · ·</view>
</view>
</view>
<view class="" style="height: 20rpx;"></view>
</scroll-view>
<view class="no_data" v-if="listData.length == 0">
<image src="/static/noData.png"></image>
<view>暂无数据</view>
</view>
<!-- <view class="noData" :style="{height: screenHeight + 'px'}" v-if="listData.length == 0">
暂无数据
</view> -->
</view>
</template>
<script>
export default {
data() {
return {
id: '',
projectId: '',
searchForm: {
enterpriseId: '',
fileName: ''
},
barBoxHeight: '',
scrollHeight:'',
listData: [],
};
},
onReady() {
this.getHeight()
},
onLoad(option) {
this.id = option.id
this.projectId = option.projectId
this.getListData()
},
methods: {
fileTypeCondition(file) {
// 获取文件后缀名
const extension = file.substring(file.lastIndexOf('.') + 1).toLowerCase();
// 常见的图片文件后缀名
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'];
// 检查文件后缀名是否在图片后缀名数组中
return imageExtensions.includes(extension);
},
getFileSuffix(fileName){
console.log(fileName)
let suffixName = fileName.split('.').pop().toLowerCase()
if(suffixName == 'pdf') return '/static/documentIcon/pdf.png'
if(suffixName == 'ppt' || suffixName == 'pptx') return '/static/documentIcon/ppt.png'
if(suffixName == 'rar' || suffixName == 'zip') return '/static/documentIcon/rar.png'
if(suffixName == 'txt') return '/static/documentIcon/txt.png'
if(suffixName == 'mp4') return '/static/documentIcon/video.png'
if(suffixName == 'doc' || suffixName == 'docx') return '/static/documentIcon/word.png'
if(suffixName == 'xlsx' || suffixName == 'excel') return '/static/documentIcon/excel.png'
return '/static/documentIcon/null.png'
// return fileName.split('.').pop();
},
async getHeight() {
const query = uni.createSelectorQuery().in(this);
let fixedheaderHeight = 0
const fixedHeaderPromise = new Promise((resolve) => {
query.select('.fixedheader').boundingClientRect(data => {
fixedheaderHeight = data.height
console.log('fixedheaderHeight', data.height);
resolve();
}).exec();
});
let searchBoxHeight = 0
const searchBoxPromise = new Promise((resolve) => {
query.select('.searchBox').boundingClientRect(data => {
searchBoxHeight = data.height
console.log('searchBoxHeight', data.height);
resolve();
}).exec();
});
let mobileTopHeight = 0
const systemInfoPromise = new Promise((resolve) => {
uni.getSystemInfo({
success(res) {
mobileTopHeight = res.statusBarHeight ? res.statusBarHeight : 0;
resolve();
}
});
});
await fixedHeaderPromise;
await searchBoxPromise;
await systemInfoPromise;
this.barBoxHeight = fixedheaderHeight + searchBoxHeight + mobileTopHeight;
console.log('this.barBoxHeight', this.barBoxHeight);
let screenHeight = uni.getSystemInfoSync().screenHeight;
console.log('screenHeight', screenHeight);
this.scrollHeight = screenHeight - this.barBoxHeight;
console.log('this.scrollHeight', this.scrollHeight);
},
isJSON(str) {
try {
JSON.parse(str);
} catch (e) {
// 转换出错,抛出异常
return false;
}
return true;
},
getListData(){
this.searchForm.enterpriseId = this.id
// let data = {
// enterpriseId: '1802547943107092481',
// }
this.sendRequest({
url: 'xmgl/enterpriseQualification/list',
method: 'post',
data: this.searchForm,
success: res => {
console.log("enterpriseQualification", res);
this.listData = res.result.map(item => {
const fileUrl = this.isJSON(item.fileUrl) && Array.isArray(JSON.parse(item.fileUrl)) ? JSON.parse(item.fileUrl)[0].url : item.fileUrl;
item.logoUrl = this.url_config+'image/'+ fileUrl
return item
})
}
})
},
previewImage(item){
// let url = this.url_config+'image/'+ JSON.parse(item.fileUrl)[0].url
// console.log(url);
// uni.previewImage({
// urls: [url]
// })
const fileUrl = this.isJSON(item.fileUrl) ? JSON.parse(item.fileUrl)[0].url: item.fileUrl;
let url = this.url_config + 'image/' + fileUrl
console.log(url)
uni.downloadFile({
url: url,
success: function(res) {
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
success: function(res) {
console.log('打开文档成功');
}
});
}
});
},
//搜索
handleInput(e) {
setTimeout(() => {
this.getListData()
}, 300)
},
}
}
</script>
<style lang="scss" scoped>
.barBox {
// background-color: #5181F6;
background-color: #fff;
min-height: 100%;
height: 100px;
.fixedheader {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 999;
.headerName {
z-index: 1;
}
.searchBox {
color: #000000;
background-color: white;
// position: fixed;
// top: 44px;
left: 0;
width: 100%;
z-index: 999;
box-shadow: 0px 8rpx 15rpx 0px rgba(219,229,255,0.6);
.uni-form-item {
position: relative;
display: flex;
font-size: 28rpx;
}
.uni-input {
border-radius: 40rpx;
margin: 20rpx 20rpx;
background-color: #f7f8fa;
height: 70rpx;
line-height: 60rpx;
padding: 0 40rpx;
font-size: 28rpx;
width: calc(100% - 40px);
}
}
}
}
.scrollBox {
height: 100%;
width: 100%;
background-color: #f4f5fd;
// margin: 0 20rpx;
word-break: break-all;
.itemBox {
width: 100%;
min-height: 120rpx;
margin-top: 4rpx;
// border: 1px solid rgba(219, 229, 255, 0.6);
border-radius: 4rpx;
padding: 10rpx 20rpx;
box-shadow: 0px 8rpx 15rpx 0px rgba(219,229,255,0.6);
background-color: #fff;
font-size: 24rpx;
display: flex;
justify-content: space-between;
align-items: center;
.file-info{
width: 85%;
display: flex;
justify-content: flex-start;
align-items: center;
.icon-image{
width: 90rpx;
height: 90rpx;
}
.info{
width: calc(100% - 100px);
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: center;
.info-inner{
white-space: nowrap;
overflow: hidden; /* 隐藏超出部分 */
text-overflow: ellipsis; /* 使用省略号显示超出部分 */
line-height: 23px;
}
}
}
.optration{
width: 90rpx;
font-weight: bolder;
color: #2b8df3;
}
}
}
.no_data{
position: fixed;
top: 35%;
// transform: translateY(-50%);
left: 50%;
transform: translateX(-50%);
padding-top: 60rpx;
text-align: center;
color: rgba(0,0,0,0.5);
font-size: 28rpx;
uni-image{
width: 162rpx;
height: 130rpx;
display: block;
margin: 0 auto;
margin-bottom: 40rpx;
}
}
.noData{
display: flex;
justify-content: center;
align-items: center;
font-size: 34px;
color: darkgray;
transform: translateY(-60px);
}
</style>