AppropriationModel = new AppropriationModel(); $this->Field = new Field($app); $this->model = new \app\admin\model\Contract(); $this->Costmodel = new CostProjectModel(); $this->Adminmodel = new Admin(); $this->Auditmodel = new AuditModel(); $this->ContactModel = new ContactModel(); $this->uid = get_login_admin('id'); $this->unit = get_login_admin('unit_name'); $this->user_tpe = Db::name("department")->where("id", $this->unit)->value("type"); } const ZERO = 0; const ONE = 1; const TWO = 2; const THREE = 3; const FORE = 4; const FIVE = 5; const SIX = 6; const SEVEN = 7; public static $Type = [ self::ZERO => '未设置', self::ONE => '普通合同', self::TWO => '框架合同', self::THREE => '补充协议', self::FORE => '其他合同', ]; public static $Status = [ self::ZERO => '待审核', self::ONE => '审核中', self::TWO => '审核通过', self::THREE => '审核拒绝', self::FORE => '已撤销', self::FIVE => '已中止', self::SIX => '已作废', self::SEVEN => '修改中', ]; public static $ArchiveStatus = [ self::ZERO => '未归档', self::ONE => '已归档', ]; public function contract(){ $param = get_params(); $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $where = [ ["subject_id", "=", get_login_admin("unit_name")], ["delete_time", "=", 0], ["archive_status", "=", 0] ]; if (!empty($param['keywords'])) { $where[] = ['a.id|a.name|c.title', 'like', '%' . $param['keywords'] . '%']; } if (!empty($param['cate_id'])) { $where[] = ['a.cate_id', '=', $param['cate_id']]; } if (!empty($param['type'])) { $where[] = ['a.type', '=', $param['type']]; } if (isset($param['check_status']) && $param['check_status'] != '') { $where[] = ['a.check_status', '=', $param['check_status']]; } $list = $this->model ->alias('a') ->field('a.*,a.type as type_a, c.title as cate_title') ->where($where) ->join('contract_cate c', 'a.cate_id = c.id') ->order('a.create_time desc') ->paginate($rows, false, ['query' => $param]) ->each(function ($item) { $item->keeper_name = Db::name('Admin')->where(['id' => $item->keeper_uid])->value('nickname'); $item->sign_name = Db::name('Admin')->where(['id' => $item->sign_uid])->value('nickname'); $item->cate_title = Db::name('ContractCate')->where("id", $item->cate_id)->value("title"); $item->sign_time = date('Y-m-d', $item->sign_time); $item->interval_time = date('Y-m-d', $item->start_time) . ' 至 ' . date('Y-m-d', $item->end_time); $item->type_name = self::$Type[(int)$item->type]; $item->status_name = self::$Status[(int)$item->check_status]; $item->delay = countDays(date("Y-m-d"), date('Y-m-d', $item->end_time)); if ($item->cost == 0) { $item->cost = '-'; } }); // return table_assign(0, '', $list); $cate = Db::name('ContractCate')->where("unit_id", get_login_admin("unit_name"))->order('create_time asc')->select(); View::assign('list', $list); View::assign('cate', $cate); // halt($list); return view(); } public function view(){ $param = get_params(); $id = get_params("id"); $detail = (new \app\admin\model\Contract())->detail($id); //从项目页面进来的不给按钮 $view_auth = isset($param['type']) ? $param['type'] : 0; $auth = 0; $is_check_admin = 0; $is_create_admin = 0; $check_record = []; $detail['create_user'] = Db::name('Admin')->where(['id' => $detail['admin_id']])->value('nickname'); $detail['copy_user'] = '-'; if ($detail['copy_uids'] != '') { $copy_user = Db::name('Admin')->where('id', 'in', $detail['copy_uids'])->column('nickname'); $detail['copy_user'] = implode(',', $copy_user); } $check_id = Db::name("check_step")->where("id", $detail["check_step_sort"])->value("check_id"); if ($check_id == $this->uid) { $is_check_admin = 1; } if ($detail['admin_id'] == $this->uid) { $is_create_admin = 1; $auth = 1; } //关联项目 $uuid = Db::name("relation")->alias("r") ->leftJoin("cost_project c","c.id=r.uuid")->where("uid",$id)->column("r.id,project_name,uid,uuid"); $newArr = []; foreach($uuid as $item){ $key = $item['uid'].'-'.$item['uuid']; if(!isset($newArr[$key])){ $newArr[$key] = $item; } } $project = array_values($newArr); $file_array_other = Db::name('ContractFile') ->field('cf.id,f.filepath,f.name,f.filesize,f.fileext,f.create_time,f.admin_id') ->alias('cf') ->join('File f', 'f.id = cf.file_id', 'LEFT') ->order('cf.create_time asc') ->where(array('cf.contract_id' => $id, 'cf.delete_time' => 0)) ->select()->toArray(); $detail['file_array_other'] = $file_array_other; foreach ($check_record as $kk => &$vv) { $vv['check_time_str'] = date('Y-m-d H:i', $vv['check_time']); $vv['status_str'] = '提交'; if ($vv['status'] == 1) { $vv['status_str'] = '审核通过'; } else if ($vv['status'] == 2) { $vv['status_str'] = '审核拒绝'; } if ($vv['status'] == 3) { $vv['status_str'] = '撤销'; } } View::assign('is_check_admin', $is_check_admin); View::assign('auth', $auth); View::assign('view_auth', $view_auth); View::assign('is_create_admin', $is_create_admin); View::assign('check_record', $check_record); View::assign('project', $project); View::assign('detail', $detail); // halt($detail); return view(); } }