-
zhangwei
2024-09-30 2e61c194b816364fe4fbab967fee13dbefe86216
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
<template>
    <scroll-view class="full-page" scroll-y using-sticky>
        <up-sticky bgColor="#fff">
            <view class="coreshop-ff content c-p-10">
                <!-- <up-search placeholder="请点击选择日期" @clear='clear' @clickIcon='clickTime' @custom='search'
                    v-model="workTime" search-icon="calendar" @search='search'></up-search> -->
                <up-search placeholder="请输入工作名称" @clear='clear' @custom='PostMyListPageCompany'
                    v-model="state.orderName" @search='PostMyListPageCompany'></up-search>
            </view>
            <up-subsection :list="list" current="1" activeColor="#f9ae3d" @change="sectionChange"></up-subsection>
        </up-sticky>
        <view class="full-page-content">
            <view class="c-p-l-20 c-p-r-20" v-if="listO.orderList&&listO.orderList.length>0">
                <view class="listrecord c-p-t-20" v-for="(item,index) in listO.orderList" :key="item.id"
                    @click="pageToDetail(item)">
                    <view class="coreshop-ff chuany-bradius20 ">
                        <view class="c-p-24">
                            <view class="chuany-flex chuany-justify-between">
                                <text class="chuany-font32">
                                    {{item.orderName}}
                                </text>
                                <view class="chuany-flex chuany-justify-between">
                                    <!-- 招工人数:{{item.worderCount}}人 -->
                                    <!-- <text class="c-p-r-20">
                                    
                                </text> -->
                                    <!-- <up-tag class='c-m-r-10' :text="item.orderStatusName" shape="circle" type="success"
                                        plain plainFill size='mini'></up-tag> -->
                                    <up-text :type="item.orderStatus==0?'primary':'success'" :text="item.orderStatusName" size='12'></up-text>
                                    <!-- <up-button class='c-m-r-10' :text="item.isEn?'下架':'上架'" disabled shape="circle"
                                        v-if="item.orderStatus==0" :type="item.isEn?'error':'primary'" size='mini'
                                        @click.stop="manageOrder(item)"></up-button> -->
                                </view>
                            </view>
                            <view class="text-69 chuany-font28">
                                <view class="">
                                    日期:{{$util.formatDate(item.wordStartTime)}} 至 {{$util.formatDate(item.wordEndTime)}}
                                </view>
                                <view class="chuany-flex chuany-justify-between chuany-flex-wrap">
                                    <view class="chuany-width50" v-if="item.zixinganpai">
                                        时间:{{item.zixinganpaiName}}
                                    </view>
                                    <view class="chuany-width50" v-else>
                                        时间:{{item.startTimeName}} 至 {{item.endTimeName}}
                                    </view>
                                    <view class="chuany-width50">
                                        <text>
                                            方式:{{item.workerType==0?'计时':'计件'}}
                                        </text>
                                    </view>
                                    <view class="chuany-width50">
                                        工价:{{item.workPrice}}{{item.workerType==0?'元/小时':'元/件'}}
                                        <text></text>
                                    </view>
                                    <view class="">
                                        <up-button hoverStopPropagation :text="item.isEn?'下架':'上架'" shape="circle" :loading='item.isLoading' :loadingText="item.isEn?'下架中':'上架中'"
                                            v-if="item.orderStatus==0" :type="item.isEn?'error':'primary'" size='mini'
                                            @tap.stop="manageOrder(item)"></up-button>
                                    </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" type="5" @change="changePicker"
            @cancel="cancel"></fui-date-picker>
    </scroll-view>
</template>
 
<script setup>
    import {
        onLoad,
        onShow,
        onReachBottom,
        onPullDownRefresh
    } 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,
        orderName: ''
    })
    let workTime = ref('')
    let datePickerShow = ref(false)
    let loadStatus = ref('loadmore')
    let totalPages = ref(0)
    let isEn = ref(true)
    let listO = reactive({
        orderList: []
    })
    onReachBottom(() => {
        if (loadStatus.value != 'nomore') {
            PostMyListPageCompany();
        }
    })
    onShow(() => {
        PostMyListPageCompany()
    })
    onPullDownRefresh(() => {
        state.pageIndex = 1
        state.pageSize = 20
        loadStatus.value = 'loadmore'
        PostMyListPageCompany()
        uni.stopPullDownRefresh();
    })
    const current4 = ref(0);
    const list = ref(['全部', '已上架', '已下架']);
    const changePicker = (val) => {
        console.log(val);
        workTime.value = val.startDate.result + '至' + val.endDate.result
        state.wordStartTime = new Date(val.startDate.result) //工作开始时间
        state.wordEndTime = new Date(val.endDate.result)
    }
    const clear = () => {
        state.orderName = ''
        state.wordStartTime = ""
        state.wordEndTime = ""
        PostMyListPageCompany()
    }
    const clickTime = () => {
        datePickerShow.value = !datePickerShow.value
    }
    const PostMyListPageCompany = () => {
        let data = {
            pageIndex: state.pageIndex,
            pageSize: state.pageSize,
            isEn: isEn.value
        }
        if (state.wordStartTime) {
            data.wordStartTime = state.wordStartTime
        }
        if (state.wordEndTime) {
            data.wordEndTime = state.wordEndTime
        }
        if (state.orderName) {
            data.orderName = state.orderName
        }
        loadStatus.value = 'loading';
        $api.PostMyListPageCompany(data).then(res => {
            console.log(res, res.code, '-----------123’');
            if (res.code == 1) {
                if (state.pageIndex == 1) {
                    listO.orderList = res.data.items
                } else {
                    listO.orderList = listO.orderList.concat(...res.data.items)
                }
                listO.orderList.forEach(item => {
                    item.isLoading = false
                })
                console.log(listO.orderList, 'listO.orderList’');
                // totalPages.value = res.data.totalCount
                // 根据count数量判断是否还有数据
                if (res.data.totalCount > listO.orderList.length) {
                    loadStatus.value = 'loadmore'
                    state.pageIndex++
                } else {
                    // 数据已加载完毕
                    loadStatus.value = 'nomore'
                }
            } else {
                // _that.$refs.uToast.show({ message: res.msg, type: 'error' });
            }
        })
    }
    const sectionChange = (val) => {
        switch (val) {
            case 0:
                isEn.value = null
                break;
            case 1:
                isEn.value = true
                break;
            case 2:
                isEn.value = false
                break;
        }
        PostMyListPageCompany()
    }
    const manageOrder = (item) => {
        let obj = {
            orderId: item.id
        }
        console.log(obj);
        item.isLoading = true
        if (item.isEn) {
            $api.deleteOrder(obj).then(res => {
                if (res.code == 1) {
                    $util.showToast({
                        title: '下架成功!'
                    })
                    PostMyListPageCompany()
                } else {
                    $util.showToast({
                        title: res.error
                    })
                }
                item.isLoading = false
            })
        } else {
            $api.saveOrder(item).then(res => {
                if (res.code == 1) {
                    $util.showToast({
                        title: "上架成功!",
                        icon: "success"
                    })
                    PostMyListPageCompany()
                } else {
                    $util.showToast({
                        title: res.msg
                    })
                }
                item.isLoading = false
            })
        }
    }
    const pageToDetail = (item) => {
        uni.navigateTo({
            url: `/pages/order/detail?orderid=${item.id}`
        });
        // $db.set('detailItem',JSON.stringify(item))
    }
</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>