fix: 合并代码
This commit is contained in:
@@ -63,7 +63,7 @@
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="套餐商品" v-if="ruleForm.type == 'package'">
|
||||
<div style="display: block;width: 100%;">
|
||||
<div style="display: block; width: 100%">
|
||||
<div class="head-container">
|
||||
<el-radio-group v-model="ruleForm.groupType" @change="typeChange">
|
||||
<el-radio-button :label="0">固定套餐</el-radio-button>
|
||||
@@ -73,7 +73,7 @@
|
||||
<div v-if="ruleForm.groupType == '0'">
|
||||
<el-table border :data="item.goods" v-for="(item, index) in ruleForm.proGroupVo" :key="index">
|
||||
<el-table-column label="名称" prop="proName"></el-table-column>
|
||||
<el-table-column label="规格" prop="skuName"> </el-table-column>
|
||||
<el-table-column label="规格" prop="skuName"></el-table-column>
|
||||
<el-table-column label="价格" prop="price"></el-table-column>
|
||||
<el-table-column label="数量" prop="number">
|
||||
<template v-slot="scope">
|
||||
@@ -82,7 +82,9 @@
|
||||
</el-table-column>
|
||||
<el-table-column width="150">
|
||||
<template #header>
|
||||
<el-button type="primary" @click="addgoods(-1)" :disabled="isSyncStatus()">添加商品</el-button>
|
||||
<el-button type="primary" @click="addgoods(-1)" :disabled="isSyncStatus()">
|
||||
添加商品
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-slot="scope">
|
||||
<el-button type="text" :disabled="scope.row.type != 'sku' && isSyncStatus()"
|
||||
@@ -103,10 +105,12 @@
|
||||
<el-input v-model="item.number" :disabled="isSyncStatus()" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="ruleForm.proGroupVo.splice(index, 1)" :disabled="isSyncStatus()">删除</el-button>
|
||||
<el-button @click="ruleForm.proGroupVo.splice(index, 1)" :disabled="isSyncStatus()">
|
||||
删除
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div style="margin-top: 20px;">
|
||||
<div style="margin-top: 20px">
|
||||
<el-table border :data="item.goods">
|
||||
<el-table-column label="名称" prop="proName"></el-table-column>
|
||||
<el-table-column label="规格" prop="skuName"></el-table-column>
|
||||
@@ -118,7 +122,9 @@
|
||||
</el-table-column>
|
||||
<el-table-column width="150">
|
||||
<template #header>
|
||||
<el-button type="primary" @click="addgoods(index);" :disabled="isSyncStatus()">添加商品</el-button>
|
||||
<el-button type="primary" @click="addgoods(index)" :disabled="isSyncStatus()">
|
||||
添加商品
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-slot="scope">
|
||||
<el-button type="text" :disabled="scope.row.type != 'sku' && isSyncStatus()"
|
||||
@@ -130,7 +136,9 @@
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<el-button type="primary" @click="addtaocan" :disabled="isSyncStatus()">添加套餐组</el-button>
|
||||
<el-button type="primary" @click="addtaocan" :disabled="isSyncStatus()">
|
||||
添加套餐组
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
@@ -157,7 +165,7 @@
|
||||
:info="ruleForm" :list="list" ref="specificationAttributeRef"></SpecificationAttribute>
|
||||
<el-form-item label="重量">
|
||||
<el-col :span="12">
|
||||
<div style="display: block;">
|
||||
<div style="display: block">
|
||||
<el-input v-model="ruleForm.weight" placeholder="" :disabled="isSyncStatus()">
|
||||
<template #append>千克</template>
|
||||
</el-input>
|
||||
@@ -223,9 +231,7 @@
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitForm(ruleFormRef)">
|
||||
确定
|
||||
</el-button>
|
||||
<el-button type="primary" @click="submitForm(ruleFormRef)">确定</el-button>
|
||||
<el-button @click="resetForm(ruleFormRef)">取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -254,31 +260,33 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref } from 'vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { reactive, ref } from "vue";
|
||||
import type { FormInstance, FormRules } from "element-plus";
|
||||
// 规格属性
|
||||
import SpecificationAttribute from './SpecificationAttribute.vue'
|
||||
import SpecificationAttribute from "./SpecificationAttribute.vue";
|
||||
import { isSyncStatus } from "@/utils/index";
|
||||
import UserAPI from "@/api/product/productclassification";
|
||||
import UserAPI2 from "@/api/product/commonUnits";
|
||||
import UserAPI3 from "@/api/product/index";
|
||||
import UserAPI4 from "@/api/product/specificationsconfig";
|
||||
import shopList from "@/components/mycomponents/shopList.vue";
|
||||
import AddImg from '@/components/mycomponents/addImg.vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import AddImg from "@/components/mycomponents/addImg.vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useTagsViewStore } from "@/store";
|
||||
const tagsViewStore = useTagsViewStore();
|
||||
const router = useRouter();
|
||||
let list = ref<any[]>([{
|
||||
"originPrice": 0,
|
||||
"costPrice": 0,
|
||||
"salePrice": 0,
|
||||
"memberPrice": 0,
|
||||
"suitNum": 1,
|
||||
"coverImg": "",
|
||||
"weight": 0,
|
||||
"barCode": "88888888888888888888"
|
||||
}]);
|
||||
let list = ref<any[]>([
|
||||
{
|
||||
originPrice: 0,
|
||||
costPrice: 0,
|
||||
salePrice: 0,
|
||||
memberPrice: 0,
|
||||
suitNum: 1,
|
||||
coverImg: "",
|
||||
weight: 0,
|
||||
barCode: "88888888888888888888",
|
||||
},
|
||||
]);
|
||||
let datas = reactive<datasForm>({
|
||||
cycle: [
|
||||
{ label: "周一", value: "Monday" },
|
||||
@@ -287,7 +295,7 @@ let datas = reactive<datasForm>({
|
||||
{ label: "周四", value: "Thursday" },
|
||||
{ label: "周五", value: "Friday" },
|
||||
{ label: "周六", value: "Saturday" },
|
||||
{ label: "周七", value: "Sunday" }
|
||||
{ label: "周七", value: "Sunday" },
|
||||
],
|
||||
Company: [],
|
||||
classification: [],
|
||||
@@ -295,14 +303,14 @@ let datas = reactive<datasForm>({
|
||||
specificationsconfig: [],
|
||||
selectSpeclist: [],
|
||||
defaultSku: {
|
||||
"originPrice": 0,
|
||||
"costPrice": 0,
|
||||
"salePrice": 0,
|
||||
"memberPrice": 0,
|
||||
"suitNum": 1,
|
||||
"coverImg": "",
|
||||
"weight": 0,
|
||||
"barCode": "88888888888888888888"
|
||||
originPrice: 0,
|
||||
costPrice: 0,
|
||||
salePrice: 0,
|
||||
memberPrice: 0,
|
||||
suitNum: 1,
|
||||
coverImg: "",
|
||||
weight: 0,
|
||||
barCode: "88888888888888888888",
|
||||
},
|
||||
specTableHeaders: [],
|
||||
// 套餐商品-单规格index
|
||||
@@ -311,78 +319,79 @@ let datas = reactive<datasForm>({
|
||||
showSelectSku: false,
|
||||
selectSkuItem: {},
|
||||
addGroupIndex: -1,
|
||||
|
||||
})
|
||||
let shopListRef = ref(null)
|
||||
let addImg = ref(null)
|
||||
let isedit = ref(true)
|
||||
});
|
||||
let shopListRef = ref(null);
|
||||
let addImg = ref(null);
|
||||
let isedit = ref(true);
|
||||
interface datasForm {
|
||||
cycle: { label: string, value: string }[],
|
||||
Company: any[],
|
||||
classification: any[],
|
||||
specificationsconfig: any[],
|
||||
selectSpeclist: any[],
|
||||
defaultSku: any,
|
||||
specTableHeaders: any[],
|
||||
selectSkuTableIndex: any,
|
||||
selectSkuConfirmIndex: number,
|
||||
showSelectSku: boolean,
|
||||
selectSkuItem: any,
|
||||
addGroupIndex: any,
|
||||
cycle: { label: string; value: string }[];
|
||||
Company: any[];
|
||||
classification: any[];
|
||||
specificationsconfig: any[];
|
||||
selectSpeclist: any[];
|
||||
defaultSku: any;
|
||||
specTableHeaders: any[];
|
||||
selectSkuTableIndex: any;
|
||||
selectSkuConfirmIndex: number;
|
||||
showSelectSku: boolean;
|
||||
selectSkuItem: any;
|
||||
addGroupIndex: any;
|
||||
}
|
||||
interface RuleForm {
|
||||
name: string,
|
||||
shortTitle: string,
|
||||
unitId: string,
|
||||
categoryId: string,
|
||||
coverImg: string,
|
||||
images: string[],
|
||||
type: string,
|
||||
specId: any,
|
||||
groupType: any,
|
||||
skuList: string[],
|
||||
weight: any,
|
||||
isAllowTempModifyPrice: any,
|
||||
days: any,
|
||||
useTime: string[],
|
||||
startTime: string,
|
||||
endTime: string,
|
||||
isSale: string,
|
||||
isStock: string,
|
||||
isHot: string,
|
||||
stockNumber: any,
|
||||
packFee: any,
|
||||
sort: Number,
|
||||
proGroupVo: any[],
|
||||
selectSpecInfo: any
|
||||
name: string;
|
||||
shortTitle: string;
|
||||
unitId: string;
|
||||
categoryId: string;
|
||||
coverImg: string;
|
||||
images: string[];
|
||||
type: string;
|
||||
specId: any;
|
||||
groupType: any;
|
||||
skuList: string[];
|
||||
weight: any;
|
||||
isAllowTempModifyPrice: any;
|
||||
days: any;
|
||||
useTime: string[];
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
isSale: string;
|
||||
isStock: string;
|
||||
isHot: string;
|
||||
stockNumber: any;
|
||||
packFee: any;
|
||||
sort: Number;
|
||||
proGroupVo: any[];
|
||||
selectSpecInfo: any;
|
||||
}
|
||||
const ruleFormRef = ref<FormInstance>()
|
||||
const ruleFormRef = ref<FormInstance>();
|
||||
const ruleForm = reactive<RuleForm>({
|
||||
//商品名称
|
||||
name: '',
|
||||
name: "",
|
||||
//商品介绍
|
||||
shortTitle: '',
|
||||
shortTitle: "",
|
||||
// 单位id
|
||||
unitId: '',
|
||||
unitId: "",
|
||||
// 分类id
|
||||
categoryId: '',
|
||||
categoryId: "",
|
||||
// 封面图url
|
||||
coverImg: '',
|
||||
coverImg: "",
|
||||
// 详情图urls
|
||||
images: [],
|
||||
// 商品类型
|
||||
type: 'single',
|
||||
type: "single",
|
||||
// 规格id
|
||||
specId: '',
|
||||
specId: "",
|
||||
// 套餐类型
|
||||
groupType: '0',
|
||||
groupType: "0",
|
||||
// 套餐入参
|
||||
proGroupVo: [{
|
||||
title: '',
|
||||
count: '',
|
||||
number: '',
|
||||
goods: []
|
||||
}],
|
||||
proGroupVo: [
|
||||
{
|
||||
title: "",
|
||||
count: "",
|
||||
number: "",
|
||||
goods: [],
|
||||
},
|
||||
],
|
||||
// sku集合
|
||||
skuList: [],
|
||||
// 重量
|
||||
@@ -390,10 +399,10 @@ const ruleForm = reactive<RuleForm>({
|
||||
// 是否允许改价
|
||||
isAllowTempModifyPrice: 1,
|
||||
// 定时上下架周期
|
||||
days: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
|
||||
useTime: ['00:00:00', '23:59:59'],
|
||||
days: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||
useTime: ["00:00:00", "23:59:59"],
|
||||
// 开始时间
|
||||
startTime: '',
|
||||
startTime: "",
|
||||
// 结束时间
|
||||
endTime: "",
|
||||
// 是否上架
|
||||
@@ -408,37 +417,34 @@ const ruleForm = reactive<RuleForm>({
|
||||
packFee: 0,
|
||||
// 排序值
|
||||
sort: 1,
|
||||
selectSpecInfo: {}
|
||||
})
|
||||
selectSpecInfo: {},
|
||||
});
|
||||
const rules = reactive<FormRules<RuleForm>>({
|
||||
name: [
|
||||
{ required: true, message: '请输入商品名称', trigger: 'blur' },
|
||||
],
|
||||
name: [{ required: true, message: "请输入商品名称", trigger: "blur" }],
|
||||
unitId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择单位',
|
||||
trigger: 'change',
|
||||
message: "请选择单位",
|
||||
trigger: "change",
|
||||
},
|
||||
],
|
||||
categoryId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择商品分类',
|
||||
trigger: 'change',
|
||||
message: "请选择商品分类",
|
||||
trigger: "change",
|
||||
},
|
||||
],
|
||||
images: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择图片',
|
||||
trigger: 'change',
|
||||
message: "请选择图片",
|
||||
trigger: "change",
|
||||
},
|
||||
],
|
||||
|
||||
})
|
||||
});
|
||||
onMounted(() => {
|
||||
getList()
|
||||
getList();
|
||||
if (router.currentRoute.value.query.goods_id) {
|
||||
tbProductGetDetail(router.currentRoute.value.query.goods_id);
|
||||
}
|
||||
@@ -446,54 +452,51 @@ onMounted(() => {
|
||||
watch(() => router.currentRoute.value.query.goods_id, (val) => {
|
||||
tbProductGetDetail(val);
|
||||
})
|
||||
function pickerOptions(d) {
|
||||
console.log(d, '11111111');
|
||||
|
||||
}
|
||||
async function tbProductGetDetail(id: any) {
|
||||
// 获取商品详情
|
||||
const res = await UserAPI3.getDetail(id);
|
||||
changeTypeEnum(res.type)
|
||||
changeTypeEnum(res.type);
|
||||
for (const key in res) {
|
||||
if (key !== 'images' && key !== 'days') {
|
||||
if (key !== "images" && key !== "days") {
|
||||
(ruleForm as any)[key] = res[key];
|
||||
}
|
||||
}
|
||||
ruleForm.images = res.images.map((item: any, index: number) => item);
|
||||
ruleForm.days = res.days.split(',');
|
||||
ruleForm.days = res.days.split(",");
|
||||
ruleForm.useTime = [res.startTime, res.endTime];
|
||||
ruleForm.proGroupVo = res.groupSnap
|
||||
ruleForm.proGroupVo = res.groupSnap;
|
||||
if (res.type === "sku") {
|
||||
await tbProductSpecGet()
|
||||
selectSpecHandle(ruleForm.specId)
|
||||
await tbProductSpecGet();
|
||||
selectSpecHandle(ruleForm.specId);
|
||||
datas.selectSpeclist.forEach((item: any) => {
|
||||
item.selectSpecResult = res.selectSpecInfo[item.name]
|
||||
item.selectSpecResult = res.selectSpecInfo[item.name];
|
||||
// if (item.name === res.selectSpecInfo.name
|
||||
// ) { }
|
||||
// item.children.forEach((ele: any) => {
|
||||
// item.selectSpecResult.push(ele.name)
|
||||
// })
|
||||
})
|
||||
selectSpecResultChange()
|
||||
});
|
||||
selectSpecResultChange();
|
||||
} else {
|
||||
list.value = ruleForm.skuList
|
||||
list.value = ruleForm.skuList;
|
||||
}
|
||||
}
|
||||
// 选择套餐商品sku
|
||||
function selectSkuHandle(item: any, index: number) {
|
||||
// 把所有的设置为false
|
||||
datas.selectSkuItem.skuList.map((item: any, index: number) => {
|
||||
let nitem = { ...item }
|
||||
nitem.active = false
|
||||
datas.selectSkuItem.skuList[index] = nitem
|
||||
})
|
||||
let nitem = { ...item };
|
||||
nitem.active = false;
|
||||
datas.selectSkuItem.skuList[index] = nitem;
|
||||
});
|
||||
|
||||
if (item.active) {
|
||||
item.active = false
|
||||
item.active = false;
|
||||
} else {
|
||||
item.active = true
|
||||
item.active = true;
|
||||
}
|
||||
datas.selectSkuItem.skuList[index] = { ...item }
|
||||
datas.selectSkuItem.skuList[index] = { ...item };
|
||||
|
||||
// let arr = datas.selectSkuItem.skuList.filter((item:any) => item.active)
|
||||
|
||||
@@ -508,33 +511,39 @@ function addimgEvent() {
|
||||
ElMessage.error('当前同步启用状态下不可修改')
|
||||
return
|
||||
}
|
||||
(addImg.value as any)?.show()
|
||||
(addImg.value as any)?.show();
|
||||
}
|
||||
// 确认套餐商品设置规格
|
||||
function showSelectSkuConfirm() {
|
||||
let item = datas.selectSkuItem.skuList.filter((item: any) => item.active)
|
||||
ruleForm.proGroupVo[datas.selectSkuTableIndex].goods[datas.selectSkuConfirmIndex] = { ...ruleForm.proGroupVo[datas.selectSkuTableIndex].goods[datas.selectSkuConfirmIndex], skuId: item[0].id }
|
||||
ruleForm.proGroupVo[datas.selectSkuTableIndex].goods[datas.selectSkuConfirmIndex] = { ...ruleForm.proGroupVo[datas.selectSkuTableIndex].goods[datas.selectSkuConfirmIndex], skuName: item[0].specInfo }
|
||||
datas.showSelectSku = false
|
||||
let item = datas.selectSkuItem.skuList.filter((item: any) => item.active);
|
||||
ruleForm.proGroupVo[datas.selectSkuTableIndex].goods[datas.selectSkuConfirmIndex] = {
|
||||
...ruleForm.proGroupVo[datas.selectSkuTableIndex].goods[datas.selectSkuConfirmIndex],
|
||||
skuId: item[0].id,
|
||||
};
|
||||
ruleForm.proGroupVo[datas.selectSkuTableIndex].goods[datas.selectSkuConfirmIndex] = {
|
||||
...ruleForm.proGroupVo[datas.selectSkuTableIndex].goods[datas.selectSkuConfirmIndex],
|
||||
skuName: item[0].specInfo,
|
||||
};
|
||||
datas.showSelectSku = false;
|
||||
}
|
||||
// 显示套餐商品设置规格
|
||||
function showSelectSkuHandle(row: any, index: any, tabIndex: any) {
|
||||
datas.selectSkuTableIndex = tabIndex
|
||||
datas.selectSkuConfirmIndex = index
|
||||
datas.showSelectSku = true
|
||||
datas.selectSkuTableIndex = tabIndex;
|
||||
datas.selectSkuConfirmIndex = index;
|
||||
datas.showSelectSku = true;
|
||||
|
||||
let obj = { ...row }
|
||||
let obj = { ...row };
|
||||
|
||||
obj.skuList.map((item: any) => {
|
||||
item.active = false
|
||||
})
|
||||
item.active = false;
|
||||
});
|
||||
|
||||
datas.selectSkuItem = obj
|
||||
datas.selectSkuItem = obj;
|
||||
}
|
||||
// 添加商品
|
||||
function addgoods(index: number = -1) {
|
||||
datas.addGroupIndex = index;
|
||||
(shopListRef.value as any)?.opens()
|
||||
(shopListRef.value as any)?.opens();
|
||||
}
|
||||
function deleteEvent(d: any) {
|
||||
if (isSyncStatus()) {
|
||||
@@ -549,45 +558,45 @@ function successEvent(d: any) {
|
||||
}
|
||||
// 分组选择商品
|
||||
function selectShopRes(res: Array<any>) {
|
||||
let newres = res.map(item => {
|
||||
item.proId = item.id
|
||||
item.proName = item.name
|
||||
item.price = item.lowPrice
|
||||
item.skuId = item.skuList[0].id
|
||||
item.skuName = ''
|
||||
item.number = 1
|
||||
let newres = res.map((item) => {
|
||||
item.proId = item.id;
|
||||
item.proName = item.name;
|
||||
item.price = item.lowPrice;
|
||||
item.skuId = item.skuList[0].id;
|
||||
item.skuName = "";
|
||||
item.number = 1;
|
||||
// 单规格skuid添加
|
||||
return item
|
||||
})
|
||||
return item;
|
||||
});
|
||||
|
||||
if (ruleForm.groupType == '0') {
|
||||
if (ruleForm.groupType == "0") {
|
||||
let obj = {
|
||||
title: '',
|
||||
title: "",
|
||||
count: newres.length,
|
||||
number: '',
|
||||
goods: newres
|
||||
}
|
||||
ruleForm.proGroupVo = [{ ...obj }]
|
||||
number: "",
|
||||
goods: newres,
|
||||
};
|
||||
ruleForm.proGroupVo = [{ ...obj }];
|
||||
} else {
|
||||
if (datas.addGroupIndex != -1) {
|
||||
ruleForm.proGroupVo[datas.addGroupIndex].count = newres.length
|
||||
ruleForm.proGroupVo[datas.addGroupIndex].goods = newres
|
||||
ruleForm.proGroupVo[datas.addGroupIndex].count = newres.length;
|
||||
ruleForm.proGroupVo[datas.addGroupIndex].goods = newres;
|
||||
} else {
|
||||
let arr = [...ruleForm.proGroupVo]
|
||||
let arr = [...ruleForm.proGroupVo];
|
||||
arr.push({
|
||||
title: '',
|
||||
title: "",
|
||||
count: newres.length,
|
||||
number: '',
|
||||
goods: newres
|
||||
})
|
||||
ruleForm.proGroupVo = [...arr]
|
||||
number: "",
|
||||
goods: newres,
|
||||
});
|
||||
ruleForm.proGroupVo = [...arr];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 获取单位、分类数据
|
||||
async function getList() {
|
||||
datas.Company = (await UserAPI2.getList(null)) as any[]
|
||||
datas.classification = (await UserAPI.getList(null)) as any[]
|
||||
datas.Company = (await UserAPI2.getList(null)) as any[];
|
||||
datas.classification = (await UserAPI.getList(null)) as any[];
|
||||
}
|
||||
// 选择规格属性
|
||||
function selectSpecResultChange() {
|
||||
@@ -611,7 +620,7 @@ function createSkuHeader() {
|
||||
// 可选套餐弹窗
|
||||
function addtaocan() {
|
||||
datas.addGroupIndex = -1;
|
||||
(shopListRef.value as any)?.opens()
|
||||
(shopListRef.value as any)?.opens();
|
||||
}
|
||||
// 生成多规格表体
|
||||
function createSkuBody() {
|
||||
@@ -641,7 +650,6 @@ function createSkuBody() {
|
||||
for (let key in v) {
|
||||
obj[`${key}`] = v[key];
|
||||
specSnap.push(v[key]);
|
||||
|
||||
}
|
||||
}
|
||||
let specSnapStr = specSnap.join(",");
|
||||
@@ -669,18 +677,18 @@ function createSkuBody() {
|
||||
}
|
||||
if (ruleForm.skuList.length) {
|
||||
if (isedit.value) {
|
||||
let arr: any[] = []
|
||||
let arr: any[] = [];
|
||||
ruleForm.skuList.forEach((item: any, index: number) => {
|
||||
newarr.forEach((val: any, i: number) => {
|
||||
if (item.specInfo == val.specInfo) {
|
||||
// newarr[i] = item
|
||||
Object.assign(val, item)
|
||||
arr.push(val)
|
||||
Object.assign(val, item);
|
||||
arr.push(val);
|
||||
}
|
||||
});
|
||||
});
|
||||
list.value = arr
|
||||
isedit.value = false
|
||||
list.value = arr;
|
||||
isedit.value = false;
|
||||
} else {
|
||||
list.value = newarr;
|
||||
}
|
||||
@@ -691,13 +699,13 @@ function createSkuBody() {
|
||||
// 切换类型
|
||||
function changeTypeEnum(item: string) {
|
||||
// single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
|
||||
list.value = []
|
||||
if (item == 'sku') {
|
||||
list.value = [];
|
||||
if (item == "sku") {
|
||||
tbProductSpecGet();
|
||||
} else {
|
||||
ruleForm.specId = ""
|
||||
datas.selectSpeclist = []
|
||||
list.value = [datas.defaultSku]
|
||||
ruleForm.specId = "";
|
||||
datas.selectSpeclist = [];
|
||||
list.value = [datas.defaultSku];
|
||||
}
|
||||
}
|
||||
// 笛卡尔积算法
|
||||
@@ -718,114 +726,116 @@ function cartesian(arr) {
|
||||
// 套餐类型切换
|
||||
function typeChange() {
|
||||
// ruleForm.typeEnum = 'normal'
|
||||
if (ruleForm.groupType == '0') {
|
||||
ruleForm.proGroupVo = []
|
||||
if (ruleForm.groupType == "0") {
|
||||
ruleForm.proGroupVo = [];
|
||||
ruleForm.proGroupVo[0] = {
|
||||
title: '',
|
||||
count: '',
|
||||
title: "",
|
||||
count: "",
|
||||
number: 1,
|
||||
goods: []
|
||||
}
|
||||
goods: [],
|
||||
};
|
||||
} else {
|
||||
ruleForm.proGroupVo = []
|
||||
ruleForm.proGroupVo = [];
|
||||
}
|
||||
// this.changeTypeEnum()
|
||||
}
|
||||
// 获取规格列表
|
||||
async function tbProductSpecGet() {
|
||||
datas.specificationsconfig = (await UserAPI4.getPage(null)) as []
|
||||
datas.specificationsconfig = (await UserAPI4.getPage(null)) as [];
|
||||
}
|
||||
// 选择规格
|
||||
function selectSpecHandle(e: any) {
|
||||
const selectSpec = JSON.parse(JSON.stringify(datas.specificationsconfig.find((item) => item.id == e).children));
|
||||
const selectSpec = JSON.parse(
|
||||
JSON.stringify(datas.specificationsconfig.find((item) => item.id == e).children)
|
||||
);
|
||||
for (let item in selectSpec) {
|
||||
selectSpec[item].selectSpecResult = [];
|
||||
}
|
||||
datas.selectSpeclist = selectSpec;
|
||||
}
|
||||
const specificationAttributeRef = ref(null)
|
||||
const specificationAttributeRef = ref(null);
|
||||
const submitForm = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return
|
||||
if (!formEl) return;
|
||||
await formEl.validate(async (valid, fields) => {
|
||||
if (valid) {
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> 2602916201f0e12ac5cb51e5a88d69cfaaeb7baf
|
||||
// 第一张图片作为封面图
|
||||
ruleForm.coverImg = ruleForm.images[0]
|
||||
ruleForm.coverImg = ruleForm.images[0];
|
||||
// 规格id修改
|
||||
// ruleForm.specId = specIdFunction(ruleForm.type)
|
||||
let selectTitle = false
|
||||
ruleForm.proGroupVo.forEach((item: any) => {
|
||||
})
|
||||
let selectTitle = false;
|
||||
ruleForm.proGroupVo.forEach((item: any) => { });
|
||||
if (selectTitle) {
|
||||
ElMessage.error('请填写组名和几选几')
|
||||
return
|
||||
ElMessage.error("请填写组名和几选几");
|
||||
return;
|
||||
}
|
||||
// 拿到sku数据
|
||||
ruleForm.skuList = (specificationAttributeRef.value as any)?.getdata()
|
||||
ruleForm.skuList = (specificationAttributeRef.value as any)?.getdata();
|
||||
// 多规格 selectSpecInfo 添加
|
||||
if (ruleForm.type == 'sku') {
|
||||
let obj: any = {}
|
||||
if (ruleForm.type == "sku") {
|
||||
let obj: any = {};
|
||||
datas.selectSpeclist.forEach((item: any) => {
|
||||
obj[item.name] = item.selectSpecResult
|
||||
})
|
||||
ruleForm.selectSpecInfo = obj
|
||||
} else if (ruleForm.type == 'package') {
|
||||
obj[item.name] = item.selectSpecResult;
|
||||
});
|
||||
ruleForm.selectSpecInfo = obj;
|
||||
} else if (ruleForm.type == "package") {
|
||||
// console.log(ruleForm, '套餐')
|
||||
}
|
||||
|
||||
// 标题和几选几是否填写
|
||||
if (ruleForm.type == "package") {
|
||||
if (ruleForm.groupType == '1') {
|
||||
let selectTitle = false
|
||||
if (ruleForm.groupType == "1") {
|
||||
let selectTitle = false;
|
||||
ruleForm.proGroupVo.forEach((item: any) => {
|
||||
if (item.number == '' || item.title == '') {
|
||||
selectTitle = true
|
||||
if (item.number == "" || item.title == "") {
|
||||
selectTitle = true;
|
||||
}
|
||||
})
|
||||
});
|
||||
if (selectTitle) {
|
||||
ElMessage.error('请填写组名和几选几')
|
||||
return
|
||||
ElMessage.error("请填写组名和几选几");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
ruleForm.days = ruleForm.days.join(',')
|
||||
setTimeout(() => {
|
||||
ruleForm.days = ruleForm.days.split(',')
|
||||
ruleForm.days = ruleForm.days.split(",");
|
||||
}, 200);
|
||||
|
||||
if (ruleForm.type == 'weight') {
|
||||
ruleForm.specId = ''
|
||||
if (ruleForm.type == "weight") {
|
||||
ruleForm.specId = "";
|
||||
}
|
||||
if (ruleForm.id) {
|
||||
let res = await UserAPI3.update(ruleForm)
|
||||
let res = await UserAPI3.update(ruleForm);
|
||||
if (res.code == 200) {
|
||||
ElMessage.success("修改成功");
|
||||
}
|
||||
} else {
|
||||
|
||||
let res = await UserAPI3.addunit(ruleForm)
|
||||
let res = await UserAPI3.addunit(ruleForm);
|
||||
if (res.code == 200) {
|
||||
ElMessage.success("添加成功");
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
closeSelectedTag({
|
||||
"name": "addgoods",
|
||||
"title": "新增商品",
|
||||
"path": "/product/addgoods",
|
||||
"fullPath": "/product/addgoods",
|
||||
})
|
||||
name: "addgoods",
|
||||
title: "新增商品",
|
||||
path: "/product/addgoods",
|
||||
fullPath: "/product/addgoods",
|
||||
});
|
||||
}, 500);
|
||||
setTimeout(() => {
|
||||
router.push({ path: '/product/index' });
|
||||
router.push({ path: "/product/index" });
|
||||
}, 1000);
|
||||
} else {
|
||||
ElMessage.error("请填写完整信息");
|
||||
console.log('error submit!', fields)
|
||||
console.log("error submit!", fields);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
// 关闭当前窗口
|
||||
function closeSelectedTag(view: TagView) {
|
||||
@@ -837,31 +847,31 @@ function closeSelectedTag(view: TagView) {
|
||||
}
|
||||
// 规格id过滤
|
||||
const specIdFunction = (type: string) => {
|
||||
if (type === 'single') {
|
||||
return ''
|
||||
} else if (type === '2') {
|
||||
return 2
|
||||
} else if (type === '3') {
|
||||
return 3
|
||||
} else if (type === '4') {
|
||||
return 4
|
||||
} else if (type === '5') {
|
||||
return 5
|
||||
if (type === "single") {
|
||||
return "";
|
||||
} else if (type === "2") {
|
||||
return 2;
|
||||
} else if (type === "3") {
|
||||
return 3;
|
||||
} else if (type === "4") {
|
||||
return 4;
|
||||
} else if (type === "5") {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
};
|
||||
const resetForm = (formEl: FormInstance | undefined) => {
|
||||
closeSelectedTag({
|
||||
"name": "addgoods",
|
||||
"title": "新增商品",
|
||||
"path": "/product/addgoods",
|
||||
"fullPath": "/product/addgoods",
|
||||
"affix": false,
|
||||
"keepAlive": true,
|
||||
"query": {}
|
||||
})
|
||||
if (!formEl) return
|
||||
formEl.resetFields()
|
||||
}
|
||||
name: "addgoods",
|
||||
title: "新增商品",
|
||||
path: "/product/addgoods",
|
||||
fullPath: "/product/addgoods",
|
||||
affix: false,
|
||||
keepAlive: true,
|
||||
query: {},
|
||||
});
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.addgoods {
|
||||
@@ -884,7 +894,7 @@ const resetForm = (formEl: FormInstance | undefined) => {
|
||||
}
|
||||
|
||||
.tag {
|
||||
background-color: #F7F7FA;
|
||||
background-color: #f7f7fa;
|
||||
padding: 6px 12px;
|
||||
margin-right: 10px;
|
||||
border-radius: 4px;
|
||||
@@ -895,7 +905,7 @@ const resetForm = (formEl: FormInstance | undefined) => {
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: #46A6FF;
|
||||
background-color: #46a6ff;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
@@ -905,7 +915,7 @@ const resetForm = (formEl: FormInstance | undefined) => {
|
||||
|
||||
.group_wrap {
|
||||
padding: 20px;
|
||||
background-color: #F7F7FA;
|
||||
background-color: #f7f7fa;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,17 +13,18 @@
|
||||
</div>
|
||||
<div class="">¥{{ item.lowPrice }}</div>
|
||||
</div>
|
||||
<div class="status" v-if="item.isSoldStock || !item.isSale || !item.isSaleTime">
|
||||
<svg-icon
|
||||
@click="ElMessage.error('该商品已售罄')"
|
||||
v-if="item.isSoldStock"
|
||||
iconClass="shouqing"
|
||||
color="#fff"
|
||||
size="60"
|
||||
></svg-icon>
|
||||
<div
|
||||
class="status"
|
||||
v-if="
|
||||
item.isSoldStock ||
|
||||
!item.isSale ||
|
||||
!item.isSaleTime ||
|
||||
(item.isStock && item.stockNumber * 1 <= 0)
|
||||
"
|
||||
>
|
||||
<svg-icon
|
||||
@click="ElMessage.error('该商品已下架')"
|
||||
v-else-if="!item.isSale"
|
||||
v-if="!item.isSale"
|
||||
iconClass="yi-xiajia"
|
||||
color="#fff"
|
||||
size="60"
|
||||
@@ -35,6 +36,20 @@
|
||||
color="#fff"
|
||||
size="60"
|
||||
></svg-icon>
|
||||
<svg-icon
|
||||
@click="ElMessage.error('该商品已售罄')"
|
||||
v-else-if="item.isSoldStock"
|
||||
iconClass="shouqing"
|
||||
color="#fff"
|
||||
size="60"
|
||||
></svg-icon>
|
||||
<svg-icon
|
||||
@click="ElMessage.error('库存不足')"
|
||||
v-else-if="item.isStock && item.stockNumber * 1 <= 0"
|
||||
iconClass="stock_null"
|
||||
color="#fff"
|
||||
size="60"
|
||||
></svg-icon>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user