fix(GoodsStock.vue): 商品保存图片丢失问题修复
This commit is contained in:
@@ -253,15 +253,16 @@ const { specForm, skuForm, specTitles, rules, colors, tagInputs, loading } =
|
|||||||
|
|
||||||
watch(
|
watch(
|
||||||
categoryId,
|
categoryId,
|
||||||
(newVal, oldVal) => {
|
(value) => {
|
||||||
|
|
||||||
// 商品编辑不加载分类下的规格
|
// 商品编辑不加载分类下的规格
|
||||||
const spuId = props.modelValue.id;
|
const spuId = props.modelValue.id;
|
||||||
if (spuId) {
|
if (spuId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (newVal) {
|
if (value) {
|
||||||
// type=1 商品分类下的规格
|
// type=1 商品分类下的规格
|
||||||
listAttributes({ categoryId: newVal, type: 1 }).then((response) => {
|
listAttributes({ categoryId: value, type: 1 }).then((response) => {
|
||||||
const specList = response.data;
|
const specList = response.data;
|
||||||
if (specList && specList.length > 0) {
|
if (specList && specList.length > 0) {
|
||||||
specList.forEach((item) => {
|
specList.forEach((item) => {
|
||||||
@@ -281,6 +282,12 @@ watch(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
watch(state.specForm.specList,(value)=>{
|
||||||
|
generateSkuList()
|
||||||
|
})
|
||||||
|
|
||||||
function loadData() {
|
function loadData() {
|
||||||
props.modelValue.specList.forEach((specItem) => {
|
props.modelValue.specList.forEach((specItem) => {
|
||||||
const specIndex = state.specForm.specList.findIndex(
|
const specIndex = state.specForm.specList.findIndex(
|
||||||
@@ -372,16 +379,18 @@ function handleSpecReorder() {
|
|||||||
* ]
|
* ]
|
||||||
*/
|
*/
|
||||||
function generateSkuList() {
|
function generateSkuList() {
|
||||||
const specList = JSON.parse(
|
|
||||||
JSON.stringify(
|
|
||||||
state.specForm.specList.filter((item) => item.values.length > 0)
|
|
||||||
)
|
|
||||||
); // 深拷贝,取有属性的规格项,否则笛卡尔积运算得到的SKU列表值为空
|
|
||||||
// 如果规格为空,生成SKU列表为空
|
// 如果规格为空,生成SKU列表为空
|
||||||
if (specList.length === 0) {
|
if(state.specForm.specList.length==0){
|
||||||
state.skuForm.skuList = [];
|
state.skuForm.skuList = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const specList = JSON.parse(
|
||||||
|
JSON.stringify(
|
||||||
|
state.specForm.specList.filter((item) => item.values&&item.values.length > 0)
|
||||||
|
)
|
||||||
|
); // 深拷贝,取有属性的规格项,否则笛卡尔积运算得到的SKU列表值为空
|
||||||
|
|
||||||
const skuList = specList.reduce(
|
const skuList = specList.reduce(
|
||||||
(acc, curr) => {
|
(acc, curr) => {
|
||||||
let result = [];
|
let result = [];
|
||||||
@@ -447,7 +456,7 @@ function handleSpecAdd() {
|
|||||||
ElMessage.warning("最多支持3组规格");
|
ElMessage.warning("最多支持3组规格");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.specForm.specList.push({});
|
state.specForm.specList.push({values:[]});
|
||||||
state.tagInputs.push({ value: undefined, visible: false });
|
state.tagInputs.push({ value: undefined, visible: false });
|
||||||
handleSpecReorder();
|
handleSpecReorder();
|
||||||
}
|
}
|
||||||
@@ -695,7 +704,7 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-form-item--mini.el-form-item {
|
.el-form--inline .el-form-item{
|
||||||
margin-top: 18px;
|
margin-top: 18px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user