You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
252 lines
8.7 KiB
252 lines
8.7 KiB
(function () {
|
|
$(function () {
|
|
//查看详情时禁止编辑
|
|
var attach_btnEl=$("#cpt_attach_btn"),attach_listEl=$("#cpt_attach_list");
|
|
if(window.detail){
|
|
$("#tousuformbtm").remove();
|
|
attach_btnEl.remove();
|
|
setForm(window.detail);
|
|
return;
|
|
}else{
|
|
$("#tousuformbtm").show();
|
|
attach_btnEl.show();
|
|
}
|
|
|
|
attach_btnEl.on('click',function (e) {e.preventDefault();
|
|
addUploadFile();
|
|
});
|
|
|
|
attach_listEl.on('change','input',function(e){e.preventDefault();
|
|
// uploadFile.call(this,{type:'image'});
|
|
uploadFile.call(this);
|
|
});
|
|
attach_listEl.on('click','.optbtn',function(e){e.preventDefault();
|
|
var type=$(this).attr('data-type');
|
|
if(type=='delete'){
|
|
$(this).closest('tr').remove();
|
|
}
|
|
});
|
|
$("#submitformbtn").click(function (e) {e.preventDefault();
|
|
checkParams($(this))
|
|
});
|
|
$("#cpt_is_recharge").change(function () {
|
|
if($(this).val()=='0'){
|
|
$("#cpt_recharge_money").attr('disabled',true);
|
|
}else{
|
|
$("#cpt_recharge_money").attr('disabled',false);
|
|
}
|
|
});
|
|
$("#cpt_name").focus();
|
|
});
|
|
|
|
function setForm(info) {
|
|
var tousuformEl=$("#tousuform");
|
|
tousuformEl.find('input').attr('disabled',true);
|
|
tousuformEl.find('select').attr('disabled',true);
|
|
tousuformEl.find('textarea').attr('disabled',true);
|
|
tousuformEl.closest('.tvmtabwrap').css({'margin':0});
|
|
|
|
$("#cpt_name").val(info.name||'');
|
|
$("#cpt_tel").val(info.tel||'');
|
|
$("#cpt_account").val(info.account||'');
|
|
$("#cpt_is_recharge").val(info.is_recharge);
|
|
if(info.recharge_money){
|
|
$("#cpt_recharge_money").val(Utils.accDiv(info.recharge_money||0,100));
|
|
}
|
|
$("#cpt_platform").val(info.platform||'');
|
|
$("#cpt_org").val(info.org||'');
|
|
$("#cpt_target").val(info.target||'');
|
|
$("#cpt_target_relation").val(info.target_relation||'');
|
|
$("#cpt_information").val(info.information||'');
|
|
$("#cpt_economy_problem").val(info.economy_problem||'');
|
|
$("#cpt_intro").val(info.intro||'');
|
|
var attach=info.attach||'';
|
|
console.log("attach",attach);
|
|
if(attach){
|
|
var attachArr=[];
|
|
try {
|
|
attachArr=JSON.parse(attach);
|
|
}catch(e){
|
|
|
|
}
|
|
var html='';
|
|
attachArr.forEach(function (item) {
|
|
html+='<tr><td><a href="'+item.url+'" target="_blank">'+item.name+'</a></td></tr>';
|
|
});
|
|
if(html){
|
|
$("#cpt_attach_list").append(html);
|
|
}else{
|
|
$("#cpt_attach_list").append('<tr><td>无</td></tr>');
|
|
}
|
|
}
|
|
}
|
|
|
|
function addUploadFile() {
|
|
var attach_listEl=$("#cpt_attach_list");
|
|
attach_listEl.append('<tr style="display: none;"><td><input type="file"><a href="" target="_blank"></a></td><td><span class="optbtn" data-type="delete">删除</span></td></tr>');
|
|
attach_listEl.find('tr:last').find('input').click();
|
|
}
|
|
|
|
function checkParams(btnEl) {
|
|
|
|
var name=$("#cpt_name").val().trim();
|
|
if(!name){
|
|
return Utils.layerAlert('请填写姓名');
|
|
}
|
|
|
|
var tel=$("#cpt_tel").val().trim();
|
|
if(!tel){
|
|
return Utils.layerAlert('请填写电话');
|
|
}else{
|
|
var phonereg = /(^1[2|3|4|5|7|8|9]\d{9}$)|(^09\d{8}$)/;
|
|
var telreg = /^((0\d{2,3})-)(\d{7,8})(-(\d+))?$/;
|
|
if(!phonereg.test(tel)&&!telreg.test(tel)){
|
|
return Utils.layerAlert('请填写正确的电话号码');
|
|
}
|
|
}
|
|
|
|
var account=$("#cpt_account").val().trim();
|
|
if(!account){
|
|
return Utils.layerAlert('请填写客户账号');
|
|
}
|
|
|
|
var is_recharge=$("#cpt_is_recharge").val();
|
|
var recharge_money='';
|
|
if(is_recharge=='1'){
|
|
recharge_money=$("#cpt_recharge_money").val().trim();
|
|
if(!recharge_money) {
|
|
return Utils.layerAlert('请填写入金金额');
|
|
} else if(isNaN(recharge_money)||recharge_money<0){
|
|
return Utils.layerAlert('入金金额输入不合法');
|
|
}else if((recharge_money+'').indexOf('.')!=-1&&(recharge_money+'').split('.')[1].length>2){
|
|
return Utils.layerAlert('入金金额最多保留两位小数');
|
|
}
|
|
recharge_money=Utils.accMul(recharge_money,100);//分
|
|
}
|
|
|
|
var platform=$("#cpt_platform").val().trim();
|
|
if(!platform){
|
|
return Utils.layerAlert('请填写参与平台');
|
|
}
|
|
|
|
var org=$("#cpt_org").val().trim();
|
|
if(!org){
|
|
return Utils.layerAlert('请填写所属机构');
|
|
}
|
|
|
|
var target=$("#cpt_target").val().trim();
|
|
if(!target){
|
|
return Utils.layerAlert('请填写客户投诉主体');
|
|
}
|
|
|
|
var target_relation=$("#cpt_target_relation").val().trim();
|
|
if(!target_relation){
|
|
return Utils.layerAlert('请填写与投诉主体的关系');
|
|
}
|
|
|
|
var information=$("#cpt_information").val().trim();
|
|
if(!information){
|
|
return Utils.layerAlert('请填写基本情况反馈');
|
|
}
|
|
|
|
var economy_problem=$("#cpt_economy_problem").val().trim();
|
|
if(!economy_problem){
|
|
return Utils.layerAlert('请填写经济问题反馈');
|
|
}
|
|
|
|
var intro=$("#cpt_intro").val().trim();
|
|
if(!intro){
|
|
return Utils.layerAlert('请填写相关协议及签署文件情况介绍');
|
|
}
|
|
|
|
var attachListEl=$("#cpt_attach_list").find('a');
|
|
var attachArr=[];
|
|
for(var i=0,len=attachListEl.length;i<len;i++){
|
|
var attachitem=$(attachListEl[i]);
|
|
var url=attachitem.attr('href');
|
|
var filename=attachitem.text();
|
|
if(url&&filename){
|
|
attachArr.push({"url":url,'name':filename});
|
|
}
|
|
}
|
|
if(attachArr.length==0){
|
|
return Utils.layerAlert('请上传对应证明附件');
|
|
}
|
|
|
|
var token=$("input[name='__feedback__']").val().trim();
|
|
var sendParams={
|
|
name:name,
|
|
tel:tel,
|
|
platform:platform,
|
|
account:account,
|
|
is_recharge:is_recharge,
|
|
recharge_money:recharge_money,
|
|
org:org,
|
|
target:target,
|
|
target_relation:target_relation,
|
|
information:information,
|
|
economy_problem:economy_problem,
|
|
intro:intro,
|
|
__feedback__:token,
|
|
attach:JSON.stringify(attachArr),
|
|
};
|
|
saveData(btnEl,sendParams);
|
|
}
|
|
|
|
function resetForm() {
|
|
$("#tousuform")[0].reset();
|
|
$("#cpt_attach_list").empty();
|
|
}
|
|
|
|
function saveData(btnEl,info) {
|
|
btnEl.attr('disabled',true);
|
|
$.ajax({
|
|
url:'/home/feedback/submit',
|
|
type:'POST',
|
|
data:info,
|
|
dataType:'json',
|
|
success:function (rs) {
|
|
btnEl.attr('disabled',false);
|
|
if(rs&&rs.code==200){
|
|
Utils.layerAlert('您的投诉信息提交成功,请耐心等待反馈结果','success',function () {
|
|
resetForm();
|
|
});
|
|
}else{
|
|
$("input[name='__feedback__']").val(rs.data.token);
|
|
Utils.layerAlert(rs&&rs.data?rs.data:'您的投诉信息提交失败,请稍后重试','error');
|
|
}
|
|
},
|
|
error:(function (e) {
|
|
btnEl.attr('disabled',false);
|
|
Utils.layerAlert('您的投诉信息提交失败,请稍后重试','error');
|
|
})
|
|
});
|
|
|
|
}
|
|
//图片上传
|
|
function uploadFile(parms){
|
|
(function(obj){
|
|
var trEl=$(obj).closest('tr').show();
|
|
var progress=$(obj).next();
|
|
var context={
|
|
onload:function(rs){
|
|
if(rs&&rs.code=='200'){
|
|
var filename=obj.files[0].name;
|
|
var url=rs.data||'';
|
|
progress.text(filename);
|
|
progress.attr('href',url);
|
|
}else{
|
|
progress.text(rs.data||'上传失败,请稍后重试');
|
|
}
|
|
},
|
|
onprocess:function(rs){
|
|
progress.text(rs.percent);
|
|
}
|
|
};
|
|
if(parms){
|
|
context.parms=parms;
|
|
}
|
|
Utils.uploadImgWithAjax(obj,context);
|
|
})(this);
|
|
}
|
|
})();
|
|
|