fix: BUG修改

This commit is contained in:
kun 2024-04-21 09:50:53 +08:00
parent 13ce4f5397
commit 18a7dc4759
2 changed files with 129 additions and 105 deletions

View File

@ -9,8 +9,9 @@
<view class="searchBox"> <view class="searchBox">
<form @submit="formSubmit"> <form @submit="formSubmit">
<view class="uni-form-item"> <view class="uni-form-item">
<input class="uni-input" name="searchName" v-model="searchName" @input="searchFile" placeholder="请输入文件名" /> <input class="uni-input" name="searchName" v-model="searchName" @input="searchFile"
<button class="mini-btn" type="primary" size="mini" @click="loadData">搜索</button> placeholder="请输入文件名" />
<button class="mini-btn" type="primary" size="mini" @click="loadData">搜索</button>
<!-- <uni-icons class="search-icon" type="search" @click="loadData"></uni-icons> --> <!-- <uni-icons class="search-icon" type="search" @click="loadData"></uni-icons> -->
</view> </view>
</form> </form>
@ -24,8 +25,8 @@
<image @click="downloadFn(item)" class="ellipsis" src="../../static/ellipsis.png"></image> <image @click="downloadFn(item)" class="ellipsis" src="../../static/ellipsis.png"></image>
</view> </view>
</view> </view>
<view class="placeholderBox" v-else> <view class="placeholderBox" v-else>
<image src="/static/noData.png" class="noDataImg"></image> <image src="/static/noData.png" class="noDataImg"></image>
<view class="text"> <view class="text">
@ -39,77 +40,85 @@
<script> <script>
import headers from '../../components/headers/headers.vue' import headers from '../../components/headers/headers.vue'
export default { export default {
components:{headers}, components: {
headers
},
data() { data() {
return { return {
searchName:'', searchName: '',
fileList:[], fileList: [],
timer: null, timer: null,
fileImg1: require("../../static/ppt.png"), fileImg1: require("../../static/ppt.png"),
fileImg2: require("../../static/excel.png"), fileImg2: require("../../static/excel.png"),
fileImg3: require("../../static/pdf.png"), fileImg3: require("../../static/pdf.png"),
fileImg4: require("../../static/word.png"), fileImg4: require("../../static/word.png"),
}; };
}, },
mounted(){ mounted() {
this.loadData() this.loadData()
}, },
methods:{ methods: {
parseFileImgFn(url) { parseFileImgFn(url) {
var type = url.split(".")[1]; var type = url.split(".")[1];
if (type == "ppt" || type == "pptx") { if (type == "ppt" || type == "pptx") {
return this.fileImg1; return this.fileImg1;
} }
if (type == "xls" || type == "xlsx") { if (type == "xls" || type == "xlsx") {
return this.fileImg2; return this.fileImg2;
} }
if (type == "pdf") { if (type == "pdf") {
return this.fileImg3; return this.fileImg3;
} }
if (type == "doc" || type == "docx") { if (type == "doc" || type == "docx") {
return this.fileImg4; return this.fileImg4;
} }
}, },
formSubmit(e){ formSubmit(e) {
// console.log(e) // console.log(e)
this.searchName = e.detail.value.searchName this.searchName = e.detail.value.searchName
this.loadData() this.loadData()
}, },
searchFile(e){ searchFile(e) {
this.searchName = e.detail.value this.searchName = e.detail.value
}, },
loadData(){ loadData() {
var json={ var json = {
companySn: JSON.parse(uni.getStorageSync('userInfo')).headquartersSn, // companySn: JSON.parse(uni.getStorageSync('userInfo')).headquartersSn,
fileName: this.searchName, fileName: this.searchName,
pageNo: 1, pageNo: 1,
pageSize: 100 pageSize: 100
} }
if ([2, 3, 4, 7].includes(JSON.parse(uni.getStorageSync('userInfo')).accountType)) {
json.companySn = JSON.parse(uni.getStorageSync('userInfo')).sn
}
if ([5, 6, 10].includes(JSON.parse(uni.getStorageSync('userInfo')).accountType)) {
json.projectSn = JSON.parse(uni.getStorageSync('userInfo')).sn
}
var that = this var that = this
this.sendRequest({ this.sendRequest({
url: "xmgl/companyFile/list", url: "xmgl/companyFile/list",
data: json, data: json,
method: "POST", method: "POST",
success(res){ success(res) {
console.log('文件数据',res); console.log('文件数据', res);
that.fileList=res.result.page.records that.fileList = res.result.page.records
} }
}) })
}, },
downloadFn(item){ downloadFn(item) {
var that = this var that = this
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: item.fileName, content: item.fileName,
confirmText:'下载', confirmText: '下载',
success: function (res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
uni.downloadFile({ uni.downloadFile({
url: that.url_config+'image/'+item.filePath, // url: that.url_config + 'image/' + item.filePath, //
success: (res) => { success: (res) => {
console.log(res) console.log(res)
if (res.statusCode === 200) { if (res.statusCode === 200) {
// uni.showToast({ // uni.showToast({
// title:'' // title:''
// }) // })
@ -121,21 +130,21 @@
console.log(res); console.log(res);
console.log('打开文档成功'); console.log('打开文档成功');
uni.showToast({ uni.showToast({
title:'打开文档成功' title: '打开文档成功'
}) })
} }
}); });
}else{ } else {
uni.showToast({ uni.showToast({
title:'下载失败' title: '下载失败'
}) })
} }
} }
}); });
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消'); console.log('用户点击取消');
} }
} }
}); });
} }
} }
@ -143,61 +152,70 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.filePage{ .filePage {
background-color: white; background-color: white;
height: 100%; height: 100%;
} }
.searchBox{
background-color: white; .searchBox {
} background-color: white;
.uni-input{ }
border-radius: 15px;
margin: 10px 10px; .uni-input {
background-color: #f2f2f2; border-radius: 15px;
height: 30px; margin: 10px 10px;
line-height: 30px; background-color: #f2f2f2;
padding: 0 20px; height: 30px;
font-size: 14px; line-height: 30px;
width: 65%; padding: 0 20px;
} font-size: 14px;
.fileItem{ width: 65%;
font-size: 15px; }
display: flex;
align-items: center; .fileItem {
justify-content: space-between; font-size: 15px;
padding: 20px 0;
margin: 0 10px;
color: $uni-text-color;
border-bottom: 1px solid rgba(221, 221, 221,0.8);
.left{
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between;
padding: 20px 0;
margin: 0 10px;
color: $uni-text-color;
border-bottom: 1px solid rgba(221, 221, 221, 0.8);
.left {
display: flex;
align-items: center;
}
.fileIcon {
width: 20px;
height: 22px;
margin-right: 10px;
}
.ellipsis {
width: 20px;
height: 5px;
}
} }
.fileIcon{
width: 20px; .uni-form-item {
height: 22px; position: relative;
margin-right: 10px;
.search-icon {
position: absolute;
top: 50%;
right: 50rpx;
transform: translateY(-50%);
}
} }
.ellipsis{
width: 20px; .mini-btn {
height: 5px;
}
}
.uni-form-item{
position: relative;
.search-icon{
position: absolute; position: absolute;
top: 50%; right: 6px;
right: 50rpx; top: 0px;
transform: translateY(-50%); border-radius: 15px;
height: 30px;
line-height: 30px;
} }
} </style>
.mini-btn{
position: absolute;
right: 6px;
top: 0px;
border-radius: 15px;
height: 30px;
line-height: 30px;
}
</style>

View File

@ -81,11 +81,17 @@
}, },
loadData(){ loadData(){
var json={ var json={
companySn: JSON.parse(uni.getStorageSync('userInfo')).headquartersSn, // companySn: JSON.parse(uni.getStorageSync('userInfo')).headquartersSn,
fileName: this.searchName, fileName: this.searchName,
pageNo: 1, pageNo: 1,
pageSize: 100 pageSize: 100
} }
if ([2, 3, 4, 7].includes(JSON.parse(uni.getStorageSync('userInfo')).accountType)) {
json.companySn = JSON.parse(uni.getStorageSync('userInfo')).sn
}
if ([5, 6, 10].includes(JSON.parse(uni.getStorageSync('userInfo')).accountType)) {
json.projectSn = JSON.parse(uni.getStorageSync('userInfo')).sn
}
var that = this var that = this
this.sendRequest({ this.sendRequest({
url: "xmgl/companyFile/list", url: "xmgl/companyFile/list",