Browse Source

first commit

liuhairui 6 tháng trước cách đây
mục cha
commit
c165f60844

+ 118 - 23
Application/Admin/Controller/NewQcodeController.class.php

@@ -426,7 +426,7 @@ class  NewQcodeController extends AddonController
 
     public function GetSmallLabelApi(){//获取关联大标签的的小标签列表
         if(I('get.large_id')){//获取小标签列表
-            $field="id,code,code_cp1,status,l_flow,p_nums";
+            $field="id,code,code_cp1,status,l_flow,p_nums,l_flow as l_flows";
             $smalllist=M('qcode_small')
                 ->field($field)
                 ->where('large_id='.I('get.large_id'))
@@ -628,7 +628,10 @@ class  NewQcodeController extends AddonController
                         ->join("qr_qcode_large c on b.large_id=c.id")
                         ->join('qr_qcode_bach d on d.id=c.bach_id')
                         ->field('b.*,d.s_weight,d.id as bath_id,d.supplier_name,d.matter_name, d.matter_no, d.matter_size,d.num,d.manufacture_date,d.l_flow as dl_flow, b.l_flow,c.code as ccode,  c.code_cp1 as banhao,d.box_num,d.bach_num')
-                        ->where('b.large_id='.$val)
+                        ->where([
+                            'b.large_id' => $val,
+                            'b.status' => 0
+                        ])
                         ->select();
                 }
                 //$sql=M('qcode_small')->getLastSql();
@@ -733,34 +736,126 @@ class  NewQcodeController extends AddonController
          $this->ajaxReturn($data);*/
     }
 
-    public function  changestatus(){//动态改变小标签的状态
-        $data['status']=I('get.status');
-        if(M('qcode_small')->where('id='.I('get.id'))->save($data)){
-            $bach_id=M('qcode_large')->field('bach_id')->where('id='.I('get.large_id'))->find();//获取批次id
-            $small_num=M('qcode_bach')->field('small_num')->where('id='.$bach_id['bach_id'])->find();//获取批次原有的小标签数量
-            if(I('get.status')=='0'){
-                //表示已删除的标签变为正常,批次小件数量加一
-                $infos['small_num']=$small_num['small_num']+1;
-                M('qcode_bach')->where('id='.$bach_id['bach_id'])->save($infos);//更新批次的小标签数量
-                // echo M('qcode_bach')->getLastSql();
+//    public function  changestatus(){//动态改变小标签的状态
+//        $data['status']=I('get.status');
+//
+//        if(M('qcode_small')->where('id='.I('get.id'))->save($data)){
+//            $bach_id=M('qcode_large')->field('bach_id')->where('id='.I('get.large_id'))->find();//获取批次id
+//            $small_num=M('qcode_bach')->field('small_num')->where('id='.$bach_id['bach_id'])->find();//获取批次原有的小标签数量
+//            if(I('get.status')=='0'){
+//                //表示已删除的标签变为正常,批次小件数量加一
+//                $infos['small_num']=$small_num['small_num']+1;
+//                M('qcode_bach')->where('id='.$bach_id['bach_id'])->save($infos);//更新批次的小标签数量
+//                // echo M('qcode_bach')->getLastSql();
+//            }
+//            if(I('get.status')=='1'){
+//                //表示正常的标签变为已删除,批次小件数量减一
+//                $infos['small_num']=$small_num['small_num']-1;
+//                M('qcode_bach')->where('id='.$bach_id['bach_id'])->save($infos);//更新批次的小标签数量
+//                //echo M('qcode_bach')->getLastSql();
+//            }
+//            $info['code']=200;
+//            $info['error']="操作成功";
+//        }else{
+//            $info['code']=100;
+//            $info['error']="操作失败";
+//        };
+//
+//        $this->ajaxReturn($info);
+//    }
+
+
+    public function changestatus() {
+        // 获取参数并打印
+        $status = I('get.status');
+        $id = I('get.id');
+        $large_id = I('get.large_id');
+        $data['status'] = $status;
+
+        if (M('qcode_small')->where('id=' . $id)->save($data)) {
+            // 获取批次ID
+            $bach_id = M('qcode_large')->field('bach_id')->where('id=' . $large_id)->find();
+
+            if (!$bach_id) {
+                $info['code'] = 100;
+                $info['error'] = "操作失败,批次信息未找到";
+                $this->ajaxReturn($info);
             }
-            if(I('get.status')=='1'){
-                //表示正常的标签变为已删除,批次小件数量减一
-                $infos['small_num']=$small_num['small_num']-1;
-                M('qcode_bach')->where('id='.$bach_id['bach_id'])->save($infos);//更新批次的小标签数量
-                //echo M('qcode_bach')->getLastSql();
+
+            // 获取小标签数量
+            $small_num = M('qcode_bach')->field('small_num')->where('id=' . $bach_id['bach_id'])->find();
+
+            if ($status == '0') {
+                // 标签变为正常,批次小件数量加1
+                $infos['small_num'] = $small_num['small_num'] + 1;
+            } else if ($status == '1') {
+                // 标签变为已删除,批次小件数量减1
+                $infos['small_num'] = $small_num['small_num'] - 1;
             }
-            $info['code']=200;
-            $info['error']="操作成功";
-        }else{
-            $info['code']=100;
-            $info['error']="操作失败";
-        };
 
+            // 更新批次的小标签数量
+            M('qcode_bach')->where('id=' . $bach_id['bach_id'])->save($infos);
+
+            // 返回成功信息
+            $info['code'] = 200;
+            $info['error'] = "操作成功";
+        } else {
+            // 如果保存失败,返回失败信息
+            $info['code'] = 100;
+            $info['error'] = "操作失败";
+        }
+
+        // 返回响应
         $this->ajaxReturn($info);
     }
 
 
+    public function batchChangeStatus() {
+        $large_id = I('post.large_id');
+        $to_deleted = explode(',', I('post.to_set_deleted')); // 需要设为已删除 status = 1
+        $to_normal = explode(',', I('post.to_set_normal'));   // 需要设为正常 status = 0
+
+        $success_count = 0;
+
+        // 获取批次ID
+        $bach = M('qcode_large')->field('bach_id')->find($large_id);
+//        if (!$bach) {
+//            $this->ajaxReturn(['code' => 100, 'error' => '未找到对应批次']);
+//        }
+        $bach_id = $bach['bach_id'];
+
+        // 获取当前small_num
+        $current = M('qcode_bach')->field('small_num')->find($bach_id);
+        $small_num = intval($current['small_num']);
+
+        // 批量设为已删除(status=1)
+        if (!empty($to_deleted)) {
+            $delete_count = M('qcode_small')
+                ->where(['id' => ['in', $to_deleted], 'status' => 0])
+                ->save(['status' => 1]);
+            $success_count += intval($delete_count);
+            $small_num -= intval($delete_count); // 减少数量
+        }
+
+        // 批量恢复为正常(status=0)
+        if (!empty($to_normal)) {
+            $recover_count = M('qcode_small')
+                ->where(['id' => ['in', $to_normal], 'status' => 1])
+                ->save(['status' => 0]);
+            $success_count += intval($recover_count);
+            $small_num += intval($recover_count); // 增加数量
+        }
+
+        // 更新批次数量
+        M('qcode_bach')->where(['id' => $bach_id])->save(['small_num' => $small_num]);
+
+        $this->ajaxReturn([
+            'code' => 200,
+            'msg' => '批量处理完成',
+            'success' => $success_count
+        ]);
+    }
+
 
 
 }

+ 1 - 1
Application/Admin/View/NewQcode/index.html

@@ -179,7 +179,7 @@
         <input name="userid" id="userid" value="{$session_config[uid]}" type="hidden">
         <eq name="session_config.addtype" value="1">
             <fieldset class="newlabel">
-                <legend style="width:auto;margin-left:20px;">生成厂商信</legend>
+                <legend style="width:auto;margin-left:20px;">生成厂商信</legend>
                 <ul class="firm">
                     <li>
                         <ul>

+ 207 - 42
Application/Admin/View/Qcode/budadetail.html

@@ -149,6 +149,15 @@
 			<!--<a id="tccs">弹窗测试</a>-->
 			<div id="win" class="easyui-window" title="小标签列表" style="padding:10px;width:988px;height:500px;display:none;" data-options="resizable:false,closed:true,modal:true">
 				<div style="margin:5px auto;">小标签代码:<input name="small_label_enter" value="" type="num" style="width:85%;"  id="small_label_enter"></div>
+				<div style="margin:5px auto;">
+					批量选中:
+					从:
+					<input name="small_start" value="" type="text" style="width:10%;" id="small_start">
+					到
+					<input name="small_end" value="" type="text" style="width:10%;" id="small_end">
+					<button id="btn_yes">导出</button>
+					<button id="btn_no">不导出</button>
+				</div>
 				<table  id=supTgGridS width="100%" border="1" cellspacing="0" cellpadding="0">
 				</table>
 			</div>
@@ -507,6 +516,102 @@
 
         });
 
+		let currentRowData = null; // 当前大标签行数据
+		let bt_is_load = true;
+
+		function updateSmallLabelStatusInView(id, status) {
+			$('#supTgGridS tr[data-id]').each(function () {
+				const rowId = $(this).attr('data-id'); // 直接从属性取
+				if (rowId == id) {
+					const statusTd = $(this).find('td').eq(3); // 状态列现在是第 4 列
+					if (status == 1) {
+						statusTd.text("已删除").css("color", "red");
+					} else {
+						statusTd.text("正常").css("color", "green");
+					}
+				}
+			});
+		}
+
+		//批量状态更新函数(通用)
+		function batchUpdateLabels(start, end, mode) {
+			if (isNaN(start) || isNaN(end)) {
+				alert("请输入正确的序号范围");
+				return;
+			}
+
+			let to_set_deleted = []; // 设为已删除(status=1)
+			let to_set_normal = [];  // 设为正常(status=0)
+			let large_id = $('#large_id').val();
+
+			$('#supTgGridS tr[data-id]').each(function () {
+				const seq = parseInt($(this).find('td').eq(0).text()); // 现在的第1列是序号
+				const id = $(this).attr('data-id'); // ✅ 用 data-id 来定位ID
+
+				if (mode === 'noexport') {
+					if (seq >= start && seq <= end) {
+						to_set_deleted.push(id);
+					} else {
+						to_set_normal.push(id);
+					}
+				} else if (mode === 'export') {
+					if (seq >= start && seq <= end) {
+						to_set_normal.push(id);
+					} else {
+						to_set_deleted.push(id);
+					}
+				}
+			});
+
+			console.log("🔴 设为已删除(status=1)ID:", to_set_deleted);
+			console.log("🟢 设为正常(status=0)ID:", to_set_normal);
+
+			$.messager.progress({ title: '提示', msg: '正在批量更新状态,请稍候...' });
+
+			$.ajax({
+				url: "index.php?s=/Admin/NewQcode/batchChangeStatus",
+				type: "post",
+				dataType: "json",
+				data: {
+					large_id: large_id,
+					to_set_deleted: to_set_deleted.join(","),
+					to_set_normal: to_set_normal.join(",")
+				},
+				success: function (res) {
+					$.messager.progress('close');
+					if (res.code === 200) {
+						const msg = (mode === 'export') ? '批量“导出”完成' : '批量“不导出”完成';
+						$.messager.alert('系统提示', msg, 'info');
+
+						// ✅ 成功后,直接更新页面显示的状态
+						to_set_deleted.forEach(id => updateSmallLabelStatusInView(id, 1));
+						to_set_normal.forEach(id => updateSmallLabelStatusInView(id, 0));
+
+					} else {
+						$.messager.alert('系统提示', '处理失败:' + res.error, 'error');
+					}
+				},
+				error: function (err) {
+					$.messager.progress('close');
+					$.messager.alert('系统提示', '网络错误,批量处理失败!', 'error');
+				}
+			});
+		}
+
+		//导出按钮:范围内设为已删除,范围外设为正常
+		$('#btn_yes').on('click', function () {
+			const start = parseInt($('#small_start').val());
+			const end = parseInt($('#small_end').val());
+			batchUpdateLabels(start, end, 'export');
+		});
+
+		//不导出按钮:范围内设为正常,范围外设为已删除
+		$('#btn_no').on('click', function () {
+			const start = parseInt($('#small_start').val());
+			const end = parseInt($('#small_end').val());
+			batchUpdateLabels(start, end, 'noexport');
+		});
+
         supTgGrid = $('#supTgGrid').datagrid({
             url: 'index.php?s=/Admin/NewQcode/GetLargeLabelApi',
             method: 'get',
@@ -582,7 +687,8 @@
                         success: function (data) {
                             //console.log(data);
                             var result = "<tr style='background: #f5f5f5;'>" +
-                                "<td width='60%' align='center'>标签代码</td>" +
+                                "<td width='8%' align='center'>序号</td>" +
+                                "<td width='52%' align='center'>标签代码</td>" +
                                 "<td width='8%' align='center'>当前序号</td>" +
                                 "<td width='8%' align='center'>标签状态</td>" +
                                 "<td width='8%' align='center'>打印次数</td>" +
@@ -597,7 +703,8 @@
                                     tip = "已删除"
                                     color = "red";
                                 }
-                                result += "<tr data_id='" + index + "'>" +
+								result += "<tr data-id='" + item.id + "'>" +
+									"<td align='center' >" + item.l_flows + "</td>" +
                                     "<td >" + item.code + "</td>" +
                                     "<td align='center' >" + item.l_flow+ "</td>" +
                                     "<td align='center' style='color:" + color + "'>" + tip + "</td>" +
@@ -1873,48 +1980,106 @@
 
 		$('#reptWin3').window('close');
 	}
-    function yes(id,large_id){
-        //alert(id,large_id);
-        //修改对应的小标签的状态为正常
-        $.ajax({
-            url:"index.php?s=/Admin/NewQcode/changestatus",
-            data:"large_id="+large_id+"&status=0&id="+id,
-            type:"get",
-            dataType:'json',
-            success:function(data){
-                console.log(data);
-                if(data.info){
-                    $.messager.alert('系统提示', data.info, 'info');
-                }else{
-                    $.messager.alert('系统提示', data.error, 'info');
-                }
-            },
-            error:function(error){
 
-            }
-        });
-        //alert($(this).attr('data'));
-    }
-    function no(id,large_id){
-        //修改对应的小标签状态为已删除
-        $.ajax({
-            url:"index.php?s=/Admin/NewQcode/changestatus",
-            data:"large_id="+large_id+"&status=1&id="+id,
-            type:"get",
-            dataType:'json',
-            success:function(data){
-                console.log(data);
-                if(data.info){
-                    $.messager.alert('系统提示', data.info, 'info');
-                }else{
-                    $.messager.alert('系统提示', data.error, 'info');
-                }
-            },
-            error:function(error){
+    // function yes(id,large_id){
+    //     //alert(id,large_id);
+    //     //修改对应的小标签的状态为正常
+    //     $.ajax({
+    //         url:"index.php?s=/Admin/NewQcode/changestatus",
+    //         data:"large_id="+large_id+"&status=0&id="+id,
+    //         type:"get",
+    //         dataType:'json',
+    //         success:function(data){
+    //             console.log(data);
+    //             if(data.info){
+    //                 $.messager.alert('系统提示', data.info, 'info');
+    //             }else{
+    //                 $.messager.alert('系统提示', data.error, 'info');
+    //             }
+    //         },
+    //         error:function(error){
+	//
+    //         }
+    //     });
+    //     //alert($(this).attr('data'));
+    // }
+    // function no(id,large_id){
+    //     //修改对应的小标签状态为已删除
+    //     $.ajax({
+    //         url:"index.php?s=/Admin/NewQcode/changestatus",
+    //         data:"large_id="+large_id+"&status=1&id="+id,
+    //         type:"get",
+    //         dataType:'json',
+    //         success:function(data){
+    //             console.log(data);
+    //             if(data.info){
+    //                 $.messager.alert('系统提示', data.info, 'info');
+    //             }else{
+    //                 $.messager.alert('系统提示', data.error, 'info');
+    //             }
+    //         },
+    //         error:function(error){
+	//
+    //         }
+    //     });
+    // }
+	function yes(id, large_id) {
+		$.ajax({
+			url: "index.php?s=/Admin/NewQcode/changestatus",
+			data: "large_id=" + large_id + "&status=0&id=" + id,
+			type: "get",
+			dataType: 'json',
+			success: function (data) {
+				console.log(data);
+				// if (data.info) {
+				// 	$.messager.alert('系统提示', data.info, 'info');
+
+					// 获取当前行并打印调试信息
+					const row = $("tr[data-id='" + id + "']");
+					console.log("找到的行:", row);
+					const statusTd = row.find('td').eq(3);
+					console.log("当前状态:", statusTd.text());
+
+					// 更新状态
+					statusTd.text("正常").css("color", "green");
+				// } else {
+				// 	$.messager.alert('系统提示', data.error, 'info');
+				// }
+			},
+			error: function () {
+				$.messager.alert('系统提示', '网络错误', 'error');
+			}
+		});
+	}
 
-            }
-        });
-    }
+	function no(id, large_id) {
+		$.ajax({
+			url: "index.php?s=/Admin/NewQcode/changestatus",
+			data: "large_id=" + large_id + "&status=1&id=" + id,
+			type: "get",
+			dataType: 'json',
+			success: function (data) {
+				console.log(data);
+				// if (data.info) {
+				// 	$.messager.alert('系统提示', data.info, 'info');
+
+					// 获取当前行并打印调试信息
+					const row = $("tr[data-id='" + id + "']");
+					console.log("找到的行:", row);
+					const statusTd = row.find('td').eq(3);
+					console.log("当前状态:", statusTd.text());
+
+					// 更新状态
+					statusTd.text("已删除").css("color", "red");
+				// } else {
+				// 	$.messager.alert('系统提示', data.error, 'info');
+				// }
+			},
+			error: function () {
+				$.messager.alert('系统提示', '网络错误', 'error');
+			}
+		});
+	}
     function p_small(id,index){
 
 

+ 37 - 37
Application/Admin/View/Qcode/small.html

@@ -1,11 +1,11 @@
 <extend name="$_admin_public_layout"/>
- 
+
 
 <block name="main">
- 
-           
 
- 
+
+
+
                 <?php if (C('ADMIN_TABS')): ?>
                     <!-- 多标签后台 -->
                     <nav class="navbar navbar-default ct-tab-nav" role="navigation">
@@ -101,7 +101,7 @@
                                                 打印结束时间:
                                             </td>
                                             <td>
-                                               <input id ="endDate"  name="endDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/> 
+                                               <input id ="endDate"  name="endDate" class="easyui-datebox" style="width:150px" type="text" value="" data-options="editable:false"/>
                                            </td>
 
                                            <td align="right">
@@ -137,7 +137,7 @@
                                 <div style="margin:10px;">
                                     <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print',plain:true" onclick="rePrintFun(1)">标签补打</a>
                                 </div>
-                                
+
                             </div>
                             <table id=supTgGrid></table>
                         </div>
@@ -147,9 +147,9 @@
                                 重复打印数量:<input id="reptQty" name="reptQty" data-options="required:true,validType:['int','minValue[1]','maxValue[10]']" class="easyui-validatebox"/>
                             </form>
                         </div>
-                
-               
-    
+
+
+
                     <script src="__PUBLIC__/libs/guide/bootstrap-tour.js"></script>
                     <script src="__PUBLIC__/libs/My97DatePicker/WdatePicker.js"></script>
                     <script src="__PUBLIC__/libs/guide/guide_index.js?_t=2016121401"></script>
@@ -171,15 +171,15 @@
         });
         return o;
     };
-    Date.prototype.Format = function (fmt) { //author: meizz 
+    Date.prototype.Format = function (fmt) { //author: meizz
         var o = {
-        "M+": this.getMonth() + 1, //月份 
-        "d+": this.getDate(), //日 
-        "h+": this.getHours(), //小时 
-        "m+": this.getMinutes(), //分 
-        "s+": this.getSeconds(), //秒 
-        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
-        "S": this.getMilliseconds() //毫秒 
+        "M+": this.getMonth() + 1, //月份
+        "d+": this.getDate(), //日
+        "h+": this.getHours(), //小时
+        "m+": this.getMinutes(), //分
+        "s+": this.getSeconds(), //秒
+        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
+        "S": this.getMilliseconds() //毫秒
     };
     if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
     for (var k in o)
@@ -198,8 +198,8 @@ function splitEmVal(str){
   return "";
 };
 $(document).ready(function(){
-        supBthGrid=$('#supBthGrid').datagrid({    
-            url:'/index.php?s=/Admin/Qcode/ProductApi', 
+        supBthGrid=$('#supBthGrid').datagrid({
+            url:'/index.php?s=/Admin/Qcode/ProductApi',
             method:'get',
             toolbar:'#supBthGridToolbar',
             rownumbers : true,      // 如果为true,则显示一个行号列。
@@ -210,7 +210,7 @@ $(document).ready(function(){
             autoRowHeight : false,  // 定义设置行的高度,根据该行的内容。设置为false可以提高负载性能。
             pagination : true,      // 显示分页工具条
             sortName:'crtDt',       // 排序字段
-            sortOrder:'desc',       // 排序方式 
+            sortOrder:'desc',       // 排序方式
             pageSize:20,//初始化页面大小
             pageList:[20,30,50,100,500],// 初始化页面大小选择列表
             queryParams:$('#searchBthForm').serializeObject(),
@@ -250,12 +250,12 @@ $(document).ready(function(){
                 }
                 return true;
             }
-            
+
         });
-        
-        supTgGrid=$('#supTgGrid').datagrid({    
-            url:'index.php?s=/Admin/Qcode/PrintListApi', 
-            method:'get', 
+
+        supTgGrid=$('#supTgGrid').datagrid({
+            url:'index.php?s=/Admin/Qcode/PrintListApi',
+            method:'get',
             toolbar:'#supTgGridToolbar',
             rownumbers : true,      // 如果为true,则显示一个行号列。
             //singleSelect : false, // 如果为true,则只允许选择一行。
@@ -280,7 +280,7 @@ $(document).ready(function(){
             },
             onBeforeLoad:function(param){
                 var selecteRow=$('#supBthGrid').datagrid('getSelected');
-                $('#supTgGrid').datagrid('clearChecked'); 
+                $('#supTgGrid').datagrid('clearChecked');
                 if(selecteRow==null){
                     return false;
                 }
@@ -289,23 +289,23 @@ $(document).ready(function(){
         });
         //初始化日期输入框
         initDateBox();
-        $('#reptWin').dialog({    
-            title: '确认对话框',    
-            width: 300,    
-            height: 130,    
-            closed: true,    
-            cache: false,        
+        $('#reptWin').dialog({
+            title: '确认对话框',
+            width: 300,
+            height: 130,
+            closed: true,
+            cache: false,
             modal: true,
             buttons:[{
                 text:'打印',
                 handler:function(){
                     startPrint();
-                    $('#reptWin').window('close'); 
+                    $('#reptWin').window('close');
                 }
             },{
                 text:'取消',
                 handler:function(){
-                    $('#reptWin').window('close'); 
+                    $('#reptWin').window('close');
                 }
             }]
         });
@@ -322,7 +322,7 @@ $(document).ready(function(){
             supBthGrid.datagrid('load',$('#searchBthForm').serializeObject());
         }
     }
-    
 
- </script> 
-</block>
+
+ </script>
+</block>