Ver código fonte

页面修复

Zhouzhendong 5 anos atrás
pai
commit
c6f49468c9

+ 1 - 0
app/Http/Controllers/PriceModelController.php

@@ -1097,6 +1097,7 @@ class PriceModelController extends Controller
             DB::transaction(function ()use(&$model,$params,$operation){
                 $model = app('OwnerPriceOperationService')->create($operation);
                 foreach ($params["items"] as &$item){
+                    $item["discount_price"]  = implode(",",$item["discount_price"] ?? []);
                     $item["owner_price_operation_id"] = $model->id;
                     if (!isset($item["feature"]))$item["feature"] = null;
                     unset($item["features"]);

+ 28 - 32
resources/views/customer/project/create.blade.php

@@ -138,19 +138,7 @@
                         unit_id : "",
                         time_unit_id : "",
                     },
-                    operation:{
-                        operation_type:"入库",
-                        strategy:"默认",
-                        discount_count:[''],
-                        name:"",
-                        feature:"",
-                        total_discount_price:[''],
-                        items : [
-                            {strategy:"起步",type:"0",discount_price:['']},
-                            {strategy:"默认",discount_price:['']},
-                            {strategy:"特征",discount_price:['']},
-                        ],
-                    },
+                    operation:{},
                     express:{
                         name:"",
                         initial_weight:"",
@@ -214,11 +202,28 @@
                         if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
                     },0);
                 }
+                this._resetOperation();
                 this.ownerTemp = JSON.parse(JSON.stringify(this.owner));
                 $('[data-toggle="tooltip"]').tooltip();
                 $("#container").removeClass("d-none");
             },
             methods:{
+                //重置作业计费数据
+                _resetOperation(){
+                    this.model.operation = {
+                        operation_type:"入库",
+                            strategy:"默认",
+                            discount_count:[''],
+                            name:"",
+                            feature:"",
+                            total_discount_price:[''],
+                            items : [
+                            {strategy:"起步",type:"0",discount_price:['']},
+                            {strategy:"默认",discount_price:['']},
+                            {strategy:"特征",discount_price:['']},
+                        ],
+                    };
+                },
                 //悬浮效果
                 hoverEffect(key,val){
                     this.$set(this.hover,key,val);
@@ -429,8 +434,8 @@
                                     if (operation.total_discount_price) res.owner_price_operations[i].total_discount_price = operation.total_discount_price.split(",");
                                     operation.isDiscount = true;
                                 }
-                                operation.items.forEach((item,i)=>{
-                                    if (item.discount_price) res.owner_price_operations[i].items[i].discount_price = item.discount_price.split(",");
+                                operation.items.forEach((item,j)=>{
+                                    if (item.discount_price) res.owner_price_operations[i].items[j].discount_price = item.discount_price.split(",");
                                 });
                                 if (operation.total_price)operation.isSingle = true;
                             });
@@ -687,35 +692,26 @@
                             res.items[i].features = this.model.operation.items[sign]['features'];
                             res.items[i].featureFormat = this.model.operation.items[sign]['featureFormat'];
                             res.items[i].type = this.model.operation.items[sign]['type'];
+                            res.items[i].discount_price = res.items[i].discount_price ? res.items[i].discount_price.split(",") : [""];
                             sign++;
                         }
                         if (res.discount_count)res.isDiscount = true;
                         if (res.total_price)res.isSingle = true;
+
+                        res.discount_count = res.discount_count ? res.discount_count.split(",") : [""];
+                        res.total_discount_price = res.total_discount_price ? res.total_discount_price.split(",") : [""];
+
                         if (params.id) this.selectedModel.operation[params.index] = res;
                         else this.selectedModel.operation.push(res);
-                        this.model.operation = {
-                            operation_type:"入库",
-                            strategy:"默认",
-                            name:"",
-                            feature:"",
-                            items : [
-                                {strategy:"起步",type:"0"},
-                                {strategy:"默认"},
-                                {strategy:"特征"},
-                            ],
-                        };
+                        this._resetOperation();
                         this.errors = [];
                     });
                 },
                 _verifyOperationItem(itemIndex){//验证作业费子项信息完整
                     let obj = this.model.operation.items[itemIndex];
                     let sign = false;
-                    if (obj.strategy === '特征' && !obj.feature){
-                        this.errors['items.'+itemIndex+'.feature'] = ["必须选择特征"];
-                        sign = true;
-                    }
-                    if (this.model.operation.isDiscount && !obj.discount_price){
-                        this.errors['items.'+itemIndex+'.discount_price'] = ["满减单价不得为空"];
+                    if (obj.strategy === '特征' && !obj.feature) {
+                        this.errors['items.' + itemIndex + '.feature'] = ["必须选择特征"];
                         sign = true;
                     }
                     if (obj.strategy!=='起步' && !obj.amount){