城阳工作端公众号前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
7.0 KiB

<template>
<div class='pages' ref="scroll">
<div class="scroll-box" ref="scroll-content">
<van-tabs :active="active" sticky @change="hadelChangeTab">
<van-tab title="待接单">
1 year ago
<card :tableData="list" @handleCLickReceive="handleCLickReceive"></card>
</van-tab>
<van-tab title="待处理">
<card :tableData="list"></card>
</van-tab>
<van-tab title="已完成">内容 3</van-tab>
</van-tabs>
</div>
1 year ago
<van-dialog v-model="showRole" title="请选择接单身份" show-cancel-button @confirm="receiveService">
<van-radio-group v-model="serviceOrgType">
<van-radio :name="item.serviceOrgType" v-for="(item) in roleList" :key="item.id">{{item.serviceOrgName}}</van-radio>
1 year ago
</van-radio-group>
</van-dialog>
1 year ago
<van-dialog v-model="showScope" title="" show-cancel-button @confirm="receiveService">
<van-datetime-picker
v-model="serviceTimeStart"
type="datetime"
title="开始时间"
:min-date="minDate"
:max-date="maxDate"
/>
<van-datetime-picker
v-model="serviceTimeStart"
type="datetime"
title="结束时间"
:min-date="minDate"
:max-date="maxDate"
/>
</van-dialog>
</div>
</template>
<script>
import card from './card.vue'
import throttle from 'lodash/debounce'
1 year ago
import { getServiceListRcv, getServiceListProcess , getServiceListCompleted,getCommonalityDetail,getMeasureDetail, getListMyIdentities,receiveService} from '@/api/service'
export default {
data() {
return {
active: 0,
clientHeight: false,
scroll: null,
pageNo: 1,
1 year ago
pageSize: 4,
list: [],
total: 0,
1 year ago
requestFlag:false,
showRole:false,
1 year ago
roleList:[],
serviceOrgType:null,
serviceOrgId:null,
showScope:null
};
},
created() {
1 year ago
this.getListMyIdentities()
this.getServiceListRcv()
},
mounted() {
this.clientHeight = document.documentElement.clientHeight; //可视高度
console.log(this.clientHeight);
this.$nextTick(() => {
this.scroll = this.$refs.scroll;
this.scroll.addEventListener('scroll', this.bottomScroll); //监听底部加载
})
},
methods: {
1 year ago
//提交接单
async receiveService(){
let parm = {
...this.formData,
serviceOrgType:this.serviceOrgType,
serviceOrgId:this.serviceOrgId,
id:this.serverId
}
console.log(parm);
// let {data,code,msg} = await receiveService(parm)
// if(code === 0){
// this.$toast.success('接单成功')
// this.showRole = false;
// this.pageNo = 1;
// this.getTableData();
// }
},
1 year ago
handleCLickReceive(item){
1 year ago
this.showRole = item.source === 4;
this.showScope = item.source === 0;
1 year ago
this.serverId = item.id;
if(item.source === 4){
this.getMeasureDetail()
}else {
1 year ago
this.getCommonalityDetail()
}
},
async getListMyIdentities(){
let {data,code,msg} = await getListMyIdentities()
if(code === 0){
this.roleList = data;
this.serviceOrgId = data[0].id;
1 year ago
}
1 year ago
},
1 year ago
1 year ago
async getMeasureDetail(){
1 year ago
let {data,code,msg} = await getMeasureDetail({id:this.serverId})
1 year ago
if(code === 0){
1 year ago
this.formData = data;
1 year ago
}
},
1 year ago
async getCommonalityDetail(){
let {data,code,msg} = await getCommonalityDetail({id:this.serverId})
1 year ago
if(code === 0){
1 year ago
this.formData = data;
1 year ago
}
},
hadelChangeTab(e){
this.list = [];
this.pageNo = 1;
this.active = e
this.getTableData('tab')
},
//滚动加载
bottomScroll: throttle(function () {
let scrollTop = this.scroll.scrollTop; //滚动条距离顶部的高度
let scrollHeight = this.scroll.scrollHeight; //滚动条的高度
let clientHeight = this.scroll.clientHeight; //可视区域的高度
if (scrollTop + clientHeight >= scrollHeight) {
this.pageNo++;
this.getTableData()
}
}, 500),
getTableData(tab){
if ((this.active === 0 && this.requestFlag) || (tab && this.active === 0)) {
this.getServiceListRcv();
} else if ((this.active === 1 && this.requestFlag) || (tab && this.active === 1)) {
this.getServiceListProcess();
}else if((this.active === 2 && this.requestFlag ) || (tab && this.active === 2)){
this.getServiceListCompleted()
}
if(!this.requestFlag){
this.$toast({
message: '没有更多数据了',
duration: 1000
})
}
},
//获取待接单
getServiceListRcv() {
getServiceListRcv({
pageNo: this.pageNo,
pageSize: this.pageSize
}).then(res => {
console.log(res);
this.total = res.total;
1 year ago
this.requestFlag = res.data.list.length === this.pageSize;
this.list = this.list.concat(res.data.list)
}).catch(err => {
})
},
// 获取待处理
getServiceListProcess() {
getServiceListProcess({
pageNo: this.pageNo,
pageSize: this.pageSize
}).then(res => {
this.total = res.total;
// this.requestFlag = res.length === this.pageSize;
this.list = res.data.list;
}).catch(err => {
})
},
// 获取已完成
getServiceListCompleted(){
getServiceListCompleted({
pageNo: this.pageNo,
pageSize: this.pageSize
}).then(res => {
this.total = res.total;
this.requestFlag = res.length === this.pageSize;
this.list = this.list.concat(...this.list, ...res.list);
}).catch(err => {
})
}
},
destroyed() {
this.scroll.removeEventListener('scroll', this.bottomScroll);//移除滚动监听
},
components: { card },
computed: {},
watch: {}
}
</script>
1 year ago
<style lang='less' scoped>
:deep(.van-tabs__content){
1 year ago
padding: 0 10px 20px;
1 year ago
box-sizing: border-box;
}
:deep(.van-dialog__content){
1 year ago
padding:10px;
1 year ago
box-sizing: border-box;
}
</style>