651 lines
19 KiB
Vue
651 lines
19 KiB
Vue
<template>
|
|
<div class="page">
|
|
<div class="ele-body">
|
|
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
|
<ele-pro-table
|
|
ref="tableRef"
|
|
row-key="id"
|
|
:columns="columns"
|
|
:datasource="datasource"
|
|
:customRow="customRow"
|
|
:scroll="{ x: 800 }"
|
|
tool-class="ele-toolbar-form"
|
|
class="sys-org-table"
|
|
v-model:selection="selection"
|
|
>
|
|
<template #toolbar>
|
|
<search
|
|
@search="reload"
|
|
:selection="selection"
|
|
@add="openEdit"
|
|
@remove="removeBatch"
|
|
@batchMove="openMove"
|
|
@export="handleExport"
|
|
/>
|
|
</template>
|
|
<template #bodyCell="{ column, record }">
|
|
<template v-if="column.key === 'image'">
|
|
<a-image :src="record.image" :width="50" />
|
|
</template>
|
|
<template v-if="column.key === 'dateTime'">
|
|
<div>{{ record.siteName }}</div>
|
|
<div>{{ record.dateTime }} ¥{{ record.totalPrice }}元</div>
|
|
</template>
|
|
<template v-if="column.key === 'payType'">
|
|
<template v-if="record.payStatus == 1">
|
|
<a-tag v-if="record.payType == 0">余额支付</a-tag>
|
|
<a-tag v-if="record.payType == 1">
|
|
<WechatOutlined class="tag-icon" />
|
|
微信支付
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 2">积分</a-tag>
|
|
<a-tag v-if="record.payType == 3">
|
|
<AlipayCircleOutlined class="tag-icon" />
|
|
支付宝
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 4">
|
|
<IdcardOutlined class="tag-icon" />
|
|
现金
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 5">
|
|
<IdcardOutlined class="tag-icon" />
|
|
POS机
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 6">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP月卡
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 7">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP年卡
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 8">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP次卡
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 9">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC月卡
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 10">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC年卡
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 11">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC次卡
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 12">
|
|
<IdcardOutlined class="tag-icon" />
|
|
免费
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 13">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP充值卡
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 14">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC充值卡
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 15">
|
|
<IdcardOutlined class="tag-icon" />
|
|
积分支付
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 16">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP季卡
|
|
</a-tag>
|
|
<a-tag v-if="record.payType == 17">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC季卡
|
|
</a-tag>
|
|
</template>
|
|
<template v-else>
|
|
<span></span>
|
|
</template>
|
|
</template>
|
|
<template v-if="column.key === 'couponType'">
|
|
<a-tag v-if="record.couponType == 0">无</a-tag>
|
|
<a-tag v-if="record.couponType == 1" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
抵扣优惠券
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 2" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
折扣优惠券
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 3" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP月卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 4" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP年卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 5" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP次卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 6" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP会员卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 7" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC月卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 8" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC年卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 9" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC次卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 10" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC会员卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 11" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
免费订单
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 12" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP充值卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 13" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC充值卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 14" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
VIP季卡
|
|
</a-tag>
|
|
<a-tag v-if="record.couponType == 15" color="blue">
|
|
<IdcardOutlined class="tag-icon" />
|
|
IC季卡
|
|
</a-tag>
|
|
</template>
|
|
<template v-if="column.key === 'payStatus'">
|
|
<a-tag v-if="record.payStatus == 2" color="error">
|
|
<CloseOutlined class="tag-icon" />
|
|
未付款
|
|
</a-tag>
|
|
<a-tag v-if="record.payStatus == 1" color="green">
|
|
<CheckOutlined class="tag-icon" />
|
|
已付款
|
|
</a-tag>
|
|
<a-tag
|
|
v-if="record.payStatus == 3 || record.payStatus == 0"
|
|
color="cyan"
|
|
>
|
|
<CoffeeOutlined class="tag-icon" />
|
|
未付款,占场中
|
|
</a-tag>
|
|
</template>
|
|
<template v-if="column.key === 'orderInfo'">
|
|
{{ record.orderInfoList }}
|
|
</template>
|
|
<template v-if="column.key === 'orderStatus'">
|
|
<span v-if="record.orderStatus == 1" class="ele-text-success"
|
|
>已完成</span
|
|
>
|
|
<span v-if="record.orderStatus == 2" class="ele-text-placeholder"
|
|
>未使用</span
|
|
>
|
|
<span v-if="record.orderStatus == 3" class="ele-text-placeholder"
|
|
>已取消</span
|
|
>
|
|
<span v-if="record.orderStatus == 4" class="ele-text-warning"
|
|
>退款申请中</span
|
|
>
|
|
<span v-if="record.orderStatus == 5" class="ele-text-danger"
|
|
>退款被拒绝</span
|
|
>
|
|
<span v-if="record.orderStatus == 6" class="ele-text-heading"
|
|
>退款成功</span
|
|
>
|
|
<span v-if="record.orderStatus == 7" class="ele-text-warning"
|
|
>客户端申请退款</span
|
|
>
|
|
<span v-if="record.orderStatus == 9" class="ele-text-warning"
|
|
>未完成</span
|
|
>
|
|
</template>
|
|
<template v-if="column.key === 'isInvoice'">
|
|
<a-tag
|
|
v-if="record.isInvoice == 1"
|
|
color="green"
|
|
class="cursor-pointer"
|
|
@click="openInvoicePdf(record)"
|
|
>已开票
|
|
</a-tag>
|
|
<a-tag
|
|
v-if="record.isInvoice == 2"
|
|
color="red"
|
|
class="cursor-pointer"
|
|
@click="onInvoice(record)"
|
|
>未开票
|
|
</a-tag>
|
|
<a-tag v-if="record.isInvoice == 3" color="purple">不能开</a-tag>
|
|
</template>
|
|
<template v-if="column.key === 'status'">
|
|
<a-tag v-if="record.status === 0" color="green">显示</a-tag>
|
|
<a-tag v-if="record.status === 1" color="red">隐藏</a-tag>
|
|
</template>
|
|
<template v-if="column.key === 'action'">
|
|
<a-space>
|
|
<a @click="openEdit(record)">详情</a>
|
|
<a-divider type="vertical" />
|
|
<a
|
|
@click="openRefund(record)"
|
|
v-if="
|
|
record.payStatus === 1 &&
|
|
[1, 3].includes(record.payType) &&
|
|
[1, 2].includes(record.orderStatus)
|
|
"
|
|
>退款</a
|
|
>
|
|
</a-space>
|
|
</template>
|
|
</template>
|
|
</ele-pro-table>
|
|
</a-card>
|
|
<!-- 编辑弹窗 -->
|
|
<OrderInfo v-model:visible="showEdit" :data="current" @done="reload" />
|
|
<!-- 开具发票 -->
|
|
<Invoice v-model:visible="showInvoice" :data="current" @done="reload" />
|
|
<Refund v-model:visible="showRefund" :data="refundOrder" @done="reload" />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { createVNode, ref } from 'vue';
|
|
import { message, Modal } from 'ant-design-vue';
|
|
import { utils, writeFile } from 'xlsx';
|
|
import {
|
|
ExclamationCircleOutlined,
|
|
CheckOutlined,
|
|
CloseOutlined,
|
|
AlipayCircleOutlined
|
|
} from '@ant-design/icons-vue';
|
|
import { EleProTable, toDateString } from 'ele-admin-pro';
|
|
import dayjs from "dayjs";
|
|
import type {
|
|
DatasourceFunction,
|
|
ColumnItem
|
|
} from 'ele-admin-pro/es/ele-pro-table/types';
|
|
import Search from './components/search.vue';
|
|
import OrderInfo from './components/orderInfo.vue';
|
|
import Invoice from './components/invoice.vue';
|
|
import {
|
|
pageThinkOrder,
|
|
removeThinkOrder,
|
|
removeBatchThinkOrder
|
|
} from '@/api/think/thinkOrder';
|
|
import * as InvoiceApi from '@/api/think/thinkInvoice';
|
|
import type {
|
|
ThinkOrder,
|
|
ThinkOrderParam
|
|
} from '@/api/think/thinkOrder/model';
|
|
import { formatNumber } from 'ele-admin-pro/es';
|
|
import type { ThinkInvoice } from '@/api/think/thinkInvoice/model';
|
|
import Refund from '@/views/think/thinkOrder/components/refund.vue';
|
|
|
|
// 表格实例
|
|
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
|
|
|
// 表格选中数据
|
|
const selection = ref<ThinkOrder[]>([]);
|
|
// 当前编辑数据
|
|
const current = ref<ThinkOrder | null>(null);
|
|
// 是否显示编辑弹窗
|
|
const showEdit = ref(false);
|
|
// 开具发票弹窗
|
|
const showInvoice = ref(false);
|
|
// 是否显示批量移动弹窗
|
|
const showMove = ref(false);
|
|
// 加载状态
|
|
const loading = ref(true);
|
|
// 订单列表
|
|
const orderList = ref<ThinkOrder[]>([]);
|
|
|
|
// 表格数据源
|
|
const datasource: DatasourceFunction = ({
|
|
page,
|
|
limit,
|
|
where,
|
|
orders,
|
|
filters
|
|
}) => {
|
|
if (filters) {
|
|
where.status = filters.status;
|
|
}
|
|
where.forAdmin = true;
|
|
return pageThinkOrder({
|
|
...where,
|
|
...orders,
|
|
page,
|
|
limit
|
|
});
|
|
};
|
|
|
|
// 表格列配置
|
|
const columns = ref<ColumnItem[]>([
|
|
{},
|
|
{
|
|
title: '订单号',
|
|
dataIndex: 'id',
|
|
key: 'iod',
|
|
width: 90
|
|
},
|
|
{
|
|
title: '姓名',
|
|
dataIndex: 'name',
|
|
key: 'name',
|
|
align: 'center'
|
|
},
|
|
{
|
|
title: '手机号',
|
|
dataIndex: 'phone',
|
|
key: 'phone',
|
|
width: 120,
|
|
align: 'center'
|
|
},
|
|
{
|
|
title: '预约信息',
|
|
dataIndex: 'dateTime',
|
|
key: 'dateTime',
|
|
width: 120,
|
|
align: 'center'
|
|
},
|
|
{
|
|
title: '总额',
|
|
dataIndex: 'totalPrice',
|
|
key: 'totalPrice',
|
|
align: 'center',
|
|
sorter: true,
|
|
customRender: ({ text }) => `¥${formatNumber(text)}`
|
|
},
|
|
{
|
|
title: '减少金额',
|
|
dataIndex: 'reducePrice',
|
|
key: 'reducePrice',
|
|
align: 'center',
|
|
sorter: true,
|
|
customRender: ({ text }) => `¥${formatNumber(text)}`
|
|
},
|
|
{
|
|
title: '实付金额',
|
|
dataIndex: 'payPrice',
|
|
key: 'payPrice',
|
|
align: 'center',
|
|
sorter: true,
|
|
customRender: ({ text }) => `¥${formatNumber(text)}`
|
|
},
|
|
{
|
|
title: '支付方式',
|
|
dataIndex: 'payType',
|
|
key: 'payType',
|
|
align: 'center'
|
|
},
|
|
{
|
|
title: 'IC卡号',
|
|
dataIndex: 'code',
|
|
key: 'code',
|
|
align: 'center'
|
|
},
|
|
{
|
|
title: '付款状态',
|
|
dataIndex: 'payStatus',
|
|
key: 'payStatus',
|
|
sorter: true,
|
|
align: 'center'
|
|
},
|
|
{
|
|
title: '付款时间',
|
|
dataIndex: 'payTime',
|
|
key: 'payTime',
|
|
sorter: true,
|
|
align: 'center',
|
|
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
|
|
},
|
|
{
|
|
title: '订单状态',
|
|
dataIndex: 'orderStatus',
|
|
key: 'orderStatus',
|
|
align: 'center'
|
|
},
|
|
{
|
|
title: '优惠类型',
|
|
dataIndex: 'couponType',
|
|
key: 'couponType',
|
|
align: 'center'
|
|
},
|
|
{
|
|
title: '开票状态',
|
|
dataIndex: 'isInvoice',
|
|
key: 'isInvoice',
|
|
align: 'center',
|
|
sorter: true
|
|
},
|
|
// {
|
|
// title: '类型',
|
|
// dataIndex: 'type',
|
|
// key: 'type',
|
|
// align: 'center',
|
|
// customRender: ({ text }) =>
|
|
// ['商城订单', '客户预定', '俱乐部训练场', '活动订场'][text]
|
|
// },
|
|
// {
|
|
// title: '申请退款时间',
|
|
// dataIndex: 'refundApplyTime',
|
|
// key: 'refundApplyTime',
|
|
// align: 'center',
|
|
// customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
|
|
// },
|
|
// {
|
|
// title: '备注',
|
|
// dataIndex: 'comments',
|
|
// key: 'comments',
|
|
// align: 'center'
|
|
// },
|
|
{
|
|
title: '操作',
|
|
key: 'action',
|
|
width: 120,
|
|
fixed: 'right',
|
|
align: 'center',
|
|
hideInSetting: true
|
|
}
|
|
]);
|
|
|
|
/* 搜索 */
|
|
const reload = (where?: ThinkOrderParam) => {
|
|
selection.value = [];
|
|
tableRef?.value?.reload({ where: where });
|
|
};
|
|
|
|
/* 打开编辑弹窗 */
|
|
const openEdit = (row?: ThinkOrder) => {
|
|
current.value = row ?? null;
|
|
showEdit.value = true;
|
|
};
|
|
|
|
const showRefund = ref(false);
|
|
const refundOrder = ref<ThinkOrder>();
|
|
const openRefund = (row: ThinkOrder) => {
|
|
refundOrder.value = row;
|
|
showRefund.value = true;
|
|
};
|
|
|
|
/* 打开批量移动弹窗 */
|
|
const openMove = () => {
|
|
showMove.value = true;
|
|
};
|
|
|
|
/* 删除单个 */
|
|
const remove = (row: ThinkOrder) => {
|
|
const hide = message.loading('请求中..', 0);
|
|
removeThinkOrder(row.id)
|
|
.then((msg) => {
|
|
hide();
|
|
message.success(msg);
|
|
reload();
|
|
})
|
|
.catch((e) => {
|
|
hide();
|
|
message.error(e.message);
|
|
});
|
|
};
|
|
|
|
/* 批量删除 */
|
|
const removeBatch = () => {
|
|
if (!selection.value.length) {
|
|
message.error('请至少选择一条数据');
|
|
return;
|
|
}
|
|
Modal.confirm({
|
|
title: '提示',
|
|
content: '确定要删除选中的记录吗?',
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
maskClosable: true,
|
|
onOk: () => {
|
|
const hide = message.loading('请求中..', 0);
|
|
removeBatchThinkOrder(selection.value.map((d) => d.id))
|
|
.then((msg) => {
|
|
hide();
|
|
message.success(msg);
|
|
reload();
|
|
})
|
|
.catch((e) => {
|
|
hide();
|
|
message.error(e.message);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
/* 开具发票 */
|
|
const onInvoice = (row?: ThinkOrder) => {
|
|
console.log(row?.payStatus);
|
|
if (row?.payStatus != 1) {
|
|
return false;
|
|
}
|
|
current.value = row ?? null;
|
|
showInvoice.value = true;
|
|
};
|
|
|
|
const openInvoicePdf = (row?: ThinkInvoice) => {
|
|
if (row?.id) {
|
|
InvoiceApi.showInvoice(row?.id).then((res) => {
|
|
const parse = JSON.parse(res);
|
|
const pdfUrl = parse[0].pdfUrl;
|
|
window.open(pdfUrl);
|
|
});
|
|
}
|
|
};
|
|
|
|
// 导出
|
|
const handleExport = (where?: ThinkOrderParam) => {
|
|
console.log('开始导出');
|
|
loading.value = true;
|
|
const array: (string | number)[][] = [
|
|
[
|
|
'订单号',
|
|
'订单编号',
|
|
'姓名',
|
|
'电话号码',
|
|
'预定信息',
|
|
'消费金额',
|
|
'实付金额',
|
|
'付款时间',
|
|
'下单时间'
|
|
]
|
|
];
|
|
if (!where.timeStart) {
|
|
message.error('请选择导出的开始日期、结束日期,每次最多导出5000条记录');
|
|
return false;
|
|
}
|
|
pageThinkOrder(where)
|
|
.then((data) => {
|
|
data.list?.forEach((d: ThinkOrder) => {
|
|
array.push([
|
|
`${d.id}`,
|
|
`${d.orderNum}`,
|
|
`${d.name}`,
|
|
`${d.phone}`,
|
|
`${d.siteName} ${d.dateTime} ${d.totalPrice}`,
|
|
`${d.totalPrice}`,
|
|
`${d.payPrice}`,
|
|
`${toDateString(d.payTime, 'YYYY年MM月dd日 HH:mm:ss')}`,
|
|
`${toDateString(d.createTime, 'YYYY年MM月dd日 HH:mm:ss')}`
|
|
]);
|
|
});
|
|
const sheetName = `订单数据导出`;
|
|
const workbook = {
|
|
SheetNames: [sheetName],
|
|
Sheets: {}
|
|
};
|
|
const sheet = utils.aoa_to_sheet(array);
|
|
workbook.Sheets[sheetName] = sheet;
|
|
// 设置列宽
|
|
sheet['!cols'] = [
|
|
{ wch: 10 },
|
|
{ wch: 10 },
|
|
{ wch: 10 },
|
|
{ wch: 10 },
|
|
{ wch: 20 },
|
|
{ wch: 40 },
|
|
{ wch: 10 }
|
|
];
|
|
message.loading('正在导出...');
|
|
setTimeout(() => {
|
|
writeFile(workbook, `${sheetName}.xlsx`);
|
|
loading.value = false;
|
|
}, 2000);
|
|
})
|
|
.catch((msg) => {
|
|
message.error(msg);
|
|
loading.value = false;
|
|
})
|
|
.finally(() => {});
|
|
};
|
|
|
|
/* 查询 */
|
|
const query = () => {
|
|
loading.value = true;
|
|
};
|
|
|
|
/* 自定义行属性 */
|
|
const customRow = (record: ThinkOrder) => {
|
|
return {
|
|
// 行点击事件
|
|
onClick: () => {
|
|
// console.log(record);
|
|
},
|
|
// 行双击事件
|
|
onDblclick: () => {
|
|
openEdit(record);
|
|
}
|
|
};
|
|
};
|
|
query();
|
|
</script>
|
|
|
|
<script lang="ts">
|
|
import * as MenuIcons from '@/layout/menu-icons';
|
|
|
|
export default {
|
|
name: 'ThinkOrder',
|
|
components: MenuIcons
|
|
};
|
|
</script>
|
|
<style lang="less" scoped>
|
|
.tag-icon {
|
|
padding-right: 6px;
|
|
}
|
|
</style>
|