Bläddra i källkod

修改导出测试

lvhao 1 vecka sedan
förälder
incheckning
c961c31415
2 ändrade filer med 588 tillägg och 1 borttagningar
  1. 142 1
      core/CoreApp/controllers/Whlabel.php
  2. 446 0
      template/erp/whlabel_typejs.html

+ 142 - 1
core/CoreApp/controllers/Whlabel.php

@@ -186,11 +186,59 @@ class Whlabel extends Start_Controller
 			$this->_0kcdel(); //导表删除0库存
 		} else if ($arg == 'gbhtype') {
 			$this->_gbhtype(); //更改备货状态
-		} else {
+		} else if($arg == 'excelrjs'){
+			$this->_excelrjs();
+		}else if($arg == "w_t_cs"){
+			$this->_w_t_cs(); //首页
+		}else {
 			$this->_index();
 		}
 	}
 
+	public function _w_t_cs(){
+		$vip = 0;
+		if (isset($_SESSION['api'])) {
+			$user = $this->user->get_api($_SESSION['api']);
+			$fgshop = "";
+			$sid = "";
+			$usersp = explode('|', trim($user['shop'], '|'));
+			foreach ($usersp as $value) {
+				$fgshop .= " shop = " . $value . " or";
+				$sid .= " id = " . $value . " or";
+			}
+			if ($user['vip'] == 1) {
+				$vip = 1;
+			}
+		} else {
+			header('Location: /');
+			exit;
+		}
+		$prc = array();
+		$purchase = $this->purchase->find_all();
+		foreach ($purchase as $k => $v) {
+			$prc[$v['id']] = $v['title'];
+		}
+		$company = array();
+		$ct = $this->company->find_all();
+		foreach ($ct as $k => $v) {
+			$company[$v['id']] = $v['title'];
+		}
+		$sp = array();
+		$s = $this->shop->find_all('1=1', 'id,shopname');
+		foreach ($s as $v) {
+			$sp[$v['id']] = $v['shopname'];
+		}
+		$wh = array();
+		$w = $this->warehouse->find_all('1=1', 'id,title');
+		foreach ($w as $v) {
+			$wh[$v['id']] = $v['title'];
+		}
+		$wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
+		$this->data['shop'] = $wlshop;
+		$this->data['vip'] = $vip;
+		$this->_Template('whlabel_typejs', $this->data);
+	}
+
 	//管理
 	public function _index()
 	{
@@ -7541,4 +7589,97 @@ class Whlabel extends Start_Controller
 			$this->excel->get_fz2($merged, $titlename, $filename, $tail);
 		}
 	}
+
+
+	/*************************************处理exceljs导出****************************************************/
+	public function _excelrjs(){
+		if (isset($_GET['excel'])) {
+			$category = $this->input->get('category', true);
+			$size = $this->input->get('size', true);
+			$grade = $this->input->get('grade', true);
+			$color = $this->input->get('color', true);
+			$lowe = $this->input->get('lowe', true);
+			$sku = $this->input->get('sku', true);
+			$warehouse = $this->input->get('warehouse', true);
+			$purchase = $this->input->get('purchase', true);
+			$ktime = $this->input->get('ktime', true);
+			$jtime = $this->input->get('jtime', true);
+			$ktime = strtotime($ktime);
+			$jtime = strtotime($jtime);
+			$where = "1=1";
+			$gj = "";
+			$ck = "";
+			if ($category) {
+				$where  .= " and features like '%-$category-%'";
+			}
+			if ($size) {
+				$where  .= " and features like '%-$size-%'";
+			}
+			if ($grade) {
+				$where  .= " and features like '%-$grade-%'";
+			}
+			if ($color) {
+				$where  .= " and features like '%-$color-%'";
+			}
+			if ($lowe) {
+				$where  .= " and features like '%-$lowe-%'";
+			}
+			if ($warehouse) {
+				$where  .= " and warehouse = '$warehouse'";
+			}
+			if ($purchase) {
+				$where  .= " and purchase = '$purchase'";
+			}
+			if ($sku) {
+				$where  .= " and sku = '$sku'";
+			}
+			if ($ktime && $jtime) {
+				$where  .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
+			}
+			//数据排序
+			$order_str = "id desc";
+			if (empty($page)) {
+				$start = 0;
+				$perpage = 1;
+			} else {
+				$start = ($page - 1) * $perpage;
+			}
+			$list = array();
+			$rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
+			foreach ($rows as $value) {
+				$ck = $this->warehouse->read($value['warehouse']);
+				$warehouse = $ck['title'];
+				$tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
+				$retreatwarehouse = $tkck['title'];
+				$gy = $this->purchase->read($value['purchase']);
+				$purchase = $gy['title'];
+				$g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
+				$list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
+			}
+			
+			$list = array_values($list);
+			$title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
+			array_unshift($list,[
+				"仓库","SKU","商品名称","时间","数量"
+			]);
+			array_unshift($list,[
+				$title,"","","",""
+			]);
+			exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $list,'title'=>$title)));
+
+			if(empty($list)){
+				exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
+			}else{
+				$list = array_values($list);
+				$title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
+				array_unshift($list,[
+					"仓库","SKU","商品名称","时间","数量"
+				]);
+				array_unshift($list,[
+					$title,"","","",""
+				]);
+				exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $list,'title'=>$title)));
+			}
+		}
+	}
 }

+ 446 - 0
template/erp/whlabel_typejs.html

@@ -0,0 +1,446 @@
+{Template header}
+<style>
+    .diysearch{
+        padding: 5px;
+    }
+    .diysearch select{
+        width: 110px;
+        height: 28px;
+        color: #333;
+        border: 1px #ccc solid;
+        font-size: 13px;
+        margin-right: 20px;
+        border-radius: 5px;
+    }
+    .diysearch input{
+        width: 100px;
+        height: 26px;
+        color: #000;
+        border: 1px #ccc solid;
+        font-size: 13px;
+        margin-right: 20px;
+        text-align: center;
+        color: #333;
+        border-radius: 5px;
+    }
+    .diysearch .qd_show{
+        width: 70px;
+        height: 30px;
+        line-height: 30px;
+        background: #2ca8a1;
+        text-align: center;
+        color: #fff;
+        border-radius: 5px;
+        display: inline-block;
+        margin-left: 20px;
+        cursor: pointer;
+        border: 0px solid #2ca8a1;
+    }
+    
+</style>
+<link href="{$theme}js/select2/select2.min.css?v={time()}" rel="stylesheet" />
+<script src="{$theme}js/select2/select2.full.min.js?v={time()}"></script>
+
+<body>
+<div class="warp">
+<div class="fixed">
+<div  style="width:100%;display: flex;flex-direction: row;flex-wrap: wrap;">
+    <div class="diysearch">
+        类目   :<select name="category" class="select">
+            <option value="">请选择</option>{loop typeclass(16) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>{/loop}</select>
+    </div>
+    <div class="diysearch">
+        等级  :<select name="grade" class="select">
+            <option value="">请选择</option>{loop typeclass(13) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>{/loop}</select>
+    </div>
+    <div class="diysearch" >
+        颜色  :<select name="color" class="select select_two"  style="width: 150px !important;">
+            <option value="">请选择</option>{loop typeclassyc(8) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>{/loop}</select>
+    </div>
+    <div  class="diysearch" >
+        曲度  :<select name="lowe" class="select select_two"  style="width: 150px !important;" >
+            <option value="">请选择</option>{loop typeclassyc(15) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>{/loop}</select>
+    </div>
+    <div  class="diysearch">
+        头套种类  :<select name="lacetype" class="select select_two"  style="width: 220px !important;">
+            <option value="">请选择</option><option value="146">13*4 Lace Front wigs</option>
+            {loop typeclassyc(18) as $val}
+            {if $val['id']!=146}
+            <option value="{$val['id']}">{$val['title']}</option>
+            {/if}
+            {/loop}
+            </select>
+    </div>
+    <div  class="diysearch">
+        蕾丝颜色  :<select name="lacecolor" class="select">
+            <option value="">请选择</option>{loop typeclassyc(9) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>{/loop}</select>
+    </div>
+    <div  class="diysearch">
+        长度  :<select name="size" class="select">
+            <option value="">请选择</option>{loop typeclass(14) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>{/loop}</select>
+    </div>
+    <div  class="diysearch">
+        密度  :<select name="density" class="select">
+            <option value="">请选择</option>{loop typeclassyc(10) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>{/loop}</select>
+    </div>
+    <div  class="diysearch">
+        头套大小  :<select name="haircap" class="select">
+            <option value="">请选择</option>{loop typeclassyc(6) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>{/loop}</select>
+    </div>
+    <div  class="diysearch">
+        人发头套编号  :<select name="hairnumber" class="select select_two"  style="width: 150px !important;">
+            <option value="">请选择</option>
+            <option value="-1">无编号</option>
+            {loop typeclassyc(43) as $val}
+            
+            <option value="{$val['id']}">{$val['title']}</option>
+            {/loop}
+            </select>
+    </div>
+   
+    <div  class="diysearch">
+        仓库  :<select name="warehouse" class="select">
+            <option value="">请选择</option>{loop warehouse(10) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>{/loop}</select>
+    </div>
+    <div  class="diysearch">
+        仓库位置  :<input value="" name="details" type="text" >
+    </div>
+    <div  class="diysearch">
+        店铺  :<select name="shop" class="select">
+            <option value="">请选择</option>{loop $shop as $val}
+            <option value=",{$val['id']},">{$val['shopname']}</option>{/loop}</select>
+    </div>
+    <div  class="diysearch">
+        供应商  :<select name="purchase" class="select">
+            <option value="">全部</option>
+            {loop purchase(100) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>
+            {/loop}
+            </select>
+    </div>
+    <div  class="diysearch">
+        类型  :<select name="type" class="select">
+            <option value="">全部</option>
+            {loop whlabel_type(100) as $val}
+            <option value="{$val['id']}">{$val['title']}</option>
+            {/loop}
+            </select>
+    </div>
+    <div  class="diysearch">
+        SKU  :<input value="" name="sku" type="text" style="width:270px">
+    </div>
+    <div  class="diysearch">
+        商品名称  :<input value="" name="title" type="text" style="width:400px">
+    </div>
+    <div  class="diysearch">
+        产品备注  :<input value="" name="cpbz" type="text" >
+    </div>
+    <div  class="diysearch">
+        说明  :<input value="" name="sm" type="text" >
+    </div>
+   
+    <div  class="diysearch">
+        状态  :<select name="state" class="select">
+            <option value="">请选择</option>
+            <option value="1">正常出库</option>
+            <option value="10">美店零售</option>
+            </select>
+    </div>
+    <div style="width:auto;;display: flex;flex-direction: row;flex-wrap: wrap;">
+        <div  class="diysearch">
+            入库类型  :<select name="rktype" class="select">
+                <option value="">请选择</option>
+                <option value="1">采购入库</option>
+                <option value="2">盘盈调整</option>
+                <option value="3">其他调整入库</option>
+                <option value="4">其他调整入库</option>
+                <option value="5">退库入库</option>
+                <option value="6">退货可用入库</option>
+                <option value="7">形态转换入库</option>
+                </select>
+        </div>
+        <div  class="diysearch">
+            出库类型  :<select name="cktype" class="select">
+                <option value="">请选择</option>
+                <option value="1">销售出库</option>
+                <option value="2">美国销售调货出库</option>
+                <option value="3">盘亏调整</option>
+                <option value="4">其他调整出库</option>
+                <option value="5">形态转换出库</option>
+                </select>
+        </div>
+       
+    </div>
+    
+    <div  class="diysearch">
+        统计时间:<input id="timetk"  value="{date('Y-m-d',time()-29*24*3600)} 0:00" name="ktime" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})">
+        至&nbsp;&nbsp;&nbsp;&nbsp; <input id="timetj" value="{date('Y-m-d',time()+24*3600)} 0:00" name="jtime" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})">
+    </div>
+    <div  class="diysearch">
+        <button onclick="searchspan(1)" class="qd_show">确 定</button>
+    </div>
+    
+
+</div>
+<div class="control">
+<select name="dccz" class="dcmb">
+<option value="">选择导出内容</option>
+<option data-url="excelr" value="1">导出入库数据</option>
+<option data-url="excelct" value="2">导出退库数据</option>
+<option data-url="excelct" value="1">导出出库数据</option>
+<option data-url="excelct" value="5">导出零售数据</option>
+<option data-url="excelct" value="4">导出出库+零售数据</option>
+<option data-url="excelcr" value="4">导出出库+入库合数据</option>
+</select>
+<a href="javascript:void(0);" data-url="exceljxc" data-id="1" class="whlabelexcel">导出进销存</a>
+<a href="javascript:void(0);" data-url="excelct" data-id="3" class="whlabelexcel">导出条件检索</a>
+<a href="javascript:void(0);" class="summary">出库汇总</a>
+
+<a href="javascript:void(0);" data-url="presetout" data-id="3" class="whlabelexcel">导出库存模板</a>
+<a href="javascript:void(0);" class="whlabeldr">导入库存</a>
+{if $vip > 0} {/if}
+<a href="javascript:void(0);" class="whlabelxq">导出数据详情</a>
+<a href="javascript:void(0);" class="whlabelexcelzh">导出库存数据及在途中</a>
+<!--<a href="javascript:void(0);" class="window" data-h="/whlabel/abnormal/" data-t="异常占单" style="background-color:#fc5454;color:#fff">查看异常占单</a>-->
+{if $vip > 0}
+<a href="/whlabel/error/" style="background-color:#fc5454;color:#fff">0库存SKU</a>
+{/if}
+<a href="javascript:void(0);" class="plszbhtype">批量设置备货类型</a>
+<a href="javascript:void(0);" class="dccrtype">导出出入库分类数据</a>
+</div>
+<table class="datatitle data" border="0" style="border-collapse:collapse;">
+<tr>
+<td><label onClick="swapCheck()"><input name="checkbox" type="checkbox" class="regular-checkbox"></label></td>
+<td>仓库</td>
+<td>供应商</td>
+<td>SKU</td>
+<td>商品名称</td>
+<td>位置</td>
+<td>品牌 / 公司</td>
+<td>备注</td>
+<td>说明</td>
+<td>类型</td>
+<td>库存</td>
+<td>在途</td>
+<td>购进</td>
+<td>销售</td>
+<td>退货</td>
+<td>占单数量</td>
+</tr>
+</table>
+</div>
+<table class="datatext data" border="0" style="border-collapse:collapse;">
+</table>
+<div class="bomf"></div>
+</div>
+<div class="systemwindow">
+<div>
+<p><select name="whlabeltype" class="select" style="width:200px;margin-left:15px;">{loop whlabel_type(99) as $val}<option value="{$val['id']}" data-content="{$val['content']}">{$val['title']}</option>{/loop}</select></p>
+<p>{loop whlabel_type(1) as $val}{$val['content']}{/loop}</p>
+<p><font class="button">确 定</font><font class="esc">取 消</font></p>
+</div>
+</div>
+<script>
+let ppkc = false
+let kcpd = false
+var dataurl = "/whlabel/type";var fdataurl = "/whlabel/";var excel = "/whlabel/";
+$(function () { $("#ktime").calendar();$("#jtime").calendar();});
+var customon = 1;
+var editurl = "/whlabel/kj/";
+var editdj = 3;
+var editt = "扣减库存 - 操作";
+function custom(){
+$(".data tr").each(function() {
+$(this).find('td:eq(1)').css("width","3%");
+$(this).find('td:eq(2)').css("width","3%");
+$(this).find('td:eq(3)').css("width","12%");
+$(this).find('td:eq(4)').css("width","22%");
+$(this).find('td:eq(5)').css("width","4%");
+$(this).find('td:eq(6)').css("width","5%");
+$(this).find('td:eq(7)').css("width","4%");
+$(this).find('td:eq(8)').css("width","4%");
+$(this).find('td:eq(8)').css("width","4%");
+$(this).find('td:eq(9)').css("width","3%");
+$(this).find('td:eq(10)').css("width","4%");
+$(this).find('td:eq(11)').css("width","8%");
+$(this).find('td:eq(12)').css("width","3%");
+$(this).find('td:eq(13)').css("width","3%");
+$(this).find('td:eq(14)').css("width","3%");
+$(this).find('td:eq(15)').css("width","12%");
+});}
+
+$(".whlabelxq").click(function() {
+window.location.href = "http://1.wepolicy.cn/whlabel/uck?excel=1";
+});
+$(".whlabelexcelzh").click(function() {
+window.location.href = "http://1.wepolicy.cn/whlabel/whlabelexcelzh?excel=1";
+});
+$(".plszbhtype").click(function() {
+            $(".systemwindow").show();
+});
+$(".systemwindow .esc").click(function() {
+	$(".systemwindow").hide();
+	});
+$(".systemwindow .button").click(function() {
+var n = $(".systemwindow select").find("option:selected").val();
+var a = "";
+    $(".datatext input[name='check']:checked").each(function() {
+        a = a + $(this).val()+",";
+    });
+$(".systemwindow").hide();
+	layx.load('loadId','操作中,请稍后',{shadable:0.6});
+     $.ajax({
+        url: "/whlabel/gbhtype",
+        data: "s="+a+"&n="+n,
+        type: "POST",
+        dataType: "json",
+        success: function(a) {
+			layx.destroy('loadId');
+            if (a && a.success) {
+			layx.alert('正确',a.msg,function(id,button){
+			$.each(a.d,function(f,b){ $("#"+b).find("td:eq(8)").text(a.t)});
+},{dialogIcon:'success'});
+            }
+			else
+			{
+				 layx.alert('错误',a.msg,function(id,button){
+},{dialogIcon:'error'});
+			}
+        }
+    });
+	});
+
+
+$("select[name=whlabeltype]").change(function(){
+	$(".systemwindow p:eq(1)").html($(this).children("option:selected").data("content"));
+});
+
+$(".dccrtype").click(function() {
+    var f = "";
+	var a = "";
+    $(".datatext input[name='check']:checked").each(function() {
+        a = a + $(this).val()+",";
+    });
+	f = f + "sid=" + a + "&";
+    $(".select").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
+    });
+    $("input:text").each(function() {
+		
+		var str = $(this).val().replace(/\#/g,"%23");
+        f = f + $(this).attr("name") + "=" + str + "&";
+    });
+	$("input:hidden").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+	window.location.href = excel+"dccrtype?"+f;
+});
+</script>
+<script src="{$theme}js/excel/xlxs.js"></script>
+<script>
+    $(document).ready(function(){
+        $('.select_two').select2({
+                placeholder: "请选择",
+                allowClear: true,
+                //tags: true // 允许输入新值
+            });
+       searchspan(1);
+    })
+
+    $("select[name=dccz]").change(function(){
+        if($(this).find("option:selected").val() == "")
+        {
+            $(".ts p").html("请选择导出模板");
+                    $(".ts").fadeIn();
+                    setTimeout('$(".ts").fadeOut()', 800);
+                    return false;
+        }
+        var f = "";
+        $(".select").each(function() {
+            f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
+        });
+        $("input:text").each(function() {
+            f = f + $(this).attr("name") + "=" + encodeURIComponent($(this).val()) + "&";
+        });
+        $("input:hidden").each(function() {
+            f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+        });
+        layx.load('loadId','导出中,请稍后',{shadable:0.6});
+        let url = "/whlabel/"+$("select[name=dccz]").find("option:selected").data("url")+"js?excel="+$("select[name=dccz]").find("option:selected").val()+"&"+f;
+        $("select[name=dccz] option:eq(0)").prop('selected','selected');
+        $.get(url,{},function(res){
+            if(res.code == 1){
+                importRukuData(res.data,res.title)
+            }else{
+
+            }
+        },'json')
+        
+    });
+    //导出入库数据
+    function importRukuData(data,title){
+        const fileName = title+'.xlsx' ;
+        // 将数据转换为工作表
+
+        // 创建工作表
+        const worksheet = XLSX.utils.aoa_to_sheet(data);
+
+        // 定义合并区域
+        const merges = [
+            // 合并标题行 (A1:F1)
+            { s: { r: 0, c: 0 }, e: { r: 0, c: 4 } },
+        ];
+        worksheet['!cols'] = 
+        [
+            { wch: 15 }, 
+            { wch: 20 },  
+            { wch: 20 },  
+            { wch: 10 },  
+            { wch: 10 },  
+        ];
+
+        // 应用合并
+        worksheet["!merges"] = merges;
+
+        // 设置标题样式(仅在Excel中可见)
+        worksheet.A1.s = {
+                font: { sz: 20, name: "微软雅黑", bold: true },
+                alignment: { horizontal: "center" }
+        };
+        // 创建工作簿
+        const workbook = XLSX.utils.book_new();
+        XLSX.utils.book_append_sheet(workbook, worksheet, title);
+        
+        // 导出文件
+        XLSX.writeFile(workbook, fileName);
+        
+        alert('合并报表已导出为 :'+fileName)
+
+
+        return ;
+    
+       
+
+        // 将工作表添加到工作簿
+        XLSX.utils.book_append_sheet(workbook, worksheet, res.filename);
+        
+        // 导出文件
+        XLSX.writeFile(workbook, fileName);
+        layx.destroy('loadId');
+    }
+    
+</script>
+<script type="text/javascript" src="{$theme}js/laydate.js"></script>
+<div style="display:none;">
+<input id="upload-file" name="files" accept="image/xls,image/xlsx" type="file">
+</div>
+{Template footer}