|
@@ -0,0 +1,48 @@
|
|
|
+<?php
|
|
|
+declare (strict_types = 1);
|
|
|
+
|
|
|
+namespace app\admin\controller;
|
|
|
+
|
|
|
+use think\App;use think\facade\Validate;use think\Request;
|
|
|
+
|
|
|
+class ThStock extends Base
|
|
|
+{
|
|
|
+ protected $model=null;
|
|
|
+ public function __construct(App $app) {
|
|
|
+ parent::__construct($app);
|
|
|
+ $this->model=new \app\admin\model\ThStock();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function List(){
|
|
|
+ $param=$this->request->param(['start',"end","orderCode","thCode","good_code","companyNo","status"],"post","trim");
|
|
|
+ $where=[];
|
|
|
+ if($param['start']!='' && $param['end']!=""){
|
|
|
+ $where[]=["addtime","between",[date("Y-m-d 00:00:00",strtotime($param['start'])),date('Y-m-d 23:59:59',strtotime($param['end']))]];
|
|
|
+ }
|
|
|
+ $param['orderCode']==""?:$where[]=["orderCode","like","%{$param["orderCode"]}%"];
|
|
|
+ $param['thCode']==""?:$where[]=["thCode","like","%{$param["thCode"]}%"];
|
|
|
+ $param['thCode']==""?:$where[]=["thCode","like","%{$param["thCode"]}%"];
|
|
|
+ $param['companyNo']==""?:$where[]=["companyNo","=",$param["companyNo"]];
|
|
|
+ $param['status']==""?:$where[]=["status","=",$param["status"]];
|
|
|
+ $list=$this->model->with(["purcheaseOrder"])->order("id desc")->paginate(["list_rows"=>$param['size'],
|
|
|
+ "page"=>$param["page"]]);
|
|
|
+ return app_show(0,"获取成功",["list"=>$list->items(),"count"=>$list->total()]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function status(){
|
|
|
+ $param=$this->request->param(['id'=>"","rela_cgdNo"=>"","status"=>""],'post','trim');
|
|
|
+ $valid=Validate::rule([
|
|
|
+ "id|主键ID"=>"require|number|gt:0",
|
|
|
+ "rela_cgdNo|关联采购单编号"=>"requireIf:status,2|max:255|unique:th_stock",
|
|
|
+ "status|状态"=>"require|number|in:1,2,3"
|
|
|
+ ]);
|
|
|
+ if($valid->check($param)==false) return error_show(1004,$valid->getError());
|
|
|
+ $info =$this->model->findOrEmpty($param['id']);
|
|
|
+ if($info->isEmpty())return error_show(1004,'未找到数据');
|
|
|
+ $info->status=$param['status'];
|
|
|
+ $info->rela_cgdNo=$param['status']==3?"":$param['rela_cgdNo'];
|
|
|
+ $up =$info->save();
|
|
|
+ return $up?app_show(0,"数据更新成功"):error_show(1004,"数据更新失败");
|
|
|
+ }
|
|
|
+}
|