Commit 61f087dc authored by xishifeng's avatar xishifeng

收款记录优化处理

parent 1ae2f375
......@@ -331,6 +331,7 @@
<label>请选择一个图像文件:</label>
<button type="button btn2" class="btn btn-default">上传图片</button>
<input type="file" id="file_input"/>
<div id="container_body_img_area"></div>
</div>
</div>
<ul class="img-pre-ul" id="xiangqing_pic_ul">
......
......@@ -7,73 +7,116 @@ define(['doT', 'text!temp/get_collection_template_tpl.html', 'css!style/home.css
id: '',
house_id: '',
house_fatherid: '',
type: '',
valueCurrent: '',
ajaxObj: '',
stopstatus: true,
boxphoto: '',
image_file: '',
init: function() {
//初始化dot
$(document.body).append(template);
follow.getList(0);
follow.event();
follow.getaddPicList2();
},
event: function() {
var _doc = $(document);
_doc.on('click', '.span-del', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).parent().remove();
});
_doc.on('click', '.span-del2', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).prev().attr('class');
$(this).parent().remove();
follow.spandelList($(this).prev().attr('class'));
});
//时间轴点击出现
_doc.on('click', 'a[href="#modal-time"]', function(e) {
follow.house_id = $(this).attr("data-id");
e.preventDefault();
e.stopPropagation();
$('.iframe-time-line').attr('src', '/app_broker/timeline_pc?order_id=' + follow.house_id);
});
//搜索按钮点击事件
$("#search").click(function() {
follow.getList(1);
});
//收款图片按钮点击的事件
_doc.on('click', '.add-pic', function() {//区分收款记录的id 和 father-id 获取图片 和保存图片 都区分
follow.house_id = $(this).attr("data-id");
follow.house_fatherid = $(this).attr("father-id");
follow.getaddPicList();
var _this = $(this);
follow.house_id = _this.attr("data-id");
follow.house_fatherid = _this.attr("father-id");
follow.getaddPicList();//获取已经上传的图片信息
});
//重置按钮的事件
$("#reset").click(function() { //重置
document.getElementById("form_search").reset();
});
//导出列表事件
$("#export").click(function() { //导出列表
follow.exportList();
});
//编辑按钮点击事件
$(document).delegate(".submit_edit2", "click", function() { //提交
follow.house_id2 = $(this).attr("data-id");
var _this = $(this);
follow.house_id2 = _this.attr("data-id");
console.log(follow.house_id2);
$("#real_money").val($(this).attr("data-money"));
$("#real_money").val(_this.attr("data-money"));
});
$(document).delegate(".submit_edit", "click", function() { //提交
//编辑-收付金额-保存
$(document).delegate(".submit_edit", "click", function() {
follow.Submit_follow();
});
$(document).on("input", "#cus_fang", function() { //手机号搜索客方2
if($("#cus_fang").val() == '') {
$(".user-ul2").html('');
} else {
follow.search_phone2();
}
//收款图片-点击添加图片事件
$('#file_input').on('change', function(){
var _this = $(this);
var formData = new FormData();
formData.append('type', 'chat');
formData.append('image', _this[0].files[0]);
$.ajax({
type: 'post',
url: '/index/uploadImg',
data: formData,
dataType: 'json',
contentType: false,
cache: false,
processData: false,
beforeSend: function() {},
success: function(_data) {
if(_data.code == 200) {
$('#container_body_img_area').append('<div class="result"><img data-imgname="{0}" src="{1}" alt=""/> <span class="span-del">删除</span></div>'.stringFormatObj({
'0': _data.data.img_path,
'1': urlDeal(_data.data.internet_img_name)
}));
} else {
alert(_data.msg);
};
},
error: function() {
alert('enter error');
},
complete: function(xhr, textStatus) {
if(textStatus === 'timeout') {
//处理超时的逻辑
alert('请求超时,请重试');
};
}
});
});
$(document).delegate(".addphone2", "click", function() { //list2消失
follow.addphone2(this);
//图片删除事件
_doc.on('click', '.span-del', function(e) {
e.preventDefault();
e.stopPropagation();
$(this).parent().remove();
});
//图片删除,已有的则调用接口删除
_doc.on('click', '.span-del2', function(e) {
var _this = $(this);
e.preventDefault();
e.stopPropagation();
if(confirm('确认删除吗?')){
_this.parent().remove();
follow.spandelList(_this.prev().attr('data-imgid'));
};
});
//保存上传的图片
_doc.on('click', '#saveBtn', function(e) {
var _this = $(this);
......@@ -81,24 +124,19 @@ define(['doT', 'text!temp/get_collection_template_tpl.html', 'css!style/home.css
e.stopPropagation();
var imgname = [];
for(var i = 0; i < $('.result').length; i++) {
imgname[i] = $('.result>img').get(i).getAttribute("class");
}
imgname[i] = $('.result>img').attr('data-imgname');
};
console.log(imgname.join(','));
var id_pic;
if(follow.house_fatherid > 0) {
id_pic = follow.house_fatherid;
} else {
id_pic = follow.house_id;
}
var id_pic = follow.house_fatherid > 0?follow.house_fatherid:follow.house_id;
var _data = {
img_id: id_pic,
img_id: id_pic
};
//无新的图片上传 不调用接口
if(imgname.join(',')) {
_data['img_name'] = imgname.join(',');
} else {
return
}
};
$.ajax({
type: 'GET',
url: '/index/addReceiptImg',
......@@ -107,6 +145,7 @@ define(['doT', 'text!temp/get_collection_template_tpl.html', 'css!style/home.css
beforeSend: function() {},
success: function(_data) {
if(typeof _data === 'object') {
alert('保存成功');
follow.getList(0);
} else {
alert('数据错误');
......@@ -124,38 +163,7 @@ define(['doT', 'text!temp/get_collection_template_tpl.html', 'css!style/home.css
});
});
},
addphone2: function(obj) {
var user_ht = $(obj).html();
$("#cus_fang").val(user_ht);
$(".user-ul2").html('');
follow.agent_id = $(obj).attr("data-id");
},
search_phone2: function() { //手机号
$.ajax({
url: '/index/select_by_phone',
type: 'POST',
async: true,
data: {
"phone": $("#cus_fang").val()
},
dataType: 'json',
success: function(data) {
if(data.code == 200) {
var user_ul2 = "";
$.each(data.data, function(i, item) {
user_ul2 += '<li class="addphone2" data-id="' + item.id + '">' + item.id + '-' + item.realname + '-' + item.phone + '</li>';
});
$(".user-ul2").html(user_ul2);
} else {
alert(data.msg);
}
}
});
},
//编辑-收付金额-保存
Submit_follow: function() { //提交
$.ajax({
'type': 'POST',
......@@ -172,7 +180,7 @@ define(['doT', 'text!temp/get_collection_template_tpl.html', 'css!style/home.css
}
});
},
spandelList: function(n) { //删除已经保cun的时图片都调用
spandelList: function(n) { //删除已经保存的图片都调用
$.ajax({
'type': 'POST',
'url': '/index/deleteReceiptImg',
......@@ -188,13 +196,10 @@ define(['doT', 'text!temp/get_collection_template_tpl.html', 'css!style/home.css
});
},
getaddPicList: function() { //获取收款图片
var id_pic;
if(follow.house_fatherid > 0) {
id_pic = follow.house_fatherid;
} else {
id_pic = follow.house_id;
}
getaddPicList: function() {
//获取收款图片
$('#container_body_img_area').html('');//每回先清空所有图片
var id_pic = follow.house_fatherid > 0?follow.house_fatherid:follow.house_id;
$('.result2,.result').remove(); //删除之前存在的图片 显示从接口获取的数据 用来区分新添加的 和 已经保存的
$.ajax({
'type': 'GET',
......@@ -207,12 +212,11 @@ define(['doT', 'text!temp/get_collection_template_tpl.html', 'css!style/home.css
if(data.code == 200) {
//渲染已经有的列表
for(i = 0; i < data.data.length; i++) {
var result = '<div class="result2"><img class="' + data.data[i].id + '" src="' + data.data[i].img_name + '" alt=""/> <span class="span-del2">删除</span></div>';
div = document.createElement('div');
div.innerHTML = result;
document.getElementById('container_body').appendChild(div);
} 
$('#container_body_img_area').append('<div class="result2"><img data-imgid="{0}" src="{1}" alt=""/> <span class="span-del2">删除</span></div>'.stringFormatObj({
'0': data.data[i].id,
'1': urlDeal(data.data[i].img_name)
}));
};
} else {}
}
});
......
......@@ -159,4 +159,10 @@ function hideTel(str){
}else{
return str;
}
}
//处理url信息,改为当前域名的协议
function urlDeal(urlStr, httpStr) {
//处理
return urlStr.replace(/(http|https):\/\//g, (httpStr ? (httpStr + ':') : location.protocol) + '//');
}
\ 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