lvhao 13 小時之前
父節點
當前提交
5404478ea2
共有 2 個文件被更改,包括 85 次插入1 次删除
  1. 35 1
      core/CoreApp/controllers/Goodimglibrary.php
  2. 50 0
      template/erp/goodimglibrary_noimg.html

+ 35 - 1
core/CoreApp/controllers/Goodimglibrary.php

@@ -36,6 +36,8 @@ class Goodimglibrary extends Start_Controller {
             $this->_getgoodbyids();
         }elseif($arg == 'excelgood'){
             $this->_excelgood();
+        }elseif($arg == 'editsku'){
+            $this->_editsku();
         }else{
 			$this->_index();
 		}
@@ -391,6 +393,8 @@ class Goodimglibrary extends Start_Controller {
         return $u9_jm;
     }
     private function _indexnoimg(){
+        $user = $this->user->get_api($_SESSION['api']);
+        $user_id = $user['id'];
 		if($this->input->method() == 'post'){
             $page = $this->input->post('page',true);
 		    $perpage = $this->input->post('perpage',true);
@@ -483,11 +487,20 @@ class Goodimglibrary extends Start_Controller {
                 $where .= ' AND features LIKE "%'.trim($hairnumber).'%" ';
             }
 
+            $is_able_edit = 0;
+            if(in_array($user_id,[10,28])){
+                $is_able_edit = 1;
+            }
             $list = $this->goods->find_all($where,'id,sku,title,zh,jm,update_time','id DESC',$start,$perpage);
             $info_list = [];
             foreach($list as $k => $v){
                 $info_list[$k]['id'] = $v['id'];
-                $info_list[$k]['sku'] = $v['sku']."  <i class='fa fa-copy' data-text='".$v['sku']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
+                if($is_able_edit == 1){
+                    $info_list[$k]['sku'] = " <i class='fa fa-edit' data-id ='".$v['id']."'  data-sku='".$v['sku']."' onclick='editsku(this)' style='color:red'></i> ".$v['sku']."  <i class='fa fa-copy' data-text='".$v['sku']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
+                }else{
+                    $info_list[$k]['sku'] = $v['sku']."  <i class='fa fa-copy' data-text='".$v['sku']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
+                }
+                
                 $info_list[$k]['title'] = $v['title']."  <i class='fa fa-copy' data-text='".$v['title']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
                 $info_list[$k]['zh'] = $v['zh']."  <i class='fa fa-copy' data-text='".$v['zh']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
                 $info_list[$k]['jm'] = $v['jm']."  <i class='fa fa-copy' data-text='".$v['jm']."' onclick='fuzhi(this)' style='background-color:#FFE4C4'></i>";
@@ -868,4 +881,25 @@ class Goodimglibrary extends Start_Controller {
             echo json_encode(['success'=>false,'msg'=>'请求不合法']);exit;
         }
     }
+
+    private function _editsku(){
+        if($this->input->method() == 'post'){
+            $id = $this->input->post('id',true);
+            $sku = $this->input->post('sku',true);
+            $info = $this->goods->read($id);
+            if(empty($info)){
+                echo json_encode(['success'=>false,'msg'=>'料品不存在']);exit;
+            }
+            if($info['sku'] == $sku){
+                echo json_encode(['success'=>false,'msg'=>'料品SKU未变动']);exit;
+            }
+            if($this->goods->save(array('sku'=>$sku),$id)){
+                echo json_encode(['success'=>true,'msg'=>'料品SKU修改成功']);exit;
+            }else{
+                echo json_encode(['success'=>false,'msg'=>'料品SKU修改失败']);exit;
+            }
+        }else{
+            echo json_encode(['success'=>false,'msg'=>'请求不合法']);exit;
+        }
+    }
 }

+ 50 - 0
template/erp/goodimglibrary_noimg.html

@@ -76,6 +76,12 @@
 </table>
 <div class="bomf"></div>
 </div>
+<div class="boundtj">
+<div>
+<p style="padding:10px 0px"></p>
+<p style="padding:10px 0px"><font class="button">确 定</font><font class="esc">取 消</font></p>
+</div>
+</div>
 
 <script>
 var dataurl = "/goodimglibrary/indexnoimg";
@@ -185,6 +191,50 @@ function downloadexcel(data){
     XLSX.utils.book_append_sheet(workbook, sheet, "Sheet1");
     XLSX.writeFile(workbook, "料品.xlsx");
 }
+
+function editsku(that){
+    let id = $(that).data('id');
+    let sku = $(that).data('sku');
+    $(".boundtj div p:eq(0)").html('<textarea style="width:95%" name="sku" >'+sku+'</textarea><input type="hidden" name="id" value="'+id+'" />');
+    $(".boundtj div p:eq(1)").html("<font class='obaddgo' onclick='doAddYcrk()'>确 定</font><font class='esc' onclick='escDo()'>取 消</font>");
+    $(".boundtj").show();
+}
+function doAddYcrk(){
+     let obj = {}
+     obj.id = $(".boundtj input[name='id']").val();
+     obj.sku = $(".boundtj textarea[name='sku']").val();
+     escDo();
+     $.post("/goodimglibrary/editsku", obj, function(a){
+        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
+			})
+        }
+     }, "json")
+}
+function escDo(){
+    $(".boundtj p").html("");
+    $(".boundtj").hide();
+}
 </script>
 <script type="text/javascript" src="{$theme}js/excel/xlxswidth.js"></script>
 {Template footer}