yxk_h5_master/pages/eqRepair/turnToSearch.vue

226 lines
5.9 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="page">
<view class="mybox" v-if="listCards.length>0">
<view v-for="(item,index) in listCards" :key="index" class="people-box myContainer myContentBox" @click="selectPeople(item,index)">
<view class="name_">{{item.NAME}}</view>
<view class="user_container">
<img src="../../static/img/user2.png">
<view class="username">{{item.deptName}}</view>
</view>
<view class="user_container">
<img src="../../static/img/phone.png">
<view class="username">{{item.mobile}}</view>
</view>
</view>
<uni-load-more :status="loading_status"></uni-load-more>
</view>
<view class="mybox" v-else>
<xinsoft-no-record noRecordContent="暂无满足条件的内容,请输入关键字重新搜索" ></xinsoft-no-record>
</view>
<view class="goHome" @click='goMain()'>
<img src="../../static/img/gohome.png">
</view>
</view>
</template>
<script>
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: {
uniIcons,
uniLoadMore,xinsoftNoRecord
},
data() {
return {
id:'',
search_text:'',
listCards: [],
pagenumber:1,//当前第几页
pagesize:20,//每页加载数据条数
loading_status: 'more',//moreloading前、loadingloading中、noMore没有更多了
flag:'',
previousUrl:''
}
},
onLoad(option) {
//责任人和抄送人 维修指派
this.flag = option.flag;
this.previousUrl = option.url;
if(this.flag == 'wxzp'){ //维修指派
this.id = option.id;
if (this.id == undefined) {
uni.reLaunch({
url: 'eqRepair'
});
return false;
}
}
else if(this.flag == 'zrr'){ //责任人
}
else if(this.flag == 'csr'){ //抄送人
}
},
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.getDateList();
},
methods: {
//获取列表数据
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/user/list',
params: filterRes,
method:"GET"
}).then(res => {
uni.stopPullDownRefresh();
if(!res.data.data){
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(res.data.data.datas);
}
}).catch(err => {
this.loading_status="noMore";
});
},
//点击搜索 实现效果 这里需要根据情况判断。处理方式和前面差不多。
selectPeople(item,index){
if(this.flag == 'wxzp'){ //维修指派
var _this=this;
uni.showModal({
title: '提示',
content: '确定将维修单转派给'+item.NAME+"吗?",
success: function (res) {
if (res.confirm) {
_this.$http.request({
url: '/apis/repairEvent/reventTurnToSend',
params: {
eventId:_this.id,
userId:item.userId
}
}).then(res => {
if (res.data.code == 0) {
uni.showToast({
title: res.data.msg,
duration: 2000,
icon:"none"
});
setTimeout( function(){
uni.redirectTo({
url: 'repairDetail?id='+_this.id
});
},1000)
}
}).catch(err => {
uni.showToast({
title: '操作失败',
duration: 2000,
icon:"none"
});
});
} else if (res.cancel) {
}
}
});
}
else if(this.flag == 'zrr' || this.flag == 'csr'){ //责任人
var userInfo = {
userId :item.userId,
name:item.NAME
}
if(this.previousUrl == 'addRepair'){
//故障报修
//保存当前修改信息
var repairInfo = uni.getStorageSync('repairInfo');
if(!repairInfo){
repairInfo = {}
}
repairInfo[this.flag] = userInfo;
uni.setStorage({
key: 'repairInfo',
data: repairInfo,
success: function () {
uni.navigateTo({
url: 'addRepair'
});
}
});
}else{
//新增维修记录。
var addRepairInfo = uni.getStorageSync('addRepairInfo');
if(!addRepairInfo){
addRepairInfo = {}
}
addRepairInfo[this.flag] = userInfo;
uni.setStorage({
key: 'addRepairInfo',
data: addRepairInfo,
success: function () {
uni.navigateTo({
url: 'repairRecordAddStep1'
});
}
});
}
}
}
},
onPageScroll : function(e) {
uni.hideKeyboard()
},
//搜索框文本变化
onNavigationBarSearchInputChanged(n){
this.search_text=n.text;
},
//点击软键盘搜索按钮
onNavigationBarSearchInputConfirmed(){
this.listCards=[];
this.pagenumber=1;
this.loading_status="more";
this.getDateList();
},
//点击搜索按钮
onNavigationBarButtonTap(obj) {
this.listCards=[];
this.pagenumber=1;
this.loading_status="more";
this.getDateList();
}
}
</script>
<style scoped>
>>>.noRecord{
padding-top: 30%;
margin-top: 0 !important;
}
</style>