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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<template>
    <view class="content">
        <view id="divide" style="width: 100%;height: 0rpx;background-color: #e5e5e5;"></view>
        <view :style="{
            height: calcContentHeight + 'px',
            overflowY: 'auto'
        }">
            <view class="list" v-for="(item,index) in showList" :key="index" v-if="tabs==0">
                <uni-card :title="item.检查项目" style="margin: 10px;">
                    <view class="card-detail">
                        <view class="detail" style="width: 25%; justify-content: left;" v-for="(field, index)  in HFieldList" :key="index">
                            <text>{{field.ColmCols}}:</text>{{item[field.ColmCols]}}
                        </view>
                    </view>
                </uni-card>
            </view>
        </view>
        <view class="pagination-zone" id="pagination-zone">
            <uni-pagination show-icon :page-size="size" :total="dataLength" :current="page"
                @change="onPaginationChangeHandler"></uni-pagination>
        </view>
        <BarCodePopupVue ref="barcodePopup"></BarCodePopupVue>
    </view>
</template>
 
<script>
    import {
        getUserInfo
    } from "@/utils/auth.js";
    import BarCodePopupVue from "@/components/BarCodePopup/BarCodePopup.vue";
    import {
        CommonUtils
    } from "../../../utils/common";
    import dayjs from "dayjs";
    export default {
        data() {
            return {
                dayjs,
                userInfo: getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                tabs: 0,
                urls: '/Sc_WorkBeginDotCheckBill/getSc_WorkDotCheckList_Day',
                MvarReportTitle: '设备月点检记录',
                hform: {
                    HInterId: 0,
                    HBillNo: '',
                    HSourceBillNo: '',
                    user: uni.getStorageSync('HUserName'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                    Type: "设备",
                    sWhere: "",
                },
                sWhere: '',
                listData: [],
                showList: [],
                HFieldList: [], // 字段列表
                showDetail: -1,
                operations: -1,
 
                page: 1,
                size: 20,
                dataLength: 0,
                divideBottom: 0,
                paginationTop: 0,
                showmore: false,
            }
        },
        computed: {
            calcContentHeight: {
                get() {
                    return this.paginationTop - this.divideBottom
                }
            }
        },
        onShow() {
            //用户模块权限判断
            this.changeTab(0)
            console.log(this.userInfo, uni.getStorageSync('HUserName'))
        },
        components: {
            BarCodePopupVue
        },
        onReady() {
            this.getCalcHeight()
        },
        methods: {
            changeShowMore() {
                this.showmore = !this.showmore
                this.$nextTick(() => {
                    // 重新计算内容视口高度
                    this.getCalcHeight()
                })
            },
            getCalcHeight() {
                let query = uni.createSelectorQuery().in(this)
                query
                    .select("#divide")
                    .boundingClientRect()
                    .select("#pagination-zone")
                    .boundingClientRect()
                    .exec(res => {
                        this.divideBottom = Math.ceil(res[0].bottom)
                        this.paginationTop = Math.floor(res[1].top)
                    })
            },
            async qrCodeDisplay(item) {
                this.$refs.barcodePopup.setCodeInfo(item.HBillNo)
                await this.$nextTick()
                this.$refs.barcodePopup.open()
            },
            onPaginationChangeHandler({
                current
            }) {
                this.page = current
                this.showList = this.getPage(current, this.size, this.listData)
            },
            getPage(page, size, list) {
                let sindex = (parseInt(page) - 1) * size
                let eindex = parseInt(page) * size
                let newList = list.slice(sindex, eindex)
                return newList
            },
            changeTab(e) {
                this.tabs = e
                this.page = 1
                this.showList = []
 
                if (this.tabs == 0) {
                    this.urls = '/Sc_WorkBeginDotCheckBill/getSc_WorkDotCheckList_Day'
                }
                // if (this.tabs == 1) {
                //     this.urls = '/WEBSController/GetKf_ICStockBillQueryList_User_Json'
                // }
                this.search()
            },
            async getList() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: this.urls,
                        data: this.hform
                    })
 
                    let {
                        count,
                        data,
                        Message,
                        list
                    } = res.data
 
                    if (count == 1) {
                        if (data == null) {
                            data = []
                        }
                        this.listData = data
                        console.log('data: ', data);
                        this.showList = this.getPage(this.page, this.size, data)
                        this.dataLength = data.length
                        this.HFieldList = CommonUtils.fieldListFilterRole({
                            FieldList: list,
                            ExcludeKeys: ["检查项目"]
                        }).data
                        
                        console.log('this.HFieldList: ',this.HFieldList);
                    } else {
                        CommonUtils.showTips({
                            title: "温馨提示",
                            message: `获取点检记录失败: ${Message}`
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: "温馨提示",
                        message: `获取点检记录失败: ${err}`
                    })
                }
 
            },
            search() {
                this.hform.sWhere = ''
                this.listData = []
                this.page = 1
                this.showList = []
                
                this.hform.sWhere = {
                    Type: this.hform.Type,
                    HInterId: this.hform.HInterId
                }
                
                this.getList()
            },
        },
        onLoad(e) {
            let {operationType, HEquipID} = e
            
            this.hform.Type = operationType
            this.hform.HInterId = HEquipID
        }
    }
</script>
 
<style lang="scss" scoped>
    @import "@/pages/MJGL/style/MJListStyle.scss"
</style>