| xqd
@@ -12,7 +12,6 @@ namespace App\Http\Controllers\Admin\Company;
|
|
|
use App\Http\Controllers\Admin\Controller;
|
|
|
use App\Imports\CompanyInfoImport;
|
|
|
use App\Models\CompanyInfoModel;
|
|
|
-use App\Models\UserCompanyCollectionModel;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Repositories\Company\InfoRepository;
|
|
|
use Maatwebsite\Excel\Facades\Excel;
|
| xqd
@@ -28,7 +27,7 @@ class InfoController extends Controller
|
|
|
|
|
|
|
|
|
/*
|
|
|
- * 搜索页
|
|
|
+ * 搜索页视图
|
|
|
* */
|
|
|
public function search()
|
|
|
{
|
| xqd
@@ -64,68 +63,10 @@ class InfoController extends Controller
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
- * 创建公海
|
|
|
+ * 导入企业信息
|
|
|
* @param Request $request
|
|
|
- * @return int
|
|
|
*/
|
|
|
- public function add_collection(Request $request)
|
|
|
- {
|
|
|
- $filter_fields = $request->except('_token');
|
|
|
-
|
|
|
- $data['user_id'] = \Auth::guard('admin')->user()->id;
|
|
|
- $data['filter_fields'] = json_encode($filter_fields);
|
|
|
- $data['name'] = '我的公海';
|
|
|
-
|
|
|
- UserCompanyCollectionModel::create($data);
|
|
|
-
|
|
|
- return 200;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public function collection(Request $request)
|
|
|
- {
|
|
|
- if ($request->ajax()) {
|
|
|
- $search = $request->all();
|
|
|
-
|
|
|
- $order = array();
|
|
|
- if (isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
|
|
|
- $order[$request['sort_field']] = $request['sort_field_by'];
|
|
|
- } else {
|
|
|
- $order['id'] = 'DESC';
|
|
|
- }
|
|
|
-
|
|
|
- $list = $this->repository->searchCompany($search, $order);
|
|
|
-
|
|
|
- $view = view('admin.company.collection.data', compact('list'))->render();
|
|
|
- return response()->json(['html' => $view]);
|
|
|
- }
|
|
|
-
|
|
|
- $user_id = \Auth::guard('admin')->user()->id;
|
|
|
- $collection = UserCompanyCollectionModel::where('user_id', $user_id)->first();
|
|
|
-
|
|
|
- if (count($collection)) {
|
|
|
- $search = (array)json_decode($collection->filter_fields);
|
|
|
- $order = array();
|
|
|
- if (isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
|
|
|
- $order[$request['sort_field']] = $request['sort_field_by'];
|
|
|
- } else {
|
|
|
- $order['id'] = 'DESC';
|
|
|
- }
|
|
|
-
|
|
|
- $list = $this->repository->searchCompany($search, $order);
|
|
|
-
|
|
|
- $fields = (new CompanyInfoModel())->filterFields;
|
|
|
-
|
|
|
- return view('admin.company.collection.index', compact('list', 'fields'));
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加
|
|
|
- */
|
|
|
- public function create(Request $request)
|
|
|
+ public function import(Request $request)
|
|
|
{
|
|
|
$res = Excel::import(new CompanyInfoImport, request()->file('company_info'));
|
|
|
|
| xqd
@@ -133,52 +74,11 @@ class InfoController extends Controller
|
|
|
$this->showMessage('导入成功', $url);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 保存修改
|
|
|
- */
|
|
|
- private function _createSave()
|
|
|
- {
|
|
|
- $data = (array)request('data');
|
|
|
- $id = $this->repository->create($data);
|
|
|
- if ($id) {
|
|
|
- $url[] = array('url' => U('Company/Info/index'), 'title' => '返回列表');
|
|
|
- $url[] = array('url' => U('Company/Info/create'), 'title' => '继续添加');
|
|
|
- $this->showMessage('添加成功', $url);
|
|
|
- } else {
|
|
|
- $url[] = array('url' => U('Company/Info/index'), 'title' => '返回列表');
|
|
|
- return $this->showWarning('添加失败', $url);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改
|
|
|
- */
|
|
|
- public function update(Request $request)
|
|
|
- {
|
|
|
- if ($request->method() == 'POST') {
|
|
|
- return $this->_updateSave();
|
|
|
- }
|
|
|
- $data = $this->repository->find($request->get('id'));
|
|
|
- return view('admin.company.info.edit', compact('data'));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存修改
|
|
|
+ /***
|
|
|
+ * 企业详情页
|
|
|
+ * @param Request $request
|
|
|
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
|
*/
|
|
|
- private function _updateSave()
|
|
|
- {
|
|
|
- $data = (array)request('data');
|
|
|
- $ok = $this->repository->update(request('id'), $data);
|
|
|
- if ($ok) {
|
|
|
- $url[] = array('url' => U('Company/Info/index'), 'title' => '返回列表');
|
|
|
- return $this->showMessage('操作成功', urldecode(request('_referer')));
|
|
|
- } else {
|
|
|
- $url[] = array('url' => U('Company/Info/index'), 'title' => '返回列表');
|
|
|
- return $this->showWarning('操作失败', $url);
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public function view(Request $request)
|
|
|
{
|
|
|
$data = $this->repository->find(request('id'));
|