resource = admin_api_url(request()->path()); } /** * 设置request模式请求类型 * @param string $requestMethod * @return $this */ public function requestMethod(string $requestMethod) { $this->requestMethod = $requestMethod; return $this; } /** * 确认操作提示信息 * @param mixed $message * @return $this */ public function message($message) { $this->message = $message; return $this; } /** * 按钮气泡信息 * @param mixed $tooltip * @return $this */ public function tooltip($tooltip) { $this->tooltip = $tooltip; return $this; } /** * 请求前出发事件 * @param string $beforeEmit * @param mixed $data * @return $this */ public function beforeEmit(string $beforeEmit, $data=null) { $this->beforeEmit = collect($this->beforeEmit)->push(["eventName" => $beforeEmit, "eventData" => $data]); return $this; } /** * 操作成功后触发事件 * @param string $successEmit * @param mixed $data * @return $this */ public function successEmit(string $successEmit, $data=null) { $this->successEmit = collect($this->successEmit)->push(["eventName" => $successEmit, "eventData" => $data]); return $this; } /** * 操作完成后触发事件,失败成功都会触发 * @param string $afterEmit * @param mixed $data * @return $this */ public function afterEmit(string $afterEmit, $data=null) { $this->afterEmit = collect($this->afterEmit)->push(["eventName" => $afterEmit, "eventData" => $data]); return $this; } /** * @return string */ public function getResource() { return $this->resource; } public function jsonSerialize() :array { $data = []; $hide = collect($this->hideAttrs)->push("hideAttrs")->toArray(); foreach ($this as $key => $val) { if (!in_array($key, $hide)) { $data[$key] = $val; } } return $data; } }