qingyiay
2023-04-21 1fdf41cc692eb7b208fe647259d4295164280a41
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
<template>
    <view class="freightForwarder-index">
        <view class="freightForwarder-index-body">
            <u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" textSize="30" iconSize="1000" v-if="orderPlanData.length == 0"></u-empty>
            <card v-for="(item, index) in orderPlanData" :key="index" :name="item.id" @click="cardBodyClick(item)" backgroundType="1">
                <template v-slot:left>
                    <view class="card-left__top">
                        <text>{{ item.carNum }}</text>
                        张
                    </view>
                    <view class="card-left__utils"><u-button text="转发" type="primary" @tap.stop="forwardClick(item)" shape="circle"></u-button></view>
                </template>
                <template v-slot:right-top>
                    <view class="right-top">
                        <view class="card-right-top-row">
                            <view>
                                <text>转发剩余:{{ item.carNumSurplusHuodai || 0 }}</text>
                            </view>
                            <view>
                                <text>{{ item.coalName || '' }}</text>
                            </view>
                        </view>
                    </view>
                </template>
                <template v-slot:right-bottom>
                    <view class="code">
                        <text>编号:{{ item.orderCode || '' }}</text>
                    </view>
                </template>
            </card>
        </view>
        <view class="history-numbers">
            <combined-title title="历史提煤单"></combined-title>
            <scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltolower="historyScrolltolower">
                <uni-table border stripe emptyText="暂无更多数据" :loading="loading">
                    <uni-tr>
                        <uni-th width="100" align="center">发运日期</uni-th>
                        <uni-th width="100" align="center">所属单位</uni-th>
                        <uni-th align="center" width="150">煤场名称</uni-th>
                        <uni-th align="center" width="100">煤种名称</uni-th>
                        <uni-th align="center" width="150">订单编号</uni-th>
                        <uni-th align="center" width="100">订单剩余量</uni-th>
                        <uni-th align="center" width="80">提煤单个数</uni-th>
                    </uni-tr>
                    <uni-tr v-for="(item, index) in historyCoalData" :key="index">
                        <uni-td align="center" @row-click="faYundetail(item)">{{ item.sendDate || '' }}</uni-td>
                        <uni-td align="left" @row-click="faYundetail(item)">{{ item.deptName || '' }}</uni-td>
                        <uni-td align="center" @row-click="faYundetail(item)">{{ item.filedName || '' }}</uni-td>
                        <uni-td align="center" @row-click="faYundetail(item)">{{ item.coalName || '' }}</uni-td>
                        <uni-td align="center" @row-click="faYundetail(item)">{{ item.orderCode || '' }}</uni-td>
                        <uni-td align="center" @row-click="faYundetail(item)">{{ item.carNumSurplus || '' }}</uni-td>
                        <uni-td align="center" @row-click="faYundetail(item)">{{ item.tmCount || '' }}</uni-td>
                    </uni-tr>
                </uni-table>
                <view class="more_text" v-if="showMoreData && historyCoalData.length !== 0">没有数据了...</view>
            </scroll-view>
        </view>
    </view>
</template>
 
<script>
import combinedTitle from '@/components/combined-title/combined-title.vue';
export default {
    props: {
        indexHistoryCoalData: {
            type: Array,
            default: []
        },
        indexHuoDaiOrderPlanData: {
            type: Array,
            default: []
        }
    },
    watch: {
        indexHistoryCoalData: {
            handler(v) {
                this.historyCoalData = v;
            },
            deep: true,
            immediate: true
        },
        indexHuoDaiOrderPlanData: {
            handler(v) {
                this.orderPlanData = v;
            },
            deep: true,
            immediate: true
        }
    },
    components: {
        combinedTitle
    },
    data() {
        return {
            orderPlanData: [],
            historyCoalData: [],
            // 表格加载状态
            loading: false,
            scrollTop: 0,
            // 每页数据量
            pageSize: 10,
            // 当前页
            pageCurrent: 1,
            // 数据总量
            total: 0,
            // 是否显示更多数据
            showMoreData: false
        };
    },
    onShow() {
        this.init();
    },
    computed: {
        huoDaiId() {
            return uni.getStorageSync('userInfo').id;
        }
    },
    methods: {
        // 获取历史提煤单
        getJhOrderPlanDataPage() {
            this.loading = true;
            this.$reqGet('getJhOrderPlanDataPage', { current: this.pageCurrent, size: this.pageSize }).then(res => {
                if (res.data.records) {
                    if (this.pageCurrent > 1) {
                        this.historyCoalData = this.historyCoalData.concat(res.data.records);
                        this.historyCoalData = this.ArrSet(this.historyCoalData, 'id');
                        this.loading = false;
                    } else {
                        this.historyCoalData = res.data.records;
                        this.loading = false;
                    }
                }
            });
        },
        // 上拉加载
        historyScrolltolower() {
            if (this.pageCurrent * this.pageSize >= this.total) return (this.showMoreData = true);
            this.pageCurrent++;
            this.getJhOrderPlanDataPage();
        },
        //fix 点击提煤单返回会增加重复数据
        ArrSet(Arr, id) {
            var obj = {};
            const arrays = Arr.reduce((setArr, item) => {
                obj[item[id]] ? '' : (obj[item[id]] = true && setArr.push(item));
                return setArr;
            }, []);
            return arrays;
        },
        init() {
            this.huoDaiList();
            this.getJhOrderPlanDataPage();
        },
        huoDaiList() {
            this.$reqGet('huoDaiList').then(res => {
                this.orderPlanData = res.data;
            });
        },
        cardBodyClick(item) {
            // let code = null;
            // this.orderPlanData.forEach(item => {
            //     if (item.orderPlanId == id) {
            //         code = item.code;
            //         id = item.orderPlanId;
            //     }
            // });
            uni.navigateTo({
                url: `/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanDetails?orderPlanId=${item.orderPlanId}&code=${item.code}`
            });
        },
        // 转发
        forwardClick(value) {
            uni.navigateTo({
                url: `/pages/public-page/forward/forward?orderPlanId=${value.orderPlanId}&carNumSurplusHuodai=${value.carNumSurplusHuodai}&carNum=${value.carNum}`
            });
        },
        // 点击历史提煤单一行获取详情
        faYundetail(v) {
            uni.navigateTo({
                url: `/pages/customer-page/customer-index/fayunPlanDetails/fayunPlanDetails?orderPlanId=${v.id}&cars2=${v.cars2}`
            });
        }
    }
};
</script>
 
<style lang="scss" scoped>
.scroll-Y {
    height: 600rpx;
    margin-bottom: vww(50);
    .more_text {
        color: #999;
        font-size: 24rpx;
        text-align: center;
    }
}
::v-deep.freightForwarder-index {
    width: 94%;
    margin: 0 auto;
    // 主体
    .freightForwarder-index-body {
        margin-bottom: vww(10);
 
        // 卡片样式
        .card-left__top {
            margin-top: vww(26);
            text-align: center;
            color: #ffffff;
            text {
                font-size: vww(48);
                font-weight: 800;
            }
        }
        .card-left__utils {
            display: flex;
            padding: 0 vww(15) 0 vww(15);
            .u-button {
                width: vww(55);
                height: vww(24);
                background-color: #fff;
                color: #1987ff;
            }
        }
        .right-top {
            display: flex;
            flex-flow: column nowrap;
            align-content: space-around;
            .card-right-top-row {
                margin-top: vww(26);
                text-align: center;
                &:nth-child(1) {
                    display: flex;
                    justify-content: space-between;
                    view {
                        text-align: center;
                        width: 50%;
                    }
                }
            }
        }
 
        .code {
            margin-top: vww(2);
            text-align: center;
        }
    }
}
</style>