lvhao 1 tydzień temu
rodzic
commit
b2ac594a56

+ 60 - 1
core/CoreApp/controllers/Fullorderabf.php

@@ -9,7 +9,7 @@ class Fullorderabf extends Start_Controller {
 		$this->load->_model('Model_fullorder','fullorder');
 		$this->load->_model('Model_shop','shop');
 		$this->load->_model('Model_express','express');
-			$this->load->_model('Model_country','country');
+		$this->load->_model('Model_country','country');
 		$this->load->_model('Model_typeclass','typeclass');
 		$this->load->_model('Model_pay','pay');
 		$this->load->_model('Model_logic_order','logic_order');
@@ -18,6 +18,8 @@ class Fullorderabf extends Start_Controller {
 		$this->load->_model('Model_specialstock','specialstock');
 		$this->load->_model('Model_whlabel','whlabel');
 		$this->load->_model('Model_customer','customer');
+		$this->load->_model('Model_goods','goods');
+		$this->load->_model("Model_logic_zhlp","logic_zhlp");
 	}
     //定义方法的调用规则 获取URI第二段值
   public function _remap($arg,$arg_array)
@@ -27,6 +29,8 @@ class Fullorderabf extends Start_Controller {
              $this->_addOrder();
         }elseif($arg == 'yhtj_kh'){
 			$this->_addOrder_kh($arg_array);
+		}elseif($arg == 'batchhetgood'){
+			$this->_batchhetgood();
 		}
 		else
 		{
@@ -844,4 +848,59 @@ class Fullorderabf extends Start_Controller {
 		$this->_Template('fullorderabf_yjtj',$this->data);
 
   }
+
+  public function _batchhetgood(){
+	if($this->input->method() === 'post'){
+	   // 获取原始数据流(字符串)
+	   $raw_data = $this->input->raw_input_stream;
+
+	   // 如果你知道是 JSON 数据,可以将其解码为数组
+	   $jsonn_data = json_decode($this->input->raw_input_stream, true);
+		
+
+       $params = $jsonn_data['list'];
+	   $list = [];
+	   $err_list = [];
+	   foreach($params as $k=>$v){
+		   if(empty($v[0])){
+  				$err_list[] = ['msg'=>($k+1)."行的信息不存在"] ;
+			   continue;
+		   }
+		   if(empty($v[1])){
+  				$err_list[] = ['msg'=>($k+1)."行的数量不存在"];
+			   continue;
+		   }
+		   $str = "( (sku = '{$v[0]}') or (jm = '{$v[0]}')  )";
+		   $info = $this->goods->find($str);
+		   if(empty($info)){
+			   $err_list[] = ['msg'=>$v[0]."不存在"];
+			   continue;
+		   }else{
+			   $list[] = [
+					'features'=>$info['features'],
+					'title'=>$info['title'],
+					'sku'=>$info['sku'],
+					'jm'=>$info['jm'],
+					'zh'=>$info['zh'],
+					'fpdata'=>'',
+					'num'=>$v['1'],
+			   ];
+		   }
+	   }
+	  
+	   if(!empty($list)){
+			$size_list= $this->typeclass->find_all("classid = '14' ");
+			$size_list_ids = array_column($size_list,'id');
+			foreach($list as $k=>$v){
+				$tmp_fpdata = $this->logic_zhlp->featureTransfer($size_list_ids,$v['features']);
+				$list[$k]['fpdata'] = $tmp_fpdata;
+			}
+			echo json_encode(array('msg'=>'获取成功','list'=>$list,'error_list'=>$err_list,'success'=>true));exit;
+	   }else{
+ 			echo json_encode(array('msg'=>'数据不存在','error_list'=>$err_list,'success'=>false));exit;
+	   }
+	}else{
+       echo json_encode(array('msg'=>'非法请求','success'=>false));exit;
+	}
+  }
 }

+ 15 - 14
core/CoreApp/controllers/Whlabeltransport.php

@@ -482,24 +482,25 @@ class Whlabeltransport extends Start_Controller {
 				    $this->whlabel->insert($label);
 			    }
 				$this->whlabeltransport->save(array('time'=>$time,'cz'=>1),$data['id']);
-				$num = $this->whlabeltransport->find_count("order_no = '".$data['order_no']."' and cz = 0");
-				if($num == 0){
-					if(!empty($data['order_no'])){
-						$this->zzquque_u9->insert( [
-							'platform'=>'',
-							'warehouse'=>0,
-							'type'=>2,   //将在途库存调入到美仓
-							'order_no'=>$data['order_no'],
-							'status'=>0,
-							'create_time'=>time(),
-							'update_time'=>time(),
-						]);
-					}
-				}
+				
 
 				if ($this->db->trans_status() === TRUE)
         		{
 					$this->db->trans_commit();
+					$num = $this->whlabeltransport->find_count("order_no = '".$data['order_no']."' and cz = 0");
+					if($num == 0){
+						if(!empty($data['order_no'])){
+							$this->zzquque_u9->insert( [
+								'platform'=>'',
+								'warehouse'=>0,
+								'type'=>2,   //将在途库存调入到美仓
+								'order_no'=>$data['order_no'],
+								'status'=>0,
+								'create_time'=>time(),
+								'update_time'=>time(),
+							]);
+						}
+					}
 					echo json_encode(array('msg'=>'入库成功!','id'=>$id,'time'=>date('Y-m-d H:i:s',$time),'success'=>true));exit;
 				}
 				else

+ 10 - 1
template/erp/customer_mdedit.html

@@ -21,6 +21,8 @@
 {if $user == 'admin' || $user == 'PIFA'}
 <a href="javascript:void(0);" class="window2" data-h="/specialstock/order" data-t="库存选择">库存选择</a>
 {/if}
+<a href="/data/excelmoban/batchu9jm.xlsx">料品导入模板</a>
+<a href="javascript:void(0);" class="batchu9jm">料品导入</a>
 </div>
 <table class="datatitle data" border="0" style="border-collapse:collapse;">
 <tr>
@@ -422,6 +424,9 @@
 
 <div class="none fullorderdata"></div>
 <div class="zm none"></div>
+<div style="display:none;">
+<input id="upload-file" name="files" accept="image/xls,image/xlsx" type="file">
+</div>
 <script type="text/javascript">
 var addedit="/customer/mdedit/";
 var fh="/fullorder";
@@ -556,5 +561,9 @@ $("#is_jiaji_id").on('change',function(){
 });
 </script>
 <script type="text/javascript" src="{$theme}js/time.js"></script>
-<script src="{$theme}js/fullorder-addedit.js?v=202309060001"></script>
+<script src="{$theme}js/fullorder-addedit.js?v=2023090600021"></script>
+
+<script type="text/javascript" src="{$theme}js/fullorder_addeditbc.js" ></script>
+
+<script type="text/javascript" src="{$theme}js/excel/xlxs.js" ></script>
 {Template footer}

+ 8 - 3
template/erp/fullorderabf_yjtj.html

@@ -18,9 +18,9 @@
 <a href="javascript:void(0);" class="exptj">添 加</a>
 <a href="javascript:void(0);" class="expxg">修 改</a>
 <a href="javascript:void(0);" class="expsc">删 除</a>
-{if $user == 'admin' || $user == 'PIFA'}
-<!-- <a href="javascript:void(0);" class="window2" data-h="/specialstock/order" data-t="库存选择">库存选择</a> -->
-{/if}
+
+<a href="/data/excelmoban/batchu9jm.xlsx">料品导入模板</a>
+<a href="javascript:void(0);" class="batchu9jm">料品导入</a>
 </div>
 <table class="datatitle data" border="0" style="border-collapse:collapse;">
 <tr>
@@ -422,6 +422,9 @@
 
 <div class="none fullorderdata"></div>
 <div class="zm none"></div>
+<div style="display:none;">
+<input id="upload-file" name="files" accept="image/xls,image/xlsx" type="file">
+</div>
 <script type="text/javascript">
 var addedit="/fullorderabf/yjtj/";
 var fh="/fullorder";
@@ -557,4 +560,6 @@ $("#is_jiaji_id").on('change',function(){
 </script>
 <script type="text/javascript" src="{$theme}js/time.js"></script>
 <script src="{$theme}js/fullorder-addedit.js?v=202309060"></script>
+<script type="text/javascript" src="{$theme}js/fullorder_addeditbc.js" ></script>
+<script type="text/javascript" src="{$theme}js/excel/xlxs.js" ></script>
 {Template footer}

+ 193 - 0
template/erp/js/fullorder_addeditbc.js

@@ -0,0 +1,193 @@
+$(".batchu9jm").click(function() {
+    var dr = $(this);
+    $("#upload-file").click();
+    $("#upload-file").unbind("change");
+    $("#upload-file").bind("change",function(){
+        excel_parsing(dr);
+        layx.load('loadId','导入中,请稍后',{shadable:0.6});
+    });
+});
+function excel_parsing(dr){
+    var file = document.getElementById("upload-file").files[0];
+    if (!file) return;
+
+    // 显示加载提示
+    //layx.load('loadId', '解析 Excel 中,请稍后', { shadable: 0.6 });
+
+    // 使用 FileReader 读取文件
+    var reader = new FileReader();
+    reader.onload = function(e) {
+        var data = e.target.result;
+        try {
+            // 使用 SheetJS 解析 Excel 为 JSON
+            var workbook = XLSX.read(data, { type: 'array' });
+            var sheetName = workbook.SheetNames[0]; // 取第一个工作表
+            var worksheet = workbook.Sheets[sheetName];
+            var jsonData = XLSX.utils.sheet_to_json(worksheet, { header:1,defval: "" });
+            jsonData.shift(); // 去掉第一行表头
+            
+            // 构建要上传的数据(可以包含文件名、sheet名等)
+            // var uploadData = {
+            //     fileName: file.name,
+            //     sheetName: sheetName,
+            //     data: jsonData   // 解析后的 JSON 数组
+            // };
+            // 通过 AJAX 上传 JSON 数据
+            document.getElementById("upload-file").files[0] = '';
+            //return console.log(jsonData); // 输出解析后的 JSON 数据
+
+            $.ajax({
+                url: '/fullorderabf/batchhetgood' ,  // 注意:后端接口可能需要改为接收 JSON
+                type: "POST",
+                contentType: "application/json", // 发送 JSON 格式
+                data:JSON.stringify({
+                    list:jsonData
+                }),
+                dataType: "json",
+                success: function(a) {
+                    layx.destroy('loadId');
+
+                    if(a.hasOwnProperty('list')){
+                        addGoodList(a.list)
+                    }
+
+                    if(a.hasOwnProperty('error_list')){
+                        layx.confirm(a.msg,'是否下载错误列表?',null,{
+                            buttons:[
+                                {
+                                    label:'确定',
+                                    callback:function(id, button, event){
+                                        layx.destroy(id);
+                                        downloadErrorList(a.error_list)
+                                        $(".search span").click();
+                                    }
+                                },
+                                {
+                                    label:'取消',
+                                    callback:function(id, button, event){
+                                        layx.destroy(id);
+                                    }
+                                }
+                            ],dialogIcon:'success',shadable:0.6
+                        });
+                    }else{
+                        if(a.success){
+                            layx.confirm('消息提示',a.msg,null,{
+                                buttons:[
+                                    {
+                                        label:'确定',
+                                        callback:function(id, button, event){
+                                            layx.destroy(id);
+                                            $(".search span").click();
+                                        }
+                                    }
+                                ],dialogIcon:'success',shadable:0.6
+                            });
+                        }else{
+                            layx.confirm('错误提示',a.msg,null,{
+                                buttons:[
+                                    {
+                                        label:'确定',
+                                        callback:function(id, button, event){
+                                            layx.destroy(id);
+                                        }
+                                    }
+                                ],dialogIcon:'error',shadable:0.6
+                            });
+                        }
+                    }
+                },
+                error: function(xhr, status, error) {
+                    layx.destroy('loadId');
+                    console.error("上传失败:", error);
+                    errorc({ success: false, message: "上传失败" });
+                }
+            });
+
+            
+        } catch (err) {
+            layx.destroy('loadId');
+            console.error("解析 Excel 失败:", err);
+            errorc({ success: false, message: "解析 Excel 文件失败" });
+        }
+    };
+    reader.onerror = function() {
+        layx.destroy('loadId');
+        errorc({ success: false, message: "文件读取失败" });
+    };
+    reader.readAsArrayBuffer(file); // 以 ArrayBuffer 读取
+}
+function downloadErrorList(error_list){
+    let  sheet = XLSX.utils.json_to_sheet(error_list)
+
+    
+    sheet['!cols'] = [
+            //订单号
+            {
+                 wch:80,
+            },
+  
+        ];
+
+
+    let workbook = XLSX.utils.book_new();
+    
+    XLSX.utils.book_append_sheet(workbook, sheet, "Sheet1");
+    XLSX.writeFile(workbook, "错误列表.xlsx");
+}
+
+function addGoodList(list){
+    let str = ''
+    for(let i=0;i<list.length;i++){
+        doAddGoodList(list[i].fpdata,list[i].title,list[i].num,0);
+    }
+   
+
+    //$(".datatext",window.parent.document).append("<tr data-list='"+f+"'><td>"+e+"</td><td>"+ts+"</td><td class='none'>"+(dj).toFixed(2)+"</td><td class='none'>"+(ts*dj).toFixed(2)+"</td><td class='none'>CNY</td><td class='none'>"+inch.replace("inch","")+"</td><td class='none'>"+(ts*purchasemy).toFixed(2)+"</td><td class='none'>"+(ts*costmy).toFixed(2)+"</td><td class='none'>"+(ts*weight)+"</td><td class='none val9'>0</td><td></td><td><font class='jzzd'>禁止占单</font></td></tr>");
+}
+function doAddGoodList(f,title,ts,weight = 0){
+    var x = 0
+    $(".datatext tr", window.parent.document).each(function() {
+        if ($(this).data("list") == f) {
+            x++;
+        }
+    });
+    if (x > 0) {
+        $(".ts p").text("已有相同信息!");
+        $(".ts").show();
+        setTimeout('$(".ts").fadeOut()', 1700);
+        return false;
+    } else {
+        var dj = $(".exp input[name='money']").val() * 1;
+        var purchasemy = $(".exp .purchase").text() * 1;
+        var costmy = $(".exp .cost").text() * 1;
+        var index = $(".cike select").find("option:selected").index();
+        var inch = $(".datalist .checkbox .ckrows input:checked").next("font").text(); //针对单选尺寸,多选需要修改
+
+        //xyxg 删除这个
+       
+        if ($("input[name='mdedit']").length > 0) //线下单操作界面
+        {
+            $(".datatext").append("<tr data-list='" + f + "'><td>" + title + "</td><td>" + ts +
+                "</td><td class='none'>" + (dj).toFixed(2) + "</td><td class='none'>" + (ts * dj).toFixed(2) +
+                "</td><td class='none'>CNY</td><td class='none'>" + inch.replace("inch", "") +
+                "</td><td class='none'>" + (ts * purchasemy).toFixed(2) + "</td><td class='none'>" + (ts * costmy)
+                .toFixed(2) + "</td><td class='none'>" + (ts * weight) +
+                "</td><td class='none val9'>0</td><td><font class='jzzd'>禁止占单</font></td></tr>");
+        } else {
+            $(".datatext").append("<tr data-list='" + f + "'><td>" + title + "</td><td>" + ts +
+                "</td><td class='none'>" + (dj).toFixed(2) + "</td><td class='none'>" + (ts * dj).toFixed(2) +
+                "</td><td class='none'>CNY</td><td class='none'>" + inch.replace("inch", "") +
+                "</td><td class='none'>" + (ts * purchasemy).toFixed(2) + "</td><td class='none'>" + (ts * costmy)
+                .toFixed(2) + "</td><td class='none'>" + (ts * weight) +
+                "</td><td class='none val9'>0</td><td></td><td><font class='jzzd'>禁止占单</font></td></tr>");
+        }
+
+    }
+    //$("input[name='shouldmoney']").val(($("input[name='shouldmoney']").val()*1+(sl*dj)).toFixed(2));//应收价格加上新增价格
+    //et();
+    cost(); //计算成本价
+    window.parent.custom();
+    choicegb();
+    pptskc("a"); //匹配特殊库存
+}