isAjax()) { $param = get_params(); $where = array(); $whereOr = array(); 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']]; } $where[] = ['a.delete_time', '=', 0]; $where[] = ['a.archive_status', '=', 0]; $uid = $this->uid; $auth = isAuth($uid,'contract_admin'); if($auth==0){ $whereOr[] =['a.admin_id|a.prepared_uid|a.sign_uid|a.keeper_uid', '=', $uid]; $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',a.share_ids)")]; $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',a.check_admin_ids)")]; $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',a.flow_admin_ids)")]; $dids = get_department_role($this->uid); if(!empty($dids)){ $whereOr[] =['a.sign_did', 'in', $dids]; } } $model = new ContractList(); $list = $model->get_list($param, $where, $whereOr); return table_assign(0, '', $list); } else { $uid = $this->uid; $auth = isAuth($uid,'contract_admin'); View::assign('auth', $auth); return view(); } } public function archive() { if (request()->isAjax()) { $param = get_params(); $where = array(); $whereOr = array(); 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['cate_id'])) { $where[] = ['a.cate_id', '=', $param['cate_id']]; } if (!empty($param['type'])) { $where[] = ['a.type', '=', $param['type']]; } $where[] = ['a.delete_time', '=', 0]; $where[] = ['a.archive_status', '=', 1]; $uid = $this->uid; $auth = isAuth($uid,'contract_admin'); if($auth==0){ $whereOr[] =['a.admin_id|a.prepared_uid|a.sign_uid|a.keeper_uid', '=', $uid]; $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',a.share_ids)")]; $dids = get_department_role($this->uid); if(!empty($dids)){ $whereOr[] =['a.sign_did', 'in', $dids]; } } $model = new ContractList(); $list = $model->get_list($param, $where, $whereOr); return table_assign(0, '', $list); } else { return view(); } } //添加&&编辑 public function add() { $param = get_params(); if (request()->isAjax()) { if (isset($param['sign_time'])) { $param['sign_time'] = strtotime($param['sign_time']); } if (isset($param['start_time'])) { $param['start_time'] = strtotime($param['start_time']); } if (isset($param['end_time'])) { $param['end_time'] = strtotime($param['end_time']); if ($param['end_time'] <= $param['start_time']) { return to_assign(1, "结束时间需要大于开始时间"); } } if (!empty($param['id']) && $param['id'] > 0) { try { validate(ContractCheck::class)->scene($param['scene'])->check($param); } catch (ValidateException $e) { // 验证失败 输出错误信息 return to_assign(1, $e->getError()); } $param['update_time'] = time(); $old = Db::name('Contract')->where(['id' => $param['id']])->find(); $auth = isAuth($this->uid,'contract_admin'); if($old['check_status'] == 0 || $old['check_status'] == 4){ if($this->uid!=$old['admin_id'] && $auth==0){ return to_assign(1, "只有录入人员和合同管理员有权限操作"); } $res = contractList::strict(false)->field(true)->update($param); if ($res) { add_log('edit', $param['id'], $param); to_log($this->uid,$param,$old); return to_assign(); } else { return to_assign(1, '操作失败'); } } else{ return to_assign(1, "当前状态不允许编辑"); } } else { try { validate(ContractCheck::class)->scene('add')->check($param); } catch (ValidateException $e) { // 验证失败 输出错误信息 return to_assign(1, $e->getError()); } $param['create_time'] = time(); $param['admin_id'] = $this->uid; $aid = ContractList::strict(false)->field(true)->insertGetId($param); if ($aid) { add_log('add', $aid, $param); $log_data = array( 'field' => 'new', 'action' => 'add', 'contract_id' => $aid, 'admin_id' => $param['admin_id'], 'create_time' => time(), ); Db::name('ContractLog')->strict(false)->field(true)->insert($log_data); return to_assign(); } else { return to_assign(1, '操作失败'); } } } else { $id = isset($param['id']) ? $param['id'] : 0; $type = isset($param['type']) ? $param['type'] : 0; $pid = isset($param['pid']) ? $param['pid'] : 0; $is_customer = Db::name('DataAuth')->where('name','contract_admin')->value('expected_1'); $is_codeno = Db::name('DataAuth')->where('name','contract_admin')->value('expected_2'); $codeno=''; if($is_codeno==1){ $codeno = get_codeno(1); } View::assign('is_customer', $is_customer); View::assign('codeno', $codeno); View::assign('id', $id); View::assign('type', $type); View::assign('pid', $pid); View::assign('auth', isAuth($this->uid,'contract_admin')); if ($id > 0) { $detail = (new ContractList())->detail($id); if($detail['check_status'] == 0 || $detail['check_status'] == 4){ View::assign('detail', $detail); return view('edit'); } else{ echo '