更新下拉列表的功能以及增加下拉列表的筛选功能

This commit is contained in:
panx
2025-01-15 21:02:04 +08:00
parent 2c167222bd
commit 24091459b5
11 changed files with 77 additions and 249 deletions

View File

@@ -59,7 +59,7 @@ class PdmPartitemIndex extends AdminController
* @throws DbException
* @throws ModelNotFoundException
*/
public function dataList(array $params): array
public static function dataList(array $params): array
{
// $where = array();
// if (!empty($params['partnumber'])) {
@@ -91,14 +91,17 @@ class PdmPartitemIndex extends AdminController
$page = (int)input('page', 1);
$limit = (int)input('limit', 18);
$where = $this->buildSelectParams();
$count = $this->model->where($where)->count();
$fieldList = $this->model->getFields();
$controller = new PdmPartitemIndex();
$where = $controller->buildSelectParams();
$count = $controller->model->where($where)->count();
$fieldList = $controller->model->getFields();
$order = !array_key_exists('sort', $fieldList) ? 'id' : 'sort';
$subQuery = $this->model->field('id')->where($where)->order($order, 'desc')->limit($limit)->page($page)->buildSql();
$subQuery = $controller->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()->toArray(); // 如果是'desc' list_to_tree 函数返回为空!
$list = $this->model->with($this->relationModel)->where('id in' . $subQuery)->order($order, 'asc')->select(); // 如果是'desc' list_to_tree 函数返回为空!
$list = $controller->model->with($controller->relationModel)->where('id in' . $subQuery)->order($order, 'asc')->select(); // 如果是'desc' list_to_tree 函数返回为空!
foreach($list as $key => $value){
// throw new \Exception(json_encode($value));
@@ -127,8 +130,8 @@ class PdmPartitemIndex extends AdminController
foreach($list as $key => $value){
if(!in_array($value['pid'],$nodeid) && $value['pid'] > 0){
$nodeid[] = $value['pid'];
$nodevalue = $this->model->find($value['pid']);
$nodevalue = $this->model->find($value['pid'])->toArray();
$nodevalue = $controller->model->find($value['pid']);
$nodevalue = $controller->model->find($value['pid'])->toArray();
if(!empty($nodevalue)){
$list[] = &$nodevalue;