优化新增点单智能推荐
This commit is contained in:
@@ -603,6 +603,32 @@ export function limitTimeDiscountDel(params) {
|
||||
});
|
||||
}
|
||||
|
||||
// 点单智能推荐-分页
|
||||
export function suggestPage(params) {
|
||||
return request({
|
||||
url: `${Market_BaseUrl}/admin/suggest/page`,
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
// 点单智能推荐-添加/修改
|
||||
export function suggestPostPut(data, method = 'post') {
|
||||
return request({
|
||||
url: `${Market_BaseUrl}/admin/suggest`,
|
||||
method: method,
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
// 点单智能推荐-删除
|
||||
export function suggestDel(params) {
|
||||
return request({
|
||||
url: `${Market_BaseUrl}/admin/suggest`,
|
||||
method: 'DELETE',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ export function filterNumberInput(value, isIntegerOnly = false) {
|
||||
let filtered = value.replace(/[^\d.]/g, "");
|
||||
|
||||
// 整数模式处理
|
||||
if (isIntegerOnly) {
|
||||
if (isIntegerOnly !== false) {
|
||||
// 移除所有小数点
|
||||
filtered = filtered.replace(/\./g, "");
|
||||
|
||||
@@ -167,8 +167,8 @@ export function filterNumberInput(value, isIntegerOnly = false) {
|
||||
}
|
||||
|
||||
// 最小值限制
|
||||
if (filtered === "0" || parseInt(filtered, 10) < 1) {
|
||||
return "1";
|
||||
if (filtered === isIntegerOnly || parseInt(filtered, 10) < isIntegerOnly) {
|
||||
return isIntegerOnly;
|
||||
}
|
||||
|
||||
return filtered;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<template>
|
||||
<div class="m-4 bg-white p-4">
|
||||
<HeaderCard name="生日有礼" intro="用户生日管理设置" icon="birthdayGift" showSwitch v-model:isOpen="basicForm.isEnable">
|
||||
<HeaderCard name="生日有礼" intro="用户生日管理设置" icon="birthdayGift"
|
||||
:showSwitch="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'" v-model:isOpen="basicForm.isEnable">
|
||||
</HeaderCard>
|
||||
<el-tabs class="mt-4" v-model="activeTab" type="border-card">
|
||||
<el-tab-pane :label="item.label" v-for="item in configs" :key="item.name" :name="item.name">
|
||||
<template v-if="item.name == 'basic'">
|
||||
<el-form ref="form" :model="basicForm">
|
||||
<div class="u-m-b-10">
|
||||
<el-button type="primary" @click="refDialogPlans.open()">添加</el-button>
|
||||
<el-button type="primary" @click="refDialogPlans.open()"
|
||||
v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">添加</el-button>
|
||||
</div>
|
||||
<el-form-item label="">
|
||||
<el-table :data="basicForm.configList" border style="width: 60%">
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
<template>
|
||||
<div class="gyq_container">
|
||||
<div class="gyq_content">
|
||||
<HeaderCard name="消费返现" intro="允许客户充值并使用余额支付" icon="xffx" showSwitch v-model:isOpen="form.isEnable"></HeaderCard>
|
||||
<HeaderCard name="消费返现" intro="允许客户充值并使用余额支付" icon="xffx"
|
||||
:showSwitch="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'" v-model:isOpen="form.isEnable">
|
||||
</HeaderCard>
|
||||
<div style="padding-top: 14px;">
|
||||
<el-tabs v-model="tabsValue">
|
||||
<el-tab-pane label="基础明细" :name="1">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog title="添加兑换码" width="500px" v-model="visible" @closed="onClosedHandle">
|
||||
<el-dialog :title="form.id ? '编辑兑换码' : '添加兑换码'" width="500px" v-model="visible" @closed="onClosedHandle">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px" label-position="right">
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入" :maxlength="50" show-word-limit
|
||||
@@ -8,15 +8,18 @@
|
||||
<el-form-item label="活动日期" prop="timeScope">
|
||||
<div style="width: 350px;">
|
||||
<el-date-picker v-model="form.timeScope" type="datetimerange" range-separator="至" start-placeholder="开始日期"
|
||||
end-placeholder="结束日期" value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%;" />
|
||||
end-placeholder="结束日期" value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss" style="width: 100%;"
|
||||
:disabled="!!form.id" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="发行数量" prop="total">
|
||||
<div class="column">
|
||||
<el-input v-model="form.total" placeholder="请输入" :maxlength="8" show-word-limit style="width: 350px;"
|
||||
@input="e => form.total = filterNumberInput(e, true)">
|
||||
@input="e => form.total = filterNumberInput(e, true)" :disabled="!!form.id">
|
||||
<template #append>个</template>
|
||||
</el-input>
|
||||
<div class="tips" style="color: #999;">单次发行上限1000个,如需更多请分多次创建</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="库存" prop="stock" v-if="form.id">
|
||||
<el-input v-model="form.stock" placeholder="请输入" :maxlength="4" show-word-limit style="width: 350px;"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<el-form-item label="优惠券">
|
||||
{{form.couponInfoList.map(item => item.title).join('、')}}
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-form-item v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">
|
||||
<el-button type="primary" @click="addRef.show({ ...form })">编辑</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -68,10 +68,9 @@ import { couponRedemptionCodeList, couponRedemptionDetail, couponRedemptionCodeE
|
||||
import { downloadFile } from "@/utils/index";
|
||||
|
||||
const emit = defineEmits(['update']);
|
||||
|
||||
const addRef = ref(null);
|
||||
|
||||
const visible = ref(false);
|
||||
const shopInfo = ref(JSON.parse(localStorage.getItem("userInfo")));
|
||||
|
||||
const form = ref({
|
||||
id: '',
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<!-- 券兑换码 -->
|
||||
<template>
|
||||
<div class="gyq_container">
|
||||
<div class="gyq_content">
|
||||
<header-card name="券兑换码" intro="可添加多券组合兑换" icon="qdhm" showSwitch v-model:isOpen="queryForm.isEnable" />
|
||||
<div class="gyq_content" v-if="shopInfo.isHeadShop == 1 || isUse">
|
||||
<header-card name="券兑换码" intro="可添加多券组合兑换" icon="qdhm"
|
||||
:showSwitch="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'" v-model:isOpen="queryForm.isEnable" />
|
||||
<div class="row mt14">
|
||||
<el-form inline>
|
||||
<el-form-item>
|
||||
@@ -10,7 +11,7 @@
|
||||
<el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-form-item v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">
|
||||
<el-button type="primary" @click="addRef.show()">添加</el-button>
|
||||
<el-button type="primary" plain @click="useShopsRef.show()">适用门店</el-button>
|
||||
</el-form-item>
|
||||
@@ -20,7 +21,7 @@
|
||||
<el-table :data="tableData.list" border stripe v-loading="tableData.loading">
|
||||
<el-table-column label="ID" prop="id" width="80" />
|
||||
<el-table-column label="名称" prop="name" />
|
||||
<el-table-column label="优惠券(张)" prop="couponInfoList" width="200">
|
||||
<el-table-column label="优惠券(张)" prop="couponInfoList" width="250">
|
||||
<template #default="scope">
|
||||
<div class="column">
|
||||
<div v-for="item in scope.row.couponInfoList" :key="item.id">
|
||||
@@ -47,7 +48,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="addRef.show(scope.row)">编辑</el-button>
|
||||
<el-button link type="primary" @click="addRef.show(scope.row)"
|
||||
v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">编辑</el-button>
|
||||
<el-button link type="primary" @click="recordRef.show(scope.row)">查看</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -59,6 +61,9 @@
|
||||
:total="tableData.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="gyq_content" v-else>
|
||||
门店未参券兑换码活动,如需开启参与请联系主店
|
||||
</div>
|
||||
<useShops ref="useShopsRef" />
|
||||
<add ref="addRef" @success="getTableData" />
|
||||
<record ref="recordRef" @update="getTableData" />
|
||||
@@ -73,6 +78,7 @@ import record from "./components/record.vue";
|
||||
import { ref, reactive, onMounted } from "vue";
|
||||
import { couponRedemptionEnable, couponRedemptionList, couponRedemptionEnableStatus } from "@/api/coupon/index.js";
|
||||
|
||||
const shopInfo = ref(JSON.parse(localStorage.getItem("userInfo")));
|
||||
const useShopsRef = ref(null);
|
||||
const addRef = ref(null);
|
||||
const recordRef = ref(null);
|
||||
@@ -156,10 +162,23 @@ async function getTableData() {
|
||||
}
|
||||
|
||||
// 开关状态
|
||||
const isUse = ref(false)
|
||||
async function rechargeRedemptionEnableStatusAjax() {
|
||||
try {
|
||||
const res = await couponRedemptionEnableStatus();
|
||||
queryForm.value.isEnable = res.isEnable;
|
||||
|
||||
if (res.useType == 'all') {
|
||||
isUse.value = true
|
||||
} else {
|
||||
let currentShopId = shopInfo.value.shopId;
|
||||
res.shopIdList.some((item) => {
|
||||
if (item == currentShopId) {
|
||||
isUse.value = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer" v-if="(shopInfo.isHeadShop && shopInfo.shopType != 'only') || !form.syncId">
|
||||
<div class="dialog-footer" v-if="shopInfo.isHeadShop || shopInfo.shopType == 'only'">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="submitHandle">确 定</el-button>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<template>
|
||||
<div class="gyq_container">
|
||||
<div class="gyq_content">
|
||||
<headerCard icon="mjhd" name="满减活动" intro="达到指定支付金额享受减价" showSwitch v-model:isOpen="form.isEnableDiscount" />
|
||||
<headerCard icon="mjhd" name="满减活动" intro="达到指定支付金额享受减价"
|
||||
:showSwitch="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'" v-model:isOpen="form.isEnableDiscount" />
|
||||
<div class="row">
|
||||
<el-form :model="form" inline>
|
||||
<el-form-item>
|
||||
<el-form-item v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">
|
||||
<el-button type="primary" icon="CirclePlus" @click="addDialogRef.show()">添加</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@@ -55,8 +56,11 @@
|
||||
<el-table-column label="操作" prop="orderNo" width="120" fixed="right">
|
||||
<template #default="scope">
|
||||
<div class="center">
|
||||
<el-button link type="primary" @click="addDialogRef.show(scope.row)">编辑</el-button>
|
||||
<el-popconfirm title="确认要删除吗?" @confirm="deleteHandle(scope.row)">
|
||||
<el-button link type="primary" @click="addDialogRef.show(scope.row)"
|
||||
v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">编辑</el-button>
|
||||
<el-button link type="primary" @click="addDialogRef.show(scope.row)" v-else>查看</el-button>
|
||||
<el-popconfirm title="确认要删除吗?" @confirm="deleteHandle(scope.row)"
|
||||
v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">
|
||||
<template #reference>
|
||||
<el-button type="danger" link>删除</el-button>
|
||||
</template>
|
||||
@@ -81,6 +85,7 @@ import { ref, watch } from 'vue'
|
||||
import addDialog from './components/addDialog.vue'
|
||||
import { discountActivityPage, discountActivityDelete, shopInfoPut, shopInfoGet } from '@/api/coupon/index'
|
||||
|
||||
const shopInfo = ref(JSON.parse(localStorage.getItem('userInfo')))
|
||||
const addDialogRef = ref(null)
|
||||
|
||||
const form = ref({
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<el-option :label="item.shopName" :value="item.id" v-for="item in branchList" :key="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="活动日期" :rules="[{ required: true, message: '请选择活动日期', trigger: 'change' }]">
|
||||
<el-form-item label="活动日期" prop="validityScope">
|
||||
<div style="width: 200px">
|
||||
<el-date-picker v-model="validityScope" type="daterange" range-separator="至" start-placeholder="开始时间"
|
||||
end-placeholder="结束时间" @change="validityScopeChange" />
|
||||
@@ -32,7 +32,7 @@
|
||||
<el-checkbox value="周四" label="周四" />
|
||||
<el-checkbox value="周五" label="周五" />
|
||||
<el-checkbox value="周六" label="周六" />
|
||||
<el-checkbox value="周七" label="周日" />
|
||||
<el-checkbox value="周日" label="周日" />
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="指定时间段">
|
||||
@@ -89,7 +89,7 @@
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer" v-if="(shopInfo.isHeadShop && shopInfo.shopType != 'only') || !form.syncId">
|
||||
<div class="dialog-footer" v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="submitHandle">确 定</el-button>
|
||||
</div>
|
||||
@@ -173,7 +173,7 @@ const form = ref({
|
||||
foodType: 1, // 参与商品类型 1-全部 2-部分
|
||||
foods: "", // 指定商品 id 拼接
|
||||
useType: ["dine-in"],
|
||||
useDays: ["周一", "周二", "周三", "周四", "周五", "周六", "周七"],
|
||||
useDays: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
|
||||
useTimeType: "all",
|
||||
useStartTime: "",
|
||||
useEndTime: "",
|
||||
@@ -254,6 +254,19 @@ const formRules = reactive({
|
||||
trigger: "change",
|
||||
},
|
||||
],
|
||||
validityScope: [
|
||||
{
|
||||
required: true,
|
||||
validator: (rule, value, callback) => {
|
||||
if (!validityScope.value || validityScope.value.length == 0) {
|
||||
callback(new Error("请选择活动日期"));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
trigger: "change",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// 开始提交
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
<div class="gyq_content">
|
||||
<HeaderCard name="限时折扣" intro="批量设置商品折扣" icon="xszk"></HeaderCard>
|
||||
<div class="row mt14">
|
||||
<el-button type="primary" @click="addRef.show()">添加</el-button>
|
||||
<el-button type="primary" @click="addRef.show()"
|
||||
v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">添加</el-button>
|
||||
</div>
|
||||
<div class="row mt14">
|
||||
<el-table :data="tableData.list" stripe border v-loading="tableData.loading" height="58vh">
|
||||
@@ -33,8 +34,11 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" fixed="right" width="120">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="addRef.show(scope.row)">编辑</el-button>
|
||||
<el-popconfirm title="确认要删除吗?" @confirm="delHandle(scope.row)">
|
||||
<el-button link type="primary" @click="addRef.show(scope.row)"
|
||||
v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">编辑</el-button>
|
||||
<el-button link type="primary" @click="addRef.show(scope.row)" v-else>查看</el-button>
|
||||
<el-popconfirm title="确认要删除吗?" @confirm="delHandle(scope.row)"
|
||||
v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">
|
||||
<template #reference>
|
||||
<el-button type="danger" link>删除</el-button>
|
||||
</template>
|
||||
@@ -60,6 +64,8 @@ import HeaderCard from '../components/headerCard.vue'
|
||||
import add from './components/add.vue'
|
||||
import { limitTimeDiscountPage, limitTimeDiscountDel } from '@/api/coupon/index.js'
|
||||
|
||||
const shopInfo = ref(JSON.parse(localStorage.getItem('userInfo')) || {});
|
||||
|
||||
const addRef = ref(null);
|
||||
|
||||
// 1未开始,2进行中,3已结束 -1当前时间不可用
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<!-- 霸王餐 -->
|
||||
<template>
|
||||
<div class="gyq_container">
|
||||
<div class="gyq_content">
|
||||
<HeaderCard name="霸王餐" intro="设置充值消费的N倍,当前订单立即免单" icon="xffx" showSwitch v-model:isOpen="form.enable">
|
||||
<div class="gyq_content" v-if="shopInfo.isHeadShop == 1 || isUse">
|
||||
<HeaderCard name="霸王餐" intro="设置充值消费的N倍,当前订单立即免单" icon="xffx"
|
||||
:showSwitch="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'" v-model:isOpen="form.enable">
|
||||
</HeaderCard>
|
||||
<div class="row">
|
||||
<el-tabs v-model="tabsValue">
|
||||
@@ -62,6 +63,9 @@
|
||||
</el-tabs>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gyq_content" v-else>
|
||||
门店未参券兑换码活动,如需开启参与请联系主店
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -127,11 +131,24 @@ function submitHandle() {
|
||||
}
|
||||
|
||||
// 获取当前店铺霸王餐配置信息列表
|
||||
const isUse = ref(false)
|
||||
async function freeDingGetAjax() {
|
||||
try {
|
||||
const res = await freeDingGet();
|
||||
form.value = { ...res }
|
||||
form.value.enable = res.enable ? 1 : 0
|
||||
|
||||
if (res.useType == 'all') {
|
||||
isUse.value = true
|
||||
} else {
|
||||
let currentShopId = shopInfo.value.shopId;
|
||||
res.shopIdList.some((item) => {
|
||||
if (item == currentShopId) {
|
||||
isUse.value = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ const menus = ref([
|
||||
{
|
||||
name: "点餐智能推荐",
|
||||
icon: "dczntj",
|
||||
pathName: "",
|
||||
pathName: "order_recommendation",
|
||||
intro: "进入点单页X秒未点自动推荐商品,此推荐设置启用即生效",
|
||||
},
|
||||
{ name: "超值券包", icon: "czqb", pathName: "", intro: "下单加购" },
|
||||
|
||||
278
src/views/marketing_center/order_recommendation/add.vue
Normal file
278
src/views/marketing_center/order_recommendation/add.vue
Normal file
@@ -0,0 +1,278 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? '编辑点单智能' : '添加点单智能'" width="600px" v-model="visible" @closed="onClosed">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px" label-position="right">
|
||||
<el-form-item label="模版名称" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入模版名称" :maxlength="20" show-word-limit
|
||||
style="width: 300px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择商品" prop="foods">
|
||||
<!-- <el-cascader v-model="goodsTypeCascaderValue" :options="goodsList" :props="cascaderProps"
|
||||
:show-all-levels="false" :max-collapse-tags="3" collapse-tags clearable style="width: 300px"
|
||||
@change="selectFoodsConfirm" placeholder="请选择商品"></el-cascader> -->
|
||||
<el-select v-model="form.foods" placeholder="请选择商品" style="width: 300px;">
|
||||
<el-option v-for="item in allGoods" :key="item.id" :label="item.name" :value="item.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="自定义引导语" prop="guideDetail">
|
||||
<el-input v-model="form.guideDetail" placeholder="请输入自定义引导语" :maxlength="12" show-word-limit
|
||||
style="width: 300px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="可用周期" prop="useDays">
|
||||
<el-checkbox-group v-model="form.useDays">
|
||||
<el-checkbox value="周一" label="周一" />
|
||||
<el-checkbox value="周二" label="周二" />
|
||||
<el-checkbox value="周三" label="周三" />
|
||||
<el-checkbox value="周四" label="周四" />
|
||||
<el-checkbox value="周五" label="周五" />
|
||||
<el-checkbox value="周六" label="周六" />
|
||||
<el-checkbox value="周日" label="周日" />
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="指定时间段">
|
||||
<el-radio-group v-model="form.useTimeType">
|
||||
<el-radio label="全时段可用" value="all"></el-radio>
|
||||
<el-radio label="指定时间段可用" value="custom"></el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.useTimeType == 'custom'" prop="useTimeScope">
|
||||
<div style="width: 200px">
|
||||
<el-time-picker v-model="useTimeScope" is-range range-separator="至" start-placeholder="开始时间"
|
||||
end-placeholder="结束时间" @change="useTimeScopeChange" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visible = false;">取 消</el-button>
|
||||
<el-button type="primary" @click="handleOk" :loading="confirmLoading">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import dayjs from "dayjs";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { suggestPostPut, getProductList, getCategoryList } from "@/api/coupon/index.js";
|
||||
|
||||
const visible = ref(false);
|
||||
const confirmLoading = ref(false);
|
||||
const formRef = ref(null);
|
||||
const shopInfo = ref(JSON.parse(localStorage.getItem("userInfo")) || {});
|
||||
|
||||
const form = ref({
|
||||
id: '',
|
||||
shopId: '',
|
||||
title: '',
|
||||
foods: '',
|
||||
guideDetail: '',
|
||||
useDays: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
|
||||
useTimeType: 'all',
|
||||
useStartTime: '',
|
||||
useEndTime: '',
|
||||
});
|
||||
|
||||
const resetForm = ref('')
|
||||
|
||||
const rules = ref({
|
||||
title: [
|
||||
{ required: true, message: "请输入模版名称", trigger: "blur" },
|
||||
],
|
||||
foods: [
|
||||
{ required: true, message: "请选择商品", trigger: "change" },
|
||||
],
|
||||
useDays: [{ required: true, message: "可用周期", trigger: "change" }],
|
||||
guideDetail: [
|
||||
{ required: true, message: "请输入自定义引导语", trigger: "blur" },
|
||||
],
|
||||
useTimeScope: [
|
||||
{
|
||||
required: true,
|
||||
validator: (rule, value, callback) => {
|
||||
if (useTimeScope.value.length == 0) {
|
||||
callback(new Error('请选择指定时间段'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: "change",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
// 可用时间
|
||||
const useTimeScope = ref([]);
|
||||
function useTimeScopeChange(e) {
|
||||
if (e && e.length) {
|
||||
form.value.useStartTime = dayjs(e[0]).format("HH:mm:ss");
|
||||
form.value.useEndTime = dayjs(e[1]).format("HH:mm:ss");
|
||||
} else {
|
||||
form.value.useStartTime = "";
|
||||
form.value.useEndTime = "";
|
||||
}
|
||||
}
|
||||
|
||||
// 获取商品列表
|
||||
const cascaderProps = ref({
|
||||
multiple: true,
|
||||
emitPath: false,
|
||||
value: "id",
|
||||
label: "name",
|
||||
});
|
||||
const goodsList = ref([]);
|
||||
const allGoods = ref([]);
|
||||
async function getProductListAjax() {
|
||||
try {
|
||||
const categorys = await getCategoryList();
|
||||
const products = await getProductList();
|
||||
allGoods.value = products;
|
||||
|
||||
console.log(allGoods.value);
|
||||
|
||||
goodsList.value = formatCategoryWithProducts(categorys, products);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
// 给分类组合相应的商品
|
||||
function formatCategoryWithProducts(categories, products) {
|
||||
// 步骤1:遍历所有分类,为每个分类匹配对应的商品
|
||||
const allCategoriesWithProducts = categories.map((category) => {
|
||||
// 匹配当前分类下的商品(通过category.id === product.categoryId关联)
|
||||
const matchedProducts = products
|
||||
.filter((product) => product.categoryId === category.id) // 关键:按分类ID匹配商品
|
||||
.map((product) => ({
|
||||
id: product.id,
|
||||
name: product.name, // 提取商品的id和name
|
||||
}));
|
||||
|
||||
// 组装单个分类的结构
|
||||
return {
|
||||
id: category.id,
|
||||
name: category.name,
|
||||
children: matchedProducts, // 该分类下的商品(空数组表示无商品)
|
||||
};
|
||||
});
|
||||
|
||||
// 步骤2:过滤掉“无商品”的分类(children为空数组的分类)
|
||||
return allCategoriesWithProducts.filter((item) => item.children.length > 0);
|
||||
}
|
||||
|
||||
// 选择指定商品
|
||||
const goodsTypeCascaderValue = ref([]);
|
||||
function selectFoodsConfirm(e) {
|
||||
console.log(JSON.stringify(e));
|
||||
form.value.foods = e.join(",");
|
||||
}
|
||||
|
||||
// 开始提交
|
||||
const emit = defineEmits(['success']);
|
||||
const handleOk = () => {
|
||||
formRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
confirmLoading.value = true;
|
||||
const data = { ...form.value };
|
||||
data.shopId = shopInfo.value.shopId;
|
||||
data.useDays = form.value.useDays.join(",");
|
||||
await suggestPostPut(data, form.value.id ? 'put' : 'post');
|
||||
emit('success');
|
||||
visible.value = false;
|
||||
} catch (error) {
|
||||
console.log('error', error);
|
||||
}
|
||||
setTimeout(() => {
|
||||
confirmLoading.value = false;
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 弹窗关闭后
|
||||
const onClosed = () => {
|
||||
visible.value = false;
|
||||
form.value = { ...resetForm.value };
|
||||
formRef.value.resetFields()
|
||||
};
|
||||
|
||||
function show(obj) {
|
||||
visible.value = true;
|
||||
console.log(obj);
|
||||
if (obj && obj.id) {
|
||||
form.value = { ...obj };
|
||||
form.value.useDays = obj.useDays ? obj.useDays.split(",") : [];
|
||||
|
||||
if (form.value.useTimeType == "custom") {
|
||||
useTimeScope.value = [
|
||||
convertTimeToDate(form.value.useStartTime),
|
||||
convertTimeToDate(form.value.useEndTime),
|
||||
];
|
||||
|
||||
console.log(useTimeScope.value);
|
||||
}
|
||||
} else {
|
||||
form.value = { ...resetForm.value };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将时分秒字符串转换为完整日期格式
|
||||
* @param {string} timeStr - 时分秒字符串,格式需为 HH:mm:ss(如 '00:53:00')
|
||||
* @param {Object} options - 可选配置项
|
||||
* @param {string} [options.customDate] - 自定义日期,格式为 YYYY-MM-DD(默认使用当前日期)
|
||||
* @param {string} [options.format='YYYY-MM-DD HH:mm:ss'] - 输出的日期格式
|
||||
* @returns {string|null} 转换后的日期字符串,失败时返回 null
|
||||
*/
|
||||
function convertTimeToDate(timeStr, options = {}) {
|
||||
// 解构配置项,设置默认值
|
||||
const { customDate, format = "YYYY-MM-DD HH:mm:ss" } = options;
|
||||
|
||||
// 1. 校验时分秒格式(必须为 HH:mm:ss,允许数字1-2位)
|
||||
const timeRegex = /^\d{1,2}:\d{1,2}:\d{1,2}$/;
|
||||
if (!timeRegex.test(timeStr)) {
|
||||
console.error("时分秒格式错误,请使用 HH:mm:ss 格式(如 00:53:00)");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 2. 确定日期部分(自定义日期或当前日期)
|
||||
let datePart;
|
||||
if (customDate) {
|
||||
// 校验自定义日期格式
|
||||
if (!dayjs(customDate, "YYYY-MM-DD", true).isValid()) {
|
||||
console.error("自定义日期格式错误,请使用 YYYY-MM-DD 格式(如 2024-05-20)");
|
||||
return null;
|
||||
}
|
||||
datePart = customDate;
|
||||
} else {
|
||||
// 使用当前日期(格式:YYYY-MM-DD)
|
||||
datePart = dayjs().format("YYYY-MM-DD");
|
||||
}
|
||||
|
||||
// 3. 组合日期和时分秒,生成完整日期对象
|
||||
const fullDateTime = `${datePart} ${timeStr}`;
|
||||
const dateObj = dayjs(fullDateTime);
|
||||
|
||||
// 4. 校验完整日期是否有效(如避免 2024-02-30 这种无效日期)
|
||||
if (!dateObj.isValid()) {
|
||||
console.error("生成的日期无效,请检查日期或时分秒是否合理");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 5. 按指定格式返回日期字符串
|
||||
return dateObj.format(format);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
resetForm.value = { ...form.value };
|
||||
getProductListAjax();
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
270
src/views/marketing_center/order_recommendation/index.vue
Normal file
270
src/views/marketing_center/order_recommendation/index.vue
Normal file
@@ -0,0 +1,270 @@
|
||||
<!-- 点单智能推荐 -->
|
||||
<template>
|
||||
<div class="gyq_container">
|
||||
<div class="gyq_content">
|
||||
<HeaderCard name="点单智能推荐" intro="进入点单页X秒未点自动推荐商品,此推荐设置启用即生效" icon="dczntj" show-switch
|
||||
v-model:isOpen="form.isProductSuggest">
|
||||
</HeaderCard>
|
||||
<div class="row mt14">
|
||||
<div class="center">
|
||||
<el-button type="primary" @click="addRef.show()">添加</el-button>
|
||||
<el-button type="primary" plain @click="visible = true">首次弹窗触发事件</el-button>
|
||||
<span class="tips">多个弹窗时,每个弹窗之间关闭和弹出间隔为30秒</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt14">
|
||||
<el-table :data="tableData.list" stripe border v-loading="tableData.loading">
|
||||
<el-table-column label="ID" prop="id" width="80"></el-table-column>
|
||||
<el-table-column label="模版名称" prop="title"></el-table-column>
|
||||
<el-table-column label="生效周期" prop="useDays"></el-table-column>
|
||||
<el-table-column label="生效时段" prop="useTimeType">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.useTimeType == 'all'">全天</div>
|
||||
<div v-else>{{ scope.row.useStartTime }} - {{ scope.row.useEndTime }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="启用状态" prop="status">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0"
|
||||
@change="statusChange($event, scope.row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="addRef.show(scope.row)">编辑</el-button>
|
||||
<el-popconfirm title="确认要删除吗?" @confirm="deleteHandle(scope.row)">
|
||||
<template #reference>
|
||||
<el-button type="danger" link>删除</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="row mt14">
|
||||
<el-pagination v-model:current-page="tableData.page" v-model:page-size="tableData.size"
|
||||
:page-sizes="[10, 30, 50, 100]" background layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="tableData.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
||||
</div>
|
||||
</div>
|
||||
<add ref="addRef" @success="getTableData" />
|
||||
<el-dialog title="弹窗时间" width="500px" v-model="visible" @closed="closedHandle">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="200px" label-position="right">
|
||||
<el-form-item label="首次弹窗触发时间(秒)" prop="suggestTime">
|
||||
<div class="column">
|
||||
<div>
|
||||
<el-input v-model="form.suggestTime" placeholder="请输入触发时间"
|
||||
@input="e => form.suggestTime = filterNumberInput(e, 0)"></el-input>
|
||||
</div>
|
||||
<div class="tips">
|
||||
设置为0时,进入点餐页立即弹出
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleOk" :loading="confirmLoading">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import HeaderCard from "../components/headerCard.vue";
|
||||
import add from "./add.vue";
|
||||
import { filterNumberInput } from '@/utils'
|
||||
import { ref, reactive, onMounted, watch } from "vue";
|
||||
import { suggestPage, suggestDel, suggestPostPut, shopInfoGet, shopInfoPut } from "@/api/coupon/index.js";
|
||||
|
||||
const addRef = ref(null);
|
||||
|
||||
const form = ref({
|
||||
id: '',
|
||||
isProductSuggest: 0,
|
||||
suggestTime: ''
|
||||
});
|
||||
|
||||
const rules = ref({
|
||||
suggestTime: [
|
||||
{
|
||||
required: true,
|
||||
validator: (rule, value, callback) => {
|
||||
console.log('value==', value);
|
||||
if (value === '' || value < 0) {
|
||||
callback(new Error('请输入触发时间'))
|
||||
return
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
triiger: 'blur'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
watch(
|
||||
() => form.value.isProductSuggest,
|
||||
(newVal) => {
|
||||
if (!tableData.loading) {
|
||||
shopInfoPutAjax();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 更新店铺信息
|
||||
async function shopInfoPutAjax() {
|
||||
try {
|
||||
await shopInfoPut(form.value)
|
||||
ElNotification({
|
||||
title: '注意',
|
||||
message: '更新成功',
|
||||
type: 'success'
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取店铺信息
|
||||
async function shopInfoGetAjax() {
|
||||
try {
|
||||
const res = await shopInfoGet()
|
||||
form.value.id = res.id
|
||||
form.value.isProductSuggest = res.isProductSuggest
|
||||
form.value.suggestTime = res.suggestTime
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
const visible = ref(false)
|
||||
const confirmLoading = ref(false)
|
||||
const formRef = ref(null)
|
||||
function handleOk() {
|
||||
formRef.value.validate(async valid => {
|
||||
try {
|
||||
if (valid) {
|
||||
confirmLoading.value = true
|
||||
await shopInfoPutAjax()
|
||||
shopInfoGetAjax()
|
||||
visible.value = false
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
confirmLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function closedHandle() {
|
||||
formRef.value.resetFields()
|
||||
}
|
||||
|
||||
const tableData = reactive({
|
||||
loading: true,
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
list: [],
|
||||
})
|
||||
|
||||
// 修改状态
|
||||
async function statusChange(e, row) {
|
||||
try {
|
||||
await suggestPostPut(row, 'put');
|
||||
getTableData();
|
||||
} catch (error) {
|
||||
console.log("状态修改失败", error);
|
||||
}
|
||||
}
|
||||
|
||||
// 分页大小发生变化
|
||||
function handleSizeChange(e) {
|
||||
tableData.pageSize = e;
|
||||
consumeCashbackRecordAjax();
|
||||
}
|
||||
|
||||
// 分页发生变化
|
||||
function handleCurrentChange(e) {
|
||||
tableData.page = e;
|
||||
consumeCashbackRecordAjax();
|
||||
}
|
||||
|
||||
// 删除
|
||||
async function deleteHandle(row) {
|
||||
try {
|
||||
tableData.loading = true;
|
||||
await suggestDel({
|
||||
id: row.id
|
||||
});
|
||||
ElNotification({
|
||||
title: '注意',
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
});
|
||||
getTableData();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取表格数据
|
||||
async function getTableData() {
|
||||
try {
|
||||
tableData.loading = true;
|
||||
const res = await suggestPage({
|
||||
page: tableData.page,
|
||||
size: tableData.size,
|
||||
});
|
||||
tableData.list = res.records;
|
||||
tableData.total = res.totalRow;
|
||||
} catch (error) {
|
||||
console.log("获取表格数据失败", error);
|
||||
}
|
||||
setTimeout(() => {
|
||||
tableData.loading = false;
|
||||
}, 500);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTableData();
|
||||
shopInfoGetAjax()
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.gyq_container {
|
||||
padding: 14px;
|
||||
|
||||
.gyq_content {
|
||||
padding: 14px;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.row {
|
||||
&.mt14 {
|
||||
margin-top: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.tips {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
</style>
|
||||
@@ -8,17 +8,20 @@
|
||||
<el-form-item label="有效期" prop="timeScope">
|
||||
<div style="width: 350px;">
|
||||
<el-date-picker v-model="form.timeScope" type="datetimerange" range-separator="至" start-placeholder="开始日期"
|
||||
end-placeholder="结束日期" value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%;" />
|
||||
end-placeholder="结束日期" value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss" style="width: 100%;"
|
||||
:disabled="!!form.id" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="金额" prop="amount">
|
||||
<el-input v-model="form.amount" placeholder="请输入" :maxlength="8" show-word-limit style="width: 350px;"
|
||||
@input="e => form.amount = filterNumberInput(e)"></el-input>
|
||||
@input="e => form.amount = filterNumberInput(e)" :disabled="!!form.id"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="发行数量" prop="total">
|
||||
<div class="column">
|
||||
<el-input v-model="form.total" placeholder="请输入" :maxlength="4" show-word-limit style="width: 350px;"
|
||||
@input="e => form.total = filterNumberInput(e, true)"></el-input>
|
||||
@input="e => form.total = filterNumberInput(e, true)" :disabled="!!form.id"></el-input>
|
||||
<div class="tips" style="color: #999;">单次发行上限1000个,如需更多请分多次创建</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="库存" prop="stock" v-if="form.id">
|
||||
<el-input v-model="form.stock" placeholder="请输入" :maxlength="4" show-word-limit style="width: 350px;"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<el-form-item label="库存">
|
||||
{{ form.stock }}
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-form-item v-if="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'">
|
||||
<el-button type="primary" @click="addRef.show({ ...form })">编辑</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -68,10 +68,9 @@ import { rechargeRedemptionCodeList, rechargeRedemptionDetail, rechargeRedemptio
|
||||
import { downloadFile } from "@/utils/index";
|
||||
|
||||
const emit = defineEmits(['update']);
|
||||
|
||||
const addRef = ref(null);
|
||||
|
||||
const visible = ref(false);
|
||||
const shopInfo = ref(JSON.parse(localStorage.getItem("userInfo")));
|
||||
|
||||
const form = ref({
|
||||
id: '',
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<!-- 充值兑换码 -->
|
||||
<template>
|
||||
<div class="gyq_container">
|
||||
<div class="gyq_content">
|
||||
<header-card name="充值兑换码" intro="兑换码直充余额,可当作礼品赠送" icon="czdhm" showSwitch v-model:isOpen="queryForm.isEnable" />
|
||||
<div class="gyq_content" v-if="shopInfo.isHeadShop == 1 || isUse">
|
||||
<header-card name="充值兑换码" intro="兑换码直充余额,可当作礼品赠送" icon="czdhm"
|
||||
:showSwitch="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'" v-model:isOpen="queryForm.isEnable" />
|
||||
<div class="row mt14">
|
||||
<el-form inline>
|
||||
<el-form-item>
|
||||
@@ -10,7 +11,7 @@
|
||||
<el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-form-item v-if="shopInfo.isHeadShop || shopInfo.shopType == 'only'">
|
||||
<el-button type="primary" @click="addRef.show()">添加</el-button>
|
||||
<el-button type="primary" plain @click="useShopsRef.show()">适用门店</el-button>
|
||||
</el-form-item>
|
||||
@@ -37,7 +38,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" @click="addRef.show(scope.row)">编辑</el-button>
|
||||
<el-button link type="primary" @click="addRef.show(scope.row)"
|
||||
v-if="shopInfo.isHeadShop || shopInfo.shopType == 'only'">编辑</el-button>
|
||||
<el-button link type="primary" @click="recordRef.show(scope.row)">查看</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -49,6 +51,9 @@
|
||||
:total="tableData.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="gyq_content" v-else>
|
||||
门店未参券兑换码活动,如需开启参与请联系主店
|
||||
</div>
|
||||
<useShops ref="useShopsRef" />
|
||||
<add ref="addRef" @success="getTableData" />
|
||||
<record ref="recordRef" @update="getTableData" />
|
||||
@@ -63,6 +68,7 @@ import record from "./components/record.vue";
|
||||
import { ref, reactive, onMounted } from "vue";
|
||||
import { rechargeRedemptionPut, rechargeRedemptionList, rechargeRedemptionEnableStatus } from "@/api/coupon/index.js";
|
||||
|
||||
const shopInfo = ref(JSON.parse(localStorage.getItem("userInfo")));
|
||||
const useShopsRef = ref(null);
|
||||
const addRef = ref(null);
|
||||
const recordRef = ref(null);
|
||||
@@ -138,10 +144,23 @@ async function getTableData() {
|
||||
}
|
||||
|
||||
// 开关状态
|
||||
const isUse = ref(false)
|
||||
async function rechargeRedemptionEnableStatusAjax() {
|
||||
try {
|
||||
const res = await rechargeRedemptionEnableStatus();
|
||||
queryForm.value.isEnable = res.isEnable;
|
||||
|
||||
if (res.useType == 'all') {
|
||||
isUse.value = true
|
||||
} else {
|
||||
let currentShopId = shopInfo.value.shopId;
|
||||
res.shopIdList.some((item) => {
|
||||
if (item == currentShopId) {
|
||||
isUse.value = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<template>
|
||||
<div class="m-4 bg-white p-4">
|
||||
<HeaderCard name="超级会员" intro="用户会员管理设置" icon="super_vip" showSwitch v-model:isOpen="basicForm.isOpen"></HeaderCard>
|
||||
<div v-if="shopInfo.isHeadShop == 1 || isUse">
|
||||
<HeaderCard name="超级会员" intro="用户会员管理设置" icon="super_vip"
|
||||
:showSwitch="shopInfo.isHeadShop == 1 || shopInfo.shopType == 'only'" v-model:isOpen="basicForm.isOpen">
|
||||
</HeaderCard>
|
||||
<el-tabs class="mt-4" v-model="activeTab" type="border-card">
|
||||
<el-tab-pane :label="item.label" v-for="item in configs" :key="item.name" :name="item.name">
|
||||
<template v-if="item.name == 'basic'">
|
||||
@@ -243,7 +246,8 @@
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
</div>
|
||||
<div style="padding-top: 14px;" v-else>门店未参券兑换码活动,如需开启参与请联系主店</div>
|
||||
<DialogPlans ref="refDialogPlans" @submitSuccess="submitSuccess"></DialogPlans>
|
||||
</div>
|
||||
</template>
|
||||
@@ -257,7 +261,6 @@ import CouponLists from "./components/coup-lists.vue";
|
||||
import { ref, reactive, watch, toRaw, getCurrentInstance, onMounted } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useRouter } from "vue-router";
|
||||
import a from "@/utils/test";
|
||||
|
||||
const shopInfo = ref("");
|
||||
const inputStyle = {
|
||||
@@ -490,6 +493,7 @@ async function saveLevel(level) {
|
||||
|
||||
const shops = ref([]);
|
||||
|
||||
const isUse = ref(false)
|
||||
async function levelRefresh() {
|
||||
memberApi.levelList().then((res) => {
|
||||
if (res && res.length) {
|
||||
@@ -523,6 +527,18 @@ async function init() {
|
||||
return v;
|
||||
});
|
||||
console.log(conditionLists.value);
|
||||
|
||||
if (res.useType == 'all' || shopInfo.value.shopType == 'only') {
|
||||
isUse.value = true
|
||||
} else {
|
||||
let currentShopId = shopInfo.value.shopId;
|
||||
res.memberPriceShopIdList.some((item) => {
|
||||
if (item == currentShopId) {
|
||||
isUse.value = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
memberApi.levelList().then((res) => {
|
||||
if (res && res.length) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="gyq_container">
|
||||
<div class="gyq_content">
|
||||
<div class="gyq_content" v-if="shopInfo.isHeadShop == 1 || isUse">
|
||||
<HeaderCard name="智慧充值" intro="允许客户充值并使用余额支付" icon="zhcz" showSwitch v-model:isOpen="form.isEnable"></HeaderCard>
|
||||
<div style="padding-top: 14px">
|
||||
<el-tabs v-model="tabsValue">
|
||||
@@ -50,7 +50,7 @@
|
||||
<el-radio label="指定门店可用" value="part"></el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择门店" v-if="form.useType == 'part'">
|
||||
<el-form-item label="选择门店" v-if="form.useType == 'part'" prop="shopIdList">
|
||||
<selectBranchs all v-model="form.shopIdList" />
|
||||
</el-form-item>
|
||||
<el-form-item label="自定义金额">
|
||||
@@ -94,6 +94,7 @@
|
||||
</el-tabs>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gyq_content err" v-else>门店未参与充值活动,如需开启参与请联系主店</div>
|
||||
<AddDialog ref="AddDialogRef" :couponList="couponList" @success="addSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -135,6 +136,7 @@ const rules = ref({
|
||||
},
|
||||
],
|
||||
remark: [{ required: true, message: "请输入充值说明", trigger: "blur" }],
|
||||
shopIdList: [{ required: true, message: '请选择门店', trigger: 'change' }]
|
||||
});
|
||||
|
||||
function submitHandle() {
|
||||
@@ -215,6 +217,7 @@ function back() {
|
||||
}
|
||||
|
||||
// 配置信息获取
|
||||
const isUse = ref(false);
|
||||
async function shopRechargeGetAjax() {
|
||||
try {
|
||||
const res = await shopRechargeGet();
|
||||
@@ -225,6 +228,18 @@ async function shopRechargeGetAjax() {
|
||||
});
|
||||
form.value = res;
|
||||
|
||||
if (res.useType == 'all') {
|
||||
isUse.value = true;
|
||||
} else {
|
||||
let currentShopId = shopInfo.value.shopId;
|
||||
res.shopIdList.some((item) => {
|
||||
if (item == currentShopId) {
|
||||
isUse.value = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log('isUse', isUse.value);
|
||||
console.log(form.value);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
@@ -247,6 +262,12 @@ onMounted(async () => {
|
||||
padding: 14px;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
|
||||
&.err {
|
||||
color: #f56c6c;
|
||||
margin-top: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user