This commit is contained in:
2025-03-26 15:22:03 +08:00
parent 4a3911ba12
commit 92cc1c27f3
16 changed files with 565 additions and 227 deletions

View File

@ -81,16 +81,8 @@ class Ticket extends Controller
{
$this->title = '工单详情';
['id' => $id] = $this->_vali(['id.require' => '请指定工单ID!']);
$this->vo = TicketTicket::mk()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->find($id);
$this->vo = TicketTicket::mk()->with(['user_shares', 'views', 'repairs', 'verifys', 'view_process', 'repair_process', 'verify_process'])->append(['imgs_arr', 'type_name'])->find($id);
$this->ticket = $this->vo;
$process = ApprovalProcess::where('type', '=', 'GDSH')->order('id', 'asc')->findOrEmpty();
$instance = ApprovalInstance::query()->with(['steps.approver', 'logs'])->where('process_id', '=', $process->id)->where('oid', '=', $id)->findOrEmpty();
$this->instance = $instance;
if ($instance->isEmpty()) {
$this->step_index = -1;
} else {
$this->step_index = $instance->current_step;
}
$this->fetch();
}
@ -160,6 +152,9 @@ class Ticket extends Controller
public function move()
{
$this->title = "工单分配";
$id = $this->request->param('id');
$ticket = TicketTicket::mk()->where('id', '=', $id)->findOrEmpty();
if ($ticket->isEmpty()) $this->error('工单不存在!');
if ($this->request->isPost()) {
// 提交
$data = $this->_vali([
@ -168,8 +163,6 @@ class Ticket extends Controller
'dept_id.require' => '请指定处理部门!',
'user_id.default' => '0',
]);
$ticket = TicketTicket::mk()->where('id', '=', $data['id'])->findOrEmpty();
if ($ticket->isEmpty()) $this->error('工单不存在!');
$ticket->fz_user_id = $data['user_id'];
$ticket->fz_dept_id = $data['dept_id'];
if ($data['type'] == 1) {
@ -467,15 +460,6 @@ class Ticket extends Controller
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if (sizeof($ticket->views) === 0) {
if (sizeof($ticket->inspection_shares) === 0) {
$this->error('请先提请核验工单!');
} else {
$view = $ticket->inspection_shares[0];
}
} else {
$view = $ticket->views[0];
}
if ($this->request->isPost()) {
$adminInfo = $this->request->session('user');
$instance_data = $this->_vali([
@ -484,9 +468,10 @@ class Ticket extends Controller
]);
$ticket->kj_user_id = $instance_data['kj_user_id'];
$repair = $ticket->repairs()->save([
'gc_content'=>$view->gc_content,
'zf_content'=>$view->zf_content,
'ys_content'=>$view->ys_content,
'gc_content'=>$ticket->gc_content,
'zf_content'=>$ticket->zf_content,
'ys_content'=>$ticket->ys_content,
'work_days'=>$ticket->work_days,
'staff_id'=>$instance_data['staff_id'],
'status'=>0,
'create_id'=>$adminInfo['id'],

View File

@ -63,46 +63,11 @@ class TicketInter extends Controller
{
$this->title = '工单详情';
['id' => $id] = $this->_vali(['id.require' => '请指定工单ID!']);
$this->vo = TicketTicketInter::mk()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->find($id);
$this->vo = TicketTicketInter::mk()->with(['user_shares', 'views', 'repairs', 'verifys', 'view_process', 'repair_process', 'verify_process'])->append(['imgs_arr', 'type_name'])->find($id);
$this->ticket = $this->vo;
$process = ApprovalProcess::where('type', '=', 'GDSH')->order('id', 'asc')->findOrEmpty();
$instance = ApprovalInstance::query()->with(['steps.approver', 'logs'])->where('process_id', '=', $process->id)->where('oid', '=', $id)->findOrEmpty();
$this->instance = $instance;
if ($instance->isEmpty()) {
$this->step_index = -1;
} else {
$this->step_index = $instance->current_step;
}
$this->fetch();
}
public function reply()
{
$this->title = '回复工单';
[
'ticket_id'=>$ticket_id,
'id'=>$id
] = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
'id.require'=>'请指定回复ID!'
]);
$this->vo = TicketTicket::mk()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->find($ticket_id);
TicketReply::mForm('reply');
}
public function _reply_form_filter(&$data)
{
if ($this->request->isPost()) {
$this->_applyFormToken();
$data['type'] = 1;
$adminInfo = $this->request->session('user');
$data['user_id'] = $adminInfo['id'];
$data['username'] = $adminInfo['nickname'];
$data['contact'] = $adminInfo['contact_phone'];
}
}
/**
* 审核页面
* @auth true
@ -201,105 +166,6 @@ class TicketInter extends Controller
$this->success('创建成功!');
}
public function view_process_create()
{
$data = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
]);
$process = ApprovalProcess::where('type', '=', 'HSSH')->order('id', 'asc')->findOrEmpty();
if ($process->isEmpty()) {
$this->error('未找到可用的审核流程');
}
$adminInfo = $this->request->session('user');
$ticket = TicketTicket::query()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if ($this->request->isPost()) {
$instance_data = $this->_vali([
'title.default'=>'核验工单审核',
'content.default'=>'',
]);
ApprovalInstance::mk()->startTrans();
try {
$instance = ApprovalInstance::create([
'process_id' => $process->id,
'oid' => $ticket->id,
'title' => $instance_data['title'],
'content' => $instance_data['content'],
'status' => 0,
'current_step' => 0,
'create_time' => date('Y-m-d H:i:s'),
'create_by' => $adminInfo['id'],
'create_name' => $adminInfo['username'],
]);
foreach ($process->steps as $index => $step) {
$approver_id = $step['approver_id'] ?? 0;
if ($index == 0) {
if ($step['approver_type'] == 3) {
$approve_data = $this->_vali([
'approver_id.require' => '请指定审核人!',
]);
$approver_id = $approve_data['approver_id'];
}
}
ApprovalStep::create([
'instance_id' => $instance->id,
'step_number' => $index,
'approver_type' => $step['approver_type'],
'approver_id' => $approver_id,
'status' => 0,
]);
}
$ticket->view_pid = $instance->id;
$ticket->save();
ApprovalInstance::mk()->commit();
} catch (HttpResponseException $e) {
ApprovalInstance::mk()->rollback();
throw $e;
} catch (\Exception $e) {
ApprovalInstance::mk()->rollback();
$this->error("创建失败");
}
$this->success('创建成功!');
} else {
$this->vo = $ticket;
$this->process = $process;
$this->step_index = -1;
$this->current_step = $process->steps[0];
$this->users = SystemUser::query()->field('id,username,nickname')->select();
$this->fetch();
}
}
public function view_ticket_create()
{
$data = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
]);
$ticket = TicketTicket::query()->with(['view_process'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty();
$staffs = InspectionStaff::query()->field('id,name,phone')->select();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if ($this->request->isPost()) {
$adminInfo = $this->request->session('user');
$instance_data = $this->_vali([
'staff_id.require'=>'请指定维修人员!',
]);
$view = $ticket->views()->save([
'staff_id'=>$instance_data['staff_id'],
'status'=>0,
'create_by'=>$adminInfo['id'],
]);
$this->success('创建成功!', $view);
} else {
$this->vo = $ticket;
$this->staffs = $staffs;
$this->fetch();
}
}
public function repair_process_create()
{
$data = $this->_vali([
@ -389,7 +255,7 @@ class TicketInter extends Controller
$view = $ticket->repairs()->save([
'staff_id'=>$instance_data['staff_id'],
'status'=>0,
'create_by'=>$adminInfo['id'],
'create_id'=>$adminInfo['id'],
]);
$this->success('创建成功!', $view);
} else {
@ -428,7 +294,7 @@ class TicketInter extends Controller
'status' => 0,
'current_step' => 0,
'create_time' => date('Y-m-d H:i:s'),
'create_by' => $adminInfo['id'],
'create_id' => $adminInfo['id'],
'create_name' => $adminInfo['username'],
]);
foreach ($process->steps as $index => $step) {
@ -488,7 +354,7 @@ class TicketInter extends Controller
$view = $ticket->verifys()->save([
'staff_id'=>$instance_data['staff_id'],
'status'=>0,
'create_by'=>$adminInfo['id'],
'create_id'=>$adminInfo['id'],
]);
$this->success('创建成功!', $view);
} else {

View File

@ -133,4 +133,31 @@ class UserShare extends Controller
]);
$this->success('处理成功!');
}
/**
* 随手拍评论
* @auth true
* @menu true
* @return void
*/
public function comment()
{
$this->title = '随手拍详情';
$where = $this->_vali([
'id.require' => '随手拍ID不能为空',
]);
$this->vo = TicketUserShare::mk()->where($where)->with(['linked_ticket'])->findOrEmpty();
if ($this->vo->isEmpty()) $this->error('用户随手拍不存在!');
if (!$this->vo->linked_ticket_id) {
$this->ticket_list = TicketTicket::mk()->scope(['avail'])->select();
} else {
$this->ticket_list = [];
}
$this->type_list = TicketType::getList();
$this->user_list = SystemUser::query()->select();
$this->common_reply_list = TicketCommonReply::query()->scope(['avail'])->select();
$this->fetch();
}
}