|
@@ -30,8 +30,49 @@
|
30
|
30
|
</el-row>
|
31
|
31
|
<el-row>
|
32
|
32
|
<el-col :span="12">
|
33
|
|
- <el-form-item label="城市:" required prop="city">
|
34
|
|
- <el-cascader
|
|
33
|
+ <el-form-item label="城市:" required prop="city_id">
|
|
34
|
+ <el-select
|
|
35
|
+ v-model="form.province_id"
|
|
36
|
+ style="width:32%"
|
|
37
|
+ placeholder="选择地址"
|
|
38
|
+ @change="changeProvince">
|
|
39
|
+ <el-option
|
|
40
|
+ v-for="item in provinceOptions"
|
|
41
|
+ :key="item.id"
|
|
42
|
+ :label="item.name"
|
|
43
|
+ :value="item.id">
|
|
44
|
+ </el-option>
|
|
45
|
+ </el-select>
|
|
46
|
+
|
|
47
|
+ <el-select
|
|
48
|
+ v-model="form.city_id"
|
|
49
|
+ style="width:32%"
|
|
50
|
+ placeholder="选择地址"
|
|
51
|
+ @change="changeCity"
|
|
52
|
+ v-show="cityOptions.length>0"
|
|
53
|
+ >
|
|
54
|
+ <el-option
|
|
55
|
+ v-for="item in cityOptions"
|
|
56
|
+ :key="item.id"
|
|
57
|
+ :label="item.name"
|
|
58
|
+ :value="item.id">
|
|
59
|
+ </el-option>
|
|
60
|
+ </el-select>
|
|
61
|
+
|
|
62
|
+ <el-select
|
|
63
|
+ v-model="form.district_id"
|
|
64
|
+ style="width:32%"
|
|
65
|
+ placeholder="选择地址"
|
|
66
|
+ v-show="distictOptions.length>0"
|
|
67
|
+ >
|
|
68
|
+ <el-option
|
|
69
|
+ v-for="item in distictOptions"
|
|
70
|
+ :key="item.id"
|
|
71
|
+ :label="item.name"
|
|
72
|
+ :value="item.id">
|
|
73
|
+ </el-option>
|
|
74
|
+ </el-select>
|
|
75
|
+ <!-- <el-cascader
|
35
|
76
|
v-model="form.city"
|
36
|
77
|
:options="cityOptions"
|
37
|
78
|
@active-item-change="handleChangeCity"
|
|
@@ -42,7 +83,7 @@
|
42
|
83
|
label: 'name',
|
43
|
84
|
children: 'cities'
|
44
|
85
|
}"
|
45
|
|
- ></el-cascader>
|
|
86
|
+ ></el-cascader> -->
|
46
|
87
|
</el-form-item>
|
47
|
88
|
</el-col>
|
48
|
89
|
<el-col :span="12">
|
|
@@ -179,7 +220,7 @@ export default {
|
179
|
220
|
mobile: [{required: true, message: "请填写手机号",},{ validator: checkMobileRule}],
|
180
|
221
|
gender: [{required: true, message: "请选择性别",},],
|
181
|
222
|
birthday: [{required: true, message: "请选择生日",},],
|
182
|
|
- city: [{required: true, message: "请选择城市",},],
|
|
223
|
+ city_id: [{required: true, message: "请选择城市",},],
|
183
|
224
|
illness: [{required: true, message: "请选择病种",},],
|
184
|
225
|
ill_date: [{required: true, message: "请选择患病时间",},],
|
185
|
226
|
treat_type: [{required: true, message: "请选择治疗方式",},],
|
|
@@ -189,14 +230,16 @@ export default {
|
189
|
230
|
{id:1, name:'男'},
|
190
|
231
|
{id:2, name:'女'},
|
191
|
232
|
],
|
|
233
|
+ provinceOptions:[],
|
192
|
234
|
cityOptions:[],
|
|
235
|
+ distictOptions:[],
|
193
|
236
|
form:{
|
194
|
237
|
name:'',
|
195
|
238
|
mobile:'',
|
196
|
239
|
gender:0,
|
197
|
240
|
birthday:'',
|
198
|
241
|
city:[],
|
199
|
|
- province_id:0,
|
|
242
|
+ province_id:'',
|
200
|
243
|
city_id:0,
|
201
|
244
|
district_id:0,
|
202
|
245
|
illness:[],
|
|
@@ -212,7 +255,7 @@ export default {
|
212
|
255
|
},
|
213
|
256
|
methods:{
|
214
|
257
|
open:function(){
|
215
|
|
- this.GetDistrictsByUpid();
|
|
258
|
+ this.GetProvince(0);
|
216
|
259
|
this.resetForm("memberForm");
|
217
|
260
|
this.createMemberFormVisible = true;
|
218
|
261
|
},
|
|
@@ -227,6 +270,9 @@ export default {
|
227
|
270
|
// }
|
228
|
271
|
this.$refs[formName].validate((valid) => {
|
229
|
272
|
if (valid) {
|
|
273
|
+ if (this.form.district_id == '') {
|
|
274
|
+ this.form.district_id = this.form.city_id;
|
|
275
|
+ }
|
230
|
276
|
CreateMember(this.form).then(response=>{
|
231
|
277
|
var res = response.data;
|
232
|
278
|
if(res.state === 1) {
|
|
@@ -264,83 +310,48 @@ export default {
|
264
|
310
|
this.form.avatar = 'https://images.shengws.com/201809182128111.png';
|
265
|
311
|
}
|
266
|
312
|
},
|
267
|
|
- handleChangeCity:function(val) {
|
268
|
|
- this.GetDistrictsByUpid(val);
|
|
313
|
+ changeProvince(id) {
|
|
314
|
+ this.form.city_id = '';
|
|
315
|
+ this.form.district_id = '';
|
|
316
|
+ this.GetCity(id);
|
|
317
|
+ this.distictOptions = [];
|
269
|
318
|
},
|
270
|
|
- handleSelectedCity:function(val) {
|
271
|
|
- this.form.province_id = val[0];
|
272
|
|
- this.form.city_id = val[1];
|
273
|
|
- this.form.district_id = val[2];
|
|
319
|
+ changeCity(id){
|
|
320
|
+ this.form.district_id = '';
|
|
321
|
+ this.GetDistrict(id);
|
274
|
322
|
},
|
275
|
|
- GetDistrictsByUpid:function(val) {
|
276
|
|
- let idArea
|
277
|
|
- let sizeArea
|
278
|
|
- if (!val) {
|
279
|
|
- idArea = 0
|
280
|
|
- sizeArea = 0
|
281
|
|
- } else if (val.length === 1) {
|
282
|
|
- idArea = val[0]
|
283
|
|
- sizeArea = val.length // 3:一级 4:二级 6:三级
|
284
|
|
- } else if (val.length === 2) {
|
285
|
|
- idArea = val[1]
|
286
|
|
- sizeArea = val.length // 3:一级 4:二级 6:三级
|
287
|
|
- }
|
288
|
|
-
|
289
|
|
- GetDistrictsByUpid({id:idArea}).then(response=>{
|
|
323
|
+ GetProvince:function(id) {
|
|
324
|
+ GetDistrictsByUpid({id:id}).then(response=>{
|
290
|
325
|
var res = response.data;
|
291
|
326
|
if (res.state===1) {
|
292
|
|
- var citys = res.data.citys;
|
293
|
|
- if (sizeArea === 0) { // 初始化 加载一级 省
|
294
|
|
- this.cityOptions = citys.map((value, i) => {
|
295
|
|
- return {
|
296
|
|
- id: value.id,
|
297
|
|
- name: value.name,
|
298
|
|
- cities: []
|
299
|
|
- }
|
300
|
|
- })
|
301
|
|
- } else if (sizeArea === 1) { // 点击一级 加载二级 市
|
302
|
|
- this.cityOptions.map((value, i) => {
|
303
|
|
- if (value.id === val[0]) {
|
304
|
|
- if (!value.cities.length) {
|
305
|
|
- value.cities = citys.map((value, i) => {
|
306
|
|
- return {
|
307
|
|
- id: value.id,
|
308
|
|
- name: value.name,
|
309
|
|
- cities: []
|
310
|
|
- }
|
311
|
|
- })
|
312
|
|
- }
|
313
|
|
- }
|
314
|
|
- })
|
315
|
|
- } else if (sizeArea === 2) { // 点击二级 加载三级 区
|
316
|
|
- this.cityOptions.map((value, i) => {
|
317
|
|
- if (value.id === val[0]) {
|
318
|
|
- value.cities.map((value, i) => {
|
319
|
|
- if (value.id === val[1]) {
|
320
|
|
- if (!value.cities.length) {
|
321
|
|
- if (citys.length) {
|
322
|
|
- value.cities = citys.map((value, i) => {
|
323
|
|
- return {
|
324
|
|
- id: value.id,
|
325
|
|
- name: value.name
|
326
|
|
- }
|
327
|
|
- })
|
328
|
|
- }else {
|
329
|
|
- value.cities = [
|
330
|
|
- {id:value.id, name:value.name}
|
331
|
|
- ];
|
332
|
|
- }
|
333
|
|
-
|
334
|
|
- }
|
335
|
|
- }
|
336
|
|
- })
|
337
|
|
- }
|
338
|
|
- })
|
339
|
|
- }
|
|
327
|
+ this.provinceOptions = res.data.citys;
|
|
328
|
+ }else {
|
|
329
|
+ this.$message.error(res.msg);
|
|
330
|
+ }
|
|
331
|
+ }).catch(e=>{
|
|
332
|
+ });
|
|
333
|
+ },
|
|
334
|
+ GetCity:function(id) {
|
|
335
|
+ GetDistrictsByUpid({id:id}).then(response=>{
|
|
336
|
+ var res = response.data;
|
|
337
|
+ if (res.state===1) {
|
|
338
|
+ this.cityOptions = res.data.citys;
|
340
|
339
|
}else {
|
341
|
340
|
this.$message.error(res.msg);
|
342
|
341
|
}
|
343
|
|
- }).catch(e=>{});
|
|
342
|
+ }).catch(e=>{
|
|
343
|
+ });
|
|
344
|
+ },
|
|
345
|
+ GetDistrict:function(id) {
|
|
346
|
+ GetDistrictsByUpid({id:id}).then(response=>{
|
|
347
|
+ var res = response.data;
|
|
348
|
+ if (res.state===1) {
|
|
349
|
+ this.distictOptions = res.data.citys;
|
|
350
|
+ }else {
|
|
351
|
+ this.$message.error(res.msg);
|
|
352
|
+ }
|
|
353
|
+ }).catch(e=>{
|
|
354
|
+ });
|
344
|
355
|
},
|
345
|
356
|
}
|
346
|
357
|
}
|