Files
2024-08-23 22:28:24 +08:00

420 lines
13 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="orderId"
:columns="columns"
:datasource="datasource"
:customRow="customRow"
:scroll="{ x: 800 }"
tool-class="ele-toolbar-form"
class="sys-org-table"
>
<template #toolbar>
<search
@search="reload"
:selection="selection"
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'image'">
<a-image :src="record.image" :width="50" />
</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 == 1" color="green"
><CheckOutlined class="tag-icon" />已付款</a-tag
>
<a-tag v-if="record.payStatus == 0" color="error"
><CloseOutlined class="tag-icon" />未付款</a-tag
>
<a-tag v-if="record.payStatus == 3" 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 == 0" class="ele-text-primary"
>未使用</span
>
<span v-if="record.orderStatus == 2" class="ele-text-placeholder"
>已取消</span
>
<span v-if="record.orderStatus == 1" class="ele-text-success"
>已完成</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
>
</template>
<template v-if="column.key === 'isInvoice'">
<a-tag v-if="record.isInvoice == 0">未开</a-tag>
<a-tag v-if="record.isInvoice == 1" color="green">已开</a-tag>
<a-tag v-if="record.isInvoice == 2">不能开</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-space>
</template>
</template>
</ele-pro-table>
</a-card>
<!-- 编辑弹窗 -->
<OrderInfo v-model:visible="showEdit" :data="current" @done="reload" />
</div>
</div>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import {
ExclamationCircleOutlined,
CheckOutlined,
CloseOutlined,
AlipayCircleOutlined
} from '@ant-design/icons-vue';
import { EleProTable, toDateString } from 'ele-admin-pro';
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 {
pageOrder,
removeOrder,
removeBatchOrder
} from '@/api/booking/order';
import type { Order, OrderParam } from '@/api/booking/order/model';
import { formatNumber } from 'ele-admin-pro/es';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格选中数据
const selection = ref<Order[]>([]);
// 当前编辑数据
const current = ref<Order | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
if (filters) {
where.status = filters.status;
}
// 预定订单
where.type = 1;
// where.sceneType = 'showOrderInfo';
// where.merchantId = getMerchantId();
return pageOrder({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: '场馆名称',
dataIndex: 'merchantName',
key: 'merchantName',
align: 'center'
},
{
title: '下单时间',
dataIndex: 'createTime',
key: 'createTime',
align: 'center'
},
{
title: '单位',
dataIndex: 'realName',
key: 'realName',
align: 'center'
},
{
title: '手机号',
dataIndex: 'phone',
key: 'phone',
align: 'center'
},
{
title: '实际转账单位/个人',
dataIndex: 'realName',
key: 'realName',
align: 'center'
},
{
title: '价格',
dataIndex: 'totalPrice',
align: 'center'
},
{
title: '积分',
dataIndex: 'money',
align: 'center'
},
{
title: '支付方式',
dataIndex: 'payType',
key: 'payType',
align: 'center'
},
{
title: '会员/散客',
dataIndex: 'gradeName',
key: 'gradeName',
align: 'center'
},
{
title: '预付卡号',
dataIndex: 'icCard',
align: 'center'
},
{
title: '预付卡到期时间',
dataIndex: 'expirationTime',
align: 'center'
},
{
title: '备注',
dataIndex: 'comments',
align: 'center'
}
]);
/* 搜索 */
const reload = (where?: OrderParam) => {
selection.value = [];
tableRef?.value?.reload({ where: where });
};
/* 打开编辑弹窗 */
const openEdit = (row?: Order) => {
current.value = row ?? null;
showEdit.value = true;
};
/* 打开批量移动弹窗 */
const openMove = () => {
showMove.value = true;
};
/* 删除单个 */
const remove = (row: Order) => {
const hide = message.loading('请求中..', 0);
removeOrder(row.orderId)
.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);
removeBatchOrder(selection.value.map((d) => d.orderId))
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
}
});
};
/* 查询 */
const query = () => {
loading.value = true;
};
/* 自定义行属性 */
const customRow = (record: Order) => {
return {
// 行点击事件
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
}
};
};
query();
</script>
<script lang="ts">
import * as MenuIcons from '@/layout/menu-icons';
export default {
name: 'Order',
components: MenuIcons
};
</script>
<style lang="less" scoped>
.tag-icon {
padding-right: 6px;
}
</style>