QA-UniApp-wlaq/pages/basics/study-files/study-detail.vue

112 lines
3.1 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<view>
<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
<block slot="backText">返回</block>
<block slot="content">法律法规</block>
</cu-custom>
<view class="vi-card">
<view class="vi-card-items" v-for="(item,index) of varList" :key="index">
<view class="vi-card-title">
{{item.NAME}}
</view>
<view class="vi-card-content">
<text v-if="item.extension_name == '.docx' || item.extension_name == '.doc'">文件属性:文档</text>
<text v-else-if="item.extension_name == '.xls' || item.extension_name == '.xlsx'">文件属性:表格</text>
<text v-else-if="item.extension_name == '.ppt' || item.extension_name == '.pptx'">文件属性:幻灯片</text>
<text v-else-if="item.extension_name == '.pdf'">文件属性PDF</text>
<text v-else>文件属性:</text>
<text>上传日期:{{item.CTIME | formatDate}}</text>
</view>
<view class="vi-card-foot">
<button class="cu-btn bg-blue sm" @click="$noMultipleClicks(downloadFile,item.FILEPATH)"><text class="cuIcon-pulldown"></text>下载</button>
<button
class="cu-btn bg-cyan sm" @click="$noMultipleClicks(showFile,item)">
<text class="cuIcon-playfill"></text> 预览
</button>
</view>
</view>
</view>
</view>
<!-- <web-view src="https://view.officeapps.live.com/op/view.aspx?src=https://qask.qhdsafety.com/file/uploadFiles/file/20210601/8f4f5ad3c0a34b6380ab6b1f20f38b61.docx"></web-view> -->
</template>
<script>
import {
basePath,corpinfoId,loginSession,formatDate,loginUser,baseImgPath
} from '@/common/tool.js';
export default {
data() {
return {
varList: [],
noClick:true,
PARENT_ID:''
}
},
filters: {
formatDate(time) {
if(time){
var subStr=new RegExp('-','ig');//创建正则表达式对象,不区分大小写,全局查找
time=time.replace(subStr,"/");//把'is'替换为空字符串
}
let date = new Date(time)
return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
}
},
onLoad(event) {
this.PARENT_ID = event.PARENT_ID;
this.getData()
},
methods: {
getData(){
var _this = this;
uni.showLoading({
title:"加载中..."
});//加载中动画
uni.request({
url: basePath +'/app/mfolderStipulate/listByParentId',
method: 'POST',
dataType: 'json',
header: {
'Content-type':'application/x-www-form-urlencoded'
},
data: {
PARENT_ID:this.PARENT_ID,
TYPE:2
},
success: (res) => {
uni.hideLoading();//结束加载中动画
_this.varList = res.data.varList;
}
})
},
downloadFile(e){
var url=baseImgPath + e ;
var url2 = encodeURI(url);
plus.runtime.openURL(url2, function(res) {
});
},
showFile(item){
uni.showLoading({
title:"加载中..."
});//加载中动画
uni.downloadFile({
url:baseImgPath+item.FILEPATH,
success:(res)=>{
uni.hideLoading();//结束加载中动画
uni.openDocument({
filePath:res.tempFilePath,
success:function(){
}
})
}
})
}
}
}
</script>
<style>
</style>