lvhao 8 ore fa
parent
commit
54ec3d707c

+ 64 - 0
core/CoreApp/controllers/Goodimglibrary.php

@@ -34,6 +34,8 @@ class Goodimglibrary extends Start_Controller {
             $this->_selectgood();
         }elseif($arg == 'getgoodbyids'){
             $this->_getgoodbyids();
+        }elseif($arg == 'excelgood'){
+            $this->_excelgood();
         }else{
 			$this->_index();
 		}
@@ -803,4 +805,66 @@ class Goodimglibrary extends Start_Controller {
             echo json_encode(['success'=>false,'msg'=>'查询失败']);exit;
         }
     }
+    private function _excelgood(){
+        if($this->input->method() == 'post'){
+            $params = $this->input->post(null,true);
+            $this->db->select('features, title, sku, zh, jm');
+            $this->db->from('crowd_goods');
+            if(!empty($params['category'])){
+                $this->db->like('features',$params['category']);
+            }
+            if(!empty($params['color'])){
+                $this->db->like('features',$params['color']);
+            }
+            if(!empty($params['density'])){
+                $this->db->like('features',$params['density']);
+            }
+            if(!empty($params['grade'])){
+                $this->db->like('features',$params['grade']);
+            }
+            if(!empty($params['haircap'])){
+                $this->db->like('features',$params['haircap']);
+            }
+            if(!empty($params['lacecolor'])){
+                $this->db->like('features',$params['lacecolor']);
+            }
+            if(!empty($params['lacetype'])){
+                $this->db->like('features',$params['lacetype']);
+            }
+            if(!empty($params['lowe'])){
+                $this->db->like('features',$params['lowe']);
+            }
+            if(!empty($params['size'])){
+                $this->db->like('features',$params['size']);
+            }
+            if(!empty($params['zh'])){
+                $this->db->like('zh',$params['zh']);
+            }
+            if(!empty($params['sku'])){
+                $this->db->like('sku',$params['sku']);
+            }
+            if(!empty($params['title'])){
+                $this->db->like('title',$params['title']);
+            }
+    
+            $query = $this->db->get();
+            $list =  $query->result_array();
+            if(empty($list)){
+                echo json_encode(['success'=>false,'msg'=>'没有数据']);exit;
+            }else{
+                $final_list = [];
+                foreach($list as $k => $v){
+                    $final_list[] = [
+                        'u9料号'=>$v['jm'],
+                        '仓库品名'=>$v['zh'],
+                        '英文名字'=>$v['title'],
+                        'SKU'=>$v['sku'],
+                    ];
+                }
+                echo json_encode(['success'=>true,'msg'=>'查询成功','data'=>$final_list]);exit;
+            }
+        }else{
+            echo json_encode(['success'=>false,'msg'=>'请求不合法']);exit;
+        }
+    }
 }

+ 57 - 0
template/erp/goodimglibrary_noimg.html

@@ -59,6 +59,7 @@
 {if (in_array($user_id,[10,28]))}
 <div class="control">
   <a href="javascript:void(0);" class="window" data-h="/goodimglibrary/add/" data-t="添加">添加</a>
+  <a href="javascript:void(0);"  onclick="goodexcel()">excel导出</a>
 </div>
 {/if}
 <table class="datatitle data" border="0" style="border-collapse:collapse;">
@@ -129,5 +130,61 @@ function fuzhi(that){
         $input.remove();
     }
 }
+function goodexcel(){
+    let obj = {}
+    $(".search select").each(function() {
+        let name = $(this).attr('name');
+        let val = $(this).val();
+        if (val) {
+            obj[name] = val;
+        }
+    });
+    $(".search input").each(function() {
+        let name = $(this).attr('name');
+        let val = $(this).val();
+        if (val) {
+            obj[name] = val;
+        }
+    });
+    
+    $.post("/goodimglibrary/excelgood",obj,function(res){
+        if(res.success){
+            downloadexcel(res.data)
+        }else{
+            layx.alert('提示', res.msg, function(id, button) {
+							
+			}, { dialogIcon: 'error' });
+        }
+    },'json')
+}
+function downloadexcel(data){
+    let  sheet = XLSX.utils.json_to_sheet(data)
+
+    sheet['!cols'] = [
+            //订单号
+            {
+                wch:60,
+            },
+            //订单编码
+            {
+                wch:80,
+            },
+            //店铺名称
+            {
+                wch:80,
+            },
+            //状态
+            {
+                wch:80,
+            },
+    ];
+
+
+    let workbook = XLSX.utils.book_new();
+
+    XLSX.utils.book_append_sheet(workbook, sheet, "Sheet1");
+    XLSX.writeFile(workbook, "goodimglibrary.xlsx");
+}
 </script>
+<script type="text/javascript" src="{$theme}js/excel/xlxswidth.js"></script>
 {Template footer}