5 changed files with 301 additions and 6 deletions
-
7MySQL_change.sql
-
84app/AdminAgent/Controllers/IndustryOrderController.php
-
28app/AdminSupplier/Controllers/IndustryOrderController.php
-
88app/AdminSupplier/Extensions/Grid/IndustryOrderAudit.php
-
100app/Http/Controllers/Api/TestController.php
@ -0,0 +1,88 @@ |
|||
<?php |
|||
|
|||
namespace App\AdminSupplier\Extensions\Grid; |
|||
|
|||
use App\Common\OrderStatus; |
|||
use App\Models\IndustryOrder; |
|||
use App\Models\IndustryProduct; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Illuminate\Http\Request; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
/** |
|||
* 供应商审核 |
|||
* Class AuditSupplier |
|||
* @package App\Admin\Extensions\Grid |
|||
*/ |
|||
class IndustryOrderAudit extends RowAction |
|||
{ |
|||
private $action; |
|||
|
|||
public function __construct($title = null, $action = 1) |
|||
{ |
|||
parent::__construct($title); |
|||
$this->action = $action; //$action:1=通过;2=拒绝
|
|||
$this->title = $action == 1 ? '通过' : '拒绝'; |
|||
} |
|||
|
|||
protected function html() |
|||
{ |
|||
$class = $this->action == 1 ? 'btn btn-sm btn-success' : 'btn btn-sm btn-danger'; |
|||
$this->appendHtmlAttribute('class', $class); |
|||
$this->defaultHtmlAttribute('href', 'javascript:;'); |
|||
|
|||
return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>"; |
|||
} |
|||
|
|||
protected function actionScript() |
|||
{ |
|||
if ($this->action == 2) { |
|||
return <<<JS |
|||
function (data, target, action) { |
|||
data.audit_opinion = prompt('请输入拒绝理由'); |
|||
if (!data.audit_opinion) { |
|||
return false; |
|||
} |
|||
} |
|||
JS; |
|||
} |
|||
return parent::actionScript(); |
|||
} |
|||
|
|||
public function handle(Request $request) |
|||
{ |
|||
$id = $this->getKey(); |
|||
$status = $request->action == 1 ? 1 : -1; |
|||
|
|||
try { |
|||
$order = IndustryOrder::where('audit_status', 0)->find($id); |
|||
if (!$order) { |
|||
throw new \Exception('订单不存在或已经审核过了'); |
|||
} |
|||
|
|||
if (!is_null($request->audit_opinion)) { |
|||
$order->audit_opinion = $request->audit_opinion; |
|||
} |
|||
$order->audit_status = $status; |
|||
$order->save(); |
|||
|
|||
return $this->response()->success('操作成功')->refresh(); |
|||
} catch (\Exception $e) { |
|||
return $this->response()->error($e->getMessage())->refresh(); |
|||
} |
|||
} |
|||
|
|||
public function confirm() |
|||
{ |
|||
if ($this->action == 1) { |
|||
return ['确定要设置为已通过吗?', '']; |
|||
} |
|||
} |
|||
|
|||
public function parameters() |
|||
{ |
|||
return [ |
|||
'action' => $this->action, |
|||
]; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue