<template>
<view>
<view class="header border-bottom">
<view :style="{height: systemBarHeight}"></view>
<view class="headertop px-2 d-flex a-center j-sb">
<view class="mr-5" @click="nextBack">
<image style="width: 45rpx;height: 45rpx;" src="../../static/back.png" mode=""></image>
</view>
<view class="wrapInput py-1 px-3 flex-1">
<input v-model="keyword" type="text" placeholder='请输入关键字'>
</view>
<view class="ml-4 search" @click="searchBtn">搜索</view>
</view>
<view class="d-flex a-center bg-white">
<view class="flex-1">
<uni-data-select v-model="subId" :localdata="SubCategoryList" placeholder="请选择标准"></uni-data-select>
</view>
<view class="flex-1">
<uni-data-select v-model="status" :localdata="range"></uni-data-select>
</view>
</view>
</view>
<view :style="{height: fixedHeight}"></view>
<view class="p-2">
<view class="wrap p-2 mb-2" v-for="(item,index) in tableData" :key="index" @click="nextTo(item)">
<view class="mb-1 font-weight">{{item.FileName}}</view>
<view class="d-flex">
<view class="flex-1 text-one-line">文号:{{item.WenHao}}</view>
<view class="flex-1 text-one-line ml-3">实施日期: {{item.ExecDate}}</view>
</view>
<view class="d-flex">
<view class="flex-1 text-one-line">{{item.SubCategory}}</view>
<view class="flex-1 text-one-line ml-3 d-flex">
<view>{{item.DeptName}}</view>
<view class="ml-2">{{item.StatusText}}</view>
</view>
</view>
</view>
<u-modal showCancelButton @cancel="show=false" @confirm="openFile" :show="show" :title="title" :content='content'></u-modal>
<u-loadmore class="mt-1" :status="status" :loading-text="loadingText" :loadmore-text="loadmoreText"
:nomore-text="nomoreText" :line="true" />
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 系统状态栏的高度
systemBarHeight: 0,
fixedHeight: 0,
categoryId: 0,
keyword: '',
page: 1,
pageSize: 10,
totalPages: null,
tableData: [],
show:false,
title:'浏览文件',
content:'文件需要通过第三方软件打开,是否继续?',
openUrl:'',
status: 'nomore',
loadingText: '努力加载中',
loadmoreText: '',
nomoreText: '已加载全部数据',
SubCategoryList: [],
subId: '',
status: '',
range: [{
value: '',
text: "全部"
},
{
value: '1',
text: "现行"
},
{
value: '0',
text: "废止"
},
],
}
},
onLoad(opt) {
this.getSysteminfo()
console.log(JSON.parse(opt.data));
this.categoryId = JSON.parse(opt.data).id
this.getSubCategoryList()
this.getFileList()
},
onReachBottom() {
if (this.page >= this.totalPages) {
this.status = 'nomore'
return;
}
this.page++;
this.getFileList()
},
methods: {
nextTo(item) {
console.log(item.FilePath);
console.log(this.$http.pdfUrl);
var filename = item.FilePath;
var extension = filename.split('.').pop();
let url = this.$http.pdfUrl + item.FilePath
this.openUrl=url
console.log(extension);
if (extension == 'pdf') {
// let url = 'http://192.168.0.3:9996' + item.FilePath
uni.navigateTo({
url: '/pages/officefile/officefile?url=' + url
})
} else {
this.show=true
}
// let url = 'http://192.168.0.3:9996' + item.FilePath
// uni.navigateTo({
// url: '/pages/officefile/officefile?url=' + url
// })
},
openFile(){
var dtask = plus.downloader.createDownload(this.openUrl, {}, function(d, status) {
if (status == 200) {
var fileUrl = d.filename;
plus.runtime.openFile(fileUrl, {}, function(e) {
plus.nativeUI.alert("打开失败!");
});
} else {
alert("Download failed: " + status);
}
});
dtask.start();
this.show=false
},
searchBtn() {
this.page = 1,
this.pageSize = 10,
this.totalPages = null,
this.tableData = [],
this.getFileList()
},
getFileList() {
let data = {
categoryId: this.categoryId,
keyword: this.keyword,
subId: this.subId,
status: this.status,
page: this.page,
pageSize: this.pageSize
}
this.$http.get('App2/GetFileList', data).then(res => {
console.log(res, '11111111');
this.totalPages = res.TotalPages
this.tableData = this.tableData.concat(res.data)
})
},
getSysteminfo() {
uni.getSystemInfo({
success: res => {
this.systemBarHeight = res.statusBarHeight + 'px';
this.fixedHeight = res.statusBarHeight + 88 + 'px'
}
});
},
getSubCategoryList() {
this.$http.get('App2/GetSubCategoryList?categoryId=' + this.categoryId).then(res => {
console.log(res);
this.SubCategoryList = res.map(item => {
return {
value: item.ID,
text: item.Name
}
})
})
},
nextBack() {
uni.navigateBack()
}
}
}
</script>
<style lang="scss">
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: #fff;
z-index: 999;
background-color: #3d7eff;
}
.headertop {
height: 88rpx;
width: 100%;
background-color: #3d7eff;
}
.wrapInput {
// background-color: rgba(0, 0, 0, 0.2);
background-color: #fff;
border-radius: 10rpx;
}
.search {
color: #fff;
font-size: 14px;
}
.wrap {
background-color: #fff;
border-radius: 15rpx;
box-shadow: 0 5rpx 10rpx rgba(0, 0, 0, .2);
}
</style>