作者 jinglong
1 个管道 的构建 通过 耗费 37 秒

修改企业领导多选以及相关程序

... ... @@ -441,7 +441,7 @@ class PersonController extends RestBaseController
}
}else if($identity == 1){
//领导
$where = ['u_l_id' => $this->userId];
$where = ['u_l_id' => ['like',','.$this->userId.',']];
$field = 'id c_id,company_name,pid';
$res = $this->getCompany($where,$field);
$result['company_name'] = $res['company_name'];
... ...
... ... @@ -57,7 +57,7 @@ class CommonController extends RestBaseController
}
}else if($identity == 1){
//领导
$where = ['u_l_id' => $this->userId];
$where = ['u_l_id' => ['like','%,'.$this->userId.',%']];
$field = 'id c_id,company_name,pid,logo,create_time';
$res = $this->getCompany($where,$field);
$result['company_name'] = $res['company_name'];
... ... @@ -556,7 +556,7 @@ class CommonController extends RestBaseController
}
}else if($identity == 1){
//领导
$where = ['u_l_id' => $uid];
$where = ['u_l_id' => ['like','%,'.$uid.',%']];
$field = 'id c_id,company_name,pid';
$res = $this->getCompany($where,$field);
//甲方
... ... @@ -617,7 +617,7 @@ class CommonController extends RestBaseController
}
}else if($identity == 1){
//领导
$where = ['u_l_id' => $uid];
$where = ['u_l_id' => ['like','%,'.$uid.',%']];
$field = 'id c_id,company_name,pid';
$res = $this->getCompany($where,$field);
//甲方
... ...
... ... @@ -11,6 +11,7 @@
namespace app\portal\controller;
use app\portal\model\UserModel;
use cmf\controller\AdminBaseController;
use app\portal\model\CompanyModel;
use think\Db;
... ... @@ -22,30 +23,26 @@ class AdminCompanyController extends AdminBaseController
//列表页
public function index(){
$list = Db::name('company')
->alias('c')
->join('user u','c.u_l_id = u.id','LEFT')
->where('c.pid',0)
->where('pid',0)
->where(function (Query $query) {
$data = $this->request->param();
if (!empty($data['company_name'])) {
$company_name = $data['company_name'];
$query->where('c.company_name', 'like', "%$company_name%");
}
if (!empty($data['user_login'])) {
$user_login = $data['user_login'];
$query->where('u.user_login', 'like', "%$user_login%");
}
if (!empty($data['mobile'])) {
$mobile = $data['mobile'];
$query->where('u.mobile', 'like', "%$mobile%");
$query->where('company_name', 'like', "%$company_name%");
}
})
->field('c.id,c.company_name,u.user_login,u.mobile')
->order('c.id desc')
->field('id,company_name,u_l_id')
->order('id desc')
->paginate(10,false,['query'=>request()->param()]);
$res = $list->toArray();
// 获取分页显示
$page = $list->render();
foreach($res['data'] as &$value){
$ids = explode(',',trim($value['u_l_id'],','));
$user = $this->getLeader($ids);
$value['user_login'] = $user['user_login'];
// $value['mobile'] = $user['mobile'];
}
$this->assign('list', $res['data']);
$this->assign('page', $page);
... ... @@ -57,6 +54,19 @@ class AdminCompanyController extends AdminBaseController
return $this->fetch();
}
//获取领导用户名
public function getLeader($ids){
$res = Db::name('user')
->whereIn('id',$ids)
->where('user_status',1)
->field('id,user_login,mobile')
->select()
->toArray();
$arr['user_login'] = implode(',',array_values(array_column($res,'user_login')));
// $arr['mobile'] = implode(',',array_values(array_column($res,'mobile')));
return $arr;
}
//新增页面
public function add(){
//查询领导
... ... @@ -108,7 +118,7 @@ class AdminCompanyController extends AdminBaseController
//乙方数据
$part_B['company_name'] = $data['company_name'];
//负责人uid
$part_B['u_l_id'] = $data['u_l_id'];
$part_B['u_l_id'] = ','.implode(',',$data['u_l_id']).',';
//员工uid,以逗号隔开
$part_B['u_s_id'] = ','.implode(',',$data['u_s_id']).',';
//营业执照
... ... @@ -133,7 +143,7 @@ class AdminCompanyController extends AdminBaseController
}
$part_A['is_children'] = $data['is_children'.$value];
//负责人uid
$part_A['u_l_id'] = $data['u_l_id'.$value];
$part_A['u_l_id'] = ','.implode(',',$data['u_l_id'.$value]).',';
//员工uid,以逗号隔开
$part_A['u_s_id'] = ','.implode(',',$data['u_s_id'.$value]).',';
//营业执照
... ... @@ -144,6 +154,17 @@ class AdminCompanyController extends AdminBaseController
$companyModel->create($part_A);
}
}
//创建乙方登录普通管理员账号
$userModel = new UserModel();
$arr['user_login'] = $res->company_name;
$arr['user_pass'] = cmf_password('123456');
$arr['company_id'] = $res->id;
$res1 = $userModel->create($arr);
//role_user表
$role['role_id'] = 2;
$role['user_id'] = $res1->id;
Db::name('RoleUser')->insert($role);
$this->success("添加成功!", url("AdminCompany/index"));
}
... ... @@ -154,6 +175,7 @@ class AdminCompanyController extends AdminBaseController
$res = Db::name('company')
->where('id',$id)
->find();
$res['u_l_id'] = explode(',',trim($res['u_l_id'],','));
$res['u_s_id'] = explode(',',trim($res['u_s_id'],','));
//获取甲方数据
$res1 = Db::name('company')
... ... @@ -161,9 +183,9 @@ class AdminCompanyController extends AdminBaseController
->select()
->toArray();
foreach($res1 as &$value){
$value['u_l_id'] = explode(',',trim($value['u_l_id'],','));
$value['u_s_id'] = explode(',',trim($value['u_s_id'],','));
}
//数组数量
$index = count($res1);
$this->assign('index',$index);
... ... @@ -221,7 +243,7 @@ class AdminCompanyController extends AdminBaseController
//乙方数据
$part_B['company_name'] = $data['company_name'];
//负责人uid
$part_B['u_l_id'] = $data['u_l_id'];
$part_B['u_l_id'] = ','.implode(',',$data['u_l_id']).',';
//员工uid,以逗号隔开
$part_B['u_s_id'] = ','.implode(',',$data['u_s_id']).',';
//营业执照
... ... @@ -230,7 +252,6 @@ class AdminCompanyController extends AdminBaseController
//公司logo
$part_B['logo'] = $data['logo'];
$companyModel->where('id',$data['id'])->update($part_B);
//甲方数据
if(isset($data['flag'])){
foreach($data['flag'] as $value){
... ... @@ -246,7 +267,7 @@ class AdminCompanyController extends AdminBaseController
}
$part_A['is_children'] = $data['is_children'.$value];
//负责人uid
$part_A['u_l_id'] = $data['u_l_id'.$value];
$part_A['u_l_id'] = ','.implode(',',$data['u_l_id'.$value]).',';
//员工uid,以逗号隔开
$part_A['u_s_id'] = ','.implode(',',$data['u_s_id'.$value]).',';
//营业执照
... ...
... ... @@ -138,7 +138,7 @@ class AdminIndexController extends AdminBaseController
$identity = $this->request->param('identity',0,'intval');
if($identity == 1){
//查询公司中是否存在领导
$res = $this->getCompanyLeader(['u_l_id'=>$id]);
$res = $this->getCompanyLeader(['u_l_id'=>['like','%'.','.$id.','.'%']]);
if($res){
$this->error('公司中存在该用户,不能删除!');
}
... ...
... ... @@ -87,7 +87,7 @@
<volist name="user_leader" id="vo">
<div class="users">
<div class="user_name">{$vo.user_login}</div>
<div class="box"><input type="radio" name="u_l_id" value="{$vo.id}"/></div>
<div class="box"><input type="checkbox" name="u_l_id[]" value="{$vo.id}"/></div>
</div>
</volist>
</div>
... ... @@ -381,7 +381,7 @@
a_company += '<volist name="user_leader" id="vo">';
a_company += '<div class="users">';
a_company += '<div class="user_name">{$vo.user_login}</div>';
a_company += '<div class="box"><input type="radio" name="u_l_id'+index+'" value="{$vo.id}"/></div>';
a_company += '<div class="box"><input type="checkbox" name="u_l_id'+index+'[]" value="{$vo.id}"/></div>';
a_company += '</div>';
a_company += '</volist>';
a_company += '</div>';
... ...
... ... @@ -67,7 +67,7 @@
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('AdminCompany/index')}">企业管理</a></li>
<li class="active"><a href="{:url('AdminCompany/add')}">添加企业</a></li>
<li class="active"><a href="{:url('AdminCompany/edit')}">编辑企业</a></li>
</ul>
<form action="{:url('AdminCompany/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
... ... @@ -88,7 +88,7 @@
<volist name="user_leader" id="vo">
<div class="users">
<div class="user_name">{$vo.user_login}</div>
<div class="box"><input type="radio" name="u_l_id" value="{$vo.id}" <eq name="vo.id" value="$post.u_l_id">checked</eq> /></div>
<div class="box"><input type="checkbox" name="u_l_id[]" value="{$vo.id}" <if condition='in_array($vo.id,$post.u_l_id)'> checked</if> /></div>
</div>
</volist>
</div>
... ... @@ -214,7 +214,7 @@
<volist name="user_leader" id="voo">
<div class="users">
<div class="user_name">{$voo.user_login}</div>
<div class="box"><input type="radio" name="u_l_id{$key1}" value="{$voo.id}" <eq name="voo.id" value="$vo.u_l_id">checked</eq>/></div>
<div class="box"><input type="checkbox" name="u_l_id{$key1}[]" value="{$voo.id}" <if condition='in_array($voo.id,$vo.u_l_id)'> checked</if>/></div>
</div>
</volist>
</div>
... ... @@ -443,7 +443,7 @@
a_company += '<volist name="user_leader" id="vo">';
a_company += '<div class="users">';
a_company += '<div class="user_name">{$vo.user_login}</div>';
a_company += '<div class="box"><input type="radio" name="u_l_id'+index+'" value="{$vo.id}"/></div>';
a_company += '<div class="box"><input type="checkbox" name="u_l_id'+index+'[]" value="{$vo.id}"/></div>';
a_company += '</div>';
a_company += '</volist>';
a_company += '</div>';
... ...
... ... @@ -10,12 +10,6 @@
企业名称:
<input class="form-control" type="text" name="company_name" style="width: 200px;" value="{:input('request.company_name')}"
placeholder="请输入企业名称">
负责人:
<input class="form-control" type="text" name="user_login" style="width: 200px;" value="{:input('request.user_login')}"
placeholder="请输入负责人">
电话号码:
<input class="form-control" type="text" name="mobile" style="width: 200px;" value="{:input('request.mobile')}"
placeholder="请输入电话号码">
<input type="submit" class="btn btn-primary" value="搜索"/>
<a class="btn btn-danger" href="{:url('AdminCompany/index')}">清空</a>
</form>
... ... @@ -31,7 +25,6 @@
<th>ID</th>
<th>企业名称(乙方)</th>
<th>负责人姓名(乙方)</th>
<th>手机号(乙方)</th>
<th>操作</th>
</tr>
</thead>
... ... @@ -45,7 +38,6 @@
<td>{$vo.id}</td>
<td>{$vo.company_name}</td>
<td>{$vo.user_login}</td>
<td>{$vo.mobile}</td>
<td width="150">
<a class="btn btn-xs btn-primary" href="{:url('AdminCompany/edit',array('id'=>$vo['id']))}">{:lang('EDIT')}</a>
<!--<a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('AdminCompany/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>-->
... ...