2024-08-23 16:04:38 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
declare (strict_types = 1);
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
|
|
|
|
|
|
use app\AdminController;
|
|
|
|
|
|
use Webman\Http\Request;
|
2024-12-29 22:18:05 +08:00
|
|
|
|
use app\admin\model\PdmPurchasecode as PdmPurchasecodeModel;
|
2024-08-23 16:04:38 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* pdm_purchasecode
|
|
|
|
|
|
* 采购编码
|
|
|
|
|
|
* <!--partmanage-->
|
|
|
|
|
|
* Class PdmPurchasecode
|
|
|
|
|
|
* @package app\admin\controller
|
|
|
|
|
|
*/
|
|
|
|
|
|
class PdmPurchasecode extends AdminController
|
|
|
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
|
|
|
* PdmPurchasecode模型对象
|
2024-12-29 22:18:05 +08:00
|
|
|
|
* @var \app\admin\model\PdmPurchasecode
|
2024-08-23 16:04:38 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
|
{
|
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
$this->model = new PdmPurchasecodeModel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 默认生成的方法为index/add/edit/del/status 五个方法
|
|
|
|
|
|
* 当创建CURD的时候,DIY的函数体和模板为空,请自行编写代码
|
|
|
|
|
|
*/
|
2025-01-06 00:06:03 +08:00
|
|
|
|
|
|
|
|
|
|
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();
|
2025-01-13 22:28:27 +08:00
|
|
|
|
$list = $this->model->with($this->relationModel)->where('id in' . $subQuery)->order($order, 'desc')->select() ;
|
2025-01-06 00:06:03 +08:00
|
|
|
|
// $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',[ ]);
|
|
|
|
|
|
}
|
2024-08-23 16:04:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-05-03 08:52:41 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 修改资源状态 -EOL
|
|
|
|
|
|
* @return Response|void
|
|
|
|
|
|
*/
|
|
|
|
|
|
public function statusEol()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (request()->isAjax()) {
|
|
|
|
|
|
|
|
|
|
|
|
$where[] = ['id', '=', input('id')];
|
|
|
|
|
|
if (!$this->authService->SuperAdmin() && $this->dataLimit
|
|
|
|
|
|
&& in_array($this->dataLimitField, $this->model->getFields())) {
|
|
|
|
|
|
$where[] = [$this->dataLimitField, '=', get_admin_id()];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
$this->status = $this->model->where($where)->update(['eol' => input('eol')]);
|
|
|
|
|
|
} catch (\Throwable $th) {
|
|
|
|
|
|
return $this->error($th->getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->status) {
|
|
|
|
|
|
return $this->success();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $this->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-23 16:04:38 +08:00
|
|
|
|
}
|