Commit 531c843f authored by hujun's avatar hujun

修改添加部门总监

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