Commit 86268483 by renyizhao

api订单处理

parent 03d2db39
<template>
<el-dialog title="订单详情" v-model="visible" width="700px">
<el-descriptions :column="2" border v-loading="loading">
<el-descriptions-item label="订单编号">{{ detailData.orderNo }}</el-descriptions-item>
<el-descriptions-item label="用户手机号">{{ detailData.userMobile || '-' }}</el-descriptions-item>
<el-descriptions-item label="用户昵称">{{ detailData.userNickname || '-' }}</el-descriptions-item>
<el-descriptions-item label="订单状态">{{ orderStatusText(detailData.status) }}</el-descriptions-item>
<el-descriptions-item label="API应用">{{ detailData.apiName }}</el-descriptions-item>
<el-descriptions-item label="套餐名称">{{ detailData.packageName }}</el-descriptions-item>
<el-descriptions-item label="订单金额">
{{ detailData.costPrice ? (detailData.costPrice / 100).toFixed(2) + '元' : '-' }}
</el-descriptions-item>
<el-descriptions-item label="开票状态">{{ invoiceStatusText(detailData.invoiceStatus) }}</el-descriptions-item>
<el-descriptions-item label="支付时间">{{ formatDate(detailData.payTime) }}</el-descriptions-item>
<el-descriptions-item label="创建时间">{{ formatDate(detailData.createTime) }}</el-descriptions-item>
<el-descriptions-item label="取消时间">{{ formatDate(detailData.cancelTime) }}</el-descriptions-item>
</el-descriptions>
</el-dialog>
</template>
<script setup lang="ts">
import { ApiOrderApi } from '@/api/apihub/apiorder'
const visible = ref(false)
const loading = ref(false)
const detailData = ref<any>({})
const formatDate = (date: string) => {
if (!date) return '-'
const d = new Date(date)
if (isNaN(d.getTime())) return date
const pad = (n: number) => n.toString().padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`
}
const orderStatusText = (status: number) => {
const map: Record<number, string> = { 0: '待支付', 1: '已支付', 2: '已取消', 3: '已退款' }
return map[status] ?? '-'
}
const invoiceStatusText = (status: number) => {
const map: Record<number, string> = { 0: '未开票', 1: '开票中', 2: '已开票' }
return map[status] ?? '-'
}
const open = async (id: number) => {
visible.value = true
loading.value = true
try {
const data = await ApiOrderApi.getApiOrder(id)
detailData.value = data
} finally {
loading.value = false
}
}
defineExpose({ open })
</script>
<template>
<Dialog v-model="dialogVisible" title="上传发票" width="45%">
<el-form-item label="发票地址" prop="invoiceUrl">
<UploadImg v-model="formData.invoiceUrl" />
<p class="upload-tips">
请上传 大小不超过 <span class="red-text">5MB</span> 格式为
<span class="red-text">pdf</span>
的文件
</p>
</el-form-item>
<el-form ref="formRef" :model="formData" label-width="100px">
<el-form-item label="发票地址" prop="invoiceUrl">
<UploadFile v-model="formData.invoiceUrl" :file-type="['pdf']" :limit="1" />
<p class="upload-tips">
请上传 大小不超过 <span class="red-text">5MB</span> 格式为
<span class="red-text">pdf</span>
的文件
</p>
</el-form-item>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
......@@ -17,6 +19,7 @@
<script setup lang="ts">
import {ApiOrderApi} from "@/api/apihub/apiorder";
import { UploadFile } from '@/components/UploadFile';
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
......@@ -75,5 +78,12 @@
<style scoped lang="scss">
.red-text {
color: red;
}
.upload-tips {
font-size: 12px;
color: #666;
margin-top: 5px;
}
</style>
......@@ -8,15 +8,24 @@
:inline="true"
label-width="68px"
>
<el-form-item label="用户手机号" prop="userId">
<el-form-item label="手机号" prop="mobile">
<el-input
v-model="queryParams.userId"
v-model="queryParams.mobile"
placeholder="请输入用户手机号"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="用户昵称" prop="nickname">
<el-input
v-model="queryParams.nickname"
placeholder="请输入用户昵称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="API应用" prop="apiName">
<el-input
v-model="queryParams.apiName"
......@@ -47,11 +56,13 @@
<el-form-item label="订单状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="请选择订单状态:0=待支付,1=已支付,2=已取消"
placeholder="请选择订单状态"
clearable
class="!w-240px"
>
<el-option label="请选择字典生成" value=""/>
<el-option label="待支付" :value="0" />
<el-option label="已支付" :value="1" />
<el-option label="已取消" :value="2" />
</el-select>
</el-form-item>
<!-- <el-form-item label="支付订单编号" prop="payOrderId">-->
......@@ -96,22 +107,22 @@
<!-- </el-form-item>-->
<el-form-item>
<el-button @click="handleQuery">
<Icon icon="ep:search" class="mr-5px"/>
<Icon icon="ep:search" class="mr-5px" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px"/>
<Icon icon="ep:refresh" class="mr-5px" />
重置
</el-button>
<el-button
<!-- <el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['apihub:api-order:create']"
>
<Icon icon="ep:plus" class="mr-5px"/>
<Icon icon="ep:plus" class="mr-5px" />
新增
</el-button>
</el-button> -->
<el-button
type="success"
plain
......@@ -119,19 +130,19 @@
:loading="exportLoading"
v-hasPermi="['apihub:api-order:export']"
>
<Icon icon="ep:download" class="mr-5px"/>
<Icon icon="ep:download" class="mr-5px" />
导出
</el-button>
<el-button
<!-- <el-button
type="danger"
plain
:disabled="isEmpty(checkedIds)"
@click="handleDeleteBatch"
v-hasPermi="['apihub:api-order:delete']"
>
<Icon icon="ep:delete" class="mr-5px"/>
<Icon icon="ep:delete" class="mr-5px" />
批量删除
</el-button>
</el-button> -->
</el-form-item>
</el-form>
</ContentWrap>
......@@ -146,18 +157,42 @@
:show-overflow-tooltip="true"
@selection-change="handleRowCheckboxChange"
>
<el-table-column type="selection" width="55"/>
<!-- <el-table-column type="selection" width="55" /> -->
<!-- <el-table-column label="订单ID" align="center" prop="id" />-->
<el-table-column label="用户手机号" align="center" prop="userMobile" width="120px"/>
<el-table-column label="API应用" align="center" prop="apiName" width="100px"/>
<el-table-column label="套餐名称" align="center" prop="packageName" width="100px"/>
<el-table-column label="订单编号" align="center" prop="orderNo" width="100px"/>
<el-table-column label="用户手机号" align="center" prop="userMobile" width="120px" />
<el-table-column label="用户昵称" align="center" prop="userNickname" width="100px" />
<el-table-column label="API应用" align="center" prop="apiName" width="100px" />
<el-table-column label="套餐名称" align="center" prop="packageName" width="100px" />
<el-table-column label="订单编号" align="center" prop="orderNo" width="100px" />
<el-table-column label="订单金额" align="center" prop="costPrice">
<template #default="scope"> {{ (scope.row.costPrice / 100).toFixed(2) }}</template>
</el-table-column>
<el-table-column label="订单状态" align="center" prop="status">
<template #default="scope">
{{
scope.row.status === 0
? '待支付'
: scope.row.status === 1
? '已支付'
: scope.row.status === 2
? '已取消'
: '-'
}}
</template>
</el-table-column>
<el-table-column label="开票状态" align="center" prop="invoiceStatus">
<template #default="scope">
{{ (scope.row.costPrice / 100).toFixed(2) }}
{{
scope.row.invoiceStatus === InvoiceRequestEnum.UNINVOICED.type
? InvoiceRequestEnum.UNINVOICED.name
: scope.row.invoiceStatus === InvoiceRequestEnum.INVOICING.type
? InvoiceRequestEnum.INVOICING.name
: scope.row.invoiceStatus === InvoiceRequestEnum.INVOICED.type
? InvoiceRequestEnum.INVOICED.name
: '-'
}}
</template>
</el-table-column>
<el-table-column label="订单状态" align="center" prop="statusName"/>
<!-- <el-table-column label="支付订单编号" align="center" prop="payOrderId" />-->
<el-table-column
label="订单支付时间"
......@@ -188,27 +223,30 @@
<!-- :formatter="dateFormatter"-->
<!-- width="180px"-->
<!-- />-->
<el-table-column label="操作" align="center" min-width="120px">
<el-table-column label="操作" align="center" min-width="180px">
<template #default="scope">
<el-button
<el-button link type="primary" @click="handleDetail(scope.row.id)"> 详情 </el-button>
<!-- <el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['apihub:api-order:update']"
>
编辑
</el-button>
<el-button
</el-button> -->
<!-- <el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['apihub:api-order:delete']"
>
删除
</el-button>
</el-button> -->
<el-button
v-if="scope.row.invoiceStatus === InvoiceRequestEnum.UNINVOICED.type ||
scope.row.invoiceStatus === InvoiceRequestEnum.INVOICING.type"
v-if="
scope.row.invoiceStatus === InvoiceRequestEnum.UNINVOICED.type ||
scope.row.invoiceStatus === InvoiceRequestEnum.INVOICING.type
"
link
type="warning"
plain
......@@ -236,40 +274,36 @@ scope.row.invoiceStatus === InvoiceRequestEnum.INVOICING.type"
@pagination="getList"
/>
<!-- 发票预览弹窗 -->
<el-dialog
v-model="pdfDialogVisible"
title="发票预览"
width="80%"
top="5vh"
>
<el-dialog v-model="pdfDialogVisible" title="发票预览" width="80%" top="5vh">
<iframe
v-if="invoiceUrl"
:src="invoiceUrl"
style="width: 100%; height: 80vh; border: none;"
style="width: 100%; height: 80vh; border: none"
></iframe>
</el-dialog>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<ApiOrderForm ref="formRef" @success="getList"/>
<OrderIssueInvoiceForm ref="issueInvoiceFormRef" @success="getList"/>
<ApiOrderForm ref="formRef" @success="getList" />
<OrderIssueInvoiceForm ref="issueInvoiceFormRef" @success="getList" />
<ApiOrderDetail ref="detailRef" />
</template>
<script setup lang="ts">
import {isEmpty} from '@/utils/is'
import {dateFormatter} from '@/utils/formatTime'
import { isEmpty } from '@/utils/is'
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import {ApiOrder, ApiOrderApi} from '@/api/apihub/apiorder'
import { ApiOrder, ApiOrderApi } from '@/api/apihub/apiorder'
import ApiOrderForm from './ApiOrderForm.vue'
import OrderIssueInvoiceForm from "@/views/apihub/apiorder/OrderIssueInvoiceForm.vue";
import {InvoiceRequestEnum} from "@/utils/constants";
import OrderIssueInvoiceForm from '@/views/apihub/apiorder/OrderIssueInvoiceForm.vue'
import ApiOrderDetail from './ApiOrderDetail.vue'
import { InvoiceRequestEnum } from '@/utils/constants'
/** api订单 列表 */
defineOptions({name: 'ApiOrder'})
defineOptions({ name: 'ApiOrder' })
const message = useMessage() // 消息弹窗
const {t} = useI18n() // 国际化
const { t } = useI18n() // 国际化
const loading = ref(true) // 列表的加载中
const list = ref<ApiOrder[]>([]) // 列表的数据
......@@ -277,6 +311,8 @@ const total = ref(0) // 列表的总页数
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
mobile: undefined,
nickname: undefined,
userId: undefined,
apiId: undefined,
apiName: undefined,
......@@ -321,19 +357,25 @@ const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
const detailRef = ref()
const handleDetail = (id: number) => {
detailRef.value.open(id)
}
/**
* 开票
*/
const issueInvoiceFormRef = ref()
const issueInvoice = (row) => {
issueInvoiceFormRef.value.open(row);
issueInvoiceFormRef.value.open(row)
}
const pdfDialogVisible = ref(false)
const invoiceUrl = ref('')
function viewInvoice(row) {
invoiceUrl.value = import.meta.env.VITE_BASE_URL + '/admin-api/infra/file/preview?url=' + row.invoiceUrl // 从接口带回的 pdf 地址
invoiceUrl.value =
import.meta.env.VITE_BASE_URL + '/admin-api/infra/file/preview?url=' + row.invoiceUrl // 从接口带回的 pdf 地址
pdfDialogVisible.value = true
}
......@@ -347,8 +389,7 @@ const handleDelete = async (id: number) => {
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {
}
} catch {}
}
/** 批量删除api订单 */
......@@ -356,16 +397,15 @@ const handleDeleteBatch = async () => {
try {
// 删除的二次确认
await message.delConfirm()
await ApiOrderApi.deleteApiOrderList(checkedIds.value);
await ApiOrderApi.deleteApiOrderList(checkedIds.value)
message.success(t('common.delSuccess'))
await getList();
} catch {
}
await getList()
} catch {}
}
const checkedIds = ref<number[]>([])
const handleRowCheckboxChange = (records: ApiOrder[]) => {
checkedIds.value = records.map((item) => item.id);
checkedIds.value = records.map((item) => item.id)
}
/** 导出按钮操作 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment