cuiqian2004
8 天以前 f57571f987f3d25730123f488fccdfa3158ec5b1
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
<template>
    <view class="page-calendar-list">
        <view class="container" v-if="calendarLst.length > 0">
            <view class="uni-panel-content">
                <view v-for="(item,index) in calendarLst" class="uni-panel-calendar-item" :key="item.ID"
                    @click="clickCalendarItem(item)">
                    <view class="uni-panel-item">
                        <text class="uni-panel-item-ico fs-calendar"></text>
                        <text class="uni-panel-item-text blue-text">{{item.CreatorName}}</text>
                        <text class="uni-panel-item-text">{{item.Name}}</text>
                    </view>
                    <text class="uni-panel-right-icon blue-text "
                        :class="item.checked ? 'fs-CheckBoxOk2' : 'fs-CheckBoxEmpty2'" style="transform:scale(0.8)" />
                </view>
            </view>
            <view class="uni-panel-bottom">
                <view class="button-clz">
                    <button class="uni-panel-button" @click="onOK">确定</button>
                </view>
            </view>
            <view class="uni-panel-safe-bottom" :style="{height:safeAreaBottom + 'px'}" />
        </view>
        <view class="container justify-center items-center" v-else>
            <view class="uni-panel-no-calendar">
                <view class="uni-no-calendar-tip">{{noCalendarTip}}</view>
            </view>
        </view>
    </view>
</template>
 
<script>
    import Session from "@/common/utils.js"
    import {
        otherList as calendarOtherList,
        subordinateList as calendarSubordinateList,
        publishList as calendarPublishList,
    } from "@/api/gungho/calendar.js"
    import {
        showModal,
        showToast,
        showLoading,
        hideLoading
    } from "@/common/Page.js"
    export default {
        name: "pageCalendarList",
        data() {
            return {
                safeAreaBottom: getApp().globalData.safeAreaBottom,
                options: {},
                calendarLst: [],
                noCalendarTip: "",
            }
        },
        methods: {
            setData: function(obj) {
                let that = this;
                let keys = [];
                let val, data;
 
                Object.keys(obj).forEach(function(key) {
                    keys = key.split(".");
                    val = obj[key];
                    data = that.$data;
                    keys.forEach(function(key2, index) {
                        if (index + 1 == keys.length) {
                            that.$set(data, key2, val);
                        } else {
                            if (!data[key2]) {
                                that.$set(data, key2, {});
                            }
                        }
                        data = data[key2];
                    });
                });
            },
            loadShareList() {
                var _this = this
                showLoading("加载中,请稍后...")
                calendarOtherList(0x02).then((res) => {
                    const list = res || []
                    if (list.length > 0) {
                        _this.setData({
                            calendarLst: list
                        })
                    } else
                        _this.setData({
                            calendarLst: [],
                            noCalendarTip: "没有共享给我的日历"
                        })
                    hideLoading()
                }).catch((rej) => {
                    hideLoading()
                    _this.setData({
                        calendarLst: [],
                        noCalendarTip: "没有共享给我的日历"
                    })
                    console.log("shareList catch", rej)
                })
 
            },
            loadPublicList() {
                var _this = this
                showLoading("加载中,请稍后...")
                calendarPublishList().then((res) => {
                        hideLoading()
                    const list = res || []
                    if (list.length > 0) {
                        _this.setData({
                            calendarLst: list
                        })
                    } else {
                        _this.setData({
                            calendarLst: [],
                            noCalendarTip: "没有公开日历"
                        })
                    }
                
                }).catch((rej) => {
                    hideLoading()
                    _this.setData({
                        calendarLst: [],
                        noCalendarTip: "没有公开日历"
                    })
                    console.log("publicList catch", rej)
                })
            },
            loadSubordinateList() {
                var _this = this
                showLoading("加载中,请稍后...")
                calendarSubordinateList().then((res) => {
                    const list = res || []
                        hideLoading()
                    if (list.length > 0) {
                        _this.setData({
                            calendarLst: list
                        })
                    } else
                        _this.setData({
                            calendarLst: [],
                            noCalendarTip: "没有我的下属日历"
                        })
                
                }).catch((rej) => {
                    hideLoading()
                    _this.setData({
                        calendarLst: [],
                        noCalendarTip: "没有我的下属日历"
                    })
                    console.log("getSubordinate catch", rej)
                })
            },
            clickCalendarItem(item) {
                item.checked = !item.checked
 
            },
            onOK() {
                const list = []
                for (let i = 0; i < this.calendarLst.length; i++) {
                    let item = this.calendarLst[i]
                    if (item.checked) {
                        list.push(item)
                    }
                }
                let pages = getCurrentPages();
                let prepage = pages[pages.length - 2];
                prepage.$vm[this.options.evalfunction](list)
                uni.navigateBack({
                    delta: 1
                })
 
            },
            showError(ex) {
                let tip = typeof ex == 'string' ? ex : typeof ex.err_msg == 'string' ? ex.err_msg : typeof ex.errMsg ==
                    'string' ? ex.errMsg : ""
                showModal(tip, "提示", false)
            },
        },
        onLoad(option) {
            if (!option.evalfunction)
                option.evalfunction = 'getBackList'
            this.options = option;
            // #ifdef MP-DINGTALK
 
            my.setNavigationBar({
                backgroundColor: "#007AFF",
                frontColor: "#ffffff"
            })
            // #endif
            if (option.type == 0) {
                uni.setNavigationBarTitle({
                    title: "从共享给我的日历选"
                })
                this.loadShareList()
            } else if (option.type == 1) {
                uni.setNavigationBarTitle({
                    title: "从我的下属日历选"
                })
                this.loadSubordinateList()
 
            } else if (option.type == 2) {
                uni.setNavigationBarTitle({
                    title: "从所有公共日历选"
                })
                this.loadPublicList()
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    @import "../../common/css/button.scss";
 
    page {
        background-color: #e5eaee;
        height: calc(100vh - 10px);
    }
 
    .page-calendar-list {
 
        width: 750rpx;
        height: 100vh;
        background-color: #e5eaee;
 
        .justify-center {
            justify-content: center;
        }
 
        .items-center {
            align-items: center
        }
 
        .container {
            display: flex;
            width: 100%;
            height: 100%;
            flex-direction: column;
 
            .uni-panel-content {
                display: flex;
                flex: 1;
                width: 100%;
                padding: 8px 0;
                overflow: auto;
                flex-direction: column;
                height: calc(100% - 64px);
            }
 
            .uni-panel-calendar-item {
                display: flex;
                flex-direction: row;
                width: calc(750rpx - 30px);
                margin: 5px 10px;
                background-color: white;
                border-radius: 8px;
                padding: 10px 5px;
            }
 
            .uni-panel-item {
                width: 100%;
                flex: 1;
 
                .uni-panel-item-ico {
                    // display: flex;
                    margin: 4px 8px 4px 4px;
                    font-size: 16px;
                    color: #333;
                    line-height: 50rpx;
                }
 
                .uni-panel-item-text {
                    // display: flex;
                    margin: 4px 8px 4px 4px;
                    font-size: 14px;
                    line-height: 50rpx;
                }
 
 
            }
 
            .blue-text {
                color: #007aff;
            }
 
            .uni-panel-right-icon {
                height: 50rpx;
                padding: 0px 4px;
                line-height: 50rpx;
                font-size: 24px;
                text-align: right;
            }
 
            .button-clz {
                display: flex;
                width: 100%;
                flex-direction: row;
                font-size: 17px !important;
                margin-top: 8px;
                margin-bottom: 8px;
                border-radius: 0px;
            }
 
            .uni-panel-button {
                width: 100%;
                border-radius: 12px;
                margin: 5px 12px 16px;
                background-color: #00aaff;
                color: #fff;
            }
 
            .uni-panel-bottom {
                display: flex;
                justify-content: flex-end;
                align-items: flex-end;
                min-height: 20px;
                padding: 8px 12px;
                font-size: 14px;
            }
 
            .uni-panel-no-calendar {
                padding: 20px;
            }
 
            .unino-calendar-tip {
                color: #aaa;
                padding-bottom: 20px;
                font-size: 20px;
            }
        }
    }
</style>