更新下拉列表的功能以及增加下拉列表的筛选功能
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -7,6 +7,7 @@ use Webman\Http\Request;
|
||||
use app\admin\model\PdmPartitemRelation as PdmPartitemRelationModel;
|
||||
use app\admin\model\PdmSymbol as PdmSymbolModel;
|
||||
use app\admin\model\PdmFootprint as PdmFootprintModel;
|
||||
use app\admin\model\PdmPartitemIndex as PdmPartitemIndexModel;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
@@ -154,6 +155,7 @@ class PdmPartitemRelation extends AdminController
|
||||
{
|
||||
$symbol = PdmSymbolModel::select()->toArray();
|
||||
$footprint = PdmFootprintModel::select()->toArray();
|
||||
$partitemIndex = PdmPartitemIndexModel::select()->toArray();
|
||||
|
||||
if (request()->isPost()) {
|
||||
$post = \request()->post();
|
||||
@@ -179,6 +181,7 @@ class PdmPartitemRelation extends AdminController
|
||||
'data' => $data,
|
||||
'symbol' => json_encode( list_to_tree($symbol), JSON_UNESCAPED_UNICODE),
|
||||
'footprint' => json_encode( list_to_tree($footprint), JSON_UNESCAPED_UNICODE),
|
||||
'partitemIndex' => json_encode( list_to_tree($partitemIndex), JSON_UNESCAPED_UNICODE),
|
||||
// 'parttype' => $this->parttype,
|
||||
'list' => json_encode( list_to_tree($list), JSON_UNESCAPED_UNICODE),
|
||||
]);
|
||||
@@ -199,12 +202,18 @@ class PdmPartitemRelation extends AdminController
|
||||
|
||||
$symbolid = $data['symbolid'];
|
||||
$footprintid = $data['footprintid'];
|
||||
$partnumbertemp = $data['partnumber'];
|
||||
|
||||
// $parems['id'] = input('parttypeid', 0);
|
||||
$symbol = PdmSymbolModel::find($symbolid)->toArray();
|
||||
list($countsymbol, $symbol) = \app\admin\controller\PdmSymbol::dataList($symbol);
|
||||
$footprint = PdmFootprintModel::find($footprintid)->toArray();
|
||||
list($countfootprint, $footprint) = \app\admin\controller\PdmFootprint::dataList($footprint);
|
||||
$where = ['partnumber' => $partnumbertemp];
|
||||
// $partnumbertemp1 = PdmPartitemIndexModel::find($partnumbertemp)->toArray();
|
||||
$partnumbertemp1 = PdmPartitemIndexModel::where($where)->select()->toArray();
|
||||
list($countpartnumberIndex, $partitemIndex) = \app\admin\controller\PdmPartitemIndex::dataList($partnumbertemp1);
|
||||
|
||||
|
||||
if (request()->isPost()) {
|
||||
$post = \request()->post();
|
||||
@@ -221,6 +230,7 @@ class PdmPartitemRelation extends AdminController
|
||||
'data' => $data,
|
||||
'symbol' => json_encode( list_to_tree($symbol), JSON_UNESCAPED_UNICODE),
|
||||
'footprint' => json_encode( list_to_tree($footprint), JSON_UNESCAPED_UNICODE),
|
||||
'partitemIndex' => json_encode( list_to_tree($partitemIndex), JSON_UNESCAPED_UNICODE),
|
||||
// 'parttype' => json_encode( $parttype, JSON_UNESCAPED_UNICODE),
|
||||
'list' => json_encode( list_to_tree($list), JSON_UNESCAPED_UNICODE),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user