张延森 4 年前
父节点
当前提交
1f5e2ad8ff
共有 5 个文件被更改,包括 368 次插入178 次删除
  1. 8
    6
      src/components/Picker/index.vue
  2. 63
    63
      src/store/models/dicts.js
  3. 51
    40
      src/store/models/room.js
  4. 5
    5
      src/utils/index.js
  5. 241
    64
      src/view/addhouse/addsecondhand/index.vue

+ 8
- 6
src/components/Picker/index.vue 查看文件

20
 </template>
20
 </template>
21
 
21
 
22
 <script>
22
 <script>
23
-import { Popup, Picker, Loading } from "vant"
24
-import { computed, ref, toRaw, unref } from "vue"
25
-import { isEmpty } from "@/utils"
23
+import { Popup, Picker, Loading } from 'vant'
24
+import { computed, ref, toRaw, unref } from 'vue'
25
+import { isEmpty } from '@/utils'
26
 
26
 
27
 export default {
27
 export default {
28
   components: {
28
   components: {
38
     placeholder: String,
38
     placeholder: String,
39
     modelValue: undefined,
39
     modelValue: undefined,
40
   },
40
   },
41
-  emits: ["update:modelValue"],
41
+  emits: ['update:modelValue', 'change'],
42
   setup(props, { emit }) {
42
   setup(props, { emit }) {
43
     const showPopup = ref(false)
43
     const showPopup = ref(false)
44
 
44
 
70
     })
70
     })
71
 
71
 
72
     const onConfirm = (value, index) => {
72
     const onConfirm = (value, index) => {
73
-      const val = ((props.options || [])[index] || {}).value
74
-      emit("update:modelValue", val)
73
+      const item = (props.options || [])[index]
74
+      const val = (item || {}).value
75
+      emit('update:modelValue', val)
76
+      emit('change', item)
75
       showPopup.value = false
77
       showPopup.value = false
76
     }
78
     }
77
 
79
 

+ 63
- 63
src/store/models/dicts.js 查看文件

1
-import { reactive, computed } from "vue"
2
-import request from "../../utils/request"
1
+import { reactive, computed } from 'vue'
2
+import request from '../../utils/request'
3
 
3
 
4
 // 户型
4
 // 户型
5
 const roomType = [
5
 const roomType = [
6
   {
6
   {
7
-    text: "一室",
8
-    value: "1",
7
+    text: '一室',
8
+    value: '1',
9
   },
9
   },
10
   {
10
   {
11
-    text: "两室",
12
-    value: "2",
11
+    text: '两室',
12
+    value: '2',
13
   },
13
   },
14
   {
14
   {
15
-    text: "三室",
16
-    value: "3",
15
+    text: '三室',
16
+    value: '3',
17
   },
17
   },
18
   {
18
   {
19
-    text: "三室以上",
20
-    value: "4",
19
+    text: '三室以上',
20
+    value: '4',
21
   },
21
   },
22
 ]
22
 ]
23
 
23
 
24
 // 实勘状态
24
 // 实勘状态
25
 const rescStatus = [
25
 const rescStatus = [
26
   {
26
   {
27
-    text: "已实勘",
28
-    value: "0",
27
+    text: '已实勘',
28
+    value: '0',
29
   },
29
   },
30
   {
30
   {
31
-    text: "待审核",
32
-    value: "1",
31
+    text: '待审核',
32
+    value: '1',
33
   },
33
   },
34
   {
34
   {
35
-    text: "未实勘",
36
-    value: "9",
35
+    text: '未实勘',
36
+    value: '9',
37
   },
37
   },
38
 ]
38
 ]
39
 
39
 
40
 // 钥匙状态
40
 // 钥匙状态
41
 const keyStatus = [
41
 const keyStatus = [
42
   {
42
   {
43
-    text: "有钥匙",
44
-    value: "0",
43
+    text: '有钥匙',
44
+    value: '0',
45
   },
45
   },
46
   {
46
   {
47
-    text: "待审核",
48
-    value: "1",
47
+    text: '待审核',
48
+    value: '1',
49
   },
49
   },
50
   {
50
   {
51
-    text: "无钥匙",
52
-    value: "9",
51
+    text: '无钥匙',
52
+    value: '9',
53
   },
53
   },
54
 ]
54
 ]
55
 
55
 
56
 // 业主委托
56
 // 业主委托
57
 const authStatus = [
57
 const authStatus = [
58
   {
58
   {
59
-    text: "有委托",
60
-    value: "0",
59
+    text: '有委托',
60
+    value: '0',
61
   },
61
   },
62
   {
62
   {
63
-    text: "待审核",
64
-    value: "1",
63
+    text: '待审核',
64
+    value: '1',
65
   },
65
   },
66
   {
66
   {
67
-    text: "无委托",
68
-    value: "9",
67
+    text: '无委托',
68
+    value: '9',
69
   },
69
   },
70
 ]
70
 ]
71
 
71
 
72
 // 电梯
72
 // 电梯
73
 const elevator = [
73
 const elevator = [
74
   {
74
   {
75
-    text: "有",
76
-    value: "0",
75
+    text: '有',
76
+    value: '0',
77
   },
77
   },
78
   {
78
   {
79
-    text: "无",
80
-    value: "1",
79
+    text: '无',
80
+    value: '1',
81
   },
81
   },
82
 ]
82
 ]
83
 
83
 
84
 // 带看
84
 // 带看
85
 const lookTimes = [
85
 const lookTimes = [
86
   {
86
   {
87
-    text: "有",
88
-    value: "1",
87
+    text: '有',
88
+    value: '1',
89
   },
89
   },
90
   {
90
   {
91
-    text: "无",
92
-    value: "0",
91
+    text: '无',
92
+    value: '0',
93
   },
93
   },
94
 ]
94
 ]
95
 
95
 
96
 // 锁盘
96
 // 锁盘
97
 const lockRoom = [
97
 const lockRoom = [
98
   {
98
   {
99
-    text: "未锁盘",
100
-    value: "0",
99
+    text: '未锁盘',
100
+    value: '0',
101
   },
101
   },
102
   {
102
   {
103
-    text: "锁盘已关联",
104
-    value: "1",
103
+    text: '锁盘已关联',
104
+    value: '1',
105
   },
105
   },
106
   {
106
   {
107
-    text: "锁盘未关联",
108
-    value: "2",
107
+    text: '锁盘未关联',
108
+    value: '2',
109
   },
109
   },
110
 ]
110
 ]
111
 
111
 
112
 //租房类型
112
 //租房类型
113
 const leaseWay = [
113
 const leaseWay = [
114
   {
114
   {
115
-    text: "整租",
116
-    value: "0",
115
+    text: '整租',
116
+    value: '0',
117
   },
117
   },
118
   {
118
   {
119
-    text: "合租",
120
-    value: "1",
119
+    text: '合租',
120
+    value: '1',
121
   },
121
   },
122
 ]
122
 ]
123
 
123
 
135
 
135
 
136
   const getDict = (key) => {
136
   const getDict = (key) => {
137
     request({
137
     request({
138
-      url: "/comm/dict",
138
+      url: '/comm/dict',
139
       params: { groupCode: key },
139
       params: { groupCode: key },
140
     }).then((res) => {
140
     }).then((res) => {
141
       dicts[key] = (res || []).map((x) => ({ text: x.name, value: x.code }))
141
       dicts[key] = (res || []).map((x) => ({ text: x.name, value: x.code }))
145
   //
145
   //
146
   const getBusinessCity = (areaType, pcode) => {
146
   const getBusinessCity = (areaType, pcode) => {
147
     if (1 === areaType) {
147
     if (1 === areaType) {
148
-      pcode = "025"
148
+      pcode = '025'
149
     }
149
     }
150
 
150
 
151
     request({
151
     request({
152
-      url: "/comm/dict/business-city",
152
+      url: '/comm/dict/business-city',
153
       params: { areaType, pcode },
153
       params: { areaType, pcode },
154
     }).then((res) => {
154
     }).then((res) => {
155
       if (1 === areaType) {
155
       if (1 === areaType) {
156
         // 区县
156
         // 区县
157
-        dicts["roomDistrict"] = res
157
+        dicts['roomDistrict'] = res
158
       } else {
158
       } else {
159
         // 商圈
159
         // 商圈
160
-        dicts["roomBussines"] = res
160
+        dicts['roomBussines'] = res
161
       }
161
       }
162
     })
162
     })
163
   }
163
   }
164
 
164
 
165
   const getBuilding = ({ buildingName, pageNo = 1, pageSize = 20 }) => {
165
   const getBuilding = ({ buildingName, pageNo = 1, pageSize = 20 }) => {
166
     return request({
166
     return request({
167
-      url: "/comm/dict/building-list",
167
+      url: '/comm/dict/building-list',
168
       params: { buildingName, pageNo, pageSize },
168
       params: { buildingName, pageNo, pageSize },
169
     }).then((res) => {
169
     }).then((res) => {
170
       if (res.result && res.result.length && !buildingName && pageNo === 1) {
170
       if (res.result && res.result.length && !buildingName && pageNo === 1) {
171
         // 只缓存第一页的
171
         // 只缓存第一页的
172
-        dicts["building"] = res.result
172
+        dicts['building'] = res.result
173
       }
173
       }
174
 
174
 
175
       return res
175
       return res
180
   const decorationOptions = computed(() => {
180
   const decorationOptions = computed(() => {
181
     const decorationDict = dicts.decoration || []
181
     const decorationDict = dicts.decoration || []
182
     if (!decorationDict.length) {
182
     if (!decorationDict.length) {
183
-      getDict("decoration")
183
+      getDict('decoration')
184
     }
184
     }
185
 
185
 
186
     return decorationDict
186
     return decorationDict
190
   const aspectOptions = computed(() => {
190
   const aspectOptions = computed(() => {
191
     const aspectDict = dicts.aspect || []
191
     const aspectDict = dicts.aspect || []
192
     if (!aspectDict.length) {
192
     if (!aspectDict.length) {
193
-      getDict("aspect")
193
+      getDict('aspect')
194
     }
194
     }
195
 
195
 
196
     return aspectDict
196
     return aspectDict
200
   const sourceFromOptions = computed(() => {
200
   const sourceFromOptions = computed(() => {
201
     const sourceFromDict = dicts.sourceFrom || []
201
     const sourceFromDict = dicts.sourceFrom || []
202
     if (!sourceFromDict.length) {
202
     if (!sourceFromDict.length) {
203
-      getDict("sourceFrom")
203
+      getDict('sourceFrom')
204
     }
204
     }
205
 
205
 
206
     return sourceFromDict
206
     return sourceFromDict
208
 
208
 
209
   // 建筑类型
209
   // 建筑类型
210
   const buildTypeOptions = computed(() => {
210
   const buildTypeOptions = computed(() => {
211
-    const buildTypeDict = dicts["build_type"] || []
211
+    const buildTypeDict = dicts['build_type'] || []
212
     if (!buildTypeDict.length) {
212
     if (!buildTypeDict.length) {
213
-      getDict("build_type")
213
+      getDict('build_type')
214
     }
214
     }
215
 
215
 
216
     return buildTypeDict
216
     return buildTypeDict
223
   const natureOptions = computed(() => {
223
   const natureOptions = computed(() => {
224
     const natureDict = dicts.nature || []
224
     const natureDict = dicts.nature || []
225
     if (!natureDict.length) {
225
     if (!natureDict.length) {
226
-      getDict("nature")
226
+      getDict('nature')
227
     }
227
     }
228
 
228
 
229
     return natureDict
229
     return natureDict
233
   const purposeOptions = computed(() => {
233
   const purposeOptions = computed(() => {
234
     const purposeDict = dicts.purpose || []
234
     const purposeDict = dicts.purpose || []
235
     if (!purposeDict.length) {
235
     if (!purposeDict.length) {
236
-      getDict("purpose")
236
+      getDict('purpose')
237
     }
237
     }
238
 
238
 
239
     return purposeDict
239
     return purposeDict
243
   const mortgageOptions = computed(() => {
243
   const mortgageOptions = computed(() => {
244
     const mortgageDict = dicts.mortgage || []
244
     const mortgageDict = dicts.mortgage || []
245
     if (!mortgageDict.length) {
245
     if (!mortgageDict.length) {
246
-      getDict("mortgage")
246
+      getDict('mortgage')
247
     }
247
     }
248
 
248
 
249
     return mortgageDict
249
     return mortgageDict
251
 
251
 
252
   // 税费
252
   // 税费
253
   const buildTimeOptions = computed(() => {
253
   const buildTimeOptions = computed(() => {
254
-    const buildTimeDict = dicts["build_time"] || []
254
+    const buildTimeDict = dicts['build_time'] || []
255
     if (!buildTimeDict.length) {
255
     if (!buildTimeDict.length) {
256
-      getDict("build_time")
256
+      getDict('build_time')
257
     }
257
     }
258
 
258
 
259
     return buildTimeDict
259
     return buildTimeDict

+ 51
- 40
src/store/models/room.js 查看文件

1
-import { reactive, ref } from "vue"
2
-import request from "@/utils/request"
3
-import { showDanger } from "@/utils"
1
+import { reactive, ref } from 'vue'
2
+import request from '@/utils/request'
3
+import { showDanger } from '@/utils'
4
 
4
 
5
 export default () => {
5
 export default () => {
6
   const loading = ref(false)
6
   const loading = ref(false)
14
   const getList = (data) => {
14
   const getList = (data) => {
15
     loading.value = true
15
     loading.value = true
16
     request({
16
     request({
17
-      loadingId: "room.list",
18
-      url: "/room/list",
17
+      loadingId: 'room.list',
18
+      url: '/room/list',
19
       data: {
19
       data: {
20
         pageNo: 1,
20
         pageNo: 1,
21
         pageSize: 10,
21
         pageSize: 10,
41
   // 房源详情--基础信息
41
   // 房源详情--基础信息
42
   const getDetail = (id) => {
42
   const getDetail = (id) => {
43
     request({
43
     request({
44
-      loadingId: "room.view",
45
-      url: "/room/detail",
44
+      loadingId: 'room.view',
45
+      url: '/room/detail',
46
       params: { id },
46
       params: { id },
47
     })
47
     })
48
       .then((res) => {
48
       .then((res) => {
50
       })
50
       })
51
       .catch((e) => {
51
       .catch((e) => {
52
         console.error(e)
52
         console.error(e)
53
-        showDanger("获取详情失败")
53
+        showDanger('获取详情失败')
54
       })
54
       })
55
   }
55
   }
56
 
56
 
57
   // 角色人信息
57
   // 角色人信息
58
   const getRole = (data) => {
58
   const getRole = (data) => {
59
     request({
59
     request({
60
-      loadingId: "room.role",
61
-      url: "/room/role",
60
+      loadingId: 'room.role',
61
+      url: '/room/role',
62
       params: {
62
       params: {
63
         roomId: data,
63
         roomId: data,
64
       },
64
       },
68
       })
68
       })
69
       .catch((e) => {
69
       .catch((e) => {
70
         console.error(e)
70
         console.error(e)
71
-        showDanger("获取角色人失败")
71
+        showDanger('获取角色人失败')
72
       })
72
       })
73
   }
73
   }
74
 
74
 
75
   // 委托书信息
75
   // 委托书信息
76
   const getAuth = (data) => {
76
   const getAuth = (data) => {
77
     request({
77
     request({
78
-      loadingId: "room.auth",
79
-      url: "/room/auth",
78
+      loadingId: 'room.auth',
79
+      url: '/room/auth',
80
       params: {
80
       params: {
81
         roomId: data,
81
         roomId: data,
82
       },
82
       },
86
       })
86
       })
87
       .catch((e) => {
87
       .catch((e) => {
88
         console.error(e)
88
         console.error(e)
89
-        showDanger("获取委托书失败")
89
+        showDanger('获取委托书失败')
90
       })
90
       })
91
   }
91
   }
92
 
92
 
93
   // 钥匙信息
93
   // 钥匙信息
94
   const getKey = (data) => {
94
   const getKey = (data) => {
95
     request({
95
     request({
96
-      loadingId: "room.key",
97
-      url: "/room/key",
96
+      loadingId: 'room.key',
97
+      url: '/room/key',
98
       params: {
98
       params: {
99
         roomId: data,
99
         roomId: data,
100
       },
100
       },
104
       })
104
       })
105
       .catch((e) => {
105
       .catch((e) => {
106
         console.error(e)
106
         console.error(e)
107
-        showDanger("获取钥匙失败")
107
+        showDanger('获取钥匙失败')
108
       })
108
       })
109
   }
109
   }
110
 
110
 
111
   // 房源保护
111
   // 房源保护
112
   const updateProtection = (data) => {
112
   const updateProtection = (data) => {
113
     return request({
113
     return request({
114
-      url: "/room/protection/update-status",
114
+      url: '/room/protection/update-status',
115
       data,
115
       data,
116
-      toast: "请稍候...",
116
+      toast: '请稍候...',
117
     }).then(() => {
117
     }).then(() => {
118
       detail.roomInfo.protectionFlag = data.protectionFlag
118
       detail.roomInfo.protectionFlag = data.protectionFlag
119
       return
119
       return
123
   // 业主电话
123
   // 业主电话
124
   const addOwnerTel = (params) => {
124
   const addOwnerTel = (params) => {
125
     return request({
125
     return request({
126
-      url: "/room/own-tel/add",
126
+      url: '/room/own-tel/add',
127
       params,
127
       params,
128
-      toast: "请稍候...",
128
+      toast: '请稍候...',
129
     }).then(() => {
129
     }).then(() => {
130
-      const ownerTel = detail.roomInfo.ownerTel || ""
130
+      const ownerTel = detail.roomInfo.ownerTel || ''
131
       detail.roomInfo.ownerTel = ownerTel
131
       detail.roomInfo.ownerTel = ownerTel
132
-        .split(",")
132
+        .split(',')
133
         .filter(Boolean)
133
         .filter(Boolean)
134
         .concat(params.newOwnerTel)
134
         .concat(params.newOwnerTel)
135
-        .join(",")
135
+        .join(',')
136
       return
136
       return
137
     })
137
     })
138
   }
138
   }
140
   // 获取楼栋详情
140
   // 获取楼栋详情
141
   const getBuilding = (estateId) => {
141
   const getBuilding = (estateId) => {
142
     return request({
142
     return request({
143
-      url: "/room/building",
143
+      url: '/room/building',
144
       params: { estateId },
144
       params: { estateId },
145
     })
145
     })
146
   }
146
   }
148
   // 房源下架
148
   // 房源下架
149
   const closeHouse = (data) => {
149
   const closeHouse = (data) => {
150
     return request({
150
     return request({
151
-      url: "/room/close",
151
+      url: '/room/close',
152
       params: { estateId: data.estateId },
152
       params: { estateId: data.estateId },
153
       data,
153
       data,
154
-      toast: "请稍候...",
154
+      toast: '请稍候...',
155
     }).then(() => {
155
     }).then(() => {
156
       return
156
       return
157
     })
157
     })
160
   // 房源编辑
160
   // 房源编辑
161
   const houseEdit = (data) => {
161
   const houseEdit = (data) => {
162
     return request({
162
     return request({
163
-      url: "/room/save",
163
+      url: '/room/save',
164
       data,
164
       data,
165
-      toast: "请稍候...",
165
+      toast: '请稍候...',
166
     })
166
     })
167
   }
167
   }
168
 
168
 
169
   // 实勘列表
169
   // 实勘列表
170
   const getRescList = (roomId) => {
170
   const getRescList = (roomId) => {
171
     return request({
171
     return request({
172
-      url: "/room/resc/list",
172
+      url: '/room/resc/list',
173
       params: { roomId },
173
       params: { roomId },
174
-      loadingId: "room.resc.list",
174
+      loadingId: 'room.resc.list',
175
     })
175
     })
176
   }
176
   }
177
 
177
 
178
   // 设置封面
178
   // 设置封面
179
   const setRescCover = (rescId) => {
179
   const setRescCover = (rescId) => {
180
     return request({
180
     return request({
181
-      url: "/room/resc/cover",
181
+      url: '/room/resc/cover',
182
       params: { id: rescId },
182
       params: { id: rescId },
183
-      toast: "请稍候...",
183
+      toast: '请稍候...',
184
     })
184
     })
185
   }
185
   }
186
 
186
 
187
   // 保存
187
   // 保存
188
   const saveResc = (data, roomId) => {
188
   const saveResc = (data, roomId) => {
189
     return request({
189
     return request({
190
-      url: "/room/resc/save",
190
+      url: '/room/resc/save',
191
       headers: {
191
       headers: {
192
-        "Content-Type": "application/json",
192
+        'Content-Type': 'application/json',
193
       },
193
       },
194
       params: { roomId },
194
       params: { roomId },
195
       data,
195
       data,
196
-      toast: "请稍候...",
196
+      toast: '请稍候...',
197
     })
197
     })
198
   }
198
   }
199
 
199
 
200
   // 删除
200
   // 删除
201
   const deleteResc = ({ roomId, rescId, rescType }) => {
201
   const deleteResc = ({ roomId, rescId, rescType }) => {
202
     return request({
202
     return request({
203
-      url: "/room/resc/delete",
203
+      url: '/room/resc/delete',
204
       params: { roomId, rescId, rescType },
204
       params: { roomId, rescId, rescType },
205
-      toast: "请稍候...",
205
+      toast: '请稍候...',
206
     })
206
     })
207
   }
207
   }
208
 
208
 
209
   // 查看业务房源数
209
   // 查看业务房源数
210
   const countOwnerTel = (ownerTel) => {
210
   const countOwnerTel = (ownerTel) => {
211
     return request({
211
     return request({
212
-      url: "/room/owner-tel/count",
212
+      url: '/room/owner-tel/count',
213
       params: { ownerTel },
213
       params: { ownerTel },
214
-      toast: "请稍候...",
214
+      toast: '请稍候...',
215
+    })
216
+  }
217
+
218
+  // 新增房源
219
+  const addHouse = (params, data) => {
220
+    return request({
221
+      url: '/room/add',
222
+      params,
223
+      data,
224
+      toast: '请稍候...',
215
     })
225
     })
216
   }
226
   }
217
 
227
 
238
     saveResc,
248
     saveResc,
239
     deleteResc,
249
     deleteResc,
240
     countOwnerTel,
250
     countOwnerTel,
251
+    addHouse,
241
   }
252
   }
242
 }
253
 }

+ 5
- 5
src/utils/index.js 查看文件

1
-import { Notify, Dialog } from "vant"
1
+import { Notify, Dialog } from 'vant'
2
 
2
 
3
 export function showSuccess(message) {
3
 export function showSuccess(message) {
4
-  return Notify({ type: "success", message, duration: 1000 })
4
+  return Notify({ type: 'success', message, duration: 1000 })
5
 }
5
 }
6
 
6
 
7
 export function showDanger(message) {
7
 export function showDanger(message) {
8
-  return Notify({ type: "danger", message })
8
+  return Notify({ type: 'danger', message })
9
 }
9
 }
10
 
10
 
11
 export function showWarn(message) {
11
 export function showWarn(message) {
12
-  return Notify({ type: "warning", message })
12
+  return Notify({ type: 'warning', message })
13
 }
13
 }
14
 
14
 
15
 export function alert(message, opts) {
15
 export function alert(message, opts) {
27
 }
27
 }
28
 
28
 
29
 export function isEmpty(o) {
29
 export function isEmpty(o) {
30
-  if (o === undefined || o === null || o === "") {
30
+  if (o === undefined || o === null || o === '') {
31
     return true
31
     return true
32
   }
32
   }
33
 
33
 

+ 241
- 64
src/view/addhouse/addsecondhand/index.vue 查看文件

7
     </div>
7
     </div>
8
 
8
 
9
     <div>
9
     <div>
10
-      <van-form @submit="onSubmit">
10
+      <van-form @submit.prevent="() => false">
11
         <van-field
11
         <van-field
12
           v-model="roomInfo.estateName"
12
           v-model="roomInfo.estateName"
13
           readonly
13
           readonly
23
           @change="handleEstateChange"
23
           @change="handleEstateChange"
24
         />
24
         />
25
 
25
 
26
-        <van-field
27
-          v-model="roomInfo.roomBuild"
28
-          name="roomBuild"
29
-          label="栋号"
30
-          placeholder="请输入"
31
-          required
32
-          :rules="[{ required: true, message: '请填写栋号' }]"
33
-        />
34
-
35
-        <van-field
36
-          v-model="roomInfo.roomUnit"
37
-          name="roomUnit"
38
-          label="单元"
39
-          placeholder="请输入"
40
-          required
41
-          :rules="[{ required: true, message: '请填写单元' }]"
42
-        />
43
-
44
-        <van-field
45
-          v-model="roomInfo.roomFloor"
46
-          name="roomFloor"
47
-          label="楼层"
48
-          placeholder="请输入"
49
-          required
50
-          :rules="[{ required: true, message: '请填写楼层' }]"
51
-        >
52
-          <template #input>
53
-            <Floor v-model="roomInfo.roomFloor" />
54
-          </template>
55
-        </van-field>
56
-
57
-        <van-field
58
-          v-model="roomInfo.roomNum"
59
-          name="roomNum"
60
-          label="房号"
61
-          placeholder="请输入"
62
-          required
63
-          :rules="[{ required: true, message: '请填写房号' }]"
64
-        />
26
+        <template v-if="isLock">
27
+          <van-field
28
+            v-model="roomInfo.roomBuild"
29
+            name="roomBuild"
30
+            label="栋号"
31
+            required
32
+            :rules="[{ required: true, message: '请选择栋号' }]"
33
+          >
34
+            <template #input>
35
+              <Picker
36
+                :options="lockBuilding.dong"
37
+                v-model="roomInfo.roomBuild"
38
+                placeholder="请选择"
39
+              />
40
+            </template>
41
+          </van-field>
42
+
43
+          <van-field
44
+            v-model="roomInfo.roomUnit"
45
+            name="roomUnit"
46
+            label="单元"
47
+            required
48
+            :rules="[{ required: true, message: '请选择单元' }]"
49
+          >
50
+            <template #input>
51
+              <Picker
52
+                :options="lockBuilding.unit"
53
+                v-model="roomInfo.roomUnit"
54
+                placeholder="请选择"
55
+              />
56
+            </template>
57
+          </van-field>
58
+
59
+          <van-field
60
+            v-model="roomInfo.roomFloor"
61
+            name="roomFloor"
62
+            label="楼层"
63
+            required
64
+            :rules="[{ required: true, message: '请选择楼层' }]"
65
+          >
66
+            <template #input>
67
+              <Picker
68
+                :options="lockBuilding.floor"
69
+                v-model="roomInfo.roomFloor"
70
+                placeholder="请选择"
71
+              />
72
+            </template>
73
+          </van-field>
74
+
75
+          <van-field
76
+            v-model="roomInfo.roomNum"
77
+            name="roomNum"
78
+            label="房号"
79
+            required
80
+            :rules="[{ required: true, message: '请选择房号' }]"
81
+          >
82
+            <template #input>
83
+              <Picker
84
+                :options="lockBuilding.room"
85
+                v-model="roomInfo.roomNum"
86
+                placeholder="请选择"
87
+                @change="handleRoomNumChange"
88
+              />
89
+            </template>
90
+          </van-field>
91
+        </template>
92
+
93
+        <template v-else>
94
+          <van-field
95
+            v-model="roomInfo.roomBuild"
96
+            name="roomBuild"
97
+            label="栋号"
98
+            placeholder="请输入"
99
+            required
100
+            :rules="[{ required: true, message: '请填写栋号' }]"
101
+          />
102
+
103
+          <van-field
104
+            v-model="roomInfo.roomUnit"
105
+            name="roomUnit"
106
+            label="单元"
107
+            placeholder="请输入"
108
+            required
109
+            :rules="[{ required: true, message: '请填写单元' }]"
110
+          />
111
+
112
+          <van-field
113
+            v-model="roomInfo.roomFloor"
114
+            name="roomFloor"
115
+            label="楼层"
116
+            placeholder="请输入"
117
+            required
118
+            :rules="[{ required: true, message: '请填写楼层' }]"
119
+          >
120
+            <template #input>
121
+              <Floor v-model="roomInfo.roomFloor" />
122
+            </template>
123
+          </van-field>
124
+
125
+          <van-field
126
+            v-model="roomInfo.roomNum"
127
+            name="roomNum"
128
+            label="房号"
129
+            placeholder="请输入"
130
+            required
131
+            :rules="[{ required: true, message: '请填写房号' }]"
132
+          />
133
+        </template>
65
 
134
 
66
         <van-field
135
         <van-field
67
           v-model="roomInfo.title"
136
           v-model="roomInfo.title"
289
         <van-field v-model="tel3" label="业主电话3" placeholder="请输入" />
358
         <van-field v-model="tel3" label="业主电话3" placeholder="请输入" />
290
 
359
 
291
         <div style="margin: 1em">
360
         <div style="margin: 1em">
292
-          <van-button block type="warning" native-type="submit">
293
-            提交
294
-          </van-button>
361
+          <van-button block type="warning" @click="onSubmit"> 提交 </van-button>
295
         </div>
362
         </div>
296
       </van-form>
363
       </van-form>
297
     </div>
364
     </div>
310
 import Floor from './components/Floor'
377
 import Floor from './components/Floor'
311
 import RoomType from './components/RoomType'
378
 import RoomType from './components/RoomType'
312
 import Proportion from './components/Proportion'
379
 import Proportion from './components/Proportion'
313
-import { showDanger, confirm } from '@/utils'
380
+import { showDanger, confirm, showSuccess } from '@/utils'
381
+import request from '@/utils/request'
314
 
382
 
315
 export default {
383
 export default {
316
   name: 'addsecondhand',
384
   name: 'addsecondhand',
327
     RoomType,
395
     RoomType,
328
     Proportion,
396
     Proportion,
329
   },
397
   },
330
-  data() {
331
-    return {}
332
-  },
333
 
398
 
334
   setup() {
399
   setup() {
335
     const router = useRouter()
400
     const router = useRouter()
336
     const showBuildingPicker = ref(false)
401
     const showBuildingPicker = ref(false)
337
     const { dicts, namedDicts } = useModel('dicts')
402
     const { dicts, namedDicts } = useModel('dicts')
338
-    const { countOwnerTel } = useModel('room')
403
+    const { countOwnerTel, addHouse } = useModel('room')
404
+
405
+    const lockBuilding = reactive({
406
+      // 栋
407
+      dong: [],
408
+      // 单元
409
+      unit: [],
410
+      // 层
411
+      floor: [],
412
+      // 房
413
+      room: [],
414
+    })
339
 
415
 
340
     // 房源信息
416
     // 房源信息
341
     const roomInfo = reactive({
417
     const roomInfo = reactive({
394
     const tel2 = ref('')
470
     const tel2 = ref('')
395
     const tel3 = ref('')
471
     const tel3 = ref('')
396
     const building = ref()
472
     const building = ref()
473
+    const isLock = ref()
474
+    const localRoomNo = ref()
397
 
475
 
398
     watch([tel1, tel2, tel3], (nw) => {
476
     watch([tel1, tel2, tel3], (nw) => {
399
-      roomInfo.roomInfo = nw.join(',')
477
+      roomInfo.ownerTel = nw.join(',')
400
     })
478
     })
401
 
479
 
402
-    const onSubmit = (values) => {
403
-      // 锁盘房号
404
-      let localRoomNo
405
-      const lockRoomType = 0
406
-      const isLock = building.value.isLock
407
-      if (isLock) {
408
-        localRoomNo = roomInfo.roomNum
480
+    // 锁盘的情况下监控楼栋的选择
481
+    // 生成单元字典
482
+    watch(
483
+      () => roomInfo.roomBuild,
484
+      (nw) => {
485
+        if (isLock.value) {
486
+          request({
487
+            url: '/lock/unit',
488
+            params: { buildingId: roomInfo.estateId, dong: nw },
489
+          }).then((res) => {
490
+            lockBuilding.unit = (res || []).map((x) => ({
491
+              text: x.name,
492
+              value: x.code,
493
+            }))
494
+          })
495
+        }
496
+      }
497
+    )
498
+
499
+    // 锁盘的情况下监控单元的选择
500
+    // 生成楼层字典
501
+    watch(
502
+      () => roomInfo.roomUnit,
503
+      (nw) => {
504
+        if (isLock.value) {
505
+          request({
506
+            url: '/lock/floor',
507
+            params: {
508
+              buildingId: roomInfo.estateId,
509
+              dong: roomInfo.roomBuild,
510
+              unit: nw,
511
+            },
512
+          }).then((res) => {
513
+            lockBuilding.floor = (res || []).map((x) => ({
514
+              text: x.name,
515
+              value: x.code,
516
+            }))
517
+          })
518
+        }
519
+      }
520
+    )
521
+
522
+    // 锁盘的情况下监控楼层的选择
523
+    // 生成楼栋-房号字典
524
+    watch(
525
+      () => roomInfo.roomFloor,
526
+      (nw) => {
527
+        if (isLock.value) {
528
+          request({
529
+            url: '/lock/room',
530
+            params: {
531
+              buildingId: roomInfo.estateId,
532
+              dong: roomInfo.roomBuild,
533
+              unit: roomInfo.roomUnit,
534
+              floor: nw,
535
+            },
536
+          }).then((res) => {
537
+            lockBuilding.room = (res || []).map((x) => ({
538
+              text: x.name,
539
+              value: x.code,
540
+            }))
541
+          })
542
+        }
543
+      }
544
+    )
545
+
546
+    const onSubmit = () => {
547
+      // 生成保存函数
548
+      const submit = () => {
549
+        addHouse(
550
+          { localRoomNo: localRoomNo.value || '', lockRoomType: 0 },
551
+          roomInfo
552
+        )
553
+          .then(() => {
554
+            showSuccess('添加成功')
555
+            router.go(-1)
556
+          })
557
+          .catch((e) => {
558
+            showDanger(e.message)
559
+          })
409
       }
560
       }
410
 
561
 
411
       // 校验手机号
562
       // 校验手机号
429
             message.push(`${tels[2]} 的业主已经有 ${r3} 套房源`)
580
             message.push(`${tels[2]} 的业主已经有 ${r3} 套房源`)
430
           }
581
           }
431
 
582
 
432
-          message.push('是否继续? (选否则返回上一页)')
583
+          if (message.length > 0) {
584
+            message.push('是否继续? (选否则返回上一页)')
433
 
585
 
434
-          confirm(message.join(','))
435
-            .then(() => {})
436
-            .catch(() => {
437
-              router.go(-1)
438
-            })
586
+            confirm(message.join(','))
587
+              .then(() => submit())
588
+              .catch(() => {
589
+                router.go(-1)
590
+              })
591
+          } else {
592
+            submit()
593
+          }
439
         })
594
         })
440
         .catch((e) => {
595
         .catch((e) => {
441
           console.error(e)
596
           console.error(e)
442
           showDanger(`校验用户手机失败: ${e.message}`)
597
           showDanger(`校验用户手机失败: ${e.message}`)
443
         })
598
         })
444
-
445
-      console.log('submit', values)
446
     }
599
     }
447
 
600
 
448
     const handleEstateChange = ({ id, item }) => {
601
     const handleEstateChange = ({ id, item }) => {
449
       roomInfo.estateId = id
602
       roomInfo.estateId = id
450
       roomInfo.estateName = item.buildingName
603
       roomInfo.estateName = item.buildingName
451
       building.value = item
604
       building.value = item
605
+      isLock.value = building.value.isLock - 0
606
+
607
+      // 锁盘的情况下
608
+      // 生成楼栋字典
609
+      if (isLock.value) {
610
+        request({
611
+          url: '/lock/dong',
612
+          params: { buildingId: id },
613
+        }).then((res) => {
614
+          lockBuilding.dong = (res || []).map((x) => ({
615
+            text: x.name,
616
+            value: x.code,
617
+          }))
618
+        })
619
+      } else {
620
+        localRoomNo.value = undefined
621
+      }
622
+    }
623
+
624
+    const handleRoomNumChange = (item) => {
625
+      localRoomNo.value = item.text
452
     }
626
     }
453
 
627
 
454
     return {
628
     return {
460
       tel2,
634
       tel2,
461
       tel3,
635
       tel3,
462
       onSubmit,
636
       onSubmit,
637
+      isLock,
638
+      lockBuilding,
463
       handleEstateChange,
639
       handleEstateChange,
640
+      handleRoomNumChange,
464
     }
641
     }
465
   },
642
   },
466
 }
643
 }