551 lines
12 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 class="dangerbig-list">
<view class="fixedheader">
<headers :showBack="true">
<view class="headerName">
{{sunshineTitle}}明细
</view>
</headers>
</view>
<view :style="{ 'padding-top': ((statusBarHeight * 2) + 45) * 1.5 + 'rpx' }">
<view class="list">
<view class="list-item">
<!-- <view class="download" v-for="item in workDetail.image" :key="item.id">
<image mode="aspectFill" :src="item.url.includes('http://') ? item.url : url_config+'image/'+item.url"
class="img"
@click="previewImage(item.url.includes('http://') ? item.url : url_config+'image/'+item.url)">
</image>
<view class="list-info">
{{workDetail.createDate}}
</view>
</view> -->
<!-- <view class="list_status">
<view>
阅读状态{{workDetail.isRead == 1 ? "已读" : "未读" }}
</view>
</view> -->
<view class="list-title">
{{workDetail.title}}
</view>
<view class="list-content">
<view class="list-info">
<text class="vhtml" v-html="workDetail.content"></text>
</view>
</view>
<div class="preview_box" v-for="item in workDetail.attachment" :key="item.uid">
<image class="el-image" :src="setFileImg(item)" />
<span class="download1" @click="downloadFile(item)">{{ item.name }}</span>
</div>
</view>
</view>
<!-- <view class="no-data" v-else>
<image class="img" src="/static/noData.png"></image>
<text class="txt">暂无数据</text>
</view> -->
</view>
</view>
</template>
<script>
import {
isJSON
} from '@/utils/tool.js'
import fileImg1 from '@/static/ppt.png';
import fileImg2 from '@/static/excel.png';
import fileImg3 from '@/static/pdf.png';
import fileImg4 from '@/static/word.png';
import dir from '@/static/file/dir.png';
import file_chm from '@/static/file/file_chm.png';
import file_css from '@/static/file/file_css.png';
import file_csv from '@/static/file/file_csv.png';
import file_rar from '@/static/file/file_rar.png';
import file_zip from '@/static/file/file_zip.png';
// import file_mp3 from '@/static/file/file_mp3.png';
import file_open from '@/static/file/file_open.png';
import file_rtf from '@/static/file/file_rtf.png';
import file_txt from '@/static/file/file_txt.png';
import file_oa from '@/static/file/file_oa.png';
import file_js from '@/static/file/file_js.png';
import file_html from '@/static/file/file_html.png';
import file_sql from '@/static/file/file_sql.png';
import file_jar from '@/static/file/file_jar.png';
import file_svg from '@/static/file/file_svg.png';
import file_gif from '@/static/file/file_gif.png';
import file_json from '@/static/file/file_json.png';
import file_exe from '@/static/file/file_exe.png';
import file_pic from '@/static/file/file_pic.png';
import file_word from '@/static/file/file_word.png';
import file_excel from '@/static/file/file_excel.png';
import file_avi from '@/static/file/file_avi.png';
import file_video from '@/static/file/file_video.png';
import file_music from '@/static/file/file_music.png';
import file_img from '@/static/file/file_img.png';
import file_dmg from '@/static/file/file_dmg.png';
import file_ppt from '@/static/file/file_ppt.png';
import file_pdf from '@/static/file/file_pdf.png';
import file_unknown from '@/static/file/file_unknown.png';
export default {
data() {
return {
// 可以识别的文件类型
fileImgTypeList: [
'png',
'jpg',
'jpeg',
'docx',
'doc',
'ppt',
'pptx',
'xls',
'xlsx',
'avi',
'mp4',
'css',
'csv',
'chm',
'rar',
'zip',
'dmg',
'mp3',
'open',
'pdf',
'rtf',
'txt',
'oa',
'js',
'html',
'img',
'sql',
'jar',
'svg',
'gif',
'json',
'exe'
],
// 文件图片Map映射
fileImgMap: {
dir: dir,
chm: file_chm,
css: file_css,
csv: file_csv,
png: file_pic,
jpg: file_pic,
jpeg: file_pic,
docx: file_word,
doc: file_word,
ppt: file_ppt,
pptx: file_ppt,
xls: file_excel,
xlsx: file_excel,
mp4: file_video,
avi: file_avi,
rar: file_rar,
zip: file_zip,
dmg: file_dmg,
mp3: file_music,
open: file_open,
pdf: file_pdf,
rtf: file_rtf,
txt: file_txt,
oa: file_oa,
unknown: file_unknown,
js: file_js,
html: file_html,
img: file_img,
sql: file_sql,
jar: file_jar,
svg: file_svg,
gif: file_gif,
json: file_json,
exe: file_exe
},
statusBarHeight: 0,
pageNo: 1,
pageSize: 10,
projectSn: "",
listData: [],
isLoadMore: false,
loadStatus: 'more',
workDetail: [],
levelList: [{
id: 1,
workCategoryName: "一级"
}, {
id: 2,
workCategoryName: "二级"
}, {
id: 3,
workCategoryName: "三级"
}, {
id: 4,
workCategoryName: "普通"
}],
searchName: "",
sunshineTitle: "",
sunshineId: "",
}
},
onShow() {
this.statusBarHeight = uni.getStorageSync('systemInfo').statusBarHeight;
this.projectSn = JSON.parse(uni.getStorageSync('userInfo')).sn
this.getWorkList()
},
onLoad(val) {
this.detailId = val.id;
this.sunshineTitle = val.title;
this.sunshineId = val.sunshineId;
// this.initData()
},
onReachBottom() {
console.log(1)
if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
this.isLoadMore = true
this.pageNo += 1
this.getWorkList()
}
},
onPullDownRefresh() {
console.log(2)
this.pageNo = 1
this.listData = []
this.getWorkList()
},
methods: {
// 根据文件扩展名设置文件图片
setFileImg(row) {
const extendName = row.name.substring(row.name.lastIndexOf('.') + 1).toLowerCase();
if (!extendName) {
// 文件夹
return this.fileImgMap.dir
} else if (!this.fileImgTypeList.includes(extendName)) {
// 无法识别文件类型的文件
return this.fileImgMap.unknown
} else if (['jpg', 'png', 'jpeg', 'gif'].includes(extendName)) {
// 图片类型,直接显示缩略图
return row.url.includes("http://") ? row.url : this.url_config + 'image/' + row.url
} else {
// 可以识别文件类型的文件
return this.fileImgMap[extendName]
}
},
//预览图片
previewImage(url) {
uni.previewImage({
urls: [url]
})
},
handleInput() {
this.pageNo = 1;
this.listData = []
this.getWorkList();
},
getWorkList() {
let data = {
id: this.detailId,
// projectSn: this.projectSn,
// type: 7,
}
const url = this.sunshineId ? 'xmgl/sunshineConstructionList/queryById' : 'xmgl/sunshineProject/queryById';
this.sendRequest({
url: url,
method: 'get',
data: data,
success: res => {
uni.hideLoading()
if (res.code == 200) {
console.log("workList======================", res)
// this.listData = res.result.records
// this.workList=this.workList.concat(res.result)
this.workDetail = {
...res.result,
attachment: isJSON(res.result.attachment) && JSON.parse(res.result
.attachment) instanceof Array ? JSON.parse(res.result.attachment) :
[],
}
}
}
})
},
checkItem(val) {
console.log(val)
uni.navigateTo({
url: './detail?id=' + val.id
})
},
downloadFile(url) {
const newUrl = url.url.includes('http://') ? url.url : this.url_config + 'image/' + url.url;
console.log(url)
// uni.downloadFile({
// url: newUrl,
// success: function(res) {
// var filePath = res.tempFilePath;
// uni.openDocument({
// filePath: filePath,
// success: function(res) {
// console.log('打开文档成功');
// }
// });
// }
// });
const typeImageList = ['png', 'jpg', 'jpeg'];
const extendName = url.url.slice(url.url.lastIndexOf('.') + 1);
if (typeImageList.includes(extendName)) {
uni.previewImage({
urls: [newUrl]
})
} else {
// //#ifdef H5
// uni.showToast({
// title: '暂不支持预览!',
// icon: "none",
// duration: 2000
// });
// return;
// //#endif
uni.downloadFile({
url: newUrl,
success: function(res) {
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
success: function(res) {
console.log('打开文档成功');
}
});
}
});
}
},
}
}
</script>
<style lang="scss" scoped>
.preview_box {
display: flex;
align-items: center;
.download1 {
color: #1684fc;
cursor: pointer;
}
:deep(img) {
width: 100%;
}
.el-image {
width: 30px;
height: 30px;
}
}
.preview_box:not(:first-child) {
margin-top: 10px;
}
.vhtml {
flex: 1;
:deep(img) {
width: 100%;
}
}
.searchBox {
background-color: white;
}
.uni-form-item {
position: relative;
display: flex;
align-items: center;
font-size: 28rpx;
/* .search-icon{
position: absolute;
top: 50%;
right: 50rpx;
transform: translateY(-50%);
} */
}
.uni-input {
border-radius: 40rpx;
margin: 20rpx 20rpx;
background-color: #f7f8fa;
height: 70rpx;
line-height: 60rpx;
padding: 0 40rpx;
font-size: 28rpx;
flex: 1;
}
.screen {
line-height: 100rpx;
color: gray;
}
.flex {
display: flex;
align-items: center;
}
.content {
padding: 0px 30rpx 20rpx;
box-sizing: border-box;
width: 100%;
}
.download {
// display: flex;
// flex-wrap: wrap;
// align-items: center;
// margin-top: 10rpx;
// justify-content: center;
border-radius: 16rpx;
position: relative;
height: 280rpx;
.list-info {
width: 100%;
padding: 12rpx 40rpx;
border-radius: 0 0 16rpx 16rpx;
color: white;
font-size: 24rpx;
text-align: right;
background: rgba(0, 0, 0, 0.7);
position: absolute;
bottom: 0;
}
}
.img {
width: 100%;
// width: 720rpx;
height: 280rpx;
border-radius: 16rpx;
}
.dangerbig-list {
min-height: 100%;
// background: #F6F6F6;
.fixedheader {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 2;
.headerName {
z-index: 1;
}
}
.list {
padding: 20rpx 30rpx;
.list-item {
background: #fff;
margin-bottom: 20rpx;
.list_status {
padding: 12rpx 0 0 0;
display: flex;
align-items: center;
justify-content: space-between;
color: #1A1A1A;
font-size: 24rpx;
}
.list-title {
padding: 34rpx 0 20rpx 0;
// border-bottom: 4rpx solid #F6F6F6;
display: flex;
align-items: center;
justify-content: space-between;
color: #1A1A1A;
font-size: 32rpx;
.tag {
background: #F0AD4E;
color: #fff;
padding: 4rpx 8rpx;
font-size: 24rpx;
margin-right: 20rpx;
margin-left: -20rpx;
height: 32rpx;
}
.status1 {
background: #2b8df3;
color: #fff;
padding: 4rpx 8rpx;
font-size: 24rpx;
}
.status2 {
background: #F0AD4E;
color: #fff;
padding: 4rpx 8rpx;
font-size: 24rpx;
}
.status3 {
background: #B22222;
color: #fff;
padding: 4rpx 8rpx;
font-size: 24rpx;
}
.status4 {
background: #ccc;
color: #fff;
padding: 4rpx 8rpx;
font-size: 24rpx;
}
}
.info-status {
padding: 0 10rpx;
border: 1px solid #DD524D;
border-radius: 6rpx;
color: #DD524D;
margin-left: 10rpx;
}
}
}
.btn {
height: 96rpx;
width: 100%;
line-height: 96rpx;
text-align: center;
background: #4181FE;
color: #fff;
position: fixed;
bottom: 0;
left: 0;
}
.no-data {
text-align: center;
.img {
display: block;
height: 200rpx;
width: 200rpx;
margin: 0 auto;
margin-top: 560rpx;
margin-bottom: 60rpx;
}
.txt {
color: #CFC8CC;
}
}
}
</style>