address-client 4.0.2 → 4.0.4-1

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.
@@ -0,0 +1,324 @@
1
+ <template>
2
+ <div class="span">
3
+ <validator name='v'>
4
+ <p class="bg-info text-center" style="padding: 8px;" v-if="operation=='add'">添加{{areatype}}</p>
5
+ <p class="bg-info text-center" style="padding: 8px;" v-if="operation=='modify'&&areatype=='街道'">修改【{{streetmodel.f_street}}】街道</p>
6
+ <p class="bg-info text-center" style="padding: 8px;" v-if="operation=='modify'&&areatype=='省市区'">修改【{{pcdmodel.f_pcd}}】</p>
7
+ <div class="auto select-overspread form-horizontal">
8
+ <div style="text-align:right;margin-top:6px;" class="col-sm-12">
9
+ <!-- 省市区-->
10
+ <div v-if="areatype=='省市区'" class="row">
11
+ <div class="col-sm-6 form-group "
12
+ :class="[$v.f_province.required ? 'has-error' : 'has-success']">
13
+ <label class="font_normal_body">省&emsp;&emsp;份</label>
14
+ <input type="text" v-model="pcdmodel.f_province"
15
+ class="input_search" style="width:60%" placeholder="省份"
16
+ v-validate:f_province='{required: true }'>
17
+ </div>
18
+ <div class="col-sm-6 form-group "
19
+ :class="[$v.f_city.required ? 'has-error' : 'has-success']">
20
+ <label class="font_normal_body">城&emsp;&emsp;市</label>
21
+ <input type="text" v-model="pcdmodel.f_city"
22
+ class="input_search" style="width:60%" placeholder="城市"
23
+ v-validate:f_city='{required: true }'>
24
+ </div>
25
+ <div class="col-sm-6 form-group "
26
+ :class="[$v.f_district.required ? 'has-error' : 'has-success']">
27
+ <label class="font_normal_body">区&ensp;&ensp;/&ensp;县</label>
28
+ <input type="text" v-model="pcdmodel.f_district"
29
+ class="input_search" style="width:60%" placeholder="区/县"
30
+ v-validate:f_district='{required: true }'>
31
+ </div>
32
+ <div class="col-sm-6 form-group " v-if="config.hasnumber"
33
+ :class="[$v.f_pcd_number.required ? 'has-error' : 'has-success']">
34
+ <label class="font_normal_body">区域编码</label>
35
+ <input type="number" v-model="pcdmodel.f_pcd_number"
36
+ class="input_search" style="width:60%" placeholder="区/县"
37
+ @change="numberyanzheng"
38
+ v-validate:f_pcd_number='{required: true }'>
39
+ </div>
40
+ <div class="col-sm-12 form-group">
41
+ <label class="font_normal_body " style="">备&emsp;&emsp;注</label>
42
+ <textarea class="input_textarea" rows="3" style="margin-top:25px;width:80%;height: auto;" v-model="pcdmodel.f_comments"></textarea>
43
+ </div>
44
+ </div>
45
+ <!-- 街道-->
46
+ <div v-if="areatype=='街道'" class="row">
47
+ <div class="col-sm-6 form-group "
48
+ :class="[$v.f_pcd_id.required ? 'has-error' : 'has-success']">
49
+ <label class="font_normal_body">省&ensp;市&ensp;区</label>
50
+ <input type="text" v-show="false" v-model="streetmodel.f_pcd_id"
51
+ v-validate:f_pcd_id='{required: true }'>
52
+ <v-select
53
+ :value.sync="streetmodel.f_pcd_id" :value-single="true"
54
+ :options='pcdslist' placeholder='请选择'
55
+ close-on-select search="true" @change="pcdChange">
56
+ </v-select>
57
+ </div>
58
+ <div class="col-sm-6 form-group "
59
+ :class="[$v.f_street.required ? 'has-error' : 'has-success']">
60
+ <label class="font_normal_body">街道/乡镇</label>
61
+ <input type="text" v-model="streetmodel.f_street"
62
+ class="input_search" style="width:60%" placeholder="街道/乡镇"
63
+ v-validate:f_street='{required: true }'>
64
+ </div>
65
+ <div class="col-sm-6 form-group " v-if="config.hasnumber"
66
+ :class="[$v.f_street_number.required ? 'has-error' : 'has-success']">
67
+ <label class="font_normal_body">街道编号</label>
68
+ <input type="text" v-model="streetmodel.f_street_number"
69
+ @change="streetyanzheng"
70
+ class="input_search" style="width:60%" placeholder="街道编号"
71
+ v-validate:f_street_number='{required: true }'>
72
+ </div>
73
+ <div class="col-sm-6 form-group "
74
+ :class="[$v.f_iscity.required ? 'has-error' : 'has-success']">
75
+ <label class="font_normal_body">地区类型</label>
76
+ <input type="text" v-show="false" v-model="streetmodel.f_iscity"
77
+ v-validate:f_iscity='{required: true }'>
78
+ <v-select
79
+ :value.sync="streetmodel.f_iscity" :value-single="true"
80
+ :options='iscity' placeholder='请选择'
81
+ close-on-select>
82
+ </v-select>
83
+ </div>
84
+ <div class="col-sm-12 form-group">
85
+ <label class="font_normal_body " style="">备&emsp;&emsp;注</label>
86
+ <textarea class="input_textarea" rows="3" style="margin-top:25px;width:80%;height: auto;" v-model="streetmodel.f_comments"></textarea>
87
+ </div>
88
+ </div>
89
+
90
+ <div class="row">
91
+ <div style="margin-top:40px;text-align:right;">
92
+ <button class="button_search button_spacing" @click="confirm()" :disabled='!$v.valid || !this.validateCanSave()' >保存</button>
93
+ <button class="button_clear button_spacing" @click="cancel()">取消</button>
94
+ </div>
95
+ <div v-if="areatype=='省市区'" class="row" style="margin-top:40px;height: 580px;">
96
+ <city-list v-ref:addpcd @select-changed="selected" :f_filialeids.sync="f_filialeids"></city-list>
97
+ </div>
98
+ </div>
99
+ </div>
100
+ </validator>
101
+ </div>
102
+ </template>
103
+
104
+ <script>
105
+ import {HttpResetClass} from 'vue-client'
106
+
107
+ let getAreaConfig = async function (self) {
108
+ // 获取气价里面的配置
109
+ await self.$getConfig(self, 'UserPcd')
110
+ console.log('原地址配置',self.config)
111
+ console.log('获取地址配置',self.config)
112
+ Object.assign(self.model, self.config)
113
+ }
114
+ export default {
115
+ title: '区域地址添加',
116
+ data () {
117
+ return {
118
+ canSave: true,
119
+ //初始化省市区数据
120
+ config:{
121
+ hasnumber: false
122
+ },
123
+ pcdslist:[],
124
+ iscity:[{label:'市区',value:'市区'},{label:'乡镇',value:'乡镇'}],
125
+ //省市区
126
+ pcdmodel: {
127
+ f_province:'',
128
+ f_city:'',
129
+ f_district:'',
130
+ f_comments:'',
131
+ f_pcd_number: ''
132
+ },
133
+ //街道
134
+ streetmodel: {
135
+ f_pcd_id:'',
136
+ f_street_id:'',
137
+ slice_area: null,
138
+ f_slice_area: null,
139
+ f_adjustable_id: null,
140
+ f_street:'',
141
+ f_comments:'',
142
+ f_street_number:''
143
+ }
144
+ }
145
+ },
146
+ props: ['f_filialeids', 'areatype','row','operation'],
147
+ ready(){
148
+ this.initdata()
149
+ getAreaConfig(this)
150
+ },
151
+ methods: {
152
+ validateCanSave() {
153
+ this.canSave = this.$login.r.includes('区域地址修改权限')
154
+ if (!this.canSave) {
155
+ this.$showAlert('您没有权限进行保存操作', 'warning', 1500)
156
+ }
157
+ return this.canSave
158
+ },
159
+ async streetyanzheng(){
160
+ console.log(this.streetmodel.f_street_number.length)
161
+ let res =await this.$resetpost('api/af-revenue/sql/address_singleTableOrderBy', {
162
+ data: {
163
+ items: '*',
164
+ tablename: 't_street',
165
+ orderitem: 'id',
166
+ condition: `f_street_number = '${this.streetmodel.f_street_number}' and f_orgid = '${this.$login.f.orgid}'`
167
+ }
168
+ }, {resolveMsg: null, rejectMsg: null})
169
+ if (res.data.length>0){
170
+ if (res.data[0].id != this.streetmodel.id) {
171
+ this.$showAlert('当前编号已存在', 'warning', 2000)
172
+ this.streetmodel.f_street_number = ''
173
+ }
174
+ }
175
+ },
176
+ async numberyanzheng(){
177
+ console.log(this.pcdmodel.f_pcd_number.length)
178
+ if (this.pcdmodel.f_pcd_number.length != 3){
179
+ this.$showAlert('请输入正确的位数', 'warning', 2000)
180
+ this.pcdmodel.f_pcd_number = ''
181
+ }else{
182
+ let res =await this.$resetpost('api/af-revenue/sql/address_singleTableOrderBy', {
183
+ data: {
184
+ items: '*',
185
+ tablename: 't_pcd',
186
+ orderitem: 'id',
187
+ condition: `f_pcd_number = '${this.pcdmodel.f_pcd_number}' and f_orgid = '${this.$login.f.orgid}'`
188
+ }
189
+ }, {resolveMsg: null, rejectMsg: null})
190
+ if (res.data.length>0){
191
+ if (res.data[0].id != this.pcdmodel.id) {
192
+ this.$showAlert('当前编号已存在', 'warning', 2000)
193
+ this.pcdmodel.f_pcd_number = ''
194
+ }
195
+ }
196
+ }
197
+ },
198
+ //初始化省市区,添加街道
199
+ initpcds(pconditon){
200
+ console.log("省市区准备")
201
+ let HttpReset = new HttpResetClass()
202
+ HttpReset.load('POST', 'api/af-revenue/sql/address_singleTableOrderBy', {
203
+ data: {
204
+ items: '*',
205
+ tablename: 't_pcd',
206
+ orderitem: 'id',
207
+ condition: pconditon
208
+ }
209
+ }, {resolveMsg: null, rejectMsg: '获取地址失败!'}).then((req) => {
210
+ let redata = []
211
+ req.data.forEach((row, n) => {
212
+ redata[n] = {
213
+ label: row.f_pcd,
214
+ value: row.id,
215
+ data:row,
216
+ id:row.id
217
+ }
218
+ })
219
+ this.pcdslist=redata
220
+ })
221
+ },
222
+ //根据名字找数据
223
+ findbyid(list,name){
224
+ var result
225
+ list.forEach((row, n) => {
226
+ if(name==row.id){
227
+ result= row.data
228
+ }
229
+ })
230
+ return result
231
+ },
232
+ //初始化数据
233
+ initdata(){
234
+ if(this.areatype=='街道'){
235
+ this.initpcds(` f_filialeid = '${this.f_filialeids}'`)
236
+ }
237
+ if(this.areatype=='小区'){
238
+ this.initpcds(` f_filialeid = '${this.f_filialeids}'`)
239
+ this.initstreets(` f_filialeid = '${this.f_filialeids}'`)
240
+ }
241
+ },
242
+ //省/市/区变化
243
+ pcdChange(val){
244
+ console.log("省/市/区变化",val)
245
+ this.$resetValidation()
246
+ },
247
+ //保存
248
+ async confirm(){
249
+ if(this.areatype=='省市区'){
250
+ await this.savepcd()
251
+ this.$refs.addpcd.search()
252
+ }
253
+ if(this.areatype=='街道'){
254
+ await this.savestreet()
255
+ }
256
+ this.cleardara()
257
+ this.$dispatch('confirm')
258
+ },
259
+ //保存省市区
260
+ async savepcd(){
261
+ this.pcdmodel.f_filialeid = this.f_filialeids
262
+ this.pcdmodel.f_operator = this.$login.f.name
263
+ this.pcdmodel.f_operatorid = this.$login.f.id
264
+ this.pcdmodel.f_orgid = this.$login.f.orgid
265
+ this.pcdmodel.f_orgname = this.$login.f.orgs
266
+ this.pcdmodel.f_depid = this.$login.f.depids
267
+ this.pcdmodel.f_depname = this.$login.f.deps
268
+ this.pcdmodel.f_pcd = this.pcdmodel.f_province+this.pcdmodel.f_city+this.pcdmodel.f_district
269
+ await this.$resetpost('api/af-revenue/logic/address_updatepcd', this.pcdmodel)
270
+ },
271
+ //保存街道
272
+ async savestreet(){
273
+ this.streetmodel.f_filialeid = this.f_filialeids
274
+ this.streetmodel.f_operator= this.$login.f.name
275
+ this.streetmodel.f_operatorid = this.$login.f.id
276
+ this.streetmodel.f_orgid = this.$login.f.orgid
277
+ this.streetmodel.f_orgname = this.$login.f.orgs
278
+ this.streetmodel.f_depid = this.$login.f.depids
279
+ this.streetmodel.f_depname = this.$login.f.deps
280
+ this.streetmodel.f_pcd=this.findbyid(this.pcdslist,this.streetmodel.f_pcd_id).f_pcd
281
+ console.log('获取街道model', this.streetmodel)
282
+ await this.$resetpost('api/af-revenue/logic/address_updatestreet', this.streetmodel)
283
+ },
284
+ cancel(){
285
+ this.cleardara()
286
+ this.$dispatch('cancel')
287
+ },
288
+ cleardara () {
289
+ this.pcdmodel = {
290
+ f_province: '',
291
+ f_city: '',
292
+ f_district: '',
293
+ f_comments:''
294
+ }
295
+ this.streetmodel = {
296
+ f_pcd_id: '',
297
+ f_slice_area: '',
298
+ f_adjustable_id: '',
299
+ f_street: '',
300
+ f_comments:''
301
+ }
302
+ }
303
+
304
+ },
305
+ watch: {
306
+ 'areatype'(){
307
+ this.initdata()
308
+ },
309
+ 'f_filialeids'(){
310
+ if (this.streetmodel.f_filialeid) {
311
+ if (this.streetmodel.f_filialeid != this.f_filialeids) {
312
+ this.$dispatch('cancel')
313
+ }
314
+ }
315
+ if (this.pcdmodel.f_filialeid) {
316
+ if (this.pcdmodel.f_filialeid != this.f_filialeids) {
317
+ this.$dispatch('cancel')
318
+ }
319
+ }
320
+ this.initdata()
321
+ }
322
+ }
323
+ }
324
+ </script>