zhangwei
2025-03-10 6dc59277cedc8c995b1c68807e40a6ee5903f0f4
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<template>
    <view class="full-page" scroll-y using-sticky>
        <view class="">
            <up-sticky bgColor="#fff">
                <view class="coreshop-ff content c-p-10">
                    <up-search placeholder="请点击选择日期" @clear='clear' @click='clickTime' disabled @custom='init'
                        v-model="workTime" search-icon="calendar" @search='init' :show-action="false"></up-search>
                </view>
                <view class="coreshop-ff content c-p-10 chuany-flex chuany-justify-between"
                    v-if="role !== 'zhuGuan'&&approvalStatus=='unApproval'">
                    <view class="chuany-width75">
                        <up-search placeholder="请输入工人名字" v-model="workerUserName" @custom='init' @clear='init'
                            @search='init'></up-search>
                    </view>
 
                    <!-- <up-search placeholder="请点击选择打卡日期" @click='clickIcon' @clear='PostMyComDakaListPage' disabled
                        v-model="wordDate" search-icon="calendar" @search='PostMyComDakaListPage'
                        @custom='PostMyComDakaListPage'></up-search> -->
                    <up-text align="center" type='success' text='批准' size='14' @click="arrange('Yes')"></up-text>
                    <up-text align="center" type="error" text='不批准' size='14' @click="arrange('No')"></up-text>
                </view>
                <view class="coreshop-ff content c-p-10 chuany-flex chuany-justify-between" v-else>
                    <up-search placeholder="请输入工人名字" v-model="workerUserName" @custom='init' @clear='init'
                        @search='init'></up-search>
 
                    <!-- <up-search placeholder="请点击选择打卡日期" @click='clickIcon' @clear='PostMyComDakaListPage' disabled
                        v-model="wordDate" search-icon="calendar" @search='PostMyComDakaListPage'
                        @custom='PostMyComDakaListPage'></up-search> -->
 
                </view>
                <!-- <up-subsection :list="list" :current="current4" activeColor="#f9ae3d"
                    @change="sectionChange"></up-subsection> -->
                <up-subsection :list="list" current='1' activeColor="#f9ae3d" @change="sectionChange"></up-subsection>
            </up-sticky>
            <view class="full-page-content c-p-b-100">
                <view class="c-p-l-20 c-p-r-20" v-if="listO.orderList&&listO.orderList.length>0">
                    <u-checkbox-group v-model="checkboxValue1" placement="column" @change="checkboxChange"
                        v-if='role !== "zhuGuan"&&approvalStatus=="unApproval"'>
                        <view class="listrecord c-p-t-20" v-for="(item,index) in listO.orderList" :key="item.keyid"
                            @click="pageToDetail(item)">
                            <view class="coreshop-ff chuany-bradius20 chuany-flex">
                                <view class="c-p-14">
                                    <u-checkbox :name="item.keyid" v-if='role !== "zhuGuan"'>
                                    </u-checkbox>
                                </view>
                                <view class="chuany-width100">
                                    <view class="c-p-t-20 c-p-b-20 c-p-r-20 chuany-font28">
                                        <view class="chuany-flex chuany-justify-between">
                                            <text class="chuany-width6">{{index+1}}</text>
                                            <view class="chuany-width30">
                                                {{item.planPeople}}
                                            </view>
                                            <view class="chuany-width50">
                                                {{item.depart.name}}
                                            </view>
                                            <view class="chuany-width24">
                                                <up-text align="right" size='14'
                                                    :type="item.approvalStatus=='unApproval'?'primary':item.approvalStatus=='Yes'?'success':'warning'"
                                                    :text="item.approvalStatus=='unApproval'?'未审批':item.approvalStatus=='Yes'?'批准':'不批准'">
                                                </up-text>
                                            </view>
                                        </view>
                                        <view class="text-69 chuany-flex chuany-justify-between">
                                            <!-- <view class="c-p-t-8 chuany-width24">
                                                费用报销
                                            </view> -->
                                            <text class="chuany-width6" style="color: white;">{{index+1}}</text>
                                            <view class="c-p-t-8 chuany-width30">
                                                {{$util.formatDate(item.planStartTime)}}
                                            </view>
                                            <view class="c-p-t-6 chuany-width50">
                                                <up-text color="#696969" :lines="1" :text="item.planContent"></up-text>
                                            </view>
                                            <view class="c-p-t-8 chuany-width24 chuany-text-right">
                                                {{item.planMoney}} 元
                                            </view>
                                        </view>
                                        
                                        <!-- <view class="c-p-t-8">
                                            <up-text :lines="1" :text="item.planContent"></up-text>
                                        </view> -->
                                    </view>
                                </view>
                            </view>
                        </view>
                    </u-checkbox-group>
                    <view v-else class="listrecord c-p-t-20" v-for="(item,index) in listO.orderList" :key="item.keyid"
                        @click="pageToDetail(item)">
                        <view class="coreshop-ff chuany-bradius20 chuany-flex chuany-align-center">
                            <view class=" c-p-l-10">
 
                            </view>
                            <view class="chuany-width100">
                                <view class="c-p-t-20 c-p-b-20 c-p-r-20 chuany-font28">
                                    <view class="chuany-flex chuany-justify-between">
                                        <text class="chuany-width6">{{index+1}}</text>
                                        <view class="chuany-width26">
                                            {{item.planPeople}}
                                        </view>
                                        <view class="chuany-width50">
                                            {{item.depart.name}}
                                        </view>
                                        <view class="chuany-width24">
                                            <up-text align="right" size='14'
                                                :type="item.approvalStatus=='unApproval'?'primary':item.approvalStatus=='Yes'?'success':'warning'"
                                                :text="item.approvalStatus=='unApproval'?'未审批':item.approvalStatus=='Yes'?'批准':'不批准'">
                                            </up-text>
                                        </view>
                                    </view>
                                    <view class="text-69 chuany-flex chuany-justify-between">
                                        <!-- <view class="c-p-t-8 chuany-width24">
                                            费用报销
                                        </view> -->
                                        <text class="chuany-width6" style="color: white;">{{index+1}}</text>
                                        <view class="c-p-t-8 chuany-width26">
                                            {{$util.formatDate(item.planStartTime)}}
                                        </view>
                                        <view class="c-p-t-6 chuany-width50">
                                            <up-text color="#696969" :lines="1" :text="item.planContent"></up-text>
                                        </view>
                                        <view class="c-p-t-8 chuany-width24 chuany-text-right">
                                            {{item.planMoney}} 元
                                        </view>
                                    </view>
                                    
                                </view>
                            </view>
                        </view>
                    </view>
                    <up-loadmore :status="loadStatus" />
                </view>
                <view v-else>
                    <up-empty text='暂无' icon="/static/order.png">
                    </up-empty>
                </view>
            </view>
            <fui-date-picker range :show="datePickerShow" :value="getFirstDayOfMonth()" type="3" @change="changePicker"
                @cancel="cancel"></fui-date-picker>
            <view class="tabbtns">
                合计:{{heji}} 元
            </view>
        </view>
    </view>
 
</template>
 
<script setup>
    import {
        onLoad,
        onShow,
        onReachBottom,
        onPullDownRefresh,
        onHide
    } from "@dcloudio/uni-app";
    import {
        reactive,
        ref,
        getCurrentInstance
    } from 'vue';
    const {
        $upload,
        $api,
        $util,
        $db
    } = getCurrentInstance().appContext.config.globalProperties
    let state = reactive({
        pageIndex: 1,
        pageSize: 20,
    })
    const list = ['全部', '未审批', '不批准', '批准']
    let workTime = ref('')
    let datePickerShow = ref(false)
    let loadStatus = ref('loadmore')
    let workerUserName = ref('')
    let totalPages = ref(0)
    let listO = reactive({
        orderList: []
    })
    let checkboxValue1 = ref(null)
    let idValue = ref(null)
    let role = ref()
    let approvalStatus = ref('unApproval')
    let heji = ref(0)
    onReachBottom(() => {
        if (loadStatus.value != 'nomore') {
            getRolePlaneList();
        }
    })
 
    onPullDownRefresh(() => {
        init()
        uni.stopPullDownRefresh();
    })
    onLoad((options) => {
        role.value = options.role
        // workTime.value = getFirstDayOfMonth() + '至' + $util.formatDate(new Date())
        // state.planStartTimeStart = getFirstDayOfMonth() //工作开始时间
        // state.planStartTimeEnd = $util.formatDate(new Date())
 
    })
    onShow(() => {
        init()
    })
    const getFirstDayOfMonth = () => {
        var currentDate = new Date();
        currentDate.setDate(1); // 将日期设为1
        return $util.formatDate(currentDate);
    }
    const sectionChange = (val) => {
        switch (val) {
            case 0:
                approvalStatus.value = null
                break;
            case 1:
                approvalStatus.value = 'unApproval'
                break;
            case 2:
                approvalStatus.value = 'No'
                break;
            case 3:
                approvalStatus.value = 'Yes'
                break;
        }
        init()
    }
    const current4 = ref(0);
    // const list = ref(['全部', '审核中', '已录用', '未录用']);
    const changePicker = (val) => {
        console.log(val);
        workTime.value = val.startDate.result + '至' + val.endDate.result
        state.planStartTimeStart = new Date(val.startDate.result) //工作开始时间
        state.planStartTimeEnd = new Date(val.endDate.result)
        datePickerShow.value = !datePickerShow.value
        init()
    }
 
    // const search = (index) => {
    //     console.log(index, '------’');
    //     if (index == 0) {
    //         getRolePlaneList()
    //     } else {
    //         getRolePlaneList(index - 1)
    //     }
 
    // }
    const clear = () => {
        state.planStartTimeStart = ""
        state.planStartTimeEnd = ""
        getRolePlaneList()
    }
    const clickTime = () => {
        datePickerShow.value = !datePickerShow.value
    }
 
    const cancel = () => {
        datePickerShow.value = !datePickerShow.value
    }
    const init = () => {
        state.pageIndex = 1
        state.pageSize = 20
        loadStatus.value = 'loadmore'
        listO.orderList = []
        getRolePlaneList()
    }
    const getRolePlaneList = () => {
        let data = {
            page: {
                pageIndex: state.pageIndex,
                pageSize: state.pageSize,
            },
            approvalStatus: approvalStatus.value
        }
        if (state.planStartTimeStart) {
            data.planStartTimeStart = state.planStartTimeStart
        }
        if (state.planStartTimeEnd) {
            data.planStartTimeEnd = state.planStartTimeEnd
        }
        if (workerUserName.value) {
            data.staffName = workerUserName.value
        }
        loadStatus.value = 'loading';
        let getList = null
        if (role.value == 'zhuGuan') {
            getList = $api.getzhuguanplanelist
        } else {
            getList = $api.getjingliplanelist
        }
        getList(data).then(res => {
            console.log(res, res.code, '-----------123’');
            if (res.code == 1) {
                heji.value = res.data.totalMoney
                if (state.pageIndex == 1) {
                    listO.orderList = res.data.list
                } else {
                    listO.orderList = listO.orderList.concat(...res.data.list)
                }
                console.log(listO.orderList, 'listO.orderList’');
                // totalPages.value = res.data.totalCount
                // 根据count数量判断是否还有数据
                if (res.data.page.totalCount > listO.orderList.length) {
                    loadStatus.value = 'loadmore'
                    state.pageIndex++
                } else {
                    // 数据已加载完毕
                    loadStatus.value = 'nomore'
                }
            } else {
                // _that.$refs.uToast.show({ message: res.msg, type: 'error' });
            }
        })
    }
    const pageToDetail = (item) => {
        uni.navigateTo({
            url: `/pages/reimbursement/approve?role=${role.value}&detailId=${item.keyid}`
        });
 
        // if (state.planStartTimeStart) {
        //     data.planStartTimeStart = state.planStartTimeStart
        // }
        // if (state.planStartTimeEnd) {
        //     data.planStartTimeEnd = state.planStartTimeEnd
        // }
 
        // $db.set('detailItem',JSON.stringify(item))
    }
    const arrange = (val) => {
        if (!idValue.value || idValue.value.length < 1) {
            $util.showToast({
                title: '至少选择一项!'
            })
            return
        }
        uni.showModal({
            title: val == 'Yes' ? '确认批准所选内容?' : '确认不批准所选内容?',
            content: '',
            editable: true,
            placeholderText: '请输入审批意见',
            success: function(res) {
                if (res.confirm) {
                    console.log('确认', res)
                    //执行
                    // start()
                    let obj = {
                        oA_WorkPlanIds: idValue.value,
                        approvalStatus: val,
                        approvalContent: res.content
                    }
                    $api.BatchShenPi(obj).then(resp => {
                        if (resp.code == 1) {
                            $util.showToast({
                                title: val == 'Yes' ? '批准成功!' : "不批准成功!",
                                icon: "success"
                            })
                            idValue.value = []
                            checkboxValue1.value = []
                            init()
                        } else {
                            $util.showToast({
                                title: resp.error
                            })
                        }
                    })
                } else if (res.cancel) {
                    console.log('取消');
                }
            }
        });
        // uni.navigateTo({
        //     url: '/pages/delivery/driver/arrangedetail'
        // });
    }
    const checkboxChange = (val) => {
        idValue.value = val
    }
</script>
 
<style>
    .content {
        /* width: 100%; */
        box-sizing: border-box;
    }
 
    .bgblue {
        background-color: #4e96f5;
        border-radius: 20rpx 20rpx 0 0;
        color: #fff;
    }
 
    .listrecord {
        width: 100%;
        box-sizing: border-box;
    }
</style>