+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 立即同步
+ 取消
+
+ >
+
+
+
+
+
+
+
+
+
+
+
+ {{scope.row[column.prop]}}
+
+
+
+
+
+
+
上一步
下一步
@@ -210,11 +306,32 @@ export default {
data() {
return {
tableColumnHeaderTemplate:[],
+ tableBodyTemplate:[
+ // {'stock':'商品库存1',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
+ // {'stock':'商品库存2',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
+ // {'stock':'商品库存3',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
+ // {'stock':'商品库存4',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
+ // {'stock':'商品库存5',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
+ // {'stock':'商品库存6',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
+ // {'stock':'商品库存7',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
+ // {'stock':'商品库存8',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
+ // {'stock':'商品库存9',price: "1",purchasePrice:"1",sellingPrice:"1",image:"1",number:"1",weight:"1",volume:"1"},
+ ],
active: 0,
rule: [],
+ ruleAttrList:[],
brandList:[],
ruleList:[],
tableData:[],
+ skuFormTemplate:{
+ 'stock': '0',
+ 'price': '0',
+ purchasePrice: '0',
+ sellingPrice: '0',
+ image: '',
+ number: '0',
+ weight: '0',
+ volume: '0'},
// 遮罩层
loading: true,
// 选中数组
@@ -262,21 +379,64 @@ export default {
this.initRuleListInfo();
},
methods: {
- changeRuleInfoListByRuleId(object){
- this.tableColumnHeaderTemplate = [];
- let ruleInfo = null
- this.ruleList.forEach(item => {
- if(object == item.id){
- ruleInfo = item;
- }
- })
- if(null == ruleInfo){
- return;
+ onSubmit(){
+ this.settingsOrnClear(true)
+ },
+
+ onClear(){
+ this.settingsOrnClear();
+ },
+
+ settingsOrnClear(flag){
+ for (let skuFormTemplateKey in this.skuFormTemplate) {
+ this.tableBodyTemplate.forEach(item=>{
+ for (let itemKey in item) {
+ if(skuFormTemplateKey==itemKey){
+ if(flag){
+ item[itemKey]=this.skuFormTemplate[skuFormTemplateKey]
+ }else{
+ item[itemKey]=''
+ }
+ }
+ }
+ });
}
- let ruleAttrJson=JSON.parse(ruleInfo.ruleAttr)
- ruleAttrJson.forEach(ruleAttr => {
- this.tableColumnHeaderTemplate.push({'prop':'xxx','label':ruleAttr.ruleType})
- })
+ },
+
+ changeRuleInfoListByRuleId(object) {
+ this.tableColumnHeaderTemplate = [];
+ this.tableBodyTemplate = [];
+ let ruleInfo = this.ruleList.find(item => object == item.id);
+ if (!ruleInfo) {
+ return;
+ }
+
+ let ruleAttrJson;
+ try {
+ ruleAttrJson = JSON.parse(ruleInfo.ruleAttr);
+ } catch (error) {
+ console.error('Error parsing ruleAttr JSON:', error);
+ return;
+ }
+
+ ruleAttrJson.forEach((ruleAttr, index) => {
+ this.tableColumnHeaderTemplate.push({'prop': `xxx${index}`, 'label': ruleAttr.ruleType});
+ });
+
+ const cartesian = (ruleAttrJson, index, current) => {
+ if (index === ruleAttrJson.length) {
+ this.tableBodyTemplate.push({...current});
+ return;
+ }
+ for (let i = 0; i < ruleAttrJson[index].ruleAttrList.length; i++) {
+ const updatedCurrent = {...current}; // Create a copy of current object
+ updatedCurrent[`xxx${index}`] = ruleAttrJson[index].ruleAttrList[i];
+ cartesian(ruleAttrJson, index + 1, updatedCurrent);
+ }
+ };
+
+ cartesian(ruleAttrJson, 0, {});
+
this.tableColumnHeaderTemplate.push(
{prop:'stock',label:'商品库存'},
{prop:'price',label:'商品价格'},
diff --git a/src/views/product/rule/index.vue b/src/views/product/rule/index.vue
index e4e0115..381e676 100644
--- a/src/views/product/rule/index.vue
+++ b/src/views/product/rule/index.vue
@@ -1,20 +1,12 @@
-
-
+
-
-
-
@@ -69,19 +61,34 @@
-
-
- 商品规格数据列表
-
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+ {{ rule.ruleType }}
+
+
+
+
+
+ {{ ruleAttr }}
+
+
+
+
+
+
+
+
+
+
+ 创建
+ 取 消
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 创建
+ 取 消
+
+
+
@@ -127,17 +184,15 @@
取 消
-