123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>打印运费结算单</title>
- <script src="../../js/min-loader-next.js"></script>
- <script src="../../js/jquery.jqprint-0.3.js"></script>
- <script src="http://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script>
- <style>
- .layui-table-cell {
- height: 28px;
- line-height: 28px;
- padding: 0 0px;
- position: relative;
- box-sizing: border-box;
- overflow: visible !important;
- text-overflow: !important;
- white-space: nowrap !important;
- }
- .printChuku{
- display: none;
- }
- </style>
- </head>
- <body class="body-content">
- <div class="order-body">
- <div class="order-tiaojian back-gray">
- <div class="tiaojian-part1" id="conditions">
- <div class="fl f12-gray4-op mt4">所选条件:</div>
- </div>
- <div class="tiaojian-part2 fr demoTableOne">
- <button class="order-bnt1" onclick="reload();">查询</button>
- <button class="order-bnt2" onclick="cancle();">重置</button>
- <a href="#" id="toggle" class="top">收起<i class="iconfont up iconSelect_drop-down"></i></a>
- </div>
- </div>
- <form class="layui-form" action="javascript:void(0)" id = "formName" >
- <div class="order-select back-border" id="content" style="display: block;">
- <div class="layui-inline">
- <label class="f12-gray4">到货日期:</label>
- <input type="text" class="search-select" id="datesTwo" autocomplete="off" placeholder=" - ">
- </div>
- <div class="layui-inline">
- <label class="f12-gray4">运输方:</label>
- <div class="layui-input-inline" id ="name" >
- </div>
- </div>
- </div>
- </form>
- </div>
- <div class="shadow-content" >
- <div class="gray-title demoTable" id = "buttonForm">
- <button class="layui-btn left-bnt1 in-b" id="printBtn" >
- 打印
- </button>
- <button class="layui-btn left-bnt1 in-b" id="saveBtn">
- 保存
- </button>
- <button class="layui-btn left-bnt1 in-b" id="detailBtn">
- 查看明细数据
- </button>
- <button class="layui-btn left-bnt1 in-b" id="addDetailBtn">
- 新增明细数据
- </button>
- </div>
- <div id="big" style = "display : none">
- <div style="margin-bottom: 24px;border-bottom: 1px black solid;width: 100%;height: 127px; display: none;" id = "headImg">
- <img src="../../images/wlHead.jpg" style="
- width: 80%;
- margin-left: 10%;
- height: 125px;
- ">
- </div>
- <div id="DivHead" style="margin-bottom: 24px;">
- <div style="margin: 0;width: 100%;">
- <div style="font-size: 18px;font-weight: 600;text-align: center;margin: 0;">
- <span id="title">运费结算单</span>
- </div>
- <div style="font-size:18px;font-weight: 600;text-align: center;margin: 0;">
- <span style="float:left" contenteditable="true"><span id="sell1"></span>:</span>
- </div><br/><br/>
- <div style="float:left;font-size: 12px;font-weight: 400;text-align: center;margin: 0;">
- <span contenteditable="true">
- 现将我司<span id="strh"></span>月运费结算明细与贵司确认:</span>
- </div>
- <br>
- <div style = "width:980px;margin-top: 20px;">
- <table id="tableTest" lay-filter="tableFilter" ></table>
-
- <table id="tableTestPrint" style="display: none;width: 100%;" class="printChuku">
- <thead style = "padding-left:24px;padding-right:24px;">
- <tr>
- <th>运费结算月</th>
- <th>发出库</th>
- <th>到站地</th>
- <th>到货重量</th>
- <th>运费单价(元)</th>
- <th>运费(元)</th>
- </tr>
- </thead>
- <tbody id ="small" style = "padding-left:24px;padding-right:24px;">
- </tbody>
- </table>
- </div>
- </div>
- </div>
- <div id="DivFoot" style="margin: 0;padding-bottom: 24px;">
- <div style="margin: 0;width: 100%;">
- <div class="display5" style="font-size: 18px;font-weight: 600;float:left">
- <div>卖方:</div>
- <div id="sell" style="padding-right:300px;font-size: 18px;font-weight: 600;" contenteditable="true"></div>
- <div>买方:</div>
- <div id="buy" contenteditable="true"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- var tabPageId = getQueryString("tabPageId");
- var datesTwo = getTempVal('datesTwo');
- var transporter = getTempVal('transporter');
- var chooseDate = getQueryString("chooseDate");
- var id = getQueryString("id");
- var companyName = decodeURI(decodeURI(getQueryString("companyName")));
- if(!isEmpty(chooseDate)){
- $("#datesTwo").val(chooseDate);
- }
-
- if(!isEmpty(companyName)){
- layui.use('form', function(){
- var form = layui.form;
- $.request({
- action : 'giveOutManageAction/qureyTransporter',
- data : {},
- success : function(data) {
- var name ="name";
- var html = '<select name="';
- html = html + name;
- html = html + '"';
- html = html + 'lay-search="" lay-filter="'+name+'"';
- html = html + '><option value="">请选择物流方</option>';
- $.each(data.data, function(i, j) {
- if( j.name == companyName){
- html = html + '<option ';
- html = html + 'selected value="';
- html = html + j.name + '">';
- html = html + j.name+ '</option>';
- }else{
- html = html + '<option ';
- html = html + 'value="';
- html = html + j.name + '">';
- html = html + j.name+ '</option>';
- }
- })
- html = html + '</select>';
- $("#name").html(html);
- form.render();
- }
-
- })
- })
- }else{
- layui.use('form', function(){
- var form = layui.form;
- $.request({
- action : 'giveOutManageAction/qureyTransporter',
- data : {},
- success : function(data) {
- var name ="name";
- var html = '<select name="';
- html = html + name;
- html = html + '"';
- html = html + 'lay-search="" lay-filter="'+name+'"';
- html = html + '><option value="">请选择物流方</option>';
- $.each(data.data, function(i, j) {
- html = html + '<option ';
- html = html + 'value="';
- html = html + j.name + '">';
- html = html + j.name+ '</option>';
- })
- html = html + '</select>';
- $("#name").html(html);
- form.render();
- }
-
- })
- })
- }
-
-
- if(!isEmpty(id)){
- reload();
- }
-
- layui.use('laydate', function(){
- var laydate = layui.laydate;
- laydate.render({
- elem: '#datesTwo'
- ,range: true
- ,format:'yyyyMMdd'
- ,trigger: 'click'
- });
- })
-
-
- var table;
- function reload(func){
- var datesTwo = $("#datesTwo").val();
- var transporter = $("[name='name']").val();
- if (isEmpty(transporter)) {
- transporter = companyName;
- }
-
- if (isEmpty(id)) {
- if (isEmpty(datesTwo)) {
- $.ErrorAlert("请选择到货日期!");
- return;
- }
- if (isEmpty(transporter)) {
- $.ErrorAlert("请选择运输方!");
- return;
- }
- }
-
- $.request({
- action : 'giveOutManageAction/freightPrinting',
- loading : false,
- data : {MINView:"JSON", datesTwo : datesTwo,transporter : transporter, id : id},
- success : function(res) {
- $('#sell1').html(res.sell);
- $('#strh').html(res.strh);
- $('#buy').html(res.buy+"(盖章)");
- $('#sell').html(res.sell+"(盖章)");
- var mesList = res.data;
- tableData = heji(mesList);
- //新增
- layui.use('table', function(){
- //创建一行参数
- table = layui.table;
- table.render({
- id : 'tableTest'
- ,elem: '#tableTest'
- ,data : tableData
- ,limit:1000
- ,size: 'sm' //小尺寸的表格
- ,cols : [[ //表头
- {field : 'strh', title: '运费结算月',edit: 'text'}
- ,{field : 'deliver', title: '发出库',edit: 'text'}
- ,{field : 'arrive', title: '到站地', edit: 'text'}
- ,{field : 'weight', title: '到货重量', edit: 'text'}
- ,{field : 'price', title: '运费单价(元)', edit: 'text'}
- ,{field : 'totalPriceII', title: '运费(元)', edit: 'text'}
- ]]
- ,page: false
- ,done: function(res, curr, count){
- //如果是异步请求数据方式,res即为你接口返回的信息。
- $("#big").show();
- // 处理合计行
- var trs = $("tbody").find("tr");
- // 最后一个tr的div
- var divs = $(trs[trs.length - 1]).find("div");
- $(divs[0]).html("合计");
- if (!isEmpty(func)) {
- func();
- }
- }
- });
- table.on('edit(tableFilter)', function(obj){ //注:edit是固定事件名,test是table原始容器的属性 lay-filter="对应的值"
- console.log(obj); //所在行的所有相关数据
- var editData = obj.data;
- var index = editData.LAY_TABLE_INDEX;
- var field = obj.field;
- var tableData = table.cache["tableTest"];
- //修改单价或重量,且不是合计
- if ((field == 'weight' || field == 'price') && index != (tableData.length - 1)) {
- var editTr = $("tbody").find("tr")[index];
- $(editTr).find('td[data-field="totalPriceII"]').click();
- $($($(editTr).find('td[data-field="totalPriceII"]')).find("input")).val(accMul(editData.weight, editData.price, 2));
- tableData[index].totalPriceII = accMul(editData.weight, editData.price, 2);
- var totalWeight = "0";
- var totalPrice = "0";
- for (var i = 0; i < (tableData.length - 1); i ++) {
- var trData = tableData[i];
- totalWeight = accAdd(totalWeight, trData.weight, 4);
- totalPrice = accAdd(totalPrice, trData.totalPriceII, 2);
- }
- var hejiTr = $("tbody").find("tr")[tableData.length - 1];
- $(hejiTr).find('td[data-field="weight"]').click();
- $($($(hejiTr).find('td[data-field="weight"]')).find("input")).val(totalWeight);
- $(hejiTr).find('td[data-field="totalPriceII"]').click();
- $($($(hejiTr).find('td[data-field="totalPriceII"]')).find("input")).val(totalPrice);
- }
- });
- })
- },
- error : function(data) {
- layer.alert(data.MINErrorMessage, {
- icon: 5,
- title: "提示"
- });
- }
- });
- }
-
- function heji(tableData) {
- // 总重量
- var weight = 0;
- // 总结算金额
- var totalPriceII = 0;
- for (var i = 0; i < tableData.length; i ++) {
- var d = tableData[i];
-
- // 总重量
- weight = accAdd(d.weight, weight);
- // 总结算金额
- totalPriceII = accAdd(d.totalPriceII, totalPriceII);
- }
-
- var hejiMap = {};
- hejiMap.weight = fomatFloat(weight,4);
- hejiMap.totalPriceII = fomatFloat(totalPriceII,2);
- tableData.push(hejiMap);
- return tableData;
- }
- //打印
- $(document).on('click','#printBtn',function(){
- var tableData = table.cache['tableTest'];
- var printTableHtml = "";
- for (var i = 0; i < tableData.length; i ++) {
- var inf = tableData[i];
- printTableHtml += '<tr><td>' + (isEmpty(inf.strh)?'合计':inf.strh) + '</td><td>' + (isEmpty(inf.deliver)?'':inf.deliver)
- + '</td><td>' + (isEmpty(inf.arrive)?'':inf.arrive) + '</td><td>' + (isEmpty(inf.weight)?'':inf.weight) + '</td><td>'
- + (isEmpty(inf.price)?'':inf.price) + '</td><td>' + (isEmpty(inf.totalPriceII)?'':inf.totalPriceII) + '</td></tr>';
- }
- $("#small").html(printTableHtml);
- $(".layui-table-view").hide();
- $("#headImg").show();
- $("#tableTestPrint").show();
- $("#big").jqprint();
- $("#headImg").hide();
- $("#tableTestPrint").hide();
- $(".layui-table-view").show();
- });
- //保存
- $(document).on('click','#saveBtn',function(){
- isConfirm = true;
- saveFunc();
- });
- function saveFunc() {
- var datesTwo = $("#datesTwo").val();
- var transporter = $("[name='name']").val();
- if (isEmpty(datesTwo)) {
- $.ErrorAlert("请选择到货日期!");
- return;
- }
- if (isEmpty(transporter)) {
- $.ErrorAlert("请选择运输方!");
- return;
- }
- var isShow = $("#big").css("display");
- if (isShow == 'none') {
- $.ErrorAlert("请先查询!");
- return;
- }
- var saveHtml = window.btoa(encodeURI($("#big").html()));
- $.request({
- action : 'giveOutManageAction/freightPrintingSave',
- data : {MINView:"JSON", datesTwo : datesTwo,transporter : transporter, saveHtml : saveHtml, id : id},
- success : function(data) {
- var resId = data.id;
- id = resId;
- if (isConfirm) {
- $.SuccAlert("保存成功!");
- }
- }
- })
- }
-
- $(document).on('click','#detailBtn',function(){
- if (isEmpty(id)) {
- $.ErrorAlert("保存后查看明细数据.");
- return;
- }
- openMainTabPageParent(tabPageId+'-01', '发运数据明细', 'logisticsManage/logisticsInformation.html?tabPageId='+tabPageId+'-01&oprate=del&delTransId='+id,'',tabPageId,back);
- });
-
- $(document).on('click','#addDetailBtn',function(){
- if (isEmpty(id)) {
- $.ErrorAlert("请保存后再增加明细数据!");
- return;
- }
- var transporter = $("[name='name']").val();
- openMainTabPageParent(tabPageId+'-02', '选择发运数据明细', 'logisticsManage/logisticsInformation.html?tabPageId='+tabPageId+'-02&transState=01&oprate=add&addTransId='+id+'&transporter='+encodeURI(encodeURI(transporter)),'',tabPageId,back);
- });
- var isConfirm;
- function back() {
- var logisticsDel = getTempVal("logisticsDel");
-
- if (!isEmpty(logisticsDel)) {
- isConfirm = false;
- setTempVal("logisticsDel", null);
- reload(saveFunc);
- } else {
- console.log("未经行删除操作!");
- }
- }
- </script>
-
-
-
- </body>
- </html>
|