qingyiay
2023-09-25 f46eb243908e145da448f65bffb8ba17197d9164
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
<template>
    <view class="appointment">
        <combined-title
            :title="yuYueData.length != 0 ? yuYueData[0].filedName + '——' + yuYueData[0].sendDate : '暂无预约列表'"></combined-title>
        <view class="appointment-table">
            <uni-table border
                stripe
                emptyText="暂无更多数据">
                <uni-tr>
                    <uni-th align="center">时间段</uni-th>
                    <uni-th align="center">可预约</uni-th>
                    <uni-th align="center">已预约</uni-th>
                    <uni-th align="center">操作</uni-th>
                </uni-tr>
                <uni-tr v-for="(item, index) in yuYueData"
                    :key="item.id">
                    <uni-td align="center">{{ (item.startTime || '') + '-' + (item.endTime || '') }}</uni-td>
                    <uni-td align="center">{{ item.carNum || '' }}</uni-td>
                    <uni-td align="center">{{ item.carNum1 || '' }}</uni-td>
                    <uni-td><u-button text="选择"
                            type="primary"
                            :disabled="item.carNum == item.carNum1"
                            @click="yuYueBtnClick(item)"></u-button></uni-td>
                </uni-tr>
            </uni-table>
        </view>
    </view>
</template>
 
<script>
    import combinedTitle from '@/components/combined-title/combined-title.vue';
    export default {
        components: {
            combinedTitle
        },
        data() {
            return {
                // 预约列表请求参数
                yuYueListParams: {
                    filedId: '',
                    deptId: '',
                    sendDate: ''
                },
                // 预约请求参数
                yuYuePostParams: {
                    takeCoalId: null,
                    yuYueId: null
                },
                yuYueData: [],
                isRCSQ: false, // 入场申请接口控制
                rcsqData: {
                    taskId: '',
                    originalYyId: '',
                    yyId: '',
                    deptId: '',
                    filedId: '',
                    remark: ''
                }
            };
        },
        onLoad(params) {
            if (params.type == '入场申请') {
                this.isRCSQ = true;
                this.rcsqData.originalYyId = params.yyId;
            }
            this.yuYuePostParams.takeCoalId = params.takeCoalId;
            this.yuYueListParams.filedId = params.filedId;
            this.yuYueListParams.deptId = params.deptId;
            this.yuYueListParams.sendDate = params.sendDate;
        },
        onShow() {
            this.init();
        },
        methods: {
            init() {
                this.yuYueList();
            },
            // 预约列表
            yuYueList() {
                uni.showLoading({
                    title: '加载中...'
                });
                this.$reqGet('yuYueList', this.yuYueListParams).then(res => {
                    uni.hideLoading();
                    if (res.code == 0) {
                        this.yuYueData = res.data;
                    } else {
                        this.$u.toast('加载失败');
                    }
                });
            },
            // 预约和入场申请共用事件
            yuYueBtnClick(value) {
                if (this.isRCSQ) {
                    this.rcsqData.taskId = this.yuYuePostParams.takeCoalId;
                    this.saveRCSQ(value);
                } else {
                    this.yuYueClick(value.id);
                }
            },
            // 预约
            yuYueClick(id) {
                this.yuYuePostParams.yuYueId = id;
                this.$reqPost('yuYue', {
                    takeCoalId: this.yuYuePostParams.takeCoalId,
                    yuYueId: this.yuYuePostParams.yuYueId
                }, 'params').then(res => {
                    if (res.code == 0) {
                        this.yuYueList();
                        this.$u.toast('预约成功');
                        let timer = setTimeout(() => {
                            uni.navigateBack({
                                delta: 1
                            });
                        }, 500);
                    } else {
                        this.$u.toast(res.msg ? res.msg : '预约失败');
                    }
                })
            },
            // 入场申请
            saveRCSQ(value) {
                this.rcsqData.yyId = value.id;
                this.rcsqData.deptId = value.deptId;
                this.rcsqData.filedId = value.filedId;
                this.$reqPost('saveRCSQ', this.rcsqData, 'json').then(res => {
                    if (res.code == 0) {
                        this.$u.toast('入场申请成功');
                        let timer = setTimeout(() => {
                            uni.navigateBack({
                                delta: 1
                            });
                        }, 500);
                    } else {
                        this.$u.toast(res.msg ? res.msg : '入场申请失败,请稍后重试');
                    }
                });
            }
        }
    };
</script>
 
<style lang="scss"
    scoped>
    ::v-deep.appointment {
        width: 94%;
        margin: 0 auto;
 
        h1 {
            font-size: vww(20);
            text-align: center;
            font-weight: 550;
            margin: vww(30) 0 vww(18) 0;
        }
 
        // 表格
        .uni-table-scroll {
            width: 100%;
            overflow-x: hidden;
 
            .uni-table {
                min-width: 0 !important;
 
                .uni-table-tr {
                    padding: 0;
                    font-size: vww(13);
 
                    .uni-table-th {
                        height: vww(32);
                        line-height: vww(20);
                        padding: vww(5) vww(10);
                        color: #111111;
                        font-weight: 550;
                        background: #f5f5f5;
                    }
 
                    .uni-table-td {
                        height: vww(32);
                        line-height: vww(20);
                        padding: vww(5) vww(10);
                        color: #111111;
 
                        .u-button {
                            height: vww(23);
                        }
                    }
                }
            }
        }
    }
</style>