Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc5bf66b

Browse files
committed
modify apijson-table prop from table_name to model_name, add request_tag prop
1 parent5559694 commitc5bf66b

File tree

2 files changed

+37
-26
lines changed

2 files changed

+37
-26
lines changed

‎demo/apps/tables/templates/Tables/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<divid="app">
1111
<tabsv-model:value="tab_current"type="card">
1212
<tab-panev-for="item in tabs":key="item":label="item":name="item">
13-
<apijson-table:table_name="item":config="apijson_tables[item]"></apijson-table>
13+
<apijson-table:model_name="item":config="apijson_tables[item]"></apijson-table>
1414
</tab-pane>
1515
</tabs>
1616
</div>

‎uliweb_apijson/apijson/templates/vue/inc_apijson_table.html

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
Vue.component('apijson-table',{
33
delimiters:['{','}'],
44
props:[
5-
"table_name",
5+
"model_name",//apijson model name
6+
"request_tag",//apijson request tag, default will be same with model name
67
"config",
78
"custom_tcolumns_render_generator",
89
"hook_init",
@@ -44,12 +45,14 @@
4445
</div>
4546
</modal>
4647
<modal v-model="modal_delete" title="Confirm to delete" @on-ok="real_remove">
47-
<p>Confirm to delete #{delete_params.row&&delete_params.row.id} in table '{table_name}'?</p>
48+
<p>Confirm to delete #{delete_params.row&&delete_params.row.id} in table '{model_name}'?</p>
4849
</modal>
4950
</div>`,
5051
data:function(){
5152
varthisp=this
5253
return{
54+
l_request_tag:null,
55+
5356
loading:false,
5457
modal_view:false,
5558
viewedit_items:[],
@@ -172,7 +175,7 @@
172175
"@page":thisp.current_page-1,
173176
"@query":2
174177
}
175-
arr_params[this.table_name]={
178+
arr_params[this.model_name]={
176179
"@order":thisp.sort_key+thisp.sort_order,
177180
"@role":"{{=role}}"
178181
}
@@ -225,7 +228,7 @@
225228
}
226229
else{
227230
thisp.$Notice.error({
228-
title:'error when get table '+thisp.table_name,
231+
title:'error when get table '+thisp.model_name,
229232
desc:data.msg
230233
})
231234
}
@@ -276,18 +279,19 @@
276279
save:function(){
277280
varthisp=this
278281
varparams={
279-
"@tag":thisp.table_name
282+
"@tag":thisp.l_request_tag
280283
}
281284
varrecord_params={}
282285
varrow=thisp.edit_params.row
283286

287+
//only save modified fields
284288
for(varkinthisp.viewedit_items){
285289
vard=thisp.viewedit_items[k]
286290
if(d.key=="id"||d.value!=row[d.key]){
287291
record_params[d.key]=d.value
288292
}
289293
}
290-
params[thisp.table_name]=record_params
294+
params[thisp.l_request_tag]=record_params
291295
params=thisp.ajax_hook("apijson_put","update",params)
292296
$.ajax({
293297
type:"POST",
@@ -297,15 +301,15 @@
297301
success:function(data){
298302
if(data.code==200){
299303
thisp.$Notice.success({
300-
title:'success update #'+row.id+' in table '+thisp.table_name,
304+
title:'success update #'+row.id+' in table '+thisp.model_name,
301305
desc:data.msg
302306
})
303307
thisp.modal_view=false
304308
thisp.update_list()
305309
}
306310
else{
307311
thisp.$Notice.error({
308-
title:'error when update #'+row.id+' in table '+thisp.table_name,
312+
title:'error when update #'+row.id+' in table '+thisp.model_name,
309313
desc:data.msg
310314
})
311315
}
@@ -323,13 +327,13 @@
323327
real_remove_set_deleted:function(){
324328
varthisp=this
325329
varparams={
326-
"@tag":thisp.table_name
330+
"@tag":thisp.l_request_tag
327331
}
328332
varparams_table={
329333
"id":thisp.delete_params.row.id,
330334
}
331335
params_table[this.config_deleted_field_name]=true
332-
params[thisp.table_name]=params_table
336+
params[thisp.l_request_tag]=params_table
333337

334338
params=thisp.ajax_hook("apijson_put","delete",params)
335339

@@ -341,21 +345,21 @@
341345
success:function(data){
342346
if(data.code!=200){
343347
thisp.$Notice.error({
344-
title:'error when remove #'+thisp.delete_params.row.id+' in table '+thisp.table_name,
348+
title:'error when remove #'+thisp.delete_params.row.id+' in table '+thisp.model_name,
345349
desc:data.msg
346350
})
347351
return
348352
}
349-
varresult=data[thisp.table_name]
353+
varresult=data[thisp.l_request_tag]
350354
if(result.code!=200){
351355
thisp.$Notice.error({
352-
title:'error when remove #'+thisp.delete_params.row.id+' in table '+thisp.table_name,
356+
title:'error when remove #'+thisp.delete_params.row.id+' in table '+thisp.model_name,
353357
desc:result.msg
354358
})
355359
return
356360
}
357361
thisp.$Notice.success({
358-
title:'success remove #'+thisp.delete_params.row.id+' in table '+thisp.table_name,
362+
title:'success remove #'+thisp.delete_params.row.id+' in table '+thisp.model_name,
359363
desc:result.msg
360364
})
361365
thisp.update_list()
@@ -365,9 +369,9 @@
365369
real_remove_delete:function(){
366370
varthisp=this
367371
varparams={
368-
"@tag":thisp.table_name
372+
"@tag":thisp.l_request_tag
369373
}
370-
params[thisp.table_name]={
374+
params[thisp.l_request_tag]={
371375
"id":thisp.delete_params.row.id
372376
}
373377
params=thisp.ajax_hook("apijson_delete","delete",params)
@@ -379,21 +383,21 @@
379383
success:function(data){
380384
if(data.code!=200){
381385
thisp.$Notice.error({
382-
title:'error when remove #'+thisp.delete_params.row.id+' in table '+thisp.table_name,
386+
title:'error when remove #'+thisp.delete_params.row.id+' in table '+thisp.model_name,
383387
desc:data.msg
384388
})
385389
return
386390
}
387-
varresult=data[thisp.table_name]
391+
varresult=data[thisp.l_request_tag]
388392
if(result.code!=200){
389393
thisp.$Notice.error({
390-
title:'error when remove #'+thisp.delete_params.row.id+' in table '+thisp.table_name,
394+
title:'error when remove #'+thisp.delete_params.row.id+' in table '+thisp.model_name,
391395
desc:result.msg
392396
})
393397
return
394398
}
395399
thisp.$Notice.success({
396-
title:'success remove #'+thisp.delete_params.row.id+' in table '+thisp.table_name,
400+
title:'success remove #'+thisp.delete_params.row.id+' in table '+thisp.model_name,
397401
desc:result.msg
398402
})
399403
thisp.update_list()
@@ -411,14 +415,14 @@
411415
real_add:function(){
412416
thisp=this
413417
varparams={
414-
"@tag":thisp.table_name
418+
"@tag":thisp.l_request_tag
415419
}
416420
varpost_params={}
417421
for(varkinthisp.add_items){
418422
vard=thisp.add_items[k]
419423
post_params[d.key]=d.value
420424
}
421-
params[this.table_name]=post_params
425+
params[this.l_request_tag]=post_params
422426
params=thisp.ajax_hook("apijson_post","add",params)
423427
$.ajax({
424428
type:"POST",
@@ -428,14 +432,14 @@
428432
success:function(data){
429433
if(data.code!=200){
430434
thisp.$Notice.error({
431-
title:'error when add new record in table '+thisp.table_name,
435+
title:'error when add new record in table '+thisp.model_name,
432436
desc:data.msg
433437
})
434438
return
435439
}
436-
varresult=data[thisp.table_name]
440+
varresult=data[thisp.l_request_tag]
437441
thisp.$Notice.success({
438-
title:'success add #'+result.id+' in table '+thisp.table_name,
442+
title:'success add #'+result.id+' in table '+thisp.model_name,
439443
desc:result.msg
440444
})
441445
thisp.update_list()
@@ -456,6 +460,13 @@
456460
}
457461
},
458462
mounted:function(){
463+
if(this.request_tag==null){
464+
this.l_request_tag=this.model_name
465+
}
466+
else{
467+
this.l_request_tag=this.request_tag
468+
}
469+
459470
if(this.config!=null){
460471
this.config_editable=this.config.editable||false
461472
this.config_table_fields=this.config.table_fields||null

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp