zlisen 4 years ago
parent
commit
11ec4d307a

+ 2
- 2
src/store/models/renting.js View File

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

+ 171
- 40
src/view/renting/edithouse/components/Form.vue View File

69
       <template #extra> ㎡ </template>
69
       <template #extra> ㎡ </template>
70
     </van-field>
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
     <van-field
115
     <van-field
95
       v-model="formData.innerAcreage"
116
       v-model="formData.innerAcreage"
282
 </template>
303
 </template>
283
 
304
 
284
 <script>
305
 <script>
285
-import { reactive, computed, watch, ref } from 'vue'
306
+import { reactive, computed, watch, ref, onMounted } from 'vue'
286
 import { Form, Field, Button } from 'vant'
307
 import { Form, Field, Button } from 'vant'
287
 import { useModel } from '@zjxpcyc/vue-tiny-store'
308
 import { useModel } from '@zjxpcyc/vue-tiny-store'
288
 import Picker from '@/components/Picker'
309
 import Picker from '@/components/Picker'
289
 import { showWarn } from '@/utils'
310
 import { showWarn } from '@/utils'
290
 import RoomType from './RoomType'
311
 import RoomType from './RoomType'
291
 import Proportion from './Proportion'
312
 import Proportion from './Proportion'
313
+import request from '@/utils/request'
292
 
314
 
293
 export default {
315
 export default {
294
   components: {
316
   components: {
303
   setup(props, { emit }) {
325
   setup(props, { emit }) {
304
     const buildingName = ref('')
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
     const formData = reactive({})
339
     const formData = reactive({})
307
     const { dicts, getDict } = useModel('dicts')
340
     const { dicts, getDict } = useModel('dicts')
308
     const { detail } = useModel('renting')
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
       return decorationDict
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
     const aspectOptions = computed(() => {
441
     const aspectOptions = computed(() => {
336
       const aspectDict = dicts.aspect || []
442
       const aspectDict = dicts.aspect || []
527
       if (!validManually()) {
633
       if (!validManually()) {
528
         return
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
       emit('submit', query, formData)
653
       emit('submit', query, formData)
537
     }
654
     }
538
 
655
 
548
       { immediate: true }
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
     return {
681
     return {
682
+      lockBuilding,
552
       mustEdit,
683
       mustEdit,
553
       buildingName,
684
       buildingName,
554
       formData,
685
       formData,
555
       handleSumbit,
686
       handleSumbit,
556
       decorationOptions,
687
       decorationOptions,
557
-      roomBuildOptions,
688
+
558
       aspectOptions,
689
       aspectOptions,
559
       sourceFromOptions,
690
       sourceFromOptions,
560
       buildTypeOptions,
691
       buildTypeOptions,

+ 1
- 3
src/view/renting/edithouse/index.vue View File

40
       { immediate: true }
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
       console.log(query, values, 'values')
44
       console.log(query, values, 'values')
47
       houseEdit(query, values)
45
       houseEdit(query, values)
48
         .then(() => {
46
         .then(() => {