feat: 修改商品类型错误

This commit is contained in:
duan
2025-02-24 09:44:05 +08:00
parent 7a508800f4
commit bad27514f3

View File

@@ -137,7 +137,7 @@
</el-table> </el-table>
</div> </div>
</div> </div>
<el-button type="primary" @click="$refs.shopListRef.show(); addGroupIndex = false">添加套餐组</el-button> <el-button type="primary" @click="addtaocan">添加套餐组</el-button>
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
@@ -335,11 +335,11 @@ interface RuleForm {
coverImg: string, coverImg: string,
images: string[], images: string[],
type: string, type: string,
specId: string, specId: any,
groupType: string, groupType: string,
skuList: string[], skuList: string[],
weight: Number, weight: any,
isAllowTempModifyPrice: Number, isAllowTempModifyPrice: any,
days: string[], days: string[],
useTime: string[], useTime: string[],
startTime: string, startTime: string,
@@ -347,10 +347,11 @@ interface RuleForm {
isSale: string, isSale: string,
isStock: string, isStock: string,
isHot: string, isHot: string,
stockNumber: Number, stockNumber: any,
packFee: Number, packFee: any,
sort: Number, sort: Number,
proGroupVo: any[], proGroupVo: any[],
selectSpecInfo: any
} }
const ruleFormRef = ref<FormInstance>() const ruleFormRef = ref<FormInstance>()
const ruleForm = reactive<RuleForm>({ const ruleForm = reactive<RuleForm>({
@@ -404,6 +405,7 @@ const ruleForm = reactive<RuleForm>({
packFee: 0, packFee: 0,
// 排序值 // 排序值
sort: 1, sort: 1,
selectSpecInfo: {}
}) })
const rules = reactive<FormRules<RuleForm>>({ const rules = reactive<FormRules<RuleForm>>({
name: [ name: [
@@ -509,14 +511,14 @@ function selectShopRes(res: Array<any>) {
// this.form.proGroupVo[this.addGroupIndex].count = newres.length // this.form.proGroupVo[this.addGroupIndex].count = newres.length
// this.form.proGroupVo[this.addGroupIndex].goods = newres // this.form.proGroupVo[this.addGroupIndex].goods = newres
// } else { // } else {
// let arr = [...this.form.proGroupVo] let arr = [...ruleForm.proGroupVo]
// arr.push({ arr.push({
// title: '', title: '',
// count: newres.length, count: newres.length,
// number: '', number: '',
// goods: newres goods: newres
// }) })
// this.form.proGroupVo = [...arr] ruleForm.proGroupVo = [...arr]
// } // }
} }
} }
@@ -544,7 +546,10 @@ function createSkuHeader() {
} }
datas.specTableHeaders = headers; datas.specTableHeaders = headers;
} }
// 可选套餐弹窗
function addtaocan() {
(shopListRef.value as any)?.opens()
}
// 生成多规格表体 // 生成多规格表体
function createSkuBody() { function createSkuBody() {
let bodys = []; let bodys = [];
@@ -615,19 +620,20 @@ function changeTypeEnum(item: string) {
} }
} }
// 笛卡尔积算法 // 笛卡尔积算法
function cartesian(arr: any) { function cartesian(arr: any[]) {
if (arr.length < 2) return arr[0] || []; if (arr.length < 2) return arr[0] || [];
return [].reduce.call(arr, (col, set) => { return [].reduce.call(arr, (col: any, set: any, index) => {
let res = []; let res = <any>[];
col.forEach((c) => { col.forEach((c: any) => {
set.forEach((s) => { set.forEach((s: any) => {
let t = [].concat(Array.isArray(c) ? c : [c]); let arr: any = Array.isArray(c) ? c : [c]
let t: any[] = [].concat(arr);
t.push(s); t.push(s);
res.push(t); res.push(t);
}); });
}); });
return res; return res;
}); }, []);
} }
// 套餐类型切换 // 套餐类型切换
function typeChange() { function typeChange() {
@@ -671,10 +677,10 @@ const submitForm = async (formEl: FormInstance | undefined) => {
ruleForm.startTime = ruleForm.useTime[0] ruleForm.startTime = ruleForm.useTime[0]
ruleForm.endTime = ruleForm.useTime[1] ruleForm.endTime = ruleForm.useTime[1]
// 拿到sku数据 // 拿到sku数据
ruleForm.skuList = specificationAttributeRef.value.getdata() ruleForm.skuList = (specificationAttributeRef.value as any)?.getdata()
// 多规格 selectSpecInfo 添加 // 多规格 selectSpecInfo 添加
if (ruleForm.type == 'sku') { if (ruleForm.type == 'sku') {
let obj = {} let obj: any = {}
datas.selectSpeclist.forEach((item: any) => { datas.selectSpeclist.forEach((item: any) => {
obj[item.name] = item.selectSpecResult obj[item.name] = item.selectSpecResult
}) })
@@ -717,7 +723,7 @@ function closeSelectedTag(view: TagView) {
// 规格id过滤 // 规格id过滤
const specIdFunction = (type: string) => { const specIdFunction = (type: string) => {
if (type === 'single') { if (type === 'single') {
return null return ''
} else if (type === '2') { } else if (type === '2') {
return 2 return 2
} else if (type === '3') { } else if (type === '3') {
@@ -781,4 +787,10 @@ const resetForm = (formEl: FormInstance | undefined) => {
} }
} }
} }
.group_wrap {
padding: 20px;
background-color: #F7F7FA;
margin-bottom: 20px;
}
</style> </style>