yxk_h5_master/components/xinsoft-search-list/chooseCodeMulti.vue

700 lines
17 KiB
Vue
Raw Permalink 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="search-list-container" v-show="showsearch">
<view class="search-list-out">
<view class="search-container">
<view class="back_btn" @click="toBack">
<uni-icons type="arrowleft" size="30" color="#999"></uni-icons>
</view>
<view class="search-title">关联单据列表</view>
<view class="search_btn1" @click="to_sure">确定</view>
<view class="search_btn" @click="to_search">搜索</view>
</view>
<view class="search-container2" style="height: 40px;">
<view class="search-container2-flex">
<view style="width: 25%;">
<xinsoft-sl-filter :ref="'slFilter'" style="left: 0;" :menuList.sync="menuListLeft"
@result="getFilter"></xinsoft-sl-filter>
<!-- <uni-icons color="#bbb" size="20" type="search" class="my-uni-icon-search"></uni-icons>
<input style="text" class="input-" placeholder="物料编号、物料名称" v-model="inputText" />
<uni-icons color="#bbb" size="20" type="close" class="my-uni-icon-close" v-if="inputText.length > 0" @click="clearInput"></uni-icons> -->
</view>
<view class="searchSelectBox" style=" width:75%;">
<view style="display: flex;">
<input type="text" placeholder="供应商" disabled
style="width: 30%;background: #F6F6F6;border-radius: 40px;text-align: center;height: 30px;"
v-model="supplierName">
<view class="text" style="width: 65%;" @click="filterDate">
{{timeData.begin==''?'填报时间':(timeData.begin+'~'+timeData.end)}}</view>
</view>
<!-- <xinsoft-sl-filter
:topFixed="fixed"
ref="slFilter"
:color="titleColor"
:themeColor="themeColor"
:menuList.sync="menuList"
@result="getFilter"
></xinsoft-sl-filter> -->
</view>
</view>
</view>
<view class="search-list" style="top: 90px;">
<view class="panel flex-column">
<view class="flex-row" v-for="(item1, index1) in dataList" @click="chooseItem(item1, index1)"
:key="index1" @touchmove="hiddenkeyboard">
<view class="flex-cell-single ">
<span>单据编号:</span>
{{ item1.contractCode }}
</view>
<view class="flex-cell-single">
<span>供应商:</span>
{{ item1.supplierName }}
</view>
<view class="flex-cell-single">
<span>应付日期:</span>
{{ item1.dueDate }}
</view>
<view class="flex-cell-single">
<span>应付金额:</span>
{{ item1.payAmount }}
</view>
<view class="flex-cell-single">
<span>已付金额:</span>
{{ item1.amountPaid }}
</view>
<view class="flex-cell-single">
<span>未付金额:</span>
{{ item1.unpayAmount }}
</view>
<uni-icons type="checkbox-filled" size="20" :color="item1.checked ? '#3699FF' : '#CECECE'"
class="checkbox-filled"></uni-icons>
</view>
</view>
<view class="toloadmore" v-show="show_toloadmore && !show_search_none && !loadingmore"
@click.stop="mysearchlist_">查看更多</view>
<view class="loading-container" v-if="loadingmore">加载中...</view>
<view class="search_none" v-show="show_search_none">搜索结果为空</view>
</view>
</view>
<!-- 时间组件 -->
<uni-calendar ref="calendar" :lunar="false" :range="true" @confirm="confirmDate" />
</view>
</template>
<script>
import xinsoftSlFilter from '@/components/xinsoft-sl-filter/xinsoft-sl-filter.vue';
import uniIcons from '../uni-icons/uni-icons.vue';
import uniCalendar from '@/components/uni-calendar/uni-calendar.vue'
var searchListHeight, panelHeight, query;
var timeout = '';
export default {
mounted() {},
components: {
uniIcons,
xinsoftSlFilter,
uniCalendar
},
data() {
return {
url_: '/apis/user/list',
list_: [],
list2_: [],
supplierName: '', //供应商名称
loadingmore: false,
lastpage: false, //是否加载完最后一页数据了
show_search_none: false,
show_toloadmore: false,
inputText: '',
lastIndex: 0, //加载列表翻页数据时上一页的最后一个index
pagesize: 10, //每页显示多少条
pageno: 1, //第几页
dataList: [], //显示在页面的列表数据
themeColor: '#000000',
titleColor: '#666666',
fixed: true,
numType: '',
timeData: {
begin: "",
end: ''
}, //时间
menuListLeft: [{
'title': '采购合同',
'isMutiple': false,
'key': 'num',
'detailList': [{
'title': '采购订单',
'value': ''
},
{
'title': '委外合同',
'value': 271
},
{
'title': '其他应付',
'value': 296
}
],
'defaultSelectedIndex': [0]
}],
defaultFacility: '',
spartType: '',
formInfo: ''
};
},
props: {
showsearch: {
type: Boolean
},
itemInfo_: {},
singleRow: {
type: Array,
default: function() {
return [];
}
}
},
mounted() {
//备件类型
var _this = this;
this.formInfo = uni.getStorageSync('formInfo')
this.supplierName = uni.getStorageSync('formInfo').payApply.supplierName
this.$http
.request({
url: '/apis/dict/getDictsByType',
params: {
type: 'sparepart_type'
}
})
.then(res => {
if (res.data.code == 0) {
_this.menuList[0].detailList = [{
title: '不限',
value: ''
}];
var useType = res.data.datas;
for (let i = 0; i < useType.length; i++) {
var myVal = {
title: useType[i].name,
value: useType[i].id
};
_this.menuList[0].detailList.push(myVal);
}
}
})
.catch(err => {});
//仓库
var _this = this;
this.$http
.request({
url: '/apis/dict/getDictsByType',
params: {
type: 'fac_type'
}
})
.then(res => {
if (res.statusCode == '200') {
_this.menuList[1].detailList = [{
title: '不限',
value: ''
}];
var useType = res.data.datas;
for (let i = 0; i < useType.length; i++) {
var myVal = {
title: useType[i].name,
value: useType[i].id
};
_this.menuList[1].detailList.push(myVal);
}
}
})
.catch(err => {});
},
watch: {
showsearch(newv) {
if (newv) {
this.to_search();
}
}
},
methods: {
hiddenkeyboard() {
uni.hideKeyboard();
},
chooseItem(item, index) {
if (item.checked == undefined) {
this.$set(this.dataList[index], 'checked', true);
} else {
this.$set(this.dataList[index], 'checked', !this.dataList[index].checked);
}
},
clearAll() {
this.list_ = [];
this.show_search_none = false;
this.loadingmore = false;
this.show_toloadmore = false;
this.inputText = '';
this.lastIndex = 0;
this.dataList = [];
this.$emit('update:showsearch', false);
},
mysearchlist_() {
if (!this.lastpage) {
this.mysearchinput_();
}
},
clearInput() {
this.inputText = '';
},
toBack() {
this.clearAll();
uni.hideKeyboard();
},
to_search() {
this.loadingmore = true;
this.show_toloadmore = false;
this.show_search_none = false;
var v = this;
this.pageno = 1;
this.dataList = [];
v.set_request();
},
//筛选条件
getFilter(filterRes) {
this.numType = filterRes.num
this.set_request()
},
set_request() {
let filterRes = {
pagesize: this.pagesize,
pageno: this.pageno,
isDialog: 1,
closeStatus: 0,
auditSign: 179,
supplierId: this.formInfo.payApply.supplierId,
supplierName: this.formInfo.payApply.supplierName,
startTime: this.timeData.begin,
endTime: this.timeData.end
};
this.loadingmore = true;
var url = ''
if (this.numType == '') {
// console.log(url)
url = '/apis/scm/purchaseContractPay/contractPayList'
} else if (this.numType == 271) {
url = '/apis/outsourcingContract/payList'
} else if (this.numType == 296) {
url = '/apis/scm/otherPayable/listForIncoming'
}
this.$http
.request({
url: url,
data: filterRes,
method: 'POST',
header: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.then(res => {
this.loadingmore = false;
if (res.data.code !== 0) {
uni.showToast({
title: res.msg,
icon: 'none',
duration: 2000
});
return false;
}
if (!res.data.data) {//当借口返回为空时
this.dataList=[]//列表置空
if (this.pageno == 1) {
//搜索结果为空
this.show_search_none = true;
}
//最后一页搜索结果为空
this.show_toloadmore = false;
return false;
}
if (res.data.code == 0 && res.data.data.datas) {
this.show_search_none = false;//搜索结果为空的字段隐藏
// this.pageno = this.pageno + 1;
if (this.numType == '') {
this.dataList = []
this.dataList = this.dataList.concat(res.data.data.datas); //采购订单
this.$forceUpdate()
} else if (this.numType == 296) {
this.dataList = []
res.data.data.datas.forEach(item => {
let arr = {}
arr.payAmount = item.receivablePayablesAmount
arr.contractCode = item.code
arr.supplierName = item.supplierClientName
arr.dueDate = item.accrualDate
arr.unpayAmount = item.noReceiptPaymentAmount
arr.amountPaid = item.paidReceivedAmount ? item.paidReceivedAmount : 0
arr.payId = item.id
this.dataList.push(arr)
this.$forceUpdate()
})
} else if (this.numType == 271) { //委外合同
this.dataList = []
res.data.data.datas.forEach(item => {
let arr = {}
arr.payAmount = item.payableAmount
arr.contractCode = item.contractCode
arr.supplierName = item.supplierName
arr.dueDate = item.payableDate
arr.unpayAmount = item.unpaidAmount
arr.amountPaid = item.paidAmount
arr.payId = item.id
this.dataList.push(arr)
this.$forceUpdate()
})
}
if (this.pagesize == res.data.data.datas.length) {
this.show_toloadmore = true;
} else if (this.pagesize > res.data.data.datas.length) {
//已经加载到最后一页了
this.show_toloadmore = false;
}
}
// this.$nextTick(function() {
// //首次加载高度没有撑满页面,继续加载下一页
// query = uni.createSelectorQuery().in(this);
// query
// .select('.search-list')
// .boundingClientRect(data => {
// searchListHeight = data.height;
// })
// .exec();
// query
// .select('.panel')
// .boundingClientRect(data => {
// panelHeight = data.height;
// if (panelHeight <= searchListHeight && res.data.data != undefined) {
// this.mysearchinput_();
// }
// })
// .exec();
// });
})
.catch(err => {
this.loadingmore = false;
if (res.errMsg == 'request:fail timeout') {
uni.showToast({
title: '请求超时',
icon: 'none',
duration: 2000
});
} else {
uni.showToast({
title: '请求失败',
icon: 'none',
duration: 2000
});
}
});
},
mysearchinput_() {
this.set_request(this.inputText);
},
to_sure() {
let list = [];
for (var i = 0; i < this.dataList.length; i++) {
let arr={}
if (this.dataList[i].checked) {
arr.dueDate=this.dataList[i].dueDate.split(' ')[0]
arr.payableAmount=this.dataList[i].payAmount
arr.paidAmount=this.dataList[i].amountPaid
arr.unpaidAmount=this.dataList[i].unpayAmount
arr.sourceType=this.dataList[i].thisSourceType == 205 ? 0 : this.dataList[i].thisSourceType == 271 ? 1 : 2
arr.sourceTypeName=this.dataList[i].thisSourceTypeName
arr.sourceCode=this.dataList[i].contractCode
arr.sourceId=this.dataList[i].id
arr.payAmount=0
arr.remark=''
list.push(arr);
}
}
this.$emit('update:itemInfo_', list);
this.clearAll();
uni.hideKeyboard();
},
// 时间弹窗
filterDate() {
this.$refs.calendar.open();
},
// 选择时间
confirmDate(e) {
if (e.range.begin && e.range.end) {
this.timeData = {
begin: e.range.begin,
end: e.range.end
}
this.dataList = [];
this.page = 1;
this.loading_status = "more";
this.set_request()
}
}
}
};
</script>
<style scoped>
.search-container,
.search-container2 {
position: fixed;
z-index: 10;
width: 100%;
background-color: #fff;
left: 0;
}
/* 下拉框样式 */
>>>.select-tab-fixed-top {
left: 0;
width: 25% !important;
}
>>>.select-tab-item {
width: 100% !important;
}
.search-container {
border-bottom: 1px solid #d9d9d9;
box-sizing: border-box;
height: 50px;
box-sizing: border-box;
}
.search-container2 {
top: 50px;
height: auto;
}
.search-container2-flex {
position: relative;
align-items: center;
height: 100%;
padding: 0 5px;
display: flex;
box-sizing: border-box;
justify-content: space-around;
flex-wrap: wrap;
}
.search-input {
position: relative;
height: 30px;
border: 1px solid #e6e6e6;
border-radius: 15px;
box-sizing: border-box;
}
.search-title {
position: absolute;
left: 60px;
right: 60px;
height: 50px;
line-height: 50px;
text-align: center;
font-size: 18px;
color: #000;
}
.searchSelectBox {
float: left;
}
.searchSelectBox .text {
margin: 0px 3%;
background: #f6f6f6;
border-radius: 40px;
width: 94%;
line-height: 30px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 14px;
text-align: center;
color: #333;
}
.my-uni-icon-search {
line-height: 30px;
margin-left: 5px;
}
.input- {
position: absolute;
height: 100%;
left: 30px;
top: 0;
right: 0px;
border: none;
outline: medium;
color: #666;
font-size: 14px;
padding: 0 30px 0 0 !important;
box-sizing: border-box;
}
.my-uni-icon-close {
position: absolute;
height: 30px;
width: 30px;
right: 0px;
line-height: 30px;
top: 0;
text-align: center;
}
.search_btn,
.search_btn1,
.back_btn {
position: absolute;
width: 50px;
height: 30px;
right: 5px;
top: 10px;
font-size: 16px;
line-height: 30px;
text-align: center;
color: #007aff;
}
.search_btn1 {
right: 55px;
}
.back_btn {
left: 5px;
right: auto;
color: #999;
}
.search-list-container {
position: fixed;
z-index: 10000;
width: 100%;
left: 0;
top: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
}
.search-list-out {
position: absolute;
width: 100%;
left: 0;
top: 0px;
bottom: 0;
background-color: #fff;
z-index: 1;
}
.search-list {
position: absolute;
overflow: scroll;
bottom: 0;
width: 100%;
left: 0;
}
.panel view {
line-height: 20px;
padding: 8px 10px 8px 10px;
box-sizing: border-box;
}
.panel .flex-row:nth-of-type(even) {
//奇数
background-color: #efefef;
}
.panel .flex-row:nth-of-type(odd) {
//偶数
background-color: #f9f9fb;
}
.flex-row {
position: relative;
width: 100%;
padding-right: 45px !important;
/* display: flex; */
/* flex-direction: row; */
}
.flex-column {
display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
}
.flex-cell {
width: 50%;
float: left;
text-align: left;
/* display: flex;
font-size: 15px;
flex: 1;
justify-content: center;
align-items: center; */
}
.flex-cell-single {
width: 100%;
float: left;
}
.flex-cell-single span,
.flex-cell span {
color: #999;
}
.search_none,
.toloadmore {
position: relative;
font-size: 16px;
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
background-color: #fff;
left: 0;
}
.toloadmore {
color: #666;
}
.loading-container {
position: relative;
font-size: 16px;
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
background-color: #fff;
left: 0;
}
.checkbox-filled {
right: 10px;
}
>>>.select-tab-fixed-top {
right: 0;
width: 50%;
z-index: 2;
top: 50px;
white-space: nowrap;
}
</style>