Merge branch 'ymf' of https://e.coding.net/g-cphe0354/cashier/cashier-web
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import VersionApi, { type addRequest } from "@/api/system/version";
|
||||
import { sourceOptions, typeOptions, isForceOptions } from "./config";
|
||||
import API, { type addRequest } from "@/api/system/miniAppPages";
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
|
||||
const modalConfig: IModalConfig<addRequest> = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "新增版本",
|
||||
title: "新增小程序页面",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
@@ -13,75 +12,78 @@ const modalConfig: IModalConfig<addRequest> = {
|
||||
labelWidth: 140,
|
||||
},
|
||||
formAction: function (data) {
|
||||
return VersionApi.add({ ...data, url: typeof data.url === "string" ? data.url : data.url[0] });
|
||||
if (data.icon) {
|
||||
data.icon = typeof data.icon === "string" ? data.icon : data.icon[0]
|
||||
}
|
||||
return API.add(data);
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
|
||||
{
|
||||
label: "渠道",
|
||||
prop: "source",
|
||||
rules: [{ required: true, message: "请选择渠道", trigger: "blur" }],
|
||||
type: "select",
|
||||
type: "UpImage",
|
||||
label: "图标",
|
||||
prop: "icon",
|
||||
rules: [{ required: false, message: "请上传图标", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请选择渠道",
|
||||
placeholder: "请上传图标",
|
||||
},
|
||||
options: sourceOptions,
|
||||
},
|
||||
{
|
||||
label: "类型",
|
||||
prop: "type",
|
||||
rules: [{ required: true, message: "请选择类型", trigger: "blur" }],
|
||||
type: "select",
|
||||
attrs: {
|
||||
placeholder: "请选择类型",
|
||||
},
|
||||
col: {
|
||||
xs: 24,
|
||||
sm: 12,
|
||||
},
|
||||
options: typeOptions,
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
label: "版本号",
|
||||
prop: "version",
|
||||
rules: [{ required: true, message: "请输入版本号", trigger: "blur" }],
|
||||
label: "小程序页面名称",
|
||||
prop: "name",
|
||||
rules: [{ required: true, message: "请输入小程序页面名称", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入版本号",
|
||||
placeholder: "请输入小程序页面名称",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "radio",
|
||||
label: "是否强制更新",
|
||||
prop: "isForce",
|
||||
rules: [{ required: true, message: "请输入版本号", trigger: "blur" }],
|
||||
type: "input",
|
||||
label: "小程序页面路径",
|
||||
prop: "path",
|
||||
rules: [{ required: true, message: "请输入小程序页面路径", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入版本号",
|
||||
placeholder: "请输入小程序页面路径",
|
||||
},
|
||||
initialValue: 0,
|
||||
options: isForceOptions,
|
||||
},
|
||||
{
|
||||
type: "textarea",
|
||||
label: "更新提示内容",
|
||||
prop: "message",
|
||||
rules: [{ required: true, message: "请输入更新提示内容", trigger: "blur" }],
|
||||
label: "页面描述",
|
||||
prop: "description",
|
||||
rules: [{ required: false, message: "请输入页面描述", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入更新提示内容",
|
||||
placeholder: "请输入页面描述",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "custom",
|
||||
label: "版本文件",
|
||||
prop: "url",
|
||||
rules: [{ required: true, message: "请上传版本文件", trigger: "blur" }],
|
||||
type: "input-number",
|
||||
label: "排序",
|
||||
prop: "sort",
|
||||
rules: [{ required: false, message: "请输入排序", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请上传版本文件",
|
||||
placeholder: "请输入排序",
|
||||
},
|
||||
initialValue: [],
|
||||
initialValue: 0,
|
||||
},
|
||||
{
|
||||
type: "radio-button",
|
||||
label: "小程序页面状态",
|
||||
prop: "status",
|
||||
options: [
|
||||
{
|
||||
label: "启用",
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: "禁用",
|
||||
value: 0,
|
||||
},
|
||||
],
|
||||
initialValue: 1,
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -1,31 +1,17 @@
|
||||
import { property } from "lodash";
|
||||
|
||||
export const sourceOptions: options[] = [
|
||||
{ label: "桌面端", value: "pc" },
|
||||
{ label: "管理端", value: "manager_app" },
|
||||
{ label: "电话机点餐", value: "phone_book " },
|
||||
];
|
||||
export const typeOptions: options[] = [
|
||||
{ label: "windows", value: "0" },
|
||||
{ label: "安卓", value: "1" },
|
||||
{ label: "IOS", value: "2" },
|
||||
];
|
||||
export const isForceOptions: options[] = [
|
||||
{ label: "不强制更新", value: 0 },
|
||||
{ label: "强制更新", value: 1 },
|
||||
export const statusOptions: options[] = [
|
||||
{ label: "全部", value: '' },
|
||||
{ label: "启用", value: 1 },
|
||||
{ label: "禁用", value: 0 },
|
||||
];
|
||||
|
||||
export type optionsType = "source" | "type" | "isForce";
|
||||
|
||||
export type optionsType = "status";
|
||||
|
||||
export function returnOptions(type: optionsType) {
|
||||
if (type === "source") {
|
||||
return sourceOptions;
|
||||
}
|
||||
if (type === "type") {
|
||||
return typeOptions;
|
||||
}
|
||||
if (type === "isForce") {
|
||||
return isForceOptions;
|
||||
if (type === "status") {
|
||||
return statusOptions;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import VersionApi from "@/api/system/version";
|
||||
import type { editRequest } from "@/api/system/version";
|
||||
import API, { type editRequest } from "@/api/system/miniAppPages";
|
||||
import type { IContentConfig } from "@/components/CURD/types";
|
||||
|
||||
const contentConfig: IContentConfig<editRequest> = {
|
||||
@@ -15,61 +14,50 @@ const contentConfig: IContentConfig<editRequest> = {
|
||||
pageSizes: [10, 20, 30, 50],
|
||||
},
|
||||
indexAction: function (params) {
|
||||
return VersionApi.getList();
|
||||
return API.getList(params);
|
||||
},
|
||||
deleteAction: VersionApi.delete,
|
||||
deleteAction: API.delete,
|
||||
// modifyAction: function (data) {
|
||||
// // return VersionApi.edit(data);
|
||||
// // return API.edit(data);
|
||||
// },
|
||||
pk: "id",
|
||||
toolbar: ["add"],
|
||||
defaultToolbar: ["refresh", "filter", "search"],
|
||||
cols: [
|
||||
{ type: "selection", width: 50, align: "center" },
|
||||
{ label: "id", align: "center", prop: "id", width: 100, show: true },
|
||||
{
|
||||
label: "渠道",
|
||||
label: "小程序页面名称",
|
||||
align: "center",
|
||||
prop: "source",
|
||||
width: 120,
|
||||
prop: "name",
|
||||
},
|
||||
{
|
||||
label: "图标",
|
||||
align: "center",
|
||||
prop: "icon",
|
||||
templet: "custom",
|
||||
slotName: "options",
|
||||
slotName: "icon",
|
||||
},
|
||||
{
|
||||
label: "类型",
|
||||
label: "小程序页面路径",
|
||||
align: "center",
|
||||
prop: "type",
|
||||
width: 120,
|
||||
prop: "path",
|
||||
},
|
||||
{
|
||||
label: "页面描述",
|
||||
align: "center",
|
||||
prop: "description",
|
||||
},
|
||||
{
|
||||
label: "排序",
|
||||
align: "center",
|
||||
prop: "sort",
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
align: "center",
|
||||
prop: "status",
|
||||
templet: "custom",
|
||||
slotName: "options",
|
||||
},
|
||||
{
|
||||
label: "版本号",
|
||||
align: "center",
|
||||
width: 120,
|
||||
prop: "version",
|
||||
},
|
||||
|
||||
{
|
||||
label: "是否强制升级",
|
||||
align: "center",
|
||||
prop: "isForce",
|
||||
width: 120,
|
||||
templet: "switch",
|
||||
slotName: "isForce",
|
||||
},
|
||||
{
|
||||
label: "更新内容",
|
||||
align: "center",
|
||||
prop: "message",
|
||||
width: 240,
|
||||
},
|
||||
{
|
||||
label: "下载地址",
|
||||
align: "center",
|
||||
prop: "url",
|
||||
templet: "url",
|
||||
slotName: "url",
|
||||
slotName: "status",
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
|
||||
@@ -1,86 +1,91 @@
|
||||
import VersionApi, { type editRequest } from "@/api/system/version";
|
||||
import API, { type editRequest } from "@/api/system/miniAppPages";
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
import { sourceOptions, typeOptions, isForceOptions } from "./config";
|
||||
|
||||
const modalConfig: IModalConfig<editRequest> = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "编辑版本",
|
||||
title: "编辑小程序页面",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
pk: "id",
|
||||
form: {
|
||||
labelWidth: 140,
|
||||
},
|
||||
formAction: function (data) {
|
||||
return VersionApi.edit({ ...data, url: typeof data.url === "string" ? data.url : data.url[0] });
|
||||
if (data.icon) {
|
||||
data.icon = typeof data.icon === "string" ? data.icon : data.icon[0]
|
||||
}
|
||||
return API.edit(data);
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
|
||||
{
|
||||
label: "渠道",
|
||||
prop: "source",
|
||||
rules: [{ required: true, message: "请选择渠道", trigger: "blur" }],
|
||||
type: "select",
|
||||
type: "UpImage",
|
||||
label: "图标",
|
||||
prop: "icon",
|
||||
rules: [{ required: false, message: "请上传图标", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请选择渠道",
|
||||
placeholder: "请上传图标",
|
||||
},
|
||||
options: sourceOptions,
|
||||
},
|
||||
{
|
||||
label: "类型",
|
||||
prop: "type",
|
||||
rules: [{ required: true, message: "请选择类型", trigger: "blur" }],
|
||||
type: "select",
|
||||
attrs: {
|
||||
placeholder: "请选择类型",
|
||||
},
|
||||
col: {
|
||||
xs: 24,
|
||||
sm: 12,
|
||||
},
|
||||
options: typeOptions,
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
label: "版本号",
|
||||
prop: "version",
|
||||
rules: [{ required: true, message: "请输入版本号", trigger: "blur" }],
|
||||
label: "小程序页面名称",
|
||||
prop: "name",
|
||||
rules: [{ required: true, message: "请输入小程序页面名称", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入版本号",
|
||||
placeholder: "请输入小程序页面名称",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "radio",
|
||||
label: "是否强制更新",
|
||||
prop: "isForce",
|
||||
rules: [{ required: true, message: "请输入版本号", trigger: "blur" }],
|
||||
type: "input",
|
||||
label: "小程序页面路径",
|
||||
prop: "path",
|
||||
rules: [{ required: true, message: "请输入小程序页面路径", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入版本号",
|
||||
placeholder: "请输入小程序页面路径",
|
||||
},
|
||||
initialValue: 0,
|
||||
options: isForceOptions,
|
||||
},
|
||||
{
|
||||
type: "textarea",
|
||||
label: "更新提示内容",
|
||||
prop: "message",
|
||||
rules: [{ required: true, message: "请输入更新提示内容", trigger: "blur" }],
|
||||
label: "页面描述",
|
||||
prop: "description",
|
||||
rules: [{ required: false, message: "请输入页面描述", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入更新提示内容",
|
||||
placeholder: "请输入页面描述",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "custom",
|
||||
label: "版本文件",
|
||||
prop: "url",
|
||||
rules: [{ required: true, message: "请上传版本文件", trigger: "blur" }],
|
||||
type: "input-number",
|
||||
label: "排序",
|
||||
prop: "sort",
|
||||
rules: [{ required: false, message: "请输入排序", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请上传版本文件",
|
||||
placeholder: "请输入排序",
|
||||
},
|
||||
initialValue: [],
|
||||
initialValue: 0,
|
||||
},
|
||||
{
|
||||
type: "radio-button",
|
||||
label: "小程序页面状态",
|
||||
prop: "status",
|
||||
options: [
|
||||
{
|
||||
label: "启用",
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: "禁用",
|
||||
value: 0,
|
||||
},
|
||||
],
|
||||
initialValue: 1,
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||||
export default reactive(modalConfig);
|
||||
|
||||
@@ -1,20 +1,39 @@
|
||||
import type { ISearchConfig } from "@/components/CURD/types";
|
||||
|
||||
import { statusOptions } from './config'
|
||||
const searchConfig: ISearchConfig = {
|
||||
pageName: "sys:user",
|
||||
formItems: [
|
||||
{
|
||||
type: "input",
|
||||
label: "版本号",
|
||||
prop: "keywords",
|
||||
label: "小程序页面路径",
|
||||
prop: "name",
|
||||
attrs: {
|
||||
placeholder: "请输入版本号",
|
||||
placeholder: "请输入小程序页面路径",
|
||||
clearable: true,
|
||||
style: {
|
||||
width: "200px",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
label: "小程序页面路径",
|
||||
prop: "path",
|
||||
attrs: {
|
||||
placeholder: "请输入小程序页面路径",
|
||||
clearable: true,
|
||||
style: {
|
||||
width: "200px",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "radio-button",
|
||||
label: "小程序页面状态",
|
||||
prop: "status",
|
||||
options: statusOptions,
|
||||
initialValue: '',
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,13 @@
|
||||
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #icon="scope">
|
||||
<el-image
|
||||
style="width: 50px; height: 50px"
|
||||
:src="scope.row[scope.prop]"
|
||||
:preview-src-list="[scope.row[scope.prop]]"
|
||||
/>
|
||||
</template>
|
||||
<template #options="scope">
|
||||
{{ returnOptionsLabel(scope.prop, scope.row[scope.prop]) }}
|
||||
</template>
|
||||
@@ -99,8 +106,8 @@ async function handleEditClick(row: IObject) {
|
||||
editModalRef.value?.setModalVisible();
|
||||
// 根据id获取数据进行填充
|
||||
// const data = await Api.getFormData(row.id);
|
||||
console.log({ ...row, url: [row.url] });
|
||||
editModalRef.value?.setFormData({ ...row, url: [row.url] });
|
||||
console.log({ ...row, icon: row.icon ? [row.icon] : [] });
|
||||
editModalRef.value?.setFormData({ ...row, icon: row.icon ? [row.icon] : [] });
|
||||
}
|
||||
1;
|
||||
// 其他工具栏
|
||||
|
||||
1479
src/views/data/index copy.vue
Normal file
1479
src/views/data/index copy.vue
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@
|
||||
<el-radio-button :value="1">员工</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item prop="merchantName" v-if="state.loginForm.loginType == 'staff'">
|
||||
<el-form-item prop="merchantName" v-if="state.loginForm.loginType == 1">
|
||||
<el-input
|
||||
v-model="state.loginForm.merchantName"
|
||||
type="text"
|
||||
@@ -145,7 +145,7 @@ function getCookie() {
|
||||
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
|
||||
code: "",
|
||||
merchantName: "",
|
||||
loginType: "merchant",
|
||||
loginType: 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
::v-deep(.el-dialog__header) {
|
||||
:deep(.el-dialog__header) {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1 +1,52 @@
|
||||
<template>11</template>
|
||||
<template>
|
||||
<div v-for="(item, index) in list" :key="index">
|
||||
<h4 class="title">
|
||||
{{ item.label }}
|
||||
</h4>
|
||||
<div v-if="item.children" class="flex gap-10">
|
||||
<el-checkbox-group v-model="model[index]">
|
||||
<el-checkbox
|
||||
v-for="(child, childIndex) in item.children"
|
||||
:key="childIndex"
|
||||
:value="child.id"
|
||||
:label="child.label"
|
||||
:style="returnStyle(child)"
|
||||
></el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
list: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const model = defineModel({ type: Array, default: () => [] });
|
||||
|
||||
const importantPer = ["允许收款", "允许打折", "允许修改会员余额", "允许沽清"];
|
||||
function returnStyle(child) {
|
||||
if (importantPer.includes(child.label)) {
|
||||
return "color:red";
|
||||
}
|
||||
}
|
||||
for (const item in props.list) {
|
||||
console.log(item);
|
||||
model[item] = [];
|
||||
}
|
||||
function getFormData() {
|
||||
return formData;
|
||||
}
|
||||
defineExpose({
|
||||
getFormData,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped >
|
||||
.title {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
@@ -144,12 +144,7 @@ const modalConfig: IModalConfig<addRequest> = {
|
||||
sm: 12,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "员工权限设置",
|
||||
prop: "",
|
||||
type: "title",
|
||||
slotName: "title",
|
||||
},
|
||||
|
||||
{
|
||||
label: "是否允许管理端登录",
|
||||
prop: "isManage",
|
||||
@@ -170,6 +165,20 @@ const modalConfig: IModalConfig<addRequest> = {
|
||||
],
|
||||
initialValue: 1,
|
||||
},
|
||||
{
|
||||
label: "员工权限设置",
|
||||
prop: "",
|
||||
type: "title",
|
||||
slotName: "title",
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
prop: 'permission',
|
||||
slotName: 'permission',
|
||||
label: '',
|
||||
hidden: true
|
||||
}
|
||||
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const modalConfig: IModalConfig<editRequest> = {
|
||||
{
|
||||
label: "角色",
|
||||
prop: "roleId",
|
||||
rules: [{ required: true, message: "请选择角色", trigger: "blur" }],
|
||||
rules: [{ required: false, message: "请选择角色", trigger: "blur" }],
|
||||
type: "select",
|
||||
attrs: {
|
||||
placeholder: "请选择角色",
|
||||
@@ -54,7 +54,7 @@ const modalConfig: IModalConfig<editRequest> = {
|
||||
{
|
||||
label: "员工编号",
|
||||
prop: "code",
|
||||
rules: [{ required: true, message: "请输入员工编号", trigger: "blur" }],
|
||||
rules: [{ required: false, message: "请输入员工编号", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入员工编号",
|
||||
@@ -68,7 +68,7 @@ const modalConfig: IModalConfig<editRequest> = {
|
||||
label: "手机号",
|
||||
prop: "phone",
|
||||
rules: [{
|
||||
required: true,
|
||||
required: false,
|
||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
||||
message: "请输入正确的手机号码",
|
||||
trigger: "blur",
|
||||
@@ -85,7 +85,7 @@ const modalConfig: IModalConfig<editRequest> = {
|
||||
{
|
||||
label: "登录账号",
|
||||
prop: "accountName",
|
||||
rules: [{ required: true, message: "请输入登录账号", trigger: "blur" }],
|
||||
rules: [{ required: false, message: "请输入登录账号", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入登录账号",
|
||||
@@ -98,7 +98,7 @@ const modalConfig: IModalConfig<editRequest> = {
|
||||
{
|
||||
label: "登录密码",
|
||||
prop: "accountPwd",
|
||||
rules: [{ required: true, message: "请输入登录密码", trigger: "blur" }],
|
||||
rules: [{ required: false, message: "请输入登录密码", trigger: "blur" }],
|
||||
type: "input",
|
||||
attrs: {
|
||||
placeholder: "请输入登录密码",
|
||||
@@ -144,12 +144,6 @@ const modalConfig: IModalConfig<editRequest> = {
|
||||
sm: 12,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "员工权限设置",
|
||||
prop: "",
|
||||
type: "title",
|
||||
slotName: "title",
|
||||
},
|
||||
{
|
||||
label: "是否允许管理端登录",
|
||||
prop: "isManage",
|
||||
@@ -170,6 +164,12 @@ const modalConfig: IModalConfig<editRequest> = {
|
||||
],
|
||||
initialValue: 1,
|
||||
},
|
||||
{
|
||||
label: "员工权限设置",
|
||||
prop: "",
|
||||
type: "title",
|
||||
slotName: "title",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -43,8 +43,12 @@
|
||||
|
||||
<!-- 新增 -->
|
||||
<page-modal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick">
|
||||
<template #permission="scope">
|
||||
<selectPermission></selectPermission>
|
||||
<template #formFooter>
|
||||
<selectPermission
|
||||
v-model="selPermissionList"
|
||||
:list="permissionList"
|
||||
ref="refSelectPermission"
|
||||
></selectPermission>
|
||||
</template>
|
||||
</page-modal>
|
||||
|
||||
@@ -54,8 +58,12 @@
|
||||
:modal-config="editModalConfig"
|
||||
@submit-click="handleSubmitClick"
|
||||
>
|
||||
<template #permission="scope">
|
||||
<selectPermission></selectPermission>
|
||||
<template #formFooter>
|
||||
<selectPermission
|
||||
v-model="selPermissionList"
|
||||
:list="permissionList"
|
||||
ref="refSelectPermission"
|
||||
></selectPermission>
|
||||
</template>
|
||||
</page-modal>
|
||||
</div>
|
||||
@@ -71,9 +79,10 @@ import searchConfig from "./config/search";
|
||||
import { returnOptionsLabel } from "./config/config";
|
||||
import RoleApi, { type SysRole } from "@/api/account/role";
|
||||
import ShopStaffApi from "@/api/account/shopStaff";
|
||||
import permissionApi from "@/api/account/permission";
|
||||
import permissionApi, { type ShopPermission } from "@/api/account/permission";
|
||||
import selectPermission from "./components/select-permission.vue";
|
||||
permissionApi.getshopPermission();
|
||||
const refSelectPermission = ref();
|
||||
|
||||
const {
|
||||
searchRef,
|
||||
contentRef,
|
||||
@@ -89,9 +98,36 @@ const {
|
||||
handleFilterChange,
|
||||
} = usePage();
|
||||
|
||||
//店铺权限列表
|
||||
let permissionList = ref<ShopPermission[]>([]);
|
||||
//选中的权限列表
|
||||
let selPermissionList = ref<string[]>([]);
|
||||
// 数据初始化
|
||||
async function init() {
|
||||
// 覆写添加确定方法
|
||||
const oldAddSubmitFunc = addModalConfig.formAction;
|
||||
addModalConfig.formAction = (data) => {
|
||||
return oldAddSubmitFunc({
|
||||
...data,
|
||||
shopPermissionIds: selPermissionList.value.reduce((pre: string[], cur: string) => {
|
||||
return pre.concat(cur);
|
||||
}, [] as string[]),
|
||||
});
|
||||
};
|
||||
// 覆写编辑确定方法
|
||||
const oldeditSubmitFunc = editModalConfig.formAction;
|
||||
editModalConfig.formAction = (data) => {
|
||||
return oldeditSubmitFunc({
|
||||
...data,
|
||||
shopPermissionIds: selPermissionList.value.reduce((pre: string[], cur: string) => {
|
||||
return pre.concat(cur);
|
||||
}, [] as string[]),
|
||||
});
|
||||
};
|
||||
|
||||
const res = await RoleApi.getList({ page: 1, size: 100 });
|
||||
const permission = await permissionApi.getshopPermission();
|
||||
permissionList.value = Array.isArray(permission) ? permission : [];
|
||||
const roleArr = res.records.map((item: SysRole) => {
|
||||
return {
|
||||
...item,
|
||||
@@ -106,12 +142,33 @@ init();
|
||||
|
||||
// 新增
|
||||
async function handleAddClick() {
|
||||
selPermissionList.value = [];
|
||||
addModalRef.value?.setModalVisible();
|
||||
}
|
||||
// 编辑
|
||||
async function handleEditClick(row: IObject) {
|
||||
selPermissionList.value = [];
|
||||
editModalRef.value?.handleDisabled(false);
|
||||
editModalRef.value?.setModalVisible();
|
||||
// 设置权限选中
|
||||
const perselArr = await permissionApi.getPermission(row.id);
|
||||
for (let id of perselArr) {
|
||||
for (let index in permissionList.value) {
|
||||
const item = permissionList.value[index];
|
||||
if (item.children) {
|
||||
for (let child of item.children) {
|
||||
if (child.id != null && child.id == id) {
|
||||
if (selPermissionList.value[index]) {
|
||||
selPermissionList.value[index].push(id);
|
||||
} else {
|
||||
selPermissionList.value[index] = [id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(selPermissionList.value);
|
||||
// 根据id获取数据进行填充
|
||||
await ShopStaffApi.get(row.id).then((res) => {
|
||||
console.log(res);
|
||||
|
||||
465
src/views/tool/Instead/components/carts/item.vue
Normal file
465
src/views/tool/Instead/components/carts/item.vue
Normal file
@@ -0,0 +1,465 @@
|
||||
<template>
|
||||
<div class="flex order-item u-m-b-14 relative" :class="[isActive]" @click="itemClick">
|
||||
<div class="absolute status-box">
|
||||
<span class="pack" v-if="item.pack_number * 1 > 0">
|
||||
包
|
||||
<span class="number">{{ item.pack_number * 1 }}</span>
|
||||
</span>
|
||||
<span class="da" v-if="item.is_print || item.is_print === null">打</span>
|
||||
<span class="isWaitCall" v-if="item.is_wait_call">等</span>
|
||||
<span class="tui" v-if="item.status === 'return'">退</span>
|
||||
</div>
|
||||
<div class="flex u-col-top">
|
||||
<div class="img">
|
||||
<div class="isSeatFee img u-line-1 u-flex u-col-center u-row-center" v-if="isSeatFee">
|
||||
<span>{{ item.name }}</span>
|
||||
</div>
|
||||
<div
|
||||
class="isSeatFee img u-line-1 u-flex u-col-center u-row-center"
|
||||
v-else-if="!item.product_id"
|
||||
>
|
||||
<span>临时菜</span>
|
||||
</div>
|
||||
<img v-else :src="item.coverImg" class="" alt="" />
|
||||
</div>
|
||||
<div class="good-info u-p-t-6">
|
||||
<div class="flex lh-16">
|
||||
<div class="name" :class="{ 'free-price': item.status === 'return' }">
|
||||
{{ item.name }}
|
||||
</div>
|
||||
<span class="good_info_discount" v-if="item.is_gift">赠</span>
|
||||
</div>
|
||||
<div v-if="item.typeEnum == 'weight'" class="specSnap">
|
||||
¥{{ currentPrice }}/{{ item.unit }}
|
||||
</div>
|
||||
<div v-if="item.specSnap" class="specSnap">
|
||||
{{ item.specSnap }}
|
||||
</div>
|
||||
<div v-if="item.proGroupInfo" class="specSnapss">
|
||||
<span>{{ item.groupType == 0 ? "固定套餐" : "可选套餐" }}:</span>
|
||||
<span v-for="(a, b) in proGroupInfo" :key="a.proId">
|
||||
{{ b == 0 ? "" : "," }}{{ a.proName }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="" v-if="placeNum == 0">
|
||||
<div class="note" v-if="item.remark">备注:{{ item.remark }}</div>
|
||||
<div class="note flex" v-else>
|
||||
<span>备注:</span>
|
||||
<el-icon @click="editNote" color="#999"><EditPen /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="note" v-if="placeNum != 0 && item.note">备注:{{ item.remark || "" }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="width: 10px"></div>
|
||||
<div class="flex u-p-t-6">
|
||||
<div class="order-number-box u-font-12">
|
||||
<div class="" v-if="isSeatFee">X{{ item.totalNumber }}</div>
|
||||
<div class="" v-else>X{{ item.number }}</div>
|
||||
<div class="absolute" v-if="canChangeNumber">
|
||||
<div class="order-input-number">
|
||||
<el-icon color="#d8d8d8" size="22" @click="changeOrderNumber(-1)"><Remove /></el-icon>
|
||||
|
||||
<div style="width: 60px; margin: 0 4px" class="number-box">
|
||||
<el-input
|
||||
:min="0"
|
||||
type="number"
|
||||
@input="cartGoodsNumberInput"
|
||||
@change="cartGoodsNumberChange"
|
||||
v-model="number"
|
||||
placeholder="0"
|
||||
></el-input>
|
||||
</div>
|
||||
<el-icon color="#22bf64" size="22" @click="changeOrderNumber(1)">
|
||||
<CirclePlusFilled />
|
||||
</el-icon>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="color-333 total-price">
|
||||
<template v-if="item.is_gift || item.status == 'return'">
|
||||
<div>¥0</div>
|
||||
<div class="free-price">
|
||||
<span v-if="isSeatFee">¥{{ item.totalAmount }}</span>
|
||||
<span v-else>¥{{ isShowVipPrice ? vipAllPrice : allPrice }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="item.discountSaleAmount">
|
||||
<div>¥{{ discountNewPrice }}</div>
|
||||
<div class="free-price">
|
||||
<span>¥{{ isShowVipPrice ? vipAllPrice : allPrice }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div v-if="isSeatFee">¥{{ item.totalAmount }}</div>
|
||||
<div v-else>
|
||||
<div v-if="isShowVipPrice && vipAllPrice != allPrice">¥{{ vipAllPrice }}</div>
|
||||
<div
|
||||
:class="{
|
||||
'free-price': isShowVipPrice && vipAllPrice != allPrice,
|
||||
}"
|
||||
>
|
||||
<span>¥{{ allPrice }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
isShowVipPrice: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
//是否是餐位费
|
||||
isSeatFee: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
//是否是历史订单商品
|
||||
isOld: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
//第几次下单 1以及以上为历史订单 0为当前购物车
|
||||
placeNum: {
|
||||
type: [String, Number],
|
||||
default: 0,
|
||||
},
|
||||
selPlaceNum: {
|
||||
type: [String, Number],
|
||||
default: -1,
|
||||
},
|
||||
//是否允许改变数量
|
||||
canChangeNumber: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
item: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
number: 0,
|
||||
};
|
||||
},
|
||||
},
|
||||
selCart: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: "",
|
||||
};
|
||||
},
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
|
||||
let number = ref(0);
|
||||
|
||||
const currentPrice = computed(() => {
|
||||
return 0;
|
||||
});
|
||||
const proGroupInfo = computed(() => {
|
||||
return JSON.parse(props.item.proGroupInfo);
|
||||
});
|
||||
const discountNewPrice = computed(() => {
|
||||
return 0;
|
||||
});
|
||||
const vipAllPrice = computed(() => {
|
||||
return 0;
|
||||
});
|
||||
const allPrice = computed(() => {
|
||||
return props.item.number * props.item.salePrice;
|
||||
});
|
||||
|
||||
const isActive = computed(() => {
|
||||
return props.item.id == props.selCart.id ? "active" : "";
|
||||
});
|
||||
watch(
|
||||
() => props.item.number,
|
||||
(newval) => {
|
||||
console.log(newval);
|
||||
number.value = newval;
|
||||
}
|
||||
);
|
||||
|
||||
const emits = defineEmits([
|
||||
"editNote",
|
||||
"cartGoodsNumberChange",
|
||||
"cartGoodsNumberInput",
|
||||
"changeNumber",
|
||||
"itemClick",
|
||||
]);
|
||||
function editNote() {
|
||||
emits("editNote", props.index);
|
||||
}
|
||||
//购物车商品输入框数量改变
|
||||
function cartGoodsNumberChange(newval) {
|
||||
if (newval <= 0) {
|
||||
item.number = 1;
|
||||
}
|
||||
newval = `${newval}`.split(".")[0] * 1;
|
||||
number.value = newval;
|
||||
changeOrderNumber(newval - props.item.number);
|
||||
}
|
||||
//购物车商品输入框数量输入
|
||||
function cartGoodsNumberInput(newval) {
|
||||
if (newval <= 0) {
|
||||
return (number.value = 1);
|
||||
}
|
||||
newval = `${newval}`.split(".")[0] * 1;
|
||||
number.value = newval;
|
||||
}
|
||||
function changeOrderNumber(step) {
|
||||
emits("changeNumber", step, props.item);
|
||||
}
|
||||
function itemClick() {
|
||||
emits("itemClick");
|
||||
}
|
||||
onMounted(() => {
|
||||
number.value = props.item.number;
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .number-box .el-input__inner {
|
||||
border: none;
|
||||
}
|
||||
|
||||
::v-deep .el-button--text {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
::v-deep .number-box .el-input__inner {
|
||||
border: none;
|
||||
padding: 0 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.isSeatFee {
|
||||
background: #3f9eff;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.icon-remove {
|
||||
border: 1px solid #d8d8d8;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: 50%;
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
display: block;
|
||||
width: 10px;
|
||||
height: 1px;
|
||||
background: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.icon-add {
|
||||
color: rgb(34, 191, 100);
|
||||
font-size: 22px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.flex.order-item {
|
||||
padding: 4px;
|
||||
border-radius: 2px;
|
||||
display: flex;
|
||||
overflow: visible;
|
||||
cursor: pointer;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
transition: all 0.3s;
|
||||
|
||||
.status-box {
|
||||
width: 18px;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
right: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
|
||||
> span {
|
||||
display: block;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 4px 0 4px 0;
|
||||
font-size: 12px;
|
||||
line-height: 17px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.isWaitCall {
|
||||
background: #d3adf7;
|
||||
}
|
||||
|
||||
.pack {
|
||||
background: #35ac6a;
|
||||
.number {
|
||||
background: #f56c6c;
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
left: -7px;
|
||||
top: -7px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
text-align: center;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.da {
|
||||
background: #35ac6a;
|
||||
}
|
||||
|
||||
.tui {
|
||||
background: #ac4735;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background-color: rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.total-price {
|
||||
width: 94px;
|
||||
font-size: 16px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.good-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
min-width: 70px;
|
||||
|
||||
.specSnap {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.specSnapss {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 3px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
|
||||
.specSnap {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
color: #212121;
|
||||
overflow: hidden;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.img {
|
||||
width: 59px;
|
||||
height: 59px;
|
||||
position: relative;
|
||||
margin-right: 10px;
|
||||
|
||||
img {
|
||||
width: 59px;
|
||||
height: 59px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.note {
|
||||
max-width: 70%;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
text-align: left;
|
||||
color: #999;
|
||||
margin-top: 5px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.order-number-box {
|
||||
position: relative;
|
||||
|
||||
.absolute {
|
||||
width: 60px;
|
||||
height: 40px;
|
||||
right: -38px;
|
||||
top: -14px;
|
||||
position: absolute;
|
||||
|
||||
.order-input-number {
|
||||
position: absolute;
|
||||
right: -6px;
|
||||
top: 0;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
display: none;
|
||||
background-color: #fff;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.06);
|
||||
padding: 9px 6px;
|
||||
background-color: #fff;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
&:hover .order-input-number {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.good_info_discount {
|
||||
height: 16px;
|
||||
padding: 0 3px;
|
||||
color: #ff3f3f;
|
||||
background-color: rgba(255, 63, 63, 0.1);
|
||||
border-radius: 2px;
|
||||
margin-left: 6px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
::v-deep .order-input-number .el-input__inner::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
::v-deep .order-input-number .el-input__inner::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
146
src/views/tool/Instead/components/carts/list.vue
Normal file
146
src/views/tool/Instead/components/carts/list.vue
Normal file
@@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<div class="list">
|
||||
<div class="carts">
|
||||
<!-- 当前购物车 -->
|
||||
<div v-for="(item, index) in carts.list" :key="index">
|
||||
<carts-item
|
||||
:item="item"
|
||||
@changeNumber="changeNumber"
|
||||
:selCart="carts.selCart"
|
||||
@itemClick="itemClick(item)"
|
||||
></carts-item>
|
||||
</div>
|
||||
<!-- 赠菜 -->
|
||||
<div class="cart-title"><span>以下是优惠菜品</span></div>
|
||||
<div v-for="(item, index) in carts.giftList" :key="index">
|
||||
<carts-item
|
||||
:item="item"
|
||||
@changeNumber="changeNumber"
|
||||
:selCart="carts.selCart"
|
||||
@itemClick="itemClick(item)"
|
||||
></carts-item>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<div class="yiyouhui">{{ carts.yiyouhui }}</div>
|
||||
<div class="u-flex u-row-between">
|
||||
<el-link type="primary">打印制作单</el-link>
|
||||
<div>
|
||||
<span class="totalNumber">共{{ carts.totalNumber }}件</span>
|
||||
<span class="totalPrice">¥{{ carts.payMoney }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<el-button type="primary">微信/支付宝</el-button>
|
||||
<el-button type="primary">现金</el-button>
|
||||
<el-button type="primary">更多支付</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import cartsItem from "./item.vue";
|
||||
import { useCartsStore } from "@/store/modules/carts";
|
||||
|
||||
const props = defineProps({
|
||||
goodsList: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
goodsMapisFinish: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
const selCartId = ref(null);
|
||||
|
||||
const carts = useCartsStore();
|
||||
const goodsMap = {};
|
||||
watch(
|
||||
() => props.goodsMapisFinish,
|
||||
(newval) => {
|
||||
if (newval) {
|
||||
for (let goods of props.goodsList) {
|
||||
goodsMap[goods.id] = goods;
|
||||
}
|
||||
carts.init({}, goodsMap);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function itemClick(item) {
|
||||
carts.changeSelCart(item);
|
||||
}
|
||||
|
||||
function changeNumber(step, item) {
|
||||
carts.changeNumber(step * 1, item);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
carts,
|
||||
});
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.list {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.totalNumber {
|
||||
color: #666;
|
||||
font-size: 14px;
|
||||
}
|
||||
.totalPrice {
|
||||
font-size: 18px;
|
||||
color: #000;
|
||||
}
|
||||
.bottom {
|
||||
position: relative;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid #ebebeb;
|
||||
.yiyouhui {
|
||||
text-align: right;
|
||||
color: #c12a2a;
|
||||
font-size: 13px;
|
||||
line-height: 16px;
|
||||
top: 14px;
|
||||
}
|
||||
}
|
||||
:deep(.btn-group) {
|
||||
display: flex;
|
||||
margin-top: 20px;
|
||||
.el-button {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
.carts {
|
||||
height: calc(100% - 120px);
|
||||
overflow-y: scroll;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
/* 修改垂直滚动条 */
|
||||
.carts::-webkit-scrollbar {
|
||||
width: 0; /* 修改宽度 */
|
||||
}
|
||||
|
||||
/* 修改滚动条轨道背景色 */
|
||||
.carts::-webkit-scrollbar-track {
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
.cart-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
color: rgba(0, 0, 0, 0.4);
|
||||
&::after {
|
||||
content: "";
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
background-color: #ebebeb;
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
143
src/views/tool/Instead/components/control.vue
Normal file
143
src/views/tool/Instead/components/control.vue
Normal file
@@ -0,0 +1,143 @@
|
||||
<template>
|
||||
<div class="controls">
|
||||
<div class="input-number">
|
||||
<div class="reduce">
|
||||
<el-icon @click="carts.changeNumber(-1, carts.selCart)"><Minus /></el-icon>
|
||||
</div>
|
||||
<span class="text">{{ carts.selCart.number || 1 }}</span>
|
||||
<div class="add">
|
||||
<el-icon @click="carts.changeNumber(1, carts.selCart)"><Plus /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
<el-button
|
||||
v-for="(item, index) in controls"
|
||||
:key="index"
|
||||
v-bund="item"
|
||||
:disabled="btnDisabled(item)"
|
||||
@click="controlsClick(item)"
|
||||
>
|
||||
{{ returnLabel(item) }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const number = ref(1);
|
||||
import { useCartsStore } from "@/store/modules/carts";
|
||||
const carts = useCartsStore();
|
||||
|
||||
const controls = ref([
|
||||
{ label: "规格", key: "", disabled: false, per: "sku" },
|
||||
{ label: "赠送", key: "is_gift", disabled: false, per: "cart" },
|
||||
{ label: "打包", key: "is_pack", disabled: false, per: "cart" },
|
||||
{ label: "删除", key: "del", disabled: false, per: "cart" },
|
||||
{ label: "存单", key: "", disabled: false, per: "save" },
|
||||
{ label: "取单", key: "", disabled: false },
|
||||
{ label: "单品备注", key: "one-note", disabled: false, per: "one-note" },
|
||||
{ label: "整单备注", key: "all-note", disabled: false, per: "all-note" },
|
||||
{ label: "退菜", key: "", disabled: false, per: "order" },
|
||||
{ label: "免厨打", key: "is_print", disabled: false, per: "cart" },
|
||||
{ label: "单品改价", key: "", disabled: false, per: "cart" },
|
||||
{ label: "等叫", key: "", disabled: false, per: "cart" },
|
||||
{ label: "整单等叫", key: "", disabled: false, per: "all-wating" },
|
||||
]);
|
||||
|
||||
const emits = defineEmits(["noteClick"]);
|
||||
function controlsClick(item) {
|
||||
switch (item.key) {
|
||||
case "is_gift":
|
||||
carts.updateTag("is_gift", carts.selCart.is_gift ? 0 : 1);
|
||||
break;
|
||||
case "is_pack":
|
||||
emits("packClick", carts.selCart.pack_number, carts.selCart.number);
|
||||
break;
|
||||
case "is_print":
|
||||
carts.updateTag("is_print", carts.selCart.is_print ? 0 : 1);
|
||||
break;
|
||||
case "del":
|
||||
carts.del(carts.selCart);
|
||||
break;
|
||||
case "save":
|
||||
carts.saveCart();
|
||||
break;
|
||||
case "one-note":
|
||||
emits("noteClick", true);
|
||||
break;
|
||||
case "all-note":
|
||||
emits("noteClick", false);
|
||||
break;
|
||||
case "order":
|
||||
carts.order();
|
||||
break;
|
||||
case "all-wating":
|
||||
carts.allWating();
|
||||
break;
|
||||
}
|
||||
}
|
||||
const perList = computed(() => {
|
||||
if (!carts.selCart.id) {
|
||||
return ["all-wating", "all-note"];
|
||||
}
|
||||
if (carts.selCart.id) {
|
||||
return ["cart", "save", "one-note", "all-note", "all-wating"];
|
||||
}
|
||||
});
|
||||
|
||||
function btnDisabled(item) {
|
||||
return !perList.value.includes(item.per);
|
||||
}
|
||||
function returnLabel(item) {
|
||||
if (item.key == "is_gift") {
|
||||
return carts.selCart.is_gift ? "取消赠送" : "赠送";
|
||||
}
|
||||
if (item.key == "is_pack") {
|
||||
return carts.selCart.is_pack ? "取消打包" : "打包";
|
||||
}
|
||||
if (item.key == "is_print") {
|
||||
return carts.selCart.is_print ? "免厨打" : "打印";
|
||||
}
|
||||
return item.label;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
$gap: 10px;
|
||||
.controls {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
width: 106px;
|
||||
padding: 14px 10px;
|
||||
background-color: #f7f7fa;
|
||||
}
|
||||
.el-button + .el-button {
|
||||
margin-top: $gap;
|
||||
margin-left: 0;
|
||||
}
|
||||
.input-number {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #fff;
|
||||
border: 1px solid #dcdfe6;
|
||||
margin-bottom: $gap;
|
||||
cursor: pointer;
|
||||
.reduce,
|
||||
.text,
|
||||
.add {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 38px;
|
||||
}
|
||||
.text {
|
||||
height: 48px;
|
||||
font-size: 30px;
|
||||
border-top: 1px solid #dcdfe6;
|
||||
border-bottom: 1px solid #dcdfe6;
|
||||
}
|
||||
.reduce {
|
||||
}
|
||||
.add {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
147
src/views/tool/Instead/components/dialog-goods-sel.vue
Normal file
147
src/views/tool/Instead/components/dialog-goods-sel.vue
Normal file
@@ -0,0 +1,147 @@
|
||||
<template>
|
||||
<!-- 选择规格 -->
|
||||
<el-dialog width="410px" :title="goods.name" v-model="show" @close="close">
|
||||
<div class="tag-group">
|
||||
<div class="tag-item" v-for="(item, key) in goods.selectSpecInfo" :key="key">
|
||||
<div class="tag-name">{{ key }}</div>
|
||||
<div>
|
||||
<span style="margin: 0 10px 10px 0" v-for="(val, valIndex) in item.list" :key="valIndex">
|
||||
<el-button
|
||||
plain
|
||||
:type="val === item.sel ? 'primary' : ''"
|
||||
:disabled="val.disabled"
|
||||
@click="changeSkuSel(key, val)"
|
||||
>
|
||||
{{ val }}
|
||||
</el-button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<template v-if="skuData">
|
||||
<div class="u-flex u-row-between">
|
||||
<div>
|
||||
<div class="price">¥ {{ skuData.salePrice }}</div>
|
||||
<div class="sku-group-text">
|
||||
<span>{{ skuName }}</span>
|
||||
<span>库存:{{ 0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-flex">
|
||||
<el-input-number v-model="number" :min="skuData.suitNum"></el-input-number>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-flex" style="margin-top: 14px">
|
||||
<el-button v-if="!skuData.isGrounding" disabled style="width: 100%">已下架</el-button>
|
||||
<template v-else>
|
||||
<el-button type="primary" style="width: 100%">确 定</el-button>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else>
|
||||
<el-button type="primary" style="width: 100%" disabled>确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup >
|
||||
let show = ref(false);
|
||||
// const props = defineProps({
|
||||
// goods: {
|
||||
// type: Object,
|
||||
// default: () => ({}),
|
||||
// },
|
||||
// });
|
||||
|
||||
let number = ref(1);
|
||||
|
||||
const defaultGoods = { selectSpecInfo: {}, skuList: [] };
|
||||
let goods = ref({ ...defaultGoods });
|
||||
|
||||
function resetData() {
|
||||
goods.value = { ...defaultGoods };
|
||||
}
|
||||
|
||||
function changeSkuSel(key, val) {
|
||||
console.log(key, val);
|
||||
goods.value.selectSpecInfo[key].sel = val;
|
||||
}
|
||||
|
||||
function open(data) {
|
||||
show.value = true;
|
||||
if (data) {
|
||||
let selectSpecInfo = {};
|
||||
for (let i in data.selectSpecInfo) {
|
||||
if (data.selectSpecInfo[i].length > 0) {
|
||||
selectSpecInfo[i] = {
|
||||
list: data.selectSpecInfo[i],
|
||||
sel: "",
|
||||
disabled: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
goods.value = { ...data, selectSpecInfo };
|
||||
console.log(goods.value);
|
||||
}
|
||||
}
|
||||
function close() {
|
||||
show.value = false;
|
||||
resetData();
|
||||
}
|
||||
const skuName = computed(() => {
|
||||
if (goods.value.selectSpecInfo) {
|
||||
let sku = [];
|
||||
for (let i in goods.value.selectSpecInfo) {
|
||||
sku.push(goods.value.selectSpecInfo[i].sel);
|
||||
}
|
||||
return sku.join(",");
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
});
|
||||
|
||||
const skuData = computed(() => {
|
||||
if (goods.value.skuList.length <= 0) {
|
||||
return undefined;
|
||||
}
|
||||
return goods.value.skuList.find((item) => {
|
||||
return item.specInfo === skuName.value;
|
||||
});
|
||||
});
|
||||
|
||||
defineExpose({ open, close });
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.tag-group {
|
||||
margin-top: 10px;
|
||||
|
||||
.tag-item {
|
||||
margin-bottom: 20px;
|
||||
|
||||
.tag-name {
|
||||
margin-bottom: 10px;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
.price {
|
||||
font-size: 18px;
|
||||
text-align: left;
|
||||
color: #ff5152;
|
||||
font-weight: 600;
|
||||
}
|
||||
.sku-group-text {
|
||||
text-align: left;
|
||||
color: #666;
|
||||
font-size: 11px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
::v-deep .number-box .el-input__inner {
|
||||
border: none;
|
||||
padding: 0 4px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
50
src/views/tool/Instead/components/goods-item.vue
Normal file
50
src/views/tool/Instead/components/goods-item.vue
Normal file
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<div class="goods-item">
|
||||
<el-image v-if="item.coverImg" class="goods-image" :src="item.coverImg" fit="cover"></el-image>
|
||||
<div class="info">
|
||||
<div class="name u-flex u-flex-wrap">
|
||||
<span class="weight" v-if="item.type == 'weigh'">称重</span>
|
||||
<span>{{ item.name }}</span>
|
||||
</div>
|
||||
<div class="">¥{{ item.lowPrice }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
item: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
index: Number,
|
||||
active: Boolean,
|
||||
select: Function,
|
||||
});
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.goods-item {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border-radius: 4px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
.goods-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.info {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
padding: 8px;
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
background-color: rgba(46, 46, 46, 0.38);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
96
src/views/tool/Instead/components/note.vue
Normal file
96
src/views/tool/Instead/components/note.vue
Normal file
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<el-dialog :title="title" width="410px" v-model="show" @close="reset">
|
||||
<el-input :rows="6" type="textarea" v-model="note" placeholder="请输入备注"></el-input>
|
||||
<div>
|
||||
<el-tag
|
||||
v-for="(tag, index) in tags"
|
||||
@click="addNote(tag)"
|
||||
size="medium"
|
||||
:key="index"
|
||||
closable
|
||||
@close="delTag(index)"
|
||||
type="primary"
|
||||
>
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button size="medium" @click="close">取消</el-button>
|
||||
<el-button size="medium" type="primary" @click="confirm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup>
|
||||
let show = ref(false);
|
||||
let tags = ref([]);
|
||||
let note = ref("");
|
||||
let title = ref("整单备注(提交订单时生效)");
|
||||
let isOne = ref(false);
|
||||
watch(
|
||||
() => tags.length,
|
||||
() => {
|
||||
localStorage.setItem("tags", JSON.stringify(tags.value));
|
||||
}
|
||||
);
|
||||
|
||||
function reset() {
|
||||
note.value = "";
|
||||
}
|
||||
function delTag(index) {
|
||||
this.tags.splice(index, 1);
|
||||
}
|
||||
function addNote(tag) {
|
||||
if (!note.value) {
|
||||
return (note.value = tag);
|
||||
}
|
||||
note.value = tag + "," + note.value;
|
||||
}
|
||||
function open(remark, isOneNote) {
|
||||
isOne.value = isOneNote;
|
||||
title.value = isOneNote ? "整单备注(提交订单时生效)" : "单品备注(提交订单时生效)";
|
||||
show.value = true;
|
||||
note.value = remark ? remark : "";
|
||||
const tags = localStorage.getItem("tags");
|
||||
console.log(tags);
|
||||
this.tags = tags ? JSON.parse(tags) : ["免香菜", "不要辣", "不要葱"];
|
||||
}
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
const emits = defineEmits(["confirm"]);
|
||||
function confirm() {
|
||||
const originTags = [...tags.value];
|
||||
if (note.value) {
|
||||
if (originTags >= 10) {
|
||||
originTags.shift();
|
||||
}
|
||||
if (note.value.length <= 16) {
|
||||
const newTags = new Set([note.value, ...originTags]);
|
||||
localStorage.setItem("tags", JSON.stringify([...newTags]));
|
||||
}
|
||||
}
|
||||
emits("confirm", note.value, isOne.value);
|
||||
close();
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
close,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
margin-bottom: 14px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
::v-deep .el-tag {
|
||||
margin-top: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
line-height: 35px;
|
||||
height: 35px;
|
||||
}
|
||||
</style>
|
||||
60
src/views/tool/Instead/components/pack.vue
Normal file
60
src/views/tool/Instead/components/pack.vue
Normal file
@@ -0,0 +1,60 @@
|
||||
<template>
|
||||
<el-dialog title="修改打包数量" width="410px" v-model="show" @close="reset">
|
||||
<el-input-number
|
||||
:min="0"
|
||||
:max="max"
|
||||
type="number"
|
||||
v-model="number"
|
||||
placeholder="请输入打包数量"
|
||||
></el-input-number>
|
||||
<template #footer>
|
||||
<el-button size="medium" @click="close">取消</el-button>
|
||||
<el-button size="medium" type="primary" @click="confirm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup>
|
||||
let show = ref(false);
|
||||
let number = ref(0);
|
||||
const max = ref(0);
|
||||
function reset() {
|
||||
max.value = 0;
|
||||
number.value = 0;
|
||||
}
|
||||
|
||||
function open(packNumber, maxNumber) {
|
||||
show.value = true;
|
||||
max.value = maxNumber || 0;
|
||||
number.value = packNumber || 0;
|
||||
}
|
||||
function close() {
|
||||
show.value = false;
|
||||
reset();
|
||||
}
|
||||
const emits = defineEmits(["confirm"]);
|
||||
function confirm() {
|
||||
emits("confirm", number.value);
|
||||
close();
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
close,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
margin-bottom: 14px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
::v-deep .el-tag {
|
||||
margin-top: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
line-height: 35px;
|
||||
height: 35px;
|
||||
}
|
||||
</style>
|
||||
403
src/views/tool/Instead/index.vue
Normal file
403
src/views/tool/Instead/index.vue
Normal file
@@ -0,0 +1,403 @@
|
||||
<template>
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
<div class="top">
|
||||
<div class="left u-flex u-col-center">
|
||||
<span class="title">代客下单</span>
|
||||
<div class="u-m-l-20 flex">
|
||||
<el-button type="primary">选择用户</el-button>
|
||||
<el-button>选择桌号</el-button>
|
||||
<el-button type="warning">扫码验券</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right">
|
||||
<el-input placeholder="请输入商品名称" v-model="keywords" clearable>
|
||||
<template #suffix>
|
||||
<el-icon class="el-input__icon"><search /></el-icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="diancan">
|
||||
<div class="left">
|
||||
<div class="diners">
|
||||
<el-button-group v-model="diners.sel" style="width: 100%; display: flex">
|
||||
<el-button
|
||||
:class="{ active: index == diners.sel }"
|
||||
v-for="(item, index) in diners.list"
|
||||
:key="index"
|
||||
>
|
||||
{{ item.label }}
|
||||
</el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-font-14 clear u-m-t-10 perpoles">
|
||||
<div
|
||||
class="u-flex u-p-r-14 u-m-r-14"
|
||||
style="border-right: 1px solid #ebebeb; line-height: 1"
|
||||
>
|
||||
<span>就餐人数:-位</span>
|
||||
<el-icon><ArrowRight /></el-icon>
|
||||
</div>
|
||||
<a @click="clearCarts" style="color: #1890ff">清空</a>
|
||||
</div>
|
||||
<cartsList
|
||||
:goodsMapisFinish="goodsMapisFinish"
|
||||
:goodsList="goods.list"
|
||||
ref="refCart"
|
||||
></cartsList>
|
||||
</div>
|
||||
<div class="center">
|
||||
<Controls @noteClick="showNote" @packClick="showPack" />
|
||||
</div>
|
||||
<div class="right">
|
||||
<div class="flex categoty u-col-center">
|
||||
<div
|
||||
class="show_more_btn"
|
||||
:class="{ showAll: category.showAll }"
|
||||
@click="toggleShowAll"
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="flex showmore">
|
||||
<el-icon color="#fff"><ArrowDown /></el-icon>
|
||||
</div>
|
||||
<span>{{ category.showAll ? "收起" : "展开" }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex categorys" :class="{ 'flex-wrap': category.showAll }">
|
||||
<div
|
||||
v-for="(item, index) in category.list"
|
||||
:key="index"
|
||||
@click="changeCategoryId(item)"
|
||||
>
|
||||
<el-tag
|
||||
size="large"
|
||||
type="primary"
|
||||
effect="dark"
|
||||
v-if="goods.query.categoryId === item.id"
|
||||
>
|
||||
{{ item.name }}
|
||||
</el-tag>
|
||||
<el-tag size="large" type="info" v-else effect="plain">{{ item.name }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="goods-list">
|
||||
<GoodsItem
|
||||
:item="item"
|
||||
@click="goodsClick(item)"
|
||||
v-for="item in goods.list"
|
||||
:key="item.id"
|
||||
></GoodsItem>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<dialogGoodsSel ref="refSelSku"></dialogGoodsSel>
|
||||
<note ref="refNote" @confirm="noteConfirm"></note>
|
||||
<pack ref="refPack" @confirm="packConfirm"></pack>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import Controls from "./components/control.vue";
|
||||
import note from "./components/note.vue";
|
||||
import pack from "./components/pack.vue";
|
||||
import GoodsItem from "./components/goods-item.vue";
|
||||
import dialogGoodsSel from "./components/dialog-goods-sel.vue";
|
||||
import cartsList from "./components/carts/list.vue";
|
||||
import categoryApi from "@/api/product/productclassification";
|
||||
import productApi from "@/api/product/index";
|
||||
//打包
|
||||
const refPack = ref();
|
||||
function showPack(packNumber, max) {
|
||||
refPack.value.open(packNumber * 1, max * 1);
|
||||
}
|
||||
function packConfirm(packNumber) {
|
||||
refCart.value.carts.updateTag("pack_number", packNumber);
|
||||
}
|
||||
|
||||
//备注
|
||||
const refNote = ref(null);
|
||||
function showNote(isOneNote) {
|
||||
const remark = isOneNote ? refCart.value.carts.selCart.remark : "";
|
||||
console.log(remark);
|
||||
refNote.value.open(remark, isOneNote);
|
||||
}
|
||||
function noteConfirm(note, isOneNote) {
|
||||
if (isOneNote) {
|
||||
refCart.value.carts.updateTag("remark", note);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索
|
||||
const keywords = ref("");
|
||||
|
||||
// 就餐类型
|
||||
const diners = reactive({
|
||||
list: [
|
||||
{ label: "堂食", value: 1 },
|
||||
{ label: "自取", value: 2 },
|
||||
],
|
||||
sel: 0,
|
||||
});
|
||||
// 商品分类
|
||||
const category = reactive({
|
||||
list: [],
|
||||
showAll: false,
|
||||
});
|
||||
function toggleShowAll() {
|
||||
category.showAll = !category.showAll;
|
||||
}
|
||||
function changeCategoryId() {}
|
||||
|
||||
function getCategoryList() {
|
||||
categoryApi
|
||||
.getList({
|
||||
page: 1,
|
||||
size: 200,
|
||||
})
|
||||
.then((res) => {
|
||||
category.list = res;
|
||||
});
|
||||
}
|
||||
|
||||
//商品
|
||||
const refSelSku = ref(null);
|
||||
|
||||
const goods = reactive({
|
||||
list: [],
|
||||
query: {
|
||||
categoryId: "",
|
||||
keywords: "",
|
||||
},
|
||||
});
|
||||
|
||||
let goodsMapisFinish = ref(false);
|
||||
|
||||
function getGoods() {
|
||||
productApi
|
||||
.getPage({
|
||||
page: 1,
|
||||
size: 200,
|
||||
...goods.query,
|
||||
})
|
||||
.then((res) => {
|
||||
goods.list = res.records;
|
||||
goodsMapisFinish.value = true;
|
||||
});
|
||||
}
|
||||
|
||||
function goodsClick(item) {
|
||||
//单规格
|
||||
if (item.type == "single") {
|
||||
addCarts({
|
||||
product_id: item.id,
|
||||
sku_id: item.skuList[0].id,
|
||||
number: 1,
|
||||
is_pack: 0,
|
||||
is_gift: 0,
|
||||
is_temporary: 0,
|
||||
discount_sale_amount: 0,
|
||||
discount_sale_note: "",
|
||||
is_print: 0,
|
||||
is_wait_call: 0,
|
||||
product_name: "",
|
||||
remark: "",
|
||||
});
|
||||
}
|
||||
// 多规格
|
||||
if (item.type == "sku") {
|
||||
refSelSku.value.open(item);
|
||||
}
|
||||
}
|
||||
//购物车
|
||||
const refCart = ref(null);
|
||||
function clearCarts() {
|
||||
ElMessageBox.alert("确定要清空点餐列表吗?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(() => {
|
||||
refCart.value.carts.clear();
|
||||
});
|
||||
}
|
||||
function addCarts(item) {
|
||||
const hasCart = refCart.value.carts.list.find((cartItem) => {
|
||||
return cartItem.product_id == item.product_id && cartItem.sku_id == item.sku_id;
|
||||
});
|
||||
console.log(hasCart);
|
||||
if (hasCart) {
|
||||
refCart.value.carts.update({ ...item, id: hasCart.id });
|
||||
} else {
|
||||
refCart.value.carts.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
getCategoryList();
|
||||
getGoods();
|
||||
}
|
||||
init();
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$pl: 30px;
|
||||
.box {
|
||||
padding: 20px 20px 10px 20px;
|
||||
height: 100%;
|
||||
.content {
|
||||
background-color: #fff;
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 20px 20px 20px 0;
|
||||
.top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #ebebeb;
|
||||
margin-left: $pl;
|
||||
.left {
|
||||
flex: 1;
|
||||
|
||||
.title {
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.right {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
.diancan {
|
||||
padding-top: 10px;
|
||||
display: flex;
|
||||
max-height: calc(100vh - 256px);
|
||||
.left {
|
||||
width: 350px;
|
||||
padding-right: 14px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.diners {
|
||||
padding-left: $pl;
|
||||
}
|
||||
.perpoles {
|
||||
padding-left: $pl;
|
||||
}
|
||||
}
|
||||
.right {
|
||||
flex: 1;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
&::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
}
|
||||
.center {
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
&::-webkit-scrollbar {
|
||||
width: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.diners .el-button-group .active) {
|
||||
border: 1px solid #409eff !important;
|
||||
color: #409eff !important;
|
||||
background: rgba(24, 144, 255, 0.1) !important;
|
||||
z-index: 10;
|
||||
}
|
||||
:deep(.diners .el-button-group) {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
}
|
||||
:deep(.diners .el-button-group .el-button) {
|
||||
flex: 1;
|
||||
}
|
||||
:deep(.categorys .el-tag--plain.el-tag--info) {
|
||||
border: 1px solid #dcdfe6;
|
||||
color: #000;
|
||||
font-weight: 600;
|
||||
}
|
||||
:deep(.categorys .el-tag) {
|
||||
min-width: 80px;
|
||||
height: 38px;
|
||||
line-height: 38px;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
padding: 0 14px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
border-radius: 2px;
|
||||
user-select: none;
|
||||
margin: 0 10px 10px 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.categoty {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background-color: #f7f7fa;
|
||||
z-index: 1;
|
||||
padding-top: 14px;
|
||||
|
||||
.show_more_btn {
|
||||
padding: 0 10px;
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
user-select: none;
|
||||
min-width: 80px;
|
||||
background: #f7f7fa;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 14px;
|
||||
height: 38px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.showmore {
|
||||
transition: all 0.2s;
|
||||
margin-right: 8px;
|
||||
width: 21px;
|
||||
height: 21px;
|
||||
border-radius: 50%;
|
||||
background: #3f9eff;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&.showAll {
|
||||
.showmore {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.goods-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
flex: 1;
|
||||
}
|
||||
:deep(.carts) {
|
||||
padding-left: $pl;
|
||||
}
|
||||
:deep(.left) {
|
||||
.bottom {
|
||||
padding-left: $pl;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
250
src/views/tool/Instead/quan_util.js
Normal file
250
src/views/tool/Instead/quan_util.js
Normal file
@@ -0,0 +1,250 @@
|
||||
export function isTui(item) {
|
||||
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
|
||||
}
|
||||
//是否使用会员价
|
||||
export function isUseVipPrice(vipUser,goods){
|
||||
return vipUser.id&&vipUser.isVip&&goods.isMember
|
||||
}
|
||||
|
||||
//计算商品券优惠价格
|
||||
export function returnProductCouponPrice(coup, goodsArr, vipUser) {
|
||||
const item = goodsArr.find(v => v.productId == coup.proId);
|
||||
if (!item) {
|
||||
return 0
|
||||
}
|
||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||
const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
|
||||
return price * coup.num
|
||||
|
||||
}
|
||||
//返回新的商品列表,过滤掉退菜的,退单的商品
|
||||
export function returnNewGoodsList(arr) {
|
||||
let goodsMap = {}
|
||||
return arr.filter(v => !isTui(v))
|
||||
}
|
||||
//根据当前购物车商品以及数量,已选券对应商品数量,判断该商品券是否可用
|
||||
export function returnCoupCanUse(goodsArr = [], coup, selCoupArr = []) {
|
||||
// if(!coup.use){
|
||||
// return false
|
||||
// }
|
||||
const findGoods = goodsArr.filter(v => v.productId == coup.proId)
|
||||
if (!findGoods.length) {
|
||||
return false
|
||||
}
|
||||
const findGoodsTotalNumber = findGoods.reduce((prve, cur) => {
|
||||
return prve + cur.num * 1
|
||||
}, 0)
|
||||
const selCoupNumber = selCoupArr.filter(v => v.proId == coup.proId).reduce((prve, cur) => {
|
||||
return prve + cur.num * 1
|
||||
}, 0)
|
||||
if (selCoupNumber >= findGoodsTotalNumber) {
|
||||
return false
|
||||
}
|
||||
console.log(selCoupNumber,findGoodsTotalNumber);
|
||||
return findGoodsTotalNumber < selCoupNumber ? false : true
|
||||
}
|
||||
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
|
||||
export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
|
||||
const newGoodsArr = returnNewGoodsList(goodsArr)
|
||||
const item = newGoodsArr.find(v => v.productId == coup.proId);
|
||||
if (!item) {
|
||||
return {
|
||||
...coup,
|
||||
discountAmount: 0,
|
||||
use: false
|
||||
}
|
||||
}
|
||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||
const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
|
||||
const discountAmount = (price * coup.num).toFixed(2)
|
||||
console.log(discountAmount);
|
||||
|
||||
// const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
|
||||
// const canUse=discountAmount>0
|
||||
const canUse=coup.use
|
||||
return {
|
||||
...coup,
|
||||
discountAmount: discountAmount,
|
||||
use: canUse
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 根据购物车商品计算商品券抵扣价格以及是否满足可用需求
|
||||
* 1.商品券对应商品数量大于购物车对应商品数量不可用
|
||||
* 2.未在购物车找到相关商品不可用
|
||||
* @param {*} coupArr
|
||||
* @param {*} goodsArr
|
||||
* @param {*} vipUser
|
||||
* @returns
|
||||
*/
|
||||
export function returnProductAllCoup(coupArr, goodsArr, vipUser) {
|
||||
return coupArr.map((v) => {
|
||||
return returnProductCoupon(v, goodsArr, vipUser)
|
||||
})
|
||||
|
||||
}
|
||||
//返回商品实际支付价格
|
||||
export function returnProductPayPrice(goods,vipUser){
|
||||
const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
|
||||
const price = isUseVipPrice(vipUser,goods) ? memberPrice : goods.price;
|
||||
return price
|
||||
}
|
||||
//返回商品券抵扣的商品价格
|
||||
export function returnProductCoupAllPrice(productPriceArr,startIndex,num,isMember=true){
|
||||
console.log(productPriceArr);
|
||||
return productPriceArr.slice(startIndex,startIndex+num).reduce((prve,cur)=>{
|
||||
let curPrice=0
|
||||
if(typeof cur==='object'){
|
||||
curPrice=isMember?cur.memberPrice*1:cur.price
|
||||
}else{
|
||||
curPrice=cur*1
|
||||
}
|
||||
return prve+curPrice
|
||||
},0)
|
||||
}
|
||||
|
||||
//返回商品券可抵扣的商品数量
|
||||
export function returnProductCanUseNum(productPriceArr,startIndex,num){
|
||||
console.log(productPriceArr);
|
||||
console.log(num);
|
||||
let n=0;
|
||||
for(let i=0;i<num;i++){
|
||||
if(productPriceArr[startIndex*1+i]){
|
||||
n+=1
|
||||
console.log(n);
|
||||
}else{
|
||||
break
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
//返回同类商品券在同类商品价格数组里的开始位置
|
||||
export function returnProCoupStartIndex(coupArr,index){
|
||||
return coupArr.slice(0,index).reduce((prve,cur)=>{
|
||||
return prve+cur.num*1
|
||||
},0)
|
||||
}
|
||||
//返回商品数量从0到n每一个对应的价格对照表
|
||||
export function returnGoodsPayPriceMap(goodsArr){
|
||||
return goodsArr.reduce((prve,cur)=>{
|
||||
if(!prve.hasOwnProperty(cur.productId)){
|
||||
prve[cur.productId]=[]
|
||||
}
|
||||
const arr=new Array(cur.num).fill(cur).map(v=>{
|
||||
return {
|
||||
memberPrice:v.memberPrice?v.memberPrice:v.price,
|
||||
price:v.price
|
||||
}
|
||||
})
|
||||
prve[cur.productId].push(...arr)
|
||||
return prve
|
||||
},{})
|
||||
}
|
||||
//计算商品券总优惠价格
|
||||
export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
if (coupArr.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
//商品分组
|
||||
const goodsMap={}
|
||||
//商品数量从0到n每一个对应的价格
|
||||
const goodsPayPriceMap={}
|
||||
//商品券分组
|
||||
let coupMap={}
|
||||
for(let i in coupArr){
|
||||
const coup=coupArr[i]
|
||||
if(coupMap.hasOwnProperty(coup.proId)){
|
||||
coupMap[coup.proId].push(coup)
|
||||
}else{
|
||||
coupMap[coup.proId]=[coup]
|
||||
}
|
||||
}
|
||||
let total=0
|
||||
for(let key in coupMap){
|
||||
const arr=coupMap[key]
|
||||
for(let i in arr){
|
||||
const coup=arr[i]
|
||||
if(!goodsMap.hasOwnProperty(coup.proId)){
|
||||
goodsMap[coup.proId]=goodsArr.filter(v=>v.productId==coup.proId).map(v=>{
|
||||
return {
|
||||
...v,
|
||||
payPrice:returnProductPayPrice(v,vipUser)
|
||||
}
|
||||
}).sort((a,b)=>{
|
||||
const aPrice=a.payPrice
|
||||
const bPrice=b.payPrice
|
||||
return aPrice-bPrice
|
||||
})
|
||||
goodsPayPriceMap[coup.proId]=goodsMap[coup.proId].reduce((prve,cur)=>{
|
||||
const arr=new Array(cur.num).fill(cur.payPrice)
|
||||
console.log(arr);
|
||||
prve.push(...arr)
|
||||
return prve
|
||||
},[])
|
||||
}
|
||||
const proCoupStartIndex=returnProCoupStartIndex(arr,i)
|
||||
console.log(proCoupStartIndex);
|
||||
const coupNum=Math.min(goodsPayPriceMap[coup.proId].length,coup.num)
|
||||
console.log(coupNum);
|
||||
total+=returnProductCoupAllPrice(goodsPayPriceMap[coup.proId],proCoupStartIndex,coupNum)
|
||||
}
|
||||
}
|
||||
|
||||
return total.toFixed(2);
|
||||
|
||||
}
|
||||
//计算满减券总优惠价格
|
||||
export function returnFullReductionCouponAllPrice(coupArr) {
|
||||
if (coupArr.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
return coupArr.filter(v => v.type == 1).reduce((a, b) => {
|
||||
const price = b.discountAmount
|
||||
return a + price;
|
||||
}, 0).toFixed(2);
|
||||
|
||||
}
|
||||
//计算优惠券总价格
|
||||
export function returnCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
const poductAllprice = returnProductCouponAllPrice(coupArr, goodsArr, vipUser)
|
||||
const pointAllPrice = returnFullReductionCouponAllPrice(coupArr)
|
||||
return (poductAllprice * 1 + pointAllPrice * 1).toFixed(2);
|
||||
}
|
||||
|
||||
//返回当前满减券列表可用状态
|
||||
export function returnCanUseFullReductionCoupon(coupArr, payPrice, selCoup) {
|
||||
return coupArr.map(v => {
|
||||
if (v.id == selCoup.id) {
|
||||
return {...v,use:true}
|
||||
}
|
||||
const isfullAmount = payPrice*1 >= v.fullAmount * 1
|
||||
if(payPrice<=0){
|
||||
return {
|
||||
...v,
|
||||
use: false
|
||||
}
|
||||
}
|
||||
return {
|
||||
...v,
|
||||
use: v.use && isfullAmount
|
||||
}
|
||||
}).filter(v => v.use)
|
||||
}
|
||||
|
||||
//根据商品数量还有商品券数量返回优惠券可以使用的数量数组
|
||||
export function returnCanUseNumProductCoup(coupArr,){
|
||||
let productCoup = coupArr.filter(v => v.type == 2)
|
||||
//商品券分组
|
||||
let coupMap={}
|
||||
for(let i in productCoup){
|
||||
const coup=productCoup[i]
|
||||
if(coupMap.hasOwnProperty(coup.proId)){
|
||||
coupMap[coup.proId].push(coup)
|
||||
}else{
|
||||
coupMap[coup.proId]=[coup]
|
||||
}
|
||||
}
|
||||
return arr
|
||||
}
|
||||
231
src/views/tool/Instead/util.js
Normal file
231
src/views/tool/Instead/util.js
Normal file
@@ -0,0 +1,231 @@
|
||||
import {isTui} from '../../order_manage/order_goods_util.js'
|
||||
//计算打包费
|
||||
export function returnPackFee(arr, isOld = true) {
|
||||
if (isOld) {
|
||||
return arr.reduce((a, b) => {
|
||||
const bTotal = b.info
|
||||
.filter((v) => v.isGift !== "true" && v.status !== "return")
|
||||
.reduce((prve, cur) => {
|
||||
return prve + (cur.packFee || cur.packAmount || 0);
|
||||
}, 0);
|
||||
return a + bTotal;
|
||||
}, 0);
|
||||
} else {
|
||||
return arr.filter(v => v.status !== 'return' && v.isGift !== 'true').reduce((a, b) => {
|
||||
return a + (b.packFee || b.packAmount || 0);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
}
|
||||
//判断商品是否可以下单
|
||||
export function isCanBuy(skuGoods, goods) {
|
||||
if (goods.typeEnum == 'normal') {
|
||||
//单规格
|
||||
return goods.isGrounding && goods.isPauseSale == 0 && (goods.isStock ? goods.stockNumber > 0 : true);
|
||||
} else {
|
||||
//多规格
|
||||
return goods.isGrounding && goods.isPauseSale == 0 && skuGoods.isGrounding && skuGoods.isPauseSale == 0 && (goods.isStock ? goods.stockNumber > 0 : true);
|
||||
|
||||
}
|
||||
}
|
||||
//字符匹配
|
||||
export function $strMatch(matchStr, str) {
|
||||
return matchStr.toLowerCase().includes(str.toLowerCase())
|
||||
}
|
||||
|
||||
// 一个数组是否包含另外一个数组全部元素
|
||||
export function arrayContainsAll(arr1, arr2) {
|
||||
for (let i = 0; i < arr2.length; i++) {
|
||||
if (!arr1.includes(arr2[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//n项 n-1项组合,生成全部结果
|
||||
export function generateCombinations(arr, k) {
|
||||
console.log(arr)
|
||||
console.log(k)
|
||||
let result = [];
|
||||
|
||||
function helper(index, current) {
|
||||
if (current.length === k) {
|
||||
result.push(current.slice()); // 使用slice()来避免直接修改原始数组
|
||||
} else {
|
||||
for (let i = index; i < arr.length; i++) {
|
||||
current.push(arr[i]); // 将当前元素添加到组合中
|
||||
helper(i + 1, current); // 递归调用,索引增加以避免重复选择相同的元素
|
||||
current.pop(); // 回溯,移除当前元素以便尝试其他组合
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
helper(0, []); // 从索引0开始,初始空数组作为起点
|
||||
return result;
|
||||
}
|
||||
|
||||
export function returnReverseVal(val, isReturnString = true) {
|
||||
const isBol = typeof val === "boolean";
|
||||
const isString = typeof val === "string";
|
||||
let reverseNewval = "";
|
||||
if (isBol) {
|
||||
reverseNewval = !val;
|
||||
}
|
||||
if (isString) {
|
||||
reverseNewval = val === "true" ? "false" : "true";
|
||||
}
|
||||
return reverseNewval;
|
||||
}
|
||||
|
||||
export function returnGiftArr(arr) {
|
||||
let result = []
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const info = arr[i].info
|
||||
for (let j = 0; j < info.length; j++) {
|
||||
if (info[j].isGift === 'true') {
|
||||
result.push(info[j])
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export function formatOrderGoodsList(arr) {
|
||||
const goodsMap = {}
|
||||
for (let i in arr) {
|
||||
const goods = arr[i]
|
||||
if (goods.productName != '客座费') {
|
||||
if (goodsMap.hasOwnProperty(goods.placeNum)) {
|
||||
goodsMap[goods.placeNum || 1].push(goods)
|
||||
} else {
|
||||
goodsMap[goods.placeNum || 1] = [goods]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return Object.entries(goodsMap).map(([key, value]) => ({
|
||||
info: value,
|
||||
placeNum: key || 1
|
||||
}))
|
||||
}
|
||||
|
||||
export function returnIsSeatFee(item) {
|
||||
if (!item) {
|
||||
return false
|
||||
}
|
||||
return item.productId == "-999"?true:false;
|
||||
}
|
||||
/**
|
||||
* 计算购物车会员优惠价格
|
||||
*/
|
||||
export function returnVipDiscountPrice() {
|
||||
|
||||
}
|
||||
|
||||
//计算商品券优惠价格
|
||||
export function returnProductCouponPrice(coup, goodsArr, vipUser) {
|
||||
const item = goodsArr.find(v => v.productId == coup.proId);
|
||||
if(!item){
|
||||
return 0
|
||||
}
|
||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
|
||||
return price*coup.num
|
||||
|
||||
}
|
||||
//返回新的商品列表,过滤掉退菜的,退单的商品
|
||||
export function returnNewGoodsList(arr) {
|
||||
let goodsMap={}
|
||||
return arr.filter(v => !isTui(v))
|
||||
}
|
||||
//根据当前购物车商品以及数量,已选券对应商品数量,判断该商品券是否可用
|
||||
export function returnCoupCanUse(goodsArr=[],coup,selCoupArr=[]) {
|
||||
if(!coup.use){
|
||||
return false
|
||||
}
|
||||
const findGoods=goodsArr.filter(v=>v.productId==coup.proId)
|
||||
if(!findGoods.length){
|
||||
return false
|
||||
}
|
||||
const findGoodsTotalNumber=findGoods.reduce((prve,cur)=>{
|
||||
return prve+cur.num*1
|
||||
},0)
|
||||
const selCoupNumber=selCoupArr.filter(v=>v.proId==coup.proId).reduce((prve,cur)=>{
|
||||
return prve+cur.num*1
|
||||
},0)
|
||||
if(selCoupNumber>=findGoodsTotalNumber){
|
||||
return false
|
||||
}
|
||||
return findGoodsTotalNumber<(coup.num+selCoupNumber)?false:true
|
||||
}
|
||||
//查找购物车商品根据购物车商品数据返回商品券信息(抵扣价格以及是否满足可用需求)
|
||||
export function returnProductCoupon(coup, goodsArr, vipUser,selCoupArr=[]) {
|
||||
const newGoodsArr = returnNewGoodsList(goodsArr)
|
||||
const item = newGoodsArr.find(v => v.productId == coup.proId);
|
||||
if(!item){
|
||||
return {...coup, discountAmount: 0,use:false}
|
||||
}
|
||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||
const price = item ? (vipUser.isVip ? memberPrice : item.price) : 0;
|
||||
const discountAmount=(price*coup.num).toFixed(2)
|
||||
console.log(discountAmount);
|
||||
const canUse=!coup.use?false:(discountAmount>0&&returnCoupCanUse(goodsArr,coup,selCoupArr))
|
||||
// const canUse=discountAmount>0
|
||||
return { ...coup, discountAmount: discountAmount,use:canUse}
|
||||
|
||||
}
|
||||
/**
|
||||
* 根据购物车商品计算商品券抵扣价格以及是否满足可用需求
|
||||
* 1.商品券对应商品数量大于购物车对应商品数量不可用
|
||||
* 2.未在购物车找到相关商品不可用
|
||||
* @param {*} coupArr
|
||||
* @param {*} goodsArr
|
||||
* @param {*} vipUser
|
||||
* @returns
|
||||
*/
|
||||
export function returnProductAllCoup(coupArr, goodsArr, vipUser){
|
||||
return coupArr.map((v) => {
|
||||
return returnProductCoupon(v, goodsArr, vipUser)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
//计算商品券总优惠价格
|
||||
export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
if(coupArr.length == 0){
|
||||
return 0;
|
||||
}
|
||||
return coupArr.reduce((a, b) => {
|
||||
const price = returnProductCouponPrice(b, goodsArr, vipUser)
|
||||
return a + price;
|
||||
}, 0).toFixed(2);
|
||||
|
||||
}
|
||||
//计算满减券总优惠价格
|
||||
export function returnFullReductionCouponAllPrice(coupArr) {
|
||||
if(coupArr.length == 0){
|
||||
return 0;
|
||||
}
|
||||
return coupArr.filter(v => v.type == 1).reduce((a, b) => {
|
||||
const price = b.discountAmount
|
||||
return a + price;
|
||||
}, 0).toFixed(2);
|
||||
|
||||
}
|
||||
//计算优惠券总价格
|
||||
export function returnCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
const poductAllprice=returnProductCouponAllPrice(coupArr, goodsArr, vipUser)
|
||||
const pointAllPrice=returnFullReductionCouponAllPrice(coupArr)
|
||||
return (poductAllprice*1+pointAllPrice*1).toFixed(2);
|
||||
}
|
||||
|
||||
//返回购物车商品价格
|
||||
export function returnCartPrice(goods, vipUser) {
|
||||
const price=goods.price||goods.salePrice
|
||||
if(!vipUser||!vipUser.id ||!vipUser.isVip){
|
||||
return price
|
||||
}
|
||||
const memberPrice = goods.memberPrice ? goods.memberPrice :price;
|
||||
return memberPrice
|
||||
}
|
||||
@@ -1,73 +1,82 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? '编辑区域' : '添加区域'" :visible.sync="dialogVisible" @close="reset">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
|
||||
<el-form-item label="区域名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入区域名称"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="onSubmitHandle">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog :title="form.id ? '编辑区域' : '添加区域'" v-model="dialogVisible" @close="reset">
|
||||
<el-form ref="refForm" :model="form" :rules="rules" label-width="120px" label-position="left">
|
||||
<el-form-item label="区域名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入区域名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="form.sort" placeholder="请输入排序"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="onSubmitHandle">确 定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { tbShopArea } from '@/api/table'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
form: {
|
||||
id: '',
|
||||
name: ''
|
||||
},
|
||||
rules: {
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入区域名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
<script setup>
|
||||
import APi from "@/api/account/shopArea";
|
||||
|
||||
let dialogVisible = ref(false);
|
||||
const form = reactive({
|
||||
name: "",
|
||||
});
|
||||
const rules = reactive({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入区域名称",
|
||||
trigger: "blur",
|
||||
},
|
||||
methods: {
|
||||
onSubmitHandle() {
|
||||
this.$refs.form.validate(async valid => {
|
||||
if (valid) {
|
||||
try {
|
||||
let res = await tbShopArea({
|
||||
...this.form,
|
||||
shopId: localStorage.getItem('shopId')
|
||||
}, this.form.id ? 'put' : 'post')
|
||||
this.$emit('success', res)
|
||||
this.close()
|
||||
this.$notify({
|
||||
title: '成功',
|
||||
message: `${this.form.id ? '编辑' : '添加'}成功`,
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
show(obj) {
|
||||
this.dialogVisible = true
|
||||
if (obj && obj.id) {
|
||||
this.form = JSON.parse(JSON.stringify(obj))
|
||||
}
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false
|
||||
},
|
||||
reset() {
|
||||
this.form.id = ''
|
||||
this.form.name = ''
|
||||
}
|
||||
],
|
||||
sort: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入排序",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const emits = defineEmits(["success"]);
|
||||
const refForm = ref(null);
|
||||
function onSubmitHandle() {
|
||||
refForm.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
let res = !form.id ? await APi.add(form) : await APi.edit(form);
|
||||
emits("success", res);
|
||||
close();
|
||||
ElNotification({
|
||||
title: "成功",
|
||||
message: `${form.id ? "编辑" : "添加"}成功`,
|
||||
type: "success",
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function show(obj) {
|
||||
dialogVisible.value = true;
|
||||
if (obj && obj.id) {
|
||||
Object.assign(form, obj);
|
||||
}
|
||||
}
|
||||
function close() {
|
||||
dialogVisible.value = false;
|
||||
}
|
||||
function reset() {
|
||||
form.id = "";
|
||||
form.name = "";
|
||||
form.sort = "";
|
||||
}
|
||||
defineExpose({
|
||||
show,
|
||||
close,
|
||||
});
|
||||
</script>
|
||||
@@ -1,21 +1,13 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="form.id ? '编辑台桌' : '添加台桌'"
|
||||
:visible.sync="dialogVisible"
|
||||
v-model="dialogVisible"
|
||||
@open="tbShopAreaGet"
|
||||
@close="reset"
|
||||
>
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="120px"
|
||||
label-position="left"
|
||||
>
|
||||
<el-form ref="refForm" :model="form" :rules="rules" label-width="120px" label-position="left">
|
||||
<el-form-item label="选择区域" prop="areaId">
|
||||
<el-select v-model="form.areaId" placeholder="请选择区域"
|
||||
@change="selectChange($event, 'form' , 'areaId')"
|
||||
>
|
||||
<el-select v-model="form.areaId" placeholder="请选择区域">
|
||||
<el-option
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
@@ -34,202 +26,172 @@
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="台桌标识" prop="sign">
|
||||
<el-form-item label="台桌标识" prop="sign" v-if="!form.id">
|
||||
<div class="u-flex">
|
||||
<div class="u-flex" style="width: 57px;">
|
||||
<el-input
|
||||
v-model="form.sign"
|
||||
placeholder="A"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-m-l-30" >
|
||||
<div class="u-flex">
|
||||
<div class="u-m-r-4">起始</div>
|
||||
<el-input v-model="form.start" style="width: 57px;" placeholder="请输入起始值" >
|
||||
</el-input>
|
||||
<div class="u-flex" style="width: 57px">
|
||||
<el-input v-model="form.sign" placeholder="A"></el-input>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-m-l-30">
|
||||
<div class="u-flex">
|
||||
<div class="u-m-r-4">起始</div>
|
||||
<el-input
|
||||
v-model="form.start"
|
||||
style="width: 57px"
|
||||
placeholder="请输入起始值"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style="background-color: #d9d9d9; height: 1px; width: 32px; border-radius: 1px"
|
||||
class="u-m-l-16 u-m-r-16"
|
||||
></div>
|
||||
<div class="u-flex">
|
||||
<span class="u-m-r-4">结束</span>
|
||||
<el-input
|
||||
v-model="form.end"
|
||||
style="width: 57px"
|
||||
placeholder="请输入结束值"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style="
|
||||
background-color: #D9D9D9;
|
||||
height: 1px;
|
||||
width: 32px;
|
||||
border-radius: 1px;
|
||||
"
|
||||
class="u-m-l-16 u-m-r-16"
|
||||
></div>
|
||||
<div class="u-flex">
|
||||
<span class="u-m-r-4">结束</span>
|
||||
<el-input v-model="form.end" style="width: 57px;" placeholder="请输入结束值">
|
||||
|
||||
</el-input>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="台桌名称" prop="name" v-if="form.id">
|
||||
<el-input v-model="form.name" placeholder="请输入台桌名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="客座数">
|
||||
<el-input-number
|
||||
v-model="form.capacity"
|
||||
v-model="form.maxCapacity"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="清台管理">
|
||||
<el-radio-group v-model="form.autoClear">
|
||||
<el-radio-button :label="0">手动清台</el-radio-button>
|
||||
<el-radio-button :label="1">自动清台</el-radio-button>
|
||||
<el-radio-button :value="0">手动清台</el-radio-button>
|
||||
<el-radio-button :value="1">自动清台</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="网络预定开关">
|
||||
<el-switch
|
||||
v-model="form.isPredate"
|
||||
:active-value="1"
|
||||
:inactive-value="2"
|
||||
></el-switch>
|
||||
<el-form-item v-if="form.id" label="网络预定开关">
|
||||
<el-switch v-model="form.isPredate" :active-value="1" :inactive-value="2"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型">
|
||||
<el-radio-group v-model="form.type">
|
||||
<el-radio-button :label="0">低消</el-radio-button>
|
||||
<el-radio-button :label="2">计时</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="最低消费" v-if="form.type == 0">
|
||||
<el-form-item v-if="form.id" label="网络预定台桌支付金额">
|
||||
<el-input-number
|
||||
v-model="form.amount"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="每小时收费" v-if="form.type == 2">
|
||||
<el-input-number
|
||||
v-model="form.perhour"
|
||||
v-model="form.predateAmount"
|
||||
:min="0"
|
||||
controls-position="right"
|
||||
></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="onSubmitHandle"
|
||||
>确 定</el-button
|
||||
>
|
||||
</span>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="onSubmitHandle">确 定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { tbShopTable, tbShopAreaGet ,$fastCreateTable} from "@/api/table";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
resetForm: "",
|
||||
loading: false,
|
||||
status: [
|
||||
{ value: "pending", name: "挂单中" },
|
||||
{ value: "using", name: "开台中" },
|
||||
{ value: "paying", name: "结算中" },
|
||||
{ value: "idle", name: "空闲" },
|
||||
{ value: "subscribe", name: "预定" },
|
||||
{ value: "closed", name: "关台" },
|
||||
// {value:'opening',name:'开台中'},
|
||||
{ value: "cleaning", name: "台桌清理中" },
|
||||
],
|
||||
form: {
|
||||
id: "",
|
||||
areaId: "",
|
||||
sign:'',
|
||||
start:1,
|
||||
end:10,
|
||||
capacity: 0,
|
||||
isPredate: 1,
|
||||
type: 2,
|
||||
perhour: 0,
|
||||
amount: 0,
|
||||
autoClear: 1,
|
||||
},
|
||||
rules: {
|
||||
areaId: [
|
||||
{
|
||||
required: true,
|
||||
message: "请选择区域",
|
||||
trigger: ["blur","change"],
|
||||
},
|
||||
],
|
||||
sign: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入台桌标识",
|
||||
trigger: ["blur","change"],
|
||||
},
|
||||
],
|
||||
},
|
||||
areaList: [],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.resetForm = { ...this.form };
|
||||
},
|
||||
methods: {
|
||||
//解决selectc值改变后未验证问题
|
||||
selectChange($event, ref, type) {
|
||||
this.$refs[ref][0].validateField(type)
|
||||
<script setup>
|
||||
import shopAreaApi from "@/api/account/shopArea";
|
||||
import tableApi from "@/api/account/table";
|
||||
let dialogVisible = ref(false);
|
||||
let resetForm = {};
|
||||
let loading = ref(false);
|
||||
let status = [
|
||||
{ value: "pending", name: "挂单中" },
|
||||
{ value: "using", name: "开台中" },
|
||||
{ value: "paying", name: "结算中" },
|
||||
{ value: "idle", name: "空闲" },
|
||||
{ value: "subscribe", name: "预定" },
|
||||
{ value: "closed", name: "关台" },
|
||||
// {value:'opening',name:'开台中'},
|
||||
{ value: "cleaning", name: "台桌清理中" },
|
||||
];
|
||||
|
||||
const form = reactive({
|
||||
areaId: "",
|
||||
sign: "",
|
||||
start: 1,
|
||||
end: 10,
|
||||
maxCapacity: 0,
|
||||
autoClear: 1,
|
||||
isPredate: "",
|
||||
predateAmount: "",
|
||||
});
|
||||
const rules = {
|
||||
areaId: [
|
||||
{
|
||||
required: true,
|
||||
message: "请选择区域",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
onSubmitHandle() {
|
||||
this.$refs.form.validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.loading = true;
|
||||
try {
|
||||
let res = await $fastCreateTable(
|
||||
{
|
||||
...this.form,
|
||||
qrcode: this.form.tableId,
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
},
|
||||
this.form.id ? "put" : "post"
|
||||
);
|
||||
this.$emit("success", res);
|
||||
this.close();
|
||||
this.$notify({
|
||||
title: "成功",
|
||||
message: `${this.form.id ? "编辑" : "添加"}成功`,
|
||||
type: "success",
|
||||
});
|
||||
this.loading = false;
|
||||
} catch (error) {
|
||||
this.loading = false;
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
],
|
||||
sign: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入台桌标识",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
show(obj) {
|
||||
this.dialogVisible = true;
|
||||
if (obj && obj.id) {
|
||||
this.form = JSON.parse(JSON.stringify(obj));
|
||||
}
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
reset() {
|
||||
this.form = { ...this.resetForm };
|
||||
},
|
||||
// 获取区域
|
||||
async tbShopAreaGet() {
|
||||
],
|
||||
};
|
||||
let areaList = ref([]);
|
||||
onMounted(() => {
|
||||
resetForm = { ...form };
|
||||
});
|
||||
|
||||
//解决selectc值改变后未验证问题
|
||||
const refForm = ref(null);
|
||||
const emits = defineEmits(["success"]);
|
||||
function onSubmitHandle() {
|
||||
refForm.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
loading.value = true;
|
||||
try {
|
||||
const { content } = await tbShopAreaGet({
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
let res = form.id ? await tableApi.edit(form) : await tableApi.add(form);
|
||||
console.log(res);
|
||||
emits("success", res);
|
||||
close();
|
||||
ElNotification({
|
||||
title: "成功",
|
||||
message: `${form.id ? "编辑" : "添加"}成功`,
|
||||
type: "success",
|
||||
});
|
||||
this.areaList = content;
|
||||
loading.value = false;
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
function show(obj) {
|
||||
dialogVisible.value = true;
|
||||
if (obj && obj.id) {
|
||||
Object.assign(form, obj);
|
||||
}
|
||||
}
|
||||
function close() {
|
||||
dialogVisible.value = false;
|
||||
}
|
||||
function reset() {
|
||||
delete form.id;
|
||||
Object.assign(form, resetForm);
|
||||
console.log(form);
|
||||
}
|
||||
// 获取区域
|
||||
async function tbShopAreaGet() {
|
||||
try {
|
||||
const data = await shopAreaApi.getList({});
|
||||
areaList.value = data.records;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show,
|
||||
close,
|
||||
});
|
||||
</script>
|
||||
@@ -1 +1,497 @@
|
||||
<template></template>
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-tabs v-model="tableArea.tabsSel" type="card" @tab-click="tabClick">
|
||||
<el-tab-pane label="全部" name="" />
|
||||
<el-tab-pane
|
||||
v-for="item in tableArea.tabs"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:name="`${item.id}`"
|
||||
>
|
||||
<template #label>
|
||||
<div class="">
|
||||
<span>
|
||||
{{ item.name }}
|
||||
</span>
|
||||
<el-icon style="margin: 0 10px" @click="addEaraShow(item)"><EditPen /></el-icon>
|
||||
<el-popconfirm title="确定删除吗?" @confirm="delArea(item.id)">
|
||||
<template #reference>
|
||||
<el-icon><Delete /></el-icon>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<div class="">
|
||||
<el-button icon="plus" @click="addEaraShow()">添加区域</el-button>
|
||||
<el-button type="primary" icon="plus" @click="addTableShow()">添加台桌</el-button>
|
||||
<el-button type="primary" icon="download" @click="downloadTableCpde">下载桌台码</el-button>
|
||||
<el-button type="primary" icon="download" @click="downloadShopCpde">下载店铺码</el-button>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-p-b-15 u-font-14 u-m-t-16">
|
||||
<div v-for="(item, key) in status" :key="key" class="state u-m-r-24">
|
||||
<span
|
||||
class="dot"
|
||||
:style="{
|
||||
backgroundColor: status[key] ? status[key].type : '',
|
||||
}"
|
||||
/>
|
||||
{{ item.label }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 列表 -->
|
||||
<div class="head-container">
|
||||
<div v-loading="loading" class="table_list">
|
||||
<div
|
||||
v-for="item in tableList"
|
||||
:key="item.id"
|
||||
class="item"
|
||||
:style="{ 'background-color': status[item.status].type }"
|
||||
>
|
||||
<div class="new-top flex u-row-between">
|
||||
<div class="u-flex u-flex-1 u-p-r-10">
|
||||
<span class="name u-line-1" style="max-width: 50px">
|
||||
{{ item.name }}
|
||||
</span>
|
||||
<span class="u-font-14 u-line-1">丨{{ areaMap[item.areaId] || "" }}</span>
|
||||
</div>
|
||||
<el-dropdown trigger="click" @command="tableComman($event, item)">
|
||||
<el-icon color="#fff" class="cur-pointer"><More /></el-icon>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="edit">
|
||||
<i class="i el-icon-edit" />
|
||||
<span>编辑</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item command="del">
|
||||
<i class="i el-icon-delete" />
|
||||
<span>删除</span>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="top">
|
||||
<div v-if="item.status == 'subscribe'">
|
||||
<div class="row row1" style="align-items: flex-start">
|
||||
<span style="font-size: 14px; color: #333">
|
||||
{{ item.bookingInfo.createUserName }}订{{ item.bookingInfo.bookingPerson }}「{{
|
||||
item.bookingInfo.gender == 1 ? "先生" : "女士"
|
||||
}}」
|
||||
</span>
|
||||
<div
|
||||
class="state"
|
||||
style="font-size: 12px; color: #666; display: flex; align-items: center"
|
||||
>
|
||||
<img
|
||||
style="width: 16px; height: 16px; filter: contrast(0.5)"
|
||||
src="@/assets/images/perpole.png"
|
||||
alt=""
|
||||
/>
|
||||
|
||||
{{ item.bookingInfo.bookingTime.substring(11, 19) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span style="font-size: 14px; color: #333; margin-top: 5px">
|
||||
{{ item.bookingInfo.phoneNumber }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="u-font-18 font-600 total-price">
|
||||
<span
|
||||
v-if="item.status == 'using'"
|
||||
class="cur-pointer"
|
||||
@click="diancanShow(item, 'isAddGoods')"
|
||||
>
|
||||
¥{{ item.totalAmount || 0 }}「{{ item.productNum }}件」
|
||||
</span>
|
||||
<!-- <span v-else class="color-fff">|</span> -->
|
||||
</div>
|
||||
<div class="row btn-group" style="margin-top: 10px">
|
||||
<template v-if="item.status == 'subscribe'">
|
||||
<el-button
|
||||
type="success"
|
||||
:disabled="!item.tableId || item.status === 'closed'"
|
||||
@click="markStatus(item, -1)"
|
||||
>
|
||||
取消预约
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-if="item.status == 'subscribe' && item.bookingInfo.status == 20">
|
||||
<el-button
|
||||
type="success"
|
||||
:disabled="!item.tableId || item.status === 'closed'"
|
||||
@click="markStatus(item, 10)"
|
||||
>
|
||||
到店
|
||||
</el-button>
|
||||
</template>
|
||||
<template
|
||||
v-if="
|
||||
item.status == 'idle' ||
|
||||
(item.status == 'subscribe' && item.bookingInfo.status == 10)
|
||||
"
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
:disabled="!item.tableId || item.status === 'closed'"
|
||||
@click="diancanShow(item)"
|
||||
>
|
||||
点餐
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-else-if="item.status != 'idle' && item.status != 'subscribe'">
|
||||
<template v-if="item.status == 'using'">
|
||||
<el-button
|
||||
:disabled="!item.tableId || item.status === 'closed'"
|
||||
@click="diancanShow(item, 'isAddGoods')"
|
||||
>
|
||||
加菜
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
:disabled="!item.tableId || item.status === 'closed'"
|
||||
@click="diancanShow(item, 'isPayOrder')"
|
||||
>
|
||||
结账
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-else-if="item.status == 'closed'">
|
||||
<el-button type="info" disabled>已关台</el-button>
|
||||
</template>
|
||||
<template v-else-if="item.status == 'cleaning'">
|
||||
<el-button
|
||||
type="info"
|
||||
:style="{
|
||||
backgroundColor: status[item.status].type,
|
||||
borderColor: status[item.status].type,
|
||||
}"
|
||||
@click="cleanTableHandle(item)"
|
||||
>
|
||||
清台
|
||||
</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button type="info" disabled>点餐</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="u-flex u-col-bottom bottom u-row-between color-666"
|
||||
:class="{ 'opacity-0': item.status == 'closed' }"
|
||||
>
|
||||
<div class="u-flex u-col-center">
|
||||
<img
|
||||
style="width: 16px; height: 16px; filter: contrast(0.5)"
|
||||
src="@/assets/images/perpole.png"
|
||||
alt=""
|
||||
/>
|
||||
<span class="u-m-t-4 u-font-12 u-m-l-2">
|
||||
{{ item.useNum || 0 }}/{{ item.maxCapacity }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="item.status == 'using'" class="u-flex">
|
||||
<img
|
||||
style="width: 16px; height: 16px; filter: contrast(0.5)"
|
||||
src="@/assets/images/shalou.png"
|
||||
alt=""
|
||||
/>
|
||||
<span class="u-m-t-4 u-font-12">{{ formatTime(item.durationTime) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="empty_wrap">
|
||||
<el-empty v-if="!tableList.length" description="空空如也~" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<addEara ref="refAddEara" @success="areainit" />
|
||||
<addTable ref="refAddTable" @success="tableinit" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import status from "./status.js";
|
||||
|
||||
import shopAreaApi from "@/api/account/shopArea";
|
||||
import tableApi from "@/api/account/table";
|
||||
import addEara from "./components/addEara.vue";
|
||||
import addTable from "./components/addTable.vue";
|
||||
|
||||
let loading = ref(false);
|
||||
//工具方法
|
||||
function formatTime(milliseconds) {
|
||||
console.log(milliseconds);
|
||||
if (!milliseconds) {
|
||||
return "";
|
||||
}
|
||||
const days = Math.floor(milliseconds / (1000 * 60 * 60 * 24));
|
||||
const hours = Math.floor((milliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60));
|
||||
return `${days ? days + "天" : ""} ${hours ? hours + "时" : ""} ${minutes + "分"}`;
|
||||
}
|
||||
|
||||
function downloadTableCpde() {}
|
||||
function downloadShopCpde() {}
|
||||
|
||||
// 台桌
|
||||
|
||||
/**
|
||||
* 编辑/删除
|
||||
* @param command
|
||||
* @param item
|
||||
*/
|
||||
function tableComman(command, item) {
|
||||
if (command === "edit") {
|
||||
return refAddTable.value.show(item);
|
||||
}
|
||||
if (command === "del") {
|
||||
ElMessageBox.confirm("是否删除" + item.name + "台桌", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(async () => {
|
||||
await tableApi.delete(item.id);
|
||||
ElMessage.success("删除成功");
|
||||
tableInit();
|
||||
})
|
||||
.catch(() => {});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const refAddTable = ref(null);
|
||||
function addTableShow(item) {
|
||||
refAddTable.value.show(item);
|
||||
}
|
||||
|
||||
const tableList = ref([]);
|
||||
const tablequery = reactive({
|
||||
page: 1,
|
||||
size: 100,
|
||||
});
|
||||
|
||||
async function tableInit() {
|
||||
const res = await tableApi.getList({ ...tablequery, areaId: tableArea.tabsSel });
|
||||
tableList.value = res.records;
|
||||
}
|
||||
|
||||
// 区域
|
||||
let areaMap = ref({});
|
||||
const refAddEara = ref(null);
|
||||
function addEaraShow(item) {
|
||||
refAddEara.value.show(item);
|
||||
}
|
||||
const tabVlaue = ref("");
|
||||
const tabs = ref([]);
|
||||
const tableArea = reactive({
|
||||
tabs: [],
|
||||
tabsSel: "",
|
||||
});
|
||||
watch(
|
||||
() => tableArea.tabsSel,
|
||||
() => {
|
||||
tableInit();
|
||||
}
|
||||
);
|
||||
//区域删除
|
||||
function delArea(id) {
|
||||
shopAreaApi.delete(id).then((res) => {
|
||||
ElMessage.success("删除成功");
|
||||
areainit();
|
||||
});
|
||||
}
|
||||
//区域列表初始化
|
||||
async function areainit() {
|
||||
const res = await shopAreaApi.getList();
|
||||
console.log(res);
|
||||
tableArea.tabs = res.records;
|
||||
areaMap.value = res.records.reduce((prve, cur) => {
|
||||
prve[cur.id] = cur.name;
|
||||
return prve;
|
||||
}, {});
|
||||
}
|
||||
|
||||
const tabClick = (tab) => {
|
||||
console.log(tab);
|
||||
};
|
||||
init();
|
||||
function init() {
|
||||
areainit();
|
||||
tableInit();
|
||||
}
|
||||
onMounted(() => {});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.el-tabs {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
<style scoped lang="scss">
|
||||
.cur-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
.opacity-0 {
|
||||
opacity: 0;
|
||||
}
|
||||
.icon {
|
||||
margin-left: 10px;
|
||||
}
|
||||
::v-deep .btn-group .el-button {
|
||||
width: 100%;
|
||||
}
|
||||
::v-deep .el-dropdown-menu__item {
|
||||
line-height: 36px;
|
||||
padding: 0 20px;
|
||||
min-width: 60px;
|
||||
text-align: center;
|
||||
}
|
||||
.state {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.dot {
|
||||
$size: 8px;
|
||||
width: $size;
|
||||
height: $size;
|
||||
border-radius: 50%;
|
||||
margin-right: $size;
|
||||
}
|
||||
}
|
||||
.table_list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
min-height: 150px;
|
||||
|
||||
.empty_wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.btn-group {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.item {
|
||||
padding: 1px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #ddd;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
border-radius: 6px;
|
||||
background-color: #1890ff;
|
||||
max-width: 210px;
|
||||
min-width: 190px;
|
||||
&.using {
|
||||
background-color: rgb(250, 85, 85);
|
||||
}
|
||||
&.closed {
|
||||
background-color: rgb(221, 221, 221);
|
||||
filter: grayscale(1);
|
||||
}
|
||||
.total-price {
|
||||
line-height: 35px;
|
||||
height: 35px;
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
.new-top {
|
||||
height: 30px;
|
||||
color: #fff;
|
||||
padding: 0 12px;
|
||||
}
|
||||
.name {
|
||||
font-size: 16px;
|
||||
line-height: 30px;
|
||||
margin-right: 10px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.box {
|
||||
height: 100%;
|
||||
background-color: #fff;
|
||||
border-radius: 3px 3px 6px 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.bottom {
|
||||
border-top: 1px solid #f7f7fa;
|
||||
padding: 6px 15px;
|
||||
}
|
||||
.top {
|
||||
padding: 10px;
|
||||
background-color: #fff;
|
||||
flex: 1;
|
||||
border-radius: 3px 3px 0 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
.row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
|
||||
.tips {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
&.row1 {
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btm {
|
||||
border-top: 1px solid #ddd;
|
||||
background-color: #efefef;
|
||||
display: flex;
|
||||
border-radius: 0 0 6px 6px;
|
||||
.btm_item {
|
||||
flex: 1;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&:nth-child(1) {
|
||||
&::before {
|
||||
content: "";
|
||||
height: 50%;
|
||||
border-right: 1px solid #ddd;
|
||||
position: absolute;
|
||||
top: 25%;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.i {
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
327
src/views/user/active/components/addActive.vue
Normal file
327
src/views/user/active/components/addActive.vue
Normal file
@@ -0,0 +1,327 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog :title="form.id ? '编辑活动' : '添加活动'" v-model="dialogVisible" @close="reset">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
|
||||
<el-form-item label="充值">
|
||||
<el-input
|
||||
style="width: 220px"
|
||||
placeholder="请输入金额"
|
||||
v-model="form.amount"
|
||||
@input="(v) => (form.amount = v.replace(/^(0+)|[^\d]+/g, ''))"
|
||||
>
|
||||
<template #prepend>满</template>
|
||||
<template #append>元</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="赠送">
|
||||
<div style="display: flex">
|
||||
<el-input
|
||||
style="width: 220px"
|
||||
placeholder="请输入金额"
|
||||
v-model="form.giftAmount"
|
||||
@input="(v) => (form.giftAmount = v.replace(/^(0+)|[^\d]+/g, ''))"
|
||||
>
|
||||
<template #prepend>赠</template>
|
||||
<template #append>元</template>
|
||||
</el-input>
|
||||
<el-input
|
||||
style="margin-left: 20px; width: 220px"
|
||||
placeholder="请输入金额"
|
||||
v-model="form.giftPoints"
|
||||
@input="(v) => (form.giftPoints = v.replace(/^(0+)|[^\d]+/g, ''))"
|
||||
>
|
||||
<template #prepend>赠</template>
|
||||
<template #append>积分</template>
|
||||
</el-input>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否使用优惠券">
|
||||
<el-switch v-model="form.isGiftCoupon" :active-value="1" :inactive-value="0"></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="数量">
|
||||
<el-input-number v-model="form.num" controls-position="right" :min="1"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择优惠劵" v-if="form.isGiftCoupon == 1">
|
||||
<div>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
@click="$refs.coupon.show([...productIds])"
|
||||
>
|
||||
添加优惠劵
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="shop_list">
|
||||
<div
|
||||
class="item_wrap"
|
||||
style="display: flex; align-items: center; margin-top: 6px"
|
||||
v-for="(item, index) in productIds"
|
||||
:key="index"
|
||||
>
|
||||
<div class="name">{{ item.title }}</div>
|
||||
|
||||
<el-button type="text" @click="productIds = []" style="margin-left: 20px">
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="onSubmitHandle">确 定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<coupon ref="coupon" @success="slectShop" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import handselTypes from "../handselTypes";
|
||||
// import { activate, storageupActivate } from '@/api/shop'
|
||||
import coupon from "@/components/coupon/index.vue";
|
||||
import activeApi from "@/api/account/activate";
|
||||
import { ElNotification } from "element-plus";
|
||||
export default {
|
||||
components: { coupon },
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
loading: false,
|
||||
handselTypes: handselTypes,
|
||||
form: {
|
||||
id: "",
|
||||
amount: "",
|
||||
giftAmount: "",
|
||||
giftPoints: "",
|
||||
isGiftCoupon: 0,
|
||||
couponId: "",
|
||||
num: 1,
|
||||
},
|
||||
productIds: [],
|
||||
resetForm: "",
|
||||
rules: {
|
||||
minNum: [
|
||||
{
|
||||
required: true,
|
||||
message: " ",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
maxNum: [
|
||||
{
|
||||
required: true,
|
||||
message: " ",
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.resetForm = { ...this.form };
|
||||
},
|
||||
methods: {
|
||||
slectShop(res) {
|
||||
console.log(res, 11);
|
||||
// if (this.productIds.length) {
|
||||
// res.map(async item => {
|
||||
// if (!await this.checkShop(item.id)) {
|
||||
// this.productIds.push({ ...item })
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
this.productIds = res;
|
||||
// }
|
||||
},
|
||||
// 判断是否存在重复商品
|
||||
checkShop(id) {
|
||||
let falg = false;
|
||||
this.productIds.map((item) => {
|
||||
if (item.id == id) {
|
||||
falg = true;
|
||||
}
|
||||
});
|
||||
return falg;
|
||||
},
|
||||
checkIfNum(item) {
|
||||
item.num = item.num.toString().replace(/\D/g, "");
|
||||
},
|
||||
// 确认选择商品分类
|
||||
classifySuccess(e) {
|
||||
this.form.config.categoryList = e;
|
||||
},
|
||||
onSubmitHandle() {
|
||||
console.log(this.form);
|
||||
if (this.form.amount == "") {
|
||||
this.$message({
|
||||
message: "充值金额不能为空",
|
||||
type: "warning",
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (this.form.isGiftCoupon == 1) {
|
||||
if (this.productIds.length == 0) {
|
||||
this.$message({
|
||||
message: "请选择优惠劵",
|
||||
type: "warning",
|
||||
});
|
||||
return false;
|
||||
}
|
||||
this.form.couponId = this.productIds[0].id;
|
||||
} else {
|
||||
this.form.couponId = "";
|
||||
this.form.couponName = "";
|
||||
this.productIds = [];
|
||||
}
|
||||
// let arr = []
|
||||
// this.productIds.forEach(ele => {
|
||||
// arr.push({
|
||||
// productId: ele.id,
|
||||
// num: ele.num
|
||||
// })
|
||||
// })
|
||||
this.$refs.form.validate(async (valid) => {
|
||||
if (valid) {
|
||||
try {
|
||||
this.loading = true;
|
||||
let res = this.form.id
|
||||
? await activeApi.edit(this.form)
|
||||
: await activeApi.add(this.form);
|
||||
this.$emit("success", res);
|
||||
this.close();
|
||||
ElNotification({
|
||||
title: "成功",
|
||||
message: `${this.form.id ? "编辑" : "添加"}成功`,
|
||||
type: "success",
|
||||
});
|
||||
this.loading = false;
|
||||
} catch (error) {
|
||||
this.loading = false;
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
async show(obj) {
|
||||
this.productIds = [];
|
||||
this.dialogVisible = true;
|
||||
if (obj && obj.id) {
|
||||
this.form = { ...obj };
|
||||
// 留着以后说不定多个优惠劵
|
||||
// let res = await activate(obj.id)
|
||||
// this.productIds = res
|
||||
if (obj.couponId) {
|
||||
this.productIds = [{ title: obj.couponName, id: obj.couponId }];
|
||||
}
|
||||
console.log(obj, "调试1");
|
||||
}
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
reset() {
|
||||
this.form = { ...this.resetForm };
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.labelbox {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
color: #666666;
|
||||
width: 130px;
|
||||
background: #f7f7fa;
|
||||
border-radius: 2px 2px 2px 2px;
|
||||
border: 1px solid #dddfe6;
|
||||
padding: 0 10px;
|
||||
|
||||
input {
|
||||
border: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.labelboxss {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
font-family: Source Han Sans CN, Source Han Sans CN;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.shop_list {
|
||||
// display: flex;/
|
||||
// flex-wrap: wrap;
|
||||
|
||||
.item_wrap {
|
||||
$size: 80px;
|
||||
|
||||
.item {
|
||||
$radius: 4px;
|
||||
width: $size;
|
||||
height: $size;
|
||||
border-radius: $radius;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
margin-right: 10px;
|
||||
margin-top: 10px;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: attr(data-index);
|
||||
font-size: 12px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
padding: 0 10px;
|
||||
border-radius: 0 0 $radius 0;
|
||||
align-items: center;
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
backdrop-filter: blur(10px);
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: "删除";
|
||||
font-size: 12px;
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
padding: 0 10px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
backdrop-filter: blur(10px);
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 10;
|
||||
transition: all 0.1s ease-in-out;
|
||||
}
|
||||
}
|
||||
|
||||
.name {
|
||||
width: $size;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
73
src/views/user/active/components/downloadQR.vue
Normal file
73
src/views/user/active/components/downloadQR.vue
Normal file
@@ -0,0 +1,73 @@
|
||||
<template>
|
||||
<div class="downloadQR" v-show="isshow">
|
||||
<div class="box">
|
||||
<img :src="imgUrl" style="width: 300px; height: 300px" alt="" />
|
||||
<div class="btnStyle">
|
||||
<el-button type="primary" @click="isshow = false">取消</el-button>
|
||||
|
||||
<a :href="imgUrl"><el-button type="primary" @click="downImg">下载</el-button></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
// import { getwxacode } from '@/api/shop'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
isshow: false,
|
||||
imgUrl: "",
|
||||
};
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
show() {
|
||||
this.getlist();
|
||||
},
|
||||
async getlist() {
|
||||
let res = await getwxacode({
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
});
|
||||
this.isshow = true;
|
||||
|
||||
this.imgUrl = res;
|
||||
},
|
||||
downImg() {
|
||||
// window.location.href()
|
||||
window.URL.revokeObjectURL(this.imgUrl);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.downloadQR {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: rgba($color: #000000, $alpha: 0.6);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 9999;
|
||||
|
||||
.box {
|
||||
padding: 20px;
|
||||
border-radius: 3px;
|
||||
height: 400px;
|
||||
width: 340px;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
// align-items: center;
|
||||
// justify-content: center;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.btnStyle {
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
10
src/views/user/active/handselTypes.js
Normal file
10
src/views/user/active/handselTypes.js
Normal file
@@ -0,0 +1,10 @@
|
||||
export default [
|
||||
{
|
||||
label: "固定金额",
|
||||
value: "GD"
|
||||
},
|
||||
{
|
||||
label: "比例",
|
||||
value: "RATIO"
|
||||
}
|
||||
];
|
||||
@@ -1,155 +1,147 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 列表 -->
|
||||
<!-- 搜索 -->
|
||||
<page-search
|
||||
ref="searchRef"
|
||||
:search-config="searchConfig"
|
||||
@query-click="handleQueryClick"
|
||||
@reset-click="handleResetClick"
|
||||
/>
|
||||
<!-- 列表 -->
|
||||
<page-content
|
||||
ref="contentRef"
|
||||
:content-config="contentConfig"
|
||||
@add-click="handleAddClick"
|
||||
@edit-click="handleEditClick"
|
||||
@export-click="handleExportClick"
|
||||
@search-click="handleSearchClick"
|
||||
@toolbar-click="handleToolbarClick"
|
||||
@operat-click="handleOperatClick"
|
||||
@filter-change="handleFilterChange"
|
||||
>
|
||||
<template #status="scope">
|
||||
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
||||
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #options="scope">
|
||||
{{ returnOptionsLabel(scope.prop, scope.row[scope.prop]) }}
|
||||
</template>
|
||||
<template #bol="scope">
|
||||
{{ scope.row[scope.prop] ? "是" : "否" }}
|
||||
</template>
|
||||
<template #gender="scope">
|
||||
<el-tag
|
||||
:type="
|
||||
scope.row[scope.prop] == null
|
||||
? 'info'
|
||||
: scope.row[scope.prop] == 1
|
||||
? 'success'
|
||||
: 'warning'
|
||||
"
|
||||
>
|
||||
{{ scope.row[scope.prop] === null ? "未知" : scope.row[scope.prop] == 1 ? "男" : "女" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #user="scope">
|
||||
<div class="flex align-center">
|
||||
<el-avatar :src="scope.row.headImg" />
|
||||
<el-tag>{{ scope.row.nickName }}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
<template #link="scope">
|
||||
<el-link>{{ scope.row[scope.prop] }}</el-link>
|
||||
</template>
|
||||
<template #mobile="scope">
|
||||
<el-text>{{ scope.row[scope.prop] }}</el-text>
|
||||
<copy-button
|
||||
v-if="scope.row[scope.prop]"
|
||||
:text="scope.row[scope.prop]"
|
||||
style="margin-left: 2px"
|
||||
/>
|
||||
</template>
|
||||
</page-content>
|
||||
|
||||
<!-- 新增 -->
|
||||
<page-modal
|
||||
ref="addModalRef"
|
||||
:modal-config="addModalConfig"
|
||||
@submit-click="handleSubmitClick"
|
||||
@formDataChange="formDataChange"
|
||||
></page-modal>
|
||||
|
||||
<!-- 编辑 -->
|
||||
<page-modal
|
||||
ref="editModalRef"
|
||||
:modal-config="editModalConfig"
|
||||
@submit-click="handleSubmitClick"
|
||||
@formDataChange="formDataChange"
|
||||
></page-modal>
|
||||
<div class="head-container">
|
||||
<el-button type="primary" icon="plus" @click="$refs.addActive.show()">添加活动</el-button>
|
||||
<el-button type="primary" icon="download" @click="$refs.downloadQR.show()">
|
||||
下载会员充值二维码
|
||||
</el-button>
|
||||
<div style="margin-top: 35px; font-size: 16px; color: #333">
|
||||
允许充值自定义金额:
|
||||
<el-switch
|
||||
v-model="shopInfo.isCustom"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
size="large"
|
||||
@change="customStatusChange"
|
||||
></el-switch>
|
||||
</div>
|
||||
</div>
|
||||
<div class="head-container">
|
||||
<el-table :data="tableData.data" v-loading="tableData.loading">
|
||||
<el-table-column label="店铺ID" prop="shopId"></el-table-column>
|
||||
<el-table-column label="充值金额" prop="amount"></el-table-column>
|
||||
<el-table-column label="赠送金额" prop="giftAmount"></el-table-column>
|
||||
<el-table-column label="赠送积分" prop="giftPoints"></el-table-column>
|
||||
<el-table-column label="是否使用优惠券" prop="isUseCoupon">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.isUseCoupon == 1 ? "是" : "否" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120">
|
||||
<template v-slot="scope">
|
||||
<el-button type="text" icon="edit" @click="$refs.addActive.show(scope.row)">
|
||||
编辑
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="head-container">
|
||||
<el-pagination
|
||||
:total="tableData.total"
|
||||
:current-page="tableData.page + 1"
|
||||
:page-size="tableData.size"
|
||||
@current-change="paginationChange"
|
||||
layout="total"
|
||||
></el-pagination>
|
||||
</div>
|
||||
<addActive ref="addActive" @success="getTableData" />
|
||||
<QR ref="downloadQR"></QR>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup >
|
||||
import usePage from "@/components/CURD/usePage";
|
||||
import addModalConfig from "./config/add";
|
||||
import contentConfig from "./config/content";
|
||||
import editModalConfig from "./config/edit";
|
||||
import searchConfig from "./config/search";
|
||||
import { returnOptionsLabel } from "./config/config";
|
||||
const editMoneyModalRef = ref(null);
|
||||
const {
|
||||
searchRef,
|
||||
contentRef,
|
||||
addModalRef,
|
||||
editModalRef,
|
||||
handleQueryClick,
|
||||
handleResetClick,
|
||||
// handleAddClick,
|
||||
// handleEditClick,
|
||||
handleSubmitClick,
|
||||
handleExportClick,
|
||||
handleSearchClick,
|
||||
handleFilterChange,
|
||||
} = usePage();
|
||||
|
||||
// 修改金额表单类型
|
||||
function formDataChange(type, val) {
|
||||
console.log(type, val);
|
||||
}
|
||||
|
||||
// 新增
|
||||
async function handleAddClick() {
|
||||
addModalRef.value?.setModalVisible();
|
||||
}
|
||||
// 获取优惠券
|
||||
async function getCouponList() {}
|
||||
// 编辑
|
||||
async function handleEditClick(row) {
|
||||
editModalRef.value?.handleDisabled(false);
|
||||
editModalRef.value?.setModalVisible();
|
||||
// 根据id获取数据进行填充
|
||||
// const data = await VersionApi.getFormData(row.id);
|
||||
editModalRef.value?.setFormData({ ...row, headImg: row.headImg ? [row.headImg] : "" });
|
||||
}
|
||||
|
||||
// 其他工具栏
|
||||
function handleToolbarClick(name) {
|
||||
console.log(name);
|
||||
if (name === "custom1") {
|
||||
ElMessage.success("点击了自定义1按钮");
|
||||
}
|
||||
}
|
||||
|
||||
// 其他操作列
|
||||
async function handleOperatClick(data) {
|
||||
const row = data.row;
|
||||
if (data.name == "more") {
|
||||
if (data.command === "change-money") {
|
||||
editMoneyModalRef.value.setModalVisible();
|
||||
editMoneyModalRef.value.setFormData({ ...row, headImg: row.headImg ? [row.headImg] : "" });
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 切换示例
|
||||
const isA = ref(true);
|
||||
<script>
|
||||
import handselTypes from "./handselTypes";
|
||||
import addActive from "./components/addActive.vue";
|
||||
import QR from "./components/downloadQR.vue";
|
||||
import activeApi from "@/api/account/activate";
|
||||
import dayjs from "dayjs";
|
||||
export default {
|
||||
components: {
|
||||
addActive,
|
||||
QR,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
query: {
|
||||
shopId: "",
|
||||
},
|
||||
tableData: {
|
||||
data: [],
|
||||
page: 0,
|
||||
size: 10,
|
||||
loading: false,
|
||||
total: 0,
|
||||
},
|
||||
shopInfo: {
|
||||
isCustom: "0",
|
||||
},
|
||||
};
|
||||
},
|
||||
filters: {
|
||||
handselTypeFilter(value) {
|
||||
return handselTypes.find((item) => item.value == value).label;
|
||||
},
|
||||
timeFilter(s) {
|
||||
return dayjs(s).format("YYYY-MM-DD HH:mm:ss");
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.getTableData();
|
||||
},
|
||||
methods: {
|
||||
// 切换状态
|
||||
async statusChange(e, row) {
|
||||
if (row.couponName) {
|
||||
try {
|
||||
this.tableData.loading = true;
|
||||
const data = { ...row };
|
||||
data.isUseCoupon = e;
|
||||
console.log(data.isUseCoupon);
|
||||
await storageupActivate(data);
|
||||
this.getTableData();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
this.tableData.loading = false;
|
||||
}
|
||||
} else {
|
||||
console.log(22);
|
||||
this.$message({
|
||||
message: "请选择优惠劵",
|
||||
type: "warning",
|
||||
});
|
||||
return false;
|
||||
}
|
||||
},
|
||||
// 重置查询
|
||||
resetHandle() {
|
||||
this.query.name = "";
|
||||
this.query.type = "";
|
||||
this.getTableData();
|
||||
},
|
||||
// 分页回调
|
||||
paginationChange(e) {
|
||||
this.tableData.page = e - 1;
|
||||
this.getTableData();
|
||||
},
|
||||
// 获取商品列表
|
||||
async getTableData() {
|
||||
this.tableData.loading = true;
|
||||
try {
|
||||
const res = await activeApi.getList({});
|
||||
this.tableData.loading = false;
|
||||
this.tableData.data = res;
|
||||
this.tableData.total = res.length;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
customStatusChange() {
|
||||
this.updateShopInfo();
|
||||
},
|
||||
async updateShopInfo() {
|
||||
await tbShopInfoPut(this.shopInfo);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.align-center {
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user