This commit is contained in:
2025-02-26 16:01:57 +08:00
6 changed files with 568 additions and 19 deletions

View File

@@ -81,7 +81,7 @@
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button @click="showBatchModal = false"> </el-button>
<el-button type="primary" @click="batchNumberFormConfirm">
</el-button>

View File

@@ -36,9 +36,21 @@
<el-form-item label="商品图片" required prop="images">
<MultiImageUpload v-model="ruleForm.images" />
</el-form-item>
<!-- <el-form-item label="商品图片" required prop="images">
<div style="display: flex; flex-wrap: wrap">
<div v-for="(item, index) in datas.imgList" :key="index" style="position: relative" class="showStyle">
<i class="el-icon-error buttonstyle" @click="deleteEvent(item)"></i>
<img style="width: 148px; height: 148px; margin-right: 6px" class="imgStyle" :key="item.id" :src="item.url"
alt="" />
</div>
<div class="upImgStyle" @click="addimgEvent">+</div>
</div>
</el-form-item> -->
<el-form-item>
<div style="color: #999;">第一张图为商品封面图图片尺寸为750×750</div>
<div class="tips">第一张图为商品封面图图片尺寸为750×750</div>
</el-form-item>
<!-- 选择图片 -->
<AddImg ref="addImg" @successEvent="successEvent"></AddImg>
<!-- <el-form-item label="显示/隐藏" required prop="type">
<el-checkbox-group v-model="ruleForm.showType">
<el-checkbox label="table">堂食</el-checkbox>
@@ -250,7 +262,7 @@ 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 { useTagsViewStore } from "@/store";
const tagsViewStore = useTagsViewStore();
@@ -296,9 +308,13 @@ let datas = reactive<datasForm>({
selectSkuConfirmIndex: 0,
showSelectSku: false,
selectSkuItem: {},
addGroupIndex: -1
addGroupIndex: -1,
imgList: [],
})
let shopListRef = ref(null)
let addImg = ref(null)
let isedit = ref(true)
interface datasForm {
cycle: { label: string, value: string }[],
Company: any[],
@@ -311,7 +327,8 @@ interface datasForm {
selectSkuConfirmIndex: number,
showSelectSku: boolean,
selectSkuItem: any,
addGroupIndex: any
addGroupIndex: any,
imgList: any[]
}
interface RuleForm {
name: string,
@@ -446,12 +463,14 @@ async function tbProductGetDetail(id: any) {
await tbProductSpecGet()
selectSpecHandle(ruleForm.specId)
datas.selectSpeclist.forEach((item: any) => {
item.children.forEach((ele: any) => {
item.selectSpecResult.push(ele.name)
})
item.selectSpecResult = res.selectSpecInfo[item.name]
// if (item.name === res.selectSpecInfo.name
// ) { }
// item.children.forEach((ele: any) => {
// item.selectSpecResult.push(ele.name)
// })
})
selectSpecResultChange()
} else {
list.value = ruleForm.skuList
}
@@ -480,6 +499,9 @@ function selectSkuHandle(item: any, index: number) {
// this.selectSkuConfirmDisabled = true
// }
}
function addimgEvent() {
(addImg.value as any)?.show()
}
// 确认套餐商品设置规格
function showSelectSkuConfirm() {
let item = datas.selectSkuItem.skuList.filter((item: any) => item.active)
@@ -506,6 +528,15 @@ function addgoods(index: number = -1) {
datas.addGroupIndex = index;
(shopListRef.value as any)?.opens()
}
function deleteEvent(d: any) {
let index = datas.imgList.findIndex((ele) => ele.url == d.url);
datas.imgList.splice(index, 1);
}
function successEvent(d: any) {
// this.form.images.push(d[0].url);
// this.imgList.push(d[0]);
}
// 分组选择商品
function selectShopRes(res: Array<any>) {
let newres = res.map(item => {
@@ -625,17 +656,23 @@ function createSkuBody() {
}
}
if (ruleForm.skuList.length) {
newarr.forEach((val: any, index: number) => {
val['originPrice'] = ruleForm.skuList[index]['originPrice']
val['costPrice'] = ruleForm.skuList[index]['costPrice']
val['salePrice'] = ruleForm.skuList[index]['salePrice']
val['memberPrice'] = ruleForm.skuList[index]['memberPrice']
val['suitNum'] = ruleForm.skuList[index]['suitNum']
});
list.value = newarr
if (isedit.value) {
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)
}
});
});
list.value = arr
isedit.value = false
} else {
list.value = newarr;
}
} else {
list.value = newarr;
}
}
@@ -831,4 +868,16 @@ const resetForm = (formEl: FormInstance | undefined) => {
background-color: #F7F7FA;
margin-bottom: 20px;
}
.upImgStyle {
cursor: pointer;
width: 148px;
height: 148px;
line-height: 148px;
text-align: center;
border: 1px dashed #ccc;
border-radius: 1%;
font-size: 30px;
color: #ccc;
}
</style>