linwe
2024-08-08 3c738f4fe2762bba8087e5a22fc0dc06560eab0e
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
<template>
    <view class="form-box">
        <u-form labelWidth="70" :model="form" :rules="rules" ref="form">
            <u-form-item label="姓名" required prop="name" class="form-item">
                <u--input v-model="form.name" border="none" placeholder="请填写姓名"></u--input>
            </u-form-item>
            <u-form-item @click="showGenderPicker = true" class="form-item" label="性别" prop="legalGender">
                <u--input border="none" v-model="genderValue" disabled disabledColor="#ffffff" placeholder="请选择性别">
                </u--input>
                <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item @click="showNationPicker = true" class="form-item" label="民族" prop="ethnicity">
                <u--input border="none" v-model="nationValue" disabled disabledColor="#ffffff" placeholder="请选择民族">
                </u--input>
                <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item label="身份证号" class="form-item">
                <u--input v-model="form.idCard" type="idcard" border="none" placeholder="请填写身份证号"></u--input>
            </u-form-item>
            <u-form-item label="电话号码" class="form-item">
                <u--input v-model="form.telephone" border="none" placeholder="请填写电话号码"></u--input>
            </u-form-item>
            <u-form-item label="现居住地" class="form-item">
                <u--input v-model="form.tempAddress" border="none" placeholder="请填写现居住地"></u--input>
            </u-form-item>
 
            <!-- <u-form-item label="微信号" class="form-item">
                <u--input v-model="form.wxAccount" border="none" placeholder="请填写微信号"></u--input>
            </u-form-item> -->
 
 
 
            <u-form-item label="岗位" class="form-item">
                <u--input v-model="form.jobNature" border="none" placeholder="请填写岗位"></u--input>
            </u-form-item>
            <u-form-item v-if="addressType == 2" @click="showEmploymentTime = true" class="form-item" label="入职时间"
                prop="ethnicity">
                <u--input border="none" v-model="form.employmentTime" disabled disabledColor="#ffffff"
                    placeholder="请选择入职时间">
                </u--input>
                <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
            <u-form-item v-if="addressType == 2" @click="showResignationTime = true" class="form-item" label="离职时间"
                prop="ethnicity">
                <u--input border="none" v-model="form.resignationTime" disabled disabledColor="#ffffff"
                    placeholder="请选择离职时间">
                </u--input>
                <u-icon slot="right" name="arrow-right"></u-icon>
            </u-form-item>
 
            <!-- <u-form-item label="户籍地址" class="form-item">
                <u--input v-model="form.registeredAddress" border="none" placeholder="请填写户籍地址"></u--input>
            </u-form-item> -->
 
            <u-form-item label="从业人员照片" class="form-item" labelPosition="top" labelWidth="100">
                <view style="padding:20rpx 0 0;">
                    <u-upload :fileList="form.employerImg" :previewFullImage="uploadConfig.previewFullImage"
                        :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple"
                        :maxCount="uploadConfig.maxCount" :capture="uploadConfig.capture"
                        uploadIcon="/static/icon/upload.png" @afterRead="afterReadImgs" @delete="deleteImages">
                    </u-upload>
                </view>
            </u-form-item>
        </u-form>
 
        <u-datetime-picker ref="datetimePicker" :show="showEmploymentTime" v-model="workTime" mode="date"
            :formatter="formatter" @confirm="confirmEmploymentTime"
            @cancel="showEmploymentTime = false"></u-datetime-picker>
 
        <u-datetime-picker ref="datetimePicker" :show="showResignationTime" v-model="workTime" mode="date"
            :formatter="formatter" @confirm="confirmResignationTime"
            @cancel="showResignationTime = false"></u-datetime-picker>
 
        <u-picker :defaultIndex="nationTypeListIndex" :closeOnClickOverlay="true" :show="showNationPicker"
            :columns="[nationTypeList]" @close="showNationPicker = false" @cancel="showNationPicker = false"
            keyName="name" @confirm="confirmNation"></u-picker>
 
        <u-picker :defaultIndex="genderIndex" :closeOnClickOverlay="true" :show="showGenderPicker" :columns="[gender]"
            @close="showGenderPicker = false" @cancel="showGenderPicker = false" keyName="name"
            @confirm="confirmGender"></u-picker>
    </view>
</template>
<script>
    import {
        bizDictionary
    } from '@/api/system/dict.js'
    import uploadMixin from "@/mixin/uploadMixinPlace";
    export default {
        mixins: [uploadMixin],
        data() {
            return {
                form: {
                    name: '',
                    telephone: '',
                    tempAddress: '',
                    idCard: '',
                    gender: "",
                    ethnicity: "",
                    registeredAddress: "",
                    jobNature: "",
                    wxAccount: "",
                    employer: "",
                    jobNature: "",
                    employerImg: []
                },
                rules: {
                    name: {
                        type: 'string',
                        required: true,
                        message: '请填写姓名',
                        trigger: ['blur', 'change']
                    }
                },
                nationTypeList: [], //民族
                nationTypeIndex: [0],
                nationValue: "",
                gender: [{ //性别
                        value: 1,
                        name: '男',
                    },
                    {
                        value: 0,
                        name: '女',
                    }
                ],
                genderIndex: [0],
                genderValue: "",
                showNationPicker: false,
                showGenderPicker: false,
                showEmploymentTime: false,
                showResignationTime: false,
                workTime: Number(new Date()),
                addressType: ""
            }
        },
 
        created() {
            this.addressType = uni.getStorageSync("siteInfo").addressType;
            this.getAllBizDict()
        },
 
        methods: {
            async getAllBizDict() {
                // 获取民族
                await this.getBizDict('nationType', this.nationTypeList);
            },
 
            // 获取业务字典
            async getBizDict(code, list) {
                const param = {
                    code: code
                }
                const res = await bizDictionary(param)
                res.data.forEach(e => {
                    list.push({
                        name: e.dictValue,
                        value: Number(e.dictKey)
                    })
                })
            },
 
            //选择民族
            confirmNation(e) {
                this.nationIndex = e.indexs;
                this.nationValue = e.value[0].name;
                this.form.ethnicity = e.value[0].value;
                this.showNationPicker = false;
            },
 
            //选择性别
            confirmGender(e) {
                this.genderIndex = e.indexs;
                this.genderValue = e.value[0].name;
                this.form.gender = e.value[0].value;
                this.showGenderPicker = false;
            },
 
 
            //上传成功后对返回数据进行处理
            async afterReadImgs(event) {
                this.showLoading()
                let lists = [].concat(event.file)
                let fileListLen = this.form.employerImg.length
                lists.map((item) => {
                    this.form.employerImg.push({
                        ...item,
                        status: 'uploading',
                        message: '上传中'
                    })
                })
                for (let i = 0; i < lists.length; i++) {
                    const result = await this.uploadFilePromise(lists[i].url)
                    this.form.employerImg.splice(fileListLen, 1, Object.assign({}, {
                        url: result.data.link,
                        name: result.data.name
                    }))
                    fileListLen++
                }
                this.loadingClose()
            },
 
            deleteImages(event) {
                this.form.employerImg.splice(event.index, 1)
            },
 
            confirmResignationTime(e) {
                this.form.resignationTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
                this.showResignationTime = false;
            },
 
            confirmEmploymentTime(e) {
                this.form.employmentTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd')
                this.showEmploymentTime = false;
            },
 
 
        }
    }
</script>
<style lang="scss" scoped>
    .form-box {
        background-color: #fff;
        padding: 0 30rpx;
 
        .form-item {
            border-bottom: 1rpx solid #f6f6f6;
            padding: 0 20rpx;
            background-color: #fff;
        }
    }
</style>