Skip to content

Commit 2b65120

Browse files
author
hikki
committed
v1 点线面
1 parent c3c8337 commit 2b65120

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

resources/assets/component.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,15 @@ function componentLine(name,columns,data) {
301301
dom.getElementsByClassName('JsonTableInsert')[0].appendChild(i);
302302
}
303303

304-
function componentPlane(url,method='POST'){
304+
function componentPlane(url,xhr_url='',method='POST'){
305+
if(xhr_url==''){
306+
xhr_url = url;
307+
}
305308
let Form = {
306-
make:function (url) {
309+
make:function () {
307310
this._clear();
308311
this._createModal();
309-
this._createBox(url);
312+
this._createBox();
310313
},
311314
_clear:function(){
312315
this._modalBodyNode = null;
@@ -320,25 +323,25 @@ function componentPlane(url,method='POST'){
320323
_boxBodyNode: null,
321324
_tableNode: null,
322325
_loadingNode:null,
323-
_request: function (url) {
326+
_request: function () {
324327
this._loading();
325328
_componentMegaBlock._request(url,'GET',{},function (response) {
326329
Form._loading(true);
327330
$('.modal-body').append(response);
328331
if($('.modal-body button[type="submit"]')) {
329332
$('.modal-body button[type="submit"]').click(function () {
330-
Form._submitEvent(this, url)
333+
Form._submitEvent(this)
331334
});
332335
}
333336
});
334337
},
335-
_submitEvent:function (obj,url) {
338+
_submitEvent:function (obj) {
336339
obj.setAttribute('disabled','disabled');
337340
obj.innerText = '提交中...';
338341
let form = Form._modalBodyNode.getElementsByTagName('form')[0];
339342
let formdata = new FormData(form);
340343

341-
_componentMegaBlock._request(url,method,formdata,function (response) {
344+
_componentMegaBlock._request(xhr_url,method,formdata,function (response) {
342345
if(response.code == 0) {
343346
window.location.reload();
344347
}else{
@@ -349,7 +352,7 @@ function componentPlane(url,method='POST'){
349352
}
350353
});
351354
},
352-
_createBox: function (url) {
355+
_createBox: function () {
353356
let box = document.createElement("div");
354357
box.className = "box grid-box";
355358
let box_body = document.createElement("div");
@@ -358,7 +361,7 @@ function componentPlane(url,method='POST'){
358361
box.append(box_body);
359362
this._boxNode = box;
360363
this._boxBodyNode = box_body;
361-
this._request(url);
364+
this._request();
362365
return;
363366
},
364367
_loading: function (remove = false) {
@@ -428,8 +431,4 @@ function componentPlane(url,method='POST'){
428431
}
429432
};
430433
Form.make(url)
431-
}
432-
433-
434-
435-
434+
}

src/DLPViewer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static function makeAddFormAction(Grid $grid)
139139
$url = Request::capture()->getPathInfo();
140140
Admin::script(<<<EOF
141141
$('.CAForm').click(function(){
142-
componentPlane('{$url}/create');
142+
componentPlane('{$url}/create','{$url}/store');
143143
});
144144
EOF
145145
);
@@ -170,8 +170,8 @@ public static function makeEditFormAction(Grid $grid)
170170
$url = Request::capture()->getPathInfo();
171171
Admin::script(<<<EOF
172172
$('.CEForm').click(function(){
173-
let url = '{$url}' + '/'+this.getAttribute('data-id') + '/edit';
174-
componentPlane(url);
173+
let url = '{$url}' + '/'+this.getAttribute('data-id');
174+
componentPlane(url+'/edit',url,'PUT');
175175
});
176176
EOF
177177
);
@@ -197,8 +197,8 @@ public static function _makeEditFormAction(Grid &$grid)
197197
$url = Request::capture()->getPathInfo();
198198
Admin::script(<<<EOF
199199
$('.CEForm').click(function(){
200-
let url = '{$url}' + '/'+this.getAttribute('data-id') + '/edit';
201-
componentPlane(url);
200+
let url = '{$url}' + '/'+this.getAttribute('data-id');
201+
componentPlane(url+'/edit',url,'PUT');
202202
});
203203
EOF
204204
);

0 commit comments

Comments
 (0)