schangxiang@126.com
2025-05-21 a3a2b238a2626ef8744e7a135f9ca2e2fbb5184c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<template>
    <default-header-page-layout ref="page" title="盘点作业" :back-custom="true" @back="onPageBack">
        <view class="page-frame with-action-user-row" :style="{height:pageBodyHeight+'px'}" v-if="pageBodyHeight">
            <action-user-row />
            <view class="with-action-user-row-page-content">
                <page-main-list v-show="pageType==='mainlist'" :resetflag.sync="resetflag" ref="mainlist" @query="onListQuery" @action="onListAction" />
                <page-main-search v-show="pageType==='mainsearch'" :resetflag="resetflag" @callback="onSearchCallBack"  />
                <page-detail-list v-show="pageType==='detaillist'" ref="detaillist" :main-obj="mainActionRow" @action="onDeatilAction" />
                <page-check-action v-show="pageType==='checkaction'" ref="checkaction" :main-obj="mainActionRow" />
            </view>
        </view>
    </default-header-page-layout>
</template>
 
<script>
import DefaultHeaderPageLayout from '@/components/DefaultHeaderPageLayout.vue'
import ActionUserRow from '@/components/ActionUserRow.vue'
import PageMainList from './modules/MainList.vue'
import PageMainSearch from './modules/MainSearch.vue'
import PageDetailList from './modules/DetailList.vue'
import PageCheckAction from './modules/CheckAction.vue'
let initInterVal = null;
export default {
    name:'demoPage',
    components:{DefaultHeaderPageLayout,ActionUserRow,PageMainList,PageMainSearch,PageDetailList,PageCheckAction},
    data(){
        return {
            pageBodyHeight:0,
            pageType:'mainlist',
            resetflag:0,
            query:null,
            mainActionRow:{}
        }
    },
    watch:{
        pageType(newVal, oldVal){
            if (newVal !== oldVal) {
              if (newVal) {
                this.switchPage();
              }
            }
        },
        resetflag(newVal, oldVal){
            if (newVal !== oldVal) {
              this.query = null
                this.$refs.list.newList(this.query)
            }
        }
    },
    methods:{
        onPageBack(){
            if (this.pageType==='mainlist') {
                uni.redirectTo({url:this.$config.path.home});
            } else {
                if (this.pageType === 'mainsearch' || this.pageType === 'detaillist') {
                    this.pageType = 'mainlist'
                } else {
                    this.pageType = 'detaillist'
                }
            }
        },
        onListQuery(){
            this.pageType = 'mainsearch'
        },
        onListAction(obj){
            this.mainActionRow = obj
            this.pageType = 'detaillist'
        },
        onDeatilAction(){
            this.pageType = 'checkaction'
        },
        onSearchCallBack(params){
            this.query = params;
            this.pageType = 'mainlist'
        },
        switchPage(){
            this.$nextTick(()=>{
                switch (this.pageType){
                    case 'mainlist':
                        this.$refs.mainlist.newList(this.query)
                        break;
                    case 'detaillist':
                        this.$refs.detaillist.init()
                        this.$refs.checkaction.clear()
                        break;
                    default:
                        break;
                }
            })
        },
        /* 页面初始化获取页面body高度的定时器 */
        startInitInterval(callback){
            initInterVal = setInterval(()=>{
                if (this.pageBodyHeight) {
                    this.clearInitInterval()
                    callback && callback()
                } else {
                    this.pageBodyHeight = this.$refs.page.getBodyHeight()
                }
            },200)
        },
        /* 清除定时器 */
        clearInitInterval(){
            try{
                clearInterval(initInterVal)
                initInterVal = null
            }catch(e){
                //TODO handle the exception
            }
        }
    },
    onReady(){
        this.startInitInterval(()=>{
            /* 页面初始化后需要执行的代码在这边调用 */
            this.switchPage()
        })
    },
    onUnload(){
        this.clearInitInterval()
    }
}
</script>
 
<style scoped lang="scss">
</style>