更新数据关联查询,以及基本的数据的编辑,部分有待进一步完善。
This commit is contained in:
@@ -58,27 +58,70 @@ class PdmFootprint extends AdminController
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public static function dataList(array $params): array
|
||||
public function dataList(array $params): array
|
||||
{
|
||||
$where = array();
|
||||
if (!empty($params['footprint'])) {
|
||||
$where[] = ['footprint','like','%'.$params['footprint'].'%'];
|
||||
}
|
||||
if (!empty($params['content'])) {
|
||||
$where[] = ['content','like','%'.$params['content'].'%'];
|
||||
}
|
||||
$model = new PdmFootprintModel();
|
||||
// $model = $this->model;
|
||||
$count = $model->where($where)->count();
|
||||
// $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
$list = $model->where($where)->order('sort asc')->select();
|
||||
// $where = array();
|
||||
// if (!empty($params['footprint'])) {
|
||||
// $where[] = ['footprint','like','%'.$params['footprint'].'%'];
|
||||
// }
|
||||
// if (!empty($params['content'])) {
|
||||
// $where[] = ['content','like','%'.$params['content'].'%'];
|
||||
// }
|
||||
// $model = new PdmFootprintModel();
|
||||
// // $model = $this->model;
|
||||
// $count = $model->where($where)->count();
|
||||
// // $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
// $list = $model->where($where)->order('sort asc')->select();
|
||||
// foreach($list as $key => $value){
|
||||
// // throw new \Exception(json_encode($value));
|
||||
// // throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
// $list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
// }
|
||||
|
||||
// return [$count, $list->toArray()];
|
||||
|
||||
$where = $this->buildSelectParams();
|
||||
$count = $this->model->where($where)->count();
|
||||
$fieldList = $this->model->getFields();
|
||||
$order = !array_key_exists('sort', $fieldList) ? 'id' : 'sort';
|
||||
$subQuery = $this->model->field('id')->where($where)->order($order, 'asc')->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 函数返回为空!
|
||||
|
||||
foreach($list as $key => $value){
|
||||
// throw new \Exception(json_encode($value));
|
||||
// throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
$list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
// $list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
$list[$key]->admin;
|
||||
}
|
||||
|
||||
return [$count, $list->toArray()];
|
||||
$list = $list->toArray();
|
||||
if(!empty($list) && is_array($list)){
|
||||
$nodeid = array();
|
||||
foreach($list as $key => $value){
|
||||
if($value['pid'] == 0 ){
|
||||
$nodeid[] = $value['id'];
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if(!empty($nodevalue)){
|
||||
$list[] = &$nodevalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$list = list_sort_by($list,'id','asc');
|
||||
// usort($list, function($a, $b) {
|
||||
// return $a['id'] <=> $b['id']; // 对 'id' 进行升序排序
|
||||
// });
|
||||
// throw new \Exception(json_encode($list));
|
||||
}
|
||||
return [$count, $list];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,26 +37,6 @@ class PdmMfgName extends AdminController
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
$params = request()->all();
|
||||
$where = array();
|
||||
if (!empty($params['mfgname'])) {
|
||||
$where[] = ['mfgname','like','%'.$params['mfgname'].'%'];
|
||||
// $where[] = ['mfgname','like','%'.'ABRACON'.'%'];
|
||||
}
|
||||
if (!empty($params['mfgsite'])) {
|
||||
$where[] = ['mfgsite','like','%'.$params['mfgsite'].'%'];
|
||||
}
|
||||
|
||||
// $where[] = ['mfgname','like','%'.'ABRACON'.'%'];
|
||||
$listtemp = $this->model->where($where)->select();
|
||||
// $listtemp = $this->model->where($where);
|
||||
// $listtemp = $this->model->find(1);
|
||||
// throw new \Exception(json_encode($listtemp));
|
||||
// $admin = $this->model->admin()->where($where)->select()->toArray();
|
||||
|
||||
// $admin = $listtemp->admin;
|
||||
// throw new \Exception(json_encode($admin));
|
||||
|
||||
if (request()->isAjax()) {
|
||||
list($count, $list) = PdmMfgName::dataList(request()->all());
|
||||
// $rules = list_to_tree($list,'id','pid','children',0);
|
||||
@@ -77,54 +57,54 @@ class PdmMfgName extends AdminController
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public static function dataList(array $params): array
|
||||
public function dataList(array $params): array
|
||||
{
|
||||
$where = array();
|
||||
if (!empty($params['mfgname'])) {
|
||||
$where[] = ['mfgname','like','%'.$params['mfgname'].'%'];
|
||||
}
|
||||
if (!empty($params['mfgsite'])) {
|
||||
$where[] = ['mfgsite','like','%'.$params['mfgsite'].'%'];
|
||||
}
|
||||
$model = new PdmMfgNameModel();
|
||||
$count = $model->where($where)->count();
|
||||
// $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
$list = $model->where($where)->order('sort asc')->select();
|
||||
foreach($list as $key => $value){
|
||||
// throw new \Exception(json_encode($value));
|
||||
// throw new \Exception(json_encode($lists[$key]->admin['nickname']));
|
||||
$list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
}
|
||||
|
||||
|
||||
// $pidlist = array();
|
||||
foreach ($list as $key => $value) {
|
||||
$list[$key]['mfgname'] = __($value['mfgname']);
|
||||
|
||||
}
|
||||
// $users = array();
|
||||
// $users = $model->usernames();
|
||||
|
||||
// // throw new \Exception(json_encode($users));
|
||||
// foreach ($list as $key => $value) {
|
||||
// foreach ($users as $keyuser => $valueuser) {
|
||||
// // if ($users[$keyuser]['id'] == $list[$key]['id']){
|
||||
// // // $list[$key]['creatorid'] = __($users[$keyuser]['nickname']);
|
||||
// // $list[$key]['creatorid'] = __($users[$keyuser]['name']);
|
||||
// // break;
|
||||
// // }
|
||||
// if ($value['creatorid'] == $valueuser['id']) {
|
||||
// // $list[$key]['creatorid'] = __($valueuser['name']);
|
||||
// $list[$key]['creatorid'] = __($valueuser['nickname']);
|
||||
// break;
|
||||
// }else{
|
||||
// $list[$key]['creatorid'] =$list[$key]['creatorid'].'|'. __('未知用户');
|
||||
// }
|
||||
|
||||
// }
|
||||
// $where = array();
|
||||
// if (!empty($params['mfgname'])) {
|
||||
// $where[] = ['mfgname','like','%'.$params['mfgname'].'%'];
|
||||
// }
|
||||
// if (!empty($params['mfgsite'])) {
|
||||
// $where[] = ['mfgsite','like','%'.$params['mfgsite'].'%'];
|
||||
// }
|
||||
// $model = new PdmMfgNameModel();
|
||||
// $count = $model->where($where)->count();
|
||||
// // $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
// $list = $model->where($where)->order('sort asc')->select();
|
||||
// foreach($list as $key => $value){
|
||||
// // throw new \Exception(json_encode($value));
|
||||
// // throw new \Exception(json_encode($lists[$key]->admin['nickname']));
|
||||
// $list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
// }
|
||||
|
||||
return [$count, $list->toArray()];
|
||||
|
||||
// // $pidlist = array();
|
||||
// foreach ($list as $key => $value) {
|
||||
// $list[$key]['mfgname'] = __($value['mfgname']);
|
||||
|
||||
// }
|
||||
|
||||
$page = (int)input('page', 1);
|
||||
$limit = (int)input('limit', 18);
|
||||
$where = $this->buildSelectParams();
|
||||
$count = $this->model->where($where)->count();
|
||||
$fieldList = $this->model->getFields();
|
||||
$order = !array_key_exists('sort', $fieldList) ? 'id' : 'sort';
|
||||
// $subQuery = $this->model->field('id')->where($where)->order($order, 'asc')->buildSql();
|
||||
$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()->toArray(); // 如果是'desc' list_to_tree 函数返回为空!
|
||||
// $list = $this->model->with($this->relationModel)->where('id in' . $subQuery)->order($order, 'asc')->select(); // 如果是'desc' list_to_tree 函数返回为空!
|
||||
$list = $this->model->with($this->relationModel)->where('id in' . $subQuery)->order($order, 'desc')->select(); // 如果是'desc' list_to_tree 函数返回为空!
|
||||
|
||||
foreach($list as $key => $value){
|
||||
// throw new \Exception(json_encode($value));
|
||||
// throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
// $list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
$list[$key]->admin;
|
||||
}
|
||||
$list = $list->toArray();
|
||||
|
||||
return [$count, $list];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace app\admin\controller;
|
||||
use app\AdminController;
|
||||
use Webman\Http\Request;
|
||||
use app\admin\model\PdmPartitemIndex as PdmPartitemIndexModel;
|
||||
use app\admin\model\PdmParttype as PdmParttypeModel;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
@@ -58,35 +59,90 @@ class PdmPartitemIndex extends AdminController
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public static function dataList(array $params): array
|
||||
public function dataList(array $params): array
|
||||
{
|
||||
$where = array();
|
||||
if (!empty($params['partnumber'])) {
|
||||
$where[] = ['partnumber','like','%'.$params['partnumber'].'%'];
|
||||
}
|
||||
if (!empty($params['content'])) {
|
||||
$where[] = ['content','like','%'.$params['content'].'%'];
|
||||
}
|
||||
$model = new PdmPartitemIndexModel();
|
||||
// $model = $this->model;
|
||||
$count = $model->where($where)->count();
|
||||
// $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
$list = $model->where($where)->order('sort asc')->select();
|
||||
// $where = array();
|
||||
// if (!empty($params['partnumber'])) {
|
||||
// $where[] = ['partnumber','like','%'.$params['partnumber'].'%'];
|
||||
// }
|
||||
// if (!empty($params['content'])) {
|
||||
// $where[] = ['content','like','%'.$params['content'].'%'];
|
||||
// }
|
||||
// $model = new PdmPartitemIndexModel();
|
||||
// // $model = $this->model;
|
||||
// $count = $model->where($where)->count();
|
||||
// // $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
// $list = $model->where($where)->order('sort asc')->select();
|
||||
// foreach($list as $key => $value){
|
||||
// // throw new \Exception(json_encode($value));
|
||||
// // throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
// $list[$key]['creator'] =__($list[$key]->admin == null?'': $list[$key]->admin['nickname']);
|
||||
// $list[$key]['parttype'] =__($list[$key]->parttype ==null?'': $list[$key]->parttype['name']);
|
||||
// $list[$key]['mfg_name'] =__($list[$key]->mfgname == null ?'': $list[$key]->mfgname['mfgname']);
|
||||
// // if($list[$key]->mfgname == null){
|
||||
// // $list[$key]['mfg_name'] ='';
|
||||
// // }else{
|
||||
// // $list[$key]['mfg_name'] =$list[$key]->mfgname['mfgname'];
|
||||
// // }
|
||||
|
||||
// }
|
||||
|
||||
// return [$count, $list->toArray()];
|
||||
|
||||
$page = (int)input('page', 1);
|
||||
$limit = (int)input('limit', 18);
|
||||
$where = $this->buildSelectParams();
|
||||
$count = $this->model->where($where)->count();
|
||||
$fieldList = $this->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 = '( 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 函数返回为空!
|
||||
|
||||
foreach($list as $key => $value){
|
||||
// throw new \Exception(json_encode($value));
|
||||
// throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
$list[$key]['creator'] =__($list[$key]->admin == null?'': $list[$key]->admin['nickname']);
|
||||
$list[$key]['parttype'] =__($list[$key]->parttype ==null?'': $list[$key]->parttype['name']);
|
||||
$list[$key]['mfg_name'] =__($list[$key]->mfgname == null ?'': $list[$key]->mfgname['mfgname']);
|
||||
$list[$key]['parttype'] =__($list[$key]->pdmParttype ==null?'': $list[$key]->pdmParttype['name']);
|
||||
$list[$key]['mfg_name'] =__($list[$key]->pdmMfgName == null ?'': $list[$key]->pdmMfgName['mfgname']);
|
||||
$list[$key]['mpn'] =__($list[$key]->pdmPurchasecode == null ?'': $list[$key]->pdmPurchasecode['mpn']);
|
||||
|
||||
// if($list[$key]->mfgname == null){
|
||||
// $list[$key]['mfg_name'] ='';
|
||||
// }else{
|
||||
// $list[$key]['mfg_name'] =$list[$key]->mfgname['mfgname'];
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
return [$count, $list->toArray()];
|
||||
$list = $list->toArray();
|
||||
if(!empty($list) && is_array($list)){
|
||||
$nodeid = array();
|
||||
foreach($list as $key => $value){
|
||||
if($value['pid'] == 0 ){
|
||||
$nodeid[] = $value['id'];
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if(!empty($nodevalue)){
|
||||
$list[] = &$nodevalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$list = list_sort_by($list,'id','asc');
|
||||
// usort($list, function($a, $b) {
|
||||
// return $a['id'] <=> $b['id']; // 对 'id' 进行升序排序
|
||||
// });
|
||||
// throw new \Exception(json_encode($list));
|
||||
}
|
||||
return [$count, $list];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,6 +151,8 @@ class PdmPartitemIndex extends AdminController
|
||||
*/
|
||||
public function add(): Response
|
||||
{
|
||||
$parttype = PdmParttypeModel::select()->toArray();
|
||||
|
||||
if (request()->isPost()) {
|
||||
$post = \request()->post();
|
||||
// validate(\app\common\validate\system\AdminRules::class . '.add')->check($post);
|
||||
@@ -114,7 +172,9 @@ class PdmPartitemIndex extends AdminController
|
||||
list($count, $list) = PdmPartitemIndex::dataList(request()->all());
|
||||
return view('/pdm_partitem_index/add', [
|
||||
'data' => $data,
|
||||
'rules' => json_encode( list_to_tree($list), JSON_UNESCAPED_UNICODE),
|
||||
'parttype' => json_encode( list_to_tree($parttype), JSON_UNESCAPED_UNICODE),
|
||||
// 'parttype' => $this->parttype,
|
||||
'list' => json_encode( list_to_tree($list), JSON_UNESCAPED_UNICODE),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -129,6 +189,15 @@ class PdmPartitemIndex extends AdminController
|
||||
{
|
||||
$id = input('id', 0);
|
||||
$data = $this->model->find($id);
|
||||
$parttypeid = $data['parttypeid'];
|
||||
|
||||
// $parems['id'] = input('parttypeid', 0);
|
||||
$parems = PdmParttypeModel::find($parttypeid)->toArray();
|
||||
// throw new \Exception(json_encode($parems));
|
||||
// $parttype = PdmParttypeModel::find($parttypeid);
|
||||
list($count, $parttype) = \app\admin\controller\PdmParttype::dataList($parems);
|
||||
// $parttype = PdmParttypeModel::select()->toArray();
|
||||
|
||||
if (request()->isPost()) {
|
||||
$post = \request()->post();
|
||||
// validate(\app\common\validate\system\AdminRules::class . '.edit')->check($post);
|
||||
@@ -137,10 +206,14 @@ class PdmPartitemIndex extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
list($count, $list) = PdmPartitemIndex::dataList(request()->all());
|
||||
list($count, $list) = PdmPartitemIndex::dataList(request()->all());
|
||||
// throw new \Exception(json_encode($parttype));
|
||||
// throw new \Exception( json_encode(list_to_tree($parttype)));
|
||||
return view('/pdm_partitem_index/add', [
|
||||
'data' => $data,
|
||||
'rules' => json_encode( list_to_tree($list), JSON_UNESCAPED_UNICODE),
|
||||
'parttype' => json_encode( list_to_tree($parttype), JSON_UNESCAPED_UNICODE),
|
||||
// 'parttype' => json_encode( $parttype, JSON_UNESCAPED_UNICODE),
|
||||
'list' => json_encode( list_to_tree($list), JSON_UNESCAPED_UNICODE),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace app\admin\controller;
|
||||
use app\AdminController;
|
||||
use Webman\Http\Request;
|
||||
use app\admin\model\PdmPartitemRelation as PdmPartitemRelationModel;
|
||||
use support\Response;
|
||||
|
||||
/**
|
||||
* pdm_partitem_relation
|
||||
@@ -30,7 +31,118 @@ class PdmPartitemRelation extends AdminController
|
||||
* 默认生成的方法为index/add/edit/del/status 五个方法
|
||||
* 当创建CURD的时候,DIY的函数体和模板为空,请自行编写代码
|
||||
*/
|
||||
|
||||
|
||||
public function index(): Response
|
||||
{
|
||||
if (request()->isAjax()) {
|
||||
list($count, $list) = PdmPartitemRelation::dataList(request()->all());
|
||||
// $rules = list_to_tree($list,'id','pid','children',0);
|
||||
$lists = list_to_tree($list,'id','pid','children',0);
|
||||
|
||||
return $this->success('获取成功', '/',$lists, $count);
|
||||
// return $this->success('获取成功', '/');
|
||||
}
|
||||
|
||||
return view('/pdm_partitem_relation/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取资源列表
|
||||
* @param array $params
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function dataList(array $params): array
|
||||
{
|
||||
// $where = array();
|
||||
// if (!empty($params['partnumber'])) {
|
||||
// $where[] = ['partnumber','like','%'.$params['partnumber'].'%'];
|
||||
// }
|
||||
// if (!empty($params['content'])) {
|
||||
// $where[] = ['content','like','%'.$params['content'].'%'];
|
||||
// }
|
||||
// $model = new PdmPartitemIndexModel();
|
||||
// // $model = $this->model;
|
||||
// $count = $model->where($where)->count();
|
||||
// // $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
// $list = $model->where($where)->order('sort asc')->select();
|
||||
// foreach($list as $key => $value){
|
||||
// // throw new \Exception(json_encode($value));
|
||||
// // throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
// $list[$key]['creator'] =__($list[$key]->admin == null?'': $list[$key]->admin['nickname']);
|
||||
// $list[$key]['parttype'] =__($list[$key]->parttype ==null?'': $list[$key]->parttype['name']);
|
||||
// $list[$key]['mfg_name'] =__($list[$key]->mfgname == null ?'': $list[$key]->mfgname['mfgname']);
|
||||
// // if($list[$key]->mfgname == null){
|
||||
// // $list[$key]['mfg_name'] ='';
|
||||
// // }else{
|
||||
// // $list[$key]['mfg_name'] =$list[$key]->mfgname['mfgname'];
|
||||
// // }
|
||||
|
||||
// }
|
||||
|
||||
// return [$count, $list->toArray()];
|
||||
|
||||
$page = (int)input('page', 1);
|
||||
$limit = (int)input('limit', 18);
|
||||
$where = $this->buildSelectParams();
|
||||
$count = $this->model->where($where)->count();
|
||||
$fieldList = $this->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 = '( 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 函数返回为空!
|
||||
|
||||
foreach($list as $key => $value){
|
||||
// throw new \Exception(json_encode($value));
|
||||
// throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
$list[$key]['creator'] =__($list[$key]->admin == null?'': $list[$key]->admin['nickname']);
|
||||
// $list[$key]['parttype'] =__($list[$key]->pdmParttype ==null?'': $list[$key]->pdmParttype['name']);
|
||||
// $list[$key]['mfg_name'] =__($list[$key]->pdmMfgName == null ?'': $list[$key]->pdmMfgName['mfgname']);
|
||||
// $list[$key]['mpn'] =__($list[$key]->pdmPurchasecode == null ?'': $list[$key]->pdmPurchasecode['mpn']);
|
||||
$list[$key]['purchasecode'] =__($list[$key]->pdmPartitemIndex == null ?'': $list[$key]->pdmPartitemIndex['purchasecode']);
|
||||
$list[$key]['symbolname'] =__($list[$key]->pdmSymbol == null ?'': $list[$key]->pdmSymbol['symbolname']);
|
||||
$list[$key]['footprint'] =__($list[$key]->pdmFootprint == null ?'': $list[$key]->pdmFootprint['footprint']);
|
||||
$list[$key]['departmenttitle'] =__($list[$key]->department == null ?'': $list[$key]->department['title']);
|
||||
|
||||
// if($list[$key]->mfgname == null){
|
||||
// $list[$key]['mfg_name'] ='';
|
||||
// }else{
|
||||
// $list[$key]['mfg_name'] =$list[$key]->mfgname['mfgname'];
|
||||
// }
|
||||
}
|
||||
|
||||
$list = $list->toArray();
|
||||
if(!empty($list) && is_array($list)){
|
||||
$nodeid = array();
|
||||
foreach($list as $key => $value){
|
||||
if($value['pid'] == 0 ){
|
||||
$nodeid[] = $value['id'];
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if(!empty($nodevalue)){
|
||||
$list[] = &$nodevalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$list = list_sort_by($list,'id','asc');
|
||||
// usort($list, function($a, $b) {
|
||||
// return $a['id'] <=> $b['id']; // 对 'id' 进行升序排序
|
||||
// });
|
||||
// throw new \Exception(json_encode($list));
|
||||
}
|
||||
return [$count, $list];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -55,31 +55,144 @@ class PdmParttype extends AdminController
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
// public function dataList(array $params): array
|
||||
// {
|
||||
// // $where = array();
|
||||
// // if (!empty($params['name'])) {
|
||||
// // $where[] = ['name','like','%'.$params['name'].'%'];
|
||||
// // }
|
||||
// // if (!empty($params['value'])) {
|
||||
// // $where[] = ['value','like','%'.$params['value'].'%'];
|
||||
// // }
|
||||
// // $model = new PdmParttypeModel();
|
||||
// // $count = $model->where($where)->count();
|
||||
// // // $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
// // $list = $model->where($where)->order('sort asc')->select();
|
||||
|
||||
// // foreach ($list as $key => $value) {
|
||||
// // // $list[$key]['name'] = __($value['name']);
|
||||
// // $list[$key]['creator'] = __($list[$key]->admin['nickname']);
|
||||
|
||||
// // }
|
||||
|
||||
// // return [$count, $list->toArray()];
|
||||
|
||||
// $where = $this->buildSelectParams();
|
||||
// $count = $this->model->where($where)->count();
|
||||
// $fieldList = $this->model->getFields();
|
||||
// $order = !array_key_exists('sort', $fieldList) ? 'id' : 'sort';
|
||||
// $subQuery = $this->model->field('id')->where($where)->order($order, 'asc')->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 函数返回为空!
|
||||
|
||||
// foreach($list as $key => $value){
|
||||
// // throw new \Exception(json_encode($value));
|
||||
// // throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
// // $list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
// $list[$key]->admin;
|
||||
// }
|
||||
// $list = $list->toArray();
|
||||
// if(!empty($list) && is_array($list)){
|
||||
// $nodeid = array();
|
||||
// foreach($list as $key => $value){
|
||||
// if($value['pid'] == 0 ){
|
||||
// $nodeid[] = $value['id'];
|
||||
// }
|
||||
// }
|
||||
|
||||
// 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();
|
||||
|
||||
// if(!empty($nodevalue)){
|
||||
// $list[] = &$nodevalue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// $list = list_sort_by($list,'id','asc');
|
||||
// // usort($list, function($a, $b) {
|
||||
// // return $a['id'] <=> $b['id']; // 对 'id' 进行升序排序
|
||||
// // });
|
||||
// // throw new \Exception(json_encode($list));
|
||||
// }
|
||||
// return [$count, $list];
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public static function dataList(array $params): array
|
||||
{
|
||||
$where = array();
|
||||
if (!empty($params['name'])) {
|
||||
$where[] = ['name','like','%'.$params['name'].'%'];
|
||||
}
|
||||
if (!empty($params['value'])) {
|
||||
$where[] = ['value','like','%'.$params['value'].'%'];
|
||||
}
|
||||
$model = new PdmParttypeModel();
|
||||
$count = $model->where($where)->count();
|
||||
// $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
$list = $model->where($where)->order('sort asc')->select();
|
||||
// $where = array();
|
||||
// if (!empty($params['name'])) {
|
||||
// $where[] = ['name','like','%'.$params['name'].'%'];
|
||||
// }
|
||||
// if (!empty($params['value'])) {
|
||||
// $where[] = ['value','like','%'.$params['value'].'%'];
|
||||
// }
|
||||
// $model = new PdmParttypeModel();
|
||||
// $count = $model->where($where)->count();
|
||||
// // $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
// $list = $model->where($where)->order('sort asc')->select();
|
||||
|
||||
foreach ($list as $key => $value) {
|
||||
// $list[$key]['name'] = __($value['name']);
|
||||
$list[$key]['creator'] = __($list[$key]->admin['nickname']);
|
||||
// foreach ($list as $key => $value) {
|
||||
// // $list[$key]['name'] = __($value['name']);
|
||||
// $list[$key]['creator'] = __($list[$key]->admin['nickname']);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
// return [$count, $list->toArray()];
|
||||
|
||||
$controller = new PdmParttype();
|
||||
|
||||
$where = $controller->buildSelectParams();
|
||||
$count = $controller->model->where($where)->count();
|
||||
$fieldList = $controller->model->getFields();
|
||||
$order = !array_key_exists('sort', $fieldList) ? 'id' : 'sort';
|
||||
$subQuery = $controller->model->field('id')->where($where)->order($order, 'asc')->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 = $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));
|
||||
// throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
// $list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
$list[$key]->admin;
|
||||
}
|
||||
$list = $list->toArray();
|
||||
if(!empty($list) && is_array($list)){
|
||||
$nodeid = array();
|
||||
foreach($list as $key => $value){
|
||||
if($value['pid'] == 0 ){
|
||||
$nodeid[] = $value['id'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach($list as $key => $value){
|
||||
if(!in_array($value['pid'],$nodeid) && $value['pid'] > 0){
|
||||
$nodeid[] = $value['pid'];
|
||||
$nodevalue = $controller->model->find($value['pid']);
|
||||
$nodevalue = $controller->model->find($value['pid'])->toArray();
|
||||
|
||||
if(!empty($nodevalue)){
|
||||
$list[] = &$nodevalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$list = list_sort_by($list,'id','asc');
|
||||
// usort($list, function($a, $b) {
|
||||
// return $a['id'] <=> $b['id']; // 对 'id' 进行升序排序
|
||||
// });
|
||||
// throw new \Exception(json_encode($list));
|
||||
}
|
||||
return [$count, $list];
|
||||
|
||||
return [$count, $list->toArray()];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加节点数据
|
||||
* @return Response
|
||||
|
||||
@@ -30,7 +30,51 @@ class PdmPurchasecode extends AdminController
|
||||
* 默认生成的方法为index/add/edit/del/status 五个方法
|
||||
* 当创建CURD的时候,DIY的函数体和模板为空,请自行编写代码
|
||||
*/
|
||||
|
||||
|
||||
public function index(): \support\Response
|
||||
{
|
||||
|
||||
|
||||
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();
|
||||
// }
|
||||
|
||||
// 生成查询数据
|
||||
$where = $this->buildSelectParams();
|
||||
$fieldList = $this->model->getFields();
|
||||
$order = !array_key_exists('sort', $fieldList) ? 'id' : 'sort';
|
||||
// $where[] = ['pid','in',$pid];
|
||||
// $where[] = [];
|
||||
if (!empty($post['keyword'])) {
|
||||
$where[] = ['partnumber|purchasecode|parttype|value|description|mpn|mfgname|symbol|footprint|datasheet|usernickname|department','like','%'.$post['keyword'].'%'];
|
||||
// $where[] = ['reference','like','%'.$post['keyword'].'%'];
|
||||
// $where[] = ['content','like','%'.$post['keyword'].'%'];
|
||||
// $where[] = ['item','like','%'.$post['keyword'].'%'];
|
||||
}
|
||||
|
||||
$count = $this->model->where($where)->count();
|
||||
$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->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);
|
||||
}
|
||||
|
||||
return $this->view();
|
||||
// return view('/pdm_partitem_view/index',[ ]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -58,27 +58,66 @@ class PdmSymbol extends AdminController
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public static function dataList(array $params): array
|
||||
public function dataList(array $params): array // static 限定后, $this-> 不可用。
|
||||
{
|
||||
$where = array();
|
||||
if (!empty($params['symbolname'])) {
|
||||
$where[] = ['symbolname','like','%'.$params['symbolname'].'%'];
|
||||
}
|
||||
if (!empty($params['content'])) {
|
||||
$where[] = ['content','like','%'.$params['content'].'%'];
|
||||
}
|
||||
$model = new PdmSymbolModel();
|
||||
// $model = $this->model;
|
||||
$count = $model->where($where)->count();
|
||||
// $list = $model->where($where)->order('sort asc')->select()->toArray();
|
||||
$list = $model->where($where)->order('sort asc')->select();
|
||||
// $where = array();
|
||||
// if (!empty($params['status'])) {
|
||||
// // $where[] = ['status','=',$params['status']];
|
||||
// $where[]=['status','=',$params['status']==1?0:1];
|
||||
// }
|
||||
// if (!empty($params['keyword'])) {
|
||||
// $where[] = ['symbolname|view|attachment|content','like','%'.$params['keyword'].'%'];
|
||||
// }
|
||||
// $count = $this->model->where($where)->count();
|
||||
// $list = $this->model->where($where)->order('sort asc')->select()->toArray();
|
||||
|
||||
$where = $this->buildSelectParams();
|
||||
$count = $this->model->where($where)->count();
|
||||
$fieldList = $this->model->getFields();
|
||||
$order = !array_key_exists('sort', $fieldList) ? 'id' : 'sort';
|
||||
$subQuery = $this->model->field('id')->where($where)->order($order, 'asc')->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 函数返回为空!
|
||||
|
||||
foreach($list as $key => $value){
|
||||
// throw new \Exception(json_encode($value));
|
||||
// throw new \Exception(json_encode($list[$key]->admin['nickname']));
|
||||
$list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
// $list[$key]['creator'] =__($list[$key]->admin['nickname']);
|
||||
$list[$key]->admin;
|
||||
}
|
||||
|
||||
return [$count, $list->toArray()];
|
||||
$list = $list->toArray();
|
||||
if(!empty($list) && is_array($list)){
|
||||
$nodeid = array();
|
||||
foreach($list as $key => $value){
|
||||
if($value['pid'] == 0 ){
|
||||
$nodeid[] = $value['id'];
|
||||
}
|
||||
}
|
||||
// throw new \Exception(json_encode($pidlist));
|
||||
foreach($list as $key => $value){
|
||||
if(!in_array($value['pid'],$nodeid) && $value['pid'] > 0){
|
||||
$nodeid[] = $value['pid'];
|
||||
$nodevalue = $this->model->find($value['pid']);
|
||||
// throw new \Exception(json_encode($nodevalue));
|
||||
$nodevalue = $this->model->find($value['pid'])->toArray();
|
||||
// throw new \Exception(json_encode($nodevalue));
|
||||
// throw new \Exception(json_encode($list));
|
||||
if(!empty($nodevalue)){
|
||||
$list[] = &$nodevalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
$list = list_sort_by($list,'id','asc');
|
||||
// usort($list, function($a, $b) {
|
||||
// return $a['id'] <=> $b['id']; // 对 'id' 进行升序排序
|
||||
// });
|
||||
// throw new \Exception(json_encode($list));
|
||||
}
|
||||
|
||||
// throw new \Exception(json_encode($list));
|
||||
|
||||
return [$count, $list];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user