zhanglinxin 1 year ago
parent
commit
dffea75047

+ 73 - 24
application/approve/controller/Goods.php

@@ -91,7 +91,49 @@ class Goods extends Controller
     public function add()
     {
         $this->title = '添加';
-        $this->_form($this->table, 'form');
+//        $this->_form($this->table, 'form');
+        if ($this->request->isGet()) {
+            $this->category_list = GoodsCategoryService::get_list([],1);
+            return $this->fetch('form',['vo' => []]);
+        }
+        if ($this->request->isPost()) {
+            list($data) = [$this->request->post()];
+            if($data){
+                // 添加编辑提交数据时
+                $data['goods_category_first'] = $data['first_classify'];
+                $data['goods_category_id'] = $data['second_classify'];
+                $goods_info = model::field('id')
+                    ->where('goods_category_first', $data['goods_category_first'])
+                    ->where('goods_category_id', $data['goods_category_id'])
+                    ->where('goods_name', $data['goods_name'])
+                    ->where('is_deleted', CommonConstant::IS_DELETED_0)
+                    ->find();
+                if($goods_info){
+                    $this->error('该商品已存在不能重复添加');
+                }
+
+                $result = model::create($data);
+                $goods_stock = $data['goods_stock'];
+                $goods_stock_data = [];
+                if(isset($data['id']) && $data['id']){
+
+                } else{
+                    // 添加商品 添加规格
+                    foreach ($goods_stock as $key=>$val){
+                        $goods_stock_data[] = [
+                            'goods_id'=>$result,
+                            'name'=>$val['name'],
+                            'stock'=>$val['stock'],
+                        ];
+                    }
+                    if($goods_stock_data){
+                        GoodsStock::insertAll($goods_stock_data);
+                    }
+                }
+                $this->success('商品编辑成功!', 'javascript:history.back()');
+            }
+        }
+
     }
 
     /**
@@ -129,9 +171,21 @@ class Goods extends Controller
         }
         if ($this->request->isPost()) {
             if($data){
-                // 编辑提交数据时
+                // 添加编辑提交数据时
                 $data['goods_category_first'] = $data['first_classify'];
                 $data['goods_category_id'] = $data['second_classify'];
+                if(isset($data['id']) && $data['id'] > 0){
+                } else{
+                    $goods_info = model::field('id')
+                        ->where('goods_category_first', $data['goods_category_first'])
+                        ->where('goods_category_id', $data['goods_category_id'])
+                        ->where('goods_name', $data['goods_name'])
+                        ->where('is_deleted', CommonConstant::IS_DELETED_0)
+                        ->find();
+                    if($goods_info){
+                        $this->error('该商品已存在不能重复添加');
+                    }
+                }
             }
         }
     }
@@ -144,28 +198,23 @@ class Goods extends Controller
     {
         if ($result && $this->request->isPost()) {
             list($data) = [$this->request->post()];
-            p($result);
-            p($data);
-            exit;
-//            $data['id'] = $result;
-//            $low_price = 0;
-//            foreach (json_decode($data['lists'], true) as $ko=>$vo){
-//                if($low_price == 0 || $vo[0]['sell_price'] < $low_price )$low_price =  $vo[0]['sell_price'];
-//                Data::save('StoreGoodsItem', [
-//                    'goods_id'          => $data['id'],
-//                    'spec_cover'        => $data['spec_cover'][$ko] ? $data['spec_cover'][$ko] : $vo[0]['spec_cover'],
-//                    'goods_spec'        => $vo[0]['key'],
-//                    'goods_no'          => $vo[0]['sku'],
-//                    'original_price'    => $vo[0]['original_price'],
-//                    'sell_price'        => $vo[0]['sell_price'],
-//                    'virtual'           => $vo[0]['virtual'],
-//                    'status'            => $vo[0]['status'] ? 1 : 0,
-//                    'weight'            => $vo[0]['weight'] ? $vo[0]['weight'] : 0,
-//                ], 'goods_spec', ['goods_id' => $data['id']]);
-//            }
-//            Db::name('StoreGoods')->where(['id'=>$data['id']])->update(['low_price'=>$low_price]);
-//            \app\common\model\StoreGoods::esAdd($result);
-//            \app\common\model\TopSearch::saveData($result,'goods');
+            $goods_stock = $data['goods_stock'];
+            $goods_stock_data = [];
+            if(isset($data['id']) && $data['id']){
+
+            } else{
+                // 添加商品 添加规格
+                foreach ($goods_stock as $key=>$val){
+                    $goods_stock_data[] = [
+                        'goods_id'=>$result,
+                        'name'=>$val['name'],
+                        'stock'=>$val['stock'],
+                    ];
+                }
+                if($goods_stock_data){
+                    GoodsStock::insertAll($goods_stock_data);
+                }
+            }
             $this->success('商品编辑成功!', 'javascript:history.back()');
         }
     }

+ 1 - 1
application/approve/view/approve_info/form_10.html

@@ -70,7 +70,7 @@
                 <div class="layui-form-item">
                     <label class="layui-form-label color-green font-w7">收文序号</label>
                     <div class="layui-input-block">
-                        <input name="" placeholder="" value="{$vo.module_info.number|default='--'}"
+                        <input name="" placeholder="" value="{$vo.module_info.serial_number|default='--'}"
                                class="layui-input border-0" disabled>
                         <p class="help-block"></p>
                     </div>

+ 2 - 2
application/approve/view/approve_info_log/form_10.html

@@ -38,7 +38,7 @@
                             <div class="layui-form-item">
                                 <label class="layui-form-label color-green font-w7">收文序号</label>
                                 <div class="layui-input-block">
-                                    <input name="" placeholder="" value="{$vo.module_info.number|default='--'}"
+                                    <input name="" placeholder="" value="{$vo.module_info.serial_number|default='--'}"
                                            class="layui-input border-0" disabled>
                                     <p class="help-block"></p>
                                 </div>
@@ -126,7 +126,7 @@
                             <div class="layui-form-item">
                                 <label class="layui-form-label color-green font-w7">收文序号</label>
                                 <div class="layui-input-block">
-                                    <input name="" placeholder="" value="{$vo2.module_info.number|default='--'}"
+                                    <input name="" placeholder="" value="{$vo2.module_info.serial_number|default='--'}"
                                            class="layui-input border-0" disabled>
                                     <p class="help-block"></p>
                                 </div>

+ 2 - 0
application/approve/view/approve_info_log/form_5.html

@@ -189,6 +189,7 @@
                                     <p class="help-block"></p>
                                 </div>
                             </div>
+                            {if ($vo2.type == 1)}
                             <div class="layui-form-item">
                                 <label class="layui-form-label color-green font-w7">是否跨关内关外</label>
                                 <div class="layui-input-block">
@@ -198,6 +199,7 @@
                                     <p class="help-block"></p>
                                 </div>
                             </div>
+                            {/if}
                             <div class="layui-form-item">
                                 <label class="layui-form-label color-green font-w7">备注</label>
                                 <div class="layui-input-block">