3586d118ac
- 修改.env.development配置,调整API地址 - 扩展OrderPay接口,新增支付金额、支付状态、电池型号等字段
238 lines
6.3 KiB
Vue
238 lines
6.3 KiB
Vue
<template>
|
|
<div class="page">
|
|
<div class="ele-body">
|
|
<a-card :bordered="false">
|
|
<!-- 表格 -->
|
|
<ele-pro-table
|
|
ref="tableRef"
|
|
row-key="id"
|
|
:columns="columns"
|
|
:datasource="datasource"
|
|
v-model:selection="selection"
|
|
tool-class="ele-toolbar-form"
|
|
:scroll="{ x: 1800 }"
|
|
class="sys-org-table"
|
|
:striped="true"
|
|
>
|
|
<template #toolbar>
|
|
<search
|
|
@search="reload"
|
|
:selection="selection"
|
|
@remove="removeBatch"
|
|
@advanced="openAdvanced"
|
|
/>
|
|
</template>
|
|
<template #bodyCell="{ column, record }">
|
|
<template v-if="column.key === 'rentOrderNo'">
|
|
<a-tooltip :title="record.rentOrderNo || record.rentOrderId">
|
|
<span>{{ record.rentOrderNo || ('#' + record.rentOrderId) }}</span>
|
|
</a-tooltip>
|
|
</template>
|
|
|
|
<template v-if="column.key === 'servicePeriod'">
|
|
<div>{{ record.startTime }}</div>
|
|
<div class="ele-text-placeholder">至 {{ record.expirationTime }}</div>
|
|
</template>
|
|
|
|
<template v-if="column.key === 'validity'">
|
|
<span class="ele-text-danger">{{ calcValidity(record) }}</span>
|
|
</template>
|
|
|
|
<template v-if="column.key === 'payStatus'">
|
|
<a-tag v-if="record.payStatus === 20" color="green">已付款</a-tag>
|
|
<a-tag v-else color="red">未付款</a-tag>
|
|
</template>
|
|
|
|
<template v-if="column.key === 'isAdminRenew'">
|
|
<a-tag v-if="record.isAdminRenew === 1" color="blue">后台续费</a-tag>
|
|
<a-tag v-else>用户续费</a-tag>
|
|
</template>
|
|
|
|
<template v-if="column.key === 'createTime'">
|
|
{{ record.createTime }}
|
|
</template>
|
|
</template>
|
|
</ele-pro-table>
|
|
</a-card>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { createVNode, ref } from 'vue';
|
|
import { message, Modal } from 'ant-design-vue';
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
|
|
import type { EleProTable } from 'ele-admin-pro';
|
|
import type {
|
|
DatasourceFunction,
|
|
ColumnItem
|
|
} from 'ele-admin-pro/es/ele-pro-table/types';
|
|
import { toDateString } from 'ele-admin-pro';
|
|
import Search from './components/search.vue';
|
|
import { pageOrderPay } from '@/api/order';
|
|
import type { OrderPay, OrderPayParam } from '@/api/order/model';
|
|
|
|
const props = defineProps<{
|
|
activeKey?: boolean;
|
|
data?: any;
|
|
}>();
|
|
|
|
// 表格实例
|
|
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
|
|
|
// 续费有效期(按服务起止时间计算,固定为续费时长,避免“多给一个月”的观感)
|
|
const calcValidity = (record: OrderPay) => {
|
|
if (!record.startTime || !record.expirationTime) {
|
|
return '-';
|
|
}
|
|
const start = new Date(record.startTime).getTime();
|
|
const end = new Date(record.expirationTime).getTime();
|
|
const days = Math.round((end - start) / (24 * 60 * 60 * 1000));
|
|
if (days < 0) {
|
|
return '异常';
|
|
}
|
|
return days + '天';
|
|
};
|
|
|
|
// 表格列配置
|
|
const columns = ref<ColumnItem[]>([
|
|
{
|
|
title: '续费订单号',
|
|
dataIndex: 'orderNo',
|
|
key: 'orderNo',
|
|
sorter: true
|
|
},
|
|
{
|
|
title: '关联原订单号',
|
|
dataIndex: 'rentOrderNo',
|
|
key: 'rentOrderNo',
|
|
sorter: true
|
|
},
|
|
{
|
|
title: '电池型号',
|
|
dataIndex: 'batteryModel',
|
|
key: 'batteryModel'
|
|
},
|
|
{
|
|
title: '电池编号',
|
|
dataIndex: 'equipmentCode',
|
|
key: 'equipmentCode'
|
|
},
|
|
{
|
|
title: '所属商户',
|
|
dataIndex: 'merchantName',
|
|
key: 'merchantName',
|
|
sorter: true
|
|
},
|
|
{
|
|
title: '服务期限',
|
|
dataIndex: 'servicePeriod',
|
|
key: 'servicePeriod'
|
|
},
|
|
{
|
|
title: '续费时长',
|
|
dataIndex: 'validity',
|
|
key: 'validity'
|
|
},
|
|
{
|
|
title: '续费金额',
|
|
dataIndex: 'payPrice',
|
|
key: 'payPrice'
|
|
},
|
|
{
|
|
title: '续费类型',
|
|
dataIndex: 'isAdminRenew',
|
|
key: 'isAdminRenew'
|
|
},
|
|
{
|
|
title: '付款状态',
|
|
dataIndex: 'payStatus',
|
|
key: 'payStatus',
|
|
filters: [
|
|
{ text: '未付款', value: 10 },
|
|
{ text: '已付款', value: 20 }
|
|
],
|
|
filterMultiple: false
|
|
},
|
|
{
|
|
title: '购买时间',
|
|
dataIndex: 'createTime',
|
|
key: 'createTime',
|
|
sorter: true,
|
|
customRender: ({ text }) => toDateString(text)
|
|
}
|
|
]);
|
|
|
|
// 表格选中数据
|
|
const selection = ref<OrderPay[]>([]);
|
|
// 是否显示高级搜索
|
|
const showAdvancedSearch = ref(false);
|
|
|
|
// 表格数据源:只查续费单(rentOrderId 不为空)
|
|
const datasource: DatasourceFunction = ({
|
|
page,
|
|
limit,
|
|
where,
|
|
orders
|
|
}) => {
|
|
if (where.payStatus) {
|
|
where.payStatus = where.payStatus;
|
|
}
|
|
where.tenantId = localStorage.getItem('tenantId');
|
|
// 关键:仅查询续费单(rentOrderId 不为空),避免与原订单混在一起
|
|
where.rentOrderIdNotNull = true;
|
|
return pageOrderPay({
|
|
...where,
|
|
...orders,
|
|
page,
|
|
limit
|
|
});
|
|
};
|
|
|
|
/* 搜索 */
|
|
const reload = (where?: OrderPayParam) => {
|
|
selection.value = [];
|
|
tableRef?.value?.reload({ where: where });
|
|
};
|
|
|
|
/* 打开高级搜索 */
|
|
const openAdvanced = () => {
|
|
showAdvancedSearch.value = !showAdvancedSearch.value;
|
|
};
|
|
|
|
/* 批量删除 */
|
|
const removeBatch = () => {
|
|
if (!selection.value.length) {
|
|
message.error('请至少选择一条数据');
|
|
return;
|
|
}
|
|
Modal.confirm({
|
|
title: '提示',
|
|
content: '确定要删除选中的记录吗?',
|
|
icon: createVNode(ExclamationCircleOutlined),
|
|
maskClosable: true,
|
|
onOk: () => {
|
|
message.info('续费单删除需后端支持批量接口,请联系开发');
|
|
}
|
|
});
|
|
};
|
|
</script>
|
|
|
|
<script lang="ts">
|
|
export default {
|
|
name: 'ShopRenewOrderIndex'
|
|
};
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
.sys-org-table :deep(.ant-table-body) {
|
|
overflow: auto !important;
|
|
overflow: overlay !important;
|
|
}
|
|
|
|
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
|
padding: 0 4px;
|
|
margin-bottom: 0;
|
|
}
|
|
</style>
|