spring
4 天以前 435881d494e2be4ba5ce8bfccb02d6ef49e07314
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
<template>
    <view class="work-order-list">
        <view class="page-head">
            <u-navbar title="人员列表"  :border-bottom="false"
                      :background="background"
                      :title-bold="true" title-color="#000"
                      back-icon-color="#000" />
            <view class="search">
                <u-search placeholder="请输入人员名称" v-model="staffName"
                          border-color="#ADC8E4" shape="square" bg-color="rgba(250,252,255,0.36)"
                          placeholderColor="#8992A3" :showAction="false" style="margin: 35rpx;"
                          searchIconColor="#333333" height="74" @search="search" @change="search"></u-search>
            </view>
            <span class="title">检查结果选择</span>
            <view class="list">
                <view v-for="(item, index) in personList" :key="index" class="person-card">
                    <view class="card-info">
                        <span>
                            <u-icon class="icon_num" size="26rpx"/>
                            <span class="h5-title">人员编号:</span>
                            <span class="h5-info">{{item.staffNo}}</span>
                        </span>
                        <span>
                            <u-icon class="icon_person" size="26rpx"/>
                            <span class="h5-title">人员名称:</span>
                            <span class="h5-info">{{item.staffName}}</span>
                        </span>
                    </view>
                    <u-checkbox active-color="#428BF7" icon-size="24rpx" class="checkbox" v-model="item.checked" @change="checkboxChange(item)"></u-checkbox>
                </view>
                <view class="loadmore" @click="loadMore">
                    <u-loadmore :status="loadStatus"></u-loadmore>
                </view>
            </view>
        </view>
        <view class="bottom">
            <u-button class="u-button" :loading="loading" type="primary" @click="submit">提交</u-button>
        </view>
    </view>
</template>
 
<script>
import content_bg from '@/static/custom/daily/background.png'
import UIcon from "../../../uview-ui/components/u-icon/u-icon.vue";
 
export default {
    name: "production-person",
    // import 引入的组件需要注入到对象中才能使用
    components: {UIcon},
    data() {
        // 这里存放数据
        return {
            background: {
                // background:'transparent'
                backgroundImage: `url(${content_bg})`,
                backgroundAttachment: 'fixed',
                backgroundSize: '100% auto',
                backgroundRepeat: 'no-repeat',
            },
            loading:false,
            staffName:'',
            personCheckedList : [],
            personList: [],
            query: {
                current: 1,
                size: 20,
                staffName: '',
                divisionName:"生产部"
            },
            loadStatus: 'loadmore',
        }
    },
    async onLoad(options) {
        this.personCheckedList = []
        this.personCheckedList = JSON.parse(decodeURIComponent(options.list))
        await this.loadList()
    },
    // 方法集合
    methods: {
        checkboxChange (item) {
            if(!item.checked) {
                const obj = {
                    staffName: item.staffName,
                    staffNo: item.staffNo
                }
                this.personCheckedList.push(obj)
            } else {
                var index = this.personCheckedList.findIndex((i) => {
                    return i.staffNo==item.staffNo;
                })
                this.personCheckedList.splice(index,1);
            }
            this.$set(item, 'checked', !item.checked)
        },
        submit () {
            console.log(`output->this.personCheckedList`,this.personCheckedList)
            this.loading = true;
            uni.$emit('checkedList',this.personCheckedList)
            uni.navigateBack({
                //关闭当前页面,返回上一页面或多级页面。
                delta:1
            });
            this.loading = false;
        },
        // async getUserInfoFun() {
        //     const params = {
        //         current: this.page.current,
        //         size: this.page.size,
        //         staffName: this.staffName
        //     }
        //     await this.$u.api.dailyPaper.getUserInfo(params).then(res => {
        //         this.personList = res.data.records
        //         this.choosingFUn(this.personList, this.personCheckedList)
        //     })
        // },
        search (e) {
            this.query = {
                current:1,
                size:20,
                staffName: e,
                divisionName:"生产部"
            }
            this.loadList()
        },
        // 在此加载列表
        loadList(){
            this.$u.api.dailyPaper.getUserInfo(this.query).then(res => {
                console.log(res)
                if (res.code === 0) {
                    if (!res.data.records || res.data.records.length === 0) {
                        this.loadStatus = "nomore";
                        return;
                    }
                    if (this.query.current === 1) {
                        this.personList = res.data.records
                    } else {
                        this.personList = this.personList.concat(res.data.records);
                    }
                    this.choosingFUn(this.personList, this.personCheckedList)
                    this.total = res.data.total;
                    this.query.current = res.data.current;
                    this.query.size = res.data.size;
                    this.loadStatus = "loadmore";
                }
            });
        },
        // 搜索不会使选中消失
        /**
         *
         * @param {主数据列表} mainList
         * @param {选中的数据列表} selectList
         */
        choosingFUn(mainList, selectList) {
            for (const i in mainList) {
                let isExit = false
                for (const j in selectList) {
                    if(mainList[i].staffNo === selectList[j].staffNo) {
                        isExit = true
                        this.$set(mainList[i], 'checked', true)
                    }
                }
                if(!isExit) {
                    this.$set(mainList[i], 'checked', false)
                }
            }
        },
        loadMore() {
            this.loadStatus = "loading";
            setTimeout(() => {
                this.query.current += 1;
                this.loadList();
            }, 100);
        },
    },
 
}
</script>
 
<style scoped lang="scss">
.work-order-list{
    width: 100%;
    height: 100vh;
    background: #F6F9FF;
    box-sizing: border-box;
    padding-bottom: 24rpx;
    .page-head{
        height: 750rpx;
        background-image: url('~@/static/custom/daily/background.png');
        background-size: 100% auto;
        background-repeat: no-repeat;
        .title {
            font-weight: 500;
            font-size: 28rpx;
            color: #6D82A1;
            margin-left: 30rpx;
        }
        .list {
            overflow-y: auto;
            padding: 0 30rpx;
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: space-between;
            align-content: flex-start;
            margin-top: 20rpx;
            height: calc(100vh - 450rpx);
            .person-card {
                margin-top: 30rpx;
                width: 336rpx;
                height: 138rpx;
                background: linear-gradient(180deg, #DFEDFF 0%, #F7F7F8 100%);
                border-radius: 10rpx;
                border: 1px solid #FFFFFF;
                position: relative;
                display:table-cell; vertical-align:middle;
                .card-info {
                    display: flex;
                    flex-direction: column;
                    justify-content: center;
                    height: 100%;
                    padding: 0 16rpx;
                    .icon_num {
                        background-image: url('~@/static/custom/daily/icon_num.png');
                        background-repeat: no-repeat;
                        background-size: cover;
                        height: 26rpx;
                        width: 26rpx;
                        position: relative;
                        vertical-align: middle
                    }
                    .icon_person {
                        background-image: url('~@/static/custom/daily/icon_person.png');
                        background-repeat: no-repeat;
                        background-size: cover;
                        height: 26rpx;
                        width: 26rpx;
                        position: relative;
                        vertical-align: middle
                    }
                    .h5-title {
                        font-weight: 500;
                        font-size: 26rpx;
                        color: #666666;
                        margin: 0 6rpx;
                        line-height: 48rpx;
                    }
                    .h5-info {
                        font-weight: 500;
                        font-size: 26rpx;
                        color: #333333;
                        line-height: 48rpx;
                    }
                }
                .checkbox {
                    position: absolute;
                    bottom: 12rpx;
                    right: 16rpx;
                }
            }
            .loadmore {
                margin: 20rpx auto;
                width: 100%;
                height: 60rpx;
            }
        }
    }
    .bottom {
        width: 100vw;
        position:fixed;
        bottom:60rpx;
        .u-button {
            width: 690rpx;
            height: 80rpx;
            background: #214DED;
            border-radius: 8rpx;
            font-weight: 500;
            font-size: 34rpx;
            color: #FFFFFF;
            z-index: 99;
        }
    }
}
::v-deep.uni-input-placeholder {
    font-weight: 400;
    font-size: 30rpx;
    color: #8992A3;
    line-height: 80rpx;
}
::v-deep.u-checkbox {
    display: inline;
}
::v-deep.u-checkbox__icon-wrap {
    background: #F5F9FF;
    border-radius: 2rpx;
    border: 1px solid #428BF7;
}
</style>