Commit 8e04c67a authored by xishifeng's avatar xishifeng Committed by hujun

优化所属部门所属门店

parent 1497e201
......@@ -96,8 +96,16 @@
<input type="text" class="form-control btn6" name="password" id="password" value="44444" placeholder="填写密码">
</div>
<div class="form-group">
<label class="col-sm-3 control-label">绑定门店ID:</label>
<input type="number" class="form-control btn6" name="store_id" value="" placeholder="填写门店ID">
<label class="col-sm-3 control-label">所属部门:</label>
<select name="district_id" class="form-control btn6">
<option value="">选择所属部门</option>
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">所属门店:</label>
<select name="store_id" class="form-control btn6">
</select>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">性别:</label>
......
......@@ -156,7 +156,7 @@
<input class="form-control btn2 margin-top-ld" data-rule-phoneus="false" data-rule-required="false" name="phone" placeholder="客户姓名或手机号" type="text" value="">
<input class="form-control btn2 margin-top-ld input" data-rule-phoneus="false" data-rule-required="false" name="invite_phone" placeholder="邀请人(C端用户)手机号" type="text" value="">
<input class="form-control btn2 margin-top-ld input" data-rule-phoneus="false" data-rule-required="false" name="invite_agent_phone" placeholder="邀请人(经纪人)手机号" type="text" value="">
<!--业态选择-->
<select class="form-control btn2 margin-top-ld" name="industry_type">
......@@ -199,30 +199,39 @@
<option value="2"></option>
<option value="1"></option>
</select>
<select class="form-control btn2 margin-top-ld input" name="" id="district_id" placeholder="" title="
<select class="form-control btn2 margin-top-ld" name="public_status">
<option value="2">客户状态</option>
<option value="0">求租</option>
<option value="1">已租</option>
<option value="-1">无效</option>
</select>
<select class="form-control btn2 margin-top-ld input" name="" id="district_id" title="
客方所属部门、客方所属门店 与邀请人所属部门、邀请人所属门店 不作为并列筛选项">
<option value="">客方所属部门</option>
</select>
<select class="form-control btn2 margin-top-ld input" name="" id="guest_stores" title="
客方所属部门、客方所属门店 与邀请人所属部门、邀请人所属门店 不作为并列筛选项" value="">
<input class="form-control btn2 margin-top-ld input" data-rule-phoneus="false" data-rule-required="false" id="guest_stores" placeholder="客方所属门店" type="text" value="" title="
客方所属部门、客方所属门店 与邀请人所属部门、邀请人所属门店 不作为并列筛选项">
</select>
<!--邀请人-->
<select class="form-control btn2 margin-top-ld input" name="" id="district_id2" placeholder="" title="
<select class="form-control btn2 margin-top-ld input" name="" id="district_id2" title="
客方所属部门、客方所属门店 与邀请人所属部门、邀请人所属门店 不作为并列筛选项">
<option value="">邀请人所属部门</option>
</select>
<input class="form-control btn2 margin-top-ld input" data-rule-phoneus="false" data-rule-required="false" id="guest_stores2" placeholder="邀请人所属门店" type="text" value="" title="
<select class="form-control btn2 margin-top-ld input" name="" id="guest_stores2" title="
客方所属部门、客方所属门店 与邀请人所属部门、邀请人所属门店 不作为并列筛选项">
</select>
<input class="form-control btn2 margin-top-ld input" data-rule-phoneus="false" data-rule-required="false" name="invite_agent_phone" placeholder="邀请人(经纪人)手机号" type="text" value="">
<!--<div class="clear"></div>-->
<!--<span class='left bottom'>(注:客方所属部门,客方所属门店与邀请人所属部门,邀请人所属门店不作为并列筛选项)</span>-->
<select class="form-control btn2 margin-top-ld" name="public_status">
<option value="2">客户状态</option>
<option value="0">求租</option>
<option value="1">已租</option>
<option value="-1">无效</option>
</select>
<div class="clear"></div>
......
......@@ -194,8 +194,7 @@
<select name="qx-store" class="form-control btn2" id="qx-store">
<option value="" selected="selected">选择部门</option>
</select>
<input class="form-control btn2" data-rule-phoneus="false" data-rule-required="false" id="mend_name" placeholder="门店名称" type="text" value="">
<select name="mend_name" class="form-control btn2" id="mend_name"></select>
<input class="form-control btn2" data-rule-phoneus="false" data-rule-required="false" id="name" placeholder="店长姓名" type="text" value="">
<input class="form-control btn2" data-rule-phoneus="false" data-rule-required="false" id="phone" placeholder="店长手机号" type="text" value="">
<span class="btn btn-default btn3" id="search">搜索</span>
......
......@@ -10,7 +10,25 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
agent.event();
},
event: function () {
var _doc = $(document);
agent.getDistrict(function(){
_doc.on('input', '[name=district_id]', function(){
var _this = $(this);
var _id = _this.val();
var _objTemp = _this.parent().next().find('select');
_objTemp.html('');//先清空
if(_id && _id != '0'){
agent.getDistrictStoreList(_id, function(_data){
var _str = '';
$.each(_data, function(i,item) {
_str += '<option value="'+item.id+'">'+item.store_name+'</option>';
});
_objTemp.html(_str);
});
}else{
};
});
})
$('#search').click(function (pageNo) {
agent.getList(1);
});
......@@ -23,6 +41,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
$("#title").html("新增经纪人");
$("#password").parent().addClass('hide'); //新增不显示密码
$(".form-horizontal")[0].reset(); //重置表单
agent.emptyInput();//清空表单
});
$(document).delegate(".edit", "click", function () {//点击编辑
......@@ -31,6 +50,7 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
agent.agent_id = $(this).attr("data-id");
$("#password").parent().removeClass('hide'); //编辑显示密码
$("#password").attr('type','text');
agent.emptyInput();//清空表单
agent.Edit();
});
......@@ -112,23 +132,35 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
success: function (data) {
if (data.code == 200) {
$("input[name = id]").val(data.data.id);
$("input[name = phone]").val(data.data.phone);
$("input[name = name]").val(data.data.name);
$("input[name = store_id]").val(data.data.store_id);
$("#admin_off").val(data.data.admin_off);
$("#remarks").val(data.data.remarks);
$("#password").val(data.data.password);
$("input[name='password']").attr('form-group');
// store.getDistrict(data.data.district_name);
if(data.data){
$("input[name = id]").val(data.data.id);
$("input[name = phone]").val(data.data.phone);
$("input[name = name]").val(data.data.name);
$("[name = district_id]").val(data.data.district_id);
if(data.data.district_id){
agent.getDistrictStoreList(data.data.district_id, function(_data){
var _str = '';
$.each(_data, function(i,item) {
_str += '<option value="'+item.id+'">'+item.store_name+'</option>';
});
$("[name = store_id]").html(_str).val(data.data.store_id);
});
}else{
}
$("#remarks").val(data.data.remarks);
$("#password").val(data.data.password);
$("input[name='password']").attr('form-group');
if (data.data.sex == '0') {
$("#sex0").attr('checked', true);
} else if (data.data.sex == '1') {
$("#sex1").attr('checked', true);
} else {
$("#sex2").attr('checked', true);
}
}
if (data.data.sex == '0') {
$("#sex0").attr('checked', true);
} else if (data.data.sex == '1') {
$("#sex1").attr('checked', true);
} else {
$("#sex2").attr('checked', true);
}
} else {
alert('获取经纪人数据失败');
}
......@@ -142,7 +174,8 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
params.id = agent.agent_id;
params.name = $("input[name = name]").val();
params.password = $("#password").val();
params.store_id = $("input[name = store_id]").val();
params.district_id = $("[name = district_id]").val();
params.store_id = $("[name = store_id]").val();
params.phone = $("input[name = phone]").val();
params.admin_off = $("#admin_off").val();
params.sex = $("input[name =sex]:checked").val();
......@@ -155,9 +188,16 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
alert('手机号必填!');
return false;
}
if (params.district_id == '') {
alert('所属部门必填');
$("#modal-edit").show();
return false;
}
if (params.store_id == '') {
alert('绑定门店ID必填');
alert('所属门店必填');
$("#modal-edit").show();
return false;
}
......@@ -184,6 +224,17 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
});
},
emptyInput: function(){
console.count('emptyInput');
$("input[name = name]").val('');
$("input[name = phone]").val('');
$("#password").val('');
$("[name = district_id]").val('');
$("[name = store_id]").html('');
$("input[name =sex]").val('0');
$("#admin_off").val('0');
$("#remarks").val('');
},
getList: function (pageNo) {
agent.pageNo = pageNo;
var params = {};
......@@ -229,6 +280,42 @@ define(['doT', 'text!temp/agent_template_tpl.html', 'css!style/home.css', 'pagin
}
});
},
getDistrict : function (fn) {
$.ajax ({
url: '/index/getDistrict',
type: 'GET',
async: true,
data: {"pageSize":1000},
dataType: 'json',
success: function (data) {
if (data.code == 200 && data.data != null) {
var str = '';
$.each(data.data, function(i,item) {
str += '<option value="'+item.id+'">'+item.district_name+'</option>';
});
$('[name=district_id]').append(str);
fn && fn();
}
}
});
},
getDistrictStoreList: function(id, fn){
$.ajax ({
url: '/index/getDistrictStoreList',
type: 'GET',
async: true,
data: {
'id':id,
"pageSize":1000
},
dataType: 'json',
success: function (data) {
if (data.code == 200 && data.data != null) {
fn && fn(data.data);
}
}
});
}
};
return agent;
......
......@@ -21,10 +21,10 @@ define(['doT', 'text!temp/store_template_tpl.html', 'css!style/home.css', 'ckfin
$("body").append(template);
store.getList();
store.event();
store.getRegionsDisc();
store.getDistrict();
},
event: function() {
var _doc = $(document);
$("#search").click(function() {
store.getList(1);
});
......@@ -32,6 +32,26 @@ define(['doT', 'text!temp/store_template_tpl.html', 'css!style/home.css', 'ckfin
$("#reset").click(function() { //重置
document.getElementById("form_search").reset();
});
store.getDistrict({
'type': 1
}, function(){
_doc.on('input', '#qx-store', function(){
var _this = $(this);
var _id = _this.val();
_this.next().html('');//先清空
if(_id && _id != '0'){
store.getDistrictStoreList(_id, function(_data){
var _str = '';
$.each(_data, function(i,item) {
_str += '<option value="'+item.store_name+'">'+item.store_name+'</option>';
});
_this.next().html(_str);
});
}else{
};
});
});
$(document).delegate(".del_modal", "click", function() {
store.id = $(this).attr("data-id");
......@@ -67,7 +87,6 @@ define(['doT', 'text!temp/store_template_tpl.html', 'css!style/home.css', 'ckfin
$ (document).delegate (".add", "click", function () {//list2消失
document.getElementById('form_id').reset();
store.getDistrict();
});
/************************************************百度地址定位相关*************************************************************/
......@@ -185,29 +204,6 @@ define(['doT', 'text!temp/store_template_tpl.html', 'css!style/home.css', 'ckfin
/************************************************百度地址定位相关****结束*************************************************************/
},
getRegionsDisc: function(name) {
var params = {};
params.parent_code = 310100;
$.ajax({
url: '/index/regions',
type: 'GET',
async: true,
data: params,
dataType: 'json',
success: function(data) {
if(data.code == 200) {
var _html = '';
$.each(data.data, function(i, n) {
_html += '<option value="' + n.fullName + '">' + n.fullName + '</option>';
});
$("#area").append(_html);
} else {
alert('请求省市区错误');
}
}
});
},
Edit:function(){//获取编辑的数据
$.ajax({
'type': 'GET',
......@@ -229,7 +225,10 @@ define(['doT', 'text!temp/store_template_tpl.html', 'css!style/home.css', 'ckfin
$("#latitude").val(data.data.latitude)//经纬度
store.agents_id=data.data.agents_id;//经纪人id
store.district_id=data.data.district_id;//部门id
store.getDistrict(data.data.district_name);
store.getDistrict({
'type': 2,
'name': data.data.district_name
});
}
else {
alert('获取失败!');
......@@ -350,7 +349,7 @@ define(['doT', 'text!temp/store_template_tpl.html', 'css!style/home.css', 'ckfin
}
});
},
getDistrict: function(name) {
getDistrict: function(obj, fn) {
$.ajax({
url: '/index/getDistrictListByName',
type: 'GET',
......@@ -359,24 +358,42 @@ define(['doT', 'text!temp/store_template_tpl.html', 'css!style/home.css', 'ckfin
dataType: 'json',
success: function(data) {
if(data.code == 200) {
var _html = ' <option value="" selected="selected">请选择</option>';
var _html = '';
$.each(data.data, function(i, n) {
if (n.district_name == name && (typeof name != undefined)) {
if (obj.type == '2' && n.district_name == obj.name) {
_html += '<option selected="selected" value="' + n.id + '">' + n.district_name + '</option>';
} else {
_html += '<option value="' + n.id + '">' + n.district_name + '</option>';
}
});
$("#ss-store").html(_html);
$("#qx-store").append(_html);
// $("#qx-store").html(_html);
if(obj.type == '2'){
$("#ss-store").html(_html);
}else if(obj.type == '1'){
$("#qx-store").append(_html);
}else{}
fn && fn();
} else {
alert('获取部门信息失败');
}
}
});
},
getDistrictStoreList: function(id, fn){
$.ajax ({
url: '/index/getDistrictStoreList',
type: 'GET',
async: true,
data: {
'id':id,
"pageSize":1000
},
dataType: 'json',
success: function (data) {
if (data.code == 200 && data.data != null) {
fn && fn(data.data);
}
}
});
}
};
return store;
......
......@@ -11,8 +11,6 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
$ ("body").append (template);
user.getList ();
user.event ();
user.getDistrict();
user.getDistricttwo();
//时间控件初始化
/* $('#datetimepicker').datetimepicker({
format: 'yyyy-MM-dd',
......@@ -24,6 +22,23 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
},
event: function () {
var _doc = $(document);
user.getDistrict(function(){
_doc.on('input', '#district_id, #district_id2', function(){
var _this = $(this);
var _id = _this.val();
_this.next().html('');//先清空
if(_id && _id != '0'){
user.getDistrictStoreList(_id, function(_data){
var _str = '';
$.each(_data, function(i,item) {
_str += '<option value="'+item.store_name+'">'+item.store_name+'</option>';
});
_this.next().html(_str);
});
}else{
};
});
});
$ (".Bannertu").click (function () {
BrowseServer ('cover_image');
});
......@@ -174,6 +189,7 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
});
// ===================
},
addphone:function(obj){
var user_ht=$(obj).html();
......@@ -377,15 +393,14 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
getList: function (pageNo) {
user.pageNo = pageNo;
var params = {};
console.log($("#start_date").val());
if($("#district_id").val()!=0||$("#guest_stores").val()!=''){
$("#district_id2").val('0');
$("#guest_stores2").val('');
};
if($("#district_id2").val()!=0||$("#guest_stores2").val()!=''){
$("#district_id1").val('0');
$("#guest_stores1").val('');
};
// if($("#district_id").val()!=0||$("#guest_stores").val()!=''){
// $("#district_id2").val('0');
// $("#guest_stores2").val('');
// };
// if($("#district_id2").val()!=0||$("#guest_stores2").val()!=''){
// $("#district_id1").val('0');
// $("#guest_stores1").val('');
// };
// 输入 name
// params.name = $("input[name='user']").val();
params.phone = $("input[name='phone']").val();
......@@ -430,11 +445,6 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
/*分页代码*/
add_page(data.data.total,pageNo,user.pageSize,user.getList);
$("#total_page").html(data.data.total);
console.log(data.data.total);
console.log(user.pageSize);
console.log(pageNo);
}
});
},
......@@ -520,40 +530,39 @@ define (['doT', 'text!temp/user_template_tpl.html','ckfinder','ckfinderStart', '
}
});
},
getDistrict : function () {
getDistrict : function (fn) {
$.ajax ({
url: '/index/getDistrict',
type: 'GET',
async: true,
data: {"pageSize":50},
data: {"pageSize":1000},
dataType: 'json',
success: function (data) {
if (data.code == 200 && data.data != null) {
var str = '<option value="0">客方所属部门</option>';
var str = '';
$.each(data.data, function(i,item) {
str += '<option value="'+item.id+'">'+item.district_name+'</option>';
});
$("#district_id").html(str);
$("#district_id").append(str);
$("#district_id2").append(str);
fn && fn();
}
}
});
},
getDistricttwo : function () {
$.ajax ({
url: '/index/getDistrict',
getDistrictStoreList: function(id, fn){
$.ajax ({
url: '/index/getDistrictStoreList',
type: 'GET',
async: true,
data: {"pageSize":50},
data: {
'id':id,
"pageSize":1000
},
dataType: 'json',
success: function (data) {
if (data.code == 200 && data.data != null) {
var str = '<option value="0">邀请人所属部门</option>';
$.each(data.data, function(i,item) {
str += '<option value="'+item.id+'">'+item.district_name+'</option>';
});
$("#district_id2").html(str);
fn && fn(data.data);
}
}
});
......
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