Commit 921e3cee authored by agping's avatar agping Committed by hujun

商铺列表修改

parent 90d88fa0
...@@ -2,650 +2,664 @@ ...@@ -2,650 +2,664 @@
* Created by 刘丹 on 2017/12/11. * Created by 刘丹 on 2017/12/11.
*/ */
define (['doT', 'text!temp/house_template_tpl.html', 'css!style/home.css','ckfinder','ckfinderStart','pagination','bootstrapJs'], function (doT, template) { define(['doT', 'text!temp/house_template_tpl.html', 'css!style/home.css', 'ckfinder', 'ckfinderStart', 'pagination', 'bootstrapJs'], function(doT, template) {
business = { business = {
pageNo: 1, /*第几页*/ pageNo: 1,
pageSize: 10, /*每页显示多少条*/ /*第几页*/
id : '', pageSize: 10,
house_id:'', /*每页显示多少条*/
type:'', id: '',
valueCurrent:'', house_id: '',
ajaxObj:'', type: '',
stopstatus:true, valueCurrent: '',
ldHtml: $('.phone_list'), ajaxObj: '',
boxphoto:'', stopstatus: true,
exclusive_id : 0, ldHtml: $('.phone_list'),
init: function () { boxphoto: '',
//初始化dot exclusive_id: 0,
$ ("body").append (template); init: function() {
business.getList (); //初始化dot
business.event (); $("body").append(template);
business.resetLoad(); function  getPreMonth(date)  {            
}, var  arr  =  date.split('-');            
event: function () { var  year  =  arr[0];             
var _doc = $(document); var  month  =  arr[1];             
$("#search").click(function () { var  day  =  arr[2];             
business.getList(1); var  days  =  new  Date(year,  month,  0);            
}); days  =  days.getDate();             
var  year2  =  year;            
$("#reset").click(function () {//重置 var  month2  =  parseInt(month)  -  1;            
document.getElementById("form_search").reset(); if (month2  ==  0)  {                
}); year2  =  parseInt(year2)  -  1;                
month2  =  12;            
$ (document).delegate (".del_modal", "click", function () { }            
business.id = $ (this).attr ("data-id"); var  day2  =  day;            
var  days2  =  new  Date(year2,  month2,  0);            
}); days2  =  days2.getDate();            
$ (document).delegate (".anch", "click", function () {//点击设置案场权限人 if (day2  >  days2)  {                
$("#myModalLabel").html("设置案场权限人"); day2  =  days2;            
// 传入data-id }            
business.house_id = $ (this).attr ("data-id"); if (month2  <  10)  {                
business.type="1"; month2  =  '0'  +  month2;            
business.Anch();//获取手机号名字的 }            
}); var  t2  =  year2  +  '-'  +  month2  +  '-'  +  day2;            
// 点击设置案场权限人(盘方) return  t2;        
$ (document).delegate (".add_applies", "click", function () {//点击设置案场权限人 }
$("#myModalLabel").html("设置盘方"); var myDate = new Date();
business.house_id = $ (this).attr ("data-id"); var y = myDate.getFullYear();
business.type="2"; var m = myDate.getMonth() + 1;
business.Anch(); var d = myDate.getDate();
}); var day_end = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
$ (document).delegate (".dujia", "click", function () {//点击独家 var day_start = getPreMonth(day_end);
business.house_id = $ (this).attr ("data-id"); $('#start_date').val(day_start);
business.type="3"; $('#end_date').val(day_end);
business.Dujia(); business.getList(1);
}); business.event();
$ (document).delegate (".caozuo", "click", function () {//点击操作记录 business.resetLoad();
business.house_id = $ (this).attr ("data-id"); },
business.Caozuo(); event: function() {
}); var _doc = $(document);
$ (document).delegate (".submit_follow2", "click", function () {//提交独家 $("#search").click(function() {
business.Dujianew(); business.getList(1);
}); });
// 提交按钮设置案场权限人 $("#reset").click(function() { //重置
$ (document).delegate (".submit_follow", "click", function () {//提交按钮设置案场权限人 document.getElementById("form_search").reset();
var myModalLabel = $("#myModalLabel").html(); });
if (myModalLabel == '设置案场权限人') { $(document).delegate(".del_modal", "click", function() {
business.Submit_follow(); business.id = $(this).attr("data-id");
} else {
business.Submit_follow2(); // 提交按钮设置盘方 });
} $(document).delegate(".anch", "click", function() { //点击设置案场权限人
}); $("#myModalLabel").html("设置案场权限人");
// 传入data-id
$ (document).delegate ("#confirm_delete", "click", function () { business.house_id = $(this).attr("data-id");
business.delBusiness(); business.type = "1";
}); business.Anch(); //获取手机号名字的
$ (document).delegate (".jia", "click", function () {//加号 });
business.jiabox(); // 点击设置案场权限人(盘方)
}); $(document).delegate(".add_applies", "click", function() { //点击设置案场权限人
$ (document).delegate (".addphone", "click", function () {//加号 $("#myModalLabel").html("设置盘方");
business.addphone(this); business.house_id = $(this).attr("data-id");
}); business.type = "2";
$ (document).delegate (".jian", "click", function () {//叉号 business.Anch();
business.jianbox(); });
}); $(document).delegate(".dujia", "click", function() { //点击独家
// 批量修改客方 business.house_id = $(this).attr("data-id");
$ (document).delegate ("#modify_add", "click", function () { business.type = "3";
business.modify_add(); business.Dujia();
}); });
// 批量修改客方 $(document).delegate(".caozuo", "click", function() { //点击操作记录
business.house_id = $(this).attr("data-id");
$(document).on('input','.phone_jia,.phone_add', function(e) {//搜索手机号码/加号搜索 business.Caozuo();
e.preventDefault(); });
e.stopPropagation(); $(document).delegate(".submit_follow2", "click", function() { //提交独家
var _this = $(this); business.Dujianew();
_this.next().css("display","block"); });
valueCurrent = _this.val();
// 提交按钮设置案场权限人
if(valueCurrent != ''){ $(document).delegate(".submit_follow", "click", function() { //提交按钮设置案场权限人
business.resetLoad(1); var myModalLabel = $("#myModalLabel").html();
business.loadMain(valueCurrent,_this.next());
console.log(_this.next()); if(myModalLabel == '设置案场权限人') {
}else{ business.Submit_follow();
business.ldHtml.html(''); } else {
return false; business.Submit_follow2(); // 提交按钮设置盘方
} }
});
});
$ (document).delegate (".is_show", "click", function () {//推荐至首页 $(document).delegate("#confirm_delete", "click", function() {
if (!confirm('是否继续?')) { business.delBusiness();
return ; });
} $(document).delegate(".jia", "click", function() { //加号
business.id = $ (this).attr ("data-id"); business.jiabox();
var params ={ });
$(document).delegate(".addphone", "click", function() { //加号
}; business.addphone(this);
params.id = $ (this).attr ("data-id"); });
var str = $.trim($(this).html()); $(document).delegate(".jian", "click", function() { //叉号
if (str === "推荐至首页") { business.jianbox();
params.type = 1; });
$(this).html('已推荐'); // 批量修改客方
} else { $(document).delegate("#modify_add", "click", function() {
params.type = 0; business.modify_add();
$(this).html('推荐至首页'); });
} // 批量修改客方
$.ajax({//推荐至首页
'type': 'POST', $(document).on('input', '.phone_jia,.phone_add', function(e) { //搜索手机号码/加号搜索
'url' : '/index/carefullyChosen', e.preventDefault();
data: {"houses_id":business.id,"is_carefully_chosen":params.type}, e.stopPropagation();
dataType: "json", var _this = $(this);
success: function(data){ _this.next().css("display", "block");
if(data.code == 200){ valueCurrent = _this.val();
if (data.data) {
} if(valueCurrent != '') {
} else { business.resetLoad(1);
alert("推荐失败!") business.loadMain(valueCurrent, _this.next());
} console.log(_this.next());
} } else {
}); business.ldHtml.html('');
return false;
}); }
$ (document).delegate ("#liudan_pic_btn", "click", function () {//上传图片
var img_url=""; });
BrowseServer ('liudan_pic_btn',function(url){ $(document).delegate(".is_show", "click", function() { //推荐至首页
var alt_img=$("#liudan_pic_btn").val(); if(!confirm('是否继续?')) {
alt_img = alt_img.replace('images/',''); return;
img_url+=' <img src="'+url+'" class="jai_dujia" data-img="'+alt_img+'">'; }
$("#liudan_pic_pre").append(img_url); business.id = $(this).attr("data-id");
}); var params = {
});
// 下拉列表 };
var _ajaxObjTel = null; params.id = $(this).attr("data-id");
_doc.on('input', '.phone_jia1' ,function(){ var str = $.trim($(this).html());
var _this = $(this), if(str === "推荐至首页") {
_thisVal = $.trim(_this.val()); params.type = 1;
_this.removeAttr('data-id');//移除之前携带的信息 $(this).html('已推荐');
if(_thisVal != ''){ } else {
_ajaxObjTel && _ajaxObjTel.abort(); params.type = 0;
_ajaxObjTel = $.ajax({ $(this).html('推荐至首页');
type: 'GET', }
url: '/index/getBroker_new', $.ajax({ //推荐至首页
data: { 'type': 'POST',
'phone': $.trim(_this.val()) 'url': '/index/carefullyChosen',
}, data: {
timeout: 30000, "houses_id": business.id,
dataType: 'json', "is_carefully_chosen": params.type
beforeSend: function() {}, },
success: function(data) { dataType: "json",
if(typeof data === 'object') { success: function(data) {
if (data.code == 200) { if(data.code == 200) {
if(data['data'].length > 0){ if(data.data) {}
var _htmlTemp = ''; } else {
$.each(data['data'], function(i, item) { alert("推荐失败!")
_htmlTemp += '<li data-id="{3}">{2}{0}-{1}<li>'.stringFormatObj({ }
'0': item['name'], }
'1': item['phone'], });
'2': _this.parent().nextAll('.input-add-tel').data('hideid')?'':(item['id']+'-'),
'3': item['id'] });
}); $(document).delegate("#liudan_pic_btn", "click", function() { //上传图片
}); var img_url = "";
// 输出trim BrowseServer('liudan_pic_btn', function(url) {
var alt_img = $("#liudan_pic_btn").val();
_this.next().show().html(_htmlTemp); alt_img = alt_img.replace('images/', '');
}else{ img_url += ' <img src="' + url + '" class="jai_dujia" data-img="' + alt_img + '">';
_this.next().html(''); $("#liudan_pic_pre").append(img_url);
}; });
}else { });
alert(data['msg']); // 下拉列表
}; var _ajaxObjTel = null;
}else{ _doc.on('input', '.phone_jia1', function() {
alert('数据错误'); var _this = $(this),
}; _thisVal = $.trim(_this.val());
}, _this.removeAttr('data-id'); //移除之前携带的信息
error: function() { if(_thisVal != '') {
//alert('error'); _ajaxObjTel && _ajaxObjTel.abort();
}, _ajaxObjTel = $.ajax({
complete: function(xhr, textStatus){ type: 'GET',
if(textStatus === 'timeout'){ url: '/index/getBroker_new',
alert('请求超时'); data: {
}; 'phone': $.trim(_this.val())
} },
}); timeout: 30000,
}; dataType: 'json',
}); beforeSend: function() {},
success: function(data) {
_doc.on('click', '.jian_class1>ul>li', function(){ if(typeof data === 'object') {
var _this = $(this); if(data.code == 200) {
_this.parent().prev().val(_this.html()).attr('data-id',_this.attr('data-id')); if(data['data'].length > 0) {
_this.parent().html('').hide(); var _htmlTemp = '';
}); $.each(data['data'], function(i, item) {
_htmlTemp += '<li data-id="{3}">{2}{0}-{1}<li>'.stringFormatObj({
// '0': item['name'],
'1': item['phone'],
}, '2': _this.parent().nextAll('.input-add-tel').data('hideid') ? '' : (item['id'] + '-'),
// 获取信息 手机号 名字 '3': item['id']
Anch:function(){//获取手机号名字的 });
$.ajax({ });
'type': 'GET', // 输出trim
'url' : '/index/getAgentsTohouses',
data: {"houses_id":business.house_id,"type":business.type}, _this.next().show().html(_htmlTemp);
dataType: "json", } else {
success: function(data){ _this.next().html('');
if(data.code == 200){ };
if (data.data) { } else {
$(".jian_class").html('');//写入 alert(data['msg']);
$.each(data.data, function(i,data) { };
business.jiabox_data(data['id'],data['name'],data['phone']); } else {
}); alert('数据错误');
business.jiabox(); };
} },
} else { error: function() {
alert('请登录!'); //alert('error');
} },
} complete: function(xhr, textStatus) {
}); if(textStatus === 'timeout') {
}, alert('请求超时');
Dujia:function(){//获取独家的信息 };
$("#modal-dujia").removeClass("yz"); }
$.ajax({ });
'type': 'GET', };
'url' : '/index/getExclusive', });
data: {"houses_id":business.house_id},
dataType: "json", _doc.on('click', '.jian_class1>ul>li', function() {
success: function(data){ var _this = $(this);
if(data.code == 200){ _this.parent().prev().val(_this.html()).attr('data-id', _this.attr('data-id'));
if (data.data) { _this.parent().html('').hide();
$("#sel_dujia").val(data.data.is_exclusive_type);//是否独家 });
$("#start_date_dujia").val(data.data.agent_start_time);//上传时间
$("#end_date_dujia").val(data.data.agent_end_time); //
$("#exclusive").val(data.data.name);
business.exclusive_id=data.data.id; },
var img_url=""; // 获取信息 手机号 名字
$.each(data['data']['exclusive_img'], function(i, item) { Anch: function() { //获取手机号名字的
var local_img=location.origin+'/resource/lib/Attachments/images/'+item.img_name; $.ajax({
img_url +='<img src="'+local_img+'" class="jai_dujia" data-img="'+item.img_name+'" >'; 'type': 'GET',
}); 'url': '/index/getAgentsTohouses',
$("#liudan_pic_pre").html(img_url); data: {
} "houses_id": business.house_id,
} else { "type": business.type
alert('获取失败!'); },
} dataType: "json",
} success: function(data) {
}); if(data.code == 200) {
}, if(data.data) {
Dujianew:function(){//提交独家的信息 $(".jian_class").html(''); //写入
var images=[];//图片 $.each(data.data, function(i, data) {
var imgs =$(".jai_dujia"); business.jiabox_data(data['id'], data['name'], data['phone']);
for(var j=0;j<imgs.length;j++){ });
images.push(imgs[j].getAttribute("data-img")) business.jiabox();
}; }
console.log($("#sel_dujia").val()); } else {
if($("#sel_dujia").val()==null){ alert('请登录!');
alert("请选择是否独家"); }
return; }
} });
if(imgs.length==0){ },
alert("请选择图片"); Dujia: function() { //获取独家的信息
return; $("#modal-dujia").removeClass("yz");
} $.ajax({
if($("#start_date_dujia").val()==""){ 'type': 'GET',
alert("请选择独家代理的时间"); 'url': '/index/getExclusive',
return; data: {
} "houses_id": business.house_id
if($("#end_date_dujia").val()==""){ },
alert("请选择独家代理的时间"); dataType: "json",
return; success: function(data) {
} if(data.code == 200) {
if($("#exclusive").val()==""){ if(data.data) {
alert("请选择姓名或者手机号"); $("#sel_dujia").val(data.data.is_exclusive_type); //是否独家
return; $("#start_date_dujia").val(data.data.agent_start_time); //上传时间
$("#end_date_dujia").val(data.data.agent_end_time);
} $("#exclusive").val(data.data.name);
$("#modal-dujia").addClass("yz"); business.exclusive_id = data.data.id;
$.ajax({ var img_url = "";
'type': 'POST', $.each(data['data']['exclusive_img'], function(i, item) {
'url' : '/index/editExclusive', var local_img = location.origin + '/resource/lib/Attachments/images/' + item.img_name;
data: {"houses_id":business.house_id,//楼盘Id img_url += '<img src="' + local_img + '" class="jai_dujia" data-img="' + item.img_name + '" >';
"is_exclusive_type":$("#sel_dujia").val(),//是否独家 });
"exclusive_id":business.exclusive_id,//经纪人id $("#liudan_pic_pre").html(img_url);
"agent_start_time":$("#start_date_dujia").val(),//开始时间 }
"agent_end_time":$("#end_date_dujia").val(),//结束时间 } else {
"exclusive_img":images//图片 alert('获取失败!');
}, }
dataType: "json", }
success: function(data){ });
if(data.code == 200){ },
} else { Dujianew: function() { //提交独家的信息
alert('获取失败!'); var images = []; //图片
} var imgs = $(".jai_dujia");
for(var j = 0; j < imgs.length; j++) {
} images.push(imgs[j].getAttribute("data-img"))
}); };
}, console.log($("#sel_dujia").val());
Caozuo:function(){//获取独家的信息 if($("#sel_dujia").val() == null) {
var caozuo_table=""; alert("请选择是否独家");
$.ajax({ return;
'type': 'GET', }
'url' : '/index/getRecords',//获取操作记录 if(imgs.length == 0) {
data: {"houses_id":business.house_id}, alert("请选择图片");
dataType: "json", return;
success: function(data){ }
if(data.code == 200){ if($("#start_date_dujia").val() == "") {
if (data.data) { alert("请选择独家代理的时间");
$.each(data.data,function(i,item){ return;
caozuo_table+='<tr><td>'+item.remark+'</td> <td>'+item.name+'</td> <td>'+item.create_time+'</td></tr>' }
}); if($("#end_date_dujia").val() == "") {
$("#caozuo_table").html(caozuo_table); alert("请选择独家代理的时间");
} return;
} else { }
alert('获取失败!'); if($("#exclusive").val() == "") {
} alert("请选择姓名或者手机号");
} return;
});
}, }
Submit_follow:function(){//提交案场权限人数据 $("#modal-dujia").addClass("yz");
var agents_id=""; $.ajax({
var _agents_id=""; 'type': 'POST',
$("input[name='ues_id']").each(function() {//拼接经纪人id 'url': '/index/editExclusive',
var s =$(this).val(); data: {
var m = s.match(/[^-]+(?=[-])/g); "houses_id": business.house_id, //楼盘Id
if(m === null){ "is_exclusive_type": $("#sel_dujia").val(), //是否独家
return false; "exclusive_id": business.exclusive_id, //经纪人id
}else{ "agent_start_time": $("#start_date_dujia").val(), //开始时间
agents_id += ","+ m[0]; "agent_end_time": $("#end_date_dujia").val(), //结束时间
_agents_id=agents_id.substring(1); "exclusive_img": images //图片
} },
}); dataType: "json",
$.ajax({ success: function(data) {
'type': 'POST', if(data.code == 200) {} else {
'url' : '/index/addHousesAgents', alert('获取失败!');
data: {"houses_id":business.house_id,"type":business.type,"agents_id":_agents_id}, }
dataType: "json",
success: function(data){ }
if(data.code == 200){ });
if (data.data) { },
$("#modal-anch").hide; Caozuo: function() { //获取独家的信息
} var caozuo_table = "";
} else { $.ajax({
$("#modal-anch").hide; 'type': 'GET',
} 'url': '/index/getRecords', //获取操作记录
} data: {
}); "houses_id": business.house_id
}, },
resetLoad:function (){//手机号 dataType: "json",
if(business.ajaxObj){ success: function(data) {
business.ajaxObj.abort(); if(data.code == 200) {
} if(data.data) {
business.ldHtml.html(''); $.each(data.data, function(i, item) {
business.stopstatus = true; caozuo_table += '<tr><td>' + item.remark + '</td> <td>' + item.name + '</td> <td>' + item.create_time + '</td></tr>'
}, });
Submit_follow2:function(){//提交盘方 $("#caozuo_table").html(caozuo_table);
var agents_id=""; }
var _agents_id=""; } else {
$("input[name='ues_id']").each(function() {//拼接经纪人id alert('获取失败!');
var s =$(this).val(); }
var m = s.match(/[^-]+(?=[-])/g); }
if(m === null){ });
return false; },
}else{ Submit_follow: function() { //提交案场权限人数据
agents_id += ","+ m[0]; var agents_id = "";
_agents_id=agents_id.substring(1); var _agents_id = "";
} $("input[name='ues_id']").each(function() { //拼接经纪人id
}); var s = $(this).val();
$.ajax({ var m = s.match(/[^-]+(?=[-])/g);
'type': 'POST', if(m === null) {
'url' : '/index/addHousesAgentsDish', return false;
data: {"houses_id":business.house_id,"type":business.type,"agents_id":_agents_id}, } else {
dataType: "json", agents_id += "," + m[0];
success: function(data){ _agents_id = agents_id.substring(1);
if(data.code == 200){ }
if (data.data) { });
$("#modal-anch").hide; $.ajax({
} 'type': 'POST',
business.getList(1); 'url': '/index/addHousesAgents',
} else { data: {
$("#modal-anch").hide; "houses_id": business.house_id,
} "type": business.type,
} "agents_id": _agents_id
}); },
}, dataType: "json",
resetLoad:function (){//手机号 success: function(data) {
if(business.ajaxObj){ if(data.code == 200) {
business.ajaxObj.abort(); if(data.data) {
} $("#modal-anch").hide;
business.ldHtml.html(''); }
business.stopstatus = true; } else {
}, $("#modal-anch").hide;
// 下拉列表 }
loadMain:function(phone, obj) {//手机号 }
business.ajaxObj=$.ajax({ });
type: "GET", },
url: '/index/getBroker_new' , resetLoad: function() { //手机号
data: { if(business.ajaxObj) {
'phone': phone business.ajaxObj.abort();
}, }
timeout: 10000, business.ldHtml.html('');
dataType: "json", business.stopstatus = true;
beforeSend: function() { },
}, Submit_follow2: function() { //提交盘方
success: function(data) { var agents_id = "";
var _agents_id = "";
if(data.code === 200){ $("input[name='ues_id']").each(function() { //拼接经纪人id
var _html = ''; var s = $(this).val();
$.each(data.data, function(i,data) { var m = s.match(/[^-]+(?=[-])/g);
_html += '<li class="addphone"><span class="id">'+data['id']+'-</span><span class="phone_name">'+data['name']+'</span><span class="phone_span">-</span><span class="phone-phone">'+data['phone']+'</span> </li>'; if(m === null) {
}); return false;
obj.html(_html); } else {
} agents_id += "," + m[0];
}, _agents_id = agents_id.substring(1);
error: function() { }
});
}, $.ajax({
complete: function(xhr, textStatus) { 'type': 'POST',
if(textStatus === "timeout") { 'url': '/index/addHousesAgentsDish',
//处理超时的逻辑 data: {
alert("请求超时"); "houses_id": business.house_id,
} "type": business.type,
} "agents_id": _agents_id
}); },
}, dataType: "json",
addphone:function (obj){//list消失 success: function(data) {
var phone_name=$(obj).find(".phone_name").html(); if(data.code == 200) {
var phone_phone=$(obj).find(".phone-phone").html(); if(data.data) {
var phone_span=$(obj).find(".phone_span").html(); $("#modal-anch").hide;
var id= $(obj).find(".id").html(); }
business.exclusive_id = id.substr(0, id.length - 1); business.getList(1);
$(obj).parent().prev().val(id+phone_name+phone_span+phone_phone); } else {
$(obj).parent().hide(); $("#modal-anch").hide;
business.ldHtml.html(''); }
return ; }
}, });
jiabox:function () {//加输入框 },
business.boxphoto = '<input name="ues_id" placeholder="请输入" type="tel" style="margin-left: 10px;float: left" class="phone_add">' + resetLoad: function() { //手机号
'<ul class="phone_list1"></ul>'+ if(business.ajaxObj) {
'<img src="/resource/image/qdao-sha.png" class="jian">'; business.ajaxObj.abort();
$(".jian_class").append(business.boxphoto);//写入 }
business.ldHtml.html('');
business.jianbox(); business.stopstatus = true;
}, },
// 下拉列表
jiabox_data:function (id,name,phone) {//显示已经获取的数据 loadMain: function(phone, obj) { //手机号
business.boxphoto = '<input name="ues_id" placeholder="请输入" value='+id+'-'+name+'-'+phone+' type="tel" style="margin-left: 10px;float: left" class="phone_add">' + business.ajaxObj = $.ajax({
'<ul class="phone_list1"></ul>'+ type: "GET",
'<img src="/resource/image/qdao-sha.png" class="jian"><input type="hidden" value="'+id+'">'; url: '/index/getBroker_new',
$(".jian_class").append(business.boxphoto);//写入 data: {
}, 'phone': phone
},
timeout: 10000,
jianbox: function () { dataType: "json",
$(".jian").click(function () {//删除经纪人数据 beforeSend: function() {},
var ss =$(this).prev().prev().val(); success: function(data) {
var mm = ss.match(/[^-]+(?=[-])/g);
if(mm === null){ if(data.code === 200) {
$(this).prev().prev().remove(); var _html = '';
$(this).prev().remove(); $.each(data.data, function(i, data) {
$(this).remove(); _html += '<li class="addphone"><span class="id">' + data['id'] + '-</span><span class="phone_name">' + data['name'] + '</span><span class="phone_span">-</span><span class="phone-phone">' + data['phone'] + '</span> </li>';
return false; });
}else{ obj.html(_html);
var mm_id=mm[0]; }
} },
error: function() {
var r=confirm("确定删除吗!");
if (r==true) },
{ complete: function(xhr, textStatus) {
$(this).prev().prev().remove(); if(textStatus === "timeout") {
$(this).prev().remove(); //处理超时的逻辑
$(this).remove(); alert("请求超时");
$.ajax({ }
'type': 'POST', }
'url' : '/index/delTohouses', });
data: {"id":mm_id,"houses_id":business.house_id}, },
dataType: "json", addphone: function(obj) { //list消失
success: function(data){ var phone_name = $(obj).find(".phone_name").html();
if(data.code == 200){ var phone_phone = $(obj).find(".phone-phone").html();
var phone_span = $(obj).find(".phone_span").html();
} else { var id = $(obj).find(".id").html();
alert("删除失败"); business.exclusive_id = id.substr(0, id.length - 1);
} $(obj).parent().prev().val(id + phone_name + phone_span + phone_phone);
} $(obj).parent().hide();
}); business.ldHtml.html('');
return;
},
} jiabox: function() { //加输入框
else business.boxphoto = '<input name="ues_id" placeholder="请输入" type="tel" style="margin-left: 10px;float: left" class="phone_add">' +
{ '<ul class="phone_list1"></ul>' +
'<img src="/resource/image/qdao-sha.png" class="jian">';
} $(".jian_class").append(business.boxphoto); //写入
business.jianbox();
}); },
},
// jiabox_data: function(id, name, phone) { //显示已经获取的数据
// 批量修改客方 business.boxphoto = '<input name="ues_id" placeholder="请输入" value=' + id + '-' + name + '-' + phone + ' type="tel" style="margin-left: 10px;float: left" class="phone_add">' +
'<ul class="phone_list1"></ul>' +
modify_add : function () {//modify_add批量修改客方 '<img src="/resource/image/qdao-sha.png" class="jian"><input type="hidden" value="' + id + '">';
var old_agents_text = $('.old_agents').val(); $(".jian_class").append(business.boxphoto); //写入
var new_agents_text = $('.new_agents').val(); },
console.log($('.phone_jia1:eq(0)').attr('data-id')); jianbox: function() {
console.log($('.phone_jia1:eq(1)').attr('data-id')); $(".jian").click(function() { //删除经纪人数据
var ss = $(this).prev().prev().val();
if (old_agents_text == '') { var mm = ss.match(/[^-]+(?=[-])/g);
alert('请输入经纪人内容为空'); if(mm === null) {
return false; $(this).prev().prev().remove();
} $(this).prev().remove();
$(this).remove();
if (new_agents_text == '') { return false;
alert('请输入经纪人内容为空'); } else {
return false; var mm_id = mm[0];
} }
$.ajax ({ var r = confirm("确定删除吗!");
url: '/index/batchEditCustomer', if(r == true) {
type: 'POST', $(this).prev().prev().remove();
async: true, $(this).prev().remove();
data: { $(this).remove();
"old_agents_id":$('.phone_jia1:eq(0)').attr('data-id'), $.ajax({
"agents_id":$('.phone_jia1:eq(1)').attr('data-id'), 'type': 'POST',
}, 'url': '/index/delTohouses',
dataType: 'json', data: {
success: function (data) { "id": mm_id,
if (data.code == 200) { "houses_id": business.house_id
console.log(666); },
} dataType: "json",
} success: function(data) {
}); if(data.code == 200) {
},
//==============批量修改客方=========== } else {
getList: function (pageNo) { alert("删除失败");
business.pageNo = pageNo; }
var params = {}; }
// 商铺列表 默认时间显示 });
if(pageNo!=1){
function getPreMonth(date) { } else {
            var arr = date.split('-');
            var year = arr[0];  }
            var month = arr[1]; 
            var day = arr[2];  });
            var days = new Date(year, month, 0); },
            days = days.getDate();  //
            var year2 = year; // 批量修改客方
            var month2 = parseInt(month) - 1;
            if (month2 == 0) { modify_add: function() { //modify_add批量修改客方
                year2 = parseInt(year2) - 1; var old_agents_text = $('.old_agents').val();
                month2 = 12; var new_agents_text = $('.new_agents').val();
            }
            var day2 = day; console.log($('.phone_jia1:eq(0)').attr('data-id'));
            var days2 = new Date(year2, month2, 0); console.log($('.phone_jia1:eq(1)').attr('data-id'));
            days2 = days2.getDate();
            if (day2 > days2) { if(old_agents_text == '') {
                day2 = days2; alert('请输入经纪人内容为空');
            } return false;
            if (month2 < 10) { }
                month2 = '0' + month2;
            } if(new_agents_text == '') {
            var t2 = year2 + '-' + month2 + '-' + day2; alert('请输入经纪人内容为空');
            return t2; return false;
        } }
var myDate = new Date();
var y = myDate.getFullYear(); $.ajax({
var m = myDate.getMonth()+1; url: '/index/batchEditCustomer',
var d = myDate.getDate(); type: 'POST',
var day_end=y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d); async: true,
var day_start=getPreMonth(day_end); data: {
$('#start_date').val(day_start); "old_agents_id": $('.phone_jia1:eq(0)').attr('data-id'),
$('#end_date').val(day_end); "agents_id": $('.phone_jia1:eq(1)').attr('data-id'),
},
} dataType: 'json',
success: function(data) {
params.pageNo = business.pageNo; if(data.code == 200) {
params.pageSize = business.pageSize; console.log(666);
params.is_carefully_chosen = $('#is_carefully_chosen option:selected') .val();//首页显示 }
params.is_show = $('#is_show option:selected') .val();//c端显示 }
params.shop_type = $('#shop_type option:selected') .val();//商铺类型 });
params.leased = $('#leased option:selected') .val();//商铺状态 },
params.rent_price = $('#rent_price option:selected') .val();//月租金 //==============批量修改客方===========
params.is_exclusive_type = $('#is_exclusive_type option:selected') .val();//是否独家 getList: function(pageNo, type) {
params.internal_title = $('#internal_title') .val();//商铺名称 business.pageNo = pageNo;
params.industry_type = $('#industry_type') .val();//业态 var params = {};
params.dish = $('#dish') .val();//盘方 // 商铺列表 默认时间显示
params.id = $('#id') .val();//店铺编号 console.log(type);
params.start_date = $('#start_date') .val();//时间1 params.pageNo = business.pageNo;
params.end_date = $('#end_date') .val();//时间2 params.pageSize = business.pageSize;
params.is_carefully_chosen = $('#is_carefully_chosen option:selected').val(); //首页显示
$.ajax ({ params.is_show = $('#is_show option:selected').val(); //c端显示
url: '/index/getHouseList.html',//获取列表 params.shop_type = $('#shop_type option:selected').val(); //商铺类型
type: 'GET', params.leased = $('#leased option:selected').val(); //商铺状态
async: true, params.rent_price = $('#rent_price option:selected').val(); //月租金
data: params, params.is_exclusive_type = $('#is_exclusive_type option:selected').val(); //是否独家
dataType: 'json', params.internal_title = $('#internal_title').val(); //商铺名称
success: function (data) { params.industry_type = $('#industry_type').val(); //业态
var temp = document.getElementById ('house_list_tpl').innerHTML; params.dish = $('#dish').val(); //盘方
var doTtmpl = doT.template (temp); params.id = $('#id').val(); //店铺编号
$ ("#business_list").html (doTtmpl (data.data.list)); params.start_date = $('#start_date').val(); //时间1
params.end_date = $('#end_date').val(); //时间2
/*分页代码*/
add_page(data.data.total,pageNo,business.pageSize,business.getList); $.ajax({
/* $ ("#pagediv").pagination ({ url: '/index/getHouseList.html', //获取列表
length: data.data.total, type: 'GET',
current: pageNo, async: true,
every: business.pageSize, data: params,
onClick: function (el) { dataType: 'json',
business.getList (el.num.current); success: function(data) {
} var temp = document.getElementById('house_list_tpl').innerHTML;
});*/ var doTtmpl = doT.template(temp);
} $("#business_list").html(doTtmpl(data.data.list));
});
}, /*分页代码*/
delBusiness : function () { add_page(data.data.total, pageNo, business.pageSize, business.getList);
$.ajax({ /* $ ("#pagediv").pagination ({
url : '/index/houseDel', length: data.data.total,
type : 'POST', current: pageNo,
async: true, every: business.pageSize,
data: {"id":business.id}, onClick: function (el) {
dataType: 'json', business.getList (el.num.current);
success : function (data) { }
if (data.code == 200) { });*/
business.getList(1); }
$("#modal-delete").modal ('hide'); });
} else { },
$("#del_msg").html('<span style="color: red">删除失败!</span>'); delBusiness: function() {
} $.ajax({
} url: '/index/houseDel',
}); type: 'POST',
} async: true,
}; data: {
return business; "id": business.id
},
dataType: 'json',
success: function(data) {
if(data.code == 200) {
business.getList(1);
$("#modal-delete").modal('hide');
} else {
$("#del_msg").html('<span style="color: red">删除失败!</span>');
}
}
});
}
};
return business;
}); });
\ No newline at end of file
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