hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
<template>
    <div class="act_add">
        <v-header :title="(!$route.query.id ? '新增' : '编辑') + '房源'"></v-header>
        <el-form
            :model="form"
            :rules="rules"
            label-position="right"
            ref="ruleForm"
            label-width="150px"
            class="demo-ruleForm"
        >
            <el-form-item label="地址" required>
                <el-input
                    suffix-icon="el-icon-location-outline"
                    placeholder="请输入地址"
                    size="small"
                    class="textarea-style"
                    type="textarea"
                    resize="none"
                    :rows="4"
                    v-model="form.address"
                    maxlength="50"
                    @focus="mapCheck"
                ></el-input>
            </el-form-item>
            <div class="fl-fw">
                <el-form-item label="小区名称" prop="villageName">
                    <el-input placeholder="请输入" class="rent-form-width" v-model="form.villageName"></el-input>
                </el-form-item>
                <el-form-item label="街/路/巷" prop="alley">
                    <el-input  placeholder="请输入街/路/巷" class="rent-form-width"  v-model="form.alley"></el-input>
                </el-form-item>
            </div>
            <div class="fl-fw">
                <el-form-item label="街/路/巷号" prop="houseNum">
                    <el-input type="number" placeholder="请输入数字" class="rent-form-width" v-model="form.houseNum"></el-input>
                </el-form-item>
                <el-form-item label="楼栋号">
                    <el-input type="number" placeholder="请输入数字" class="rent-form-width" v-model="form.buildingNo"></el-input>
                </el-form-item>
            </div>
            <div class="fl-fw">
                <el-form-item label="单元号">
                    <el-input type="number" placeholder="请输入数字" class="rent-form-width" v-model="form.unitNo"></el-input>
                </el-form-item>
                <el-form-item label="楼层号">
                    <el-input type="number" placeholder="请输入数字" class="rent-form-width" v-model="form.floor"></el-input>
                </el-form-item>
            </div>
            <div class="fl-fw">
                <el-form-item label="户室号">
                    <el-input type="number" placeholder="请输入数字" class="rent-form-width" v-model="form.houseNo"></el-input>
                </el-form-item>
                <el-form-item label="看房电话" prop="seeHourseTelephone">
                    <el-input
                        placeholder="请输入"
                        class="rent-form-width"
                        v-model="form.seeHourseTelephone"
                    ></el-input>
                </el-form-item>
            </div>
            <div class="fl-fw">
                <el-form-item label="租房标题" prop="title">
                    <el-input placeholder="请输入" class="rent-form-width" v-model="form.title"></el-input>
                </el-form-item>
                <el-form-item label="房型" required>
                    <el-input maxlength="2" type="number" placeholder="几" class="num-width" v-model="form.brn"></el-input>
                    <span>室</span>
                    <el-input maxlength="2" type="number" placeholder="几" class="num-width" v-model="form.lrn"></el-input>
                    <span>厅</span>
                    <el-input maxlength="2" type="number" placeholder="几" class="num-width" v-model="form.wcn"></el-input>
                    <span>卫</span>
                </el-form-item>
            </div>
            <div class="fl-fw">
                <el-form-item label="月租金" prop="monthlyRentMoney">
                    <el-input
                        class="rent-form-width"
                        type="number" placeholder="请输入数字"
                        v-model="form.monthlyRentMoney"
                    ></el-input>
                </el-form-item>
                <el-form-item label="保证金" prop='depositMoney'>
                    <el-input
                        class="rent-form-width"
                        type="number" placeholder="请输入数字"
                        v-model="form.depositMoney"
                    ></el-input>
                </el-form-item>
            </div>
            <div class="fl-fw">
                <el-form-item label="服务费" prop="serverCharge">
                    <el-input
                        class="rent-form-width"
                        type="number" placeholder="请输入数字"
                        v-model="form.serverCharge"
                    >
                        <i slot="suffix">元</i>
                    </el-input>
                </el-form-item>
                <el-form-item label="定金" prop="dingMoney">
                    <el-input
                         type="number" placeholder="请输入数字"
                        class="rent-form-width"
                        v-model="form.dingMoney"
                    >
                        <i slot="suffix">元/7天</i>
                    </el-input>
                </el-form-item>
            </div>
            <div class="fl-fw">
                <el-form-item label="面积">
                    <el-input
                        onkeyup="value=value.replace(/[^\d.]/g,'')" placeholder="请输入数字"
                        class="rent-form-width"
                        v-model.trim="form.constructArea"
                    >
                        <i slot="suffix">㎡</i>
                    </el-input>
                </el-form-item>
                <el-form-item label="总楼层数" prop="totalFloor">
                    <el-input  type="number" placeholder="请输入数字" class="rent-form-width" v-model="form.totalFloor"></el-input>
                </el-form-item>
            </div>
            <div class="fl-fw">
                <el-form-item label="朝向">
                    <el-select
                        v-model="form.orientation"
                        class="rent-form-width"
                        filterable
                        clearable
                        placeholder="请选择朝向"
                    >
                        <el-option
                            v-for="item in cxType"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="装修" prop="decoration">
                    <el-select
                        v-model="form.decoration"
                        class="rent-form-width"
                        filterable
                        clearable
                        placeholder="请选择装修情况"
                    >
                        <el-option
                            v-for="item in zxType"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        ></el-option>
                    </el-select>
                </el-form-item>
            </div>
            <div class="fl-fw">
                <el-form-item label="看房时间">
                    <div class="rent-form-width">
                        <el-radio-group v-model="form.seeHourseDate" size="medium">
                            <el-radio-button :label="1">随时看房</el-radio-button>
                            <el-radio-button :label="2">提前预约</el-radio-button>
                        </el-radio-group>
                    </div>
                </el-form-item>
                <!-- <el-form-item label="预约时间">
                    <el-date-picker
                        format="yyyy-MM-dd HH:mm"
                        value-format="yyyy-MM-dd HH:mm"
                        v-model="form.name"
                        class="rent-form-width"
                        type="datetime"
                        placeholder="选择预约时间"
                    ></el-date-picker>
                </el-form-item> -->
            </div>
 
            <el-form-item label="房源介绍">
                <el-input
                    placeholder="请输入房源介绍"
                    class="textarea-style"
                    type="textarea"
                    resize="none"
                    :rows="4"
                    v-model="form.hourseDescription"
                    maxlength="300"
                ></el-input>
            </el-form-item>
            <el-form-item label="入住要求">
                <el-input
                    placeholder="请输入入住要求"
                    class="textarea-style"
                    type="textarea"
                    resize="none"
                    :rows="4"
                    v-model="form.checkInRequirement"
                    maxlength="300"
                ></el-input>
            </el-form-item>
            <el-form-item label="房内物品">
                <el-button size="mini" @click="addInput()">新增</el-button>
                <div v-for="(item,index) in hourseItemList" :key="index" class="mr-t-10">
                    <el-input placeholder="请输入物品名" class="thing-name" v-model="item.name"></el-input>
                    <el-input placeholder="数量" class="num-width2" v-model="item.number"></el-input>
                    <el-button size="mini" class="mr-l-20" type="text" @click="deleteInput(index)">删除</el-button>
                </div>
            </el-form-item>
            <el-form-item label="房源标签">
                <!-- <el-input placeholder="请输入" class="rent-form-width" v-model="form.label"></el-input> -->
                <el-checkbox-group v-model="labelTag" size="small">
                     <el-checkbox v-for="label in tagList" :label="label" :key="label">{{label}}</el-checkbox>
                </el-checkbox-group>
            </el-form-item>
            <el-form-item label="房源图片">
                <UploadImg :imgShow="houseSrc" @fileHandle="fileHandle" />
            </el-form-item>
            <h4>认证信息</h4>
            <el-form-item label="产权证明" required="">
                <UploadImg :imgShow="propertySrc" @fileHandle="fileHandle1" />
            </el-form-item>
            <el-form-item label="房主姓名" prop="hourseOwnerName">
                <el-input placeholder="请输入" class="rent-form-width" v-model="form.hourseOwnerName"></el-input>
            </el-form-item>
            <el-form-item label="身份证号" prop="hourseIdCard">
                <el-input
                    placeholder="请输入"
                    maxlength="18"
                    class="rent-form-width"
                    v-model="form.hourseIdCard"
                ></el-input>
            </el-form-item>
            <el-form-item label="房主电话" prop="hoursePhone">
                <el-input
                    placeholder="请输入"
                    maxlength="11"
                    class="rent-form-width"
                    v-model="form.hoursePhone"
                ></el-input>
            </el-form-item>
            <el-form-item label="证件照片" required>
                <UploadImg :imgShow="credentials" @fileHandle="fileHandle2" />
            </el-form-item>
            <el-form-item label>
                <el-button size="small" :loading="btnLoading" type="primary" @click="send(1, 'form')">提交</el-button>
                <el-button size="small" @click="$router.go(-1)">取消</el-button>
            </el-form-item>
        </el-form>
        <!-- 地图弹框 -->
        <el-dialog
            title="房源地址"
            :visible.sync="dialogVisibleMap"
            :before-close="handleCloseMap"
            append-to-body
        >
            <MapBox ref="mapContent" @setLocation="setLocation" />
            <div style="text-align: center; margin-top: 20px">
                <el-button @click="handleCloseMap">取 消</el-button>
                <el-button type="primary" @click="mapComfirm">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>
 
<script>
import {isvalidPhone,isIdcard} from '../../../assets/js/fromValidate';
import { objCopyPro } from "../../../utils/common";
import MapBox from "com/map/map.vue";
import UploadImg from 'com/upload/uploadImg.vue'
import { zxType2, cxType2 } from '../../../utils/keys';
 var validPhone=(rule, value,callback)=>{
    if (!value){
      callback(new Error('请输入电话号码'))
    }else  if (!isvalidPhone(value)){
      callback(new Error('请输入正确的11位手机号码'))
    }else {
      callback()
    }
 }
  var validIdcrad=(rule, value,callback)=>{
    if (!value){
        callback(new Error('请输入身份证号码'))
    }else  if (!isIdcard(value)){
      callback(new Error('请输入正确的身份证号码'))
    }else {
        callback()
    }
 }
export default {
    components: {
        MapBox,
        UploadImg
    },
    data() {
        return {
            labelTag:[],
            btnLoading: false,
            zxType: zxType2(), // 装修情况
            cxType: cxType2(), // 朝向
            dialogVisibleMap: false,
            mapObj: {},
            form: {
                authStatus:1,
                id:'',
                address: '',
                latitude:'',
                longitude:'',
                orientation:'',
                villageName:'',
                alley:'',
                seeHourseTelephone:'',
                houseNum:'',
                buildingNo:'',
                unitNo:'',
                floor:'',
                houseNo:'',
                title:'',
                brn:'',
                lrn:'',
                wcn:'',
                monthlyRentMoney:'',
                depositMoney:'',
                serverCharge:'',
                dingMoney:'',
                constructArea:'',
                totalFloor:'',
                decoration:'',
                seeHourseDate:'1',
                hourseDescription:'',
                checkInRequirement:'',
                hourseItem:'',
                label:'',
                housePictures:[],
                propertyPictures:[],
                hourseOwnerName:'',
                hourseIdCard:'',
                hoursePhone:'',
                credentialsPictures:[],
 
            },
            hourseItemList:[{
                    name:'',
                    number:''
                }],
            houseSrc:'',
            propertySrc:'',
            credentials:'',
            rules: {
                hourseOwnerName: [
                    {
                        required: true,
                        message: "请输入房主姓名",
                        trigger: "blur",
                    },
                ],
                hourseIdCard: [
                    {
                        required: true,
                        trigger: "blur",
                        validator:validIdcrad
                    },
                ],
                hoursePhone: [
                    {
                        required: true,
                        trigger: "blur",
                        validator: validPhone,
                    },
                ],
                decoration: [
                    {
                        required: true,
                        message: "请选择装修情况",
                        trigger: "change",
                    },
                ],
                totalFloor: [
                    {
                        required: true,
                        message: "请输入总楼层数",
                        trigger: "blur",
                    },
                ],
                dingMoney: [
                    {
                        required: true,
                        message: "请输入定金",
                        trigger: "blur",
                    },
                ],
                monthlyRentMoney: [
                    {
                        required: true,
                        message: "请输入月租金",
                        trigger: "blur",
                    },
                ],
                depositMoney: [
                    {
                        required: true,
                        message: "请输入保证金",
                        trigger: "blur",
                    },
                ],
                serverCharge: [
                    {
                        required: true,
                        message: "请输入服务费",
                        trigger: "blur",
                    },
                ],
                title: [
                    {
                        required: true,
                        message: "请输入租房标题",
                        trigger: "blur",
                    },
                ],
                villageName: [
                    {
                        required: true,
                        message: "请输入小区名称",
                        trigger: "blur",
                    },
                ],
                alley: [
                    {
                        required: true,
                        message: "请输入街/路/巷",
                        trigger: "blur",
                    },
                ],
                houseNum: [
                    {
                        required: true,
                        message: "请输入街/路/巷号",
                        trigger: "blur",
                    },
                ],
                seeHourseTelephone :[
                    {
                        required: true,
                        validator: validPhone,
                        trigger: "blur",
                    },
                ],
            },
            positionData: {},
            tagList:[],
        };
    },
    methods: {
        getTags() {
          this.$api.get("renting/houses/getConfig", {type:6}, (e) => {
              this.tagList = e.value.split(",");
              console.log(this.tagList)
          });
        },
        addInput() {
            this.hourseItemList.push({
                name:'',
                number:''
            })
        },
        deleteInput(index) {
            this.hourseItemList.splice(index, 1)
        },
        fileHandle(data) {
            if (data.type === 'loading') {
                this.btnLoading = data.val
            } else {
                this.houseSrc= data.val
                this.btnLoading = false
            }
        },
        fileHandle1(data) {
            if (data.type === 'loading') {
                this.btnLoading = data.val
            } else {
                this.propertySrc= data.val
                this.btnLoading = false
            }
        },
        fileHandle2(data) {
            if (data.type === 'loading') {
                this.btnLoading = data.val
            } else {
                this.credentials= data.val
                this.btnLoading = false
            }
        },
        mapCheck() {
            this.dialogVisibleMap = true;
            this.$nextTick(() => {
                this.$refs.mapContent.getLocation({});
                this.$refs.mapContent.getLocation({
                    val: this.form.address,
                    l: this.form.latitude,
                    r: this.form.longitude,
                });
            });
        },
        handleCloseMap() {
            this.dialogVisibleMap = false;
             this.positionData = {};
        },
        mapComfirm() {
            if (this.positionData.addr) {
                this.form.address = this.positionData.addr;
                this.form.latitude = this.positionData.lat;
                this.form.longitude = this.positionData.lng;
            }
            this.dialogVisibleMap = false;
            this.positionData = {};
        },
        setLocation(obj) {
          this.positionData = obj;
        },
        // 获取数据-编辑
        getData(id) {
            this.$api.get("renting/houses/get", {registerId:id}, (e) => {
                this.form = objCopyPro(this.form, e);
                this.houseSrc =  this.form.housePictures ? this.form.housePictures.join(",") : '';
                this.propertySrc =  this.form.propertyPictures ? this.form.propertyPictures.join(",") : '';
                this.credentials =  this.form.credentialsPictures ? this.form.credentialsPictures.join(",") : '';
                this.hourseItemList = JSON.parse(this.form.hourseItem);
                // this.tagList = this.form.label.split(",");
                this.labelTag = this.form.label.split(",");
 
            });
        },
        // 保存
        send(v, f) {
            this.$refs["ruleForm"].validate((valid) => {
                if(this.form.address == '') {
                    return this.$message('地址不能为空')
                }
                if(this.form.brn == '' || this.form.lrn == '' || this.form.wcn == '') {
                    return this.$message('房型不能为空')
                }
                if(this.propertySrc == '') {
                    return this.$message('产权证明不能为空')
                }
                if(this.credentials == '') {
                    return this.$message('证件照片不能为空')
                }
                if(+this.form.monthlyRentMoney < +this.form.dingMoney) {
                    return this.$message('定金不能超过月租金')
                }
                this.form.housePictures = this.houseSrc.split(",");
                this.form.propertyPictures = this.propertySrc.split(",");
                this.form.credentialsPictures = this.credentials.split(",");
                if(this.labelTag.length) {
                 this.form.label = this.labelTag.join(",");
                }
 
                if (valid) {
                       this.form.hourseItem = JSON.stringify(this.hourseItemList)
                    if (!this.$route.query.id) {
                        this.$api.post("renting/houses/register", this.form, (e) => {
                            demo.toast("新增成功");
                            this.$nextTick(() => {
                                this.$router.go(-1);
                            });
                        });
                    } else {
                        this.form.id = this.$route.query.id;
                        this.$api.post("renting/houses/update", this.form, (e) => {
                            demo.toast("编辑成功");
                            this.$nextTick(() => {
                                this.$router.go(-1);
                            });
                        });
                    }
                }
            });
        },
    },
    mounted() {
        if (this.$route.query.id) {
            this.getData(this.$route.query.id);
        }
        this.getTags()
 
    },
};
</script>
<style >
input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{-webkit-appearance: none !important;}
input[type="number"]{-moz-appearance:textfield;}
</style>
<style lang='less' scoped>
.act_add {
    overflow-y: auto;
    .edit {
        margin-bottom: 10px;
        padding: 0 40px;
    }
    .sec:last-child {
        margin-bottom: 0;
    }
    .up {
        margin-top: 8px;
    }
    .sec {
        .label {
            width: 120px;
        }
        article {
            width: calc(~"100% - 120px");
            max-width: 300px;
            &.more {
                max-width: 100%;
            }
            .label {
                text-align: left;
            }
            .item {
                display: flex;
                flex-wrap: wrap;
                article {
                    margin: 0 10px 10px 0;
                    width: 140px;
                    box-sizing: border-box;
                    padding: 5px 20px 5px 0;
                    text-align: center;
                    .avatar {
                        margin: 0 auto 5px;
                    }
                    .el-input {
                        margin-bottom: 5px;
                    }
                }
                .btn {
                    display: flex;
                    justify-content: space-between;
                    width: 120px;
                    .add,
                    .del {
                        width: 40px;
                        height: 40px;
                        line-height: 40px;
                        text-align: center;
                        font-size: 28px;
                        font-weight: 700;
                        display: block;
                        border-radius: 50%;
                        border: 1px solid #ccc;
                        color: #666;
                        cursor: pointer;
                    }
                }
            }
        }
    }
}
.update-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 260px;
    height: 154px;
    border: 1px dashed #999;
}
.fz-15 {
    font-size: 30px;
}
.img-shwo-item {
    cursor: pointer;
    width: 260px;
    height: 154px;
}
.img-list-item {
    margin-bottom: 10px;
    width: 260px;
    height: 154px;
    position: relative;
    border: 1px dashed #fff;
}
.check-img {
    cursor: pointer;
    z-index: 999;
    position: absolute;
    right: 0;
    top: 0;
    width: 20px;
    height: 20px;
}
.fl-f {
    display: flex;
}
.fl-fw {
    display: flex;
    flex-wrap: wrap;
}
.mr-r-10 {
    margin-right: 10px;
}
.cropper-content .cropper {
    width: auto;
    height: 500px !important;
}
.fl-al {
    display: flex;
    align-items: center;
}
.el-dialog {
    width: 800px !important;
}
.input-width {
    width: 300px;
}
.input-width2 {
    width: 200px;
}
.class-label-box {
    margin-right: 10px;
    cursor: pointer;
    padding: 12px;
    border: 1px solid #333;
    line-height: 1 !important;
}
.check-box {
    border: 1px solid rgb(23, 116, 192) !important;
    color: rgb(23, 116, 192);
}
.textarea-style {
    width: 400px;
}
.rent-form-width {
    width: 200px;
}
.num-width {
    width: 50px;
}
.num-width2 {
    width: 70px;
}
.thing-name {
    width: 150px;
}
</style>