WIN-2308041133\Administrator 1 hafta önce
ebeveyn
işleme
9ae60362fe

+ 81 - 159
app/admin/controller/store/StoreProduct.php

@@ -3,7 +3,6 @@
 namespace app\admin\controller\store;
 
 use app\admin\controller\AuthController;
-use app\models\store\StoreProductLevel;
 use app\models\system\Tree;
 use app\admin\model\store\{
     StoreDescription,
@@ -111,10 +110,10 @@ class StoreProduct extends AuthController
             ['type', $this->request->param('type')]
         ]);
         $admin_id=$this->adminId;
-        $mer_id = SystemAdmin::where('id',$admin_id)->value('mer_id');
-        if ($mer_id>0){
-            $where['mer_id'] = $mer_id;
-        }
+       $mer_id = SystemAdmin::where('id',$admin_id)->value('mer_id');
+       if ($mer_id>0){
+           $where['mer_id'] = $mer_id;
+       }
 
         return Json::successlayui(ProductModel::ProductList($where));
     }
@@ -195,7 +194,7 @@ class StoreProduct extends AuthController
     }
 
     /**
-     * 获取品详细信息
+     * 获取品详细信息
      * @param int $id
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
@@ -220,22 +219,6 @@ class StoreProduct extends AuthController
             $productInfo['cate_id'] = explode(',', $productInfo['cate_id']);
             $productInfo['description'] = htmlspecialchars_decode(StoreDescription::getDescription($id));
             $productInfo['slider_image'] = is_string($productInfo['slider_image']) ? json_decode($productInfo['slider_image'], true) : [];
-
-            // 获取等级返利数据
-            $levelRebates = StoreProductLevel::where('product_id', $id)->select();
-            if ($levelRebates) {
-                $productInfo['level_rebates'] = $levelRebates->toArray();
-            } else {
-                // 默认等级数据
-                $productInfo['level_rebates'] = [
-                    ['id' => 1, 'name' => '青源客', 'rebate_ratio' => 0],
-                    ['id' => 2, 'name' => '青润使', 'rebate_ratio' => 0],
-                    ['id' => 3, 'name' => '青金团', 'rebate_ratio' => 0],
-                    ['id' => 4, 'name' => '青玉团', 'rebate_ratio' => 0],
-                    ['id' => 5, 'name' => '青谷团', 'rebate_ratio' => 0]
-                ];
-            }
-
             if ($productInfo['spec_type'] == 1) {
                 $result = StoreProductAttrResult::getResult($id);
                 foreach ($result['value'] as $k => $v) {
@@ -319,8 +302,7 @@ class StoreProduct extends AuthController
             ['mer_use', 0],
             ['is_postage', 0],
             ['is_good', 0],
-            ['is_level_rebate', 0],
-            ['level_rebates', []],
+//            ['description', ''],
             ['spec_type', 0],
             ['video_link', ''],
             ['items', []],
@@ -329,34 +311,13 @@ class StoreProduct extends AuthController
             ['store_type', 1],
             ['mer_id',0]
         ], $this->request, false, true);
-
-        // 验证等级返利数据
-        if ($data['is_level_rebate'] == 1) {
-            if (empty($data['level_rebates']) || !is_array($data['level_rebates'])) {
-                return Json::fail('请设置等级返利数据');
-            }
-
-            // 验证返利比例是否合理
-            foreach ($data['level_rebates'] as $k => $level) {
-                if (!isset($level['rebate_ratio']) || $level['rebate_ratio'] === '') {
-                    return Json::fail('请设置等级返利比例');
-                }
-
-                if ($level['rebate_ratio'] < 0 || $level['rebate_ratio'] > 100) {
-                    return Json::fail('返利比例必须在0-100之间');
-                }
-
-                // 验证等级间返利比例是否递增
-                if ($k > 0) {
-                    if ($level['rebate_ratio'] <= $data['level_rebates'][$k-1]['rebate_ratio']) {
-                        return Json::fail('等级返利比例应随等级提高而递增');
-                    }
-                }
-            }
-        }
-
-        $data['is_pick'] = SystemStore::where('id', $data['mer_id'])->value('is_pick');
-
+//        $admin_id=$this->adminId;
+//        $mer_id = SystemAdmin::where('id',$admin_id)->value('mer_id');
+//        if ($data['mer_id']>0){
+//            $data['mer_id'] = $mer_id;
+            $data['is_pick']=SystemStore::where('id',$data['mer_id'])->value('is_pick');
+//            var_dump($data);die();
+//        }
         foreach ($data['activity'] as $k => $v) {
             if ($v == '秒杀') {
                 $data['activity'][$k] = 1;
@@ -375,11 +336,7 @@ class StoreProduct extends AuthController
         $data['ot_price'] = min(array_column($detail, 'ot_price'));
         $data['cost'] = min(array_column($detail, 'cost'));
         $attr = $data['items'];
-
-        // 保存等级返利数据
-        $levelRebates = $data['level_rebates'];
-        unset($data['items'], $data['video'], $data['attrs'], $data['level_rebates']);
-
+        unset($data['items'], $data['video'], $data['attrs']);
         if (count($data['cate_id']) < 1) return Json::fail('请选择产品分类');
         if (!in_array($data['store_type'], [1, 2])) return Json::fail('请选择正确的商品类型');
         $cate_id = $data['cate_id'];
@@ -391,110 +348,76 @@ class StoreProduct extends AuthController
         $data['image'] = $data['image'][0];
         $data['slider_image'] = json_encode($data['slider_image']);
         $data['stock'] = array_sum(array_column($detail, 'stock'));
-
         ProductModel::beginTrans();
-        try {
-            foreach ($detail as &$item) {
-                if (($item['brokerage'] + $item['brokerage_two']) > $item['price']) {
-                    throw new \Exception('一二级返佣相加不能大于商品售价');
-                }
+        foreach ($detail as &$item) {
+            if (($item['brokerage'] + $item['brokerage_two']) > $item['price']) {
+                return Json::fail('一二级返佣相加不能大于商品售价');
+            }
+        }
+        if ($id) {
+            unset($data['sales']);
+            ProductModel::edit($data, $id);
+            $description = $data['description'];
+            unset($data['description']);
+            StoreDescription::saveDescription($description, $id);
+            StoreProductCate::where('product_id', $id)->delete();
+            $cateData = [];
+            foreach ($cate_id as $cid) {
+                $cateData[] = ['product_id' => $id, 'cate_id' => $cid, 'add_time' => time()];
+            }
+            StoreProductCate::insertAll($cateData);
+            if ($data['spec_type'] == 0) {
+                $attr = [
+                    [
+                        'value' => '规格',
+                        'detailValue' => '',
+                        'attrHidden' => '',
+                        'detail' => ['默认']
+                    ]
+                ];
+                $detail[0]['value1'] = '规格';
+                $detail[0]['detail'] = ['规格' => '默认'];
             }
 
-            if ($id) {
-                unset($data['sales']);
-                ProductModel::edit($data, $id);
-                $description = $data['description'];
-                unset($data['description']);
-                StoreDescription::saveDescription($description, $id);
-                StoreProductCate::where('product_id', $id)->delete();
-                $cateData = [];
-                foreach ($cate_id as $cid) {
-                    $cateData[] = ['product_id' => $id, 'cate_id' => $cid, 'add_time' => time()];
-                }
-                StoreProductCate::insertAll($cateData);
-
-                // 更新等级返利数据
-                if ($data['is_level_rebate'] == 1) {
-                    // 删除原有数据
-                    StoreProductLevel::where('product_id', $id)->delete();
-
-                    // 插入新数据
-                    foreach ($levelRebates as $level) {
-                        StoreProductLevel::create([
-                            'product_id' => $id,
-                            'level_id' => $level['id'],
-                            'rebate_ratio' => $level['rebate_ratio'],
-                            'add_time' => time(),
-                            'update_time' => time()
-                        ]);
-                    }
-                }
-
-                if ($data['spec_type'] == 0) {
-                    $attr = [
-                        [
-                            'value' => '规格',
-                            'detailValue' => '',
-                            'attrHidden' => '',
-                            'detail' => ['默认']
-                        ]
-                    ];
-                    $detail[0]['value1'] = '规格';
-                    $detail[0]['detail'] = ['规格' => '默认'];
-                }
-
-                $attr_res = StoreProductAttr::createProductAttr($attr, $detail, $id);
-                if (!$attr_res) {
-                    throw new \Exception(StoreProductAttr::getErrorInfo());
-                }
+            $attr_res = StoreProductAttr::createProductAttr($attr, $detail, $id);
+            if ($attr_res) {
+                ProductModel::commitTrans();
+                return Json::success('修改成功!');
             } else {
-                $data['add_time'] = time();
-                $data['code_path'] = '';
-                $res = ProductModel::create($data);
-                $description = $data['description'];
-                StoreDescription::saveDescription($description, $res['id']);
-                $cateData = [];
-                foreach ($cate_id as $cid) {
-                    $cateData[] = ['product_id' => $res['id'], 'cate_id' => $cid, 'add_time' => time()];
-                }
-                StoreProductCate::insertAll($cateData);
-
-                // 保存等级返利数据
-                if ($data['is_level_rebate'] == 1) {
-                    foreach ($levelRebates as $level) {
-                        StoreProductLevel::create([
-                            'product_id' => $res['id'],
-                            'level_id' => $level['id'],
-                            'rebate_ratio' => $level['rebate_ratio'],
-                            'add_time' => time(),
-                            'update_time' => time()
-                        ]);
-                    }
-                }
-
-                if ($data['spec_type'] == 0) {
-                    $attr = [
-                        [
-                            'value' => '规格',
-                            'detailValue' => '',
-                            'attrHidden' => '',
-                            'detail' => ['默认']
-                        ]
-                    ];
-                    $detail[0]['value1'] = '规格';
-                    $detail[0]['detail'] = ['规格' => '默认'];
-                }
-                $attr_res = StoreProductAttr::createProductAttr($attr, $detail, $res['id']);
-                if (!$attr_res) {
-                    throw new \Exception(StoreProductAttr::getErrorInfo());
-                }
+                ProductModel::rollbackTrans();
+                return Json::fail(StoreProductAttr::getErrorInfo());
+            }
+        } else {
+            $data['add_time'] = time();
+            $data['code_path'] = '';
+            $res = ProductModel::create($data);
+            $description = $data['description'];
+            StoreDescription::saveDescription($description, $res['id']);
+            $cateData = [];
+            foreach ($cate_id as $cid) {
+                $cateData[] = ['product_id' => $res['id'], 'cate_id' => $cid, 'add_time' => time()];
+            }
+            StoreProductCate::insertAll($cateData);
+            if ($data['spec_type'] == 0) {
+                $attr = [
+                    [
+                        'value' => '规格',
+                        'detailValue' => '',
+                        'attrHidden' => '',
+                        'detail' => ['默认']
+                    ]
+                ];
+                $detail[0]['value1'] = '规格';
+                $detail[0]['detail'] = ['规格' => '默认'];
+            }
+            $attr_res = StoreProductAttr::createProductAttr($attr, $detail, $res['id']);
+            if ($attr_res) {
+                ProductModel::commitTrans();
+                return Json::success('添加产品成功!');
+            } else {
+                ProductModel::rollbackTrans();
+                return Json::fail(StoreProductAttr::getErrorInfo());
             }
-
-            ProductModel::commitTrans();
-            return Json::success($id ? '修改成功!' : '添加产品成功!');
-        } catch (\Exception $e) {
-            ProductModel::rollbackTrans();
-            return Json::fail($e->getMessage());
         }
     }
 
@@ -557,7 +480,6 @@ class StoreProduct extends AuthController
             Form::radio('is_postage', '是否包邮', $product->getData('is_postage'))->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]])->col(8),
             Form::radio('is_good', '是否优品推荐', $product->getData('is_good'))->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]])->col(8),
             Form::radio('is_wholesale', '是否批发商品', $product->getData('is_wholesale'))->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]])->col(8),
-            Form::radio('is_level_rebate', '是否开启等级返利', $product->getData('is_level_rebate'))->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]])->col(8),
         ];
         $form = Form::make_post_form('编辑产品', $field, Url::buildUrl('update', array('id' => $id)), 2);
         $this->assign(compact('form'));
@@ -600,7 +522,6 @@ class StoreProduct extends AuthController
             ['is_postage', 0],
             ['is_good', 0],
             ['is_wholesale',0],
-            ['is_level_rebate',0],
             ['mer_id',0]
         ]);
         if (count($data['cate_id']) < 1) return Json::fail('请选择产品分类');
@@ -609,6 +530,7 @@ class StoreProduct extends AuthController
         if (!$data['store_name']) return Json::fail('请输入产品名称');
         if (count($data['image']) < 1) return Json::fail('请上传产品图片');
         if (count($data['slider_image']) < 1) return Json::fail('请上传产品轮播图');
+        // if(count($data['slider_image'])>8) return Json::fail('轮播图最多5张图');
         if ($data['price'] == '' || $data['price'] < 0) return Json::fail('请输入产品售价');
         if ($data['ot_price'] == '' || $data['ot_price'] < 0) return Json::fail('请输入产品市场价');
         if ($data['stock'] == '' || $data['stock'] < 0) return Json::fail('请输入库存');
@@ -856,4 +778,4 @@ class StoreProduct extends AuthController
             return Json::fail();
         }
     }
-}
+}

+ 100 - 175
app/admin/view/store/store_product/create.php

@@ -143,10 +143,6 @@
             padding-left: 10px;
             line-height: 30px;
         }
-
-        .level-rebate-table {
-            margin-top: 15px;
-        }
     </style>
 </head>
 <body>
@@ -700,6 +696,19 @@
                                             </div>
                                         </div>
                                     </div>
+<!--                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">-->
+<!--                                        <div class="grid-demo grid-demo-bg1">-->
+<!--                                            <div class="layui-form-item">-->
+<!--                                                <label class="layui-form-label">返利点数</label>-->
+<!--                                                <div class="layui-input-block">-->
+<!--                                                    <input type="number" name="rebate_ratio" lay-verify="title"-->
+<!--                                                           autocomplete="off"-->
+<!--                                                           placeholder="请输入返利点数" class="layui-input"-->
+<!--                                                           v-model="formData.rebate_ratio">-->
+<!--                                                </div>-->
+<!--                                            </div>-->
+<!--                                        </div>-->
+<!--                                    </div>-->
                                     <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
                                         <div class="grid-demo grid-demo-bg1">
                                             <div class="layui-form-item">
@@ -725,21 +734,21 @@
                                             </div>
                                         </div>
                                     </div>
-                                    <!--                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">-->
-                                    <!--                                        <div class="grid-demo grid-demo-bg1">-->
-                                    <!--                                            <div class="layui-form-item">-->
-                                    <!--                                                <label class="layui-form-label">佣金设置</label>-->
-                                    <!--                                                <div class="layui-input-block">-->
-                                    <!--                                                    <input type="radio" name="is_sub" lay-filter="is_sub" value="1"-->
-                                    <!--                                                           title="单独设置"-->
-                                    <!--                                                           :checked="formData.is_sub == 1 ? true : false">-->
-                                    <!--                                                    <input type="radio" name="is_sub" lay-filter="is_sub" value="0"-->
-                                    <!--                                                           title="默认设置"-->
-                                    <!--                                                           :checked="formData.is_sub == 0 ? true : false">-->
-                                    <!--                                                </div>-->
-                                    <!--                                            </div>-->
-                                    <!--                                        </div>-->
-                                    <!--                                    </div>-->
+                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
+                                        <div class="grid-demo grid-demo-bg1">
+                                            <div class="layui-form-item">
+<!--                                                <label class="layui-form-label">佣金设置</label>-->
+<!--                                                <div class="layui-input-block">-->
+<!--                                                    <input type="radio" name="is_sub" lay-filter="is_sub" value="1"-->
+<!--                                                           title="单独设置"-->
+<!--                                                           :checked="formData.is_sub == 1 ? true : false">-->
+<!--                                                    <input type="radio" name="is_sub" lay-filter="is_sub" value="0"-->
+<!--                                                           title="默认设置"-->
+<!--                                                           :checked="formData.is_sub == 0 ? true : false">-->
+<!--                                                </div>-->
+                                            </div>
+                                        </div>
+                                    </div>
                                     <div class="layui-col-xs12 layui-col-sm12 layui-col-md12"
                                          v-if="formData.is_sub == 1 && formData.spec_type == 1">
                                         <div class="grid-demo grid-demo-bg1">
@@ -860,6 +869,19 @@
                                     </div>
                                     <!--多属性结束-->
 
+                                    <!--                                    <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">-->
+                                    <!--                                        <div class="grid-demo grid-demo-bg1">-->
+                                    <!--                                            <div class="layui-form-item">-->
+                                    <!--                                                <label class="layui-form-label">商品状态</label>-->
+                                    <!--                                                <div class="layui-input-block">-->
+                                    <!--                                                    <input type="radio" name="is_show" lay-filter="is_show" value="1" title="上架"-->
+                                    <!--                                                           :checked="formData.is_show == 1 ? true : false">-->
+                                    <!--                                                    <input type="radio" name="is_show" lay-filter="is_show" value="0" title="下架"-->
+                                    <!--                                                           :checked="formData.is_show == 0 ? true : false">-->
+                                    <!--                                                </div>-->
+                                    <!--                                            </div>-->
+                                    <!--                                        </div>-->
+                                    <!--                                    </div>-->
                                     <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
                                         <div class="grid-demo grid-demo-bg1">
                                             <div class="layui-form-item">
@@ -950,70 +972,28 @@
                                             </div>
                                         </div>
                                     </div>
-
-                                    <!-- 等级获利设置 -->
-                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
-                                        <div class="grid-demo grid-demo-bg1">
-                                            <div class="layui-form-item">
-                                                <label class="layui-form-label">等级返利设置</label>
-                                                <div class="layui-input-block">
-                                                    <input type="radio" name="is_level_rebate" lay-filter="is_level_rebate" value="1"
-                                                           title="开启"
-                                                           :checked="formData.is_level_rebate == 1 ? true : false">
-                                                    <input type="radio" name="is_level_rebate" lay-filter="is_level_rebate" value="0"
-                                                           title="关闭"
-                                                           :checked="formData.is_level_rebate == 0 ? true : false">
-                                                </div>
-                                            </div>
-                                        </div>
-                                    </div>
-                                    <!-- 等级返利比例表格 -->
-                                    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" v-if="formData.is_level_rebate == 1">
-                                        <div class="grid-demo grid-demo-bg1">
-                                            <div class="layui-form-item">
-                                                <label class="layui-form-label">等级返利比例</label>
-                                                <div class="layui-input-block">
-                                                    <div class="level-rebate-table">
-                                                        <table class="layui-table">
-                                                            <thead>
-                                                            <tr>
-                                                                <th>等级名称</th>
-                                                                <th>返利比例(%)</th>
-                                                                <th width="100">操作</th>
-                                                            </tr>
-                                                            </thead>
-                                                            <tbody>
-                                                            <tr v-for="(level, index) in formData.level_rebates" :key="level.id">
-                                                                <td>{{level.name}}</td>
-                                                                <td>
-                                                                    <input type="number" v-model="level.rebate_ratio"
-                                                                           class="layui-input"
-                                                                           min="0"
-                                                                           max="100"
-                                                                           step="0.01"
-                                                                           @change="checkRebateRatio(level)">
-                                                                </td>
-                                                                <td>
-                                                                    <button class="layui-btn layui-btn-xs layui-btn-danger"
-                                                                            type="button"
-                                                                            @click="removeLevelRebate(index)"
-                                                                            v-if="index > 0">删除</button>
-                                                                </td>
-                                                            </tr>
-                                                            </tbody>
-                                                        </table>
-                                                        <div class="layui-form-item">
-                                                            <div class="layui-input-block">
-                                                                <button class="layui-btn layui-btn-sm" type="button"
-                                                                        @click="addLevelRebate">添加等级</button>
-                                                            </div>
-                                                        </div>
-                                                    </div>
-                                                    <div class="layui-form-mid layui-word-aux red" v-if="rebateError">{{rebateError}}</div>
-                                                </div>
-                                            </div>
-                                        </div>
-                                    </div>
+<!--                                    <div class="layui-row layui-col-space15">-->
+<!--                                        <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">-->
+<!--                                            <div class="grid-demo grid-demo-bg1">-->
+<!--                                                <div class="layui-form-item">-->
+<!--                                                    <label class="layui-form-label">活动优先级</label>-->
+<!--                                                    <div class="layui-input-block">-->
+<!--                                                        <span class="layui-btn layui-btn-sm layui-btn-normal"-->
+<!--                                                              :style="'background-color:'+activity[item]"-->
+<!--                                                              v-for="(item,index) in formData.activity" :key="index"-->
+<!--                                                              draggable="true"-->
+<!--                                                              @dragstart="handleDragStart($event, item)"-->
+<!--                                                              @dragover.prevent="handleDragOver($event, item)"-->
+<!--                                                              @dragenter="handleDragEnter($event, item)"-->
+<!--                                                              @dragend="handleDragEnd($event, item)">-->
+<!--                                                        {{item}}-->
+<!--                                                    </span>-->
+<!--                                                        <span class="info">可拖动按钮调整活动的优先展示顺序</span>-->
+<!--                                                    </div>-->
+<!--                                                </div>-->
+<!--                                            </div>-->
+<!--                                        </div>-->
+<!--                                    </div>-->
                                 </div>
                             </div>
                         </div>
@@ -1111,18 +1091,16 @@
                 is_good: 0,
                 store_type: 1,
                 is_sub: 0,
-                is_level_rebate: 0,
-                level_rebates: [
-                    {id: 1, name: '青源客', rebate_ratio: 0},
-                    {id: 2, name: '青润使', rebate_ratio: 0},
-                    {id: 3, name: '青金团', rebate_ratio: 0},
-                    {id: 4, name: '青玉团', rebate_ratio: 0},
-                    {id: 5, name: '青谷团', rebate_ratio: 0}
+                items: [
+                    // {
+                    //     value: '',
+                    //     detailValue:'',
+                    //     attrHidden:false,
+                    //     detail:[]
+                    // }
                 ],
-                items: [],
                 activity: ['秒杀', '砍价', '拼团'],
             },
-            rebateError: '',
             videoLink: '',
             //批量添加属性
             batchAttr: {
@@ -1150,7 +1128,7 @@
             activity: {'秒杀': '#1E9FFF', '砍价': '#189688', '拼团': '#FEB900'},
             attr: [],//临时属性
             newRule: false,//是否添加新规则
-            radioRule: ['store_type', 'is_sub', 'is_show', 'is_hot', 'is_benefit', 'is_new', 'is_good', 'is_best','is_wholesale', 'spec_type', 'is_level_rebate'],//radio 当选规则
+            radioRule: ['store_type', 'is_sub', 'is_show', 'is_hot', 'is_benefit', 'is_new', 'is_good', 'is_best','is_wholesale', 'spec_type'],//radio 当选规则
             rule: { //多图选择规则
                 slider_image: {
                     maxLength: 5
@@ -1179,12 +1157,14 @@
                     this.render();
                 }
             },
-            'formData.is_level_rebate': function (n) {
-                if (n == 1) {
-                    // 开启等级返利时,清空返利错误提示
-                    this.rebateError = '';
-                }
-            }
+            // 'formData.image':function (n) {
+            //     if(!this.batchAttr.pic){
+            //         this.batchAttr.pic = n;
+            //     }
+            //     if(!this.formData.attr.pic){
+            //         this.formData.attr.pic = n;
+            //     }
+            // }
         },
         methods: {
             back: function () {
@@ -1222,60 +1202,6 @@
                     layui.layer.msg(msg, success);
                 });
             },
-            /**
-             * 检查返利比例是否合理
-             */
-            checkRebateRatio: function (level) {
-                this.rebateError = '';
-                // 检查是否为数字
-                if (isNaN(level.rebate_ratio) || level.rebate_ratio === '') {
-                    this.rebateError = level.name + '的返利比例必须是数字';
-                    return false;
-                }
-
-                // 检查是否在合理范围内
-                if (level.rebate_ratio < 0 || level.rebate_ratio > 100) {
-                    this.rebateError = level.name + '的返利比例必须在0-100之间';
-                    return false;
-                }
-
-                // 检查是否超过成本价
-                if (this.formData.spec_type == 0 && this.formData.attr.cost > 0) {
-                    if (level.rebate_ratio > (this.formData.attr.price - this.formData.attr.cost) / this.formData.attr.price * 100) {
-                        this.rebateError = level.name + '的返利比例过高,可能影响平台利润';
-                        return false;
-                    }
-                }
-
-                // 检查等级间返利比例是否递增
-                for (let i = 0; i < this.formData.level_rebates.length - 1; i++) {
-                    if (this.formData.level_rebates[i].rebate_ratio > this.formData.level_rebates[i + 1].rebate_ratio) {
-                        this.rebateError = '等级返利比例应随等级提高而递增';
-                        return false;
-                    }
-                }
-
-                return true;
-            },
-            /**
-             * 添加等级返利
-             */
-            addLevelRebate: function () {
-                const newId = this.formData.level_rebates.length + 1;
-                this.formData.level_rebates.push({
-                    id: newId,
-                    name: '等级' + newId,
-                    rebate_ratio: 0
-                });
-            },
-            /**
-             * 删除等级返利
-             */
-            removeLevelRebate: function (index) {
-                if (this.formData.level_rebates.length > 1) {
-                    this.formData.level_rebates.splice(index, 1);
-                }
-            },
             addBrokerage: function () {
                 if (this.brokerage.brokerage > 0 && this.brokerage.brokerage_two > 0) {
                     var that = this;
@@ -1354,18 +1280,6 @@
                     var productInfo = res.data.productInfo || {};
                     if (productInfo.id && that.id) {
                         that.$set(that, 'formData', productInfo);
-                        // 初始化等级返利数据
-                        if (productInfo.level_rebates) {
-                            that.formData.level_rebates = productInfo.level_rebates;
-                        } else {
-                            that.formData.level_rebates = [
-                                {id: 1, name: '青源客', rebate_ratio: 0},
-                                {id: 2, name: '青润使', rebate_ratio: 0},
-                                {id: 3, name: '青金团', rebate_ratio: 0},
-                                {id: 4, name: '青玉团', rebate_ratio: 0},
-                                {id: 5, name: '青谷团', rebate_ratio: 0}
-                            ];
-                        }
                         that.generate();
                     }
                     that.getRuleList();
@@ -1731,16 +1645,6 @@
                 if (!that.formData.slider_image.length) {
                     return that.showMsg('请填选择商品轮播图');
                 }
-
-                // 检查等级返利设置
-                if (that.formData.is_level_rebate == 1) {
-                    for (let i = 0; i < that.formData.level_rebates.length; i++) {
-                        if (!that.checkRebateRatio(that.formData.level_rebates[i])) {
-                            return;
-                        }
-                    }
-                }
-
                 if (that.formData.spec_type == 0) {
                     if (!that.formData.attr.pic) {
                         return that.showMsg('请选择单规则图片');
@@ -1828,6 +1732,27 @@
                     });
                 })
             },
+            // 移动
+            handleDragStart(e, item) {
+                this.dragging = item;
+            },
+            handleDragEnd(e, item) {
+                this.dragging = null
+            },
+            handleDragOver(e) {
+                e.dataTransfer.dropEffect = 'move'
+            },
+            handleDragEnter(e, item) {
+                e.dataTransfer.effectAllowed = 'move'
+                if (item === this.dragging) {
+                    return
+                }
+                var newItems = [...this.formData.activity];
+                var src = newItems.indexOf(this.dragging);
+                var dst = newItems.indexOf(item);
+                newItems.splice(dst, 0, ...newItems.splice(src, 1))
+                this.formData.activity = newItems;
+            },
             getRuleList: function (type) {
                 var that = this;
                 that.requestGet(that.U({c: 'store.StoreProduct', a: 'get_rule'})).then(function (res) {