address-client 4.0.7 → 4.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,479 +1,479 @@
1
- <template>
2
- <div class="auto content">
3
- <div class="col-sm-12">
4
- <label v-if="!model.id" class="add">添加{{type=='区'?'区/县':type}}</label>
5
- <label v-if="model.id && !isarea" class="fs24">修改{{type=='区'?'区/县':type}}</label>
6
- <label v-if="model.id && isarea" class="fs24">修改 {{model.f_name}} 默认表具</label>
7
- </div>
8
- <div class="col-sm-12" role="group">
9
- <center v-if="!(type=='区'||type=='街道'||type=='小区') && !model.id && isbasch">
10
- <button class="btn" :class="isselected ? 'btn-info':'btn-default'" @click="changetosingle">单个添加</button>
11
- <button class="btn" :class="isselected ? 'btn-default':'btn-info'" @click="changetobatch">批量添加</button>
12
- </center>
13
- <div class="auto col-sm-12 margintop" v-show="parent.f_name!='' && parent.f_type!='' && !isarea">
14
- <span class="shangji">上级名称:<label class="name">{{parent.f_name}}</label></span>
15
- <span class="shangji">上级类型:<label class="name">{{parent.f_type=='区'?'区/县':parent.f_type}}</label></span>
16
- </div>
17
-
18
- <div v-if="isselected && !isarea" class="form-group col-sm-12" style="margin-bottom: 20px; margin-top: 30px">
19
- <span class="col-sm-2 font_normal_body shangji">{{model.f_type=='区'?'区/县':model.f_type}}名称:</span>
20
- <input type="text" v-model="model.f_name" class="col-sm-10 input" placeholder="请输入" >
21
- </div>
22
-
23
- <div v-if="!isselected && !(type=='小区') && isbasch">
24
- <div class="form-group col-sm-12" v-show="type=='楼号'">
25
- <span class="col-sm-2 font_normal_body name">楼号:</span>
26
- <input v-model="name_l" class="col-sm-6" />
27
- <span class="col-sm-2 font_normal_body name">名称:</span>
28
- <input v-model="name_l_t" class="col-sm-2" />
29
- </div>
30
- <div class="form-group remark" v-show="type=='楼号'">备注:例如1-5,10-18</div>
31
- <div class="form-group col-sm-12" v-show="type=='楼号'||type=='单元'">
32
- <span class="col-sm-2 font_normal_body name">单元:</span>
33
- <input class="col-sm-6" v-model="name_d"/>
34
- <span class="col-sm-2 font_normal_body name">名称:</span>
35
- <input class="col-sm-2" v-model="name_d_t"/>
36
- </div>
37
- <div class="form-group remark" v-show="type=='楼号'||type=='单元'">备注:例如1-4</div>
38
- <div class="form-group col-sm-12" v-show="type=='楼号'||type=='单元'||type=='楼层'">
39
- <span class="col-sm-2 font_normal_body name">楼层:</span>
40
- <input class="col-sm-6" v-model="name_c" />
41
- <span class="col-sm-2 font_normal_body name">名称:</span>
42
- <input class="col-sm-2" v-model="name_c_t" />
43
- </div>
44
- <div class="form-group remark" v-show="type=='楼号'||type=='单元'||type=='楼层'">备注:例如1-5,8-10</div>
45
- <div class="form-group col-sm-12">
46
- <span class="col-sm-2 font_normal_body name">门牌号:</span>
47
- <input v-model="name_m" class="col-sm-6"/>
48
- <span class="col-sm-2 font_normal_body name">名称:</span>
49
- <input v-model="name_m_t" class="col-sm-2"/>
50
- </div>
51
- <div class="form-group remark">备注:例如1-4,门牌号规则:单元+楼层+门牌号</div>
52
- </div>
53
- <div class="form-group auto" v-show="isarea">
54
- <new-address-info v-ref:newaddressinfo v-if="type=='小区'" :areatype="areatype" :row="areaData" @addchild="addChild" @signout="signOut"></new-address-info>
55
- </div>
56
- <div class="form-group col-sm-12" v-show="!(type=='小区') || !isarea">
57
- <button type="button" class="button_search button_spacing" @click="addChild" >保存</button>
58
- <button type="button" class="button_clear button_spacing" @click="signOut">取消</button>
59
- </div>
60
- </div>
61
- </div>
62
- </template>
63
-
64
- <script>
65
- import NewAddressInfo from './NewAddressInfo'
66
- import {HttpResetClass} from 'vue-client'
67
- // 提交地址
68
- let asyncAddChild = async function(self, val) {
69
- console.log('33333333333333333',val)
70
- let result = null
71
- let data = null
72
- //新增 || 修改
73
- if(val.id != null) {
74
- console.log("asyncAddChild=" , val)
75
- result = await self.$resetpost(`api/af-revenue/logic/address_addAddress`, val, {resolveMsg: null})
76
- // 添加小区 t_area
77
- if(val.f_type=='小区') {
78
- let parent = await self.$resetpost(`api/af-revenue/logic/address_parent`, {id: val.id + ""}, {resolveMsg: null})
79
- await self.$refs.newaddressinfo.confirm(result.data.id, parent.data)
80
- }
81
- } else {
82
- // 子地址 || 根地址
83
- if(val.f_parentId == null) {
84
- data = {data: {f_parentId: null, condition: `f_locationId=${val.f_locationId} and f_locationType='${val.f_locationType}' and f_name='${val.f_name}'`}}
85
- } else {
86
- data = {data: {f_parentId: val.f_parentId.id, condition: `f_name='${val.f_name}'`}}
87
- }
88
- console.log('444444444444444',data)
89
- result = await self.$resetpost('rs/path/address_getRoot', data, {resolveMsg: null})
90
- console.log('55555555555555',result)
91
- // 查询改地址是否已存在
92
- console.log('666666666666666',result.data.length)
93
- if(result.data.length > 0) {
94
- alert("该地址已存在")
95
- throw err = new Error( '该地址已存在' )
96
- } else {
97
- console.log("调剂的速度val: ", val)
98
- result = await self.$resetpost(`api/af-revenue/logic/address_addAddress`, val, {resolveMsg: null})
99
- // 添加小区 t_area
100
- console.log("result=" , result)
101
- if(result.data && val.f_type=='小区') {
102
- let parent = await self.$resetpost(`api/af-revenue/logic/address_parent`, {id: result.data.id+""}, {resolveMsg: null})
103
- await self.$refs.newaddressinfo.confirm(result.data.id, parent.data)
104
- }
105
- }
106
- }
107
- return result
108
- }
109
- // 获取地址
110
- let asyncGetAddress = async function(self,num) {
111
- let data = {data: {f_parentId: null, condition: `id='${self.f_parentid}'`}}
112
- let result
113
- if(num == 1){ //添加
114
- result = await self.$resetpost('api/af-revenue/sql/address_getSelf', {data: {id: self.f_parentid}}, {resolveMsg: null})
115
- } else { //修改
116
- result = await self.$resetpost('api/af-revenue/sql/address_getParent', {data: {id: self.model.id}}, {resolveMsg: null})
117
- }
118
- if(result.data.length > 0) {
119
- self.parent = result.data[0]
120
- } else {
121
- self.parent = {}
122
- }
123
- return result
124
- }
125
-
126
- export default {
127
- name: "AddressAddAddress",
128
- components: {NewAddressInfo},
129
- props: {
130
- // 主键 id
131
- row: {
132
- type: Object,
133
- },
134
- // 父节点id
135
- f_parentid: {
136
- type: Number,
137
- },
138
- //位置
139
- f_location: {
140
- type: Object,
141
- },
142
- // 地址类型
143
- type: {
144
- type: String,
145
- },
146
- // 是否显示小区信息
147
- isarea: {
148
- type: Boolean,
149
- default: false,
150
- },
151
- // 是否显示批量添加
152
- isbasch: {
153
- type: Boolean,
154
- default: true
155
- }
156
- },
157
- data() {
158
- return {
159
- model: {
160
- id: null, //地址id
161
- f_locationId: null, //位置id
162
- f_locationType: null,//位置类型
163
- f_parentId: null,//上级地址id
164
- f_name: '', //地址名称
165
- f_type: '', //地址类型
166
- },
167
- // 上级地址
168
- parent: {},
169
- // 小区信息
170
- areaData: null,
171
- // 小区 的 区名称
172
- areatype: '',
173
- isselected:true,
174
- // 楼号
175
- name_l: '',
176
- name_l_t: '',
177
- // 单元
178
- name_d: '',
179
- name_d_t: '',
180
- // 楼层
181
- name_c: '',
182
- name_c_t: '',
183
- // 门牌号
184
- name_m: '',
185
- name_m_t: '',
186
- }
187
- },
188
- ready () {
189
- if(this.row) {
190
- this.model = Object.assign({}, this.model, this.row)
191
- }
192
- if(this.f_parentid) {
193
- this.model.f_parentId = {id: this.f_parentid}
194
- return this.init()
195
- }
196
- if(this.f_location) {
197
- this.model.f_locationId = this.f_location.f_locationId
198
- this.model.f_locationType = this.f_location.f_locationType
199
- }
200
- if(this.type!='') {
201
- this.model.f_type = this.type
202
- }
203
- },
204
- watch: {
205
- 'f_location' (val) {
206
- this.isselected = true
207
- if(val) {
208
- this.model.f_locationId = val.f_locationId
209
- this.model.f_locationType = val.f_locationType
210
- } else {
211
- this.model.f_locationId = null
212
- this.model.f_locationType = null
213
- }
214
- },
215
- 'f_parentid' (val) {
216
- this.isselected = true
217
- // 添加
218
- if(val) {
219
- this.model.f_parentId = {id: val}
220
- this.addinit(val)
221
- } else {
222
- this.model.f_parentId = null
223
- this.parent = {}
224
- }
225
- },
226
- 'type' (val) {
227
- console.log("asdasd safffgg456756val", val)
228
- this.isselected = true
229
- if(val!='') {
230
- this.model.f_type = val
231
- }
232
- },
233
- 'row' (val) {
234
- console.log("val", val)
235
- this.isselected = true
236
- if(val) {
237
- this.getParent(val)
238
- } else {
239
- this.addArea()
240
- }
241
- }
242
- },
243
- methods: {
244
-
245
- // 添加
246
- async addinit(val){
247
- let http = new HttpResetClass()
248
- let res = await http.load('POST', 'api/af-revenue/sql/address_getSelf', {data: {id: this.f_parentid}}, {resolveMsg: null})
249
- this.parent = res.data.length > 0 ? res.data[0]: {}
250
- let parent = await http.load('POST', `api/af-revenue/logic/address_parent`, {id: val+""}, {resolveMsg: null, rejectMsg:'请求address_parent报错!!'})
251
- this.areatype = parent.data.f_area
252
- },
253
- // 初始化
254
- async init(num) {
255
- let data = {data: {f_parentId: null, condition: `id='${this.f_parentid}'`}}
256
- let result
257
- if(num == 1){ //添加
258
- result = await this.$resetpost('api/af-revenue/sql/address_getSelf', {data: {id: this.f_parentid}}, {resolveMsg: null})
259
- } else { //修改
260
- result = await this.$resetpost('api/af-revenue/sql/address_getParent', {data: {id: this.model.id}}, {resolveMsg: null})
261
- }
262
- if(result.data.length > 0) {
263
- this.parent = result.data[0]
264
- } else {
265
- this.parent = {}
266
- }
267
- return result
268
- },
269
- //提交地址
270
- addChild() {
271
- // 判断是否是批量添加
272
- if(!this.isselected && !(this.type=='小区') && this.isbasch) {
273
- console.log("批量添加,上级id: ", this.model.f_parentId)
274
- return this.baschAdd(this.model.f_parentId)
275
- } else {
276
- console.log('11111111111111111111',this.model)
277
- let data = Object.assign({}, data, this.model)
278
- console.log('2222222222222222',data)
279
- let id = this.model.id
280
- if(this.model.f_name != '') {
281
- return asyncAddChild(this, data).then((res) => {
282
- let result = data
283
- result.id = res.data.id
284
- this.model.f_name = ''
285
- this.model.idstr = null
286
- this.model.size = null
287
- this.isselected = true
288
- this.$parent.showAddress = !this.$parent.showAddress
289
- this.initModel()
290
- console.log("addChild", result)
291
- if(id != null) { // 修改
292
- this.$emit('updata-child-node', result)
293
- } else { //新增
294
- this.$emit('add-child-node', result)
295
- }
296
- }).catch((error) => {
297
- this.$emit('error', error)
298
- })
299
- } else {
300
- alert("名称和类型不能为空")
301
- }
302
- }
303
- },
304
- //返回
305
- signOut() {
306
- if (this.type === '小区') {
307
- this.$refs.newaddressinfo.initModel()
308
- }
309
- this.model.f_name = ''
310
- this.model.id = null
311
- this.isselected = true
312
- this.initModel()
313
- this.$parent.showAddress = !this.$parent.showAddress
314
- },
315
- async baschAdd(id) {
316
- if(!this.isselected) {
317
- let batchs = new Array()
318
- if(this.name_l != '') {
319
- if(this.name_l_t == ''){
320
- this.name_l_t = '号楼'
321
- }
322
- batchs.push({type: '楼号', names: this.name_l, n_type: this.name_l_t})
323
- }
324
- if(this.name_d != '') {
325
- if(this.name_d_t == ''){
326
- this.name_d_t = '单元'
327
- }
328
- batchs.push({type: '单元', names: this.name_d, n_type: this.name_d_t})
329
- }
330
- if(this.name_c != '') {
331
- if(this.name_c_t == ''){
332
- this.name_c_t = '层'
333
- }
334
- batchs.push({type: '楼层', names: this.name_c, n_type: this.name_c_t})
335
- }
336
- if(this.name_m != '') {
337
- if(this.name_m_t == ''){
338
- this.name_m_t = '号'
339
- }
340
- batchs.push({type: '门牌号', names: this.name_m, n_type: this.name_m_t})
341
- }
342
- console.log("批量添加baschAdd: ",batchs, " ", id)
343
- this.$showMessage('将会占用几分钟!!', ['confirm', 'cancel']).then((res) => {
344
- if (res === 'confirm') {
345
- this.isselected = true
346
- this.$parent.showAddress = !this.$parent.showAddress
347
- let http = new HttpResetClass()
348
- http.load('POST', 'api/af-revenue/logic/address_batch', {id: id.id+"", json: batchs}, {rejectMsg:'批量上传出错', resolveMsg: '地址导入完成'}, 0).then(() => {
349
- this.$showMessage('导入完成。。!', ['confirm']).then((res) => {
350
- if (res === 'confirm') {
351
- this.initModel()
352
- this.$emit('add-child-node')
353
- }
354
- })
355
- })
356
- }
357
- })
358
- // let http = new HttpResetClass()
359
- // await http.load('POST', `api/af-revenue/logic/address_batch`, {id: id.id+"", json: batchs})
360
- // this.isselected = true
361
- // this.initModel()
362
- // this.$parent.showAddress = !this.$parent.showAddress
363
- // this.$emit('add-child-node')
364
- }
365
- },
366
- // 新增
367
- addArea() {
368
- this.model.id = null
369
- this.parent = {}
370
- this.model.f_name = ''
371
- if(this.type=='') {
372
- this.model.f_type = ''
373
- }
374
- if(!this.f_location) {
375
- this.model.f_locationId = null
376
- this.model.f_locationType = null
377
- }
378
- if(!this.f_parentid){
379
- this.model.f_parentId = null
380
- }
381
- this.areaData = null
382
- },
383
- //
384
- async getParent(val) {
385
- let http = new HttpResetClass()
386
- let parent = await http.load('POST', `api/af-revenue/logic/address_parent`, {id: val.id+""}, {resolveMsg: null, rejectMsg:'请求address_parent报错!!'})
387
- this.areatype = parent.data.f_area
388
-
389
- this.model = Object.assign({}, this.model, val)
390
-
391
- let res = await http.load('POST', 'api/af-revenue/sql/address_getParent', {data: {id: this.model.id}}, {resolveMsg: null, rejectMsg:'请求address_getParent报错!!'})
392
- if(res.data.length > 0) {
393
- this.parent = res.data[0]
394
- } else {
395
- this.parent = {}
396
- }
397
-
398
- if(val.id != null && this.type=='小区') {
399
- let result = await http.load('POST','rs/path/address_getArea', {data: {id: val.id}}, {resolveMsg: null})
400
- if(result.data.length > 0) {
401
- this.areaData = result.data[0]
402
- } else {
403
- this.areaData = null
404
- }
405
- } else {
406
- this.areaData = null
407
- }
408
- },
409
-
410
- changetosingle(){
411
- this.isselected = true
412
- },
413
- changetobatch(){
414
- this.isselected = false
415
- },
416
- // 初始化参数
417
- initModel() {
418
- this.name_l = ''
419
- this.name_l_t = ''
420
- // 单元
421
- this.name_d = ''
422
- this.name_d_t = ''
423
- // 楼层
424
- this.name_c = ''
425
- this.name_c_t = ''
426
- // 门牌号
427
- this.name_m = ''
428
- this.name_m_t = ''
429
- }
430
- },
431
- }
432
- </script>
433
-
434
- <style type="text/css" scoped>
435
- *{
436
- margin: 0 auto;
437
- text-align: center;
438
- }
439
- div {
440
- margin-top: 10px;
441
- }
442
- .btngroup{
443
- height: 32px;
444
- width: 92px;
445
- }
446
- .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle){
447
- border-radius: 4px;
448
- border-bottom-right-radius: 0;
449
- border-top-right-radius: 0;
450
- }
451
- .add{
452
- font-family: PingFangSC-Medium;
453
- font-size: 24px;
454
- color: #333333;
455
- }
456
- .shangji{
457
- font-family: PingFangSC-Medium;
458
- font-size: 16px;
459
- color: #666666;
460
- }
461
- .name{
462
- font-family: PingFangSC-Bold;
463
- font-size: 16px;
464
- color: #333333;
465
- }
466
- .margintop{
467
- margin-top: 20px;
468
- }
469
- .input{
470
- background-color: #FFFFFF;
471
- border: 1px solid #999999;
472
- }
473
- .remark{
474
- font-family: PingFangSC-Medium;
475
- font-size: 14px;
476
- color: #666666;
477
- }
478
-
479
- </style>
1
+ <template>
2
+ <div class="auto content">
3
+ <div class="col-sm-12">
4
+ <label v-if="!model.id" class="add">添加{{type=='区'?'区/县':type}}</label>
5
+ <label v-if="model.id && !isarea" class="fs24">修改{{type=='区'?'区/县':type}}</label>
6
+ <label v-if="model.id && isarea" class="fs24">修改 {{model.f_name}} 默认表具</label>
7
+ </div>
8
+ <div class="col-sm-12" role="group">
9
+ <center v-if="!(type=='区'||type=='街道'||type=='小区') && !model.id && isbasch">
10
+ <button class="btn" :class="isselected ? 'btn-info':'btn-default'" @click="changetosingle">单个添加</button>
11
+ <button class="btn" :class="isselected ? 'btn-default':'btn-info'" @click="changetobatch">批量添加</button>
12
+ </center>
13
+ <div class="auto col-sm-12 margintop" v-show="parent.f_name!='' && parent.f_type!='' && !isarea">
14
+ <span class="shangji">上级名称:<label class="name">{{parent.f_name}}</label></span>
15
+ <span class="shangji">上级类型:<label class="name">{{parent.f_type=='区'?'区/县':parent.f_type}}</label></span>
16
+ </div>
17
+
18
+ <div v-if="isselected && !isarea" class="form-group col-sm-12" style="margin-bottom: 20px; margin-top: 30px">
19
+ <span class="col-sm-2 font_normal_body shangji">{{model.f_type=='区'?'区/县':model.f_type}}名称:</span>
20
+ <input type="text" v-model="model.f_name" class="col-sm-10 input" placeholder="请输入" >
21
+ </div>
22
+
23
+ <div v-if="!isselected && !(type=='小区') && isbasch">
24
+ <div class="form-group col-sm-12" v-show="type=='楼号'">
25
+ <span class="col-sm-2 font_normal_body name">楼号:</span>
26
+ <input v-model="name_l" class="col-sm-6" />
27
+ <span class="col-sm-2 font_normal_body name">名称:</span>
28
+ <input v-model="name_l_t" class="col-sm-2" />
29
+ </div>
30
+ <div class="form-group remark" v-show="type=='楼号'">备注:例如1-5,10-18</div>
31
+ <div class="form-group col-sm-12" v-show="type=='楼号'||type=='单元'">
32
+ <span class="col-sm-2 font_normal_body name">单元:</span>
33
+ <input class="col-sm-6" v-model="name_d"/>
34
+ <span class="col-sm-2 font_normal_body name">名称:</span>
35
+ <input class="col-sm-2" v-model="name_d_t"/>
36
+ </div>
37
+ <div class="form-group remark" v-show="type=='楼号'||type=='单元'">备注:例如1-4</div>
38
+ <div class="form-group col-sm-12" v-show="type=='楼号'||type=='单元'||type=='楼层'">
39
+ <span class="col-sm-2 font_normal_body name">楼层:</span>
40
+ <input class="col-sm-6" v-model="name_c" />
41
+ <span class="col-sm-2 font_normal_body name">名称:</span>
42
+ <input class="col-sm-2" v-model="name_c_t" />
43
+ </div>
44
+ <div class="form-group remark" v-show="type=='楼号'||type=='单元'||type=='楼层'">备注:例如1-5,8-10</div>
45
+ <div class="form-group col-sm-12">
46
+ <span class="col-sm-2 font_normal_body name">门牌号:</span>
47
+ <input v-model="name_m" class="col-sm-6"/>
48
+ <span class="col-sm-2 font_normal_body name">名称:</span>
49
+ <input v-model="name_m_t" class="col-sm-2"/>
50
+ </div>
51
+ <div class="form-group remark">备注:例如1-4,门牌号规则:单元+楼层+门牌号</div>
52
+ </div>
53
+ <div class="form-group auto" v-show="isarea">
54
+ <new-address-info v-ref:newaddressinfo v-if="type=='小区'" :areatype="areatype" :row="areaData" @addchild="addChild" @signout="signOut"></new-address-info>
55
+ </div>
56
+ <div class="form-group col-sm-12" v-show="!(type=='小区') || !isarea">
57
+ <button type="button" class="button_search button_spacing" @click="addChild" >保存</button>
58
+ <button type="button" class="button_clear button_spacing" @click="signOut">取消</button>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ </template>
63
+
64
+ <script>
65
+ import NewAddressInfo from './NewAddressInfo'
66
+ import {HttpResetClass} from 'vue-client'
67
+ // 提交地址
68
+ let asyncAddChild = async function(self, val) {
69
+ console.log('33333333333333333',val)
70
+ let result = null
71
+ let data = null
72
+ //新增 || 修改
73
+ if(val.id != null) {
74
+ console.log("asyncAddChild=" , val)
75
+ result = await self.$resetpost(`api/af-revenue/logic/address_addAddress`, val, {resolveMsg: null})
76
+ // 添加小区 t_area
77
+ if(val.f_type=='小区') {
78
+ let parent = await self.$resetpost(`api/af-revenue/logic/address_parent`, {id: val.id + ""}, {resolveMsg: null})
79
+ await self.$refs.newaddressinfo.confirm(result.data.id, parent.data)
80
+ }
81
+ } else {
82
+ // 子地址 || 根地址
83
+ if(val.f_parentId == null) {
84
+ data = {data: {f_parentId: null, condition: `f_locationId=${val.f_locationId} and f_locationType='${val.f_locationType}' and f_name='${val.f_name}'`}}
85
+ } else {
86
+ data = {data: {f_parentId: val.f_parentId.id, condition: `f_name='${val.f_name}'`}}
87
+ }
88
+ console.log('444444444444444',data)
89
+ result = await self.$resetpost('rs/path/address_getRoot', data, {resolveMsg: null})
90
+ console.log('55555555555555',result)
91
+ // 查询改地址是否已存在
92
+ console.log('666666666666666',result.data.length)
93
+ if(result.data.length > 0) {
94
+ alert("该地址已存在")
95
+ throw err = new Error( '该地址已存在' )
96
+ } else {
97
+ console.log("调剂的速度val: ", val)
98
+ result = await self.$resetpost(`api/af-revenue/logic/address_addAddress`, val, {resolveMsg: null})
99
+ // 添加小区 t_area
100
+ console.log("result=" , result)
101
+ if(result.data && val.f_type=='小区') {
102
+ let parent = await self.$resetpost(`api/af-revenue/logic/address_parent`, {id: result.data.id+""}, {resolveMsg: null})
103
+ await self.$refs.newaddressinfo.confirm(result.data.id, parent.data)
104
+ }
105
+ }
106
+ }
107
+ return result
108
+ }
109
+ // 获取地址
110
+ let asyncGetAddress = async function(self,num) {
111
+ let data = {data: {f_parentId: null, condition: `id='${self.f_parentid}'`}}
112
+ let result
113
+ if(num == 1){ //添加
114
+ result = await self.$resetpost('api/af-revenue/sql/address_getSelf', {data: {id: self.f_parentid}}, {resolveMsg: null})
115
+ } else { //修改
116
+ result = await self.$resetpost('api/af-revenue/sql/address_getParent', {data: {id: self.model.id}}, {resolveMsg: null})
117
+ }
118
+ if(result.data.length > 0) {
119
+ self.parent = result.data[0]
120
+ } else {
121
+ self.parent = {}
122
+ }
123
+ return result
124
+ }
125
+
126
+ export default {
127
+ name: "AddressAddAddress",
128
+ components: {NewAddressInfo},
129
+ props: {
130
+ // 主键 id
131
+ row: {
132
+ type: Object,
133
+ },
134
+ // 父节点id
135
+ f_parentid: {
136
+ type: Number,
137
+ },
138
+ //位置
139
+ f_location: {
140
+ type: Object,
141
+ },
142
+ // 地址类型
143
+ type: {
144
+ type: String,
145
+ },
146
+ // 是否显示小区信息
147
+ isarea: {
148
+ type: Boolean,
149
+ default: false,
150
+ },
151
+ // 是否显示批量添加
152
+ isbasch: {
153
+ type: Boolean,
154
+ default: true
155
+ }
156
+ },
157
+ data() {
158
+ return {
159
+ model: {
160
+ id: null, //地址id
161
+ f_locationId: null, //位置id
162
+ f_locationType: null,//位置类型
163
+ f_parentId: null,//上级地址id
164
+ f_name: '', //地址名称
165
+ f_type: '', //地址类型
166
+ },
167
+ // 上级地址
168
+ parent: {},
169
+ // 小区信息
170
+ areaData: null,
171
+ // 小区 的 区名称
172
+ areatype: '',
173
+ isselected:true,
174
+ // 楼号
175
+ name_l: '',
176
+ name_l_t: '',
177
+ // 单元
178
+ name_d: '',
179
+ name_d_t: '',
180
+ // 楼层
181
+ name_c: '',
182
+ name_c_t: '',
183
+ // 门牌号
184
+ name_m: '',
185
+ name_m_t: '',
186
+ }
187
+ },
188
+ ready () {
189
+ if(this.row) {
190
+ this.model = Object.assign({}, this.model, this.row)
191
+ }
192
+ if(this.f_parentid) {
193
+ this.model.f_parentId = {id: this.f_parentid}
194
+ return this.init()
195
+ }
196
+ if(this.f_location) {
197
+ this.model.f_locationId = this.f_location.f_locationId
198
+ this.model.f_locationType = this.f_location.f_locationType
199
+ }
200
+ if(this.type!='') {
201
+ this.model.f_type = this.type
202
+ }
203
+ },
204
+ watch: {
205
+ 'f_location' (val) {
206
+ this.isselected = true
207
+ if(val) {
208
+ this.model.f_locationId = val.f_locationId
209
+ this.model.f_locationType = val.f_locationType
210
+ } else {
211
+ this.model.f_locationId = null
212
+ this.model.f_locationType = null
213
+ }
214
+ },
215
+ 'f_parentid' (val) {
216
+ this.isselected = true
217
+ // 添加
218
+ if(val) {
219
+ this.model.f_parentId = {id: val}
220
+ this.addinit(val)
221
+ } else {
222
+ this.model.f_parentId = null
223
+ this.parent = {}
224
+ }
225
+ },
226
+ 'type' (val) {
227
+ console.log("asdasd safffgg456756val", val)
228
+ this.isselected = true
229
+ if(val!='') {
230
+ this.model.f_type = val
231
+ }
232
+ },
233
+ 'row' (val) {
234
+ console.log("val", val)
235
+ this.isselected = true
236
+ if(val) {
237
+ this.getParent(val)
238
+ } else {
239
+ this.addArea()
240
+ }
241
+ }
242
+ },
243
+ methods: {
244
+
245
+ // 添加
246
+ async addinit(val){
247
+ let http = new HttpResetClass()
248
+ let res = await http.load('POST', 'api/af-revenue/sql/address_getSelf', {data: {id: this.f_parentid}}, {resolveMsg: null})
249
+ this.parent = res.data.length > 0 ? res.data[0]: {}
250
+ let parent = await http.load('POST', `api/af-revenue/logic/address_parent`, {id: val+""}, {resolveMsg: null, rejectMsg:'请求address_parent报错!!'})
251
+ this.areatype = parent.data.f_area
252
+ },
253
+ // 初始化
254
+ async init(num) {
255
+ let data = {data: {f_parentId: null, condition: `id='${this.f_parentid}'`}}
256
+ let result
257
+ if(num == 1){ //添加
258
+ result = await this.$resetpost('api/af-revenue/sql/address_getSelf', {data: {id: this.f_parentid}}, {resolveMsg: null})
259
+ } else { //修改
260
+ result = await this.$resetpost('api/af-revenue/sql/address_getParent', {data: {id: this.model.id}}, {resolveMsg: null})
261
+ }
262
+ if(result.data.length > 0) {
263
+ this.parent = result.data[0]
264
+ } else {
265
+ this.parent = {}
266
+ }
267
+ return result
268
+ },
269
+ //提交地址
270
+ addChild() {
271
+ // 判断是否是批量添加
272
+ if(!this.isselected && !(this.type=='小区') && this.isbasch) {
273
+ console.log("批量添加,上级id: ", this.model.f_parentId)
274
+ return this.baschAdd(this.model.f_parentId)
275
+ } else {
276
+ console.log('11111111111111111111',this.model)
277
+ let data = Object.assign({}, data, this.model)
278
+ console.log('2222222222222222',data)
279
+ let id = this.model.id
280
+ if(this.model.f_name != '') {
281
+ return asyncAddChild(this, data).then((res) => {
282
+ let result = data
283
+ result.id = res.data.id
284
+ this.model.f_name = ''
285
+ this.model.idstr = null
286
+ this.model.size = null
287
+ this.isselected = true
288
+ this.$parent.showAddress = !this.$parent.showAddress
289
+ this.initModel()
290
+ console.log("addChild", result)
291
+ if(id != null) { // 修改
292
+ this.$emit('updata-child-node', result)
293
+ } else { //新增
294
+ this.$emit('add-child-node', result)
295
+ }
296
+ }).catch((error) => {
297
+ this.$emit('error', error)
298
+ })
299
+ } else {
300
+ alert("名称和类型不能为空")
301
+ }
302
+ }
303
+ },
304
+ //返回
305
+ signOut() {
306
+ if (this.type === '小区') {
307
+ this.$refs.newaddressinfo.initModel()
308
+ }
309
+ this.model.f_name = ''
310
+ this.model.id = null
311
+ this.isselected = true
312
+ this.initModel()
313
+ this.$parent.showAddress = !this.$parent.showAddress
314
+ },
315
+ async baschAdd(id) {
316
+ if(!this.isselected) {
317
+ let batchs = new Array()
318
+ if(this.name_l != '') {
319
+ if(this.name_l_t == ''){
320
+ this.name_l_t = '号楼'
321
+ }
322
+ batchs.push({type: '楼号', names: this.name_l, n_type: this.name_l_t})
323
+ }
324
+ if(this.name_d != '') {
325
+ if(this.name_d_t == ''){
326
+ this.name_d_t = '单元'
327
+ }
328
+ batchs.push({type: '单元', names: this.name_d, n_type: this.name_d_t})
329
+ }
330
+ if(this.name_c != '') {
331
+ if(this.name_c_t == ''){
332
+ this.name_c_t = '层'
333
+ }
334
+ batchs.push({type: '楼层', names: this.name_c, n_type: this.name_c_t})
335
+ }
336
+ if(this.name_m != '') {
337
+ if(this.name_m_t == ''){
338
+ this.name_m_t = '号'
339
+ }
340
+ batchs.push({type: '门牌号', names: this.name_m, n_type: this.name_m_t})
341
+ }
342
+ console.log("批量添加baschAdd: ",batchs, " ", id)
343
+ this.$showMessage('将会占用几分钟!!', ['confirm', 'cancel']).then((res) => {
344
+ if (res === 'confirm') {
345
+ this.isselected = true
346
+ this.$parent.showAddress = !this.$parent.showAddress
347
+ let http = new HttpResetClass()
348
+ http.load('POST', 'api/af-revenue/logic/address_batch', {id: id.id+"", json: batchs}, {rejectMsg:'批量上传出错', resolveMsg: '地址导入完成'}, 0).then(() => {
349
+ this.$showMessage('导入完成。。!', ['confirm']).then((res) => {
350
+ if (res === 'confirm') {
351
+ this.initModel()
352
+ this.$emit('add-child-node')
353
+ }
354
+ })
355
+ })
356
+ }
357
+ })
358
+ // let http = new HttpResetClass()
359
+ // await http.load('POST', `api/af-revenue/logic/address_batch`, {id: id.id+"", json: batchs})
360
+ // this.isselected = true
361
+ // this.initModel()
362
+ // this.$parent.showAddress = !this.$parent.showAddress
363
+ // this.$emit('add-child-node')
364
+ }
365
+ },
366
+ // 新增
367
+ addArea() {
368
+ this.model.id = null
369
+ this.parent = {}
370
+ this.model.f_name = ''
371
+ if(this.type=='') {
372
+ this.model.f_type = ''
373
+ }
374
+ if(!this.f_location) {
375
+ this.model.f_locationId = null
376
+ this.model.f_locationType = null
377
+ }
378
+ if(!this.f_parentid){
379
+ this.model.f_parentId = null
380
+ }
381
+ this.areaData = null
382
+ },
383
+ //
384
+ async getParent(val) {
385
+ let http = new HttpResetClass()
386
+ let parent = await http.load('POST', `api/af-revenue/logic/address_parent`, {id: val.id+""}, {resolveMsg: null, rejectMsg:'请求address_parent报错!!'})
387
+ this.areatype = parent.data.f_area
388
+
389
+ this.model = Object.assign({}, this.model, val)
390
+
391
+ let res = await http.load('POST', 'api/af-revenue/sql/address_getParent', {data: {id: this.model.id}}, {resolveMsg: null, rejectMsg:'请求address_getParent报错!!'})
392
+ if(res.data.length > 0) {
393
+ this.parent = res.data[0]
394
+ } else {
395
+ this.parent = {}
396
+ }
397
+
398
+ if(val.id != null && this.type=='小区') {
399
+ let result = await http.load('POST','rs/path/address_getArea', {data: {id: val.id}}, {resolveMsg: null})
400
+ if(result.data.length > 0) {
401
+ this.areaData = result.data[0]
402
+ } else {
403
+ this.areaData = null
404
+ }
405
+ } else {
406
+ this.areaData = null
407
+ }
408
+ },
409
+
410
+ changetosingle(){
411
+ this.isselected = true
412
+ },
413
+ changetobatch(){
414
+ this.isselected = false
415
+ },
416
+ // 初始化参数
417
+ initModel() {
418
+ this.name_l = ''
419
+ this.name_l_t = ''
420
+ // 单元
421
+ this.name_d = ''
422
+ this.name_d_t = ''
423
+ // 楼层
424
+ this.name_c = ''
425
+ this.name_c_t = ''
426
+ // 门牌号
427
+ this.name_m = ''
428
+ this.name_m_t = ''
429
+ }
430
+ },
431
+ }
432
+ </script>
433
+
434
+ <style type="text/css" scoped>
435
+ *{
436
+ margin: 0 auto;
437
+ text-align: center;
438
+ }
439
+ div {
440
+ margin-top: 10px;
441
+ }
442
+ .btngroup{
443
+ height: 32px;
444
+ width: 92px;
445
+ }
446
+ .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle){
447
+ border-radius: 4px;
448
+ border-bottom-right-radius: 0;
449
+ border-top-right-radius: 0;
450
+ }
451
+ .add{
452
+ font-family: PingFangSC-Medium;
453
+ font-size: 24px;
454
+ color: #333333;
455
+ }
456
+ .shangji{
457
+ font-family: PingFangSC-Medium;
458
+ font-size: 16px;
459
+ color: #666666;
460
+ }
461
+ .name{
462
+ font-family: PingFangSC-Bold;
463
+ font-size: 16px;
464
+ color: #333333;
465
+ }
466
+ .margintop{
467
+ margin-top: 20px;
468
+ }
469
+ .input{
470
+ background-color: #FFFFFF;
471
+ border: 1px solid #999999;
472
+ }
473
+ .remark{
474
+ font-family: PingFangSC-Medium;
475
+ font-size: 14px;
476
+ color: #666666;
477
+ }
478
+
479
+ </style>