fix(ggmx): 规格明细上下架状态不能为空

This commit is contained in:
woody 2025-07-28 11:40:03 +08:00
parent 1e410fb30e
commit a5d5df1bee
2 changed files with 542 additions and 553 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
<template>
<div class="ggmx">
<div class="tit">{{ '规格明细' }}</div>
<div class="goodsAll" v-for="(item, index) in goodList" :key="index">
<div v-for="(item, index) in goodList" :key="index" class="goodsAll">
<div class="goods_t">
<div class="goods_tit">
<div class="goods_tit_1">{{ item.productName }}</div>
@ -25,13 +25,15 @@
<div class="goods_btm">
<el-form label-width="auto">
<el-form-item
:label="child.typeName"
v-for="(child, cindex) in item.specsTypeData"
:key="cindex"
:label="child.typeName"
>
<el-checkbox-group v-model="item.checked">
<el-checkbox
v-for="(sld, sindex) in child.specsList"
:key="sld.specsId"
:label="sld.specsId"
@change="
getCheckBox(
$event,
@ -41,16 +43,13 @@
item.isGift
)
"
:key="sld.specsId"
:label="sld.specsId"
>{{ sld.value }}</el-checkbox
>
>{{ sld.value }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
</div>
</div>
<div class="goods_b" v-show="item.allSel">
<div v-show="item.allSel" class="goods_b">
<div class="pl">
<el-row type="flex" justify="end" :gutter="20">
<el-col :span="2">
@ -58,53 +57,53 @@
</el-col>
<el-col :span="2">
<el-input
clearable
size="medium"
v-model="item.price"
clearable
size="medium"
:placeholder="'产品价格'"
></el-input>
/>
</el-col>
<el-col :span="2" v-if="specialArea == 31">
<el-col v-if="specialArea == 31" :span="2">
<el-input
clearable
size="medium"
v-model="item.vipPrice"
clearable
size="medium"
placeholder="会员价"
></el-input>
/>
</el-col>
<el-col :span="2" v-if="specialArea == 31">
<el-col v-if="specialArea == 31" :span="2">
<el-input
clearable
size="medium"
v-model="item.retailPriced"
clearable
size="medium"
placeholder="零售价"
></el-input>
/>
</el-col>
<el-col :span="2">
<el-input
clearable
size="medium"
v-model="item.integral"
clearable
size="medium"
:placeholder="'产品业绩'"
></el-input>
/>
</el-col>
<el-col :span="2">
<el-input
v-model="item.assAchieve"
clearable
size="medium"
v-model="item.assAchieve"
:placeholder="specialArea == 40 ? 'EV' : 'BV'"
></el-input>
/>
</el-col>
<el-col :span="2">
<el-select clearable size="medium" v-model="item.sj">
<el-select v-model="item.sj" size="medium">
<el-option
v-for="item in agreeList"
:key="item.val"
:label="item.text"
:value="item.val"
></el-option>
/>
</el-select>
</el-col>
<!-- <el-col :span="2">
@ -119,8 +118,7 @@
<el-button
type="primary"
@click="plcz(item.productId, item.isGift)"
>{{ '批量操作' }}</el-button
>
>{{ '批量操作' }}</el-button>
</el-col>
</el-row>
</div>
@ -133,7 +131,7 @@
:row-class-name="tableRowClassName"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column type="selection" width="55" />
<el-table-column
align="center"
width="200"
@ -151,8 +149,7 @@
align="center"
prop="productName"
:label="'产品名称'"
>
</el-table-column>
/>
<el-table-column
v-for="(ctm, index) in item.titName"
:key="index"
@ -168,10 +165,8 @@
<div v-show="index == 5">{{ scope.row.value5 }}</div>
</template>
</el-table-column>
<el-table-column align="center" prop="retailPriceTmp" label="划线价">
</el-table-column>
<el-table-column align="center" prop="quantity" label="数量">
</el-table-column>
<el-table-column align="center" prop="retailPriceTmp" label="划线价" />
<el-table-column align="center" prop="quantity" label="数量" />
<el-table-column
align="center"
prop="productPrice"
@ -179,41 +174,41 @@
>
<template slot-scope="scope">
<el-input
v-model="scope.row.productPrice"
clearable
size="medium"
v-model="scope.row.productPrice"
:placeholder="'请输入'"
></el-input>
/>
</template>
</el-table-column>
<el-table-column
align="center"
v-if="specialArea == 31"
align="center"
prop="vipPrice"
label="会员价"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.vipPrice"
clearable
size="medium"
v-model="scope.row.vipPrice"
:placeholder="'请输入'"
></el-input>
/>
</template>
</el-table-column>
<el-table-column
align="center"
v-if="specialArea == 31"
align="center"
prop="retailPrice"
label="零售价"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.retailPrice"
clearable
size="medium"
v-model="scope.row.retailPrice"
:placeholder="'请输入'"
></el-input>
/>
</template>
</el-table-column>
<el-table-column
@ -223,11 +218,11 @@
>
<template slot-scope="scope">
<el-input
v-model="scope.row.productAchieve"
clearable
size="medium"
v-model="scope.row.productAchieve"
:placeholder="'请输入'"
></el-input>
/>
</template>
</el-table-column>
<el-table-column
@ -237,11 +232,11 @@
>
<template slot-scope="scope">
<el-input
v-model="scope.row.assAchieve"
clearable
size="medium"
v-model="scope.row.assAchieve"
:placeholder="'请输入'"
></el-input>
/>
</template>
</el-table-column>
<el-table-column
@ -250,13 +245,13 @@
:label="'上架状态'"
>
<template slot-scope="scope">
<el-select clearable size="medium" v-model="scope.row.isPutOn">
<el-select v-model="scope.row.isPutOn" size="medium">
<el-option
v-for="item in agreeList"
:key="item.val"
:label="item.text"
:value="item.val"
></el-option>
/>
</el-select>
</template>
</el-table-column>
@ -287,70 +282,70 @@
</template>
<script>
import { getProductSpecsIsGift } from "@/api/product.js";
import { getProductSpecsIsGift } from '@/api/product.js'
// import SkuForm from 'vue-sku-form'
import { mapGetters } from "vuex";
import ImageUpload from "@/components/ImageUpload";
import { mapGetters } from 'vuex'
import ImageUpload from '@/components/ImageUpload'
export default {
name: "ggmx",
name: 'Ggmx',
components: {
// SkuForm,
ImageUpload,
ImageUpload
},
computed: {
...mapGetters(["productIds"]),
...mapGetters(['productIds'])
},
watch: {
goodList: {
handler(newVal, oldVal) {
// console.log('%c [ newVal ]-193', 'font-size:13px; background:#55e8eb; color:#99ffff;', newVal)
this.$emit("getGoodList", newVal, this.copyArr);
this.$emit('getGoodList', newVal, this.copyArr)
// this.fixThing()
},
deep: true, //
},
deep: true //
}
},
data() {
return {
uploadUrl: process.env.VUE_APP_BASE_API + "/manage/upload", //
uploadUrl: process.env.VUE_APP_BASE_API + '/manage/upload', //
agreeList: [
{
text: '允许',
val: 0,
val: 0
},
{
text: '禁止',
val: 1,
},
val: 1
}
],
form: {
specsList: [],
price: "",
productAchieve: "",
sj: "",
xs: "",
integral: "",
assAchieve: "",
price: '',
productAchieve: '',
sj: '',
xs: '',
integral: '',
assAchieve: ''
},
//
selCheckList: [],
// productIds: [],
goodList: [
{
checked: [],
},
checked: []
}
],
allData: [],
copyArr: [],
specialArea: "",
};
specialArea: ''
}
},
mounted() {
// this.getData()
},
methods: {
getSpecial(val) {
this.specialArea = val;
this.specialArea = val
},
// getInput() {
// console.log(
@ -381,10 +376,10 @@ export default {
if (check) {
this.allData.forEach((aTem) => {
if (aTem.productId == goodsId && aTem.isGift == isGift) {
aTem.titName = [];
aTem.titName = []
aTem.selList.forEach((sTem, sIex) => {
if (sTem.selData.indexOf(sTem.typeName) == -1) {
aTem.titName.push(sTem.typeName);
aTem.titName.push(sTem.typeName)
}
if (sTem.pkId == pkId && sTem.selData.indexOf(sld) == -1) {
sTem.selData.push(
@ -395,16 +390,16 @@ export default {
productCover: aTem.productCover,
productId: aTem.productId,
isGift: aTem.isGift,
productName: aTem.productName,
productName: aTem.productName
},
{ typeName: sTem.typeName, pkId: sTem.pkId },
sld
)
);
)
}
});
})
}
});
})
} else {
this.allData.forEach((aTem) => {
if (aTem.productId == goodsId && aTem.isGift == isGift) {
@ -415,11 +410,11 @@ export default {
(sstem) => sstem.specsId === sld.specsId
),
1
);
)
}
});
})
}
});
})
}
// this.allData
// console.log(
@ -428,190 +423,191 @@ export default {
// this.allData
// )
this.pushArr(goodsId, isGift);
this.pushArr(goodsId, isGift)
},
//
pushArr(goodsId, isGift) {
this.allData.forEach((aTem) => {
if (aTem.productId == goodsId && aTem.isGift == isGift) {
aTem.checkList = [];
aTem.checkList = []
aTem.selList.forEach((sTem, sIex) => {
aTem.checkList.push(sTem.selData);
});
aTem.checkList.push(sTem.selData)
})
}
});
this.runFunc(goodsId, isGift);
})
this.runFunc(goodsId, isGift)
},
//
runFunc(goodsId, isGift) {
this.allData.forEach((aTem) => {
if (aTem.productId == goodsId && aTem.isGift == isGift) {
aTem.checkList = this.calcDescartes(aTem.checkList);
aTem.checkList = this.calcDescartes(aTem.checkList)
}
});
})
this.goodList.forEach((item) => {
if (item.productId == goodsId && item.isGift == isGift) {
item.checkList = [];
item.checkList = []
this.allData.forEach((aTem) => {
if (aTem.productId == goodsId && aTem.isGift == isGift) {
aTem.checkList.forEach((cTem) => {
if (item.pkId == aTem.pkid) {
item.checkList.push(cTem);
item.titName = aTem.titName;
item.checkList.push(cTem)
item.titName = aTem.titName
}
});
})
}
});
})
}
});
})
this.goodList.forEach((item, fdex) => {
if (item.productId == goodsId && item.isGift == isGift) {
item.showList = [];
item.showList = []
item.checkList.forEach((ctem, cdex) => {
ctem.assn = {};
ctem.waresSpecsList = [];
ctem.assn = {}
ctem.waresSpecsList = []
if (ctem.forEach) {
ctem.forEach((cld, index) => {
this.$set(
this.goodList[fdex].checkList[cdex],
"productPrice",
""
);
this.$set(this.goodList[fdex].checkList[cdex], "vipPrice", "");
'productPrice',
''
)
this.$set(this.goodList[fdex].checkList[cdex], 'vipPrice', '')
this.$set(
this.goodList[fdex].checkList[cdex],
"retailPrice",
""
);
'retailPrice',
''
)
// this.$set(this.goodList[fdex].checkList[cdex], 'code', '')
this.$set(this.goodList[fdex].checkList[cdex], "isPutOn", 0);
this.$set(this.goodList[fdex].checkList[cdex], 'isPutOn', 0)
this.$set(
this.goodList[fdex].checkList[cdex],
"productAchieve",
""
);
'productAchieve',
''
)
this.$set(
this.goodList[fdex].checkList[cdex],
"assAchieve",
""
);
cld.productPrice = "";
cld.retailPrice = "";
cld.vipPrice = "";
cld.productAchieve = "";
cld.assAchieve = "";
cld.isPutOn = 0;
cld.status = "";
cld.pkProduct = cld.productId;
cld.quantity = item.quantity;
cld.retailPriceTmp = item.retailPriceTmp;
cld.isGift = cld.isGift;
'assAchieve',
''
)
cld.productPrice = ''
cld.retailPrice = ''
cld.vipPrice = ''
cld.productAchieve = ''
cld.assAchieve = ''
cld.isPutOn = 0
cld.status = ''
cld.pkProduct = cld.productId
cld.quantity = item.quantity
cld.retailPriceTmp = item.retailPriceTmp
cld.isGift = cld.isGift
ctem.waresSpecsList.push({
pkSpecs: cld.specsId,
pkSpecsType: cld.pkSpecsType,
});
pkSpecsType: cld.pkSpecsType
})
if (index == 0) {
cld.value0 = cld.value;
cld.pkId0 = cld.pkId;
cld.specsId0 = cld.specsId;
cld.typeName0 = cld.typeName;
cld.pkSpecsType0 = cld.pkSpecsType;
cld.value0 = cld.value
cld.pkId0 = cld.pkId
cld.specsId0 = cld.specsId
cld.typeName0 = cld.typeName
cld.pkSpecsType0 = cld.pkSpecsType
}
if (index == 1) {
cld.value1 = cld.value;
cld.pkId1 = cld.pkId;
cld.specsId1 = cld.specsId;
cld.typeName1 = cld.typeName;
cld.pkSpecsType1 = cld.pkSpecsType;
cld.value1 = cld.value
cld.pkId1 = cld.pkId
cld.specsId1 = cld.specsId
cld.typeName1 = cld.typeName
cld.pkSpecsType1 = cld.pkSpecsType
}
if (index == 2) {
cld.value2 = cld.value;
cld.pkId2 = cld.pkId;
cld.specsId2 = cld.specsId;
cld.typeName2 = cld.typeName;
cld.pkSpecsType2 = cld.pkSpecsType;
cld.value2 = cld.value
cld.pkId2 = cld.pkId
cld.specsId2 = cld.specsId
cld.typeName2 = cld.typeName
cld.pkSpecsType2 = cld.pkSpecsType
}
if (index == 3) {
cld.value3 = cld.value;
cld.pkId3 = cld.pkId;
cld.specsId3 = cld.specsId;
cld.typeName3 = cld.typeName;
cld.pkSpecsType3 = cld.pkSpecsType;
cld.value3 = cld.value
cld.pkId3 = cld.pkId
cld.specsId3 = cld.specsId
cld.typeName3 = cld.typeName
cld.pkSpecsType3 = cld.pkSpecsType
}
if (index == 4) {
cld.value4 = cld.value;
cld.pkId4 = cld.pkId;
cld.specsId4 = cld.specsId;
cld.typeName4 = cld.typeName;
cld.pkSpecsType4 = cld.pkSpecsType;
cld.value4 = cld.value
cld.pkId4 = cld.pkId
cld.specsId4 = cld.specsId
cld.typeName4 = cld.typeName
cld.pkSpecsType4 = cld.pkSpecsType
}
if (index == 5) {
cld.value5 = cld.value;
cld.pkId5 = cld.pkId;
cld.specsId5 = cld.specsId;
cld.typeName5 = cld.typeName;
cld.pkSpecsType5 = cld.pkSpecsType;
cld.value5 = cld.value
cld.pkId5 = cld.pkId
cld.specsId5 = cld.specsId
cld.typeName5 = cld.typeName
cld.pkSpecsType5 = cld.pkSpecsType
}
item.showList.push(
Object.assign(ctem.assn, cld, {
waresSpecsList: ctem.waresSpecsList,
waresSpecsList: ctem.waresSpecsList
})
);
)
// item.showList[cdex].waresSpecsList.push(cld.waresSpecs)
});
})
} else {
ctem.waresSpecsList = [
{
pkSpecs: ctem.specsId,
pkSpecsType: ctem.pkSpecsType,
},
];
pkSpecsType: ctem.pkSpecsType
}
]
this.$set(
this.goodList[fdex].checkList[cdex],
"productPrice",
""
);
this.$set(this.goodList[fdex].checkList[cdex], "retailPrice", "");
this.$set(this.goodList[fdex].checkList[cdex], "vipPrice", "");
'productPrice',
''
)
this.$set(this.goodList[fdex].checkList[cdex], 'retailPrice', '')
this.$set(this.goodList[fdex].checkList[cdex], 'vipPrice', '')
// this.$set(this.goodList[fdex].checkList[cdex], 'code', '')
this.$set(this.goodList[fdex].checkList[cdex], "isPutOn", 0);
this.$set(this.goodList[fdex].checkList[cdex], "assAchieve", 0);
this.$set(this.goodList[fdex].checkList[cdex], 'isPutOn', 0)
this.$set(this.goodList[fdex].checkList[cdex], 'assAchieve', 0)
this.$set(
this.goodList[fdex].checkList[cdex],
"productAchieve",
'productAchieve',
0
);
)
// this.$set(this.goodList[index].checkList[cdex], 'productPrice', '')
// this.$set(this.goodList[index].checkList[cdex], 'productPrice', '')
// this.$set(item.checkList, ctem.integral, '')
// this.$set(item.checkList, ctem.isPutOn, '')
// this.$set(item.checkList, ctem.status, '')
ctem.pkProduct = ctem.productId;
ctem.quantity = item.quantity;
ctem.retailPriceTmp = item.retailPriceTmp;
ctem.isGift = ctem.isGift;
ctem.value0 = ctem.value;
ctem.pkId0 = ctem.pkId;
ctem.specsId0 = ctem.specsId;
ctem.typeName0 = ctem.typeName;
ctem.pkSpecsType0 = ctem.pkSpecsType;
item.showList.push(ctem);
ctem.pkProduct = ctem.productId
ctem.quantity = item.quantity
ctem.retailPriceTmp = item.retailPriceTmp
ctem.isGift = ctem.isGift
ctem.value0 = ctem.value
ctem.pkId0 = ctem.pkId
ctem.specsId0 = ctem.specsId
ctem.typeName0 = ctem.typeName
ctem.pkSpecsType0 = ctem.pkSpecsType
item.showList.push(ctem)
}
});
})
}
});
})
this.goodList.forEach((item) => {
if (item.productId == goodsId && item.isGift == isGift) {
item.showList = this.unique(item.showList);
item.showList = this.unique(item.showList)
if (item.showList.length > 0 && item.showList[0].pkId0) {
item.allSel = true;
item.allSel = true
} else {
item.allSel = false;
item.allSel = false
}
}
});
})
this.goodList.forEach((item) => {
item.sj = this.agreeList[0].val
if (item.showList) {
item.showList.forEach((cld) => {
cld.specsIdList = [
@ -620,13 +616,13 @@ export default {
cld.specsId2,
cld.specsId3,
cld.specsId4,
cld.specsId5,
].filter(Boolean);
});
cld.specsId5
].filter(Boolean)
})
}
});
this.copyArr = JSON.parse(JSON.stringify(this.allData));
this.$forceUpdate();
})
this.copyArr = JSON.parse(JSON.stringify(this.allData))
this.$forceUpdate()
},
// //
// fixThing() {
@ -648,17 +644,17 @@ export default {
//
if (arr[i] == arr[j]) {
//
arr.splice(j, 1); //
j--;
arr.splice(j, 1) //
j--
}
}
}
return arr;
return arr
},
calcDescartes(array) {
// if (array.length < 2) return array[0] || []
return array.reduce((total, currentValue) => {
let res = [];
const res = []
// if (total.length == 0) {
// res.push([cv])
// }
@ -667,18 +663,17 @@ export default {
currentValue.forEach((cv) => {
if (t instanceof Array)
// 使 Array.isArray(t)
res.push([...t, cv]);
else res.push([t, cv]);
});
{ res.push([...t, cv]) } else res.push([t, cv])
})
} else {
res.push([t]);
res.push([t])
}
});
return res;
});
})
return res
})
},
handleSelectionChange(val) {
this.selCheckList = val;
this.selCheckList = val
},
plcz(productId, isGift) {
this.goodList.forEach((item, index) => {
@ -692,74 +687,74 @@ export default {
cld.specsIdList.sort().toString()
) {
if (item.price) {
sld.productPrice = item.price;
sld.productPrice = item.price
this.$set(
this.goodList[index].showList[sndex],
"productPrice",
'productPrice',
item.price
);
this.$forceUpdate();
)
this.$forceUpdate()
}
if (item.retailPriced) {
sld.retailPrice = item.retailPriced;
sld.retailPrice = item.retailPriced
this.$set(
this.goodList[index].showList[sndex],
"retailPrice",
'retailPrice',
item.retailPriced
);
this.$forceUpdate();
)
this.$forceUpdate()
}
if (item.vipPrice) {
sld.vipPrice = item.vipPrice;
sld.vipPrice = item.vipPrice
this.$set(
this.goodList[index].showList[sndex],
"vipPrice",
'vipPrice',
item.vipPrice
);
this.$forceUpdate();
)
this.$forceUpdate()
}
if (item.integral) {
sld.productAchieve = item.integral;
sld.productAchieve = item.integral
this.$set(
this.goodList[index].showList[sndex],
"productAchieve",
'productAchieve',
item.integral
);
this.$forceUpdate();
)
this.$forceUpdate()
}
if (item.assAchieve) {
sld.assAchieve = item.assAchieve;
sld.assAchieve = item.assAchieve
this.$set(
this.goodList[index].showList[sndex],
"assAchieve",
'assAchieve',
item.assAchieve
);
this.$forceUpdate();
)
this.$forceUpdate()
}
if (item.productAchieve) {
sld.productAchieve = item.productAchieve;
sld.productAchieve = item.productAchieve
}
if (item.sj != "" || item.sj != undefined) {
if (item.sj != '' || item.sj != undefined) {
// console.log(
// '%c [ item.sj ]-555',
// 'font-size:13px; background:#2d4cc6; color:#7190ff;',
// item.sj
// )
sld.isPutOn = item.sj;
sld.isPutOn = item.sj
this.$set(
this.goodList[index].showList[sndex],
"isPutOn",
'isPutOn',
item.sj
);
this.$forceUpdate();
)
this.$forceUpdate()
}
if (item.xs) {
sld.status = item.xs;
sld.status = item.xs
}
// this.$set(this.goodList[index].showList[sndex], isPutOn, item.sj)
}
this.$set(this.goodList[index].showList, sndex, sld);
});
this.$set(this.goodList[index].showList, sndex, sld)
})
}
// if (item.productId == productId) {
// if (item.price != '') {
@ -775,82 +770,82 @@ export default {
// cld.status = item.xs
// }
// }
});
});
})
})
// this.selCheckList
// console.log(this.$refs.multipleTable)
// this.$set('this','goodList',this.goodList)
this.$forceUpdate();
this.$forceUpdate()
this.$nextTick(() => {
for (var i = 0; i < this.$refs.multipleTable.length; i++) {
this.$refs.multipleTable[i].clearSelection();
this.$refs.multipleTable[i].clearSelection()
}
});
})
},
compareArrays(arr1, arr2) {
if (arr1.length !== arr2.length) {
return false;
return false
}
for (let i = 0; i < arr1.length; i++) {
if (arr1[i] !== arr2[i]) {
return false;
return false
}
}
return true;
return true
},
getData(data, specialArea) {
this.specialArea = specialArea;
this.specialArea = specialArea
if (this.productIds.length > 0) {
let a = this.compareArrays(this.productIds, data);
const a = this.compareArrays(this.productIds, data)
if (a) {
} else {
this.getList(data);
this.$store.commit("settings/GGMX_SETTING", data);
this.getList(data)
this.$store.commit('settings/GGMX_SETTING', data)
}
} else {
this.getList(data);
this.$store.commit("settings/GGMX_SETTING", data);
this.getList(data)
this.$store.commit('settings/GGMX_SETTING', data)
}
},
getList(data) {
getProductSpecsIsGift({ productGiftList: data }).then((res) => {
let arr = res.data;
const arr = res.data
//
let allData = [];
const allData = []
arr.forEach((item, index) => {
item.checked = [];
item.checked = []
allData.push({
productId: item.productId,
productCode: item.productCode,
productCover: item.productCover,
productName: item.productName,
selList: [],
isGift: item.isGift,
});
isGift: item.isGift
})
item.specsTypeData.forEach((cld) => {
allData[index].selList.push({
pkId: cld.pkId,
typeName: cld.typeName,
selData: [],
});
});
});
this.allData = allData;
this.goodList = arr;
});
selData: []
})
})
})
this.allData = allData
this.goodList = arr
})
},
tableRowClassName({ row, rowIndex }) {
if (rowIndex % 2 == 1) {
return "warning-row";
return 'warning-row'
} else if (rowIndex % 2 == 0) {
return "success-row";
return 'success-row'
}
return "";
},
},
};
return ''
}
}
}
</script>
<style scoped lang="scss">