更新数据关联查询,以及基本的数据的编辑,部分有待进一步完善。

This commit is contained in:
panx
2025-01-06 00:06:03 +08:00
parent d70fcccc1d
commit 018322d8c1
22 changed files with 1693 additions and 748 deletions

View File

@@ -58,6 +58,13 @@ class PdmPartlist extends AdminController
// 生成查询数据
$pid = !str_contains($pid, ',') ? $pid : explode(',',$pid);
$page = (int)input('page', 1);
$limit = (int)input('limit', 10);
$where = $this->buildSelectParams();
$fieldList = $this->model->getFields();
$order = !array_key_exists('sort', $fieldList) ? 'id' : 'sort';
$where[] = ['pid','in',$pid];
if (!empty($post['keyword'])) {
$where[] = ['partnumber|reference|content|item','like','%'.$post['keyword'].'%'];
@@ -68,9 +75,12 @@ class PdmPartlist extends AdminController
// $where[] = ['pid','in',$pid];
// $where[] = ['partnumber','like','%'.$post['partnumber'].'%'];
}
// throw new \Exception(json_encode($where));
$count = $this->model->where($where)->count();
$list = $this->model->where($where)->limit((int)$limit)->page((int)$page)->select()
$subQuery = $this->model->field('id')->where($where)->order($order, 'desc')->limit($limit)->page($page)->buildSql();
$subQuery = '( SELECT object.id FROM ' . $subQuery . ' AS object )';
$list = $this->model->with($this->relationModel)->where('id in' . $subQuery)->order($order, 'asc')->select() // 如果是'desc' list_to_tree 函数返回为空!
// $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;