|
1 | 1 | <script> |
2 | 2 | Vue.component('apijson-table', { |
3 | 3 | delimiters: ['{', '}'], |
4 | | - props: ["table_name","config","func_change_get_params"], |
| 4 | + props: ["table_name","config","func_change_params"], |
5 | 5 | template: `<div> |
6 | 6 | <div v-if="config_editable && config_add_fields!=null"><i-button type="primary" @click="add">Add</i-button> <br><br> </div> |
7 | 7 | <i-table stripe border :columns="tcolumns" :data="tlist" @on-sort-change="table_on_sort_change"></i-table> |
8 | 8 | <page :total="total" :page-size="query_count" :current.sync="current_page" :page-size-opts="[10, 20, 50, 100]" show-sizer @on-change="page_on_change" @on-page-size-change="page_on_page_size_change"></page> |
9 | | - <modal v-model="modal_add" title="Add" @on-ok="real_add"> |
| 9 | + <modal v-model="modal_add" title="Add"> |
10 | 10 | <i-form @submit.native.prevent :label-width="80"> |
11 | 11 | <form-item v-for="item in add_items" :key="item.key" :label="item.title"> |
12 | 12 | <i-input v-if="item.type=='input'" v-model="item.value"></i-input> |
13 | 13 | <checkbox v-if="item.type=='checkbox'" v-model="item.value"></checkbox> |
14 | 14 | <i-input v-if="item.type=='textarea'" v-model="item.value" type="textarea" :autosize="{minRows: 2,maxRows: 5}"></i-input> |
15 | 15 | </form-item> |
| 16 | + <form-item v-if="config_editable" label="action"> |
| 17 | + <i-button type="info" icon="plus" @click="real_add">Add</i-button> |
| 18 | + </form-item> |
16 | 19 | </i-form> |
17 | 20 | </modal> |
18 | 21 | <modal v-model="modal_view" :title="viewedit_label"> |
|
119 | 122 | "[]":arr_params, |
120 | 123 | "total@":"/[]/total" |
121 | 124 | } |
122 | | - if (thisp.func_change_get_params!=null) { |
123 | | - params = thisp.func_change_get_params(params) |
| 125 | + if (thisp.func_change_params!=null) { |
| 126 | + params = thisp.func_change_params("apijson_get",params) |
124 | 127 | } |
125 | 128 | $.ajax({ |
126 | 129 | type: "POST", |
|
219 | 222 | } |
220 | 223 | } |
221 | 224 | params[thisp.table_name] = record_params |
| 225 | + if (thisp.func_change_params!=null) { |
| 226 | + params = thisp.func_change_params("apijson_put",params) |
| 227 | + } |
222 | 228 | $.ajax({ |
223 | 229 | type: "POST", |
224 | 230 | url: "{{=url_for('uliweb_apijson.apijson.views.ApiJson.put')}}", |
|
230 | 236 | title: 'success update #'+row.id+' in table '+thisp.table_name, |
231 | 237 | desc: data.msg |
232 | 238 | }) |
| 239 | + thisp.modal_view = false |
233 | 240 | thisp.update_list() |
234 | 241 | } |
235 | 242 | else { |
|
296 | 303 | post_params[d.key] = d.value |
297 | 304 | } |
298 | 305 | params[this.table_name] = post_params |
299 | | - |
| 306 | + if (thisp.func_change_params!=null) { |
| 307 | + params = thisp.func_change_params("apijson_post",params) |
| 308 | + } |
300 | 309 | $.ajax({ |
301 | 310 | type: "POST", |
302 | 311 | url: "{{=url_for('uliweb_apijson.apijson.views.ApiJson.post')}}", |
|
316 | 325 | desc: result.msg |
317 | 326 | }) |
318 | 327 | thisp.update_list() |
| 328 | + thisp.modal_add = false |
319 | 329 | } |
320 | 330 | }) |
321 | 331 | }, |
|
0 commit comments