This commit is contained in:
@@ -18,7 +18,12 @@
|
||||
@refresh="handleRefresh"
|
||||
>
|
||||
<template #left>
|
||||
<ElButton type="primary" @click="showCreateDialog" v-if="hasAuth('agent_recharge:create')">创建充值订单</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
@click="showCreateDialog"
|
||||
v-if="hasAuth('agent_recharge:create')"
|
||||
>创建充值订单</ElButton
|
||||
>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
@@ -80,21 +85,16 @@
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="目标店铺" prop="shop_id">
|
||||
<ElTreeSelect
|
||||
<ElFormItem label="店铺" prop="shop_id">
|
||||
<ElCascader
|
||||
v-model="createForm.shop_id"
|
||||
:data="shopTreeData"
|
||||
:options="shopCascadeOptions"
|
||||
:props="shopCascadeProps"
|
||||
placeholder="请选择店铺"
|
||||
filterable
|
||||
clearable
|
||||
check-strictly
|
||||
:render-after-expand="false"
|
||||
:props="{
|
||||
label: 'shop_name',
|
||||
value: 'id',
|
||||
children: 'children'
|
||||
}"
|
||||
style="width: 100%"
|
||||
@change="handleShopChange"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
@@ -154,7 +154,7 @@
|
||||
import { h } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { AgentRechargeService, ShopService } from '@/api/modules'
|
||||
import { ElMessage, ElTag, ElTreeSelect, ElButton } from 'element-plus'
|
||||
import { ElMessage, ElTag, ElTreeSelect, ElButton, ElCascader } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type {
|
||||
AgentRecharge,
|
||||
@@ -201,6 +201,37 @@
|
||||
const shopOptions = ref<any[]>([])
|
||||
const shopTreeData = ref<ShopResponse[]>([])
|
||||
|
||||
// 店铺级联选择相关
|
||||
const shopCascadeOptions = ref<any[]>([])
|
||||
const shopCascadeProps = {
|
||||
lazy: true,
|
||||
checkStrictly: true,
|
||||
lazyLoad: async (node: any, resolve: any) => {
|
||||
const { level, value } = node
|
||||
const parentId = level === 0 ? undefined : value
|
||||
|
||||
try {
|
||||
const res = await ShopService.getShopsCascade({ parent_id: parentId })
|
||||
if (res.code === 0) {
|
||||
const nodes = (res.data || []).map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.shop_name,
|
||||
leaf: !item.has_children
|
||||
}))
|
||||
resolve(nodes)
|
||||
} else {
|
||||
resolve([])
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载店铺级联数据失败:', error)
|
||||
resolve([])
|
||||
}
|
||||
},
|
||||
value: 'value',
|
||||
label: 'label',
|
||||
children: 'children'
|
||||
}
|
||||
|
||||
// 搜索表单配置
|
||||
const searchFormItems: SearchFormItem[] = [
|
||||
{
|
||||
@@ -427,26 +458,38 @@
|
||||
return tree
|
||||
}
|
||||
|
||||
// 加载店铺列表
|
||||
// 加载店铺列表 - 改用级联查询
|
||||
const loadShops = async () => {
|
||||
try {
|
||||
const params: any = {
|
||||
page: 1,
|
||||
page_size: 9999 // 获取所有数据用于构建树形结构
|
||||
// 加载平铺列表用于搜索(保留原有逻辑)
|
||||
const res1 = await ShopService.getShops({ page: 1, page_size: 9999 })
|
||||
if (res1.code === 0) {
|
||||
shopOptions.value = res1.data.items || []
|
||||
}
|
||||
const res = await ShopService.getShops(params)
|
||||
if (res.code === 0) {
|
||||
const items = res.data.items || []
|
||||
// 保留平铺列表用于搜索
|
||||
shopOptions.value = items
|
||||
// 构建树形数据用于创建对话框
|
||||
shopTreeData.value = buildTreeData(items)
|
||||
|
||||
// 加载顶级店铺用于级联选择
|
||||
const res2 = await ShopService.getShopsCascade({ parent_id: undefined })
|
||||
if (res2.code === 0) {
|
||||
shopCascadeOptions.value = (res2.data || []).map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.shop_name,
|
||||
leaf: !item.has_children
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Load shops failed:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 处理店铺选择变化
|
||||
const handleShopChange = (value: any) => {
|
||||
if (Array.isArray(value) && value.length > 0) {
|
||||
createForm.shop_id = value[value.length - 1]
|
||||
} else {
|
||||
createForm.shop_id = null
|
||||
}
|
||||
}
|
||||
|
||||
// 获取充值订单列表
|
||||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
@@ -590,12 +633,24 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const handleViewDetail = (row: AgentRecharge) => {
|
||||
router.push({
|
||||
name: 'AgentRechargeDetailRoute',
|
||||
params: { id: row.id }
|
||||
})
|
||||
}
|
||||
|
||||
// 获取操作按钮
|
||||
const getActions = (row: AgentRecharge) => {
|
||||
const actions: any[] = []
|
||||
|
||||
// 待支付且线下转账的订单可以确认支付
|
||||
if (row.status === 1 && row.payment_method === 'offline' && hasAuth('agent_recharge:confirm_payment')) {
|
||||
if (
|
||||
row.status === 1 &&
|
||||
row.payment_method === 'offline' &&
|
||||
hasAuth('agent_recharge:confirm_payment')
|
||||
) {
|
||||
actions.push({
|
||||
label: '确认支付',
|
||||
handler: () => handleShowConfirmPay(row),
|
||||
|
||||
Reference in New Issue
Block a user