|
@@ -8,7 +8,7 @@ use think\App;
|
|
|
use think\facade\Db;
|
|
|
|
|
|
//单位
|
|
|
-class Unit extends BaseController
|
|
|
+class Unit extends Base
|
|
|
{
|
|
|
public $post ="";
|
|
|
public function __construct(App $app)
|
|
@@ -21,16 +21,16 @@ class Unit extends BaseController
|
|
|
if($unit==""){
|
|
|
return error_show(1002,"参数unit不能为空");
|
|
|
}
|
|
|
- $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
|
|
|
- if($token==''){
|
|
|
- return error_show(105,"参数token不能为空");
|
|
|
- }
|
|
|
- $user =GetUserInfo($token);
|
|
|
- if(empty($user)||$user['code']!=0){
|
|
|
- return error_show(1002,"创建人数据不存在");
|
|
|
- }
|
|
|
- $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
|
- $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
|
+// $token = isset($this->post['token'])&&$this->post['token']!='' ? trim($this->post['token']):"";
|
|
|
+// if($token==''){
|
|
|
+// return error_show(105,"参数token不能为空");
|
|
|
+// }
|
|
|
+// $user =GetUserInfo($token);
|
|
|
+// if(empty($user)||$user['code']!=0){
|
|
|
+// return error_show(1002,"创建人数据不存在");
|
|
|
+// }
|
|
|
+ $createrid= $this->uid;//isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
|
+ $creater= $this->uname;//isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
|
$status = isset($this->post['status']) &&$this->post['status'] !==""? intval($this->post['status']):"1";
|
|
|
$data=[
|
|
|
"unit"=>$unit,
|
|
@@ -56,8 +56,7 @@ class Unit extends BaseController
|
|
|
if($unit!==""){
|
|
|
$where[]=['u.unit',"like","%$unit%"];
|
|
|
}
|
|
|
- $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status'])
|
|
|
- :"";
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
|
|
|
if($status!==""){
|
|
|
$where[]=['u.status',"=",$status];
|
|
|
}
|
|
@@ -78,7 +77,6 @@ class Unit extends BaseController
|
|
|
$company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
|
|
|
if ($company_name !== "") $where[] = ["u.createrid", 'in', get_company_item_user_by_name($company_name)];
|
|
|
|
|
|
-
|
|
|
$count = Db::name('unit')
|
|
|
->alias('u')
|
|
|
->leftJoin("depart_user user", "user.uid=u.createrid AND user.is_del=0")
|
|
@@ -88,17 +86,20 @@ class Unit extends BaseController
|
|
|
$page = $page >= $total ? $total : $page;
|
|
|
$list = Db::name('unit')
|
|
|
->alias('u')
|
|
|
- ->field('u.*,user.itemid')
|
|
|
- ->leftJoin("depart_user user", "user.uid=u.createrid AND user.is_del=0")
|
|
|
->where($where)
|
|
|
->append(['company_name'])
|
|
|
- ->withAttr('company_name',function($val,$data){
|
|
|
- return implode('/', array_column(GetPart($data['itemid']), 'name'));
|
|
|
- })
|
|
|
->page($page,$size)
|
|
|
->order("addtime desc")
|
|
|
->select()
|
|
|
->toArray();
|
|
|
+
|
|
|
+ $all_createrid = array_column($list,'createrid');
|
|
|
+ $item = get_company_name_by_uid($all_createrid);
|
|
|
+
|
|
|
+ foreach ($list as &$val){
|
|
|
+ $val['company_name']=$item[$val['createrid']]??'';
|
|
|
+ }
|
|
|
+
|
|
|
return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
|
|
|
}
|
|
|
public function edit(){
|
|
@@ -142,7 +143,7 @@ class Unit extends BaseController
|
|
|
$json = json_encode($item,JSON_UNESCAPED_UNICODE);
|
|
|
$jsp = json_encode($info,JSON_UNESCAPED_UNICODE);
|
|
|
if($datainfo){
|
|
|
- ChangeLog::logAdd(4,$info['id'],$jsp,$json,$this->post['token'],$this->post);
|
|
|
+ ChangeLog::logAdd(4,$info['id'],$jsp,$json,['id'=>$this->uid,'nickname'=>$this->uname],$this->post);
|
|
|
return error_show(0,"更新成功");
|
|
|
}else{
|
|
|
return error_show(1002,"更新失败");
|