Commit e9ba5d9b authored by hujun's avatar hujun

经纪人编辑和权限控制

parent ad458d8b
...@@ -118,40 +118,41 @@ class Agent extends Basic ...@@ -118,40 +118,41 @@ class Agent extends Basic
public function saveAgent(){ public function saveAgent(){
$m_agent = new AAgents(); $m_agent = new AAgents();
$id = $this->params['id'];
if ($this->request->isPost()) { if ($this->request->isPost()) {
if (empty($this->params['store_id'])) {
return $this->response(101, '门店id为空!');
}
$password = $m_agent->verifyUser('password', '', ['phone'=> $this->params['phone']]);
//新增或者编辑数据 //新增或者编辑数据
if(empty($this->params['id'])) { if(empty($this->params['id'])) {
//判断name是否重复
if(!empty($password)) {
return $this->response(101, '手机号重复');
}
$data['create_time'] = date( 'Y-m-d H:i:s',time()); $data['create_time'] = date( 'Y-m-d H:i:s',time());
$data['update_time'] = date( 'Y-m-d H:i:s',time()); $data['update_time'] = date( 'Y-m-d H:i:s',time());
$id = 0; $id = 0;
$data['password'] = md5(substr($this->params['password'], -6)); //默认号码后6位
} else { } else {
$data['update_time'] = date( 'Y-m-d H:i:s',time()); $data['update_time'] = date( 'Y-m-d H:i:s',time());
$id = $this->params['id'];
}
//判断name是否重复 if (!empty($this->params['password'])) {
if(empty($id)) { $md5_password = md5($this->params['password']);
$num = $m_agent->getListDistrictTotal(['phone'=> $this->params['phone']]); if (($md5_password != $password['password']) && ($password['password'] != $this->params['password'])) {
if ($num > 0) { $data['password'] = $md5_password;
return $this->response(101, '手机号重复');
} }
} }
if (empty($this->params['store_id'])) {
return $this->response(101, '门店id为空!');
} }
$store = new AStore(); $store = new AStore();
$data['district_id'] = $store->getStoreKeyById('district_id', ['id'=>$this->params['store_id']]); $data['district_id'] = $store->getStoreKeyById('district_id', ['id'=>$this->params['store_id']]);
if (empty($data['password'])) {
$data['password'] = md5(substr($this->params['password'], -6));
} else {
$data['password'] = md5($this->params['password']);
}
$data['name'] = trim($this->params['name']); $data['name'] = trim($this->params['name']);
$data['store_id'] = $this->params['store_id']; $data['store_id'] = $this->params['store_id'];
$data['phone'] = trim($this->params['phone']); $data['phone'] = trim($this->params['phone']);
...@@ -159,7 +160,7 @@ class Agent extends Basic ...@@ -159,7 +160,7 @@ class Agent extends Basic
$data['sex'] = $this->params['sex']; $data['sex'] = $this->params['sex'];
$data['remarks'] = $this->params['remarks']; $data['remarks'] = $this->params['remarks'];
$data['auth_group_id'] = $this->params['auth_group_id']; $data['auth_group_id'] = $this->params['auth_group_id'];
dump($this->params);die;
if ($m_agent->editData($data, $id)) { if ($m_agent->editData($data, $id)) {
return $this->response(200, '成功'); return $this->response(200, '成功');
} else { } else {
...@@ -167,7 +168,7 @@ class Agent extends Basic ...@@ -167,7 +168,7 @@ class Agent extends Basic
} }
} else { } else {
//查看 //查看
$info = $m_agent->where('id',$group_id)->find(); $info = $m_agent->verifyUser('id,name,phone,password,store_id,sex,admin_off,remarks', '', ['id'=>$id]);
return $this->response(200, '查看', $info); return $this->response(200, '查看', $info);
} }
} }
...@@ -214,23 +215,17 @@ class Agent extends Basic ...@@ -214,23 +215,17 @@ class Agent extends Basic
if($table->saveStatus('auth_group_id', $data['group_id'], $ids)){ if($table->saveStatus('auth_group_id', $data['group_id'], $ids)){
$msg = '成功'; $msg = '成功';
} else { } else {
$code = '100'; $code = 101;
$msg = '失败'; $msg = '失败';
} }
} else { } else {
$msg = '数据为空'; $msg = '数据为空';
$code = 100; $code = 101;
} }
return $this->response($code,$msg, $data); return $this->response($code,$msg, $data);
} }
//
public function shop_district(){
}
/** /**
* 添加门店 * 添加门店
* @throws \Exception * @throws \Exception
......
...@@ -77,8 +77,8 @@ ...@@ -77,8 +77,8 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
× ×
</button> </button>
<h4 class="modal-title"> <h4 class="modal-title" id="title">
经纪人信息 经纪人编辑
</h4> </h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
</div> </div>
<div class="form-group hide"> <div class="form-group hide">
<label class="col-sm-3 control-label">密码:</label> <label class="col-sm-3 control-label">密码:</label>
<input type="number" class="form-control btn6" name="password" id="password" value="" placeholder="填写密码"> <input type="text" class="form-control btn6" name="password" id="password" value="44444" placeholder="填写密码">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">绑定门店ID:</label> <label class="col-sm-3 control-label">绑定门店ID:</label>
...@@ -169,7 +169,7 @@ ...@@ -169,7 +169,7 @@
<form class="form-horizontal"> <form class="form-horizontal">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">权限角色:</label> <label class="col-sm-3 control-label">权限角色:</label>
<select name="status" class="form-control btn6" id="User_add"> <select name="status" class="form-control btn6" id="edit_role">
</select> </select>
</div> </div>
</form> </form>
......
define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagination', 'bootstrapJs'], function (doT, template) { define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagination', 'bootstrapJs'], function (doT, template) {
var agent = { var agent = {
pageNo: 1, pageNo : 1,
pageSize: 15, pageSize : 15,
agent_id : 0,
init: function () { init: function () {
//初始化dot //初始化dot
$("body").append(template); $("body").append(template);
...@@ -19,37 +20,34 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin ...@@ -19,37 +20,34 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
}); });
$(document).delegate(".agent_add", "click", function () {//新增 $(document).delegate(".agent_add", "click", function () {//新增
$("#title").html("新增经纪人");
$("#password").parent().addClass('hide'); //新增不显示密码 $("#password").parent().addClass('hide'); //新增不显示密码
$(".form-horizontal")[0].reset(); //重置表单 $(".form-horizontal")[0].reset(); //重置表单
}); });
$(document).delegate(".edit", "click", function () {//点击编辑 $(document).delegate(".edit", "click", function () {//点击编辑
$("#title").html("编辑经纪人");
$(".form-horizontal")[0].reset(); //重置表单 $(".form-horizontal")[0].reset(); //重置表单
agent.house_id = $(this).attr("data-id"); agent.agent_id = $(this).attr("data-id");
$("#password").parent().removeClass('hide'); //编辑显示密码 $("#password").parent().removeClass('hide'); //编辑显示密码
agent.Edit();
});
$(document).delegate("#password", "click",function () {
$(this).val('').attr('type','password');
}); });
$(document).delegate(".submit_edit", "click", function () {//提交编辑 $(document).delegate(".submit_edit", "click", function () {//提交编辑
agent.Submit_edit(); agent.Submit_edit();
}); });
$(document).delegate(".User_add", "click", function () {//点击变更 $(document).delegate("#role", "click", function () {//变更角色
var vv = ''; agent.agent_id = $(this).attr("data-id");
var _idsv = ''; agent.getRole();
$("input[name=ids]:checked").each(function (i) {
vv += ',' + $(this).val();
_idsv = vv.substring(1);
});
if (_idsv == "0" || _idsv == "") {
alert("你还没有选择");
} else {
agent.User_add();
}
}); });
$(document).delegate(".submit_user", "click", function () {//提交变更 $(document).delegate(".submit_user", "click", function () {//提交变更
agent.Submit_user(); agent.Submit_user();
agent.getList();
}); });
$(document).delegate(".is_show", "click", function () {//点击禁用 $(document).delegate(".is_show", "click", function () {//点击禁用
...@@ -63,9 +61,11 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin ...@@ -63,9 +61,11 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
params.id = $(this).attr("data-id"); params.id = $(this).attr("data-id");
var str = $.trim($(this).html()); var str = $.trim($(this).html());
if (str === "正常") { if (str === "正常") {
$(this).attr('class','btn1 btn-default is_show');
params.type = 1; params.type = 1;
$(this).html('冻结'); $(this).html('冻结');
} else if (str === "冻结") { } else if (str === "冻结") {
$(this).attr('class','btn1 btn-info is_show');
params.type = 0; params.type = 0;
$(this).html('正常'); $(this).html('正常');
} else { } else {
...@@ -82,24 +82,18 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin ...@@ -82,24 +82,18 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
} }
} }
}); });
}); });
}, },
Submit_user: function () {//提交变更的信息 Submit_user: function () {//提交变更的信息
var v = ''; var group_id = $("#edit_role").val();
var _ids = '';
$("input[name=ids]:checked").each(function (i) {
v += ',' + $(this).val();
_ids = v.substring(1);
})
var group_id = $("#User_add").val();
$.ajax({ $.ajax({
'type': 'POST', 'type': 'POST',
'url': '/index/updateRole', 'url': '/index/updateRole',
data: { 'ids': _ids, 'group_id': group_id }, data: { 'ids': agent.agent_id, 'group_id': group_id },
dataType: "json", dataType: "json",
success: function (data) { success: function (data) {
if (data.code == 200) { if (data.code == 200) {
agent.getList(1);
} else { } else {
alert("重复提交"); alert("重复提交");
} }
...@@ -110,7 +104,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin ...@@ -110,7 +104,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
$.ajax({ $.ajax({
'type': 'GET', 'type': 'GET',
'url': '/index/saveAgent',//获取编辑数据 'url': '/index/saveAgent',//获取编辑数据
data: { "id": agent.house_id }, data: { "id": agent.agent_id },
dataType: "json", dataType: "json",
success: function (data) { success: function (data) {
...@@ -121,6 +115,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin ...@@ -121,6 +115,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
$("input[name = store_id]").val(data.data.store_id); $("input[name = store_id]").val(data.data.store_id);
$("#admin_off").val(data.data.admin_off); $("#admin_off").val(data.data.admin_off);
$("#remarks").val(data.data.remarks); $("#remarks").val(data.data.remarks);
$("#password").val(data.data.password);
$("input[name='password']").attr('form-group'); $("input[name='password']").attr('form-group');
if (data.data.sex == '0') { if (data.data.sex == '0') {
$("#sex0").attr('checked', true); $("#sex0").attr('checked', true);
...@@ -139,7 +134,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin ...@@ -139,7 +134,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
Submit_edit: function () { Submit_edit: function () {
//提交编辑的信息 //提交编辑的信息
var params = {} var params = {}
params.id = agent.house_id; params.id = agent.agent_id;
params.name = $("input[name = name]").val(); params.name = $("input[name = name]").val();
params.password = $("#password").val(); params.password = $("#password").val();
params.store_id = $("input[name = store_id]").val(); params.store_id = $("input[name = store_id]").val();
...@@ -175,7 +170,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin ...@@ -175,7 +170,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
dataType: "json", dataType: "json",
success: function (data) { success: function (data) {
if (data.code == 200) { if (data.code == 200) {
$("#modal-edit").model('hide'); $("#modal-edit").modal('hide');
agent.getList(1); agent.getList(1);
} else { } else {
alert(data.msg); alert(data.msg);
...@@ -206,6 +201,23 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin ...@@ -206,6 +201,23 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
add_page(data.data.total, pageNo, agent.pageSize, agent.getList); add_page(data.data.total, pageNo, agent.pageSize, agent.getList);
} }
}) })
},
getRole : function () {
$.ajax({
url: '/index/getAuth2',
type: 'GET',
data:{},
async: true,
dataType: 'json',
success: function (data) {
var User_add="";
$.each(data.data.list,function(i,item){
User_add+='<option value="'+item.id+'">'+item.title+'</option>';
});
$("#edit_role").html(User_add);
}
});
} }
}; };
return agent; return agent;
......
...@@ -17,11 +17,14 @@ ...@@ -17,11 +17,14 @@
[% if(it[item]["status"] == 0) { %] [% if(it[item]["status"] == 0) { %]
<a class="btn1 btn-info is_show" data-toggle="modal" data-id='[%= it[item]["id"] %]'>正常</a> <a class="btn1 btn-info is_show" data-toggle="modal" data-id='[%= it[item]["id"] %]'>正常</a>
[% }else if(it[item]["status"] == 1) { %] [% }else if(it[item]["status"] == 1) { %]
<a class="btn1 btn-info is_show" data-toggle="modal" data-id='[%= it[item]["id"] %]'>冻结</a> <a class="btn1 btn-default is_show" data-toggle="modal" data-id='[%= it[item]["id"] %]'>冻结</a>
[% }else{ %] [% }else{ %]
<a class="btn1 btn-default" data-toggle="modal" data-id='[%= it[item]["id"] %]'>离职</a> <a class="btn1 btn-default" data-toggle="modal" data-id='[%= it[item]["id"] %]'>离职</a>
[% } %] [% } %]
<a href="#modal-user" class="btn1 btn-danger" href="#modal-edit" data-toggle="modal" data-id='[%= it[item]["id"] %]'>角色设置</a>
[% if(check_auth('index/updateRole')) {%]
<a href="#modal-user" class="btn1 btn-danger" id='role' href="#modal-edit" data-toggle="modal" data-id='[%= it[item]["id"] %]'>角色设置</a>
[% } %]
</td> </td>
</tr> </tr>
[% } %] [% } %]
......
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