wtt
2026-03-20 410e69559e31fe4a8f2c33e892452582126e5bf3
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<template>
    <view>
        <uni-popup ref="popup" type="bottom" @change="popupChangeHandler">
            <view class="content">
                <view class="search-condition">
                    <view class="title"><text>单据号: </text></view>
                    <view class="right"><input type="text" v-model="HBillNo" @confirm="getBillList" /></view>
                </view>
                <view class="buttons">
                    <view style="flex: 1;"></view>
                    <button size="mini" type="primary" @click="search">查询</button>
                    <button size="mini" type="primary" @click="exit">退出</button>
                </view>
                <scroll-view id="#BillListPanel" scroll-y="true" style="height: 55vh;">
                    <view class="card-item" v-show="HBillList.length != 0">
                        <uni-card
                            v-for="(bill, index) in HBillList[curPage-1]" :key="index" @tap="clickCard(bill, index)">
                                <view class="card-detail" v-for="(HBillField, index) in emptyValueFilter(bill,HBillFieldsList).slice(0,10)" :key="index">
                                    <template v-if="HBillField.ColmType == 'DateTime'"><text>{{ HBillField.ColmCols }}:</text>{{  bill[HBillField.ColmCols] ? dayjs(bill[HBillField.ColmCols]).format("YYYY-MM-DD HH:mm:ss") : "" }} </template>    
                                    <template v-else><text>{{ HBillField.ColmCols }}:</text>{{  bill[HBillField.ColmCols] }}</template>
                                </view>
                                <view class="card-detail" v-if="showDetail == index">
                                    <view class="card-detail" v-for="(HBillField, index) in emptyValueFilter(bill,HBillFieldsList).slice(10,-1)" :key="index">
                                        <template v-if="HBillField.ColmType == 'DateTime'"><text>{{ HBillField.ColmCols }}:</text>{{  bill[HBillField.ColmCols] ? dayjs(bill[HBillField.ColmCols]).format("YYYY-MM-DD HH:mm:ss") : "" }} </template>    
                                        <template v-else><text>{{ HBillField.ColmCols }}:</text>{{  bill[HBillField.ColmCols] }}</template>
                                    </view>
                                </view>
                            <view class="more" v-if="showDetail == index && operations != index">
                                <view class="part" style="border-right: 1px solid #eee;" @tap.stop="showDetail = -1">
                                    <uni-icons type="top" style="color: #888;margin-right: 10rpx;" size="14" ></uni-icons>收起
                                </view>
                                <!-- <view class="part" @tap.stop="operations = operations==index?-1:index">
                                    <uni-icons type="more-filled" style="color: #888;margin-right: 10rpx;"
                                        size="14"></uni-icons>操作
                                </view> -->
                            </view>
                            <view class="more" v-if="showDetail != index && operations != index">
                                <view class="part" style="border-right: 1px solid #eee;" @tap.stop="showDetail = index">
                                    <uni-icons type="bottom" style="color: #888;margin-right: 10rpx;" size="14"></uni-icons>更多信息
                                </view>
                                <!-- <view class="part" @tap.stop="operations = operations==index?-1:index">
                                    <uni-icons type="more-filled" style="color: #888;margin-right: 10rpx;"
                                        size="14"></uni-icons>操作
                                </view> -->
                            </view>
                        </uni-card>
                    </view>
                    <view class="over" v-show="HBillList.length == 0">暂无数据</view>
                </scroll-view>
                <uni-pagination id="#pagination" title="标题文字" v-model="curPage" :pageSize="size"
                    :total="length"></uni-pagination>
            </view>
        </uni-popup>
    </view>
</template>
 
<script>
    import dayjs from 'dayjs';
    import {
        CommonUtils
    } from '@/utils/common';
    import {
        getUserInfo
    } from '@/utils/auth';
    export default {
        name: "billSelectorPopup",
        emits: ["update:modelValue"],
        data() {
            return {
                showDetail: -1,
                operations: -1,
                dayjs: dayjs,
                enablefocus: false,
                size: 20,
                curPage: 1,
                length: 0,
                page: 0,
                HName: '',
                HCode: '',
                HBillNo: '',
                HBillList: [], // 表单数据集合
                HBillFieldsList: [], // 表单字段集合
                panelHeight: 0,
 
                refTargetKey: 0,
                multiSouceBillList: [],
 
            };
        },
        props: {
            HStockOrgID: {
                type: [String, Number],
            },
            Type: {
                type: [String],
                require: true
            }
        },
        mounted() {},
        methods: {
            popupChangeHandler(e) {
                if (e.show === true) {
                    
                }
            },
            async exit() {
                this.size = 20
                this.curPage = 1
                this.length = 0
                this.page = 0
                this.HSourceBillNo = ''
                this.HMater = ''
                this.HCustom = ''
                this.HBillList = []
                this.enablefocus = false
                this.multiSouceBillList = []
                // 需要等待页面内的数据赋值完毕
                await this.$nextTick()
                this.$refs.popup.close();
            },
            search() {
                this.getBillList()
            },
            async showPopup(index) {
                this.$refs.popup.open();
                this.refTargetKey = index
                this.getBillList()
            },
            clickCard(bill, index) {
                console.log('this.HBillList: ',this.HBillList, 'index: ', index);
                let retVal = {}
                retVal[this.refTargetKey] = bill
                this.$emit("update", {
                    retVal: retVal,
                    index: this.refTargetKey
                })
            },
            getsWhere() {
                let sWhere =
                    ``
 
                // if (this.HCode) {
                //     swhere += ` and 不良原因代码 like '%${this.HCode}%'`
                // }
                if (this.HBillNo) {
                    sWhere += ` and 单据号 like '%${this.HBillNo}%'`
                }
                
                if(this.refTargetKey) {
                    // sWhere += ` and HInterID = ${this.refTargetKey}`
                }
                return sWhere
            },
            getBillList() {
                let sWhere = this.getsWhere()
                this.HBillList = []
                this.length = 0
                this.page = 0
                this.curPage = 1
                let url = ""
                if(this.Type == 'BY'){
                    url = "/Sb_EquipMaintainRuleBill/GetEquipMaintainRuleListPDA"
                }
                else if (this.Type == 'DJ'){
                    url = "/Sb_EquipDotCheckRuleBill/GetEquipDotCheckRuleListPDA"
                }
                else {
                    
                }
                CommonUtils.doRequest(
                    url, {
                        sWhere: sWhere,
                        user: getUserInfo()['Czymc'],
                    },
                    (res) => {
                        let {
                            data,
                            count,
                            list,
                            Message
                        } = res.data
                        if (count == 1) {
                            this.length = Array.from(data).length
                            const result = [];
                            for (let i = 0; i < data.length; i += this.size) {
                                result.push(data.slice(i, i + this.size));
                            }
                            this.HBillList = result
                            // 过滤不需要显示的字段
                            this.HBillFieldsList = Array.from(list)
                                .filter(e => this.shouldShowField(e.ColmCols) == true)
                            this.page = result.length
                            setTimeout(() => {
                                this.enablefocus = true
                            }, 500)
                        } else {
                            setTimeout(() => {
                                this.enablefocus = true
                            }, 500)
                            uni.showModal({
                                title: '温馨提示',
                                content: Message
                            })
                        }
                    }
                )
            },
            // 判断哪些字段需要显示
            shouldShowField(key) {
                // 排除不需要显示的字段
                const excludeKeys = []; // 这些字段已经在其他地方显示了
                
                // 判断key是否全英文(不包含中文)
                const isAllEnglish = /^[a-zA-Z]+$/.test(key);
                
                // 判断key是否包含"ID"(不区分大小写)
                const containsID = key.toUpperCase().includes('ID');
                
                return !excludeKeys.includes(key) && 
                       !isAllEnglish && // 排除全英文的key
                       !containsID // 排除包含ID的key
            },
            emptyValueFilter(item, fieldList){
                return fieldList.filter(e => item[e.ColmCols])
            }
        },
    }
</script>
 
<style lang="scss" scoped>
    .content {
        box-sizing: border-box;
        border-radius: 15rpx 15rpx 0 0;
        padding: 20rpx 20rpx 40rpx 20rpx;
        background-color: #fff;
        display: flex;
        flex-direction: column;
        gap: 10rpx;
 
        .search-condition {
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 20rpx;
            font-size: 30rpx;
 
            .title {
                width: 5rem;
                text-align: right;
            }
 
            .right {
                flex: 1;
                border-radius: 22rpx;
                border: 1px solid #acacac;
                height: auto;
                padding: 8rpx 16rpx;
 
                input {
                    width: 100%;
                    font-size: 30rpx;
                }
            }
        }
 
        .buttons {
            display: flex;
            flex-direction: row;
            gap: 20rpx;
            justify-content: flex-end;
 
            >button {
                display: inline-flex;
                width: 4rem;
            }
        }
 
        .card-item {
            .card-detail {
                width: 100%;
                display: flex;
                flex-wrap: wrap;
                justify-content: flex-start;
                line-height: 120%;
 
                .detail {
                    // width: 50%;
                    font-size: 26rpx;
                    margin-bottom: 12rpx;
                    color: #555;
                    margin-right: 20rpx;
 
                    text {
                        color: #999;
                        font-size: 26rpx;
                    }
                }
            }
        }
 
        .uni-card--is-active {
            background-color: rgba(0, 122, 255, 0.2);
        }
 
        .daterange {
            display: flex;
            flex-direction: row;
            gap: 10rpx;
            justify-content: center;
            align-items: center;
 
        }
    }
    
    .more {
        color: #888;
        font-size: 24rpx;
        display: flex;
        border-top: 1px solid #eee;
        padding-top: 20rpx;
    
        .part {
            width: 50%;
            text-align: center;
        }
    }
</style>