You've already forked guangan
全流程
This commit is contained in:
@ -10,7 +10,12 @@ class TicketRepair extends Auth
|
||||
|
||||
public function list()
|
||||
{
|
||||
$query = Model::query()->scope(['notFinish'])->with(['ticket'])->where(['staff_id'=>$this->staff->id]);
|
||||
$query = Model::query()->with(['ticket'])->where(['staff_id'=>$this->staff->id]);
|
||||
$query->order('create_at', 'desc');
|
||||
$status = $this->request->get('status/i', null);
|
||||
if (is_numeric($status)) {
|
||||
$query->where('status', '=', $status);
|
||||
}
|
||||
$keyword = $this->request->get('keyword', null);
|
||||
if ($keyword) {
|
||||
$query->where('title', 'like', "%{$keyword}%");
|
||||
@ -19,4 +24,41 @@ class TicketRepair extends Auth
|
||||
$this->success('获取工单列表', $pageData);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->request->get('id', null);
|
||||
$data = Model::query()->with(['ticket'])->where('staff_id', '=', $this->staff->id)->where(['id'=>$id])->find();
|
||||
if (!$data) {
|
||||
$this->error('工单不存在');
|
||||
}
|
||||
$this->success('获取工单详情', $data);
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$data = $this->_vali([
|
||||
'ticket_id.require' => '工单ID不能为空',
|
||||
'content.require' => '工单内容不能为空',
|
||||
'imgs.default' => '',
|
||||
]);
|
||||
$ticket = Model::query()->with(['ticket'])->where('staff_id', '=', $this->staff->id)->where(['id'=>$data['ticket_id']])->find();
|
||||
if (!$ticket) {
|
||||
$this->error('工单不存在');
|
||||
}
|
||||
unset($data['ticket_id']);
|
||||
if ($ticket->status === 1) {
|
||||
$this->error('工单已提交');
|
||||
}
|
||||
if ($ticket->status === 2) {
|
||||
$this->error('工单已关闭');
|
||||
}
|
||||
try {
|
||||
$data['status'] = 1;
|
||||
$ticket->finish_at = date('Y-m-d H:i:s');
|
||||
$ticket->save($data);
|
||||
} catch (\Exception $exception) {
|
||||
$this->error('工单提交失败');
|
||||
}
|
||||
$this->success('工单提交成功');
|
||||
}
|
||||
}
|
@ -10,7 +10,12 @@ class TicketVerify extends Auth
|
||||
|
||||
public function list()
|
||||
{
|
||||
$query = Model::query()->scope(['notFinish'])->with(['ticket'])->where(['staff_id'=>$this->staff->id]);
|
||||
$query = Model::query()->with(['ticket'])->where(['staff_id'=>$this->staff->id]);
|
||||
$query->order('create_at', 'desc');
|
||||
$status = $this->request->get('status/i', null);
|
||||
if (is_numeric($status)) {
|
||||
$query->where('status', '=', $status);
|
||||
}
|
||||
$keyword = $this->request->get('keyword', null);
|
||||
if ($keyword) {
|
||||
$query->where('title', 'like', "%{$keyword}%");
|
||||
@ -19,4 +24,43 @@ class TicketVerify extends Auth
|
||||
$this->success('获取工单列表', $pageData);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->request->get('id', null);
|
||||
$data = Model::query()->with(['ticket'])->where('staff_id', '=', $this->staff->id)->where(['id'=>$id])->find();
|
||||
if (!$data) {
|
||||
$this->error('工单不存在');
|
||||
}
|
||||
$this->success('获取工单详情', $data);
|
||||
}
|
||||
|
||||
public function submit()
|
||||
{
|
||||
$data = $this->_vali([
|
||||
'ticket_id.require' => '工单ID不能为空',
|
||||
'content.require' => '工单内容不能为空',
|
||||
'is_error.in:0,1' => '请选择是否有异常',
|
||||
'imgs.default' => '',
|
||||
'work_days.default' => '',
|
||||
]);
|
||||
$ticket = Model::query()->with(['ticket'])->where('staff_id', '=', $this->staff->id)->where(['id'=>$data['ticket_id']])->find();
|
||||
if (!$ticket) {
|
||||
$this->error('工单不存在');
|
||||
}
|
||||
unset($data['ticket_id']);
|
||||
if ($ticket->status === 1) {
|
||||
$this->error('工单已提交');
|
||||
}
|
||||
if ($ticket->status === 2) {
|
||||
$this->error('工单已关闭');
|
||||
}
|
||||
try {
|
||||
$data['status'] = 1;
|
||||
$ticket->finish_at = date('Y-m-d H:i:s');
|
||||
$ticket->save($data);
|
||||
} catch (\Exception $exception) {
|
||||
$this->error('工单提交失败');
|
||||
}
|
||||
$this->success('工单提交成功');
|
||||
}
|
||||
}
|
@ -12,8 +12,8 @@ class TicketView extends Auth
|
||||
{
|
||||
$query = Model::query()->with(['ticket'])->where(['staff_id'=>$this->staff->id]);
|
||||
$query->order('create_at', 'desc');
|
||||
$status = $this->request->get('status', null);
|
||||
if ($status) {
|
||||
$status = $this->request->get('status/i', null);
|
||||
if (is_numeric($status)) {
|
||||
$query->where('status', '=', $status);
|
||||
}
|
||||
$keyword = $this->request->get('keyword', null);
|
||||
@ -56,6 +56,7 @@ class TicketView extends Auth
|
||||
}
|
||||
try {
|
||||
$data['status'] = 1;
|
||||
$ticket->finish_at = date('Y-m-d H:i:s');
|
||||
$ticket->save($data);
|
||||
} catch (\Exception $exception) {
|
||||
$this->error('工单提交失败');
|
||||
|
Reference in New Issue
Block a user