Merge branch 'ymf' of https://e.coding.net/g-cphe0354/cashier/cashier-web
This commit is contained in:
commit
8e52613f08
|
|
@ -55,11 +55,11 @@ const CommonApi = {
|
|||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
sms(data: smsRequest) {
|
||||
sms(params: smsRequest) {
|
||||
return request<any, smsResponse>({
|
||||
url: `${baseURL}/sms`,
|
||||
method: "post",
|
||||
data: data,
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,9 +32,24 @@ const API = {
|
|||
data: data,
|
||||
});
|
||||
},
|
||||
// 查找优惠券 生成订单后使用
|
||||
findCoupon(params: findCouponRequest) {
|
||||
return request<any>({
|
||||
url: `${baseURL}/findCoupon`,
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
},
|
||||
}
|
||||
export default API;
|
||||
|
||||
export interface findCouponRequest {
|
||||
/**
|
||||
* 店铺用户Id
|
||||
*/
|
||||
shopUserId: number;
|
||||
type?: number;
|
||||
[property: string]: any;
|
||||
}
|
||||
export interface queryReceive {
|
||||
/**
|
||||
* 优惠券id
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
import request from "@/utils/request";
|
||||
import { Order_BaseUrl } from "@/api/config";
|
||||
const baseURL = Order_BaseUrl + "/admin/order/credit/buyer";
|
||||
const Api = {
|
||||
getList(params: any) {
|
||||
return request<any, any>({
|
||||
url: `${baseURL}/page`,
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
},
|
||||
get(params: any) {
|
||||
return request<any, any>({
|
||||
url: `${baseURL}`,
|
||||
method: "get",
|
||||
params
|
||||
});
|
||||
},
|
||||
add(data: any) {
|
||||
return request<any, any>({
|
||||
url: `${baseURL}`,
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
},
|
||||
edit(data: any) {
|
||||
return request<any, any>({
|
||||
url: `${baseURL}`,
|
||||
method: "put",
|
||||
data
|
||||
});
|
||||
},
|
||||
|
||||
delete(id: string | number) {
|
||||
return request<any, any>({
|
||||
url: `${baseURL}/` + id,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
// 还款
|
||||
|
||||
repayment(data: any) {
|
||||
return request<any, any>({
|
||||
url: `${baseURL}/repayment`,
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default Api;
|
||||
|
||||
|
|
@ -51,6 +51,14 @@ const Api = {
|
|||
params
|
||||
});
|
||||
},
|
||||
//挂账支付
|
||||
creditPay(data: any) {
|
||||
return request<any>({
|
||||
url: `${baseURL}/creditPay`,
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ export const constantRoutes: RouteRecordRaw[] = [
|
|||
{
|
||||
path: "credit",
|
||||
name: "creditStatistics",
|
||||
component: () => import("@/views/data/credit.vue"),
|
||||
component: () => import("@/views/data/credit/index.vue"),
|
||||
meta: {
|
||||
title: "挂账管理",
|
||||
affix: false,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
|
||||
//是否启用会员价
|
||||
const useVipPrice = computed(() => {
|
||||
return shopUser.userInfo.isMemberPrice && vipUser.value.id && vipUser.value.isVip
|
||||
return (shopUser.userInfo.isMemberPrice && vipUser.value.id && vipUser.value.isVip) ? true : false
|
||||
})
|
||||
|
||||
//台桌id
|
||||
|
|
@ -165,12 +165,14 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
const discount_sale_amount = cur.discount_sale_amount * 1 || 0
|
||||
const memberPrice = cur.skuData ? (cur.skuData.memberPrice || cur.skuData.salePrice) : 0
|
||||
const price = (discount_sale_amount || cur.salePrice || 0)
|
||||
return prve + cur.number * (discount_sale_amount || (useVipPrice.value ? memberPrice : price))
|
||||
const number = (cur.number - cur.returnNum)
|
||||
return prve + (number <= 0 ? 0 : number) * (discount_sale_amount || (useVipPrice.value ? memberPrice : price))
|
||||
}, 0)
|
||||
}
|
||||
return total
|
||||
})
|
||||
|
||||
|
||||
//支付总价
|
||||
const payMoney = computed(() => {
|
||||
const money = list.value.reduce((acc: number, cur: any) => {
|
||||
|
|
@ -181,6 +183,16 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
}, 0)
|
||||
return (money + packFee.value + oldOrderMoney.value * 1).toFixed(2)
|
||||
})
|
||||
//只算商品的总价
|
||||
const goodsTotal = computed(() => {
|
||||
const money = list.value.reduce((acc: number, cur: any) => {
|
||||
const discount_sale_amount = cur.discount_sale_amount * 1 || 0
|
||||
const memberPrice = cur.skuData ? (cur.skuData.memberPrice || cur.skuData.salePrice) : 0
|
||||
const price = (cur.discount_sale_amount * 1 || cur.salePrice || 0)
|
||||
return acc + cur.number * (discount_sale_amount || (useVipPrice.value ? memberPrice : price))
|
||||
}, 0)
|
||||
return (money + oldOrderMoney.value * 1).toFixed(2)
|
||||
})
|
||||
//总计数量
|
||||
const totalNumber = computed(() => {
|
||||
const cartNumber = list.value.reduce((acc: number, cur: any) => {
|
||||
|
|
@ -380,8 +392,8 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
for (let i in data) {
|
||||
newData[i] = data[i].map((v: any) => {
|
||||
const skuData = getProductDetails({ product_id: v.productId, sku_id: v.skuId })
|
||||
console.log(v)
|
||||
return {
|
||||
...v,
|
||||
...skuData,
|
||||
placeNum: v.placeNum,
|
||||
number: v.num,
|
||||
|
|
@ -557,6 +569,7 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
WebSocketManager.sendMessage(msg);
|
||||
}
|
||||
return {
|
||||
goodsTotal,
|
||||
isLinkFinshed,
|
||||
setOldOrder,
|
||||
singleDiscount,
|
||||
|
|
|
|||
|
|
@ -1,16 +1,11 @@
|
|||
import axios from "axios";
|
||||
import router from "@/router";
|
||||
import Config from "@/settings";
|
||||
import Cookies from "js-cookie";
|
||||
import { setToken } from "@/utils/globalCancelToken.js";
|
||||
function getToken() {
|
||||
return localStorage.getItem("bausertoken");
|
||||
}
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
// 创建axios实例
|
||||
const service = axios.create({
|
||||
// baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/',
|
||||
baseURL: "https://czgdoumei.sxczgkj.com/index.php/api/", // api 的 base_url
|
||||
timeout: Config.timeout, // 请求超时时间
|
||||
timeout: 1000 * 20, // 请求超时时间
|
||||
});
|
||||
|
||||
// request拦截器
|
||||
|
|
@ -21,7 +16,6 @@ service.interceptors.request.use(
|
|||
}
|
||||
config.headers["Content-Type"] = "application/json";
|
||||
// 添加可取消请求配置
|
||||
config.cancelToken = new axios.CancelToken((c) => setToken(c));
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class WebSocketManager {
|
|||
private reconnectAttempts = 0;
|
||||
private maxReconnectAttempts = 3; // 自定义最大重试次数
|
||||
private reconnectDelay = 5000; // 重试延迟(单位:毫秒)
|
||||
|
||||
private timer: any | null = null;
|
||||
// 初始化 WebSocket 客户端
|
||||
setupWebSocket() {
|
||||
const endpoint = import.meta.env.VITE_APP_WS_ENDPOINT;
|
||||
|
|
@ -60,8 +60,13 @@ class WebSocketManager {
|
|||
console.log("WebSocket 连接已建立");
|
||||
// ElNotification.success('WebSocket 连接已建立')
|
||||
this.sendMessage(this.initParams)
|
||||
clearTimeout(this.timer)
|
||||
this.timer = setInterval(() => {
|
||||
this.sendMessage({ "type": "ping_interval" })
|
||||
}, 1000 * 10);
|
||||
};
|
||||
this.client.onclose = () => {
|
||||
clearTimeout(this.timer)
|
||||
if (!this.connected) {
|
||||
// ElMessageBox.alert('WebSocket 连接已断开', 'Title', {
|
||||
// confirmButtonText: '立即重连',
|
||||
|
|
@ -74,6 +79,7 @@ class WebSocketManager {
|
|||
console.log("WebSocket 连接已断开");
|
||||
};
|
||||
this.client.onerror = (error) => {
|
||||
clearTimeout(this.timer)
|
||||
console.error("WebSocket 发生错误:", error);
|
||||
// ElNotification({
|
||||
// title: "提示",
|
||||
|
|
|
|||
|
|
@ -295,7 +295,25 @@ export default {
|
|||
methods: {
|
||||
reset() {
|
||||
this.$refs.form.resetFields();
|
||||
this.form = this.resetForm;
|
||||
this.form = {
|
||||
id: "",
|
||||
shopId: "",
|
||||
type: "1",
|
||||
title: "",
|
||||
fullAmount: null,
|
||||
discountAmount: null,
|
||||
validityType: "fixed",
|
||||
validStartTime: "",
|
||||
validEndTime: "",
|
||||
userDays: [],
|
||||
validDays: "",
|
||||
useTimeType: "all",
|
||||
useStartTime: "",
|
||||
useEndTime: "",
|
||||
proId: "",
|
||||
proName: "",
|
||||
number: "",
|
||||
};
|
||||
this.form.type = 1;
|
||||
},
|
||||
async open(data) {
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
import creditApi from "@/api/order/credit";
|
||||
import { returnOptions } from "./config";
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
|
||||
const modalConfig: IModalConfig = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "创建挂账人",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
form: {
|
||||
labelWidth: 140,
|
||||
},
|
||||
formAction: function (data) {
|
||||
return creditApi.add({ ...data });
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
type: 'switch',
|
||||
attrs: {
|
||||
activeText: '开启',
|
||||
inactiveText: '关闭',
|
||||
activeValue: 1,
|
||||
inactiveValue: 0
|
||||
},
|
||||
initialValue: 1
|
||||
},
|
||||
|
||||
{
|
||||
label: "挂账人",
|
||||
prop: "debtor",
|
||||
rules: [{ required: true, message: "请输入挂账人", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "手机号",
|
||||
prop: "mobile",
|
||||
rules: [{ required: true, message: "请输入挂账人手机号", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人手机号",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "职务",
|
||||
prop: "position",
|
||||
rules: [{ required: false, message: "请输入挂账人职务", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人职务",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "挂账额度",
|
||||
prop: "creditAmount",
|
||||
type: "input-number",
|
||||
rules: [{ required: true, message: "请输入挂账额度", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账额度",
|
||||
},
|
||||
initialValue: 0
|
||||
},
|
||||
{
|
||||
label: "还款方式",
|
||||
prop: "repaymentMethod",
|
||||
type: "radio-button",
|
||||
options: returnOptions('repaymentMethod'),
|
||||
initialValue: returnOptions('repaymentMethod')[0].value
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||||
export default reactive(modalConfig);
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
const options: Record<string, { label: string; value: string; }[]> = {
|
||||
repaymentMethod: [
|
||||
{ label: '按总金额还款', value: "total" },
|
||||
{ label: '按订单还款', value: "order" },
|
||||
]
|
||||
};
|
||||
|
||||
export function returnOptions(type: keyof typeof options) {
|
||||
return options[type];
|
||||
}
|
||||
|
||||
export function returnOptionsLabel(optionsType: optionsType, value: string | number) {
|
||||
const options = returnOptions(optionsType);
|
||||
if (!options) {
|
||||
return "";
|
||||
}
|
||||
const option = options.find((item) => item.value === value);
|
||||
return option ? option.label : "";
|
||||
}
|
||||
|
||||
export interface options {
|
||||
label: string;
|
||||
value: string | number;
|
||||
[property: string]: any;
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
import creditApi from "@/api/order/credit";
|
||||
import type { IContentConfig } from "@/components/CURD/types";
|
||||
|
||||
const contentConfig: IContentConfig = {
|
||||
pageName: "sys:user",
|
||||
table: {
|
||||
border: true,
|
||||
highlightCurrentRow: true,
|
||||
},
|
||||
pagination: {
|
||||
background: true,
|
||||
layout: "prev,pager,next,jumper,total,sizes",
|
||||
pageSize: 20,
|
||||
pageSizes: [10, 20, 30, 50],
|
||||
},
|
||||
indexAction: function (params) {
|
||||
return creditApi.getList(params);
|
||||
},
|
||||
deleteAction: creditApi.delete,
|
||||
// modifyAction: function (data) {
|
||||
// // return creditApi.edit(data);
|
||||
// },
|
||||
pk: "id",
|
||||
toolbar: ["add"],
|
||||
defaultToolbar: ["refresh", "filter", "search"],
|
||||
cols: [
|
||||
{
|
||||
label: "挂账编码",
|
||||
align: "center",
|
||||
prop: "id",
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
align: "center",
|
||||
prop: "status",
|
||||
templet: 'custom',
|
||||
slotName: 'status',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
label: "挂账人",
|
||||
align: "center",
|
||||
prop: "debtor",
|
||||
},
|
||||
{
|
||||
label: "手机号",
|
||||
align: "center",
|
||||
prop: "mobile",
|
||||
},
|
||||
{
|
||||
label: "挂账额度(元)",
|
||||
align: "center",
|
||||
prop: "creditAmount",
|
||||
},
|
||||
{
|
||||
label: "已挂账金额(元)",
|
||||
align: "center",
|
||||
prop: "owedAmount",
|
||||
},
|
||||
{
|
||||
label: "剩余挂账额度(元)",
|
||||
align: "center",
|
||||
prop: "owedAmount",
|
||||
},
|
||||
{
|
||||
label: "账户余额",
|
||||
align: "center",
|
||||
prop: "accountBalance",
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 300,
|
||||
templet: "tool",
|
||||
operat: [
|
||||
{
|
||||
text: "查看明细",
|
||||
name: 'detail'
|
||||
},
|
||||
{
|
||||
text: "编辑",
|
||||
name: 'edit'
|
||||
},
|
||||
{
|
||||
text: "还款",
|
||||
name: 'huankuan'
|
||||
},
|
||||
{
|
||||
text: "还款记录",
|
||||
name: 'huankuan_detail'
|
||||
},
|
||||
{
|
||||
text: "删除",
|
||||
name: 'delete'
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default contentConfig;
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
import creditApi from "@/api/order/credit";
|
||||
import { returnOptions } from "./config";
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
|
||||
const modalConfig: IModalConfig = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "编辑挂账人",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
form: {
|
||||
labelWidth: 140,
|
||||
},
|
||||
formAction: function (data) {
|
||||
return creditApi.edit({ ...data });
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
type: 'switch',
|
||||
attrs: {
|
||||
activeText: '开启',
|
||||
inactiveText: '关闭',
|
||||
activeValue: 1,
|
||||
inactiveValue: 0
|
||||
},
|
||||
initialValue: 1
|
||||
},
|
||||
|
||||
{
|
||||
label: "挂账人",
|
||||
prop: "debtor",
|
||||
rules: [{ required: true, message: "请输入挂账人", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "手机号",
|
||||
prop: "mobile",
|
||||
rules: [{ required: true, message: "请输入挂账人手机号", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人手机号",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "职务",
|
||||
prop: "position",
|
||||
rules: [{ required: false, message: "请输入挂账人职务", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人职务",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "挂账额度",
|
||||
prop: "creditAmount",
|
||||
type: "input-number",
|
||||
rules: [{ required: true, message: "请输入挂账额度", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账额度",
|
||||
},
|
||||
initialValue: 0
|
||||
},
|
||||
{
|
||||
label: "还款方式",
|
||||
prop: "repaymentMethod",
|
||||
type: "radio-button",
|
||||
options: returnOptions('repaymentMethod'),
|
||||
initialValue: returnOptions('repaymentMethod')[0].value
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||||
export default reactive(modalConfig);
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import type { ISearchConfig } from "@/components/CURD/types";
|
||||
|
||||
const searchConfig: ISearchConfig = {
|
||||
pageName: "sys:user",
|
||||
formItems: [
|
||||
{
|
||||
type: "input",
|
||||
label: "挂账人",
|
||||
prop: "keywords",
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人或手机号",
|
||||
clearable: true,
|
||||
style: {
|
||||
width: "200px",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
label: "还款状态",
|
||||
prop: "repaymentStatus",
|
||||
attrs: {
|
||||
placeholder: "请选择还款状态",
|
||||
clearable: true,
|
||||
style: {
|
||||
width: "200px",
|
||||
},
|
||||
},
|
||||
initialValue: '',
|
||||
options: [
|
||||
{ label: "未还款", value: 'unpaid' },
|
||||
{ label: "部分还款", value: 'partial' },
|
||||
{ label: "已还清", value: 'paid' },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default searchConfig;
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
<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 #gender="scope">
|
||||
<DictLabel v-model="scope.row[scope.prop]" code="gender" />
|
||||
</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"
|
||||
@form-data-change="handleFormDataChange"
|
||||
:modal-config="addModalConfig"
|
||||
@submit-click="handleSubmitClick"
|
||||
>
|
||||
<template #formFooter>
|
||||
<el-form-item label="" label-width="140">
|
||||
<p>一经创建无法更改还款方式</p>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</page-modal>
|
||||
|
||||
<!-- 编辑 -->
|
||||
<page-modal
|
||||
ref="editModalRef"
|
||||
:modal-config="editModalConfig"
|
||||
@submit-click="handleSubmitClick"
|
||||
></page-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import creditApi from "@/api/order/credit";
|
||||
import type { IObject, IOperatData } from "@/components/CURD/types";
|
||||
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";
|
||||
|
||||
let version = ref<string | number>("");
|
||||
function handleFormDataChange(type: string, value: string | number) {
|
||||
version.value = value;
|
||||
if (type === "version" && value !== "") {
|
||||
addModalConfig.formItems[5].hidden = false;
|
||||
return;
|
||||
}
|
||||
if (type === "version" && value == "") {
|
||||
addModalConfig.formItems[5].hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
const refVersionFile = ref<any>();
|
||||
const {
|
||||
searchRef,
|
||||
contentRef,
|
||||
addModalRef,
|
||||
editModalRef,
|
||||
handleQueryClick,
|
||||
handleResetClick,
|
||||
// handleAddClick,
|
||||
// handleEditClick,
|
||||
handleSubmitClick,
|
||||
handleExportClick,
|
||||
handleSearchClick,
|
||||
handleFilterChange,
|
||||
} = usePage();
|
||||
|
||||
// 新增
|
||||
async function handleAddClick() {
|
||||
addModalRef.value?.setModalVisible();
|
||||
// addModalConfig.formItems[2]!.attrs!.data =
|
||||
}
|
||||
// 编辑
|
||||
async function handleEditClick(row: IObject) {
|
||||
editModalRef.value?.handleDisabled(false);
|
||||
editModalRef.value?.setModalVisible();
|
||||
// 根据id获取数据进行填充
|
||||
// const data = await creditApi.getFormData(row.id);
|
||||
console.log({ ...row });
|
||||
editModalRef.value?.setFormData({ ...row, url: [row.url] });
|
||||
}
|
||||
1;
|
||||
// 其他工具栏
|
||||
function handleToolbarClick(name: string) {
|
||||
console.log(name);
|
||||
if (name === "custom1") {
|
||||
ElMessage.success("点击了自定义1按钮");
|
||||
}
|
||||
}
|
||||
// 其他操作列
|
||||
async function handleOperatClick(data: IOperatData) {
|
||||
console.log(data);
|
||||
}
|
||||
</script>
|
||||
|
|
@ -192,6 +192,7 @@ function handleLogin() {
|
|||
.login(user)
|
||||
.then(async (res) => {
|
||||
await userStore.getUserInfo();
|
||||
|
||||
const { path, queryParams } = parseRedirect();
|
||||
console.log(res, "Denglv返回");
|
||||
router.push({ path: path, query: queryParams });
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<div class="form">
|
||||
<div class="preview_wrap">
|
||||
<div class="phone_wrap">
|
||||
<div class="index_bg" v-if="tableActive == 'home'">
|
||||
<div class="index_bg" v-if="tableActive == 'index_bg'">
|
||||
<img class="bg" :src="selectItem.value" />
|
||||
<div class="menu_wrap">
|
||||
<div class="menu_wrap_div">
|
||||
|
|
@ -228,11 +228,12 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { ElMessage } from "element-plus";
|
||||
import shopExtendApi from "@/api/account/shopExtend";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
tableActive: "home",
|
||||
tableActive: "",
|
||||
tableData: [],
|
||||
selectItem: {},
|
||||
imageUrl: "",
|
||||
|
|
@ -248,7 +249,7 @@ export default {
|
|||
...this.selectItem,
|
||||
autokey: this.selectItem.autoKey,
|
||||
});
|
||||
this.$message({
|
||||
ElMessage({
|
||||
message: "编辑成功",
|
||||
type: "success",
|
||||
});
|
||||
|
|
@ -269,7 +270,7 @@ export default {
|
|||
try {
|
||||
let res = await shopExtendApi.get({});
|
||||
this.tableData = res;
|
||||
console.log(this.tableData[0]);
|
||||
this.tableActive = !this.tableActive ? res[0].autoKey : this.tableActive;
|
||||
this.selectItemChange(this.tableActive);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@
|
|||
<div>打包费:{{ detail.packFee || "-" }}</div>
|
||||
<div>订单原价:¥{{ detail.originAmount }}</div>
|
||||
<div>优惠金额:¥{{ detail.discountAmount }}</div>
|
||||
<div>积分抵扣:¥{{ detail.pointsDiscountAmount }}</div>
|
||||
<div>
|
||||
实收金额:
|
||||
<span style="color: red">¥{{ detail.payAmount }}</span>
|
||||
|
|
@ -104,23 +105,21 @@
|
|||
<el-table
|
||||
:data="item"
|
||||
:ref="'refTable' + index"
|
||||
@selection-change="selectionChange"
|
||||
@row-click="rowClick($event, index)"
|
||||
@select-all="tableSelectAll($event, index)"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<!-- <el-table-column type="selection" width="55" /> -->
|
||||
<el-table-column label="数量" type="selection">
|
||||
<template v-slot="scope">
|
||||
<el-checkbox v-model="scope.row.checked" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品">
|
||||
<template v-slot="scope">
|
||||
<div class="shop_info">
|
||||
<el-image
|
||||
v-if="scope.row.productSkuId != '-999'"
|
||||
:src="scope.row.productImg"
|
||||
style="width: 40px; height: 40px"
|
||||
></el-image>
|
||||
<div class="packeFee" v-else>
|
||||
<span>
|
||||
{{ scope.row.productName || "客座费" }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="info">
|
||||
<span :class="[scope.row.isVip == 1 ? 'colorStyle' : '']">
|
||||
{{ scope.row.productName }}
|
||||
|
|
@ -142,6 +141,22 @@
|
|||
<el-table-column label="实付">
|
||||
<template v-slot="scope">¥{{ scope.row.payAmount }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="可退款数量" align="center">
|
||||
<template v-slot="scope">
|
||||
<el-input-number
|
||||
v-if="scope.row.checked"
|
||||
style="width: 120px"
|
||||
v-model="scope.row.selNumber"
|
||||
:max="scope.row.num - scope.row.refundNum"
|
||||
></el-input-number>
|
||||
<span class="" v-else>0</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="已退" width="100" align="center">
|
||||
<template v-slot="scope">
|
||||
<span>{{ scope.row.refundNum }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template v-slot="scope">
|
||||
<template v-if="detail.status != 'unpaid'">
|
||||
|
|
@ -153,7 +168,7 @@
|
|||
>
|
||||
<span>退款</span>
|
||||
</el-button>
|
||||
<span class="color-999" v-if="isTui(scope.row)">已退款</span>
|
||||
<span class="color-999" v-if="scope.row.status == 'refund'">已退款</span>
|
||||
</template>
|
||||
<template v-if="detail.status == 'unpaid'">
|
||||
<el-button
|
||||
|
|
@ -170,7 +185,7 @@
|
|||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
<div class="u-p-20 u-flex u-row-right">
|
||||
<div class="u-p-20 u-flex u-row-right" v-if="detail.status !== 'refund'">
|
||||
<el-checkbox
|
||||
v-model="allSelected"
|
||||
@change="allSelectedChange"
|
||||
|
|
@ -253,6 +268,18 @@ export default {
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
tableSelect(e) {
|
||||
console.log(e);
|
||||
},
|
||||
tableSelectAll(e, index) {
|
||||
const arr = this.detail.detailMap[index];
|
||||
for (let i in arr) {
|
||||
arr[i].checked = e.length ? true : false;
|
||||
}
|
||||
},
|
||||
tableSelectionChange(e) {
|
||||
console.log(e);
|
||||
},
|
||||
rowClick(row, index) {
|
||||
this.$refs["refTable" + index][0].toggleRowSelection(row);
|
||||
},
|
||||
|
|
@ -261,17 +288,14 @@ export default {
|
|||
},
|
||||
allSelectedChange(newval) {
|
||||
for (let i in this.detail.detailMap) {
|
||||
this.detail.detailMap[i].forEach((item) => {
|
||||
if (newval) {
|
||||
this.$refs["refTable" + i][0].toggleRowSelection(item, true);
|
||||
} else {
|
||||
this.$refs["refTable" + i][0].toggleRowSelection(item, false);
|
||||
for (let key in this.detail.detailMap[i]) {
|
||||
this.detail.detailMap[i][key].checked = newval;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
reset() {
|
||||
this.user = "";
|
||||
this.allSelected = false;
|
||||
},
|
||||
returnPayType(payType) {
|
||||
if (!payType) {
|
||||
|
|
@ -350,13 +374,17 @@ export default {
|
|||
let arr = [];
|
||||
if (item === "all") {
|
||||
for (let i in this.detail.detailMap) {
|
||||
arr.push(...this.$refs["refTable" + i][0].getSelectionRows());
|
||||
this.detail.detailMap[i].map((v) => {
|
||||
if (v.checked) {
|
||||
arr.push(v);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
arr = [item];
|
||||
}
|
||||
if (arr.length == 0) {
|
||||
return ElMessage.error("请选择要退款的商品");
|
||||
return ElMessage.error("请选择要退款的商品和数量");
|
||||
}
|
||||
this.selGoods = item;
|
||||
this.$refs.refReturnMoney.open(arr, this.detail);
|
||||
|
|
@ -366,26 +394,7 @@ export default {
|
|||
console.log(item);
|
||||
this.$refs.refReturnCart.open(item);
|
||||
},
|
||||
// 切换类型
|
||||
getTableData() {
|
||||
if (this.type == "3") {
|
||||
this.tbOrderInfoData();
|
||||
}
|
||||
},
|
||||
// 获取退单列表
|
||||
async tbOrderInfoData() {
|
||||
try {
|
||||
const res = await tbOrderInfoData({
|
||||
source: this.detail.id,
|
||||
page: 0,
|
||||
pageSize: 500,
|
||||
orderType: "0",
|
||||
});
|
||||
this.refoundList = res.content;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
|
||||
// 获取订单详情
|
||||
async tbOrderInfoDetail(id) {
|
||||
try {
|
||||
|
|
@ -396,7 +405,15 @@ export default {
|
|||
this.user = res1;
|
||||
});
|
||||
}
|
||||
|
||||
for (let i in res.detailMap) {
|
||||
res.detailMap[i] = res.detailMap[i].map((v) => {
|
||||
return {
|
||||
...v,
|
||||
checked: false,
|
||||
selNumber: v.num - v.returnNum,
|
||||
};
|
||||
});
|
||||
}
|
||||
this.detail = res;
|
||||
this.loading = false;
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@
|
|||
<span class="">
|
||||
{{ goods.productName }}
|
||||
</span>
|
||||
<span class="color-999 u-m-l-10">x{{ goods.num || "" }}</span>
|
||||
<span class="color-999 u-m-l-10">x{{ goods.selNumber || "" }}</span>
|
||||
<span class="color-333 u-m-l-10 u-font-600">
|
||||
{{ goods.payAmount || "" }}
|
||||
{{ (goods.selNumber * goods.unitPrice).toFixed(2) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-flex u-col-top u-m-t-22">
|
||||
<h4span class="u-m-0">支付金额</h4span>
|
||||
<span class="u-m-0">支付金额</span>
|
||||
<div class="u-p-l-20">
|
||||
{{ detail.payAmount }}
|
||||
</div>
|
||||
|
|
@ -32,26 +32,30 @@
|
|||
</div>
|
||||
<div class="u-p-b-16 u-m-t-22">
|
||||
<div class="flex u-row-between">
|
||||
<span>线下收款</span>
|
||||
<span class="color-red">退款金额</span>
|
||||
<div class="u-flex u-flex-1 u-p-l-20">
|
||||
<el-input type="number" v-model="number" :min="min" :max="max">
|
||||
<template #append>可退1元</template>
|
||||
</el-input>
|
||||
<el-input-number
|
||||
type="number"
|
||||
v-model="number"
|
||||
:min="min"
|
||||
:max="canReturnMoney"
|
||||
></el-input-number>
|
||||
<span class="u-m-l-10">可退{{ canReturnMoney }}元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-flex u-col-top u-m-t-22">
|
||||
<div class="u-flex u-col-top u-m-t-22" v-if="detail.returnAmount * 1 > 0">
|
||||
<span class="u-m-0">退款金额</span>
|
||||
<div class="u-p-l-20">
|
||||
<span class="color-red">¥ {{ detail.discountAmount }}</span>
|
||||
<span class="color-666 u-m-l-4">(退款商品金额:260.16)</span>
|
||||
<span class="color-red">¥ {{ detail.returnAmount || 0 }}</span>
|
||||
<!-- <span class="color-666 u-m-l-4">(退款商品金额)</span> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-flex u-col-top u-m-t-22">
|
||||
<!-- <div class="u-flex u-col-top u-m-t-22">
|
||||
<span class="u-m-0">退回优惠券</span>
|
||||
<div class="u-p-l-20">
|
||||
<span class="color-666 u-m-l-4">该订单未使用优惠券</span>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div class="u-p-b-16 border-bottom">
|
||||
|
|
@ -130,6 +134,12 @@ export default {
|
|||
const danjia = this.goods.price;
|
||||
return (danjia * this.number).toFixed(2);
|
||||
},
|
||||
canReturnMoney() {
|
||||
if (!this.detail) {
|
||||
return 0;
|
||||
}
|
||||
return this.detail.payAmount - this.detail.refundAmount;
|
||||
},
|
||||
},
|
||||
filters: {
|
||||
to2(val) {
|
||||
|
|
@ -155,6 +165,11 @@ export default {
|
|||
this.note = tag + "," + this.note;
|
||||
},
|
||||
open(goods, detailInfo) {
|
||||
const totalMoney = goods.reduce((prve, cur) => {
|
||||
console.log(cur);
|
||||
return prve + cur.unitPrice * cur.selNumber;
|
||||
}, 0);
|
||||
this.number = totalMoney.toFixed(2);
|
||||
this.goodsList = goods;
|
||||
this.show = true;
|
||||
this.detail = detailInfo;
|
||||
|
|
@ -174,12 +189,12 @@ export default {
|
|||
return ElMessage.error("请输入退款原因");
|
||||
}
|
||||
this.$emit("confirm", {
|
||||
refundAmount: (this.goods.price * this.number).toFixed(2) * 1,
|
||||
refundAmount: this.number,
|
||||
cash: this.cash,
|
||||
refundReason: note,
|
||||
refundDetails: [
|
||||
{ id: this.goods.id, num: this.number, returnAmount: this.tuikuanJine * 1 },
|
||||
],
|
||||
refundDetails: this.goodsList.map((v) => {
|
||||
return { id: v.id, num: v.num };
|
||||
}),
|
||||
});
|
||||
this.close();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export function canTuicai(orderInfo, item) {
|
|||
return true;
|
||||
}
|
||||
export function canTuiKuan(orderInfo, item) {
|
||||
return orderInfo.status == "done" || orderInfo.status == "part-refund";
|
||||
return (orderInfo.status != "refund" && orderInfo.status != "unpaid") || item.status != "refund";
|
||||
}
|
||||
export function isTui(item) {
|
||||
return item.status == "return" || item.status == "refund" || item.status == "refunding";
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@
|
|||
<hr />
|
||||
<el-form ref="form" :model="form" label-width="120px" label-position="left">
|
||||
<el-form-item label="校验安全密码">
|
||||
<el-checkbox v-model="form.isReturn">退款</el-checkbox>
|
||||
<el-checkbox v-model="form.isMemberIn">会员充值</el-checkbox>
|
||||
<el-checkbox v-model="form.isMemberReturn">会员退款</el-checkbox>
|
||||
<el-checkbox v-model="form.isReturnPwd">退款</el-checkbox>
|
||||
<el-checkbox v-model="form.isMemberInPwd">会员充值</el-checkbox>
|
||||
<el-checkbox v-model="form.isMemberReturnPwd">会员退款</el-checkbox>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="submitHandles">保存</el-button>
|
||||
|
|
@ -43,6 +43,8 @@
|
|||
<script>
|
||||
import ShopApi from "@/api/account/shop";
|
||||
|
||||
import commonApi from "@/api/account/common";
|
||||
import { ElMessage } from "element-plus";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -61,48 +63,48 @@ export default {
|
|||
async getinfo() {
|
||||
const res = await ShopApi.get();
|
||||
this.form = res;
|
||||
this.form.isReturn = this.form.isReturn == 1 ? true : false;
|
||||
this.form.isMemberIn = this.form.isMemberIn == 1 ? true : false;
|
||||
this.form.isMemberReturn = this.form.isMemberReturn == 1 ? true : false;
|
||||
this.form.isReturnPwd = this.form.isReturnPwd == 1 ? true : false;
|
||||
this.form.isMemberInPwd = this.form.isMemberInPwd == 1 ? true : false;
|
||||
this.form.isMemberReturnPwd = this.form.isMemberReturnPwd == 1 ? true : false;
|
||||
},
|
||||
async submitHandle() {
|
||||
if (!this.form.prepareAmount) {
|
||||
this.$message({
|
||||
ElMessage({
|
||||
message: "请输入验证码",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.form.password) {
|
||||
this.$message({
|
||||
ElMessage({
|
||||
message: "请输入密码",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const res = await modfiyUserInfo({
|
||||
const res = await ShopApi.edit({
|
||||
id: this.form.id,
|
||||
code: this.form.prepareAmount,
|
||||
pwd: md5(this.form.password),
|
||||
operationPwd: this.form.password,
|
||||
});
|
||||
console.log(222);
|
||||
|
||||
this.form.prepareAmount = "";
|
||||
this.form.password = "******";
|
||||
this.disabled = true;
|
||||
this.$message({
|
||||
ElMessage({
|
||||
message: "修改成功",
|
||||
type: "success",
|
||||
});
|
||||
},
|
||||
async submitHandles() {
|
||||
const res = await tbShopInfoPUT({
|
||||
const res = await ShopApi.edit({
|
||||
// code: this.form.prepareAmount,
|
||||
// id: this.form.id,
|
||||
// status:this.form.status,
|
||||
...this.form,
|
||||
isReturn: this.form.isReturn == true ? 1 : 0,
|
||||
isMemberIn: this.form.isMemberIn == true ? 1 : 0,
|
||||
isMemberReturn: this.form.isMemberReturn == true ? 1 : 0,
|
||||
isReturnPwd: this.form.isReturnPwd == true ? 1 : 0,
|
||||
isMemberInPwd: this.form.isMemberInPwd == true ? 1 : 0,
|
||||
isMemberReturnPwd: this.form.isMemberReturnPwd == true ? 1 : 0,
|
||||
});
|
||||
this.$message({
|
||||
ElMessage({
|
||||
message: "修改成功",
|
||||
type: "success",
|
||||
});
|
||||
|
|
@ -112,8 +114,8 @@ export default {
|
|||
this.disabled = false;
|
||||
},
|
||||
async onSubmit() {
|
||||
const res = await sendMsg();
|
||||
this.$message({
|
||||
const res = await commonApi.sms({ type: "editShopInfoOpePwd" });
|
||||
ElMessage({
|
||||
message: "发送成功",
|
||||
type: "success",
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@
|
|||
</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>
|
||||
<span class="tui" v-if="item.returnNum">
|
||||
退
|
||||
<span class="number">{{ item.returnNum * 1 }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex u-col-top">
|
||||
<div class="img">
|
||||
|
|
@ -350,7 +353,19 @@ onMounted(() => {
|
|||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.tui {
|
||||
.number {
|
||||
background: #f56c6c;
|
||||
color: #fff;
|
||||
position: absolute;
|
||||
left: -7px;
|
||||
top: -7px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
text-align: center;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
.da {
|
||||
background: #35ac6a;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,175 @@
|
|||
<template>
|
||||
<el-dialog title="选择挂账人" width="850px" v-model="show" top="20px">
|
||||
<div class="app-container">
|
||||
<div class="head-container filtration">
|
||||
<div class="r">
|
||||
<el-input
|
||||
v-model="tableData.keywords"
|
||||
placeholder="按挂账人或手机号"
|
||||
style="width: 138px"
|
||||
/>
|
||||
<!-- <el-select
|
||||
v-model="tableData.status"
|
||||
placeholder="全部状态"
|
||||
clearable
|
||||
style="width: 123px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select> -->
|
||||
<el-button type="primary" @click="getTableData()">查询</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="head-container content">
|
||||
<el-table v-loading="tableData.loading" :data="tableData.data" @cell-click="cellClick">
|
||||
<el-table-column label="ID" prop="id" />
|
||||
|
||||
<el-table-column label="挂账人" prop="debtor" />
|
||||
<el-table-column label="手机号" prop="mobile" />
|
||||
<el-table-column label="已挂账金额(元)" prop="owedAmount" />
|
||||
<el-table-column label="可用挂账额度(元)" prop="remainingAmount" />
|
||||
<el-table-column label="操作">
|
||||
<template v-slot="scope">
|
||||
<el-button type="text" @click="cellClick(scope.row)">选择</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="head-container">
|
||||
<el-pagination
|
||||
:total="tableData.total"
|
||||
:current-page="tableData.page"
|
||||
:page-size="tableData.size"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@current-change="paginationChange"
|
||||
@size-change="sizeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import creditApi from "@/api/order/credit";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
options: [
|
||||
{
|
||||
value: "1",
|
||||
label: "启用",
|
||||
},
|
||||
{
|
||||
value: "0",
|
||||
label: "停用",
|
||||
},
|
||||
],
|
||||
tableData: {
|
||||
keywords: "",
|
||||
status: "1",
|
||||
data: [],
|
||||
page: 1,
|
||||
size: 10,
|
||||
loading: false,
|
||||
total: 0,
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
// this.getTableData();
|
||||
},
|
||||
methods: {
|
||||
cellClick(row) {
|
||||
this.$emit("confirm", row);
|
||||
this.show = false;
|
||||
},
|
||||
open() {
|
||||
this.getTableData();
|
||||
this.show = true;
|
||||
},
|
||||
/**
|
||||
* 获取挂账人列表
|
||||
*/
|
||||
async getTableData() {
|
||||
this.tableData.loading = true;
|
||||
try {
|
||||
const res = await creditApi.getList({
|
||||
page: this.tableData.page,
|
||||
size: this.tableData.size,
|
||||
keywords: this.tableData.keywords,
|
||||
status: this.tableData.status,
|
||||
shopId: localStorage.getItem("shopId"),
|
||||
});
|
||||
this.tableData.loading = false;
|
||||
this.tableData.data = res.records;
|
||||
this.tableData.total = res.totalRow * 1;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除挂账人
|
||||
* @param id
|
||||
*/
|
||||
async delTableHandle(id) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const res = await delCreditBuyer(id);
|
||||
this.getTableData();
|
||||
},
|
||||
|
||||
/**
|
||||
* 操作
|
||||
*/
|
||||
openDialog(row, type) {
|
||||
if (type === "add") {
|
||||
this.$refs.creditAdd.show();
|
||||
} else if (type === "edit") {
|
||||
this.$refs.creditAdd.show(row);
|
||||
} else if (type === "repayment" && row.repaymentMethod === "total") {
|
||||
this.$refs.creditRepayment.show(row);
|
||||
} else if (type === "rePaymentRecord") {
|
||||
this.$refs.creditRepaymentRecord.show(row);
|
||||
}
|
||||
},
|
||||
|
||||
// 重置查询
|
||||
resetHandle() {
|
||||
this.page = 1;
|
||||
this.getTableData();
|
||||
},
|
||||
// 分页大小改变
|
||||
sizeChange(e) {
|
||||
this.tableData.size = e;
|
||||
this.getTableData();
|
||||
},
|
||||
// 分页回调
|
||||
paginationChange(e) {
|
||||
this.tableData.page = e;
|
||||
this.getTableData();
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.title {
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
color: #333333;
|
||||
}
|
||||
.filtration {
|
||||
overflow: hidden;
|
||||
.l {
|
||||
float: left;
|
||||
}
|
||||
.r {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
<el-form-item>
|
||||
<div class="flex gap-20">
|
||||
<el-button type="primary" @click="getTableData" size="medium">搜索</el-button>
|
||||
<el-button @click="noChooseUser" size="medium">不选择用户</el-button>
|
||||
<el-button type="primary" @click="getTableData">搜索</el-button>
|
||||
<el-button @click="noChooseUser">不选择用户</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
<el-table-column label="操作" width="90" fixed="right">
|
||||
<template v-slot="scope">
|
||||
<el-button type="primary" size="mini" @click="choose(scope.row)">选择</el-button>
|
||||
<el-button type="primary" size="small" @click="choose(scope.row)">选择</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ const controls = ref([
|
|||
{ label: "整单等叫", key: "", disabled: false, per: "all-wating" },
|
||||
]);
|
||||
|
||||
const emits = defineEmits(["noteClick", "changePriceClick", "packClick"]);
|
||||
const emits = defineEmits(["noteClick", "changePriceClick", "packClick", "return"]);
|
||||
function controlsClick(item) {
|
||||
switch (item.key) {
|
||||
case "is_gift":
|
||||
|
|
@ -99,7 +99,12 @@ const canEdit = computed(() => {
|
|||
});
|
||||
|
||||
function btnDisabled(item) {
|
||||
return !perList.value.includes(item.per);
|
||||
const canClick = perList.value.includes(item.per);
|
||||
if (item.key == "return") {
|
||||
return !canClick || carts.selCart.returnNum >= carts.selCart.number;
|
||||
} else {
|
||||
return !canClick;
|
||||
}
|
||||
}
|
||||
function returnLabel(item) {
|
||||
if (item.key == "is_gift") {
|
||||
|
|
|
|||
|
|
@ -32,17 +32,37 @@
|
|||
<div class="u-flex u-col-center u-m-t-10">
|
||||
<span class="u-font-14 font-bold u-m-r-20">积分抵扣</span>
|
||||
<el-radio-group v-model="score.sel" size="small" class="">
|
||||
<el-radio :value="0">
|
||||
<el-radio :value="-1">
|
||||
<span class="u-font-14">不使用</span>
|
||||
</el-radio>
|
||||
<el-radio :value="0" :disabled="!pointsRes.usable">
|
||||
<span class="u-font-14">全部抵扣</span>
|
||||
</el-radio>
|
||||
<el-radio :value="1">
|
||||
<el-radio :value="1" :disabled="!pointsRes.usable">
|
||||
<span class="u-font-14">部分抵扣</span>
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
<el-input-number
|
||||
class="u-m-l-10"
|
||||
v-if="score.sel == 1"
|
||||
v-model="usePointsNumber"
|
||||
step-strictly
|
||||
placeholder="请输入积分抵扣数量"
|
||||
:min="pointsRes.minDeductionPoints"
|
||||
:max="pointsRes.maxUsablePoints"
|
||||
@change="pointsToMoney"
|
||||
></el-input-number>
|
||||
</div>
|
||||
<p class="u-font-14 color-666 u-m-t-10">
|
||||
<p
|
||||
class="u-font-14 color-666 u-m-t-10"
|
||||
v-if="pointsRes.unusableReason && !pointsRes.usable"
|
||||
>
|
||||
<span class="color-red">*</span>
|
||||
<span>积分不足或小于最低使用门槛1</span>
|
||||
<span>{{ pointsRes.unusableReason }}</span>
|
||||
</p>
|
||||
<p class="u-font-14 color-666 u-m-t-10" v-else>
|
||||
<span class="color-red">*</span>
|
||||
<span>{{ pointsRes.equivalentPoints }}积分等于1元</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="u-flex u-col-center u-m-t-20 no-wrap">
|
||||
|
|
@ -60,11 +80,58 @@
|
|||
<el-icon><ArrowDown /></el-icon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-m-t-20" v-if="quansSelArr.length > 0">
|
||||
<div class="font-bold u-m-b-10">已选优惠券</div>
|
||||
<el-table empty-text="未选择优惠券" :data="quansSelArr">
|
||||
<el-table-column type="index" width="50" label="#"></el-table-column>
|
||||
<el-table-column prop="name" label="券名称"></el-table-column>
|
||||
<el-table-column label="券类型" width="80">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品信息" width="120">
|
||||
<template v-slot="scope">
|
||||
<div class="u-flex" v-if="scope.row.type == 2">
|
||||
<div class="u-flex">
|
||||
<el-image
|
||||
:src="scope.row.productImg"
|
||||
fit="cover"
|
||||
style="width: 40px; height: 40px"
|
||||
:preview-src-list="[scope.row.productImg]"
|
||||
></el-image>
|
||||
</div>
|
||||
<div class="u-p-l-10">
|
||||
<div class="">{{ scope.row.productName }}</div>
|
||||
<div class="">x{{ scope.row.num || "" }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="discountAmount" label="抵扣">
|
||||
<template v-slot="scope">
|
||||
<span class="color-red" v-if="scope.row.type == 1">
|
||||
¥{{ scope.row.discountAmount }}
|
||||
</span>
|
||||
<span class="color-red" v-if="scope.row.type == 2">
|
||||
¥{{ returnProDiscount(scope.row, scope.row.index) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="useRestrictions" label="">
|
||||
<template v-slot="scope">
|
||||
<el-button type="danger" size="small" @click="delQuan(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="u-m-t-30">
|
||||
<el-button size="large" @click="discountShow">整单打折/减免</el-button>
|
||||
<el-button size="large" @click="discountShow">
|
||||
{{ checkOrderPay.discount ? checkOrderPay.discount / 10 + "折" : "整单打折/减免" }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="u-m-t-30">
|
||||
<p class="u-font-16 font-bold u-m-r-20 font-bold u-flex">选择支付方式</p>
|
||||
|
|
@ -87,6 +154,10 @@
|
|||
</div>
|
||||
<div class="right">
|
||||
<h3>账单明细</h3>
|
||||
<p class="u-font-12 u-m-b-20">
|
||||
<span class="color-red">*</span>
|
||||
<span class="color-red">餐位费和打包费不参与折扣和满减</span>
|
||||
</p>
|
||||
<div class="order-info">
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">订单号:</span>
|
||||
|
|
@ -94,54 +165,69 @@
|
|||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">餐位费</span>
|
||||
<span class="u-m-l-10 value">¥{{ orderInfo.seatAmount }}</span>
|
||||
<span class="u-m-l-10 value">¥{{ seatAmount }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">打包费</span>
|
||||
<span class="u-m-l-10 value">¥{{ orderInfo.packFee }}</span>
|
||||
<span class="u-m-l-10 value">¥{{ carts.packFee }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">总价</span>
|
||||
<span class="u-m-l-10 value">¥{{ carts.payMoney }}</span>
|
||||
<span class="title">商品订单金额</span>
|
||||
<span class="u-m-l-10 value">¥{{ carts.goodsTotal }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">优惠券</span>
|
||||
<span class="u-m-l-10 value">¥{{ coupDiscount }}</span>
|
||||
<span class="title">商品优惠券</span>
|
||||
<span class="u-m-l-10 value">¥{{ productCouponDiscountAmount }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">满减优惠券</span>
|
||||
<span class="u-m-l-10 value">¥{{ fullCouponDiscountAmount }}</span>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">整单改价</span>
|
||||
<span class="u-m-l-10 value">-¥{{ discountAmount }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">积分抵扣</span>
|
||||
<span class="u-m-l-10 value">-¥{{ orderInfo.pointsDiscountAmount || 0 }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">整单改价</span>
|
||||
<span class="u-m-l-10 value">-¥{{ checkOrderPay.discountAmount || 0 }}</span>
|
||||
<span class="u-m-l-10 value">-¥{{ pointsDiscountAmount }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">抹零</span>
|
||||
<span class="u-m-l-10 value">-¥{{ orderInfo.pointsDiscountAmount || 0 }}</span>
|
||||
<span class="u-m-l-10 value">-¥{{ 0 }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">应付金额</span>
|
||||
<span class="title">总价(商品订单金额-商品优惠券-满减券-整单改价-积分抵扣)</span>
|
||||
<span class="u-m-l-10 value color-red">¥{{ totalMoney }}</span>
|
||||
</div>
|
||||
<div class="u-flex u-m-b-10 u-row-between">
|
||||
<span class="title">应付金额(总价+客座费+打包费)</span>
|
||||
<span class="u-m-l-10 value price">¥{{ currentpayMoney }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 扫码 -->
|
||||
<scanPay
|
||||
ref="refScanPay"
|
||||
:order="orderInfo"
|
||||
@paySuccess="paySuccess"
|
||||
@confirm="refScanPayConfirm"
|
||||
></scanPay>
|
||||
<scanPay ref="refScanPay" :order="orderInfo" @confirm="refScanPayConfirm"></scanPay>
|
||||
<!-- 打折 -->
|
||||
<discount ref="refDiscount" @confirm="discountConfirm"></discount>
|
||||
<!-- 优惠券 -->
|
||||
<popup-coupon ref="refCoupon" @confirm="refCouponConfirm"></popup-coupon>
|
||||
<popup-coupon ref="refCoupon" :user="user" @confirm="refCouponConfirm"></popup-coupon>
|
||||
<!-- 挂账 -->
|
||||
<chooseGuaZahng
|
||||
ref="refGuaZhang"
|
||||
:payMoney="currentpayMoney"
|
||||
@confirm="refGuaZhangConfirm"
|
||||
></chooseGuaZahng>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import * as quanUtil from "../quan_util.js";
|
||||
|
||||
import { useCartsStore } from "@/store/modules/carts";
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
import chooseGuaZahng from "./popup-choose-guazhang.vue";
|
||||
const shopUser = useUserStore();
|
||||
const carts = useCartsStore();
|
||||
|
||||
import popupCoupon from "./popup-coupon.vue";
|
||||
|
|
@ -154,10 +240,56 @@ import discount from "./discount.vue";
|
|||
import { ElLoading } from "element-plus";
|
||||
import { ElMessage, ElMessageBox } from "element-plus";
|
||||
|
||||
//挂账
|
||||
const refGuaZhang = ref();
|
||||
function refGuaZhangConfirm(guazhangRen) {
|
||||
payOrder("arrears", true, guazhangRen);
|
||||
}
|
||||
function refGuaZhangShow() {
|
||||
refGuaZhang.value.open();
|
||||
}
|
||||
//商品列表
|
||||
let goodsArr = [];
|
||||
|
||||
//优惠券
|
||||
let $goodsPayPriceMap = {};
|
||||
const refCoupon = ref();
|
||||
let quansSelArr = ref([]);
|
||||
function openCoupon() {
|
||||
refCoupon.value.open();
|
||||
refCoupon.value.open(carts.goodsTotal, props.orderInfo);
|
||||
}
|
||||
//返回商品券抵扣金额
|
||||
function returnProDiscount(row) {
|
||||
//相同商品抵扣券数组
|
||||
const arr = quansSelArr.value.filter((v) => v.type == 2 && v.proId == row.proId);
|
||||
console.log(arr);
|
||||
const index = arr.findIndex((v) => v.id == row.id);
|
||||
const item = goodsArr.find((v) => v.productId == row.proId);
|
||||
if (index != -1) {
|
||||
const n = quanUtil.returnProductCoupAllPrice(
|
||||
$goodsPayPriceMap[row.proId],
|
||||
index,
|
||||
row.num,
|
||||
props.user.id && props.user.isVip
|
||||
);
|
||||
return n.toFixed(2);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
function refCouponConfirm(e, goodsPayPriceMap, goodsList) {
|
||||
goodsArr = goodsList;
|
||||
usePointsNumber.value = 0;
|
||||
pointsDiscountAmount.value = 0;
|
||||
score.sel = -1;
|
||||
quansSelArr.value = e;
|
||||
$goodsPayPriceMap = goodsPayPriceMap;
|
||||
}
|
||||
function delQuan(row) {
|
||||
const index = quansSelArr.value.findIndex((v) => v.id == row.id);
|
||||
if (index != -1) {
|
||||
quansSelArr.value.splice(index, 1);
|
||||
}
|
||||
}
|
||||
function couponChange(data) {}
|
||||
|
||||
|
|
@ -171,15 +303,14 @@ function discountConfirm(e) {
|
|||
console.log(e);
|
||||
Object.assign(checkOrderPay, e);
|
||||
if (e.discount) {
|
||||
checkOrderPay.discountAmount =
|
||||
carts.payMoney - (carts.payMoney * (e.discount / 100).toFixed(2)).toFixed(2);
|
||||
checkOrderPay.discountAmount = carts.goodsTotal - (carts.goodsTotal * (100 - e.discount)) / 100;
|
||||
} else {
|
||||
checkOrderPay.discount = 0;
|
||||
}
|
||||
}
|
||||
function discountShow(e) {
|
||||
refDiscount.value.open({
|
||||
amount: carts.payMoney,
|
||||
amount: carts.goodsTotal - productCouponDiscountAmount.value,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -194,12 +325,24 @@ const props = defineProps({
|
|||
return { id: "" };
|
||||
},
|
||||
},
|
||||
perpole: {
|
||||
type: [Number, String],
|
||||
default: 0,
|
||||
},
|
||||
orderInfo: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
});
|
||||
|
||||
const seatAmount = computed(() => {
|
||||
if (shopUser.userInfo.isTableFee) {
|
||||
return "0.00";
|
||||
}
|
||||
if (props.perpole >= 1) {
|
||||
return (props.perpole * shopUser.userInfo.tableFee).toFixed(2);
|
||||
}
|
||||
return "0.00";
|
||||
});
|
||||
watch(
|
||||
() => props.user.id,
|
||||
(newval) => {
|
||||
|
|
@ -218,16 +361,45 @@ watch(
|
|||
);
|
||||
|
||||
//002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||
function pointsInit() {
|
||||
if (!props.user.id) {
|
||||
const pointsRes = ref({ usable: true, maxUsablePoints: 0, minDeductionPoints: 0 });
|
||||
const usePointsNumber = ref(0);
|
||||
const orderAmountOrderAmount = computed(() => {
|
||||
return (carts.goodsTotal - checkOrderPay.discountAmount).toFixed(2);
|
||||
});
|
||||
const pointsDiscountAmount = ref(0);
|
||||
watch(
|
||||
() => orderAmountOrderAmount.value,
|
||||
(newval) => {
|
||||
pointsInit();
|
||||
}
|
||||
);
|
||||
|
||||
async function pointsInit() {
|
||||
if (!props.user.id || score.sel == -1) {
|
||||
return;
|
||||
}
|
||||
PointsApi.calcOrderUsablePoints({
|
||||
const res = await PointsApi.calcOrderUsablePoints({
|
||||
userId: props.user.id,
|
||||
orderAmount: (carts.payMoney - checkOrderPay.discountAmount).toFixed(2),
|
||||
orderAmount: currentpayMoney.value - pointsDiscountAmount.value,
|
||||
});
|
||||
pointsRes.value = res;
|
||||
usePointsNumber.value = res.usable ? res.maxUsablePoints : 0;
|
||||
if (res.usable) {
|
||||
pointsToMoney();
|
||||
} else {
|
||||
score.sel = -1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// 根据积分计算可抵扣金额
|
||||
async function pointsToMoney() {
|
||||
const res = await PointsApi.calcPointsToMoney({
|
||||
userId: props.user.id,
|
||||
orderAmount: currentpayMoney.value - pointsDiscountAmount.value,
|
||||
points: usePointsNumber.value,
|
||||
});
|
||||
pointsDiscountAmount.value = res;
|
||||
}
|
||||
|
||||
const emits = defineEmits(["chooseUser", "paysuccess"]);
|
||||
function chooseUser() {
|
||||
emits("chooseUser");
|
||||
|
|
@ -240,15 +412,27 @@ const coupDiscount = computed(() => {
|
|||
}
|
||||
return total.toFixed(2);
|
||||
});
|
||||
const score = ref({
|
||||
const score = reactive({
|
||||
list: [],
|
||||
sel: 0,
|
||||
sel: -1,
|
||||
});
|
||||
|
||||
const payTypes = reactive({
|
||||
list: [],
|
||||
sel: 0,
|
||||
});
|
||||
watch(
|
||||
() => score.sel,
|
||||
(newval) => {
|
||||
console.log(newval);
|
||||
if (newval == -1) {
|
||||
usePointsNumber.value = 0;
|
||||
pointsDiscountAmount.value = 0;
|
||||
} else {
|
||||
pointsInit();
|
||||
}
|
||||
}
|
||||
);
|
||||
function canUsePayType(item) {
|
||||
if (currentpayMoney.value * 1 == 0) {
|
||||
return item.payType == "cash" ? false : true;
|
||||
|
|
@ -279,15 +463,17 @@ function returnPayParams() {
|
|||
orderId: props.orderInfo.id,
|
||||
// discountRatio: (checkOrderPay.discount / 100).toFixed(2),
|
||||
discountRatio: 0,
|
||||
seatNum: props.orderInfo.seatNum,
|
||||
originAmount: carts.payMoney * 1,
|
||||
discountAmount: checkOrderPay.discountAmount * 1,
|
||||
productCouponDiscountAmount: props.orderInfo.productCouponDiscountAmount || 0,
|
||||
seatNum: props.perpole * 1,
|
||||
originAmount: carts.payMoney * 1 - productCouponDiscountAmount.value + seatAmount.value * 1,
|
||||
discountAmount: discountAmount.value,
|
||||
productCouponDiscountAmount: productCouponDiscountAmount.value * 1,
|
||||
orderAmount: currentpayMoney.value * 1,
|
||||
roundAmount: props.orderInfo.roundAmount,
|
||||
pointsDiscountAmount: props.orderInfo.pointsDiscountAmount || 0,
|
||||
pointsNum: props.orderInfo.pointsNum,
|
||||
fullCouponDiscountAmount: props.orderInfo.fullCouponDiscountAmount || 0,
|
||||
pointsDiscountAmount: pointsDiscountAmount.value * 1,
|
||||
pointsNum: usePointsNumber.value * 1,
|
||||
fullCouponDiscountAmount: fullCouponDiscountAmount.value * 1,
|
||||
couponList: quansSelArr.value.map((v) => v.id),
|
||||
userId: props.user.userId || "",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
@ -303,11 +489,18 @@ function refScanPayOpen(payType) {
|
|||
if (payType == "scanCode") {
|
||||
return refScanPay.value.open(returnPayParams(), "scanCode");
|
||||
}
|
||||
if (payType == "arrears") {
|
||||
refGuaZhangShow();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function getPaytype() {
|
||||
const res = await payTypeApi.getList();
|
||||
payTypes.list = res;
|
||||
if (currentpayMoney.value * 1 <= 0) {
|
||||
payTypes.sel = payTypes.list.findIndex((v) => v.payType == "cash");
|
||||
}
|
||||
}
|
||||
function nowPayClick(payType) {
|
||||
payType = payType || payTypes.list[payTypes.sel].payType;
|
||||
|
|
@ -330,6 +523,7 @@ function nowPayClick(payType) {
|
|||
payOrder(payType);
|
||||
return;
|
||||
}
|
||||
|
||||
refScanPayOpen(payType);
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +536,7 @@ function refScanPayConfirm($authCode, isScan) {
|
|||
|
||||
let payTimer = null;
|
||||
//是否是正扫
|
||||
async function payOrder(payType, isScan) {
|
||||
async function payOrder(payType, isScan, guazhangren) {
|
||||
clearTimeout(payTimer);
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
|
|
@ -374,6 +568,9 @@ async function payOrder(payType, isScan) {
|
|||
shopUserId: props.user.id,
|
||||
});
|
||||
}
|
||||
if (payType == "arrears") {
|
||||
res = await payApi.creditPay({ ...returnPayParams(), creditBuyerId: guazhangren.id });
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
clearTimeout(payTimer);
|
||||
|
|
@ -387,13 +584,43 @@ async function payOrder(payType, isScan) {
|
|||
loading.close();
|
||||
}
|
||||
}
|
||||
|
||||
//整单改价
|
||||
const discountAmount = computed(() => {
|
||||
const money = carts.goodsTotal - productCouponDiscountAmount.value;
|
||||
if (checkOrderPay.discount) {
|
||||
return ((money * (100 - checkOrderPay.discount)) / 100).toFixed(2);
|
||||
}
|
||||
return checkOrderPay.discountAmount;
|
||||
});
|
||||
//满减优惠券
|
||||
const fullCouponDiscountAmount = computed(() => {
|
||||
return quansSelArr.value
|
||||
.reduce((pre, cur) => {
|
||||
return pre + cur.discountAmount;
|
||||
}, 0)
|
||||
.toFixed(2);
|
||||
});
|
||||
//商品券抵扣金额
|
||||
const productCouponDiscountAmount = computed(() => {
|
||||
let index = -1;
|
||||
return quansSelArr.value.reduce((pre, cur) => {
|
||||
index++;
|
||||
return pre + returnProDiscount(cur, index) * 1;
|
||||
}, 0);
|
||||
});
|
||||
//除开客座费,打包费总金额
|
||||
const totalMoney = computed(() => {
|
||||
return (
|
||||
carts.goodsTotal -
|
||||
productCouponDiscountAmount.value -
|
||||
discountAmount.value -
|
||||
fullCouponDiscountAmount.value -
|
||||
pointsDiscountAmount.value
|
||||
).toFixed(2);
|
||||
});
|
||||
//应付金额
|
||||
const currentpayMoney = computed(() => {
|
||||
if (checkOrderPay.discount) {
|
||||
return (carts.payMoney * (checkOrderPay.discount / 100)).toFixed(2);
|
||||
}
|
||||
return (carts.payMoney - checkOrderPay.discountAmount).toFixed(2);
|
||||
return (totalMoney.value * 1 + carts.packFee * 1 + seatAmount.value * 1).toFixed(2);
|
||||
});
|
||||
watch(
|
||||
() => currentpayMoney.value,
|
||||
|
|
@ -405,7 +632,6 @@ watch(
|
|||
);
|
||||
onMounted(() => {
|
||||
getPaytype();
|
||||
pointsInit();
|
||||
});
|
||||
defineExpose({
|
||||
nowPayClick,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,353 @@
|
|||
<template>
|
||||
<div class="select_desk">
|
||||
<el-dialog width="410px" title="挂账" v-model="show" @close="reset">
|
||||
<div class="guazhangren u-flex u-row-between" @click="guazhangShow">
|
||||
<template v-if="guazhangRen">
|
||||
<div>
|
||||
<div class="name">{{ guazhangRen.debtor }}/{{ guazhangRen.position }}</div>
|
||||
<div class="u-m-t-6">手机号:{{ guazhangRen.mobile }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="">可用额度</div>
|
||||
<div class="u-m-t-6">{{ guazhangRen.remainingAmount }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="color-999">选择挂账人/单位</div>
|
||||
<span class="el-icon-caret-bottom"></span>
|
||||
</template>
|
||||
</div>
|
||||
<div class="select_desk_dialog u-p-b-20">
|
||||
<div class="u-p-l-20 u-p-r-20 u-flex w-full u-relative box_status">
|
||||
<div class="font-bold u-font-32">¥</div>
|
||||
<el-input
|
||||
placeholder="请输入挂账金额"
|
||||
v-model="number"
|
||||
@input="inputNumber"
|
||||
@change="inputChange"
|
||||
@focus="inputFocus"
|
||||
@blur="inputBlur"
|
||||
:type="focus ? 'number' : 'text'"
|
||||
></el-input>
|
||||
<div class="zhezhao"></div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="confirm_btns">
|
||||
<el-button size="large" @click="close">取消</el-button>
|
||||
<el-button type="primary" size="large" @click="confirm">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<choose-guazhang ref="refChooseGuazhang" @confirm="chooseGuazhangConfirm"></choose-guazhang>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ElMessage } from "element-plus";
|
||||
import keyBoard from "./keyboard.vue";
|
||||
import chooseGuazhang from "./choose-guazhang.vue";
|
||||
export default {
|
||||
components: { keyBoard, chooseGuazhang },
|
||||
props: {
|
||||
payMoney: {
|
||||
type: [Number, String],
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
guazhangRen: "",
|
||||
number: "",
|
||||
show: false,
|
||||
hasOpen: false,
|
||||
loading: false,
|
||||
tips: "",
|
||||
focus: false,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
number(newval) {
|
||||
console.log(newval);
|
||||
if (newval * 1 > this.payMoney * 1) {
|
||||
this.number = this.payMoney;
|
||||
this.number = newval;
|
||||
}
|
||||
if (newval * 1 > this.payMoney * 1) {
|
||||
this.tips = "已超出未结账金额";
|
||||
} else {
|
||||
const shengyu = this.payMoney - this.number;
|
||||
|
||||
this.tips = shengyu > 0 ? "还需额外支付" + shengyu.toFixed(2) + "元" : "";
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
inputFocus() {
|
||||
this.focus = true;
|
||||
},
|
||||
inputBlur() {
|
||||
this.focus = false;
|
||||
},
|
||||
chooseGuazhangConfirm(e) {
|
||||
this.guazhangRen = e;
|
||||
},
|
||||
guazhangShow() {
|
||||
this.$refs.refChooseGuazhang.open();
|
||||
},
|
||||
|
||||
inputNumber(e) {
|
||||
console.log("inputNumber");
|
||||
if (e * 1 > this.payMoney * 1) {
|
||||
this.tips = "已超出未结账金额";
|
||||
}
|
||||
},
|
||||
inputChange(e) {
|
||||
if (e * 1 > this.payMoney * 1) {
|
||||
this.tips = "已超出未结账金额";
|
||||
}
|
||||
console.log(e);
|
||||
},
|
||||
clear(e) {
|
||||
console.log(e);
|
||||
this.number = "";
|
||||
},
|
||||
confirm() {
|
||||
if (this.number * 1 > this.payMoney * 1) {
|
||||
return ElMessage("已超出未结账金额");
|
||||
}
|
||||
if (this.number * 1 <= 0) {
|
||||
return ElMessage("支付金额不正确");
|
||||
}
|
||||
if (!this.guazhangRen) {
|
||||
return ElMessage("请选择挂账人");
|
||||
}
|
||||
this.$emit("confirm", this.guazhangRen, this.number);
|
||||
this.close();
|
||||
},
|
||||
open() {
|
||||
console.log(this.payMoney);
|
||||
this.number = this.payMoney * 1;
|
||||
this.show = true;
|
||||
this.tips = "还需额外支付" + this.payMoney + "元";
|
||||
},
|
||||
reset() {
|
||||
this.number = "";
|
||||
this.guazhangRen = "";
|
||||
},
|
||||
close() {
|
||||
this.show = false;
|
||||
this.number = "";
|
||||
},
|
||||
},
|
||||
mounted() {},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-button) {
|
||||
padding: 12px 20px;
|
||||
}
|
||||
.box_status {
|
||||
margin-bottom: 0;
|
||||
margin-top: 30px;
|
||||
width: 370px;
|
||||
height: 58px;
|
||||
background: #fff;
|
||||
border: 1px solid #dcdfe6;
|
||||
}
|
||||
:deep(.el-input__wrapper) {
|
||||
box-shadow: none;
|
||||
}
|
||||
:deep(.select_desk_dialog .el-input__inner) {
|
||||
border: none;
|
||||
font-size: 32px;
|
||||
}
|
||||
:deep(.el-input__inner::-webkit-inner-spin-button) {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
:deep(.el-input__inner::-webkit-outer-spin-button) {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
:deep(.el-button--success) {
|
||||
border-color: #22bf64;
|
||||
background-color: #22bf64;
|
||||
}
|
||||
.select_desk .btn {
|
||||
height: 34px;
|
||||
}
|
||||
.tags {
|
||||
font-size: 16px;
|
||||
&.using {
|
||||
color: rgb(234, 64, 37);
|
||||
}
|
||||
&.wait {
|
||||
color: rgb(252, 236, 79);
|
||||
}
|
||||
&.idle {
|
||||
color: rgb(137, 234, 71);
|
||||
}
|
||||
&.closed {
|
||||
color: rgb(221, 221, 221);
|
||||
filter: grayscale(1);
|
||||
}
|
||||
}
|
||||
:deep(.inputs .el-input__inner) {
|
||||
border-color: transparent !important;
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
letter-spacing: 1.25px;
|
||||
font-size: 20px;
|
||||
}
|
||||
.select_desk .select_desk_dialog {
|
||||
display: flex;
|
||||
|
||||
flex-direction: column;
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .nav {
|
||||
width: 286px;
|
||||
height: 38px;
|
||||
background: #dcf0e8;
|
||||
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .nav .li,
|
||||
.select_desk .select_desk_dialog .nav {
|
||||
border-radius: 4px;
|
||||
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .nav .li {
|
||||
width: 140px;
|
||||
height: 34px;
|
||||
color: #0fc161;
|
||||
|
||||
justify-content: center;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .nav .lion {
|
||||
background: #0fc161;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .inputs {
|
||||
width: 370px;
|
||||
line-height: 54px;
|
||||
margin-top: 24px;
|
||||
height: 54px;
|
||||
margin-bottom: 20px;
|
||||
background: #fff;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
color: rgba(0, 0, 0, 0.8);
|
||||
letter-spacing: 1.25px;
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
position: relative;
|
||||
}
|
||||
.zhezhao {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
.select_desk .select_desk_dialog .inputs .close {
|
||||
color: #aaa;
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
height: 30px;
|
||||
width: 30px;
|
||||
line-height: 30px;
|
||||
top: 50%;
|
||||
margin-top: -15px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.guazhangren {
|
||||
padding: 12px 10px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
margin-top: 20px;
|
||||
min-height: 58px;
|
||||
color: #999;
|
||||
cursor: pointer;
|
||||
.name {
|
||||
color: #3f9eff;
|
||||
}
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .keyboard {
|
||||
display: flex;
|
||||
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
border-right: 1px solid #dcdfe6;
|
||||
border-bottom: 1px solid #dcdfe6;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .keyboard .li {
|
||||
height: 60px;
|
||||
width: 33.333%;
|
||||
|
||||
display: flex;
|
||||
|
||||
justify-content: center;
|
||||
|
||||
align-items: center;
|
||||
font-size: 24px;
|
||||
color: #212121;
|
||||
cursor: pointer;
|
||||
|
||||
user-select: none;
|
||||
border-left: 1px solid #dcdfe6;
|
||||
border-top: 1px solid #dcdfe6;
|
||||
|
||||
transition: all 0.1s;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .keyboard .li:hover {
|
||||
background: #dcdfe6;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .keyboard .li .icon {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .keyboard .confirm {
|
||||
height: 140px;
|
||||
background: #ff9f2e;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.select_desk .select_desk_dialog .keyboard .confirm:hover {
|
||||
background: #f88502;
|
||||
}
|
||||
|
||||
.confirm_btns {
|
||||
display: flex;
|
||||
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.confirm_btns .el-button {
|
||||
width: 175px;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -14,23 +14,23 @@
|
|||
<template v-slot="scope">
|
||||
<el-checkbox
|
||||
@change="fullReductionCouponClick(scope.row)"
|
||||
:value="scope.row.id == fullReductionCouponSel.id"
|
||||
:model-value="scope.row.id == fullReductionCouponSel.id"
|
||||
></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column type="index" label="#"></el-table-column>
|
||||
<el-table-column prop="name" label="券名称"></el-table-column>
|
||||
<el-table-column label="券类型" width="80">
|
||||
<!-- <el-table-column label="券类型" width="80">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
<el-table-column prop="discountAmount" label="抵扣">
|
||||
<template v-slot="scope">
|
||||
<span class="color-red">¥{{ scope.row.discountAmount }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="discountAmount" label="限制" width="120">
|
||||
<el-table-column prop="discountAmount" label="限制" width="180">
|
||||
<template v-slot="scope">
|
||||
<div class="u-flex">
|
||||
<span>支付满</span>
|
||||
|
|
@ -52,31 +52,31 @@
|
|||
:data="quans.productCoupon"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column>
|
||||
<el-table-column width="80">
|
||||
<template v-slot="scope">
|
||||
<el-checkbox
|
||||
@change="productCouponClick(scope.row)"
|
||||
:value="scope.row.checked"
|
||||
:model-value="scope.row.checked"
|
||||
></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column type="index" width="50" label="#"></el-table-column>
|
||||
<el-table-column prop="name" label="券名称"></el-table-column>
|
||||
|
||||
<el-table-column label="商品信息" width="120">
|
||||
<el-table-column label="商品信息" width="220">
|
||||
<template v-slot="scope">
|
||||
<div class="u-flex">
|
||||
<div class="u-flex">
|
||||
<el-image
|
||||
:src="scope.row.productCover"
|
||||
:src="scope.row.productImg"
|
||||
fit="cover"
|
||||
style="width: 40px; height: 40px"
|
||||
:preview-src-list="[scope.row.productCover]"
|
||||
:preview-src-list="[scope.row.productImg]"
|
||||
></el-image>
|
||||
</div>
|
||||
<div class="u-p-l-10">
|
||||
<div class="">{{ scope.row.productName }}</div>
|
||||
<div class="">x{{ scope.row.num || "" }}</div>
|
||||
<div class="">x{{ scope.row.num || 1 }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -88,11 +88,11 @@
|
|||
</span>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
<el-table-column label="券类型">
|
||||
<!-- <el-table-column label="券类型">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.type == 1 ? "优惠券" : "商品券" }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
<el-table-column prop="useRestrictions" label="描述"></el-table-column>
|
||||
<!-- <el-table-column prop="useRestrictions" label="是否可用">
|
||||
<template v-slot="scope">
|
||||
|
|
@ -117,15 +117,15 @@
|
|||
<div class="u-flex" v-if="scope.row.type == 2">
|
||||
<div class="u-flex">
|
||||
<el-image
|
||||
:src="scope.row.productCover"
|
||||
:src="scope.row.productImg"
|
||||
fit="cover"
|
||||
style="width: 40px; height: 40px"
|
||||
:preview-src-list="[scope.row.productCover]"
|
||||
:preview-src-list="[scope.row.productImg]"
|
||||
></el-image>
|
||||
</div>
|
||||
<div class="u-p-l-10">
|
||||
<div class="">{{ scope.row.productName }}</div>
|
||||
<div class="">x{{ scope.row.num || "" }}</div>
|
||||
<div class="">x{{ scope.row.num || 1 }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -143,7 +143,7 @@
|
|||
<el-table-column prop="useRestrictions" label="描述"></el-table-column>
|
||||
<el-table-column prop="useRestrictions" label="">
|
||||
<template v-slot="scope">
|
||||
<el-button type="danger" size="mini" @click="delQuan(scope.row)">删除</el-button>
|
||||
<el-button type="danger" size="small" @click="delQuan(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
@ -166,14 +166,17 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="u-flex u-row-center u-m-t-50">
|
||||
<el-button size="medium" @click="close">取消</el-button>
|
||||
<el-button size="medium" type="primary" @click="confirm">确定</el-button>
|
||||
<el-button size="large" @click="close">取消</el-button>
|
||||
<el-button size="large" type="primary" @click="confirm">确定</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup>
|
||||
import couponApi from "@/api/account/coupon";
|
||||
import { ElMessageBox } from "element-plus";
|
||||
import * as quanUtil from "../quan_util.js";
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
|
|
@ -183,7 +186,7 @@ const props = defineProps({
|
|||
type: Array,
|
||||
default: [],
|
||||
},
|
||||
vipUser: {
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
|
|
@ -196,7 +199,6 @@ function tabClick() {}
|
|||
|
||||
const state = reactive({
|
||||
discount: 1,
|
||||
orderPrice: 0,
|
||||
fullReductionCouponSel: {
|
||||
id: "",
|
||||
},
|
||||
|
|
@ -216,36 +218,210 @@ const state = reactive({
|
|||
|
||||
const {
|
||||
discount,
|
||||
orderPrice,
|
||||
fullReductionCouponSel,
|
||||
quansSelArr,
|
||||
quans,
|
||||
currentRow,
|
||||
multipleSelection,
|
||||
fullReductionCouponSelId,
|
||||
activeName,
|
||||
form,
|
||||
show,
|
||||
isSetProductCoup,
|
||||
} = toRefs(state);
|
||||
const AllCouponPrice = computed(() => {
|
||||
return 0;
|
||||
});
|
||||
const payPrice = computed(() => {
|
||||
return 0;
|
||||
});
|
||||
function open() {
|
||||
|
||||
let orderPrice = ref(0);
|
||||
let $originFullReductionCoupon = [];
|
||||
//可以抵扣的商品列表
|
||||
let canDikouGoodsArr = [];
|
||||
//商品数量从0到n每一个对应的价格
|
||||
let $goodsPayPriceMap = {};
|
||||
let goodsArr = [];
|
||||
|
||||
function open(money, orderInfo) {
|
||||
let arr = [];
|
||||
for (let i in orderInfo.detailMap) {
|
||||
arr.push(...orderInfo.detailMap[i]);
|
||||
}
|
||||
goodsArr = arr;
|
||||
$goodsPayPriceMap = quanUtil.returnGoodsPayPriceMap(goodsArr || []);
|
||||
canDikouGoodsArr = quanUtil.returnNewGoodsList(goodsArr);
|
||||
console.log(canDikouGoodsArr);
|
||||
getcoup();
|
||||
orderPrice.value = money;
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
async function getcoup() {
|
||||
const res = await couponApi.findCoupon({ shopUserId: props.user.id });
|
||||
quans.value.fullReductionCoupon = res.filter(
|
||||
(v) => v.type == 1 && orderPrice.value * 1 >= v.fullAmount * 1
|
||||
);
|
||||
quans.value.productCoupon = res
|
||||
.filter((v) => v.type == 2 && canDikouGoodsArr.find((goods) => v.proId == goods.productId))
|
||||
.map((v) => {
|
||||
const findGoods = goodsArr.find((goods) => goods.productId == v.proId);
|
||||
return {
|
||||
...v,
|
||||
productImg: findGoods ? findGoods.productImg : "",
|
||||
productName: findGoods ? findGoods.productName : "",
|
||||
};
|
||||
});
|
||||
}
|
||||
function fullReductionCouponClick(row) {
|
||||
if (row.id == fullReductionCouponSel.value.id) {
|
||||
fullReductionCouponSel.value = { id: "" };
|
||||
quansSelArr.value.splice(0, 1);
|
||||
return;
|
||||
}
|
||||
const dikouQuan = quansSelArr.value[0];
|
||||
fullReductionCouponSel.value = row;
|
||||
if (dikouQuan && dikouQuan.type == 1) {
|
||||
quansSelArr.value[0] = row;
|
||||
} else {
|
||||
quansSelArr.value.unshift(row);
|
||||
}
|
||||
if (!fullReductionCouponSel.value.id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const AllCouponPrice = computed(() => {
|
||||
return quanUtil.returnCouponAllPrice(quansSelArr.value, canDikouGoodsArr, props.user);
|
||||
});
|
||||
|
||||
const payPrice = computed(() => {
|
||||
return (orderPrice.value - AllCouponPrice.value).toFixed(2);
|
||||
});
|
||||
function productCouponClick(item) {
|
||||
if (!item.use) {
|
||||
return;
|
||||
}
|
||||
const hasSelNum = quansSelArr.value
|
||||
.filter((v) => v.type == 2 && v.proId == item.proId)
|
||||
.reduce((a, b) => {
|
||||
return a + (b.num || 1);
|
||||
}, 0);
|
||||
console.log($goodsPayPriceMap[item.proId]);
|
||||
const maxSelNum = $goodsPayPriceMap[item.proId].length;
|
||||
const coupMaxUseNum = Math.min(item.num || 1, maxSelNum - hasSelNum);
|
||||
const canUseNum = Math.min(maxSelNum, coupMaxUseNum);
|
||||
console.log("maxSelNum", maxSelNum);
|
||||
console.log("coupMaxUseNum", coupMaxUseNum);
|
||||
console.log("canUseNum", canUseNum);
|
||||
if (!item.checked && canUseNum <= 0) {
|
||||
return ElMessage.error("购物车该商品券可使用最大数量为" + maxSelNum);
|
||||
}
|
||||
|
||||
if (fullReductionCouponSel.value.id && !item.checked) {
|
||||
const goodsQuan = quans.value.productCoupon.filter((v) => v.checked);
|
||||
const fullReductionCoupon = fullReductionCouponSel.value.id
|
||||
? [fullReductionCouponSel.value]
|
||||
: [];
|
||||
|
||||
let coupArr = [...goodsQuan, { ...item, num: canUseNum }];
|
||||
const payPrice =
|
||||
orderPrice.value - quanUtil.returnCouponAllPrice(coupArr, canDikouGoodsArr, props.user);
|
||||
console.log(payPrice);
|
||||
if (payPrice <= 0) {
|
||||
return ElMessageBox.confirm(
|
||||
"选择该商品券后支付金额将为0,继续选择将取消选择的满减券",
|
||||
"提示",
|
||||
{
|
||||
confirmButtonText: "继续选择",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
fullReductionCouponSel.value = {
|
||||
id: "",
|
||||
};
|
||||
quansSelArr.value.splice(0, 1);
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
if (fullReductionCouponSel.value.fullAmount > payPrice) {
|
||||
ElMessageBox.confirm(
|
||||
"选择该商品券后将不满足选择抵扣券的最低满减需求,继续选择将取消选择的满减券",
|
||||
"提示",
|
||||
{
|
||||
confirmButtonText: "继续选择",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
fullReductionCouponSel.value = {
|
||||
id: "",
|
||||
};
|
||||
})
|
||||
.catch(() => {
|
||||
item.checked = false;
|
||||
const index = quansSelArr.value.findIndex((v) => v.id == item.id);
|
||||
quansSelArr.value.splice(index, 1);
|
||||
});
|
||||
}
|
||||
}
|
||||
item.checked = !item.checked;
|
||||
if (!item.checked) {
|
||||
const index = quansSelArr.value.findIndex((v) => v.id == item.id);
|
||||
quansSelArr.value.splice(index, 1);
|
||||
} else {
|
||||
quansSelArr.value.push({ ...item, num: canUseNum });
|
||||
}
|
||||
const CheckedArr = quans.value.productCoupon.filter((v) => v.checked);
|
||||
if (CheckedArr.length <= 0) {
|
||||
return quans.value.productCoupon.map((v) => {
|
||||
v.use = true;
|
||||
});
|
||||
}
|
||||
const noCheckedArr = quans.value.productCoupon.filter((v) => !v.checked);
|
||||
noCheckedArr.map((v) => {
|
||||
v.use = quanUtil.returnCoupCanUse(canDikouGoodsArr, v, CheckedArr);
|
||||
});
|
||||
}
|
||||
//返回商品券抵扣金额
|
||||
function returnProDiscount(row) {
|
||||
//相同商品抵扣券数组
|
||||
const arr = quansSelArr.value.filter((v) => v.type == 2 && v.proId == row.proId);
|
||||
const index = arr.findIndex((v) => v.id == row.id);
|
||||
const item = goodsArr.find((v) => v.productId == row.proId);
|
||||
if (index != -1) {
|
||||
const n = quanUtil.returnProductCoupAllPrice(
|
||||
$goodsPayPriceMap[row.proId],
|
||||
index,
|
||||
row.num,
|
||||
props.user.id && props.user.isVip
|
||||
);
|
||||
return n.toFixed(2);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//删除选中的优惠券
|
||||
function delQuan(row) {
|
||||
const index = quansSelArr.value.findIndex((item) => item.id == row.id);
|
||||
if (row.type == 2 && index != -1) {
|
||||
quansSelArr.value.splice(index, 1);
|
||||
const proIndex = quans.value.productCoupon.findIndex((v) => v.id == row.id);
|
||||
quans.value.productCoupon[proIndex].checked = false;
|
||||
}
|
||||
if (row.type == 1 && index != -1) {
|
||||
fullReductionCouponSel.value = { id: "" };
|
||||
quansSelArr.value.splice(0, 1);
|
||||
}
|
||||
}
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
const emits = defineEmits(["confirm"]);
|
||||
function confirm() {
|
||||
emits("confirm");
|
||||
function reset() {
|
||||
quansSelArr.value = [];
|
||||
fullReductionCouponSel.value = { id: "" };
|
||||
}
|
||||
function confirm() {
|
||||
emits("confirm", [...quansSelArr.value], $goodsPayPriceMap, goodsArr);
|
||||
close();
|
||||
}
|
||||
function reset() {}
|
||||
defineExpose({
|
||||
close,
|
||||
open,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,196 @@
|
|||
<template>
|
||||
<el-dialog title="退菜" width="410px" v-model="show" @close="reset" :modal="modal">
|
||||
<div class="u-p-b-16">
|
||||
<div class="flex u-row-between">
|
||||
<span>菜品名称</span>
|
||||
<div class="u-flex">
|
||||
{{ goods.name || "" }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-font-12 color-999 u-m-t-8" v-if="isSeatFee">
|
||||
<div>
|
||||
<span class="color-red">*</span>
|
||||
<span>客座费只能全退</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-p-b-16 border-bottom">
|
||||
<div class="flex u-row-between">
|
||||
<span>退菜数量</span>
|
||||
<div class="u-flex" v-if="!isSeatFee">
|
||||
<el-input-number v-model="number" :min="1" step-strictly :max="max"></el-input-number>
|
||||
</div>
|
||||
<div class="u-flex" v-else>
|
||||
{{ number }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-font-12 color-999 u-m-t-8" v-if="isSeatFee">
|
||||
<div>
|
||||
<span class="color-red">*</span>
|
||||
<span>客座费只能全退</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="u-m-t-10 u-font-12 color-999">菜品已点数量 {{ max }} 份</div>
|
||||
<div class="u-m-t-26">
|
||||
<div>
|
||||
<span>退菜原因</span>
|
||||
<span class="color-red">*</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-flex-wrap tags">
|
||||
<div
|
||||
class="tag"
|
||||
v-for="(tag, index) in tags"
|
||||
@click="changeSel(tag)"
|
||||
:key="index"
|
||||
:class="{ active: tag.checked }"
|
||||
>
|
||||
{{ tag.label }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-m-t-20">
|
||||
<el-input v-model="note" placeholder="请输入自定义备注"></el-input>
|
||||
</div>
|
||||
<div class="u-m-t-20">
|
||||
<el-checkbox v-model="isPrint">打印退菜单</el-checkbox>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-button @click="close">取消</el-button>
|
||||
<el-button type="primary" @click="confirm">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { ElMessage } from "element-plus";
|
||||
export default {
|
||||
props: {
|
||||
modal: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
max: 1,
|
||||
number: 1,
|
||||
isPrint: false,
|
||||
tagSel: -1,
|
||||
show: false,
|
||||
tags: [
|
||||
{ label: "不想要了", checked: false },
|
||||
{ label: "食材不足", checked: false },
|
||||
{ label: "等待时间过长", checked: false },
|
||||
],
|
||||
note: "",
|
||||
goods: {
|
||||
productId: -999,
|
||||
},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
isSeatFee() {
|
||||
return false;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
changeSel(item) {
|
||||
item.checked = !item.checked;
|
||||
},
|
||||
reset() {
|
||||
this.note = "";
|
||||
this.number = 1;
|
||||
this.tags.map((v) => {
|
||||
v.checked = false;
|
||||
});
|
||||
console.log(this.number);
|
||||
},
|
||||
delTag(index) {
|
||||
this.tags.splice(index, 1);
|
||||
},
|
||||
addNote(tag) {
|
||||
if (this.note.length <= 0) {
|
||||
return (this.note = tag);
|
||||
}
|
||||
this.note = tag + "," + this.note;
|
||||
},
|
||||
open(item) {
|
||||
this.goods = item ? item : this.goods;
|
||||
this.max = item.num - item.returnNum;
|
||||
this.show = true;
|
||||
if (item.productId != "-999") {
|
||||
this.number = 1;
|
||||
} else {
|
||||
this.number = this.max;
|
||||
}
|
||||
},
|
||||
close() {
|
||||
this.show = false;
|
||||
this.number = 1;
|
||||
},
|
||||
confirm() {
|
||||
const selTag = this.tags
|
||||
.filter((item) => item.checked)
|
||||
.map((item) => item.label)
|
||||
.join(",");
|
||||
const note = selTag + (this.note.length > 0 ? "," + this.note : "");
|
||||
console.log(note);
|
||||
if (!note) {
|
||||
return ElMessage.error("请输入退菜原因");
|
||||
}
|
||||
this.$emit("confirm", {
|
||||
refundReason: note,
|
||||
refundAmount: 0,
|
||||
refundDetails: [{ id: this.goods.id, num: this.number, returnAmount: 0 }],
|
||||
});
|
||||
this.close();
|
||||
},
|
||||
},
|
||||
mounted() {},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-dialog__body) {
|
||||
margin-bottom: 14px;
|
||||
margin-top: 14px;
|
||||
padding: 0 20px;
|
||||
}
|
||||
:deep(.el-tag) {
|
||||
margin-top: 10px;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 15px;
|
||||
line-height: 35px;
|
||||
height: 35px;
|
||||
}
|
||||
.tags {
|
||||
.tag {
|
||||
margin: 10px 10px 0 0;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
padding: 10px 13px;
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
cursor: pointer;
|
||||
&.active {
|
||||
color: #1890ff;
|
||||
background: #e8f4ff;
|
||||
border-color: #a3d3ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
:deep(.number-box .el-input__inner::-webkit-inner-spin-button) {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
:deep(.number-box .el-input__inner::-webkit-outer-spin-button) {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -122,7 +122,7 @@
|
|||
@noteClick="showNote"
|
||||
@packClick="showPack"
|
||||
@changePriceClick="showChangePrice"
|
||||
@return="showReturn"
|
||||
@return="refReturnCartShow"
|
||||
/>
|
||||
</div>
|
||||
<div class="right">
|
||||
|
|
@ -178,6 +178,7 @@
|
|||
@chooseUser="showChooseUser"
|
||||
@paysuccess="refresh"
|
||||
:table="table"
|
||||
:perpole="perpole"
|
||||
v-else
|
||||
:user="user"
|
||||
></Order>
|
||||
|
|
@ -204,6 +205,8 @@
|
|||
|
||||
<!-- 就餐人数 -->
|
||||
<dinerNumber ref="refDinerNumber" @confirm="dinerNumberConfirm"></dinerNumber>
|
||||
<!-- 退菜 -->
|
||||
<returnCart ref="refReturnCart" @confirm="refReturnCartConfirm"></returnCart>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
|
|
@ -213,6 +216,7 @@ import note from "./components/note.vue";
|
|||
import Order from "./components/order.vue";
|
||||
import pack from "./components/pack.vue";
|
||||
import changePrice from "./components/popup-cart-changePrice.vue";
|
||||
import returnCart from "./components/return-cart.vue";
|
||||
import chooseUser from "./components/choose-user.vue";
|
||||
import changeWeight from "./components/popup-weight-goods.vue";
|
||||
import changeTaocan from "./components/popup-taocan-goods.vue";
|
||||
|
|
@ -229,20 +233,45 @@ import shopUserApi from "@/api/account/shopUser";
|
|||
import { useCartsStore } from "@/store/modules/carts";
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
|
||||
import { ElLoading } from "element-plus";
|
||||
import { ElLoading, ElMessage } from "element-plus";
|
||||
|
||||
const carts = useCartsStore();
|
||||
const shopUser = useUserStore();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
//退菜
|
||||
const refReturnCart = ref();
|
||||
async function refReturnCartConfirm(e) {
|
||||
console.log(e);
|
||||
const res = await orderApi.refundOrder({
|
||||
...e,
|
||||
orderId: oldOrder.value.id,
|
||||
});
|
||||
ElMessage({
|
||||
type: res ? "success" : "error",
|
||||
text: res ? "退菜成功" : "操作失败",
|
||||
});
|
||||
if (res) {
|
||||
// 获取历史订单数据
|
||||
const res1 = await orderApi.getHistoryList({
|
||||
orderId: oldOrder.value.id,
|
||||
});
|
||||
oldOrder.value = res1;
|
||||
orderInfo.value = res1;
|
||||
carts.setOldOrder(res1);
|
||||
}
|
||||
}
|
||||
function refReturnCartShow(e) {
|
||||
const memberPrice = e.memberPrice || e.salePrice;
|
||||
refReturnCart.value.open({
|
||||
...e,
|
||||
price: e.discount_sale_amount || (carts.useVipPrice ? memberPrice : e.salePrice),
|
||||
});
|
||||
}
|
||||
|
||||
//整单备注
|
||||
const remark = ref("");
|
||||
//退菜
|
||||
function showReturn(cart) {
|
||||
console.log(cart);
|
||||
}
|
||||
|
||||
//就餐人数
|
||||
let perpole = ref("");
|
||||
|
|
@ -628,7 +657,8 @@ function init() {
|
|||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const { id } = route.query;
|
||||
const { id, tableCode } = route.query;
|
||||
console.log(id, tableCode);
|
||||
if (id) {
|
||||
// 获取历史订单数据
|
||||
const res = await orderApi.getHistoryList({
|
||||
|
|
@ -667,6 +697,10 @@ onMounted(async () => {
|
|||
showOrder.value = true;
|
||||
}
|
||||
}
|
||||
if (tableCode) {
|
||||
const tableRes = await tableApi.get({ tableCode: tableCode });
|
||||
table.value = tableRes || {};
|
||||
}
|
||||
init();
|
||||
});
|
||||
|
||||
|
|
@ -723,7 +757,7 @@ $pl: 30px;
|
|||
display: flex;
|
||||
max-height: calc(100vh - 256px);
|
||||
.left {
|
||||
width: 350px;
|
||||
width: 1;
|
||||
padding-right: 14px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
|
|
@ -736,7 +770,7 @@ $pl: 30px;
|
|||
}
|
||||
}
|
||||
.right {
|
||||
flex: 1;
|
||||
flex: 3;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
&::-webkit-scrollbar {
|
||||
|
|
@ -886,4 +920,12 @@ $pl: 30px;
|
|||
border-radius: 2px;
|
||||
margin-right: 6px;
|
||||
}
|
||||
.vip {
|
||||
padding: 2px 5px;
|
||||
background: #f7793d;
|
||||
color: #fff;
|
||||
border-radius: 4px;
|
||||
margin-left: 10px;
|
||||
font-size: 10px;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,73 +1,70 @@
|
|||
export function isTui(item) {
|
||||
return item.status == 'return' || item.status == 'refund' || item.status == 'refunding'
|
||||
return item.status == "return" || item.status == "refund" || item.status == "refunding";
|
||||
}
|
||||
//是否使用会员价
|
||||
export function isUseVipPrice(vipUser,goods){
|
||||
return vipUser.id&&vipUser.isVip&&goods.isMember
|
||||
export function isUseVipPrice(vipUser, goods) {
|
||||
return vipUser.id && vipUser.isVip;
|
||||
}
|
||||
|
||||
//计算商品券优惠价格
|
||||
export function returnProductCouponPrice(coup, goodsArr, vipUser) {
|
||||
const item = goodsArr.find(v => v.productId == coup.proId);
|
||||
const item = goodsArr.find((v) => v.productId == coup.proId);
|
||||
if (!item) {
|
||||
return 0
|
||||
return 0;
|
||||
}
|
||||
const memberPrice = item.memberPrice ? item.memberPrice : item.price;
|
||||
const price = item ? (isUseVipPrice(vipUser,item) ? memberPrice : item.price) : 0;
|
||||
return price * coup.num
|
||||
|
||||
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))
|
||||
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)
|
||||
const findGoods = goodsArr.filter((v) => v.productId == coup.proId);
|
||||
if (!findGoods.length) {
|
||||
return false
|
||||
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)
|
||||
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 false;
|
||||
}
|
||||
console.log(selCoupNumber,findGoodsTotalNumber);
|
||||
return findGoodsTotalNumber < selCoupNumber ? false : true
|
||||
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);
|
||||
const newGoodsArr = returnNewGoodsList(goodsArr);
|
||||
const item = newGoodsArr.find((v) => v.productId == coup.proId);
|
||||
if (!item) {
|
||||
return {
|
||||
...coup,
|
||||
discountAmount: 0,
|
||||
use: false
|
||||
}
|
||||
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 price = item ? (isUseVipPrice(vipUser, item) ? memberPrice : item.price) : 0;
|
||||
const discountAmount = (price * coup.num).toFixed(2);
|
||||
// const canUse = !coup.use ? false : (discountAmount > 0 && returnCoupCanUse(goodsArr, coup, selCoupArr))
|
||||
// const canUse=discountAmount>0
|
||||
const canUse=coup.use
|
||||
const canUse = coup.use;
|
||||
return {
|
||||
...coup,
|
||||
discountAmount: discountAmount,
|
||||
use: canUse
|
||||
}
|
||||
|
||||
use: canUse,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 根据购物车商品计算商品券抵扣价格以及是否满足可用需求
|
||||
|
|
@ -80,67 +77,64 @@ export function returnProductCoupon(coup, goodsArr, vipUser, selCoupArr = []) {
|
|||
*/
|
||||
export function returnProductAllCoup(coupArr, goodsArr, vipUser) {
|
||||
return coupArr.map((v) => {
|
||||
return returnProductCoupon(v, goodsArr, vipUser)
|
||||
})
|
||||
|
||||
return returnProductCoupon(v, goodsArr, vipUser);
|
||||
});
|
||||
}
|
||||
//返回商品实际支付价格
|
||||
export function returnProductPayPrice(goods,vipUser){
|
||||
export function returnProductPayPrice(goods, vipUser) {
|
||||
const memberPrice = goods.memberPrice ? goods.memberPrice : goods.price;
|
||||
const price = isUseVipPrice(vipUser,goods) ? memberPrice : goods.price;
|
||||
return 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
|
||||
export function returnProductCoupAllPrice(productPriceArr, startIndex, num = 1, isVip = true) {
|
||||
num = num || 1;
|
||||
return productPriceArr.slice(startIndex, startIndex + num).reduce((prve, cur) => {
|
||||
let curPrice = 0;
|
||||
if (typeof cur === "object") {
|
||||
curPrice = isVip ? cur.memberPrice * 1 : cur.price;
|
||||
} else {
|
||||
curPrice = cur * 1;
|
||||
}
|
||||
return prve+curPrice
|
||||
},0)
|
||||
|
||||
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
|
||||
export function returnProductCanUseNum(productPriceArr, startIndex, num) {
|
||||
let n = 0;
|
||||
for (let i = 0; i < num; i++) {
|
||||
if (productPriceArr[startIndex * 1 + i]) {
|
||||
n += 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return n
|
||||
return n;
|
||||
}
|
||||
|
||||
//返回同类商品券在同类商品价格数组里的开始位置
|
||||
export function returnProCoupStartIndex(coupArr,index){
|
||||
return coupArr.slice(0,index).reduce((prve,cur)=>{
|
||||
return prve+cur.num*1
|
||||
},0)
|
||||
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]=[]
|
||||
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=>{
|
||||
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
|
||||
},{})
|
||||
memberPrice: v.memberPrice ? v.memberPrice : v.price,
|
||||
price: v.price,
|
||||
};
|
||||
});
|
||||
prve[cur.productId].push(...arr);
|
||||
return prve;
|
||||
}, {});
|
||||
}
|
||||
//计算商品券总优惠价格
|
||||
export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
|
|
@ -148,103 +142,106 @@ export function returnProductCouponAllPrice(coupArr, goodsArr, vipUser) {
|
|||
return 0;
|
||||
}
|
||||
//商品分组
|
||||
const goodsMap={}
|
||||
const goodsMap = {};
|
||||
//商品数量从0到n每一个对应的价格
|
||||
const goodsPayPriceMap={}
|
||||
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 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=>{
|
||||
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
|
||||
payPrice: returnProductPayPrice(v, vipUser),
|
||||
};
|
||||
})
|
||||
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
|
||||
},[])
|
||||
.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);
|
||||
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)
|
||||
const proCoupStartIndex = returnProCoupStartIndex(arr, i);
|
||||
const coupNum = Math.min(goodsPayPriceMap[coup.proId].length, coup.num);
|
||||
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 coupArr
|
||||
.filter((v) => v.type == 1)
|
||||
.reduce((a, b) => {
|
||||
const price = b.discountAmount;
|
||||
return a + price;
|
||||
}, 0).toFixed(2);
|
||||
|
||||
}, 0)
|
||||
.toFixed(2);
|
||||
}
|
||||
//计算优惠券总价格
|
||||
export function returnCouponAllPrice(coupArr, goodsArr, vipUser) {
|
||||
const poductAllprice = returnProductCouponAllPrice(coupArr, goodsArr, vipUser)
|
||||
const pointAllPrice = returnFullReductionCouponAllPrice(coupArr)
|
||||
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 => {
|
||||
return coupArr
|
||||
.map((v) => {
|
||||
if (v.id == selCoup.id) {
|
||||
return {...v,use:true}
|
||||
return { ...v, use: true };
|
||||
}
|
||||
const isfullAmount = payPrice*1 >= v.fullAmount * 1
|
||||
if(payPrice<=0){
|
||||
const isfullAmount = payPrice * 1 >= v.fullAmount * 1;
|
||||
if (payPrice <= 0) {
|
||||
return {
|
||||
...v,
|
||||
use: false
|
||||
}
|
||||
use: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
...v,
|
||||
use: v.use && isfullAmount
|
||||
}
|
||||
}).filter(v => v.use)
|
||||
use: v.use && isfullAmount,
|
||||
};
|
||||
})
|
||||
.filter((v) => v.use);
|
||||
}
|
||||
|
||||
//根据商品数量还有商品券数量返回优惠券可以使用的数量数组
|
||||
export function returnCanUseNumProductCoup(coupArr,){
|
||||
let productCoup = coupArr.filter(v => v.type == 2)
|
||||
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]
|
||||
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
|
||||
return arr;
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@
|
|||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
:disabled="!item.tableId || item.status === 'closed'"
|
||||
:disabled="!item.tableCode || item.status === 'closed'"
|
||||
@click="diancanShow(item)"
|
||||
>
|
||||
点餐
|
||||
|
|
@ -227,7 +227,7 @@
|
|||
|
||||
<script setup>
|
||||
import status from "./status.js";
|
||||
|
||||
const router = useRouter();
|
||||
import shopAreaApi from "@/api/account/shopArea";
|
||||
import tableApi from "@/api/account/table";
|
||||
import addEara from "./components/addEara.vue";
|
||||
|
|
@ -334,7 +334,18 @@ async function areainit() {
|
|||
return prve;
|
||||
}, {});
|
||||
}
|
||||
|
||||
async function diancanShow(item, key) {
|
||||
if (!key) {
|
||||
router.push({ path: "/tool/index", query: { tableCode: item.tableCode } });
|
||||
return;
|
||||
}
|
||||
if (key == "isAddGoods") {
|
||||
router.push({ path: "/tool/index", query: { id: item.orderId } });
|
||||
}
|
||||
if (key == "isPayOrder") {
|
||||
router.push({ path: "/tool/index", query: { id: item.orderId } });
|
||||
}
|
||||
}
|
||||
const tabClick = (tab) => {
|
||||
console.log(tab);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue