This commit is contained in:
魏啾 2024-08-08 09:38:35 +08:00
commit 87d2f8a7bb
5 changed files with 263 additions and 67 deletions

View File

@ -36,7 +36,7 @@ export default {
dialogImageUrl: '', dialogImageUrl: '',
dialogVisible: false, dialogVisible: false,
fileList: [], fileList: [],
files: [], // files: [],
headers: { headers: {
'Authorization': getToken() 'Authorization': getToken()
} }
@ -45,7 +45,13 @@ export default {
methods: { methods: {
handleSuccess(response, file, fileList) { handleSuccess(response, file, fileList) {
// console.log('', response) // console.log('', response)
this.files = response.data setTimeout(() => {
this.fileList.push({
url: response.data[0],
id: response.data.id
})
}, 100);
// this.files = response.data
this.$emit('success', response.data) this.$emit('success', response.data)
}, },
// //
@ -69,6 +75,9 @@ export default {
}, },
handleRemove(file, fileList) { handleRemove(file, fileList) {
let arr = fileList.map(item => item.url) let arr = fileList.map(item => item.url)
//
let index = this.fileList.findIndex(ele => ele.url == file.url)
this.fileList.splice(index, 1);
this.$emit('remove', arr) this.$emit('remove', arr)
}, },
clearFiles() { clearFiles() {
@ -76,4 +85,11 @@ export default {
} }
} }
} }
</script> </script>
<style>
.el-upload-list__item {
transition: none;
}
</style>

View File

@ -2,7 +2,8 @@
<div class="app-container"> <div class="app-container">
<el-form ref="formRef" :model="form" :rules="rules" label-width="140px" label-position="left"> <el-form ref="formRef" :model="form" :rules="rules" label-width="140px" label-position="left">
<el-form-item label="商品类型" prop="typeEnum"> <el-form-item label="商品类型" prop="typeEnum">
<div class="shop_type_box" :class="{ disabled: form.id }"> <div class="shop_type_box" :class="{ }">
<!-- <div class="shop_type_box" :class="{ disabled: form.id }"> -->
<div class="item" v-for="(item, index) in shopTypes" :key="index" <div class="item" v-for="(item, index) in shopTypes" :key="index"
:class="{ active: shopTypesActive == index }" @click="changeTypeEnum(index)"> :class="{ active: shopTypesActive == index }" @click="changeTypeEnum(index)">
<div class="s_title">{{ item.label }}</div> <div class="s_title">{{ item.label }}</div>
@ -45,9 +46,19 @@
<addClassify ref="addClassifyRef" @success="tbShopCategoryGet" /> <addClassify ref="addClassifyRef" @success="tbShopCategoryGet" />
</el-form-item> </el-form-item>
<el-form-item label="商品图片"> <el-form-item label="商品图片">
<uploadImg ref="uploadImg" :limit="9" @success="uploadSuccess" @remove="uploadRemove" /> <div style="display: flex;flex-wrap: wrap; ">
<div v-for="item in imgList" 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="$refs.addImg.show()">
+
</div>
</div>
<!-- <uploadImg ref="uploadImg" :limit="9" @success="uploadSuccess" @remove="uploadRemove" /> -->
<div class="tips">第一张图为商品封面图图片尺寸为750×750</div> <div class="tips">第一张图为商品封面图图片尺寸为750×750</div>
<el-button type="primary" plain icon="el-icon-plus" @click="$refs.addImg.show()">选择图片</el-button> <!-- <el-button type="primary" plain icon="el-icon-plus" @click="$refs.addImg.show()">选择图片</el-button> -->
</el-form-item> </el-form-item>
<el-form-item label="套餐商品" v-if="shopTypes[shopTypesActive].typeEnum == 'group'"> <el-form-item label="套餐商品" v-if="shopTypes[shopTypesActive].typeEnum == 'group'">
<el-table :data="form.groupSnap" border v-if="form.groupSnap.length"> <el-table :data="form.groupSnap" border v-if="form.groupSnap.length">
@ -142,9 +153,9 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="tips" v-if="form.isShowMall"> <!-- <div class="tips" v-if="form.isShowMall">
小程序商城必须设置库存数量大于0 小程序商城必须设置库存数量大于0
</div> </div> -->
</el-form-item> </el-form-item>
<template v-if="form.typeEnum == 'group'"> <template v-if="form.typeEnum == 'group'">
<el-form-item label="使用日期说明" prop="notices.dateUsed"> <el-form-item label="使用日期说明" prop="notices.dateUsed">
@ -297,9 +308,9 @@
</template> </template>
</el-table-column> --> </el-table-column> -->
</el-table> </el-table>
<div class="tips" v-if="form.isShowMall"> <!-- <div class="tips" v-if="form.isShowMall">
小程序商城必须设置库存数量大于0 小程序商城必须设置库存数量大于0
</div> </div> -->
</el-form-item> </el-form-item>
<template v-if="form.typeEnum != 'group'"> <template v-if="form.typeEnum != 'group'">
<el-form-item label="上架区域"> <el-form-item label="上架区域">
@ -470,6 +481,7 @@ export default {
usageRules: "" usageRules: ""
} }
}, },
imgList: [],
rules: { rules: {
typeEnum: [ typeEnum: [
{ {
@ -552,15 +564,22 @@ export default {
}, },
methods: { methods: {
successEvent(d) { successEvent(d) {
// this.form.images.push(d[0].url);
// let index = this.files.findIndex(ele => ele.name == file.name) this.imgList.push(d[0])
// this.files.splice(index, 1); // if (this.$refs.uploadImg.fileList.length < 9) {
d.forEach(item => { // d.forEach(item => {
item.uid = item.id // item.uid = item.id
item.url = item.url // item.url = item.url
this.form.images.push(item.url); // this.form.images.push(item.url);
}) // })
this.$refs.uploadImg.fileList.push(...d) // this.$refs.uploadImg.fileList.push(...d)
// console.log(this.$refs.uploadImg.fileList, '1')
// } else {
// this.$notify.error({
// title: '',
// message: '9'
// });
// }
}, },
priceFormat(item, key) { priceFormat(item, key) {
const messageheight = 48; const messageheight = 48;
@ -582,6 +601,10 @@ export default {
} }
}) })
}, },
deleteEvent(d) {
let index = this.imgList.findIndex(ele => ele.url == d.url)
this.imgList.splice(index, 1);
},
// //
delGoods(goods, index, $index) { delGoods(goods, index, $index) {
goods.splice(index, 1); goods.splice(index, 1);
@ -630,14 +653,18 @@ export default {
); );
this.specTableHeaders = JSON.parse(res.specTableHeaders); this.specTableHeaders = JSON.parse(res.specTableHeaders);
this.selectSpec = JSON.parse(res.selectSpec); this.selectSpec = JSON.parse(res.selectSpec);
console.log(res, '调试11111')
// //
this.$refs.uploadImg.fileList = res.images.map(item => { // this.$refs.uploadImg.fileList = res.images.map(item => {
// return {
// url: item
// };
// });
this.imgList = res.images.map(item => {
return { return {
url: item url: item
}; };
}); });
this.form = res; this.form = res;
if (res.typeEnum == "sku") { if (res.typeEnum == "sku") {
let skuList = [...res.skuList]; let skuList = [...res.skuList];
@ -719,7 +746,7 @@ export default {
}, },
// //
changeTypeEnum(index) { changeTypeEnum(index) {
if (this.form.id) return; // if (this.form.id) return;
this.shopTypesActive = index; this.shopTypesActive = index;
const typeEnum = this.shopTypes[index].typeEnum; const typeEnum = this.shopTypes[index].typeEnum;
this.form.typeEnum = typeEnum; this.form.typeEnum = typeEnum;
@ -740,6 +767,7 @@ export default {
}, },
// //
uploadRemove(arr) { uploadRemove(arr) {
this.form.images = arr; this.form.images = arr;
}, },
// //
@ -933,6 +961,18 @@ export default {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.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;
}
.shop_list { .shop_list {
.item { .item {
display: flex; display: flex;
@ -988,4 +1028,20 @@ export default {
cursor: pointer; cursor: pointer;
} }
} }
.buttonstyle {
border-radius: 50%;
color: #db1616;
background-color: #fff;
font-size: 20px;
display: none;
position: absolute;
right: -10px;
top: -10px;
z-index: 10;
}
.showStyle:hover>.buttonstyle {
display: block;
}
</style> </style>

View File

@ -1,33 +1,58 @@
<template> <template>
<div v-if="dialogVisible"> <div v-if="dialogVisible">
<el-dialog title="请选择" :visible.sync="dialogVisible" width=""> <el-dialog title="请选择" :visible.sync="dialogVisible" width="1000px">
<el-select v-model="value" placeholder="请选择" @change="changeEvent"> <el-container>
<el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id"> <el-aside style="background-color: #fff;" width="150px">
<span style="float: left">{{ item.name }}</span> <ul style="padding-left: 0;">
<span style="float: right; color: #8492a6; font-size: 13px"><i class="el-icon-error " <li style="cursor: pointer;" v-for="item in options" :key="item.id"
@click="deleteType(item.id)"></i></span> :class="[activedata == item.id ? 'activedata' : '']" @click="changeEvent(item.id)">{{
</el-option> item.name }}</li>
</el-select> </ul>
<el-button type="primary" @click="dialogTableVisibles = true">新增类型</el-button> <div class="uplocation" :class="[activedata == -1 ? 'activedata' : '']" @click="uplocation">本地上传
<el-button type="primary" @click="showUpload = true">新增图片</el-button> </div>
<imageComponent @onSelectImage="onSelectImage" @getList="getList" @getlists="getlists" :list='dataImages'> </el-aside>
</imageComponent> <el-main>
<imageComponent @onSelectImage="onSelectImage" @getList="getList" :activedata="activedata"
:list='dataImages'>
</imageComponent>
<el-pagination layout="prev, pager, next" :total="total" :page-size="20"
@current-change="handleCurrentChange">
</el-pagination>
</el-main>
</el-container>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button> <el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="sumbit"> </el-button> <el-button type="primary" @click="sumbit"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
<!-- <el-select v-model="value" placeholder="请选择" @change="changeEvent">
<el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
<span style="float: left">{{ item.name }}</span>
<template v-if="item.id != '681'">
<template v-if="item.id != '682'">
<template v-if="item.id != '699'">
<span style="float: right; color: #8492a6; font-size: 13px"><i class="el-icon-error "
@click="deleteType(item.id)"></i></span>
</template>
</template>
</template>
</el-option>
</el-select> -->
<!-- <el-button type="primary" @click="dialogTableVisibles = true">新增类型</el-button> -->
<!-- <el-button type="primary" @click="showUpload = true">新增图片</el-button> -->
<!-- 新增类型 --> <!-- 新增类型 -->
<el-dialog title="新增类型" :visible.sync="dialogTableVisibles"> <!-- <el-dialog title="新增类型" :visible.sync="dialogTableVisibles">
<el-input v-model="typedata" placeholder="请输入类型" autocomplete="off"></el-input> <el-input v-model="typedata" placeholder="请输入类型" autocomplete="off"></el-input>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogTableVisibles = false"> </el-button> <el-button @click="dialogTableVisibles = false"> </el-button>
<el-button type="primary" @click="addtype"> </el-button> <el-button type="primary" @click="addtype"> </el-button>
</span> </span>
</el-dialog> </el-dialog> -->
<!-- 新增图片 --> <!-- 新增图片 -->
<template v-if="showUpload"> <!-- <template v-if="showUpload">
<el-dialog :visible.sync="showUpload" :close-on-click-modal="false" append-to-body width="500px" <el-dialog :visible.sync="showUpload" :close-on-click-modal="false" append-to-body width="1000px"
@close="showUpload = false"> @close="showUpload = false">
<el-upload :before-remove="handleBeforeRemove" list-type="picture-card" :on-success="handleSuccess" <el-upload :before-remove="handleBeforeRemove" list-type="picture-card" :on-success="handleSuccess"
:file-list="fileList" :headers="headers" :action="qiNiuUploadApi" class="upload-demo" multiple> :file-list="fileList" :headers="headers" :action="qiNiuUploadApi" class="upload-demo" multiple>
@ -37,7 +62,7 @@
<el-button type="primary" @click="doSubmit">确认</el-button> <el-button type="primary" @click="doSubmit">确认</el-button>
</div> </div>
</el-dialog> </el-dialog>
</template> </template> -->
</div> </div>
</template> </template>
@ -69,14 +94,28 @@ export default {
typedata: '', typedata: '',
showUpload: false, showUpload: false,
page: 1, page: 1,
total: 0,
activedata: '681'
} }
}, },
mounted() { mounted() {
this.getType() this.getType()
}, },
methods: { methods: {
changeEvent() { uplocation() {
this.activedata = -1
this.page = 1 this.page = 1
this.dataImages = []
this.total = 0
this.getList()
},
changeEvent(id) {
this.page = 1
this.activedata = id
this.getList()
},
handleCurrentChange(i) {
this.page = i
this.getList() this.getList()
}, },
// //
@ -93,10 +132,10 @@ export default {
this.getType() this.getType()
this.$message({ this.$message({
type: 'success', type: 'success',
message: '删除成功!' message: res.msg
}); });
}).catch(() => { }).catch(() => {
this.$message.error(res.msg);
}); });
}, },
// //
@ -137,15 +176,13 @@ export default {
name: this.typedata name: this.typedata
}); });
if (res.msg == '成功') { if (res.msg == '成功') {
this.typedata = ''
this.dialogTableVisibles = false this.dialogTableVisibles = false
this.getType() this.getType()
} }
} }
}, },
getlists() {
this.page++
this.getList()
},
sumbit() { sumbit() {
this.dialogVisible = false this.dialogVisible = false
this.$emit('successEvent', this.selectImage) this.$emit('successEvent', this.selectImage)
@ -155,18 +192,14 @@ export default {
}, },
async getList() { async getList() {
let obj = { let obj = {
category: this.value, category: this.activedata == -1 ? '' : this.activedata,
page: this.page, page: this.page,
size: 20, size: this.activedata == -1 ? 17:18,
store_id: localStorage.getItem("shopId"), store_id: localStorage.getItem("shopId"),
} }
const res = await getcommonpicture(obj); const res = await getcommonpicture(obj);
if (this.page == 1) { this.dataImages = res.data
this.dataImages = res.data this.total = res.count
} else {
this.dataImages.push(...res.data)
}
}, },
async getType(valueIndex) { async getType(valueIndex) {
const res = await getcommonCategor({ const res = await getcommonCategor({
@ -181,4 +214,15 @@ export default {
} }
} }
} }
</script> </script>
<style scoped>
.activedata {
color: #1890ff;
}
.uplocation {
cursor: pointer;
position: absolute;
bottom: 20px;
}
</style>

View File

@ -1,32 +1,95 @@
<template> <template>
<div> <div>
<ul class="ulStyle" v-infinite-scroll="load"> <ul class="ulStyle">
<li class="upImgStyles" @click="showUpload = true" v-if="activedata == -1">
+
</li>
<li v-for="item in list" :key="item.id" class="listyle" :class="[selectList.id == item.id ? 'actives' : '']" <li v-for="item in list" :key="item.id" class="listyle" :class="[selectList.id == item.id ? 'actives' : '']"
@click="clickEvent(item)"> @click="clickEvent(item)">
<img :src="item.url" style="width: 100px;height: 100px;" alt=""> <img :src="item.url" style="width: 100px;height: 100px;" alt="">
<el-popconfirm title="确定删除吗?" class="show" @confirm="deleteEvent(item.id)"> <!-- <el-popconfirm title="确定删除吗?" class="show" @confirm="deleteEvent(item.id)">
<i class="el-icon-error buttonstyle" slot="reference"></i> <template v-if="item.pid != '681'">
</el-popconfirm> <template v-if="item.pid != '682'">
<template v-if="item.pid != '699'">
<i class="el-icon-error buttonstyle" slot="reference"></i>
</template>
</template>
</template>
</el-popconfirm> -->
</li> </li>
</ul> </ul>
<template v-if="showUpload">
<el-dialog :visible.sync="showUpload" :close-on-click-modal="false" append-to-body width="1000px"
@close="showUpload = false">
<el-upload :before-remove="handleBeforeRemove" list-type="picture-card" :on-success="handleSuccess"
:file-list="fileList" :headers="headers" :action="qiNiuUploadApi" class="upload-demo" multiple>
<i class="el-icon-plus"></i>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSubmit">确认</el-button>
</div>
</el-dialog>
</template>
</div> </div>
</template> </template>
<script> <script>
import { delimg } from "@/api/imagesPhp"; import { delimg } from "@/api/imagesPhp";
import { getToken } from "@/utils/auth";
import { mapGetters } from "vuex";
import { getcommonCategor, getcommonpicture, storeAddcategory, addImg, delcate } from "@/api/imagesPhp";
export default { export default {
props: ['list'], computed: {
...mapGetters(["qiNiuUploadApi"])
},
props: ['list', 'activedata'],
data() { data() {
return { return {
showUpload: false,
selectList: [], selectList: [],
files: [],
fileList: [],
headers: {
Authorization: getToken()
},
} }
}, },
mounted() { mounted() {
}, },
methods: { methods: {
load() { async doSubmit() {
this.$emit('getlists') this.showUpload = false;
let arr = []
if (this.files.length) {
this.files.forEach(ele => {
arr.push({
url: ele.response.data[0],
name: ele.name
})
})
const res = await addImg({
category: '',
store_id: localStorage.getItem("shopId"),
url: arr
})
if (res.code == 1) {
// this.getType(this.value)
this.$emit('getList')
this.$message.success(res.msg);
} else {
this.$message.error(res.msg);
}
this.files = [];
}
},
handleSuccess(response, file, fileList) {
this.files.push(file)
},
handleBeforeRemove(file, fileList) {
let index = this.files.findIndex(ele => ele.name == file.name)
this.files.splice(index, 1);
}, },
clickEvent(d) { clickEvent(d) {
this.selectList = d this.selectList = d
@ -51,6 +114,7 @@ ul,
li { li {
list-style: none; list-style: none;
} }
.show { .show {
position: absolute; position: absolute;
right: -10px; right: -10px;
@ -68,6 +132,7 @@ li {
background-color: #fff; background-color: #fff;
font-size: 20px; font-size: 20px;
} }
.ulStyle { .ulStyle {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
@ -76,18 +141,30 @@ li {
} }
.listyle { .listyle {
width: 110px;
height: 110px;
margin-right: 10px; margin-right: 10px;
margin-top: 10px; margin-top: 10px;
border: 5px solid #fff; border: 5px solid #fff;
position: relative; position: relative;
} }
.upImgStyles {
cursor: pointer;
width: 110px;
height: 110px;
line-height: 110px;
text-align: center;
border: 1px dashed #ccc;
border-radius: 1%;
font-size: 30px;
color: #ccc;
margin-right: 10px;
margin-top: 10px;
}
.actives { .actives {
border: 5px solid #1890ff; border: 5px solid #1890ff;
} }
</style> </style>

View File

@ -53,6 +53,9 @@
<template v-slot="scope"> <template v-slot="scope">
<span>{{ scope.row.lowPrice }}</span> <span>{{ scope.row.lowPrice }}</span>
</template> </template>
</el-table-column>
<el-table-column label="商品规格" prop="typeEnum">
</el-table-column> </el-table-column>
<el-table-column label="销量/库存"> <el-table-column label="销量/库存">
<template v-slot="scope"> <template v-slot="scope">