|
|
@@ -3,18 +3,18 @@
|
|
|
<el-tabs tab-position="left" style="height: 100%; overflow: auto;" v-model="tabValue" @tab-click="handleClick">
|
|
|
<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-all="handleAllSelect">
|
|
|
- <el-table-column type="selection" width="55">
|
|
|
+ <el-table :data="tableData" style="width: 100%" border :ref="'multipleTable_' + tabValue" stripe highlight-current-row
|
|
|
+ @select="handleSelectionChange" @select-all="handleAllSelect" @current-change="handleCurrentChange">
|
|
|
+ <el-table-column type="index" width="55">
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="name" label="规格" align="center">
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="packet" label="包装箱" align="center">
|
|
|
+ <!-- <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="price" label="发货价" align="center" ></el-table-column>
|
|
|
+ <el-table-column prop="price" label="发货价" align="center" ></el-table-column> -->
|
|
|
|
|
|
</el-table>
|
|
|
</el-tabs>
|
|
|
@@ -42,39 +42,36 @@
|
|
|
},
|
|
|
options: Yunqi.data.packingList,//品种
|
|
|
tabValue: Object.entries(Yunqi.data.typeList).map(([value, label]) => ({ label, value }))[0].value, //选中的品种 获取到品种数据后要给他默认赋值第一个
|
|
|
-
|
|
|
chooseSpec: [], // 当前分类选中的规格
|
|
|
-
|
|
|
allData: {},
|
|
|
- type: 1, // 1编辑 0新增
|
|
|
+ type: 0, // 1编辑 0新增
|
|
|
},
|
|
|
methods: {
|
|
|
onSubmit() {
|
|
|
-
|
|
|
if (this.allData == "") return;
|
|
|
let arr = Object.values(this.allData).flat(Infinity)
|
|
|
-
|
|
|
- Yunqi.ajax.post('shop/shop_list/specs', { ids: Yunqi.data.ids, all_data: arr }, false, false, true).then(res => {
|
|
|
+ Yunqi.ajax.post('goods/fengsu_ship/specs', { ids: Yunqi.data.row.id, all_data: arr }, false, false, true).then(res => {
|
|
|
if (res.code == 200) {
|
|
|
this.$message.success(__('设置成功'));
|
|
|
//倒计时刷新窗口
|
|
|
setTimeout(() => {
|
|
|
Yunqi.api.closelayer(Yunqi.app.window.id, true);
|
|
|
}, 1000);
|
|
|
+
|
|
|
} else {
|
|
|
Yunqi.alert(__('请填写发货价格'), __('温馨提示'), { type: 'error' });
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
},
|
|
|
handleAllSelect(e){
|
|
|
this.allData[this.tabValue] = e || []
|
|
|
},
|
|
|
+ handleCurrentChange(e){
|
|
|
+
|
|
|
+ this.allData[this.tabValue] = e || []
|
|
|
+ },
|
|
|
handleSelectionChange(e) {
|
|
|
- //console.log(e,"选中的数据")
|
|
|
- // if (e.length > 0) {
|
|
|
- this.allData[this.tabValue] = e || []
|
|
|
- // }
|
|
|
+ console.log(this.allData,"=====this.allData")
|
|
|
},
|
|
|
handleClick(data, row) {
|
|
|
// 品种切换事件 可以在这里请求规格接口
|
|
|
@@ -86,15 +83,15 @@
|
|
|
getSpecData() {
|
|
|
|
|
|
//获取规格 ;
|
|
|
- Yunqi.ajax.get('shop/shop_list/get_box', { ids: Yunqi.data.ids, type_id: this.tabValue }, false, false, true).then(res => {
|
|
|
+ Yunqi.ajax.get('shop/customer_spec/get_box', { type_id: this.tabValue }, false, false, true).then(res => {
|
|
|
//编辑数据
|
|
|
if (res.length > 0) {
|
|
|
for (var key in Object(res)) {
|
|
|
- let index = this.tableData.findIndex(item => item.value == res[key]['id']);
|
|
|
+ let index = this.tableData.findIndex(item => item.id == 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'],box_name: res[key]['box_name'], type_name: res[key]['type_name'], type_id: this.tabValue });
|
|
|
+ this.tableData.push({name: res[key]['title'], id: res[key]['id'], type_id: this.tabValue });
|
|
|
}
|
|
|
}
|
|
|
this.$nextTick(() => {
|
|
|
@@ -102,15 +99,14 @@
|
|
|
if (this.type == 0 && this.allData[this.tabValue]?.length > 0 && tableRef) {
|
|
|
this.tableData.forEach((item, index) => {
|
|
|
const matched = this.allData[this.tabValue].find(row => {
|
|
|
- return row.value == item.value
|
|
|
+ return row.id == item.id
|
|
|
});
|
|
|
-
|
|
|
if (matched) {
|
|
|
this.tableData[index] = matched
|
|
|
}
|
|
|
})
|
|
|
this.allData[this.tabValue].forEach(selected => {
|
|
|
- const matched = this.tableData.find(row => row.value === selected.value);
|
|
|
+ const matched = this.tableData.find(row => row.id === selected.id);
|
|
|
if (matched) {
|
|
|
this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
|
|
|
}
|
|
|
@@ -124,9 +120,7 @@
|
|
|
} 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) {
|
|
|
@@ -152,7 +146,6 @@
|
|
|
this.$refs['multipleTable_' + this.tabValue].toggleRowSelection(matched, true); // 勾选
|
|
|
}
|
|
|
});
|
|
|
- // this.type = 0
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -161,22 +154,8 @@
|
|
|
|
|
|
},
|
|
|
onLoad: function (query) {
|
|
|
- let row = Yunqi.data.row;
|
|
|
- if (row) {
|
|
|
- this.type = 1
|
|
|
- const grouped = JSON.parse(row).reduce((acc, item) => {
|
|
|
- const key = item.type_id;
|
|
|
- if (!acc[key]) {
|
|
|
- acc[key] = [];
|
|
|
- }
|
|
|
-
|
|
|
- acc[key].push(item);
|
|
|
- return acc;
|
|
|
- }, {});
|
|
|
- this.allData = JSON.parse(JSON.stringify(grouped))
|
|
|
- } else {
|
|
|
- this.type = 0
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
//你只需要保存规格是吧, 是你末尾加了个row
|
|
|
this.getSpecData()
|
|
|
},
|