Преглед на файлове

Merge branch 'master' of http://git.ycjcjy.com/ershoufang/mp-agent into master

张延森 преди 4 години
родител
ревизия
9812dfc161
променени са 3 файла, в които са добавени 174 реда и са изтрити 45 реда
  1. 2
    2
      src/store/models/renting.js
  2. 171
    40
      src/view/renting/edithouse/components/Form.vue
  3. 1
    3
      src/view/renting/edithouse/index.vue

+ 2
- 2
src/store/models/renting.js Целия файл

@@ -145,10 +145,10 @@ export default () => {
145 145
   }
146 146
 
147 147
   // 房源编辑
148
-  const houseEdit = (query, data) => {
148
+  const houseEdit = (params, data) => {
149 149
     return request({
150 150
       url: "/rent/save",
151
-      query,
151
+      params,
152 152
       data,
153 153
       toast: "请稍候...",
154 154
     })

+ 171
- 40
src/view/renting/edithouse/components/Form.vue Целия файл

@@ -69,27 +69,48 @@
69 69
       <template #extra> ㎡ </template>
70 70
     </van-field>
71 71
 
72
-    <van-field v-show="mustEdit != '1'" name="roomBuild" label="栋号" required>
73
-      <template #input>
74
-        <Picker
75
-          :options="roomBuildOptions"
76
-          v-model="formData.roomBuild"
77
-          placeholder="请选择"
78
-        />
79
-      </template>
80
-    </van-field>
81
-
82
-    <van-field
83
-      v-model="formData.acreage"
84
-      name="acreage"
85
-      label="面积"
86
-      placeholder="请输入"
87
-      required
88
-      type="number"
89
-      :rules="[{ required: true, message: '请填写面积' }]"
90
-    >
91
-      <template #extra> ㎡ </template>
92
-    </van-field>
72
+    <div v-show="mustEdit">
73
+      <van-field name="roomBuild" label="栋号" required>
74
+        <template #input>
75
+          <Picker
76
+            :options="lockBuilding.dong"
77
+            v-model="formData.roomBuild"
78
+            placeholder="请选择"
79
+          />
80
+        </template>
81
+      </van-field>
82
+
83
+      <van-field name="roomUnit" label="单元" required>
84
+        <template #input>
85
+          <Picker
86
+            :options="lockBuilding.unit"
87
+            v-model="formData.roomUnit"
88
+            placeholder="请选择"
89
+          />
90
+        </template>
91
+      </van-field>
92
+
93
+      <van-field name="roomFloor" label="楼层" required>
94
+        <template #input>
95
+          <Picker
96
+            :options="lockBuilding.floor"
97
+            v-model="formData.roomFloor"
98
+            placeholder="请选择"
99
+          />
100
+        </template>
101
+      </van-field>
102
+
103
+      <van-field name="roomNum" label="房号" required>
104
+        <template #input>
105
+          <Picker
106
+            :options="lockBuilding.room"
107
+            v-model="formData.roomNum"
108
+            placeholder="请选择"
109
+            @change="handleRoomNumChange"
110
+          />
111
+        </template>
112
+      </van-field>
113
+    </div>
93 114
 
94 115
     <van-field
95 116
       v-model="formData.innerAcreage"
@@ -282,13 +303,14 @@
282 303
 </template>
283 304
 
284 305
 <script>
285
-import { reactive, computed, watch, ref } from 'vue'
306
+import { reactive, computed, watch, ref, onMounted } from 'vue'
286 307
 import { Form, Field, Button } from 'vant'
287 308
 import { useModel } from '@zjxpcyc/vue-tiny-store'
288 309
 import Picker from '@/components/Picker'
289 310
 import { showWarn } from '@/utils'
290 311
 import RoomType from './RoomType'
291 312
 import Proportion from './Proportion'
313
+import request from '@/utils/request'
292 314
 
293 315
 export default {
294 316
   components: {
@@ -303,12 +325,106 @@ export default {
303 325
   setup(props, { emit }) {
304 326
     const buildingName = ref('')
305 327
 
328
+    const lockBuilding = reactive({
329
+      // 栋
330
+      dong: [],
331
+      // 单元
332
+      unit: [],
333
+      // 层
334
+      floor: [],
335
+      // 房
336
+      room: [],
337
+    })
338
+
306 339
     const formData = reactive({})
307 340
     const { dicts, getDict } = useModel('dicts')
308 341
     const { detail } = useModel('renting')
342
+    const mustEdit = computed(
343
+      () => detail.building?.IsLock == '1' && detail.lockRoom == null
344
+    )
345
+    watch(
346
+      () => formData.estateId,
347
+      () => {
348
+        //   // 锁盘的情况下
349
+        //   // 生成楼栋字典
350
+        if (mustEdit.value) {
351
+          request({
352
+            url: '/lock/dong',
353
+            params: { buildingId: formData.estateId },
354
+          }).then((res) => {
355
+            lockBuilding.dong = (res || []).map((x) => ({
356
+              text: x.name,
357
+              value: x.code,
358
+            }))
359
+          })
360
+        }
361
+      }
362
+    )
309 363
 
310
-    const mustEdit = computed(() =>
311
-      detail.building.IsLock == '1' && detail.lockRoom == null ? '1' : '0'
364
+    // 锁盘的情况下监控楼栋的选择
365
+    // 生成单元字典
366
+    watch(
367
+      () => formData.roomBuild,
368
+      (nw) => {
369
+        if (mustEdit.value) {
370
+          request({
371
+            url: '/lock/unit',
372
+            params: { buildingId: formData.estateId, dong: nw },
373
+          }).then((res) => {
374
+            lockBuilding.unit = (res || []).map((x) => ({
375
+              text: x.name,
376
+              value: x.code,
377
+            }))
378
+          })
379
+        }
380
+      }
381
+    )
382
+
383
+    // 锁盘的情况下监控单元的选择
384
+    // 生成楼层字典
385
+    watch(
386
+      () => formData.roomUnit,
387
+      (nw) => {
388
+        if (mustEdit.value) {
389
+          request({
390
+            url: '/lock/floor',
391
+            params: {
392
+              buildingId: formData.estateId,
393
+              dong: formData.roomBuild,
394
+              unit: nw,
395
+            },
396
+          }).then((res) => {
397
+            lockBuilding.floor = (res || []).map((x) => ({
398
+              text: x.name,
399
+              value: x.code,
400
+            }))
401
+          })
402
+        }
403
+      }
404
+    )
405
+
406
+    // // 锁盘的情况下监控楼层的选择
407
+    // // 生成楼栋-房号字典
408
+    watch(
409
+      () => formData.roomFloor,
410
+      (nw) => {
411
+        if (mustEdit.value) {
412
+          request({
413
+            url: '/lock/room',
414
+            params: {
415
+              buildingId: formData.estateId,
416
+              dong: formData.roomBuild,
417
+              unit: formData.roomUnit,
418
+              floor: nw,
419
+            },
420
+          }).then((res) => {
421
+            lockBuilding.room = (res || []).map((x) => ({
422
+              text: x.name,
423
+              value: x.code,
424
+            }))
425
+          })
426
+        }
427
+      }
312 428
     )
313 429
 
314 430
     // 装修
@@ -321,16 +437,6 @@ export default {
321 437
       return decorationDict
322 438
     })
323 439
 
324
-    // 栋号
325
-    const roomBuildOptions = computed(() => {
326
-      const roomBuildDict = dicts.roomBuild || []
327
-      if (!roomBuildDict.length) {
328
-        getDict('roomBuild')
329
-      }
330
-
331
-      return roomBuildDict
332
-    })
333
-
334 440
     // 朝向
335 441
     const aspectOptions = computed(() => {
336 442
       const aspectDict = dicts.aspect || []
@@ -527,12 +633,23 @@ export default {
527 633
       if (!validManually()) {
528 634
         return
529 635
       }
530
-      console.log(formData, 'console.log(formData)')
531
-      const query = {
532
-        lockRoomNo: detail.roomInfo?.roomNum,
533
-        leaseWaySelect: formData.leaseWay,
534
-        type: formData,
636
+      let query = {
637
+        lockRoomNo: '',
638
+
639
+        leaseWaySelect: '',
640
+        type: '',
641
+      }
642
+      // lockRoomNo: detail.formData?.roomNum,
643
+      // leaseWaySelect: formData.leaseWay,
644
+      // type: formData,
645
+      if (mustEdit.value) {
646
+        query = {
647
+          lockRoomNo: formData.roomNum,
648
+          leaseWaySelect: formData.leaseWay,
649
+          type: formData.roomNum,
650
+        }
535 651
       }
652
+
536 653
       emit('submit', query, formData)
537 654
     }
538 655
 
@@ -548,13 +665,27 @@ export default {
548 665
       { immediate: true }
549 666
     )
550 667
 
668
+    // //选择楼盘
669
+    //     const handleEstateChange = ({ id, item }) => {
670
+    //   roomInfo.estateId = id
671
+    //   roomInfo.estateName = item.buildingName
672
+    //   building.value = item
673
+    //   isLock.value = building.value.isLock - 0
674
+
675
+    // }
676
+
677
+    // onMounted(()=>{
678
+
679
+    // })
680
+
551 681
     return {
682
+      lockBuilding,
552 683
       mustEdit,
553 684
       buildingName,
554 685
       formData,
555 686
       handleSumbit,
556 687
       decorationOptions,
557
-      roomBuildOptions,
688
+
558 689
       aspectOptions,
559 690
       sourceFromOptions,
560 691
       buildTypeOptions,

+ 1
- 3
src/view/renting/edithouse/index.vue Целия файл

@@ -40,9 +40,7 @@ export default {
40 40
       { immediate: true }
41 41
     )
42 42
 
43
-    const handleSumbit = (query,values) => {
44
-      values.lockRoomNo = detail.roomInfo?.roomNum
45
-  
43
+    const handleSumbit = (query, values) => {
46 44
       console.log(query, values, 'values')
47 45
       houseEdit(query, values)
48 46
         .then(() => {