更新数据关联查询,以及基本的数据的编辑,部分有待进一步完善。
This commit is contained in:
@@ -34,21 +34,25 @@ class PdmPartitemView extends AdminController
|
||||
|
||||
public function index(): \support\Response
|
||||
{
|
||||
// $post = input();
|
||||
// $post = request()->post();
|
||||
$post = request()->all();
|
||||
// $post['partnumber'] = input('partnumber');
|
||||
$pid = input('pid');
|
||||
$limit = input('limit') ?? 10;
|
||||
$page = input('page') ?? 1;
|
||||
// if ($pid == null) {
|
||||
// $pid = (string)$this->model->minId();
|
||||
// }
|
||||
|
||||
|
||||
if (request()->isAjax()) {
|
||||
|
||||
// $post = input();
|
||||
// $post = request()->post();
|
||||
$post = request()->all();
|
||||
// $post['partnumber'] = input('partnumber');
|
||||
// $pid = input('pid');
|
||||
$limit = (int)input('limit') ?? 10;
|
||||
$page = (int)input('page') ?? 1;
|
||||
// if ($pid == null) {
|
||||
// $pid = (string)$this->model->minId();
|
||||
// }
|
||||
|
||||
// 生成查询数据
|
||||
// $pid = !str_contains($pid, ',') ? $pid : explode(',',$pid);
|
||||
$where = $this->buildSelectParams();
|
||||
$fieldList = $this->model->getFields();
|
||||
$order = !array_key_exists('sort', $fieldList) ? 'id' : 'sort';
|
||||
// $where[] = ['pid','in',$pid];
|
||||
// $where[] = [];
|
||||
if (!empty($post['keyword'])) {
|
||||
@@ -56,22 +60,15 @@ class PdmPartitemView extends AdminController
|
||||
// $where[] = ['reference','like','%'.$post['keyword'].'%'];
|
||||
// $where[] = ['content','like','%'.$post['keyword'].'%'];
|
||||
// $where[] = ['item','like','%'.$post['keyword'].'%'];
|
||||
}else{
|
||||
// $where[] = ['pid','in',$pid];
|
||||
// $where[] = ['partnumber','like','%'.$post['partnumber'].'%'];
|
||||
$where[] = ['partnumber|purchasecode|parttype|value|description|mpn|mfgname|symbol|footprint|datasheet|usernickname|department','like','%'.'%'];
|
||||
}
|
||||
}
|
||||
|
||||
$count = $this->model->where($where)->count();
|
||||
// $list = $this->model->where($where)->limit((int)$limit)->page((int)$page)->select()
|
||||
// ->each(function($item,$key) use ($pid){
|
||||
// if ($key == 0 && $pid == '0') {
|
||||
// $item['LAY_CHECKED'] = true;
|
||||
// }
|
||||
$subQuery = $this->model->field('id')->where($where)->order($order, 'desc')->limit($limit)->page($page)->buildSql();
|
||||
$subQuery = '( SELECT object.id FROM ' . $subQuery . ' AS object )';
|
||||
|
||||
// return $item;
|
||||
// });
|
||||
$list = $this->model->where($where)->limit((int)$limit)->page((int)$page)->select();
|
||||
// $list = $this->model->where($where)->limit((int)$limit)->page((int)$page)->select();
|
||||
$list = $this->model->with($this->relationModel)->where('id in' . $subQuery)->order($order, 'asc')->select() ;
|
||||
// $list = $this->model->where($where)->limit((int)$limit)->page((int)$page)->select();
|
||||
|
||||
return $this->success('查询成功', null, $list, $count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user