<template>
|
<view class="datum_index">
|
<view class="datum_headers">
|
<view class="datum_headers_left">
|
<u--input placeholder="请输入名称搜索" width="80%" v-model="search.materialName"></u--input>
|
|
</view>
|
<view class="datum_headers_right">
|
<view @click="changeDatum()">
|
<u-input v-model="search.materialTypeValue" disabled disabledColor="#FFFFFF" placeholder="资料类型" suffixIcon="arrow-down-fill" suffixIconStyle="color: #909399" ></u-input>
|
</view>
|
<view style="width:60px;">
|
<u-button type="primary" color="#1977FF" text="查询" @click="searchDatumList"></u-button>
|
</view>
|
</view>
|
</view>
|
<view class="datum_main">
|
<scroll-view
|
scroll-y="true"
|
class="datum_index_scroll"
|
:scroll-top="scrollTop"
|
refresher-enabled="true"
|
refresher-background="#EAEAEA"
|
:refresher-triggered="triggered"
|
@refresherpulling="refresherrefresh"
|
@scrolltolower="scrolltoLower">
|
<view class="datum_main_list" v-for="(item,index) in datumLists" :key="index">
|
<view class="datum_main_text">{{item.materialName}}</view>
|
<view class="datum_main_btns">
|
<view class="datum_main_btn" style="margin-right: 3px;" @click="lookBtn(item)">查看</view>
|
<view class="datum_main_btn" @click="downFile(item)">下载</view>
|
</view>
|
</view>
|
<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
|
</scroll-view>
|
</view>
|
<u-picker
|
:show="showDatum"
|
:columns="datumColumns"
|
keyName="dictName"
|
@cancel="showDatum = false"
|
@confirm="selectDatum">
|
</u-picker>
|
</view>
|
</template>
|
|
<script>
|
import { throttle } from '../../plugins/public.js';
|
export default{
|
data(){
|
return{
|
search:{
|
materialType:null
|
},//查询条件
|
showDatum:false,//是否展示资料类型弹框
|
datumColumns:[],//资料类型
|
datumLists:[
|
],//安全资料列表数据
|
pageNum: 1,
|
pageSize: 10,
|
loadPage: 0,
|
scrollTop: 0,
|
triggered: true,
|
status: 'loading',
|
loadText: {
|
loading: '努力加载中',
|
nomore: '没有更多数据了'
|
},
|
}
|
},
|
onLoad() {
|
this.getAllDatums()
|
this.searchDatumList()
|
},
|
methods:{
|
//下载按钮
|
downFile(item){
|
uni.showLoading({
|
title: '加载中...',
|
mask: true
|
})
|
this.$api.reboSystem.detailsDatumInfo({materialId:item.materialId}).then(res=>{
|
if(res.statusMsg === 'ok'){
|
uni.downloadFile({
|
url: `https://pipe.thhy-tj.com/${res.data.materialPaths[0].materialPath}`,
|
success: function (res) {
|
uni.saveFile({
|
tempFilePath:res.tempFilePath,
|
success:function(ress){
|
uni.hideLoading()
|
uni.openDocument({
|
filePath: ress.savedFilePath,
|
showMenu:true,
|
// fileType:val.split('.')[1],
|
success: function (res) {
|
console.log('打开文档成功');
|
}
|
});
|
}
|
})
|
|
}
|
});
|
}else{
|
uni.$u.toast(res.statusMsg);
|
}
|
})
|
},
|
//查看按钮
|
lookBtn(item){
|
this.$api.reboSystem.detailsDatumInfo({materialId:item.materialId}).then(res=>{
|
if(res.statusMsg === 'ok'){
|
this.seeFile(res.data.materialPaths[0].materialPath)
|
}else{
|
uni.$u.toast(res.statusMsg);
|
}
|
})
|
},
|
//查看文件
|
seeFile(val){
|
uni.showLoading({
|
title: '加载中...',
|
mask: true
|
})
|
uni.downloadFile({
|
url: `https://pipe.thhy-tj.com/${val}`,
|
success: function (res) {
|
var filePath = res.tempFilePath;
|
uni.hideLoading()
|
uni.openDocument({
|
filePath: filePath,
|
showMenu:true,
|
fileType:val.split('.')[1],
|
success: function (res) {
|
console.log('打开文档成功');
|
}
|
});
|
}
|
});
|
},
|
//获取资料类型
|
async getAllDatums(){
|
let params = {
|
dictType: 16,
|
pageNum: 1,
|
pageSize: 100000000,
|
}
|
const {data} = await this.$api.reboSystem.getDatnmSafeType(params)
|
this.datumColumns = [data.list]
|
},
|
//打开资料类型
|
changeDatum(){
|
this.showDatum = true;
|
this.$set(this.search, 'materialType', '');
|
this.$set(this.search, 'materialTypeValue', '');
|
},
|
// 确认选择资料类型
|
selectDatum({ value }) {
|
this.$set(this.search, 'materialType', value[0].dictId);
|
this.$set(this.search, 'materialTypeValue', value[0].dictName);
|
this.showDatum = false;
|
},
|
//查询列表
|
searchDatumList(){
|
this.triggered = true;
|
this.datumLists =[]
|
let params = Object.assign({},this.search,{
|
pageNum: this.pageNum,
|
pageSize:this.pageSize,
|
})
|
this.$api.reboSystem.searchDatumLists(params).then(res=>{
|
if(res.statusMsg === 'ok'){
|
this.datumLists = res.data.list
|
this.loadPage = res.data.pages;
|
this.triggered = false;
|
this.status = 'nomore';
|
}else{
|
uni.$u.toast(res.statusMsg);
|
}
|
}).catch((err) => {
|
uni.$u.toast('请检查网络服务或联系管理员!')
|
})
|
},
|
//自定义下拉刷新
|
refresherrefresh: throttle(function() {
|
this.status = 'loading';
|
this.pageNum = 1;
|
this.searchDatumList();
|
uni.$u.toast('刷新成功');
|
}, 500),
|
//触底刷新
|
scrolltoLower: throttle(function() {
|
this.status = 'loading';
|
if(this.pageNum >= this.loadPage) {
|
setTimeout(() => {
|
this.status = 'nomore'
|
uni.$u.toast('没有更多数据了');
|
},1000)
|
return
|
} else {
|
this.pageNum+=1
|
let params =Object.assign({},this.search,{
|
pageNum: this.pageNum,
|
pageSize:this.pageSize,
|
})
|
this.$api.reboSystem.searchDatumLists(params).then(res=>{
|
if(res.statusMsg === 'ok'){
|
this.datumLists.push(...res.data.list)
|
this.loadPage = res.data.pages;
|
this.triggered = false;
|
this.status = 'nomore';
|
}else{
|
uni.$u.toast(res.statusMsg);
|
}
|
}).catch((err) => {
|
uni.$u.toast('请检查网络服务或联系管理员!')
|
})
|
}
|
}, 1500),
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.datum_index{
|
background-color: #FFFFFF;
|
height: 100vh;
|
padding: 0 15px;
|
overflow: hidden;
|
|
.datum_headers{
|
height: 10vh;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
border-bottom: 1px solid #EAEAEA;
|
.datum_headers_left{
|
width: 40%;
|
display: flex;
|
margin-right: 10px;
|
}
|
.datum_headers_right{
|
width: calc(60% - 10px);
|
display: flex;
|
}
|
}
|
.datum_main{
|
height: calc(100vh - 150px);
|
.datum_index_scroll{
|
height: 90%;
|
|
.datum_main_list{
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
line-height: 50px;
|
border-bottom: 1px solid #EAEAEA;
|
.datum_main_text{
|
font-size: 17px;
|
color: #333333;
|
}
|
.datum_main_btns{
|
display: flex;
|
height: 26px;
|
.datum_main_btn{
|
display: flex;
|
align-items: center;
|
padding: 2px 8px;
|
color: #1977FF;
|
background-color: #EDF4FF;
|
font-size: 13px;
|
border: 0.5px solid #1977FF;
|
}
|
}
|
}
|
}
|
}
|
}
|
::v-deep .u-border{
|
border-top-right-radius: 0px!important;
|
border-bottom-right-radius: 0px!important;
|
border-color: #1977FF!important;
|
}
|
::v-deep .u-button--square{
|
border-top-left-radius: 0px!important;
|
border-bottom-left-radius: 0px!important;
|
}
|
::v-deep .u-button{
|
height: 38px !important;
|
}
|
</style>
|