123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480 |
- /**
- * window onload
- * by lijg
- * 2018.11.07
- */
- window.onload = function(){
- // var yesterday = myGetDate(-1);
- var today = myGetDate(0);
- var monthAgo = myGetDate(-30);
- $(".start_date").val(monthAgo);
- $(".end_date").val(today);
- $(".top_start").html(monthAgo);
- $(".top_end").html(today);
- getOrdersInit();
- $(".code_input_in").focus();
-
- };
- function searchOrder(){
- var code = $('.search_code').val();
- if(code.length == 0){
- alert('请输入所查找编号!');
- return false;
- }
- var key = getUrlParam();
- $.ajax({
- type: 'get',
- url: 'application/main.php',
- data: 'c=wigsOut&m=searchOrders&code=' + code + '&key=' + key,
- success: function(rs){
- if(rs == '-1'){
- alert('查无此编号!');
- }else{
- $("#list").html(rs);
- }
- $('.search_code').val("");
- $('.search_code').focus();
-
- },
- });
- return false;
- }
- /**
- * get any date
- * by lijg
- * 20181108
- */
- function myGetDate(whichDay){
- var myDate = new Date();
- myDate.setDate(myDate.getDate()+whichDay);
- var year = myDate.getFullYear();
- var month = (myDate.getMonth()+1<10)?'0'+(myDate.getMonth()+1):(myDate.getMonth()+1);
- var day = (myDate.getDate()<10)?('0'+myDate.getDate()):myDate.getDate();
- var today = year + '-' + month + '-' + day;
- return today;
- }
- /**
- * by lijg
- * 2018.11.07
- */
- $(document).ready(function(){
- var key = getUrlParam();
- // if(!key){
- // $('.options').hide();
- // }
- $(document).on("click", ".gtlt", function(){
- var shop = $(".shop").val();
- var status = $(".orders_status").val();
- var type = $(".type").val();
- var time_type = $(".time_type").val();
- var start = $(".start_date").val();
- var end = $(".end_date").val();
-
- var total_page = $(".total_page").data('ttpg');
- var wh = $(this).data('wh');
- var dir = wh.substr(0, 1);
- var now = wh.substr(1);
- let pnsn = localStorage.getItem('pnsn');
- if(dir == 'h'){
- now = (now-1)*10 + 1;
- }else if(dir == 't'){
- now = now*10 + 1;
- }
- if(now > 0 && now <= total_page){
- var params1 = now + '_' + shop + '_' + status + '_' + start + '_' + end + '_' + key + '_' + pnsn + '_' + type+ '_'+time_type;
- var params2 = shop + '_'+ status + '_' + start + '_' + end + '_' + wh + '_' + pnsn + '_' + type + '_'+time_type;
- myAjax('wigsOut_getOrders', params1);
- myAjax('wigsOut_pagination', params2);
- }else{
- return false;
- }
- });
- $(document).on("click", ".cancel_order", function(){
- var barcode = $(this).data('barcode');
- updateOrdersStatus(barcode, '4');
- });
- $(".status_btn").click(function(){
- getOrdersInit();
- var start = $(".start_date").val();
- var end = $(".end_date").val();
- $('.top_start').html(start);
- $('.top_end').html(end);
- });
- $(".code_input_in").change(function(){
- var code = $(this).val();
- updateOrdersStatus(code, '2');
- });
- $(".code_input_out").change(function(){
- var code = $(this).val();
- updateOrdersStatus(code, '3');
- });
- $(".code_input_dist").change(function(){
- var code = $(this).val();
- updateOrdersStatus(code, '6');
- });
- $('.search_code_btn').click(function(){
- var code = $('.search_code').val();
- if(code.length == 0){
- alert('请输入所查找编号!');
- return false;
- }
- var key = getUrlParam();
- $.ajax({
- type: 'get',
- url: 'application/main.php',
- data: 'c=wigsOut&m=searchOrders&code=' + code + '&key=' + key,
- success: function(rs){
- if(rs == '-1'){
- alert('查无此编号!');
- }else{
- $("#list").html(rs);
- }
- },
- });
- });
- $('.export_btn').click(function(){
- var shop = $("#shop").val();
- var status = $("#orders_status").val();
- var type = $('#type').val();
- var start_date = $(".start_date").val();
- var end_date = $(".end_date").val();
- var time_type= $(".time_type").val();
-
- if(!start_date || !end_date){
- alert("请选择查询日期");
- return false;
- }else if(start_date > end_date){
- alert("结束日期不得小于起始日期");
- return false;
- }
-
- window.location.href = 'application/main.php?c=wigsOut&m=exportExcel&shop='+shop+'&status='+status+'&startDate='+start_date+'&endDate='+end_date+'&type='+type+'&time_type='+time_type;
- });
-
- $('.export_yesterday_btn').click(function(){
- eyb();
- setTimeout(eyb, 2000);
- });
- function eyb(){
- window.location.href = 'application/main.php?c=wigsOut&m=exportExcel&shop='+0+'&status='+3+'&startDate='+myGetDate(-1)+'&endDate='+myGetDate(-1)+'&type='+0;
- }
-
- /**
- * change per page amount
- * by lijg 20190214
- */
- $('.pagination').on('change', '.pnsn', function(){
- let pnsn = $(this).val();
- localStorage.setItem('pnsn', pnsn);
- getOrdersInit();
- });
- $(document).on('click', '.update_memo', function(){
- var oid = $(this).data('id');
- var omemo = $(this).parent('.options').siblings('.memo').html();
- var memo = prompt("请填写备注:", omemo);
- if(memo != null && memo != ''){
- $.ajax({
- type: 'post',
- url: 'application/main.php',
- data: 'c=wigsOut&m=updateMemo&oid=' + oid + '&memo=' + memo,
- success: function(rs){
- if(rs == -1){
- alert('添加备注失败,请联系开发人员!');
- }else{
- window.location.reload();
- }
- },
- });
- }
- });
- $('.sync_data').click(function(){
- $('.sync_icon').show();
- $.ajax({
- type: 'get',
- url: 'application/main.php',
- data: 'c=wigsOut&m=syncData',
- dataType: 'json',
- success: function(rs){
- $('.sync_icon').hide();
- if(rs.code == 0){
- alert('无新数据!');
- }else if(rs.code != 1){
- alert('同步失败,请联系开发人员!');
- }else{
- alert('同步成功!');
- window.location.reload();
- }
- },
- });
- });
-
- $('#list').on('click', '.print_bc', function(){
- var order_barcode = $(this).parent().parent('.list_block').find('.order_barcode').html();
- var goods_info = $(this).parent().parent('.list_block').find('.goods_info').html();
- var print_time = $(this).parent().parent('.list_block').find('.order_id').data('printtime');
- var transport = $(this).parent().parent('.list_block').find('.order_id').data('transport');
- var oid = $(this).parent().parent('.list_block').find('.order_id').html();
- var LODOP;
- LODOP=getLodop();
- LODOP.PRINT_INIT("");
- if (LODOP.CVERSION) CLODOP.On_Return = function(TaskID, Value) {
- if(Value==1){
- $.ajax({
- type: 'post',
- url: 'application/main.php',
- data: 'c=wigsOut&m=updatePrint&oid=' + oid,
- success: function(rs){
- if(rs == -1){
- alert('系统错误,请联系开发人员!');
- }else{
- $('.barcode>.box').html('');
- $('.yp').html('').hide();
- $('.np').show();
- reloadNow();
- }
- },
- });
- }else{
- alert('系统错误,请联系开发人员!');
- }
- }
- LODOP.ADD_PRINT_BARCODE(3, 2, 400, 35, "128Auto", order_barcode);
- LODOP.SET_PRINT_STYLEA(0, "showBarText", 0)
- var str=order_barcode+'*'+goods_info + '*' + transport + '*' + print_time;
- if(str.length>=130){
- str1=str.slice(0,130);
- str2=str.slice(130);
- LODOP.ADD_PRINT_TEXT(47, "0mm",400,"45mm", str1);
- LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
- LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
- LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
- LODOP.NewPageA();
- LODOP.ADD_PRINT_TEXT(3, "0mm",400,"45mm", str2);
- LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
- LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
- LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
- }else{
- LODOP.ADD_PRINT_TEXT(47, "0mm",400,"45mm", str);
- LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
- LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
- LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
- }
- // LODOP.ADD_PRINT_BARCODE(3, 10, 32, 400, "128Auto", order_barcode);
- // LODOP.SET_PRINT_STYLEA(0, "showBarText", 0)
- // LODOP.SET_PRINT_STYLEA(0, "Angle", 90)
- // var str=order_barcode+'*'+goods_info + '*' + transport + '*' + print_time;
- // LODOP.ADD_PRINT_TEXT(450, 4, 500, 45, str);
- // LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
- // LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
- // LODOP.SET_PRINT_STYLEA(0, "Angle", 90)
- // LODOP.SET_PRINT_PAGESIZE(3,450,70,"")//设置默认纸张
- LODOP.PRINT();
- });
- $('.print_all').click(function(){
- $.ajax({
- type: 'post',
- url: 'application/main.php',
- data: 'c=wigsOut&m=printAll',
- success: function(rs){
- if(rs == -1){
- alert('暂无可打印数据!');
- }else{
- var arr = JSON.parse(rs);
- var r=confirm("共有"+arr.length+"个单据,是否打印")
- console.log(r);
- if (r==false){
- return false;
- }
- var LODOP;
- LODOP=getLodop();
- LODOP.PRINT_INIT("");
- for(var i = 0; i < arr.length; i++) {
- (function(i) {
- setTimeout(function() {
- LODOP.ADD_PRINT_BARCODE(3, 2, 400, 35, "128Auto", arr[i].barcode);
- LODOP.SET_PRINT_STYLEA(0, "showBarText", 0)
- str=arr[i].str;
- if(str.length>=130){
- str1=str.slice(0,130);
- str2=str.slice(130);
- LODOP.ADD_PRINT_TEXT(47, "0mm",400,"45mm", str1);
- LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
- LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
- LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
- LODOP.NewPageA();
- LODOP.ADD_PRINT_TEXT(3, "0mm",400,"45mm", str2);
- LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
- LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
- LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
- }else{
- LODOP.ADD_PRINT_TEXT(47, "0mm",400,"45mm", str);
- LODOP.SET_PRINT_STYLEA(0, "FontSize", 13);
- LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
- LODOP.SET_PRINT_STYLEA(0,"FontName","黑体")
- }
- // LODOP.SET_PRINT_PAGESIZE(3,450,70,"")//设置默认纸张
- // LODOP.PRINTA();
- LODOP.PRINT();
- }, (i + 1) * 2000);
- })(i)
- }
- $('.barcode>.box').html('');
- $('.yp').html('').hide();
- $('.np').show();
- reloadNow();
- }
- },
- });
- });
- });
- /**
- * reload current page
- * by lijg
- * 2019.10.15
- */
- function reloadNow(){
- var shop = $("#shop").val();
- var status = $("#orders_status").val();
- var start_date = $(".start_date").val();
- var end_date = $(".end_date").val();
- var type= $("#type").val();
- let pnsn = localStorage.getItem('pnsn');
- if(pnsn == null){
- pnsn = 15;
- localStorage.setItem('pnsn', 15);
- }
- var now = $('#pagination').data('now');
- if(!start_date || !end_date){
- alert("请选择查询日期");
- return false;
- }else if(start_date > end_date){
- alert("结束日期不得小于起始日期");
- return false;
- }
- var key = getUrlParam();
- var param1 = now + '_' + shop + '_' + status + '_' + start_date + '_' + end_date + '_' + key + '_' + pnsn + '_' + type + '_' + time_type;
- var param3 = start_date + '_' + end_date + '_' + time_type;
- myAjax('wigsOut_getOrders', param1);
- myAjax('wigsOut_getStatistics', param3);
- }
- /**
- * get orders
- * by lijg
- * 2018.11.07
- */
- function getOrdersInit(){
- var shop = $("#shop").val();
- var status = $("#orders_status").val();
- var start_date = $(".start_date").val();
- var end_date = $(".end_date").val();
- var type= $("#type").val();
- var time_type=$('.time_type').val();
- let pnsn = localStorage.getItem('pnsn');
- if(pnsn == null){
- pnsn = 15;
- localStorage.setItem('pnsn', 15);
- }
-
- if(!start_date || !end_date){
- alert("请选择查询日期");
- return false;
- }else if(start_date > end_date){
- alert("结束日期不得小于起始日期");
- return false;
- }
- var key = getUrlParam();
- var param1 = '1' + '_' + shop + '_' + status + '_' + start_date + '_' + end_date + '_' + key + '_' + pnsn + '_' + type+ '_' + time_type;
- var param2 = shop + '_' + status + '_' + start_date + '_' + end_date + '_h0' + '_' + pnsn + '_' + type + '_' + time_type;
- var param3 = start_date + '_' + end_date + '_' + time_type;
- myAjax('wigsOut_getOrders', param1);
- myAjax('wigsOut_pagination', param2);
- myAjax('wigsOut_getStatistics', param3);
- }
- /**
- * get orders from pagination
- * by lijg
- * 2018.11.07
- */
- function getOFP(param){
- var key = getUrlParam();
- let pnsn = localStorage.getItem('pnsn');
- param += '_' + key + '_' + pnsn;
- myAjax('wigsOut_getOrders', param);
- }
- /**
- * ajax upload excel for wigsOut
- * by lijg
- * 2018.11.07
- */
- function uploadWigsout(aim){
- var xmlHttp = getXmlHttpObjecf(xmlHttp == null);
- if(xmlHttp == null){
- alert("Please update your browser!");
- return false;
- }
-
- var excel = document.getElementById('excel').files['0'];
- if(excel == undefined){
- alert("请选择导入文件");
- return false;
- }else{
- var ext = excel.name.substr(excel.name.lastIndexOf('.')+1);
- if(ext != 'xlsx'){
- alert('请选择 *.xlsx 格式文件!');
- return false;
- }else{
- $(".btn").attr("disabled", true);
- $(".upload_icon").show();
- }
- }
-
- var cm = aim.split('_');
- var url = 'application/main.php';
- var form = new FormData();
- form.append('c', cm[0]);
- form.append('m', cm[1]);
- form.append('excel', excel);
-
- xmlHttp.onreadystatechange = function(){
- stateChanged(xmlHttp, aim);
- };
-
- xmlHttp.open('POST', url, true);
- xmlHttp.send(form);
- }
- /**
- * update orders
- * by lijg 20181108
- */
- function updateOrdersStatus(code, status){
- params = code + '_' + status;
- myAjax("wigsOut_updateOrder", params);
- }
- /**
- * get url param
- * by lijg 20181120
- */
- function getUrlParam(){
- var url = window.location.href;
- var p = url.split('?');
- if(p.length == 2){
- return p[1];
- }else{
- return null;
- }
- }
|