Commit 531c843f authored by hujun's avatar hujun

修改添加部门总监

parent c6595c37
...@@ -247,17 +247,17 @@ class Broker extends Basic ...@@ -247,17 +247,17 @@ class Broker extends Basic
// 查询电话跟进数据 // 查询电话跟进数据
$UPhoneFollowPp_res = $UPhoneFollowPp->select_useraction_search($user_id,$searchdate); $UPhoneFollowPp_res = $UPhoneFollowPp->select_useraction_search($user_id,$searchdate);
$table= new AAgents(); $agent = new AAgents();
foreach($UPhoneFollowPp_res as $k=>$v){ foreach($UPhoneFollowPp_res as $k=>$v){
$agents_res = $table->verifyUser('name,phone,img','',['id'=>$v['agent_id']]); $agents_res = $agent->verifyUser('name,phone,img','',['id'=>$v['agent_id']]);
$UPhoneFollowPp_res[$k]['agentinfo'] = $agents_res ? $agents_res['name'].'-'.$agents_res['phone']:'未知'; $UPhoneFollowPp_res[$k]['agentinfo'] = $agents_res ? $agents_res['name'].'-'.$agents_res['phone']:'未知';
$UPhoneFollowPp_res[$k]['user_pic'] = AGENTHEADERIMGURL.$agents_res['img']; $UPhoneFollowPp_res[$k]['user_pic'] = AGENTHEADERIMGURL.$agents_res['img'];
$UPhoneFollowPp_res[$k]['label'] = ''; $UPhoneFollowPp_res[$k]['label'] = '';
//电话跟进标签 //电话跟进标签
if($v['labels_id']){ if($v['labels_id']){
$table = new ULabels(); $labels = new ULabels();
$table_res = $table->get_labelsname($v['labels_id']); $table_res = $labels->get_labelsname($v['labels_id']);
$UPhoneFollowPp_res[$k]['label'] = $table_res[0]['name']; $UPhoneFollowPp_res[$k]['label'] = $table_res[0]['name'];
} }
} }
...@@ -266,8 +266,8 @@ class Broker extends Basic ...@@ -266,8 +266,8 @@ class Broker extends Basic
$user_res = $user->useraction_search_user_res($user_id); $user_res = $user->useraction_search_user_res($user_id);
$user_res['user_pic'] = HEADERIMGURL.$user_res['user_pic']; $user_res['user_pic'] = HEADERIMGURL.$user_res['user_pic'];
$table = new AAgents();
$agents_res = $table->verifyUser('name,phone','', ['id'=>$user_res['agent_id']]); $agents_res = $agent->verifyUser('name,phone','', ['id'=>$user_res['agent_id']]);
$user_res['agentinfo'] = $agents_res ? $agents_res['name'].'-'.$agents_res['phone']:'未知'; $user_res['agentinfo'] = $agents_res ? $agents_res['name'].'-'.$agents_res['phone']:'未知';
$records = new GOperatingRecords(); $records = new GOperatingRecords();
......
...@@ -45,7 +45,7 @@ class District extends Basic ...@@ -45,7 +45,7 @@ class District extends Basic
if ($this->params['district_name'] != NULL) { if ($this->params['district_name'] != NULL) {
if ($join == 0) { if ($join == 0) {
$field = 'a.id,a.district_name,a.create_time'; $field = 'a.id,a.district_name,a.create_time';
$where['status'] =0; $where['status'] = 0;
$where['district_name'] = ['LIKE', $this->params['district_name'].'%']; $where['district_name'] = ['LIKE', $this->params['district_name'].'%'];
} else { } else {
$where .= " AND district_name LIKE '{$this->params['district_name']}%'"; $where .= " AND district_name LIKE '{$this->params['district_name']}%'";
...@@ -113,9 +113,9 @@ class District extends Basic ...@@ -113,9 +113,9 @@ class District extends Basic
} }
if ($where) { if ($where) {
$agent = new ADistrict(); $district = new ADistrict();
$field = 'id,district_name'; $field = 'id,district_name';
$data['data'] = $agent->getList($pageNo, $pageSize, 'id DESC', $field, $where); $data['data'] = $district->getList($pageNo, $pageSize, 'id DESC', $field, $where);
} else { } else {
$data['msg'] = '没有部门信息'; $data['msg'] = '没有部门信息';
} }
......
...@@ -18,7 +18,8 @@ class ADistrict extends BaseModel ...@@ -18,7 +18,8 @@ class ADistrict extends BaseModel
* *
* @param $data * @param $data
* @param $agents_id * @param $agents_id
* @return bool * @return bool|mixed
* @throws \Exception
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function addDepartmentAgents($data, $agents_id) { public function addDepartmentAgents($data, $agents_id) {
...@@ -43,13 +44,22 @@ class ADistrict extends BaseModel ...@@ -43,13 +44,22 @@ class ADistrict extends BaseModel
$agents_info = $agents->where([ $agents_info = $agents->where([
'district_id'=>$id, 'level'=>['in','20,30,40'] 'district_id'=>$id, 'level'=>['in','20,30,40']
])->column('id,level'); ])->column('id,level');
foreach ($agents_info as $k=>$v) { $agents_data = [];
if ($agents_id != $k) {
//总监降级为业务员 if (empty($agents_info)) {
$agents_data[$k]['id'] = $k; $agents_data[0]['id'] = $agents_id;
$agents_data[$k]['level'] = 10; $agents_data[0]['level'] = 30;
$agents_data[$k]['district_id'] = $id; $agents_data[0]['district_id'] = $id;
} else { } else {
foreach ($agents_info as $k=>$v) {
if ($agents_id != $k) {
//总监降级为业务员
$agents_data[$k]['id'] = $k;
$agents_data[$k]['level'] = 10;
$agents_data[$k]['district_id'] = $id;
}
$k += 1;
if ($v == 20) { if ($v == 20) {
//店长升总监 //店长升总监
$agents_data[$k]['level'] = 40; $agents_data[$k]['level'] = 40;
...@@ -57,19 +67,20 @@ class ADistrict extends BaseModel ...@@ -57,19 +67,20 @@ class ADistrict extends BaseModel
//业务员升总监 //业务员升总监
$agents_data[$k]['level'] = 30; $agents_data[$k]['level'] = 30;
} }
$agents_data[$k]['id'] = $k; $agents_data[$k]['id'] = $agents_id;
$agents_data[$k]['district_id'] = $id; $agents_data[$k]['district_id'] = $id;
} }
} }
$agents->saveAll($agents_data); $agents->saveAll($agents_data);
$resutlt = $id; $result = $id;
$this->commit(); $this->commit();
} else { } else {
$resutlt = false; $result = false;
$this->rollback(); $this->rollback();
} }
return $resutlt; return $result;
} }
/** /**
...@@ -130,7 +141,7 @@ class ADistrict extends BaseModel ...@@ -130,7 +141,7 @@ class ADistrict extends BaseModel
if (isset($v->id)) { if (isset($v->id)) {
if ($result[$k]['district_name']) { if ($result[$k]['district_name']) {
$agents = Db::table('a_agents')->field('name,phone')->where([ $agents = Db::table('a_agents')->field('name,phone')->where([
'status'=>0,'district_id'=>$v->id 'status'=>0,'district_id'=>$v->id,'level'=>['in','30,40']
])->find(); ])->find();
$result[$k]['name'] = $agents['name'].'-'.$agents['phone']; $result[$k]['name'] = $agents['name'].'-'.$agents['phone'];
$result[$k]['store_num'] = Db::table('a_store')->where([ $result[$k]['store_num'] = Db::table('a_store')->where([
......
...@@ -3,6 +3,8 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa ...@@ -3,6 +3,8 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
pageNo: 1, /*第几页*/ pageNo: 1, /*第几页*/
pageSize: 10, /*每页显示多少条*/ pageSize: 10, /*每页显示多少条*/
pageNum:10, pageNum:10,
district : 0,
agent_id : 0,
init: function () { init: function () {
//初始化dot //初始化dot
$ ("body").append (template); $ ("body").append (template);
...@@ -14,15 +16,15 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa ...@@ -14,15 +16,15 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
district.getList(1); district.getList(1);
}); });
$ (document).delegate (".edit", "click", function () {//点击编辑 $ (document).delegate (".edit", "click", function () {//点击编辑
district.house_id = $ (this).attr ("data-id"); district.district_id = $ (this).attr ("data-id");
district.Edit(); district.Edit();
}); });
$ (document).delegate (".submit_edit", "click", function () {//提交编辑 $ (document).delegate (".submit_edit", "click", function () {//提交编辑
district.Submit_edit(); district.Submit_edit();
district.getList(); district.getList(1);
}); });
$ (document).delegate (".mend", "click", function () {//点击门店列表 $ (document).delegate (".mend", "click", function () {//点击门店列表
district.house_id = $ (this).attr ("data-id"); district.district_id = $ (this).attr ("data-id");
district.Mend(); district.Mend();
}); });
$(document).on('input','.phone_mend', function(e) {//搜索手机号码 $(document).on('input','.phone_mend', function(e) {//搜索手机号码
...@@ -43,11 +45,13 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa ...@@ -43,11 +45,13 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
}); });
$ (document).delegate (".mend_list li", "click", function () {//点击列表 $ (document).delegate (".mend_list li", "click", function () {//点击列表
var phone_name=$(this).find(".phone_name").html(); var phone_name=$(this).find(".phone_name").html();
var phone_id=$(this).find(".phone_id").html();
var phone_phone=$(this).find(".phone-phone").html(); var phone_phone=$(this).find(".phone-phone").html();
var phone_span=$(this).find(".phone_span").html(); var phone_span=$(this).find(".phone_span").html();
$(".phone_mend").val(phone_name+phone_span+phone_phone); $(".phone_mend").val(phone_name+phone_span+phone_phone);
$(this).parent().hide(); $(this).parent().empty();
district.ldHtml.html(''); district.agent_id = phone_id;
// district.ldHtml.html('');
return false; return false;
}); });
...@@ -56,7 +60,7 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa ...@@ -56,7 +60,7 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
$.ajax({ $.ajax({
'type': 'GET', 'type': 'GET',
'url' : '/index/adddistrict',//获取编辑数据 'url' : '/index/adddistrict',//获取编辑数据
data: {"id":district.house_id}, data: {"id":district.district_id},
dataType: "json", dataType: "json",
success: function(data){ success: function(data){
if (data.data) { if (data.data) {
...@@ -70,19 +74,17 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa ...@@ -70,19 +74,17 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
}); });
}, },
Submit_edit:function(){//提交编辑的信息 Submit_edit:function(){//提交编辑的信息
var par={}; var par ={};
par.id= district.house_id; par.id = district.district_id;
par.department_name=$("input[name =title]").val(); par.department_name = $("input[name =title]").val();
par.agents_id=$("input[name =agents_id]").val(); par.agents_id = district.agent_id;
$.ajax({ $.ajax({
'type': 'POST', 'type': 'POST',
'url' : '/index/adddistrict', 'url' : '/index/adddistrict',
data:par, data:par,
dataType: "json", dataType: "json",
success: function(data){ success: function(data){
if(data.code==200){ if(data.code != 200){
}else{
alert(data.msg); alert(data.msg);
} }
} }
...@@ -93,7 +95,7 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa ...@@ -93,7 +95,7 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
$.ajax({ $.ajax({
'type': 'GET', 'type': 'GET',
'url' : '/index/getDistrictStoreList',//门店 'url' : '/index/getDistrictStoreList',//门店
data: {"id":district.house_id}, data: {"id":district.district_id},
dataType: "json", dataType: "json",
success: function(data){ success: function(data){
if(data.code == 200){ if(data.code == 200){
...@@ -125,7 +127,7 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa ...@@ -125,7 +127,7 @@ define (['doT', 'text!temp/district_template_tpl.html', 'css!style/home.css','pa
if(data.code === 200){ if(data.code === 200){
var _html = ''; var _html = '';
$.each(data.data, function(i,data) { $.each(data.data, function(i,data) {
_html += '<li><span class="phone_name">'+data['name']+'</span><span class="phone_span">-</span><span class="phone-phone">'+data['phone']+'</span> </li>'; _html += '<li><span class="phone_id">'+data['id']+'</span><span class="phone_name">'+data['name']+'</span><span class="phone_span">-</span><span class="phone-phone">'+data['phone']+'</span> </li>';
}); });
$(".mend_list").html(_html); $(".mend_list").html(_html);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment