|
@@ -17,12 +17,11 @@ class Cat extends Base
|
|
|
//树状列表
|
|
|
public function list()
|
|
|
{
|
|
|
- $param = $this->request->only(['pid' => 0, 'cat_name' => '', 'supplierNo' => ''], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['pid' => 0, 'cat_name' => ''], 'post', 'trim');
|
|
|
|
|
|
$where = [['is_del', '=', 0], ['pid', '=', $param['pid']]];
|
|
|
|
|
|
if ($param['cat_name'] !== '') $where[] = ['cat_name', 'like', '%' . $param['cat_name'] . '%'];
|
|
|
- if ($param['supplierNo'] !== '') $where[] = ['supplierNo', '=', $param['supplierNo']];
|
|
|
|
|
|
$data = Db::name('cat')->where($where)->cursor();
|
|
|
$vmp = [];
|
|
@@ -35,10 +34,9 @@ class Cat extends Base
|
|
|
//列表(含规格和创建人部门)
|
|
|
public function plist()
|
|
|
{
|
|
|
- $param = $this->request->only(['page' => 1, 'size' => 10, 'cat_name' => '', 'pid' => '', 'status' => '', 'company_name' => '', 'supplierNo' => ''], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['page' => 1, 'size' => 10, 'cat_name' => '', 'pid' => '', 'status' => '', 'company_name' => ''], 'post', 'trim');
|
|
|
$where = [['c.is_del', '=', 0]];
|
|
|
if ($param['cat_name'] !== '') $where[] = ['c.cat_name', 'like', '%' . $param['cat_name'] . '%'];
|
|
|
- if ($param['supplierNo'] !== '') $where[] = ['c.supplierNo', 'like', '%' . $param['supplierNo'] . '%'];
|
|
|
if ($param['pid'] !== '') $where[] = ['c.pid', '=', $param['pid']];
|
|
|
if ($param['status'] !== '') $where[] = ['c.status', '=', $param['status']];
|
|
|
if ($param['company_name'] !== '') $where[] = ['c.createrid', 'in', get_company_item_user_by_name($param['company_name'])];
|
|
@@ -81,14 +79,13 @@ class Cat extends Base
|
|
|
//查看所有三级分类
|
|
|
public function wlist()
|
|
|
{
|
|
|
- $param = $this->request->only(['page' => 1, 'size' => 10, 'cat_name' => '', 'search' => '', 'pid' => '', 'status' => '', 'supplierNo' => ''], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['page' => 1, 'size' => 10, 'cat_name' => '', 'search' => '', 'pid' => '', 'status' => ''], 'post', 'trim');
|
|
|
|
|
|
$where = [['is_del', '=', 0], ['level', '=', 3]];
|
|
|
if ($param['cat_name'] !== '') $where[] = ['cat_name', 'like', '%' . $param['cat_name'] . '%'];
|
|
|
if ($param['search'] !== '') $where[] = ['search', 'like', '%' . $param['search'] . '%'];
|
|
|
if ($param['pid'] !== '') $where[] = ['pid', '=', $param['pid']];
|
|
|
if ($param['status'] !== '') $where[] = ['status', '=', $param['status']];
|
|
|
- if ($param['supplierNo'] !== '') $where[] = ['supplierNo', '=', $param['supplierNo']];
|
|
|
|
|
|
$count = Db::name('cat')
|
|
|
->where($where)
|
|
@@ -110,14 +107,13 @@ class Cat extends Base
|
|
|
//列表
|
|
|
public function title()
|
|
|
{
|
|
|
- $param = $this->request->only(['cat_name' => '', 'pid' => '', 'status' => '', 'supplierNo' => ''], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['cat_name' => '', 'pid' => '', 'status' => '',], 'post', 'trim');
|
|
|
|
|
|
|
|
|
$where = [['is_del', '=', 0]];
|
|
|
if ($param['cat_name'] !== '') $where[] = ['cat_name', 'like', '%' . $param['cat_name'] . '%'];
|
|
|
if ($param['pid'] !== '') $where[] = ['pid', '=', $param['pid']];
|
|
|
if ($param['status'] !== '') $where[] = ['status', '=', $param['status']];
|
|
|
- if ($param['supplierNo'] !== '') $where[] = ['supplierNo', '=', $param['supplierNo']];
|
|
|
|
|
|
$list = Db::name('cat')
|
|
|
->where($where)
|
|
@@ -129,7 +125,7 @@ class Cat extends Base
|
|
|
//列表
|
|
|
public function tlist()
|
|
|
{
|
|
|
- $param = $this->request->only(['page' => 1, 'size' => 10, 'cat_name' => '', 'status' => '', 'creater' => '', 'start' => '', 'end' => '', 'company_name' => '', 'supplierNo' => ''], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['page' => 1, 'size' => 10, 'cat_name' => '', 'status' => '', 'creater' => '', 'start' => '', 'end' => '', 'company_name' => ''], 'post', 'trim');
|
|
|
|
|
|
|
|
|
$where = [['c.is_del', '=', 0]];
|
|
@@ -139,7 +135,6 @@ class Cat extends Base
|
|
|
if ($param['start'] !== '') $where[] = ['c.addtime', '>=', $param['start']];
|
|
|
if ($param['end'] !== '') $where[] = ['c.addtime', '<=', $param['end']];
|
|
|
if ($param['company_name'] !== '') $where[] = ['c.createrid', 'in', get_company_item_user_by_name($param['company_name'])];
|
|
|
- if ($param['supplierNo'] !== '') $where[] = ['c.supplierNo', 'like', '%' . $param['supplierNo'] . '%'];
|
|
|
|
|
|
$count = Db::name('cat')
|
|
|
->alias('c')
|
|
@@ -175,7 +170,7 @@ class Cat extends Base
|
|
|
//创建
|
|
|
public function create()
|
|
|
{
|
|
|
- $param = $this->request->only(['cat_name', 'pid', 'cat_desc' => '', 'fund_code' => '', 'specs_id', 'weight' => 0, 'status' => 0, 'ssupplierNo'], 'post', 'trim');
|
|
|
+ $param = $this->request->only(['cat_name', 'pid', 'cat_desc' => '', 'fund_code' => '', 'specs_id', 'weight' => 0, 'status' => 0], 'post', 'trim');
|
|
|
// $cat_name = isset($this->post['cat_name']) && $this->post['cat_name'] !== '' ? trim($this->post['cat_name']) : '';
|
|
|
$val = Validate::rule([
|
|
|
'cat_name|分类名称' => 'require|max:255',
|
|
@@ -183,7 +178,6 @@ class Cat extends Base
|
|
|
'specs_id' => 'require|array|max:100',
|
|
|
'weight|权重' => 'number|egt:0',
|
|
|
'status|状态' => 'number|in:0,1',
|
|
|
- 'ssupplierNo|公司编码' => 'require|length:18',
|
|
|
]);
|
|
|
|
|
|
if (!$val->check($param)) return json_show(1004, $val->getError());
|
|
@@ -252,7 +246,6 @@ class Cat extends Base
|
|
|
'status' => $param['status'],
|
|
|
'cat_desc' => $param['cat_desc'],
|
|
|
'fund_code' => $param['fund_code'],
|
|
|
- 'supplierNo' => $param['ssupplierNo'],
|
|
|
'creater' => $creater,
|
|
|
'createrid' => $createrid,
|
|
|
'is_del' => 0,
|
|
@@ -507,20 +500,36 @@ class Cat extends Base
|
|
|
//详情
|
|
|
public function info()
|
|
|
{
|
|
|
- $id = isset($this->post['id']) && $this->post['id'] !== '' ? intval($this->post['id']) : '';
|
|
|
- if ($id == '') {
|
|
|
- return error_show(1002, '参数id不能为空');
|
|
|
- }
|
|
|
- $idinfo = Db::name('cat')->where(['id' => $id])->find();
|
|
|
- if ($idinfo == '') {
|
|
|
- return error_show(1002, '未找到数据');
|
|
|
- }
|
|
|
- $info = Db::name('cat_specs')->where(['cat_id' => $idinfo['id'], 'is_del' => 0])->column('specs_id');
|
|
|
- $temp = Db::name('specs')->where(['id' => $info, 'is_del' => 0])->field('id,spec_name')->select();
|
|
|
+// $id = isset($this->post['id']) && $this->post['id'] !== '' ? intval($this->post['id']) : '';
|
|
|
+ $id = $this->request->post('id/d', 0, 'trim');
|
|
|
+// if ($id == '') {
|
|
|
+// return error_show(1002, '参数id不能为空');
|
|
|
+// }
|
|
|
+// $idinfo = Db::name('cat')->where(['id' => $id])->find();
|
|
|
+// if ($idinfo == '') {
|
|
|
+// return error_show(1002, '未找到数据');
|
|
|
+// }
|
|
|
+
|
|
|
+ $idinfo = Db::name('cat')
|
|
|
+ ->where(['id' => $id])
|
|
|
+ ->append(['spec'])
|
|
|
+ ->withAttr('spec', function ($val, $da) {
|
|
|
+ return Db::name('cat_specs')
|
|
|
+ ->alias('a')
|
|
|
+ ->leftJoin('specs b', 'b.id=a.specs_id')
|
|
|
+ ->where(['a.cat_id' => $da['id'], 'a.is_del' => 0])
|
|
|
+ ->field('a.specs_id,b.spec_name')
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ })
|
|
|
+ ->findOrEmpty();
|
|
|
+
|
|
|
+// $info = Db::name('cat_specs')->where(['cat_id' => $idinfo['id'], 'is_del' => 0])->column('specs_id');
|
|
|
+// $temp = Db::name('specs')->where(['id' => $info, 'is_del' => 0])->field('id,spec_name')->select();
|
|
|
//$idinfo['cat_id']=$info['cat_id'];
|
|
|
- $idinfo['spec'] = $temp;
|
|
|
+// $idinfo['spec'] = $temp;
|
|
|
// $idinfo['specs_id']=$info;
|
|
|
- return app_show(0, '获取成功', $idinfo);
|
|
|
+ return $idinfo ? json_show(0, '获取成功', $idinfo) : json_show(1002, '未找到数据');
|
|
|
}
|
|
|
|
|
|
//启禁用
|