提交代码
This commit is contained in:
74
app/Admin/Actions/OrderRefundAgree.php
Normal file
74
app/Admin/Actions/OrderRefundAgree.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions\Actions;
|
||||
|
||||
use Encore\Admin\Admin;
|
||||
|
||||
class OrderRefundAgree
|
||||
{
|
||||
|
||||
protected $row;
|
||||
protected $resource;
|
||||
|
||||
public function __construct($row)
|
||||
{
|
||||
$this->row = $row;
|
||||
$this->resource = url()->current();
|
||||
}
|
||||
|
||||
protected function script()
|
||||
{
|
||||
return <<<SCRIPT
|
||||
$('.grid-deliver-row').unbind('click').click(function() {
|
||||
var id = $(this).data('id');
|
||||
swal({
|
||||
title: "确认要同意退款吗?",
|
||||
type: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "确认",
|
||||
showLoaderOnConfirm: true,
|
||||
cancelButtonText: "取消",
|
||||
preConfirm: function() {
|
||||
return new Promise(function(resolve) {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '{$this->resource}/' + id + '/agree',
|
||||
data: {
|
||||
_token:LA.token,
|
||||
},
|
||||
success: function (data) {
|
||||
$.pjax.reload('#pjax-container');
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}).then(function(result) {
|
||||
var data = result.value;
|
||||
console.log(data);
|
||||
if (typeof data === 'object') {
|
||||
if (data.status) {
|
||||
swal(data.message, '', 'success');
|
||||
} else {
|
||||
swal(data.message, '', 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
SCRIPT;
|
||||
}
|
||||
|
||||
protected function render()
|
||||
{
|
||||
Admin::script($this->script());
|
||||
|
||||
return "<button type='button' class='btn btn-xs btn-success grid-deliver-row' data-id='{$this->row->orderid}'>确认退款</button>";
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->render();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user