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
<template>
    <view class="">
 
        <u-form labelPosition="left" :model="info" :rules="rules" ref="form" labelWidth="100"
            :labelStyle="{fontSize:'28rpx'}">
            <view class="content">
                <u-form-item label="对象电话" prop="transactionObjectTel" borderBottom required>
                    <u-input v-model="info.transactionObjectTel" border="none" placeholder="请输入"
                        placeholderClass="f-28 c-99" inputAlign="right"></u-input>
                </u-form-item>
                <u-form-item label="交易金额" prop="transactionMoney" borderBottom required>
                    <u-input v-model="info.transactionMoney" border="none" placeholder="请输入"
                        placeholderClass="f-28 c-99" inputAlign="right"></u-input>
                </u-form-item>
                <u-form-item label="物品数量" prop="goodsNums" borderBottom required>
                    <u-input v-model="info.goodsNums" type="number" border="none" placeholder="请输入"
                        placeholderClass="f-28 c-99" inputAlign="right"></u-input>
                </u-form-item>
                <u-form-item label="交易位置" prop="location" borderBottom ref="location" required>
                    <u-input v-model="info.location" border="none" placeholder="请输入" placeholderClass="f-28 c-99"
                        inputAlign="right"></u-input>
                </u-form-item>
                <u-form-item label="交易过程" prop="transactionProcess" borderBottom>
                    <u-input v-model="info.transactionProcess" border="none" placeholder="请输入"
                        placeholderClass="f-28 c-99" inputAlign="right"></u-input>
                </u-form-item>
            </view>
 
            <view class="upload bgc-ff">
                <view class="f-28 mb-20">手持身份证</view>
                <view class="mt-20">
                    <u-upload :fileList="imageUrls" :previewFullImage="uploadConfig.previewFullImage"
                        :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple"
                        :maxCount="uploadConfig.maxCount" :capture="uploadConfig.capture"
                        @afterRead="afterReadImgs($event,'imageUrls')" @delete="deletePic">
                        <view class="upload-item upload-icon flex_base">
                            <u-icon name="/static/icon/upload.png" width="60rpx" height="60rpx"></u-icon>
                        </view>
                    </u-upload>
                </view>
            </view>
            <view class="upload bgc-ff">
                <view class="f-28 mb-20">物品照片</view>
                <view class="mt-20">
                    <u-upload :fileList="goodsImageUrls" :previewFullImage="uploadConfig.previewFullImage"
                        :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple"
                        :maxCount="uploadConfig.maxCount" :capture="uploadConfig.capture"
                        @afterRead="afterReadImgs($event,'goodsImageUrls')" @delete="deletePic">
                        <view class="upload-item upload-icon flex_base">
                            <u-icon name="/static/icon/upload.png" width="60rpx" height="60rpx"></u-icon>
                        </view>
                    </u-upload>
                </view>
            </view>
 
        </u-form>
 
        <button class="submit-btn" @click="sumitInfo">提交</button>
        <button class="list-btn" @click="navigatorPage">我上报的事件</button>
    </view>
</template>
 
 
<script>
    import uploadMixin from "@/mixin/uploadMixin";
    import {
        saveLabelReporting
    } from "@/api/reporting/reporting";
    export default {
        mixins: [uploadMixin],
        data() {
            return {
                info: {
                    transactionObjectTel: "",
                    transactionMoney: "",
                    goodsNums: "",
                    location: "",
                    transactionProcess: "",
                    houseCode: "",
                    districtName: "",
                    userId: ""
                },
                rules: {
                    'transactionObjectTel': {
                        type: 'string',
                        required: true,
                        message: '请输入对象电话',
                        trigger: ['blur', 'change']
                    },
 
                    'transactionMoney': {
                        type: 'string',
                        required: true,
                        message: '请输入交易金额',
                        trigger: ['blur', 'change']
                    },
                    'location': {
                        type: 'string',
                        required: true,
                        message: '请输入交易位置',
                        trigger: ['blur', 'change']
                    },
                    'transactionProcess': {
                        type: 'string',
                        required: false,
                        message: '请输入交易过程',
                        trigger: ['blur', 'change']
                    }
                },
                imageUrls: [],
                goodsImageUrls: [],
                eventType:1
            }
        },
        onLoad(option) {
            if (option.type != 1) {
                this.eventType = option.type;
                uni.setNavigationBarTitle({
                    title: this.setTitle(option.type)
                })
            }
            this.$set(this.info, "eventType", option.type);
            let siteInfo = uni.getStorageSync("siteInfo");
            let userInfo = uni.getStorageSync("userInfo");
            this.$set(this.info, "houseCode", siteInfo.id);
            this.$set(this.info, "districtName", siteInfo.name);
            this.$set(this.info, "userId", userInfo.user_id);
        },
        methods: {
            setTitle(type) {
                if (type == 2) {
                    return "二手手机维修"
                } else if (type == 3) {
                    return "二手车交易"
                }
            },
 
            confirmDate(e) {
                console.log(e);
                this.showSelectDate = false;
                this.info.checkTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM')
            },
 
            async afterReadImgs(event, key) {
                this.showLoading()
                let lists = [].concat(event.file)
                let fileListLen = this[key].length
                lists.map((item) => {
                    this[key].push({
                        ...item,
                        status: 'uploading',
                        message: '上传中'
                    })
                })
                for (let i = 0; i < lists.length; i++) {
                    const result = await this.uploadFilePromise(lists[i].url)
                    this[key].splice(fileListLen, 1, Object.assign({}, {
                        url: result.data.link,
                        name: result.data.name
                    }))
                    fileListLen++
                }
                this.loadingClose()
            },
 
            checkImages() {
                if (this.imageUrls.length) {
                    this.$set(this.info, "imageUrls", this.setImages(this.imageUrls))
                }
                if (this.goodsImageUrls.length) {
                    this.$set(this.info, "goodsImageUrls", this.setImages(this.goodsImageUrls))
                }
 
            },
 
            setImages(key) {
                let urls = [];
                for (let i of key) {
                    urls.push(i.url);
                }
                return urls.join(",")
            },
 
            sumitInfo() {
                this.$refs.form.validate().then(valid => {
                    this.checkImages()
                    saveLabelReporting(this.info).then(res => {
                        uni.showToast({
                            icon: 'success',
                            title: '提交成功',
                            success() {
                                setTimeout(() => {
                                    uni.navigateBack()
                                    // this.$u.func.globalNavigator("", "navBack")
                                }, 1000)
                            }
                        })
                    })
                })
            },
            navigatorPage() {
                this.$u.func.globalNavigator(`formList?type=${this.eventType}`, "navTo")
            }
        }
    }
</script>
 
<style lang="less">
    page {
        background-color: #F5F5F5;
    }
 
    .content {
        margin: 20rpx 30rpx;
        padding: 0 30rpx;
        background-color: #fff;
    }
 
    /deep/.u-radio-group--row {
        justify-content: flex-end;
    }
 
    .site-box {
        padding: 30rpx;
        margin: 20rpx 30rpx;
        border-radius: 4rpx;
 
        .c-aa {
            color: #aaa;
        }
 
        .address {
            width: 60%;
            margin-left: 25rpx;
        }
    }
 
    .upload-item {
        width: 140rpx;
        height: 140rpx;
        border: 1px solid #EEEEEE;
    }
 
    .upload {
        margin: 0 30rpx 20rpx;
        padding: 30rpx;
 
 
    }
 
    .submit-btn {
        width: 690rpx;
        height: 78rpx;
        line-height: 78rpx;
        background: linear-gradient(163deg, #01BDFC 0%, #017BFC 100%);
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        font-size: 32rpx;
        color: #fff;
        margin-top: 50rpx;
    }
 
    .list-btn {
        width: 690rpx;
        height: 78rpx;
        line-height: 78rpx;
        background: linear-gradient(163deg, #c7d7dc 0%, #c3cdd8 100%);
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        font-size: 32rpx;
        color: #fff;
        margin-top: 50rpx;
    }
</style>