From df9a29359f33562940fe93a9cbb6528fc9f9e14e Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Fri, 22 Nov 2024 09:34:14 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A5=97=E9=A4=90=E3=80=81=E7=A7=B0=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/shop.js | 2 +- src/components/shopList/index.vue | 4 +- src/views/coupon_manage/couponEnum.js | 48 +-- src/views/product/add_shop.vue | 458 +++++++++++++++++++++----- src/views/shop/components/addShop.vue | 30 +- 5 files changed, 432 insertions(+), 110 deletions(-) diff --git a/src/api/shop.js b/src/api/shop.js index 55e9508..abdfd4d 100644 --- a/src/api/shop.js +++ b/src/api/shop.js @@ -6,7 +6,7 @@ import request from "@/utils/request"; */ export function tbProduct(params) { return request({ - url: "/api/tbProduct", + url: "/api/tbProduct/list", method: "get", params }); diff --git a/src/components/shopList/index.vue b/src/components/shopList/index.vue index c59d543..9d3396f 100644 --- a/src/components/shopList/index.vue +++ b/src/components/shopList/index.vue @@ -54,7 +54,7 @@ - + 选择 @@ -146,6 +146,8 @@ export default { categoryId: this.searhForm.category, shopId: localStorage.getItem('shopId'), sort: 'id', + createdAt: [], + sort: 'createdAt,desc' }) this.tableData.list = res.content this.tableData.total = res.totalElements diff --git a/src/views/coupon_manage/couponEnum.js b/src/views/coupon_manage/couponEnum.js index f4cbaf5..0b246e5 100644 --- a/src/views/coupon_manage/couponEnum.js +++ b/src/views/coupon_manage/couponEnum.js @@ -1,51 +1,51 @@ export default { classType: [ { - value: 'product', - label: '商品券' + value: "product", + label: "商品券" }, { - value: 'common', - label: '通用券' + value: "common", + label: "通用券" } ], type: [ { - value: '0', - label: '满减' + value: "0", + label: "满减" }, { - value: '1', - label: '折扣' + value: "1", + label: "折扣" } ], cycle: [ - { label: '周一' }, - { label: '周二' }, - { label: '周三' }, - { label: '周四' }, - { label: '周五' }, - { label: '周六' }, - { label: '周七' } + { label: "周一", value: "Monday" }, + { label: "周二", value: "Tuesday" }, + { label: "周三", value: "Wednesday" }, + { label: "周四", value: "Thursday" }, + { label: "周五", value: "Friday" }, + { label: "周六", value: "Saturday" }, + { label: "周七", value: "Sunday" } ], validityType: [ { - value: 'fixed', - label: '领券后有效期内可用' + value: "fixed", + label: "领券后有效期内可用" }, { - value: 'custom', - label: '固定有效期范围内可用' + value: "custom", + label: "固定有效期范围内可用" } ], useTimeType: [ { - value: 'all', - label: '全时段可用' + value: "all", + label: "全时段可用" }, { - value: 'custom', - label: '指定时间段' + value: "custom", + label: "指定时间段" } ] -} +}; diff --git a/src/views/product/add_shop.vue b/src/views/product/add_shop.vue index abc83fd..e468e83 100644 --- a/src/views/product/add_shop.vue +++ b/src/views/product/add_shop.vue @@ -1,9 +1,8 @@ - + {{ item.label }} @@ -13,7 +12,7 @@ - + --> @@ -58,46 +57,110 @@ 注:第一张图为商品封面图,图片尺寸为750×750 - - - - - - - - - - - - - - {{ item.name }} - x{{ item.groupNum }} - - - - - - - - - - {{ scope.row.goods.length }}选 - - - - - - 添加商品 - 删除分组 - - - - 添加分组 - + + + 堂食 + 自取 + 配送 + 快递 + - + + + 普通商品 + 套餐类型 + 称重 + + + + + 单规格 + 多规格 + + + + + + 固定套餐 + 可选套餐 + + + + + + + + + + + + + + + + + 添加商品 + + + 设置规格 + 删除 + + + + + + + + + + + + + + + 删除 + + + + + + + + + + + + + + + 添加商品 + + + 设置规格 + 删除 + + + + + + 添加套餐组 + + + @@ -207,7 +270,7 @@ - + @@ -217,7 +280,7 @@ - + @@ -331,6 +394,36 @@ 注:小程序商城必须设置库存数量大于0 --> + + + 千克 + + 用于快递或配送运费计重 + + + + 允许 + 不允许 + + + + + + + + + + + + + + + {{ item.label }} + + + + + + + + + + + + 选项值 + + {{ item.specSnap }} + + + + + + 取 消 + 确 定 + + @@ -426,6 +542,7 @@ import settings from "@/settings"; import dayjs from "dayjs"; import { RandomNumBoth } from "@/utils"; import { formatPrice } from "@/utils/format"; +import couponEnum from '@/views/coupon_manage/couponEnum.js' export default { components: { @@ -455,6 +572,7 @@ export default { } } return { + couponEnum, shopTypesActive: 0, shopTypes: settings.typeEnum, specTableHeaders: [], @@ -480,9 +598,19 @@ export default { isEditor: false, loading: false, originSkuList: [], + showSelectSku: false, + selectSkuItem: { + skuList: [] + }, + selectSkuTableIndex: 0, + selectSkuConfirmIndex: 0, + selectSkuConfirmDisabled: true, + addGroupIndex: false, form: { id: "", + type: 'normal', typeEnum: "normal", + groupType: '0', name: "", shortTitle: "", //商品介绍 unitId: "", @@ -491,6 +619,7 @@ export default { coverImg: "", images: [], shopId: localStorage.getItem("shopId"), + showType: ['table'], lowPrice: "", skuList: [], isShowMall: 1, @@ -500,6 +629,14 @@ export default { specId: "", baseSalesNumber: 0, sort: 0, + proGroupVo: [ + { + title: '', + count: '', + number: '', + goods: [] + } + ], groupSnap: [], specInfo: [], selectSpec: [], @@ -520,8 +657,17 @@ export default { }, stockNumber: 0, isHot: 1, - isGrounding: 1 + isGrounding: 1, + isTempPrice: '1', + dayLimit: 0, + singleOrderLimit: 0, + singlePeopleLimit: 0, + weight: '', + days: [], + startTime: '', + endTime: '' }, + useTime: ['', ''], imgList: [], rules: { typeEnum: [ @@ -529,6 +675,13 @@ export default { required: true, }, ], + showType: [ + { + required: true, + trigger: "change", + message: "至少选择一项", + } + ], name: [ { required: true, @@ -602,7 +755,7 @@ export default { batchNumberForm: { batchNumber: 0, }, - routequery:'' + routequery: '' }; }, mounted() { @@ -627,7 +780,75 @@ export default { } } }, - methods: { + methods: { + useTimeChange(e) { + this.form.startTime = e[0] + this.form.endTime = e[1] + }, + // 套餐类型切换 + typeChange() { + this.form.typeEnum = 'normal' + if (this.form.groupType == 0) { + this.$set(this.form.proGroupVo, 0, { + title: '', + count: '', + number: 1, + goods: [] + }) + } else { + this.form.proGroupVo = [] + } + this.changeTypeEnum() + }, + // 确认套餐商品设置规格 + showSelectSkuConfirm() { + let item = this.selectSkuItem.skuList.filter(item => item.active) + + this.$set(this.form.proGroupVo[this.selectSkuTableIndex].goods, this.selectSkuConfirmIndex, { ...this.form.proGroupVo[this.selectSkuTableIndex].goods[this.selectSkuConfirmIndex], skuId: item[0].id }) + this.$set(this.form.proGroupVo[this.selectSkuTableIndex].goods, this.selectSkuConfirmIndex, { ...this.form.proGroupVo[this.selectSkuTableIndex].goods[this.selectSkuConfirmIndex], skuName: item[0].specSnap }) + + this.showSelectSku = false + // console.log(this.form.proGroupVo.goods[this.selectSkuConfirmIndex] + }, + // 选择套餐商品sku + selectSkuHandle(item, index) { + // 把所有的设置为false + this.selectSkuItem.skuList.map((item, index) => { + let nitem = { ...item } + nitem.active = false + this.$set(this.selectSkuItem.skuList, index, nitem) + }) + + if (item.active) { + item.active = false + this.$set(this.selectSkuItem.skuList, index, { ...item }) + } else { + item.active = true + this.$set(this.selectSkuItem.skuList, index, { ...item }) + } + + let arr = this.selectSkuItem.skuList.filter(item => item.active) + + if (arr.length) { + this.selectSkuConfirmDisabled = false + } else { + this.selectSkuConfirmDisabled = true + } + }, + // 显示套餐商品设置规格 + showSelectSkuHandle(row, index, tabIndex) { + this.selectSkuTableIndex = tabIndex + this.selectSkuConfirmIndex = index + this.showSelectSku = true + + let obj = { ...row } + + obj.skuList.map(item => { + item.active = false + }) + + this.selectSkuItem = obj + }, uploadImgSucess(res, item) { console.log(res); console.log(item); @@ -735,7 +956,15 @@ export default { url: item, }; }); + + res.days = res.days.split(',') + res.showType = res.showType.split(',') + res.isTempPrice = JSON.stringify(res.isTempPrice) + this.form = res; + + this.useTime = [res.startTime, res.endTime] + if (res.typeEnum == "sku") { let skuList = [...res.skuList]; let specInfo = JSON.parse(res.specInfo); @@ -767,27 +996,31 @@ export default { // 提交 submitHandle() { - // 如果找到undefined,立即停止搜索并返回true - const hasUndefined = this.form.skuList.some(obj => { - for (const key in obj) { - if (this.shopTypesActive == 0) {//单规格判断 - if (obj['salePrice'] == undefined || obj['memberPrice'] == undefined) { - return true; - } - } else {//多规格判断 - if (obj['salePrice'] == undefined || obj['memberPrice'] == undefined || obj['costPrice'] == undefined || obj['originPrice'] == undefined) { - return true; + console.log(this.form); + // return + if (this.form.type == 'normal') { + // 如果找到undefined,立即停止搜索并返回true + const hasUndefined = this.form.skuList.some(obj => { + for (const key in obj) { + if (this.form.typeEnum == 'normal') {//单规格判断 + if (obj['salePrice'] == undefined || obj['memberPrice'] == undefined) { + return true; + } + } else {//多规格判断 + if (obj['salePrice'] == undefined || obj['memberPrice'] == undefined || obj['costPrice'] == undefined || obj['originPrice'] == undefined) { + return true; + } } } - } - return false; - }); - if (hasUndefined) { - this.$message({ - message: "请完善规格属性的参数!", - type: "warning", + return false; }); - return false; + if (hasUndefined) { + this.$message({ + message: "请完善规格属性的参数!", + type: "warning", + }); + return false; + } } let arr = []; @@ -807,6 +1040,10 @@ export default { this.form.specInfo = JSON.stringify(this.form.skuList); // this.form.skuList[0].costPrice = 0 this.form.skuList[0].originPrice = this.form.skuList[0].salePrice + + this.form.showType = this.form.showType.join(',') + this.form.days = this.form.days.join(',') + if (this.form.id) { await tbProductPut(this.form); } else { @@ -833,30 +1070,45 @@ export default { }, // 分组选择商品 selectShopRes(res) { - let arr = res.map((item) => { - item.groupNum = 1; - return item; - }); - if (this.tableAddShopIndex != null) { - this.form.groupSnap[this.tableAddShopIndex].goods = [...arr]; - this.tableAddShopIndex = null; + let newres = res.map(item => { + item.proId = item.id + item.proName = item.name + item.price = item.lowPrice + item.skuId = '' + item.skuName = '' + item.number = 1 + return item + }) + if (this.form.groupType == 0) { + let obj = { + title: '', + count: newres.length, + number: '', + goods: newres + } + this.form.proGroupVo = [{ ...obj }] } else { - this.form.groupSnap.push({ - title: "", - goods: [...arr], - number: 1, - }); + if (this.addGroupIndex !== false) { + this.form.proGroupVo[this.addGroupIndex].goods = newres + } else { + let arr = [...this.form.proGroupVo] + arr.push({ + title: '', + count: newres.length, + number: '', + goods: newres + }) + this.form.proGroupVo = [...arr] + } } - - console.log(this.form.groupSnap); }, // 切换类型 changeTypeEnum(index) { // if (this.form.id) return; - this.shopTypesActive = index; - const typeEnum = this.shopTypes[index].typeEnum; - this.form.typeEnum = typeEnum; - if (typeEnum == "sku") { + // this.shopTypesActive = index; + // const typeEnum = this.shopTypes[index].typeEnum; + // this.form.typeEnum = typeEnum; + if (this.form.typeEnum == "sku") { this.form.skuList = []; this.tbProductSpecGet(); } else { @@ -1149,4 +1401,44 @@ export default { .showStyle:hover>.buttonstyle { display: block; } + +.pro_sku { + .item { + .row { + display: flex; + align-items: center; + + &:not(:first-child) { + margin-top: 20px; + } + + .title { + width: 80px; + } + + .tag { + background-color: #F7F7FA; + padding: 6px 12px; + margin-right: 10px; + border-radius: 4px; + + &.no { + background: none; + padding: 6px 0; + } + + &.active { + background-color: #46A6FF; + color: #fff; + } + } + } + } +} + +.group_wrap { + padding: 20px; + background-color: #F7F7FA; + margin-bottom: 20px; +} diff --git a/src/views/shop/components/addShop.vue b/src/views/shop/components/addShop.vue index 8a11f3a..4088f28 100644 --- a/src/views/shop/components/addShop.vue +++ b/src/views/shop/components/addShop.vue @@ -5,6 +5,9 @@ + + + @@ -16,13 +19,28 @@ - + 快餐版 餐饮版 请谨慎修改!!! + + + 单店 + 连锁店 + 加盟店 + + 请谨慎修改!!! + + + + 不可直接管理 + 直接管理 + + 请谨慎修改!!! + 试用 @@ -161,6 +179,9 @@ export default { form: { id: '', shopName: '', + mainId: '', + type: 'only', + tube_type: '0', registerType: 'restaurant', profiles: 'release', registerCode: '', @@ -189,6 +210,13 @@ export default { trigger: 'blur' } ], + mainId: [ + { + required: true, + message: ' ', + trigger: 'blur' + } + ], provinces: [ { required: true, From cf9a6d03ff3d34f42af0995804a2d00e5fd85383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=95=BE?= <1144797966@qq.com> Date: Fri, 22 Nov 2024 09:43:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8F=B0=E6=A1=8C=E9=A2=84=E8=AE=A2?= =?UTF-8?q?=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/shop/components/shopInfo.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/views/shop/components/shopInfo.vue b/src/views/shop/components/shopInfo.vue index f55a2bd..cd0efc4 100644 --- a/src/views/shop/components/shopInfo.vue +++ b/src/views/shop/components/shopInfo.vue @@ -157,6 +157,9 @@ + + + 营业中 From 19aaea45599d8e7b0f30229958f8342c0981cd45 Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Fri, 22 Nov 2024 15:36:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E9=80=89=E6=8B=A9=E4=B8=BB=E8=B4=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/shop/components/addShop.vue | 51 ++++++++++++++++++++------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/src/views/shop/components/addShop.vue b/src/views/shop/components/addShop.vue index 4088f28..dff83dc 100644 --- a/src/views/shop/components/addShop.vue +++ b/src/views/shop/components/addShop.vue @@ -5,8 +5,20 @@ - - + + + 单店 + 连锁店 + 加盟店 + + 请谨慎修改!!! + + + + + @@ -26,14 +38,6 @@ 请谨慎修改!!! - - - 单店 - 连锁店 - 加盟店 - - 请谨慎修改!!! - 不可直接管理 @@ -54,7 +58,7 @@ - + @@ -153,7 +157,7 @@ import { getToken } from '@/utils/auth' import { mapGetters } from 'vuex' import crudQiNiu from '@/api/tools/qiniu' -import { tbShopInfoPost, geocode } from '@/api/shop' +import { tbShopInfoPost, geocode, tbShopInfo } from '@/api/shop' export default { computed: { ...mapGetters([ @@ -259,13 +263,32 @@ export default { amapOptions: { center: [108.946465, 34.347984], position: [] - } + }, + shopListLoading: false, + shopList: [] } }, mounted() { this.resetForm = { ...this.form } }, methods: { + // 获取商家列表 + async getTableData(query = '') { + this.shopListLoading = true + try { + const res = await tbShopInfo({ + page: 0, + size: 100, + shopName: query, + type: 'only' + }) + this.shopListLoading = false + this.shopList = res.content + } catch (error) { + this.shopListLoading = false + console.log(error) + } + }, onSearchResult(res) { this.locationSearchList = res this.amapOptions.center = [res[0].lng, res[0].lat] @@ -348,6 +371,8 @@ export default { } }, show(obj) { + this.getTableData() + this.dialogVisible = true if (obj && obj.id) { this.form = { ...obj }