You've already forked guangan
工单
This commit is contained in:
@ -60,4 +60,69 @@ class Ticket extends Auth
|
|||||||
$ticket->save();
|
$ticket->save();
|
||||||
$this->success("工单创建成功", $ticket);
|
$this->success("工单创建成功", $ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function list()
|
||||||
|
{
|
||||||
|
$status = $this->request->get('status', null);
|
||||||
|
$query = TicketTicket::query(); // ->where(['fz_user_id'=>$this->staff->id])
|
||||||
|
if ($status) {
|
||||||
|
$query->where('staff_status', $status);
|
||||||
|
}
|
||||||
|
$pageData = $query->paginate();
|
||||||
|
$this->success('获取工单列表', $pageData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function info()
|
||||||
|
{
|
||||||
|
$id = $this->request->get('id');
|
||||||
|
$ticket = TicketTicket::query()
|
||||||
|
// ->where(['fz_user_id'=>$this->staff->id])
|
||||||
|
->with(['verify', 'repair'])->findOrEmpty($id);
|
||||||
|
if ($ticket->isEmpty()) $this->error('工单不存在');
|
||||||
|
$this->success('获取工单详情', $ticket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verify()
|
||||||
|
{
|
||||||
|
$id = $this->request->get('id');
|
||||||
|
/** @var TicketTicket $ticket */
|
||||||
|
$ticket = TicketTicket::query()->where(['fz_user_id'=>$this->staff->id])->findOrEmpty($id);
|
||||||
|
if ($ticket->isEmpty()) $this->error('工单不存在');
|
||||||
|
$data = $this->_vali([
|
||||||
|
'content.require' => '现场核实内容不能为空',
|
||||||
|
'imgs.default' => '',
|
||||||
|
'work_days.default' => '',
|
||||||
|
]);
|
||||||
|
$ticket->verify()->save([
|
||||||
|
'staff_id' => $this->staff->id,
|
||||||
|
'content' => $data['content'],
|
||||||
|
'imgs' => $data['imgs'],
|
||||||
|
'work_days' => $data['work_days']
|
||||||
|
]);
|
||||||
|
// 已现场核实
|
||||||
|
$ticket->staff_status = 1;
|
||||||
|
$ticket->save();
|
||||||
|
$this->success('工单现场核实成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function repair()
|
||||||
|
{
|
||||||
|
$id = $this->request->get('id');
|
||||||
|
/** @var TicketTicket $ticket */
|
||||||
|
$ticket = TicketTicket::query()->where(['fz_user_id'=>$this->staff->id])->findOrEmpty($id);
|
||||||
|
if ($ticket->isEmpty()) $this->error('工单不存在');
|
||||||
|
$data = $this->_vali([
|
||||||
|
'content.require' => '维修内容不能为空',
|
||||||
|
'imgs.default' => '',
|
||||||
|
]);
|
||||||
|
$ticket->repair()->save([
|
||||||
|
'staff_id' => $this->staff->id,
|
||||||
|
'content' => $data['content'],
|
||||||
|
'imgs' => $data['imgs'],
|
||||||
|
]);
|
||||||
|
// 已维修
|
||||||
|
$ticket->staff_status = 2;
|
||||||
|
$ticket->save();
|
||||||
|
$this->success('工单维修成功');
|
||||||
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ use think\admin\Model;
|
|||||||
|
|
||||||
class TicketRepair extends Model
|
class TicketRepair extends Model
|
||||||
{
|
{
|
||||||
|
protected $append = ['imgs_arr'];
|
||||||
public function ticket()
|
public function ticket()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(TicketTicket::class, 'ticket_id');
|
return $this->belongsTo(TicketTicket::class, 'ticket_id');
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
namespace plugin\ticket\model;
|
namespace plugin\ticket\model;
|
||||||
|
|
||||||
|
use plugin\inspection\model\InspectionStaff;
|
||||||
use think\admin\Model;
|
use think\admin\Model;
|
||||||
|
|
||||||
class TicketTicket extends Model
|
class TicketTicket extends Model
|
||||||
{
|
{
|
||||||
protected $append = ['status_text', 'type_name', 'dept_name'];
|
protected $append = ['status_text', 'type_name', 'dept_name', 'imgs_arr'];
|
||||||
protected $globalScope = ['unConf'];
|
protected $globalScope = ['unConf'];
|
||||||
protected $table = 'ticket_ticket';
|
protected $table = 'ticket_ticket';
|
||||||
public function type()
|
public function type()
|
||||||
@ -105,6 +106,11 @@ class TicketTicket extends Model
|
|||||||
return $this->belongsTo(TicketDept::class, 'dept_id');
|
return $this->belongsTo(TicketDept::class, 'dept_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fzUser()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(InspectionStaff::class, 'fz_user_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function verify()
|
public function verify()
|
||||||
{
|
{
|
||||||
return $this->hasMany(TicketVerify::class, 'ticket_id')->order('create_at', 'desc');
|
return $this->hasMany(TicketVerify::class, 'ticket_id')->order('create_at', 'desc');
|
||||||
|
@ -7,6 +7,7 @@ use think\admin\Model;
|
|||||||
|
|
||||||
class TicketVerify extends Model
|
class TicketVerify extends Model
|
||||||
{
|
{
|
||||||
|
protected $append = ['imgs_arr'];
|
||||||
public function ticket()
|
public function ticket()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(TicketTicket::class, 'ticket_id');
|
return $this->belongsTo(TicketTicket::class, 'ticket_id');
|
||||||
|
Reference in New Issue
Block a user