Browse Source

优化下

test
mk 1 year ago
parent
commit
942c7f38d6
  1. 2
      src/router/router.config.js
  2. 17
      src/store/index.js
  3. 18
      src/store/modules/app.js
  4. 23
      src/views/assistance/index.vue

2
src/router/router.config.js

@ -19,7 +19,7 @@ export const constantRouterMap = [
path: '/assistance', path: '/assistance',
name:'assistance', name:'assistance',
component: () => import('@/views/assistance'), component: () => import('@/views/assistance'),
meta: { title: '诉求代办', keepAlive: false } meta: { title: '诉求代办', keepAlive: true }
}, },
{ {
path: '/changePassword', path: '/changePassword',

17
src/store/index.js

@ -1,20 +1,3 @@
// import Vue from 'vue'
// import Vuex from 'vuex'
// import getters from './getters'
// import app from './modules/app'
// Vue.use(Vuex)
// const store = new Vuex.Store({
// modules: {
// app
// },
// getters
// })
// export default store
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'

18
src/store/modules/app.js

@ -1,15 +1,29 @@
const state = { const state = {
userName: '' userName: '',
tabActive:0,
scrollTop:0
} }
const mutations = { const mutations = {
SET_USER_NAME(state, name) { SET_USER_NAME(state, name) {
state.userName = name state.userName = name
} },
SET_TAB_ACTIVE(state, num) {
state.tabActive = num
},
SET_SCROLL_TOP(state, num){
state.scrollTop = num
},
} }
const actions = { const actions = {
// 设置name // 设置name
setUserName({ commit }, name) { setUserName({ commit }, name) {
commit('SET_USER_NAME', name) commit('SET_USER_NAME', name)
},
setTabActive({ commit }, num) {
commit('SET_TAB_ACTIVE', num)
},
setScrollTop({ commit }, num){
commit('SET_SCROLL_TOP', num)
} }
} }
export default { export default {

23
src/views/assistance/index.vue

@ -1,5 +1,5 @@
<template> <template>
<div class='pages' ref="scroll"> <div class='pages' ref="scroll" style="scroll-behavior: smooth;">
<div class="scroll-box" ref="scroll-content"> <div class="scroll-box" ref="scroll-content">
<van-tabs :active="active" sticky @change="hadelChangeTab"> <van-tabs :active="active" sticky @change="hadelChangeTab">
<van-tab title="待接单"> <van-tab title="待接单">
@ -79,15 +79,13 @@ import throttle from 'lodash/debounce'
import { getServiceListRcv, getServiceListProcess, getServiceListCompleted, getCommonalityDetail, getMeasureDetail, getListMyIdentities, receiveService, getServiceScopeTree, serviceConfirm, serviceComplete,getSearchResis } from '@/api/service' import { getServiceListRcv, getServiceListProcess, getServiceListCompleted, getCommonalityDetail, getMeasureDetail, getListMyIdentities, receiveService, getServiceScopeTree, serviceConfirm, serviceComplete,getSearchResis } from '@/api/service'
import { uploadvariedfile } from '@/api/basic' import { uploadvariedfile } from '@/api/basic'
import { Dialog } from 'vant'; import { Dialog } from 'vant';
export default { export default {
data() { data() {
return { return {
active: 0, active: this.$store.state.app.tabActive,
clientHeight: false,
scroll: null, scroll: null,
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 20,
list: [], list: [],
total: 0, total: 0,
requestFlag: false, requestFlag: false,
@ -118,16 +116,23 @@ export default {
}; };
}, },
created() { created() {
this.getTableData('tab')
this.getListMyIdentities() this.getListMyIdentities()
this.getServiceListRcv()
this.getServiceScopeTree() this.getServiceScopeTree()
}, },
mounted() { mounted() {
this.clientHeight = document.documentElement.clientHeight; //
this.$nextTick(() => { this.$nextTick(() => {
this.scroll = this.$refs.scroll; this.scroll = this.$refs.scroll;
if(this.$store.state.app.scrollTop){
setTimeout(()=>{
this.$refs.scroll.scrollTo(0, this.$store.state.app.scrollTop);
},500)
}
this.scroll.addEventListener('scroll', this.bottomScroll); // this.scroll.addEventListener('scroll', this.bottomScroll); //
}) })
},
activated(){
}, },
methods: { methods: {
afterRead(file) { afterRead(file) {
@ -269,7 +274,6 @@ export default {
handelChangeRole(val) { handelChangeRole(val) {
this.serviceOrgId = val; this.serviceOrgId = val;
}, },
// //
handleCLickReceive(item) { handleCLickReceive(item) {
this.showRole = item.source === 4; this.showRole = item.source === 4;
@ -326,11 +330,14 @@ export default {
this.list = []; this.list = [];
this.pageNo = 1; this.pageNo = 1;
this.active = e; this.active = e;
this.$store.dispatch('setTabActive',e);
this.getTableData('tab') this.getTableData('tab')
}, },
// //
bottomScroll: throttle(function () { bottomScroll: throttle(function () {
console.log('滚动加载');
let scrollTop = this.scroll.scrollTop; // let scrollTop = this.scroll.scrollTop; //
this.$store.dispatch('setScrollTop',scrollTop);
let scrollHeight = this.scroll.scrollHeight; // let scrollHeight = this.scroll.scrollHeight; //
let clientHeight = this.scroll.clientHeight; // let clientHeight = this.scroll.clientHeight; //
if (scrollTop + clientHeight >= scrollHeight) { if (scrollTop + clientHeight >= scrollHeight) {

Loading…
Cancel
Save