linwe
2023-11-12 b77cc2d2012ecb4b876538ac7aee3edac7db8a2f
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
<template>
    <view class="container">
        <view class="main-content">
            <view class="mt-20 b-c-w">
                <box-title :title="'基本信息'"></box-title>
                <u-form labelWidth="70" :model="form" :rules="rules" ref="form" class="form">
                    <u-form-item label="场所位置" required class="form-item" prop="localtion">
                        <u--input border="none" v-model="form.localtion"></u--input>
                    </u-form-item>
                    <u-form-item label="场所名称" required class="form-item" prop="placeName">
                        <u--input border="none" v-model="form.placeName"></u--input>
                    </u-form-item>
                    <u-form-item label="法人信息" required class="form-item" prop="legalPerson">
                        <u--input border="none" v-model="form.legalPerson"></u--input>
                    </u-form-item>
                    <u-form-item label="法人电话" class="form-item">
                        <u--input border="none" v-model="form.legalTel"></u--input>
                    </u-form-item>
                </u-form>
            </view>
            <view class="mt-20 b-c-w">
                <box-title title="营业执照"></box-title>
                <view class="upload-img">
                    <u-upload :fileList="form.imageUrls" :previewFullImage="uploadConfig.previewFullImage"
                        :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple"
                        :maxCount="uploadConfig.maxCount" :capture="uploadConfig.capture" @afterRead="afterReadImg"
                        @delete="deletePic">
                    </u-upload>
                </view>
            </view>
            <view class="mt-20 b-c-w">
                <box-title title="场所平面图"></box-title>
                <view class="upload-img">
                    <u-upload :fileList="form.planImageUrls" :previewFullImage="uploadConfig.previewFullImage"
                        :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple"
                        :maxCount="uploadConfig.maxCount" :capture="uploadConfig.capture" @afterRead="afterReadImg"
                        @delete="deletePic">
                    </u-upload>
                </view>
            </view>
            <view class="practitioner">
                <box-title title="从业人员信息"></box-title>
                <view class="info" v-for="i in personNum" :key="i">
                    <view class="title">人员信息-#{{ i }}</view>
                    <formItem ref="formItemRef"></formItem>
                </view>
 
                <view class="add-person">
                    <u-button type="success" plain @click="addPerson">在加一人</u-button>
                </view>
            </view>
        </view>
 
        <view class="btn-group">
            <view>
                <u-button type="primary" @click="submit">提交</u-button>
            </view>
            <view class="mt-20">
                <u-button @click="pushPage">我上报的事件</u-button>
            </view>
        </view>
    </view>
</template>
 
<script>
    import {
        updatePlaceExtData,
        getPlaceDetail
    } from '@/api/placeExp/placeExp.js'
    import uploadMixin from "@/mixin/uploadMixin";
    import boxTitle from "@/subPackage/workbench/components/boxTitle/index.vue"
    import formItem from '../components/formItem.vue'
    export default {
        mixins: [uploadMixin],
        components: {
            formItem,
            boxTitle
        },
        data() {
            return {
                form: {
                    id: '',
                    placeId: '',
                    localtion: '',
                    placeName: '',
                    legalPerson: '',
                    legalTel: '',
                    imageUrls: [],
                    planImageUrls: []
                },
                rules: {
                    localtion: {
                        required: true,
                        message: '请选择地址',
                        trigger: ['blur', 'change']
                    },
                    placeName: {
                        required: true,
                        message: '请填写场所名称',
                        trigger: ['blur', 'change']
                    },
                    legalPerson: {
                        required: true,
                        message: '请填写法人信息',
                        trigger: ['blur', 'change']
                    }
                },
                personNum: 1,
                curSelectSite: {},
            }
        },
        onShow() {
            this.curSelectSite = uni.getStorageSync('siteInfo')
            this.getCsDetails()
            // this.getLocation()
        },
        methods: {
            // getLocation() {
            //     uni.chooseLocation({
            //         success: (res) => {
            //             console.log(res);
            //         }
            //     })
            // },
            getCsDetails() {
                const that = this
                getPlaceDetail({
                    placeId: this.curSelectSite.id
                }).then(detailRes => {
                    const {
                        code,
                        data
                    } = detailRes
                    if (code !== 200) {
                        uni.showToast({
                            title: '数据请求失败',
                            icon: 'error'
                        })
                        return
                    }
                    const placePractitioner = data?.placePractitioner || []
                    console.log(data);
                    Object.keys(this.form).forEach(key => {
                        this.form[key] = data[key]
                        if (key === 'imageUrls' || key === 'planImageUrls') {
                            data[key] = data[key] || ''
                            this.form[key] = []
                            if (!!data[key]) {
                                data[key] = JSON.parse(data[key])
                                if (Array.isArray(data[key])) {
                                    this.form[key] = data[key]
                                } else {
                                    this.form[key].push(data[key])
                                }
                            }
                        }
                    })
 
                    that.personNum = placePractitioner.length
                    // that.$nextTick(() => {
                        console.log(placePractitioner);
                        setTimeout(() => {
                            const componetns = that.$refs.formItemRef || []
                            that.$refs.formItemRef.forEach((item, index) => {
                                item.form = placePractitioner[index]
                            })
                        }, 0)
                    // })
                })
            },
            updatePlaceExt(data) {
                data['imageUrls'] = data['imageUrls'].join('、')
                data['planImageUrls'] = data['planImageUrls'].join('、')
                updatePlaceExtData({
                    ...data
                }).then(res => {
                    const {
                        code
                    } = res
                    if (code !== 200) {
                        uni.showToast({
                            title: '提交失败',
                            icon: 'error'
                        })
                        return
                    }
                    uni.showToast({
                        title: '提交成功',
                        icon: 'success',
                        complete() {
                            setTimeout(() => {
                                uni.navigateBack()
                            }, 1500)
                        }
                    })
                })
            },
            addPerson() {
                this.personNum++
            },
            submit() {
                const placePractitioner = []
                this.$refs.formItemRef.forEach(item => {
                    item.form.placeId = this.form.placeId
                    placePractitioner.push(item.form)
                })
                this.form.placePractitioner = placePractitioner
                this.updatePlaceExt(this.form)
            },
            pushPage() {
                this.$u.func.globalNavigator('/subPackage/workbench/views/cshw')
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .container {
        width: 100%;
        height: 100vh;
 
        display: flex;
        flex-direction: column;
        background: #F9F9FA;
        color: #fff;
        font-size: 32rpx;
 
        .main-content {
            height: 0;
            flex: 1;
            overflow-y: auto;
        }
 
        .btn-group {
            padding: 20rpx;
            z-index: 999;
            background-color: #fff;
        }
 
 
        .form {
            margin-top: 20rpx;
 
            .form-item {
                background-color: #fff;
                padding: 0 20rpx;
                border-bottom: 1rpx solid #f6f6f6;
            }
 
        }
 
        .upload-img {
            background-color: #fff;
            padding: 20rpx;
            padding-bottom: 10rpx;
            margin-top: 20rpx;
        }
 
        .add-person {
            width: 30%;
            margin: 20rpx auto;
        }
 
        .practitioner {
            .info {
                margin-top: 20rpx;
 
                .title {
                    text-align: center;
                    font-size: 30rpx;
                    margin-bottom: 10rpx;
                }
            }
        }
 
    }
</style>