You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
573 lines
18 KiB
JavaScript
573 lines
18 KiB
JavaScript
var $table = $('#table');
|
|
var $tableFee = $('#tableFee');
|
|
var formEdit = $('#formEdit')[0];
|
|
var formFee = $('#formFee')[0];
|
|
var _GID = getQueryString('id');
|
|
var _Action = getQueryString('a');
|
|
var layerIndex = parent.layer.getFrameIndex(window.name);
|
|
var selFName = document.createElement("select");//费用名称
|
|
$(selFName).addClass('.sel2');
|
|
$(selFName).attr('name','FNAME');
|
|
var selFBiBie = document.createElement("select");//币别
|
|
$(selFBiBie).addClass('.sel2');
|
|
$(selFName).attr('name', 'FBIBIE');
|
|
var selFBiaoZhun = document.createElement("select");//费用标准
|
|
$(selFBiaoZhun).addClass('.sel2');
|
|
$(selFBiaoZhun).attr('name', 'FBIAOZHUN');
|
|
//#region 基本控件绑定
|
|
|
|
//#region 下拉框
|
|
|
|
SetSelect($('#selCGS'), 'cgs');
|
|
SetSelect($('#selPORTDISCHARGE'), 'port');
|
|
SetSelect($('#selDESTINATION'), 'port');
|
|
SetSelect($('#selYunShuTiaoKuan'), 'ystk');
|
|
SetSelect($('#selFuFeiFangShi'), 'fffs');
|
|
SetSelect($('#selMBS'), 'sftmb', "mbtype='0'");
|
|
SetSelect($('#selMBF'), 'sftmb', "mbtype='1'");
|
|
SetSelect($('#selMBT'), 'sftmb', "mbtype='2'");
|
|
|
|
//#endregion
|
|
|
|
$(selFName).append("<option value='箱使费'>箱使费</option>");
|
|
$(selFName).append("<option value='海运费'>海运费</option>");
|
|
|
|
$(selFBiBie).append("<option value='RMB'>RMB</option>");
|
|
$(selFBiBie).append("<option value='USD'>USD</option>");
|
|
|
|
$(selFBiaoZhun).append("<option value='箱'>箱</option>");
|
|
$(selFBiaoZhun).append("<option value='票'>票</option>");
|
|
$(selFBiaoZhun).append("<option value='天'>天</option>");
|
|
|
|
$('#selQDFS').append("<option value='电放'>电放</option>");
|
|
$('#selQDFS').append("<option value='正本'>正本</option>");
|
|
$('#selQDFS').append("<option value='SEAWAY'>SEAWAY</option>");
|
|
|
|
$('#selTDFS').append("<option value='ONE'>ONE</option>");
|
|
$('#selTDFS').append("<option value='TWO'>TWO</option>");
|
|
$('#selTDFS').append("<option value='THREE'>THREE</option>");
|
|
$('#selTDFS').append("<option value='FOUR'>FOUR</option>");
|
|
$('#selTDFS').append("<option value='FIVE'>FIVE</option>");
|
|
$('#selTDFS').append("<option value='SIX'>SIX</option>");
|
|
$('#selTDFS').append("<option value='SEVEN'>SEVEN</option>");
|
|
$('#selTDFS').append("<option value='EIGHT'>EIGHT</option>");
|
|
$('#selTDFS').append("<option value='NINE'>NINE</option>");
|
|
$('#selTDFS').append("<option value='TEN'>TEN</option>");
|
|
//#endregion
|
|
|
|
$(function () {
|
|
|
|
LoadForm();
|
|
$('#selMBF').select2({
|
|
});
|
|
$('#selMBS').select2({
|
|
});
|
|
$('#selMBT').select2({
|
|
});
|
|
$('.sel2').select2({
|
|
|
|
});
|
|
$('#btnSaveShou').click(function () {
|
|
showMBSave(0);
|
|
});
|
|
$('#btnSaveFa').click(function () {
|
|
showMBSave(1);
|
|
});
|
|
$('#btnSaveTong').click(function () {
|
|
showMBSave(2);
|
|
});
|
|
|
|
|
|
var data = [
|
|
|
|
]
|
|
$table.bootstrapTable({
|
|
data: data,
|
|
classes: 'table-sm table-hover table-bordered',
|
|
columns: [{
|
|
title: '序号',
|
|
field: 'id',
|
|
class: 'exctest'
|
|
}, {
|
|
title: '箱型',
|
|
field: 'name'
|
|
}, {
|
|
title: '箱号',
|
|
field: 'name'
|
|
}, {
|
|
title: '封号',
|
|
field: 'date'
|
|
}, {
|
|
title: '件数',
|
|
field: 'date'
|
|
}, {
|
|
title: '包装',
|
|
field: 'date'
|
|
}, {
|
|
title: '重量',
|
|
field: 'date'
|
|
}, {
|
|
title: '尺码',
|
|
field: 'date'
|
|
}, {
|
|
title: '皮重',
|
|
field: 'date'
|
|
}, {
|
|
title: '施封人',
|
|
field: 'date'
|
|
}, {
|
|
title: '重空标识',
|
|
field: 'date'
|
|
}, {
|
|
title: '称重方式',
|
|
field: 'date'
|
|
}, {
|
|
title: '称重重量',
|
|
field: 'date'
|
|
}, {
|
|
title: '称重时间',
|
|
field: 'date'
|
|
}],
|
|
onClickCell: function (field, value, row, c) {
|
|
//if (c.html().indexOf('ex') >= 0) {
|
|
// return;
|
|
//}
|
|
//if (c.attr('class').indexOf('ex') >= 0) {
|
|
// if (c.attr('class').indexOf('exc')>=0) {
|
|
// //select
|
|
// c.html("");
|
|
// var nc = '<select class="exc">'+$("#exctest").html()+'</select>';
|
|
// c.append(nc);
|
|
// }
|
|
//}
|
|
}
|
|
})
|
|
|
|
$('#btnSave').click(function () {
|
|
var url = '/MvcShipping/MsOpSeaeTD/Save';
|
|
var feeArr = GetFeeBodyJsonData();
|
|
var dataFee = JSON.stringify(feeArr);
|
|
var data = { opstatus: _Action, data: JSON.stringify($('#formEdit').serializeFormJSON()), data2: dataFee };
|
|
|
|
$.ajax({
|
|
url: url,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
data: data,
|
|
timeout: 10000,
|
|
cache: false,
|
|
success: function (t) {
|
|
if (t.Success) {
|
|
var data = eval(t).data;
|
|
SetData(formEdit, data);
|
|
layer.msg('保存成功');
|
|
_GID = $("input[name='GID']").val();
|
|
_Action = 'e';
|
|
LoadForm();
|
|
parent.loadData();
|
|
} else {
|
|
layer.msg(t.Message);
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
$('#btnXj').click(function () {
|
|
layer.open({
|
|
type: 2,
|
|
title: '询价',
|
|
maxmin: true,
|
|
class: 'layui-layer-haze',
|
|
shadeClose: true, //点击遮罩关闭层
|
|
area: ['800px', '480px'],
|
|
content: '/MvcShipping/MsOpSeaeTD/Xj'
|
|
});
|
|
})
|
|
|
|
$('#btnClose').click(function () {
|
|
parent.layer.close(layerIndex);
|
|
});
|
|
|
|
$("#selPORTDISCHARGE").on("change", function (e) {
|
|
$("#selDESTINATION").val($(this).val());
|
|
$("#selDESTINATION").select2();
|
|
})
|
|
|
|
$("#selMBS").on("change", function (e) {
|
|
var gid = $(this).val();
|
|
GetMBData(gid, 0);
|
|
})
|
|
|
|
$("#selMBF").on("change", function (e) {
|
|
var gid = $(this).val();
|
|
GetMBData(gid, 1);
|
|
})
|
|
|
|
$("#selMBT").on("change", function (e) {
|
|
var gid = $(this).val();
|
|
GetMBData(gid, 2);
|
|
})
|
|
|
|
//日期控件
|
|
$('.datetime').ztime();
|
|
$('.datetimeymd').zdate();
|
|
|
|
})
|
|
|
|
function LoadForm() {
|
|
var cond = " and GID='" + _GID + "'";
|
|
var url = '/MvcShipping/MsOpSeaeTD/GetData';
|
|
var handle = _Action;
|
|
var param = { handle: handle, condition: cond };
|
|
$.ajax({
|
|
url: url,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
data: param,
|
|
timeout: 10000,
|
|
cache: false,
|
|
success: function (t) {
|
|
var data = eval(t).data;
|
|
SetData(formEdit, data);
|
|
LoadFee2();
|
|
}
|
|
})
|
|
}
|
|
|
|
function LoadFee2() {
|
|
$("#formFee").empty();
|
|
var gid = $("input[name='GID']").val();
|
|
var c = " tid = '" + gid + "'";
|
|
var url = '/MvcShipping/MsOpSeaeTD/GetFeeList';
|
|
var param = { condition: c, currPage: 0, limit: 200, sort: "", tid: gid };
|
|
$.ajax({
|
|
url: url,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
data: param,
|
|
timeout: 10000,
|
|
cache: false,
|
|
success: function (t) {
|
|
data = [];
|
|
var tdata = eval(t).data;
|
|
data = tdata;
|
|
//#region 费用行 表头
|
|
var dvFeeHeaderRow = document.createElement("div");
|
|
$(dvFeeHeaderRow).addClass('row');
|
|
$(dvFeeHeaderRow).addClass('hdRow');
|
|
var dvhcol0 = ColForLblWithValue('费用名称');
|
|
var dvhcol1 = ColForLblWithValue('费用标准');
|
|
//var dvhcol2 = ColForLblWithValue('单价');
|
|
var dvhcol3 = ColForLblWithValue('币别');
|
|
//var dvhcol4 = ColForLblWithValue('汇率');
|
|
//var dvhcol5 = ColForLblWithValue('数量');
|
|
var dvhcol6 = ColForLblWithValue('金额');
|
|
var dvhcol7 = ColForLblWithValue('备注');
|
|
var dvhcol8 = ColForLblWithValue('操作');
|
|
$(dvFeeHeaderRow).append(dvhcol0, dvhcol1, dvhcol3, dvhcol6, dvhcol7, dvhcol8);
|
|
$(formFee).append(dvFeeHeaderRow);
|
|
//#endregion
|
|
|
|
//#region 遍历明细
|
|
var feeBody = data;
|
|
var cnt = 0;
|
|
$.each(feeBody, function (index, bd) {
|
|
cnt++;
|
|
var dvFeeBodyRow = document.createElement("div");
|
|
$(dvFeeBodyRow).addClass('row');
|
|
$(dvFeeBodyRow).addClass('feeRow');
|
|
// var dvbcol0 = ColForTextWithNameAndValue('FNAME', bd.FNAME);
|
|
var dvbcol0 = ColForSelWithNameAndValue('FNAME', bd.FNAME, 'fname' + cnt);
|
|
AppendHiddenWithNameAndValue(dvbcol0, 'GID', bd.GID);
|
|
//var dvbcol1 = ColForTextWithNameAndValue('FBIAOZHUN', bd.FBIAOZHUN);
|
|
var dvbcol1 = ColForSelWithNameAndValue('FBIAOZHUN', bd.FBIAOZHUN,'fbiaozhun'+cnt);
|
|
//var dvbcol2 = ColForTextWithNameAndValue('FDANJIA', bd.FDANJIA);
|
|
//var dvbcol3 = ColForTextWithNameAndValue('FBIBIE', bd.FBIBIE);
|
|
var dvbcol3 = ColForSelWithNameAndValue('FBIBIE', bd.FBIBIE,'fbibie'+cnt);
|
|
//var dvbcol4 = ColForTextWithNameAndValue('FHUILV', bd.FHUILV);
|
|
//var dvbcol5 = ColForTextWithNameAndValue('FSHULIANG', bd.FSHULIANG);
|
|
var dvbcol6 = ColForTextWithNameAndValue('FJINE', bd.FJINE);
|
|
var dvbcol7 = ColForTextWithNameAndValue('FBEIZHU', bd.FBEIZHU);
|
|
var dvbcol8 = ColForButtonWithValueAndAction('删除', function () {
|
|
//$(dvFeeBodyRow).remove();
|
|
|
|
DelFee(bd.GID, dvFeeBodyRow);
|
|
|
|
});
|
|
$(dvFeeBodyRow).append(dvbcol0, dvbcol1, dvbcol3, dvbcol6, dvbcol7, dvbcol8);
|
|
$(formFee).append(dvFeeBodyRow);
|
|
$('.sel2').select2({ width: "100%" });
|
|
});
|
|
|
|
$("#addFee").bind('click', function (event) {
|
|
cnt+=100;
|
|
var dvFeeBodyRow = document.createElement("div");
|
|
$(dvFeeBodyRow).addClass('row');
|
|
$(dvFeeBodyRow).addClass('feeRow');
|
|
//var dvbcol0 = ColForTextWithNameAndValue('FNAME', '');
|
|
var dvbcol0 = ColForSelWithName('FNAME', 'fname' + cnt);
|
|
AppendHiddenWithNameAndValue(dvbcol0, 'GID', '*');
|
|
//var dvbcol1 = ColForTextWithNameAndValue('FBIAOZHUN', '箱');
|
|
var dvbcol1 = ColForSelWithName('FBIAOZHUN','fbiaozhun'+cnt);
|
|
//var dvbcol2 = ColForTextWithNameAndValue('FDANJIA', '0');
|
|
//var dvbcol3 = ColForTextWithNameAndValue('FBIBIE', 'RMB');
|
|
var dvbcol3 = ColForSelWithName('FBIBIE','fbibie'+cnt);
|
|
//var dvbcol4 = ColForTextWithNameAndValue('FHUILV', '1');
|
|
//var dvbcol5 = ColForTextWithNameAndValue('FSHULIANG', '0');
|
|
var dvbcol6 = ColForTextWithNameAndValue('FJINE', '0');
|
|
var dvbcol7 = ColForTextWithNameAndValue('FBEIZHU', '');
|
|
var dvbcol8 = ColForButtonWithValueAndAction('删除', function () {
|
|
//$(dvFeeBodyRow).remove();
|
|
DelFee('*', dvFeeBodyRow);
|
|
});
|
|
$(dvFeeBodyRow).append(dvbcol0, dvbcol1, dvbcol3, dvbcol6, dvbcol7, dvbcol8);
|
|
$(formFee).children("div:last-child").after(dvFeeBodyRow);
|
|
$('.sel2').select2({ width: "100%"});
|
|
window.scrollTo(0, document.documentElement.clientHeight);
|
|
})
|
|
//#endregion
|
|
|
|
}
|
|
})
|
|
}
|
|
|
|
function ColForSelWithName(name,idx) {
|
|
var dvCol = document.createElement("div");
|
|
$(dvCol).addClass('col');
|
|
var sel;
|
|
if (name == 'FNAME') {
|
|
sel = $(selFName).clone();
|
|
} else if (name=='FBIBIE') {
|
|
sel = $(selFBiBie).clone();
|
|
} else if (name = 'FBIAOZHUN') {
|
|
sel = $(selFBiaoZhun).clone();
|
|
}
|
|
sel.attr('id', idx);
|
|
sel.attr('name', name);
|
|
sel.addClass('sel2');
|
|
|
|
$(dvCol).append(sel);
|
|
return dvCol;
|
|
}
|
|
function ColForSelWithNameAndValue(name,value, idx) {
|
|
var dvCol = document.createElement("div");
|
|
$(dvCol).addClass('col');
|
|
var sel;
|
|
if (name == 'FNAME') {
|
|
sel = $(selFName).clone();
|
|
} else if (name == 'FBIBIE') {
|
|
sel = $(selFBiBie).clone();
|
|
} else if (name = 'FBIAOZHUN') {
|
|
sel = $(selFBiaoZhun).clone();
|
|
}
|
|
sel.val(value);
|
|
sel.attr('id', idx);
|
|
sel.attr('name', name);
|
|
sel.addClass('sel2');
|
|
|
|
$(dvCol).append(sel);
|
|
return dvCol;
|
|
}
|
|
|
|
function ColForTextWithNameAndValue(n, v) {
|
|
var dvCol = document.createElement("div");
|
|
$(dvCol).addClass('col');
|
|
var txt = document.createElement("INPUT");
|
|
$(txt).attr('type', 'text');
|
|
$(txt).attr('name', n);
|
|
$(txt).addClass('form-control');
|
|
$(txt).attr('autocomplete', 'off');
|
|
$(txt).val(v);
|
|
$(dvCol).append(txt);
|
|
return dvCol;
|
|
}
|
|
|
|
function AppendHiddenWithNameAndValue(o, n, v) {
|
|
|
|
var hidden = document.createElement("INPUT");
|
|
$(hidden).attr('type', 'hidden');
|
|
$(hidden).attr('name', n);
|
|
$(hidden).val(v);
|
|
$(hidden).append(hidden);
|
|
$(o).append(hidden);
|
|
}
|
|
|
|
|
|
function ColForLblWithValue(v) {
|
|
var dvCol = document.createElement("div");
|
|
$(dvCol).addClass('col');
|
|
var lbl = document.createElement("p");
|
|
$(lbl).addClass('form-control');
|
|
$(lbl).attr('autocomplete', 'off');
|
|
$(lbl).html(v);
|
|
$(dvCol).append(lbl);
|
|
return dvCol;
|
|
}
|
|
|
|
function ColForButtonWithValueAndAction(v, a) {
|
|
var dvCol = document.createElement("div");
|
|
$(dvCol).addClass('col');
|
|
var btn = document.createElement("BUTTON");
|
|
$(btn).addClass('form-control');
|
|
$(btn).attr('type', 'BUTTON');
|
|
$(btn).text(v);
|
|
$(btn).click(a);
|
|
$(dvCol).append(btn);
|
|
return dvCol;
|
|
}
|
|
|
|
function GetFeeBodyJsonData() {
|
|
var rows = $(formFee).children();
|
|
var feeBody = [];
|
|
$.each(rows, function (index, row) {
|
|
var cls = $(row).attr('class');
|
|
if (cls.indexOf('feeRow') >= 0) {
|
|
var cols = $(row).children();
|
|
var bodyJson = {};
|
|
$.each(cols, function (i, col) {
|
|
var fields = $(col).children();
|
|
$.each(fields, function (n, field) {
|
|
var itag = field.tagName;
|
|
var itype = $(field).attr('type');
|
|
if ((itag == 'INPUT' && (itype == 'text' || itype == 'number' || itype == 'hidden')) || itag == 'TEXTAREA' || itag == 'SELECT') {
|
|
var iname = $(field).attr('name');
|
|
var ivalue = $(field).val();
|
|
bodyJson[iname] = ivalue;
|
|
}
|
|
})
|
|
})
|
|
feeBody.push(bodyJson);
|
|
}
|
|
})
|
|
return feeBody;
|
|
}
|
|
|
|
function DelFee(gid, dv) {
|
|
layer.confirm('确定要删除费用?', {
|
|
btn: ['确定', '取消'] //按钮
|
|
}, function () {
|
|
layer.load();
|
|
if (gid == '*') {
|
|
$(dv).remove();
|
|
}
|
|
var url = '/MvcShipping/MsOpSeaeTD/DelFee';
|
|
var param = { gid: gid };
|
|
|
|
$.ajax({
|
|
url: url,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
data: param,
|
|
timeout: 10000,
|
|
cache: false,
|
|
success: function (t) {
|
|
layer.closeAll('loading');
|
|
if (t.Success) {
|
|
layer.msg('删除成功!', { icon: 1 });
|
|
$(dv).remove();
|
|
} else {
|
|
layer.msg(t.Message, { icon: 1 });
|
|
}
|
|
|
|
}
|
|
})
|
|
}, function () {
|
|
});
|
|
}
|
|
|
|
function showMBSave(type) {
|
|
var title = "";
|
|
var text = "";
|
|
if (type == 0) {
|
|
text = $("textarea[name='CONSIGNEEINFO']").val();
|
|
} else if (type == 1) {
|
|
text = $("textarea[name='SHIPPERINFO']").val();
|
|
} else {
|
|
text = $("textarea[name='NOTIFYPARTYINFO']").val();
|
|
}
|
|
|
|
if (type==0) {
|
|
title = "收货人";
|
|
} else if(type==1) {
|
|
title = "发货人";
|
|
} else {
|
|
title = "通知人";
|
|
}
|
|
|
|
if (text == '') {
|
|
layer.msg(title + "信息不能为空");
|
|
return;
|
|
}
|
|
var html = "<div class=\"input-group mb-1\">";
|
|
html+="<div class=\"input-group-prepend\"><span style=\"font-size:14px\" class=\"input-group-text\">模板名称</span></div>";
|
|
html += "<input type=\"text\" class=\"form-control\" id=\"usr\" name=\"MBNAME\">";
|
|
html += "</div>";
|
|
html += "<input type =\"button\" class=\"form-control\" id=\"btnSaveSFT\" onclick='saveSFT(" + type + ")' value=\"保存\">";
|
|
layer.open({
|
|
type: 1,
|
|
title: title+'模板',
|
|
skin: 'layui-layer-rim', //加上边框
|
|
area: ['360px', '140px'], //宽高
|
|
content: html
|
|
});
|
|
}
|
|
|
|
function saveSFT(type) {
|
|
var url = '/MvcShipping/MsOpSeaeTD/SaveSFT';
|
|
var name = $("input[name='MBNAME']").val();
|
|
var text = "";
|
|
if (type==0) {
|
|
text = $("textarea[name='CONSIGNEEINFO']").val();
|
|
} else if (type==1) {
|
|
text= $("textarea[name='SHIPPERINFO']").val();
|
|
} else {
|
|
text= $("textarea[name='NOTIFYPARTYINFO']").val();
|
|
}
|
|
var data = { name: name, text: text, type:type };
|
|
|
|
$.ajax({
|
|
url: url,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
data: data,
|
|
timeout: 10000,
|
|
cache: false,
|
|
success: function (t) {
|
|
if (t.Success) {
|
|
|
|
layer.msg('保存成功');
|
|
|
|
} else {
|
|
layer.msg(t.Message);
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
function GetMBData(gid,type) {
|
|
var url = '/MvcShipping/MsOpSeaeTD/GetSFTWithGID';
|
|
var data = { gid: gid};
|
|
$.ajax({
|
|
url: url,
|
|
type: 'POST',
|
|
dataType: 'json',
|
|
data: data,
|
|
timeout: 10000,
|
|
cache: false,
|
|
success: function (t) {
|
|
if (t.Success) {
|
|
var data = eval(t).data;
|
|
if (type==0) {
|
|
text = $("textarea[name='CONSIGNEEINFO']").val(data.MBTEXT);
|
|
} else if (type==1) {
|
|
text = $("textarea[name='SHIPPERINFO']").val(data.MBTEXT);
|
|
} else {
|
|
text = $("textarea[name='NOTIFYPARTYINFO']").val(data.MBTEXT);
|
|
}
|
|
|
|
} else {
|
|
}
|
|
}
|
|
})
|
|
} |