修复生成商品sku列表的bug
This commit is contained in:
@@ -206,7 +206,7 @@
|
||||
</a-space>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item name="oneSpec">
|
||||
<a-form-item name="oneSpec" v-if="form.specs == 1">
|
||||
<div class="w-full">
|
||||
<div class="sku-table">
|
||||
<a-table
|
||||
@@ -319,7 +319,7 @@
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form, message } from 'ant-design-vue';
|
||||
import { assignObject, uuid } from 'ele-admin-pro';
|
||||
import { addGoods, getGoods, updateGoods } from "@/api/shop/goods";
|
||||
import { addGoods, updateGoods } from "@/api/shop/goods";
|
||||
import { Goods } from '@/api/shop/goods/model';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
@@ -331,11 +331,9 @@
|
||||
import { uploadFile, uploadOss } from "@/api/system/file";
|
||||
import { SpecValue } from "@/api/shop/specValue/model";
|
||||
import { Spec } from "@/api/shop/spec/model";
|
||||
import {ColumnItem} from "ele-admin-pro/es/ele-pro-table/types";
|
||||
import { GoodsSku } from "@/api/shop/goodsSku/model";
|
||||
import { GoodsSpec } from "@/api/shop/goodsSpec/model";
|
||||
import { getGoodsSpec, pageGoodsSpec } from "@/api/shop/goodsSpec";
|
||||
import { openUrl } from "@/utils/common";
|
||||
import { generateGoodsSku, listGoodsSku } from "@/api/shop/goodsSku";
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
@@ -366,13 +364,13 @@
|
||||
const content = ref('');
|
||||
const disabled = ref(false);
|
||||
// 当前选项卡
|
||||
const active = ref('spec');
|
||||
const active = ref('base');
|
||||
|
||||
const spec = ref<SpecValue[]>([]);
|
||||
const showSpecForm = ref(false);
|
||||
const name = ref();
|
||||
const value = ref();
|
||||
const skuList = ref<GoodsSku[]>([{images: []}]);
|
||||
const skuList = ref<GoodsSku[]>([]);
|
||||
const fileList = ref<any[]>([]);
|
||||
const files = ref<ItemType[]>([]);
|
||||
const goodsSpec = ref<GoodsSpec>();
|
||||
@@ -419,6 +417,7 @@
|
||||
goodsName: undefined,
|
||||
image: undefined,
|
||||
content: undefined,
|
||||
unitName: '',
|
||||
categoryId: undefined,
|
||||
categoryParent: undefined,
|
||||
categoryChildren: undefined,
|
||||
@@ -468,9 +467,15 @@
|
||||
files: [
|
||||
{
|
||||
required: true,
|
||||
message: '请上传图片',
|
||||
message: '请上传轮播图',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (form.files?.length == 0) {
|
||||
return Promise.reject('选择上传轮播图');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
],
|
||||
specs: [
|
||||
@@ -576,11 +581,15 @@
|
||||
images.value.splice(index, 1);
|
||||
};
|
||||
|
||||
const onChange = () => {
|
||||
// reload();
|
||||
const onChange = (text: string) => {
|
||||
// 加载商品多规格
|
||||
if(text == 'spec'){
|
||||
listGoodsSku({goodsId: props.data?.goodsId}).then(data => {
|
||||
skuList.value = data;
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const onDeleteItem = (index: number) => {
|
||||
images.value.splice(index, 1);
|
||||
form.image = '';
|
||||
@@ -634,6 +643,16 @@
|
||||
files.value.splice(index, 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* 生成商品SKU列表
|
||||
*/
|
||||
const generateSku = () => {
|
||||
generateGoodsSku(spec.value).then(data => {
|
||||
if(data){
|
||||
skuList.value = data;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const editorRef = ref<InstanceType<typeof TinymceEditor> | null>(null);
|
||||
const config = ref({
|
||||
@@ -698,7 +717,7 @@
|
||||
...form,
|
||||
content: content.value,
|
||||
files: JSON.stringify(fileList.value),
|
||||
goodsSpecs: goodsSpec.value,
|
||||
goodsSpec: goodsSpec.value,
|
||||
goodsSkus: skuList.value
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateGoods : addGoods;
|
||||
@@ -722,6 +741,8 @@
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
images.value = [];
|
||||
files.value = [];
|
||||
category.value = [];
|
||||
if (props.data) {
|
||||
assignObject(form, props.data);
|
||||
if (props.data.image) {
|
||||
@@ -731,6 +752,16 @@
|
||||
status: 'done'
|
||||
});
|
||||
}
|
||||
if(props.data.files){
|
||||
const arr = JSON.parse(props.data.files);
|
||||
arr.map((img) => {
|
||||
files.value.push({
|
||||
uid: uuid(),
|
||||
url: img,
|
||||
status: 'done'
|
||||
});
|
||||
});
|
||||
}
|
||||
if(props.data.goodsSpecs){
|
||||
goodsSpec.value = props.data.goodsSpecs[0];
|
||||
if(props.data.specs == 1){
|
||||
@@ -748,6 +779,16 @@
|
||||
return d;
|
||||
});
|
||||
}
|
||||
// 商品分类
|
||||
if(props.data.categoryParent){
|
||||
category.value.push(props.data.categoryParent);
|
||||
}
|
||||
if(props.data.categoryChildren){
|
||||
category.value.push(props.data.categoryChildren);
|
||||
}
|
||||
if (props.data.content){
|
||||
content.value = props.data.content;
|
||||
}
|
||||
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user