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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<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">
                        <template v-for="(field, index)  in CommonUtils.emptyValueFilter(item, HFieldList)">
                            <view v-if="field.ColmType == 'DateTime'" class="detail">
                                <text>{{field.ColmCols}}:</text>{{dayjs(item[field.ColmCols]).format("YYYY-MM-DD HH:mm:ss")}}
                            </view>
                            <view v-else class="detail">
                                <text>{{field.ColmCols}}:</text>{{item[field.ColmCols]}}
                            </view>
                        </template>
                    </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,
                CommonUtils,
                userInfo: getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                tabs: 0,
                urls: '/Sc_HEquipStateDistribution/Get_EquipICMOTechParamList_Json',
                MvarReportTitle: '设备工艺',
                hform: {
                    HInterID: 0,
                    HICMOInterID: 0,
                    HICMOEntryID: 0,
                    HBillNo: '',
                    HSourceBillNo: '',
                    user: uni.getStorageSync('HUserName'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                    operationType: "4",
                    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_HEquipStateDistribution/Get_EquipICMOTechParamList_Json'
                }
                // 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 = {
                    HEquipID: this.hform.HInterID,
                    HICMOInterID: this.hform.HICMOInterID,
                    HICMOEntryID: this.hform.HICMOEntryID,
                }
 
                this.getList()
            },
        },
        onLoad(e) {
            let {
                operationType,
                HEquipID,
                HICMOInterID,
                HICMOEntryID
            } = e
 
            if (operationType == 4) {
                this.HInterID = HEquipID
                this.HICMOInterID = HICMOInterID
                this.HICMOEntryID = HICMOEntryID
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    @import "@/pages/MJGL/style/MJListStyle.scss"
</style>