Browse Source

规格设置

afa 4 months ago
parent
commit
3cd1b46882

+ 3 - 0
app/admin/controller/shop/CustomerSpec.php

@@ -31,6 +31,7 @@ class CustomerSpec extends Backend
         $this->model = new CustomerSpecModel();
         $this->assign('typeList',  StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title','id'));
         $this->assign('packingList', StockConfig::where('type_id', 'packing_box')->column('title','id'));
+        $this->assign('fastmailList', explode("\n", site_config('addonsd.fast_mail')));
         $this->relationField=['customer'];
     }
 
@@ -78,12 +79,14 @@ class CustomerSpec extends Backend
                         'product_id'  => $item['value'],
                         'box_id'      => $item['packet']??0,
                         'price'       => $item['price']??0,
+                        'fast_mail'   => $item['fast_mail']
 
                     ]);
                     $result++;
                 }else{
                     $row->box_id = $item['packet']??0;
                     $row->price  = $item['price']??0;
+                    $row->fast_mail  = $item['fast_mail']??0;
                     $row->status  = 1;
                     $row->save();
                     $result++;

+ 4 - 4
app/admin/controller/shop/ShopList.php

@@ -30,8 +30,7 @@ class ShopList extends Backend
         $this->assign('customerList', Customer::where('status', 1)->column('name','id'));
         $this->assign('platformList', site_config('addonsd.platform_list'));
         $this->assign('userList', User::where('status',Customer::STATUS_NORMAL)->column('nickname','id'));
-        $this->assign('fieldList', StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title','id'));
-
+        $this->assign('fastmailList', explode("\n", site_config('addonsd.fast_mail')));
         $this->assign('typeList',  StockConfig::where('type_id', 'variety_name')->order('sort desc')->column('title','id'));
         $this->assign('packingList', StockConfig::where('type_id', 'packing_box')->column('title','id'));
         $this->relationField=['customer','staff'];
@@ -69,8 +68,9 @@ class ShopList extends Backend
             if(empty($ids) || empty($type_id)) return resp_json(0, '参数错误');
             $customer_id = $this->model::where('id', $ids)->value('customer_id');
             $rows = CustomerSpec::alias('a')
-                ->leftjoin('product_config b', 'a.product_id=b.id')
-                ->field('a.*,b.title')
+                ->leftjoin('product_config b', 'a.product_id=b.id') //品种
+                ->leftjoin('stock_config c', 'a.box_id=c.id') //包装箱
+                ->field('a.*,b.title as type_name,c.title as box_name')
                 ->where('a.type_id', $type_id)
                 ->where('a.customer_id', $customer_id)
                 ->where('a.status', CustomerSpec::NORMAL)

+ 51 - 10
app/admin/view/shop/customer_spec/add.html

@@ -8,23 +8,31 @@
             </el-tab-pane>
 
             <el-table :data="tableData" style="width: 100%" border :ref="'multipleTable_' + tabValue" stripe
-                @select="handleSelectionChange">
+                @select="handleSelectionChange" @select-all="handleAllSelect">
                 <el-table-column type="selection" width="55">
                 </el-table-column>
-                <el-table-column prop="name" label="规格" align="center">
+                <el-table-column prop="type_name" label="规格" align="center">
                 </el-table-column>
                 <el-table-column prop="packet" label="包装箱" align="center">
                     <template #default="{row}">
-                        <el-select v-model="row.packet" placeholder="请选择">
+                        <el-select v-model="row.packet" placeholder="请选择" @change="changePacket($event, row)">
                             <el-option v-for="item in options" :key="item.value" :label="item.label"
                                 :value="item.value">
                             </el-option>
                         </el-select>
                     </template>
                 </el-table-column>
+                <el-table-column prop="fast_mail" label="快递" align="center">
+                    <template #default="{row}">
+                        <el-select v-model="row.fast_mail" placeholder="请选择" @change="changeLogi($event, row)">
+                            <el-option v-for="item in logiOptions" :key="item" :label="item" :value="item">
+                            </el-option>
+                        </el-select>
+                    </template>
+                </el-table-column>
                 <el-table-column prop="price" label="发货价" align="center">
                     <template #default="{row}">
-                        <el-input v-model="row.price"></el-input>
+                        <el-input v-model="row.price" @input="changePrice($event, row)"></el-input>
                     </template>
                 </el-table-column>
             </el-table>
@@ -53,7 +61,7 @@
             },
             options: Object.entries(Yunqi.data.packingList).map(([value, label]) => ({ label, value: value.toString() })),//品种
             tabValue: Object.entries(Yunqi.data.typeList).map(([value, label]) => ({ label, value }))[0].value, //选中的品种 获取到品种数据后要给他默认赋值第一个
-
+            logiOptions: Yunqi.data.fastmailList,
             chooseSpec: [], // 当前分类选中的规格  
 
             allData: {},
@@ -84,6 +92,9 @@
                 this.allData[this.tabValue] = e || []
                 // }
             },
+            handleAllSelect(e){
+                this.allData[this.tabValue] = e || []
+            },
             handleClick(data, row) {
                 // 品种切换事件 可以在这里请求规格接口
 
@@ -106,12 +117,13 @@
                             if (index != -1) {
                                 this.tableData.splice(index, 1)
                             } else {
-                                this.tableData.push({ name: res[key]['title'], value: res[key]['id'], price: res[key]['price'], type_id: this.tabValue });
+                                this.tableData.push({  value: res[key]['id'], price: res[key]['price'], type_id: this.tabValue, fast_mail: res[key]['fast_mail'] });
                             }
                         }
                         this.$nextTick(() => {
                             const tableRef = this.$refs['multipleTable_' + this.tabValue];
                             if (this.type == 0 && this.allData[this.tabValue]?.length > 0 && tableRef) {
+                                console.log(this.allData[Number(this.tabValue)], this.tableData, "===")
                                 this.tableData.forEach((item, index) => {
                                     const matched = this.allData[this.tabValue].find(row => {
                                         return row.value == item.value
@@ -129,6 +141,7 @@
                                 });
                             }
                             else if (this.type == 1 && this.allData[Number(this.tabValue)]) {
+                                console.log(this.allData[Number(this.tabValue)], this.tableData)
                                 this.tableData.forEach((item, index) => {
                                     const matched = this.allData[Number(this.tabValue)].find(row => {
                                         if (row.product_id) {
@@ -136,13 +149,13 @@
                                         } else {
                                             return row.value == item.value
                                         }
-
                                     });
                                     if (matched) {
                                         // this.tableData[index] = { name: 'kam', value: 3, price: '111', type_id: '4', packet: '3' }
                                         if (matched.product_id) {
                                             this.tableData[index].price = matched.price
                                             this.tableData[index].packet = matched.box_id != 0 ? matched?.box_id.toString() : ""
+                                            this.tableData[index].fast_mail = matched.fast_mail
                                         } else {
                                             this.tableData[index] = matched
                                         }
@@ -165,8 +178,34 @@
                         });
                     }
                 });
-            }
-
+            },
+            changeLogi(value, row) {
+                if (this.allData[this.tabValue].length > 0) {
+                   this.allData[this.tabValue].forEach((item, index) => {
+                        if (item.product_id == row.value) {
+                            this.allData[this.tabValue][index].fast_mail = value
+                        }
+                    }) 
+                }
+                
+            },
+            changePacket(value, row) {
+                if (this.allData[this.tabValue].length > 0) {
+                    this.allData[this.tabValue].forEach((item, index) => {
+                        if (item.product_id == row.value) {
+                            this.allData[this.tabValue][index].packet = value
+                            this.allData[this.tabValue][index].box_id = value
+                        }
+                    })
+                }
+            },
+            changePrice(value, row) {
+                this.allData[this.tabValue].forEach((item, index) => {
+                    if (item.product_id == row.value) {
+                        this.allData[this.tabValue][index].price = value
+                    }
+                })
+            },
         },
         onLoad: function (query) {
             let row = Yunqi.data.row;
@@ -175,7 +214,9 @@
             } else {
                 this.type = 0
             }
-            console.log(this.type)
+            // Yunqi.data.fastmailList 快递 1111
+            console.log(Yunqi.data.fastmailList, "快递")
+            console.log(row, "-----")
             const grouped = row.reduce((acc, item) => {
                 const key = item.type_id;
                 if (!acc[key]) {

+ 15 - 3
app/admin/view/shop/shop_list/specs.html

@@ -4,16 +4,17 @@
             <el-tab-pane v-for="(item,index) in tabData" :label="item.label" :name="item.value">
             </el-tab-pane>
             <el-table :data="tableData" style="width: 100%" border :ref="'multipleTable_' + tabValue" stripe
-                @select="handleSelectionChange">
+                @select="handleSelectionChange" @select-all="handleAllSelect">
                 <el-table-column type="selection" width="55">
                 </el-table-column>
-                <el-table-column prop="name" label="规格" align="center">
+                <el-table-column prop="type_name" label="规格" align="center">
                 </el-table-column>
                 <el-table-column prop="packet" label="包装箱" align="center">
                     <template #default="{row}">
                         <span>{{options[row.box_id]}}</span>
                     </template>
                 </el-table-column>
+                <el-table-column prop="fast_mail" label="快递" align="center" ></el-table-column>
                 <el-table-column prop="price" label="发货价" align="center" ></el-table-column>
                     
             </el-table>
@@ -67,6 +68,9 @@
                 });
 
             },
+            handleAllSelect(e){
+                this.allData[this.tabValue] = e || []
+            },
             handleSelectionChange(e) {
                 //console.log(e,"选中的数据")
                 // if (e.length > 0) {
@@ -85,15 +89,20 @@
                 //获取规格 ;
                 Yunqi.ajax.get('shop/shop_list/get_box', { ids: Yunqi.data.ids, type_id: this.tabValue }, false, false, true).then(res => {
                     //编辑数据
+
+                    console.log(res,"res-----------")
+
                     if (res.length > 0) {
                         for (var key in Object(res)) {
                             let index = this.tableData.findIndex(item => item.value == res[key]['id']);
                             if (index != -1) {
                                 this.tableData.splice(index, 1)
                             } else {
-                                this.tableData.push({ name: res[key]['title'], value: res[key]['product_id'], price: res[key]['price'], box_id: res[key]['box_id'], type_id: this.tabValue });
+                                this.tableData.push({  value: res[key]['product_id'], price: res[key]['price'], box_id: res[key]['box_id'], fast_mail: res[key]['fast_mail'],box_name: res[key]['box_name'], type_name: res[key]['type_name'], type_id: this.tabValue });
                             }
                         }
+                        console.log(this.tableData,"获取到的表格数据");
+                        
                         this.$nextTick(() => {
                             const tableRef = this.$refs['multipleTable_' + this.tabValue];
                             if (this.type == 0 && this.allData[this.tabValue]?.length > 0 && tableRef) {
@@ -127,6 +136,8 @@
                                     if (matched) {
                                         // this.tableData[index] = { name: 'kam', value: 3, price: '111', type_id: '4', packet: '3' }
                                         if (matched.product_id) {
+                                            this.tableData[index].box_name = matched.box_name
+                                            this.tableData[index].type_name = matched.type_name
                                             this.tableData[index].price = matched.price
                                             this.tableData[index].packet = matched.box_id != 0 ? matched?.box_id.toString() : ""
                                         } else {
@@ -156,6 +167,7 @@
         },
         onLoad: function (query) {
             let row = Yunqi.data.row;
+            console.log(row, '===')
             if (row) {
                 this.type = 1
                 const grouped = JSON.parse(row).reduce((acc, item) => {

+ 1 - 1
app/api/controller/Index.php

@@ -90,7 +90,7 @@ class Index extends Base
                   $this->error('参数有误');
             }
             $spec = $shopList->where('id', $shop_id)->value('type_spec');
-            $shopList = $spec?json_decode($spec, true): [];
+            $shopList = [];
             
             return $this->success('ok', $shopList);  
       }