Commit 367cf787 authored by daniel's avatar daniel

feat(gpsDeposit): 完善订单列表

parent 11107d18
...@@ -141,10 +141,10 @@ ...@@ -141,10 +141,10 @@
</div> </div>
<div class="w-full gap-x-2 flex flex-row items-center mt-3"> <div class="w-full gap-x-2 flex flex-row items-center mt-3">
<n-space v-if="tabIndex===2"> <n-space v-if="tabIndex===2">
<n-button type="primary"> <n-button type="primary" @click="refundAll">
一键归还 一键归还
</n-button> </n-button>
<n-button v-if="checkedRowKeys.length" type="error"> <n-button v-if="checkedRowKeys.length" @click="batchRefund" type="error">
批量退款 批量退款
</n-button> </n-button>
</n-space> </n-space>
...@@ -236,7 +236,6 @@ ...@@ -236,7 +236,6 @@
</script> </script>
<script> <script>
const cmpt = JSON.parse('${fns:toJson(cmpt)}'); const cmpt = JSON.parse('${fns:toJson(cmpt)}');
console.log({ cmpt })
// 枚举class // 枚举class
class SuperEnum { class SuperEnum {
constructor(param) { constructor(param) {
...@@ -423,6 +422,12 @@ ...@@ -423,6 +422,12 @@
const GET_DEPOSIT_URL = BASE_ECC_URL + "/api-gps-config/v1/getByCmptId?cmptId=" + getCId() const GET_DEPOSIT_URL = BASE_ECC_URL + "/api-gps-config/v1/getByCmptId?cmptId=" + getCId()
// 获取订单 // 获取订单
const GET_ORDER_PAGE_URL = BASE_ECC_URL + "/api-order/v1/order-list" const GET_ORDER_PAGE_URL = BASE_ECC_URL + "/api-order/v1/order-list"
// 删除订单
const DELETE_ORDER_URL = BASE_ECC_URL + "/api-order/v1/delete-order"
// 订单退款
const ORDER_REFUND_URL = BASE_ECC_URL + "/api-refund/v1/refund"
// 批量退款
const ORDER_BATCH_REFUND_URL = BASE_ECC_URL + "/api-refund/v1/batch-refund"
// 获取赛事信息 // 获取赛事信息
const GET_CMPT_URL = "https://timerbackend.geexek.com/getCmpt.do?cmptId=" + getCId() const GET_CMPT_URL = "https://timerbackend.geexek.com/getCmpt.do?cmptId=" + getCId()
...@@ -509,6 +514,9 @@ ...@@ -509,6 +514,9 @@
const orderColumns = [ const orderColumns = [
{ {
type: 'selection', type: 'selection',
disabled(row) {
return ![TradeStatusEnum.PAY_SUCCESS.value].includes(row.tradeStatus)
}
}, },
{ {
title: '订单号', title: '订单号',
...@@ -528,44 +536,92 @@ ...@@ -528,44 +536,92 @@
{ {
title: '状态', title: '状态',
key: 'tradeStatus', key: 'tradeStatus',
width: 100, align: 'center',
width: 150,
render: (row) => { render: (row) => {
// 两个按钮,一个 编辑 一个 删除
return h(NSpace, { return h(NSpace, {
vertical: true vertical: true
}, [ }, [
h(NSpace, {}, [
h('span', {}, "订单状态"),
h(NTag, { h(NTag, {
size: "small", size: "small",
type: TradeStatusEnum[row.tradeStatus].color, type: TradeStatusEnum[row.tradeStatus].color,
bordered: false,
round: true,
}, TradeStatusEnum[row.tradeStatus].name), }, TradeStatusEnum[row.tradeStatus].name),
]),
h(NSpace, {}, [
h('span', {}, "订单类型"),
h(NTag, { h(NTag, {
size: "small", size: "small",
bordered: false,
round: true,
type: OrderTypeEnum[row.orderType].color, type: OrderTypeEnum[row.orderType].color,
}, OrderTypeEnum[row.orderType].name), }, OrderTypeEnum[row.orderType].name),
]),
h(NSpace, {}, [
h('span', {}, "支付方式"),
h(NTag, { h(NTag, {
size: "small", size: "small",
bordered: false,
round: true,
type: PayTypeEnum[row.payType].color, type: PayTypeEnum[row.payType].color,
}, PayTypeEnum[row.orderType].name), }, PayTypeEnum[row.payType].name),
]) ])])
} }
}, },
{ {
title: '交易金额', title: '交易金额',
key: 'amount', key: 'amount',
align: 'center', align: 'center',
width: 140,
render: (row) => {
// 两个按钮,一个 编辑 一个 删除
return h(NSpace, {
vertical: true
}, [
h(NSpace, {}, [
h('span', {}, "支付金额"),
h(NTag, {
size: "small",
bordered: false,
type: 'primary',
}, `¥` + row.amount),
]),
row.returnAmount && h(NSpace, {}, [
h('span', {}, "退款金额"),
h(NTag, {
size: "small",
bordered: false,
type: 'error',
}, `¥` + row.returnAmount),
]),
])
}
}, },
{ {
title: '创建时间', title: '日期',
key: 'createTime', key: 'createTime',
align: 'center', align: 'center',
width: 100, width: 220,
}, render: (row) => {
{ // 两个按钮,一个 编辑 一个 删除
title: '更新时间', return h(NSpace, {
key: 'updateTime', vertical: true
align: 'center', }, [
width: 100, h('span', {
className: 'text-xs',
}, "创建时间:" + row.createTime),
row.updateTime && h('span', {
className: 'text-xs',
}, "更新时间:" + row.updateTime),
row.refundTime && h('span', {
className: 'text-xs',
}, "退款时间:" + row.refundTime),
])
}
}, },
{ {
title: '操作', title: '操作',
...@@ -574,28 +630,52 @@ ...@@ -574,28 +630,52 @@
align: 'center', align: 'center',
render: (row) => { render: (row) => {
// 两个按钮,一个 编辑 一个 删除 // 两个按钮,一个 编辑 一个 删除
return h(NSpace, {}, [ return h('div', {
className: 'flex flex-row items-center justify-center gap-x-1'
}, [
row.tradeStatus === TradeStatusEnum.PAY_SUCCESS.value && h(NButton, { row.tradeStatus === TradeStatusEnum.PAY_SUCCESS.value && h(NButton, {
type: 'error', type: 'error',
size: 'small', size: 'small',
onClick: async () => { onClick: async () => {
const result = confirm('将全额退款' + row.markNo + 'GPS押金?')
if (!result) {
return
} }
}, '退款'), row.refundAmount = row.amount
// h(NButton, { // 订单退款
// type: 'primary', await orderRefund(row)
// size: 'small', }
// onClick: () => { }, '全额退款'),
row.tradeStatus === TradeStatusEnum.PAY_SUCCESS.value && h(NButton, {
// } type: 'primary',
// }, '归还'), size: 'small',
// h(NButton, { onClick: async () => {
// type: 'primary', const inputConfirm = prompt('请输入退款金额(最大' + row.amount + ')')
// size: 'small', if (!inputConfirm) {
// onClick: async () => { return
}
// } if (Number(inputConfirm) > row.amount) {
// }, '退款'), NMessage.error('退款金额不能大于订单金额')
return
}
row.refundAmount = Number(inputConfirm)
// 订单退款
await orderRefund(row)
}
}, '部分退款'),
// 仅当订单状态为待支付时,显示删除按钮
row.tradeStatus === TradeStatusEnum.WAIT_PAY.value && h(NButton, {
type: 'error',
size: 'small',
onClick: async () => {
const result = confirm('确定删除订单' + row.markNo + '吗?')
if (!result) {
return
}
// 删除订单
await deleteOrder(row)
}
}, '删除订单'),
]) ])
} }
...@@ -660,7 +740,7 @@ ...@@ -660,7 +740,7 @@
checkedRowKeys.value = rowKeys checkedRowKeys.value = rowKeys
} }
function rowKey(row) { function rowKey(row) {
return row.markNo return row.id
} }
// 状态更新 // 状态更新
const updateStatus = (value) => { const updateStatus = (value) => {
...@@ -741,7 +821,62 @@ ...@@ -741,7 +821,62 @@
tradeStatusOptions.value[2].total = res[2].data.total tradeStatusOptions.value[2].total = res[2].data.total
tradeStatusOptions.value[3].total = res[3].data.total tradeStatusOptions.value[3].total = res[3].data.total
tradeStatusOptions.value[4].total = res[4].data.total tradeStatusOptions.value[4].total = res[4].data.total
}
// 订单退款
const orderRefund = async (row) => {
loading.value = true
let params = {
orderId: row.orderId,
refundAmount: row.refundAmount,
refundReason: getCId() + "_gps押金退款_" + row.markNo,
operatorCode: getUId(),
}
const [err, res] = await to(fetch(ORDER_REFUND_URL, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(res => res.json()))
loading.value = false
if (err) {
message.error(err)
return
}
if (res.code === 200) {
message.success('退款成功')
fetchOrders()
} else {
message.error(res.message)
}
}
// 删除订单
const deleteOrder = async (row) => {
loading.value = true
let params = {
applyId: row.applyId,
operator: getUId(),
}
const [err, res] = await to(fetch(DELETE_ORDER_URL, {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(res => res.json()))
loading.value = false
if (err) {
message.error(err)
return
}
if (res.code === 200) {
message.success('删除成功')
fetchOrders()
} else {
message.error(res.message)
}
} }
...@@ -835,11 +970,14 @@ ...@@ -835,11 +970,14 @@
} }
} }
// todo 批量退款 // todo 批量退款
const batchRefund = () => { } const batchRefund = () => {
// todo 触发批量退款 message.success('功能未实现')
const onBatchRefund = () => {
showBatchModal.value = true
} }
// todo 批量退款
const refundAll = () => {
message.success('功能未实现')
}
/***---------------- 押金交互相关 end -----------------*/ /***---------------- 押金交互相关 end -----------------*/
onMounted(() => { onMounted(() => {
...@@ -873,6 +1011,7 @@ ...@@ -873,6 +1011,7 @@
fetchOrders, fetchOrders,
updateStatus, updateStatus,
handleCheck, handleCheck,
rowKey,
// gps 相关 // gps 相关
GpsStatusOptions, GpsStatusOptions,
PLAYER, PLAYER,
...@@ -885,6 +1024,7 @@ ...@@ -885,6 +1024,7 @@
saveDeposit, saveDeposit,
getDeposit, getDeposit,
batchRefund, batchRefund,
refundAll,
} }
} }
......
...@@ -408,7 +408,7 @@ ...@@ -408,7 +408,7 @@
<a <a
href="/gk/gpsDeposit/index/${cmpt.cmptId}?uId=${uId}&cId=${cId}&timestamp=${timestamp}&sign=${sign}"> href="/gk/gpsDeposit/index/${cmpt.cmptId}?uId=${uId}&cId=${cId}&timestamp=${timestamp}&sign=${sign}">
<span class="left-arrow"></span> <span class="left-arrow"></span>
<span class="menu-txt">GPS押金(ing)</span> <span class="menu-txt">GPS押金</span>
</a> </a>
</li> </li>
<li class="information menu-sub-item"> <li class="information menu-sub-item">
......
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 to comment