'responsibility/cooperative/cooperativeUnit/index' ]; protected array $search = [ [ 'type' => 'input', 'name' => 'dept_code', 'title' => '部门编码', 'where' => '%s' ], ]; public function __construct() { parent::__construct(); $this->model = new CooperativeUnit(); } public function index(Request $request) { 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'], [],$limit); return sparKSuccess(dataReturn(0, 'success', $list)); } return view($this->templates['index']); } public function getList() { CooperativeUnit::truncate(); $listData = DB::connection('mysql2')->table('sha_db_sgyth_labour_team_f_d')->get()->toArray(); $postData = array(); foreach ($listData as $key => $value) { $item = array(); $item['team_id'] = $value->teamid; $item['team_name'] = $value->teamname; $item['flag'] = $value->flag; $item['team_leader'] = $value->teamleader; $item['cell_phone'] = $value->cellphone; $item['id_no'] = $value->idno; $item['dept_code'] = $value->deptcode; $item['project_id'] = $value->projectid; $item['project_name'] = $value->projectname; array_push($postData, $item); } CooperativeUnit::insertOrIgnore($postData); return sparkSuccess(dataReturn(0, 'success')); } }