'/admin/responsibility/safeconference', 'store' => '/admin/responsibility/safeconference/store', 'update' => '/admin/responsibility/safeconference/update/', 'destroy' => '/admin/responsibility/safeconference/destroy', 'show' => '/admin/responsibility/safeconference/show/', 'signIn' => '/admin/responsibility/safeconference/signIn/', ]; protected array $templates = [ 'index' => 'responsibility/safeconference/index', 'store' => 'responsibility/safeconference/store', 'update' => 'responsibility/safeconference/store', 'destroy' => 'responsibility/safeconference/destroy', 'show' => 'responsibility/safeconference/show', 'signIn' => 'responsibility/safeconference/sign-in-index', ]; protected array $page = [ 'index' => [ 'title' => '安全会议管理', 'btn' => '新增会议', ], 'store' => [ 'title' => '新增安全会议', 'btn' => '新增', 'message' => '新增成功' ], 'update' => [ 'title' => '修改会议记录', 'btn' => '修改', 'message' => '修改成功' ], ]; protected array $search = [ [ 'type' => 'input', 'name' => 'id', 'title' => '会议编号', 'where' => '%s' ], [ 'type' => 'input', 'name' => 'name', 'title' => '会议名称', 'where' => ['name', 'like', '%%%s%%'] ], [ 'type' => 'select', 'name' => 'unit', 'data' => 'orgList', 'title' => '组织部门', 'where' => '%s' ], [ 'type' => 'date', 'name' => 'drawup', 'title' => '会议时间', 'where' => ['drawup', 'between', '%s'] ] ]; protected array $columns = [ [ 'name' => 'selection', 'width' => '80', ], [ 'name' => 'id', 'title' => '会议编号', 'type' => 'text', 'width' => '80', ], [ 'name' => 'type_info.name', 'title' => '会议分类', 'type' => 'text', 'width' => '150', ], [ 'name' => 'name', 'title' => '会议名称', 'type' => 'text', 'width' => '150', ], [ 'name' => 'org.name', 'title' => '组织部门', 'type' => 'text', ], [ 'name' => 'anchor', 'title' => '主持人', 'type' => 'text', ], [ 'name' => 'drawup', 'title' => '会议时间', 'type' => 'text', ], [ 'name' => 'aNum', 'title' => '应会人数', 'type' => 'text', ], [ 'name' => 'aaNum', 'title' => '参会人数', 'type' => 'text', ], [ 'name' => 'operation', 'show' => true, 'edit' => true, 'del' => true, 'width' => '100', 'align' => 'center', 'fixed' => 'right', ] ]; public function __construct() { parent::__construct(); $this->model = new Safeconference(); $this->unitModel = new CooperativeUnit(); $this->signModel = new SafeconferenceSign(); $this->adminUserModel = new AdminUser(); $orgData = (new AdminOrg())->getAllList([['status', '=', 1]]); $unitData = $this->unitModel->getAllList([]); View::assign([ 'columns' => $this->columns, 'uris' => $this->uris, 'search' => $this->search, 'orgList' => asTreeArray($orgData, 'pid'), 'typeList' => (new SafeconferenceType())->getAllList([]), 'cooperativeList' => $unitData, ]); } /** * 规章制度页面 * * @param Request $request * @return Response */ public function index(Request $request): Response { if ($request->isAjax()) { $param = $request->all(); $limit = $param['limit']; $where = []; foreach ($this->search as $search) { if (isset($param[$search['name']]) && !empty($param[$search['name']])) { if (is_array($search['where'])) { if (is_array($param[$search['name']])) { $search['where'][2] = $param[$search['name']]; } else { $search['where'][2] = sprintf($search['where'][2], $param[$search['name']]); } $where[$search['name']] = $search['where']; } else { $where[$search['name']] = sprintf($search['where'], $param[$search['name']]); } } } $list = $this->model->getPaginateList($where, ['*'], ['id' => 'desc'], ['org', 'typeInfo'], $limit); foreach ($list['data'] as $k => &$v) { $v['aNum'] = count($v['writer_info']); $v['aaNum'] = SafeconferenceSign::where('s_id', $v['id'])->count(); } return sparKSuccess(dataReturn(0, 'success', $list)); } View::assign([ 'page' => $this->page['index'], ]); return view($this->templates['index']); } /** * 安全会议添加 * * @param Request $request * @return Response */ public function store(Request $request): Response { if ($request->isAjaxPost()) { $param = $request->post(); $this->model->create($param); return sparkSuccess(dataReturn(0, '添加成功')); } View::assign([ 'page' => $this->page['store'], ]); return view($this->templates['store']); } /** * 安全会议删除 * * @param Request $request * @return Response */ public function destroy(Request $request): Response { $ids = $request->get('ids'); $res = $this->model->delByIds($ids); return sparKSuccess(dataReturn(0, '删除成功')); } /** * 安全会议编辑 * * @param Request $request * @param $id * @return Response */ public function update(Request $request, $id): Response { if ($request->isAjaxPost()) { $data = $this->model->find($id); if (!$data) { return sparkSuccess(dataReturn(1, '数据不存在')); } $param = $request->post(); $data->fill($param)->save(); return sparkSuccess(dataReturn(0, '编辑成功')); } $data = $this->model->getInfoById($id); View::assign([ 'page' => $this->page['update'], 'data' => $data, ]); return view($this->templates['update']); } /** * 安全会议详情 * * @param Request $request * @param $id * @return Response */ public function show(Request $request, $id): Response { $data = $this->model->where('id', $id)->with(['org', 'typeInfo'])->first(); if (!$data) { return view('common/404')->withStatus(404); } View::assign([ 'data' => $data ]); return view($this->templates['show']); } /** * 管理员列表 * @param Request $request * @return Response */ public function userList(Request $request): Response { $adminService = new AdminService(); $res = $adminService->getList($request->all()); return sparkSuccess($res); } /** * 通知参会人员 * * @param Request $request * @return Response */ public function userNotify(Request $request, $id): Response { $notifyErrArr = []; $model = SafeConference::find($id); foreach ($model->writer_info as $user) { if ($user['mobile']) { $message = '安全会议通知:' . $model->name . ',将在' . $model->drawup . '开始,请及时签到'; $messageUrl = 'https://anquansys.sxlq.com:37100/h5/#/pages/responsibility/safeconference/sign?s_id=' . $id; try { DingTalk::ding_send_message_do($user['mobile'], $model->name, $message, $messageUrl); } catch (Throwable $e) { $notifyErrArr[] = $user['nickname']; } } } return sparkSuccess(dataReturn(0, '推送成功', $notifyErrArr)); } /** * 导出台账 * * @return Response */ public function exportLedger(): Response { $safeConferenceService = new SafeConferenceService(); $path = $safeConferenceService->exportLedger(); return sparKSuccess(dataReturn(0, 'success', $path)); } /** * 导出会议 * * @param Request $request * @return Response */ public function exportPrint(Request $request, $id): Response { $safeConferenceService = new SafeConferenceService(); $path = $safeConferenceService->exportPrint($id); return sparKSuccess(dataReturn(0, 'success', $path)); } /** * 签到列表 * * @param Request $request * @param [type] $s_id * @return Response */ public function signIn(Request $request, $s_id): Response { if ($request->isAjax()) { $param = $request->all(); $limit = $param['limit'] ?? 20; $nickname = $param['nickname'] ?? ''; // $sign_time = isset($param['sign_time']) ? $param['sign_time'] : []; $where = []; // if (!empty($sign_time)) { // $where[] = ['create_time', '>', strtotime($sign_time[0])]; // if (isset($sign_time[1])) { // $where[] = ['create_time', '<', strtotime($sign_time[1])]; // } // } if ($nickname) { $where[] = ['nickname', 'like', '%' . $nickname . '%']; } $model = SafeConference::find($s_id); $where[] = ['id', 'in', $model->writer]; $list = $this->adminUserModel->getPaginateList($where, ['*'], ['id' => 'asc'], ['role', 'userOrgs'], $limit); $signList = $this->signModel->getAllList([['s_id', '=', $s_id]], ['*'], ['id' => 'asc']); foreach ($list['data'] as $k => &$v) { foreach ($signList as $sign) { if ($sign['admin_user_id'] == $v['id']) { $v['longitude'] = $sign['longitude']; $v['latitude'] = $sign['latitude']; $v['distance'] = $sign['distance']; $v['sign_time'] = $sign['create_time']; } else { $v['longitude'] = ''; $v['latitude'] = ''; $v['distance'] = ''; $v['sign_time'] = ''; } } } return sparKSuccess(dataReturn(0, 'success', $list)); } View::assign([ 's_id' => $s_id ]); return view($this->templates['signIn']); } }