yxk_h5_master/pages/eqUpkeep/sparePartSearch.vue

327 lines
7.6 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="content">
<view v-for="(item,index) in listCards" :key="index" class="example-box" style="position: relative;flex: 1;" @click="toDetail(item,index)">
<dev-block :title="item.title" :titleNumber="item.titleNumber" :note="item.note" :extra="item.extra" :tagType="item.tagType"
:contentList="item.contentList" ></dev-block>
<uni-icons type="arrowright" size="20" color="#666" class="arrowright" ></uni-icons>
</view>
<uni-load-more :status="loading_status" v-if="!show_no"></uni-load-more>
<xinsoft-no-record noRecordContent="暂无满足条件的内容,请输入关键字重新搜索" v-if='show_no'></xinsoft-no-record>
<view class="goHome" @click='goMain()'>
<img src="../../static/img/gohome.png">
</view>
</view>
</template>
<script>
import {
mapState,
mapMutations
} from 'vuex'
import devBlock from '@/components/xinsoft-dev-block/xinsoft-dev-block.vue'
import uniIcons from '@/components/uni-icons/uni-icons.vue'
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
import xinsoftNoRecord from '@/components/xinsoft-no-record/xinsoft-no-record.vue';
export default {
components: {
devBlock,
uniIcons,
uniLoadMore,xinsoftNoRecord
},
data() {
return {
search_text:'',
listCards: [],
themeColor: '#000000',
titleColor: '#666666',
pagenumber:1,//当前第几页
pagesize:20,//每页加载数据条数
loading_status: 'more',//moreloading前、loadingloading中、noMore没有更多了
show_no:false,
id:'',
previousUrl:''
}
},
// onShow(){
// var _this=this;
// this.$eventHub.$on('changestate', function (data) {
// var datajson=data;
// console.log(datajson);
// if(datajson.id){
// for(var i=0;i<_this.listCards.length;i++){
// if(_this.listCards[i].id==datajson.id){
// var str=_this.listCards[i].title;
// _this.listCards[i].title=str.split('-')[0]+"-"+datajson.state;
// }
// }
// }
// _this.$eventHub.$off('changestate');
// });
// },
onLoad(option) {
this.id = option.id;
},
computed: {
...mapState(['keepPartList']),
},
created() {
this.getDateList();
},
//滚动到底部加载下一页
onReachBottom(obj){
if(this.loading_status=='noMore'){
return false;
}
this.pagenumber++;
this.getDateList();
},
//下拉刷新
onPullDownRefresh(){
this.listCards=[];
this.pagenumber=1;
this.loading_status="more";
this.show_no=false;
this.getDateList();
},
methods: {
...mapMutations(['setkeepPartList']),
//获取列表数据
getDateList(){
this.loading_status="loading";
var filterRes = {};
filterRes.pageno = this.pagenumber;
filterRes.pagesize = this.pagesize;
filterRes.query=this.search_text;
this.$http.request({
url: '/apis/materiel/list',
params: filterRes,
method:"GET"
}).then(res => {
uni.stopPullDownRefresh();
if(!res.data.data){
if(this.listCards.length==0){
this.show_no=true;
}else{
this.loading_status="noMore";
}
}else if(res.data.data.datas.length<this.pagesize){
this.loading_status="noMore";
}else{
this.loading_status="more";
}
if (res.data.code == 0) {
this.listCards = this.listCards.concat(this.formaterData(res.data.data.datas));
}
}).catch(err => {
console.log(err)
this.loading_status="noMore";
uni.showToast({
title: '获取信息失败',
duration: 2000,
icon:"none"
});
});
},
//时间格式化
setTime1(time) {
if(time){
var t = time.split('-');
return t[0] + '/' + t[1] + '/' + t[2].substring(0, 8)
}else{
return " "
}
},
//设置状态颜色
setTag(val) {
if (val == 50) {
return "106";
} else if (val == 49) {
return "108";
} else {
return "106";
}
},
//列表数据格式化
formaterData(data) {
var resData = [];
data.forEach((vals, index) => {
var combineJSON = {
id: vals.id,
title: vals.name,
amount:1,//数量
price:vals.salePrice,//单价
titleNumber:"["+vals.serialNo+"]",
checked:false,
contentList: [{
id: 1,
isDouble: true,
labelName: '规格型号',
labelContent: vals.specification
},
{
id: 2,
isDouble: true,
labelName: '库位',
labelContent: vals.defaultFacilityName
},
{
id: 3,
isDouble: true,
labelName: '设备类型',
labelContent: vals.typeName
}
],
}
resData.push(combineJSON);
});
return resData;
},
//查看详情
toDetail(item,index){
var _this=this;
uni.showModal({
title: '提示',
content: '确定选择'+item.title+"吗?",
success: function (res) {
if (res.confirm) {
var keepPartList=_this.keepPartList.keepPartList
keepPartList.push(item)
_this.setkeepPartList({id:_this.id,keepPartList:keepPartList});
uni.redirectTo({
url:'keepStep2?id='+_this.id
});
} else if (res.cancel) {
}
}
})
},
},
onPageScroll : function(e) {
uni.hideKeyboard()
},
//搜索框文本变化
onNavigationBarSearchInputChanged(n){
this.search_text=n.text;
},
//点击软键盘搜索按钮
onNavigationBarSearchInputConfirmed(){
this.listCards=[];
this.pagenumber=1;
this.loading_status="more";
this.show_no=false;
this.getDateList();
},
//点击搜索按钮
onNavigationBarButtonTap(obj) {
this.listCards=[];
this.pagenumber=1;
this.loading_status="more";
this.show_no=false;
this.getDateList();
},
onBackPress(options) { //取消默认的返回事件.
if (options.from === 'backButton' || options.from === 'backbutton' || options.from === 'navigateBack') {
uni.redirectTo({
url:'keepStep2?id='+this.id
});
return true;
}
},
}
</script>
<style>
page{
height: 100%;
}
</style>
<style scoped>
>>>.noRecord{
padding-top: 30%;
margin-top: 0 !important;
}
.content{
position: relative;
}
.filter_container {
position: fixed;
width: 50%;
top: var(--window-top);
background-color: #fff;
height: 40px;
z-index: 2;
padding-top: 7px;
box-sizing: border-box;
}
>>>.doubleList:nth-of-type(1) {
width: 60%;
}
>>>.doubleList:nth-of-type(2) {
width: 40%;
}
>>>.doubleList:nth-of-type(3) {
width: 60%;
}
>>>.doubleList:nth-of-type(4) {
width: 40%;
}
>>>.dev-label{
white-space: nowrap;
}
>>>.select-tab-fixed-top{
right: 0;
width: 50%;
z-index: 2;
top:var(--window-top);
}
>>>.popup-layer{
position: fixed;
top: var(--window-top);
margin-top: 40px;
}
.search_container {
position: relative;
padding-left: 30px;
box-sizing: border-box;
color: #bdbdbd;
margin: auto;
width: 80%;
height: 26px;
background-color: #F6F6F6;
border-radius: 26px;
font-size: 14px;
line-height: 26px;
}
.search_icon{
position: absolute;
left: 5px;
top: 3px;
}
.fliter_content {
position: absolute;
right: 15px;
left: 85px;
height: 100%;
z-index: 2;
}
.arrowright{
position: absolute;
right: 30upx;
bottom: 30upx;
font-size: 40upx !important;
}
</style>