This commit is contained in:
177
src/api/modules/businessOptions.ts
Normal file
177
src/api/modules/businessOptions.ts
Normal file
@@ -0,0 +1,177 @@
|
||||
import { PackageManageService } from './packageManage'
|
||||
import { PackageSeriesService } from './packageSeries'
|
||||
import { ShopService } from './shop'
|
||||
import { CardService } from './card'
|
||||
import { DeviceService } from './device'
|
||||
import { AccountService } from './account'
|
||||
import { PackageSilenceService } from './packageSilence'
|
||||
import { gatewayData, gatewayError } from '@/utils/business/gateway'
|
||||
|
||||
export type BusinessOptionKind =
|
||||
| 'asset'
|
||||
| 'card'
|
||||
| 'package'
|
||||
| 'series'
|
||||
| 'shop'
|
||||
| 'usage'
|
||||
| 'account'
|
||||
export interface BusinessOption {
|
||||
value: string | number
|
||||
label: string
|
||||
}
|
||||
export interface BusinessOptionPage {
|
||||
options: BusinessOption[]
|
||||
hasMore: boolean
|
||||
warning?: string
|
||||
}
|
||||
export const BUSINESS_OPTION_LABELS: Record<BusinessOptionKind, string> = {
|
||||
asset: '资产',
|
||||
card: '网卡',
|
||||
package: '套餐',
|
||||
series: '套餐系列',
|
||||
shop: '店铺',
|
||||
usage: '套餐记录',
|
||||
account: '操作人'
|
||||
}
|
||||
|
||||
export async function searchBusinessOptions(
|
||||
kind: BusinessOptionKind,
|
||||
keyword: string,
|
||||
page = 1,
|
||||
context: { asset_identifier?: string; package_id?: number } = {}
|
||||
): Promise<BusinessOptionPage> {
|
||||
const pagination = { page, page_size: 20 },
|
||||
name = keyword.trim()
|
||||
const result = (
|
||||
data: { items?: unknown[] | null; total?: number },
|
||||
options: BusinessOption[]
|
||||
) => ({
|
||||
options,
|
||||
hasMore:
|
||||
typeof data.total === 'number'
|
||||
? page * pagination.page_size < data.total
|
||||
: (data.items?.length || 0) >= pagination.page_size
|
||||
})
|
||||
if (kind === 'package') {
|
||||
const data = gatewayData(
|
||||
await PackageManageService.getPackages({ ...pagination, package_name: name })
|
||||
)
|
||||
return result(
|
||||
data,
|
||||
(data.items || []).map((x) => ({ value: x.id, label: x.package_name }))
|
||||
)
|
||||
}
|
||||
if (kind === 'series') {
|
||||
const data = gatewayData(
|
||||
await PackageSeriesService.getPackageSeries({ ...pagination, series_name: name })
|
||||
)
|
||||
return result(
|
||||
data,
|
||||
(data.items || []).map((x) => ({ value: x.id, label: x.series_name }))
|
||||
)
|
||||
}
|
||||
if (kind === 'shop') {
|
||||
const data = gatewayData(await ShopService.getShops({ ...pagination, shop_name: name }))
|
||||
return result(
|
||||
data,
|
||||
(data.items || []).map((x) => ({ value: x.id, label: x.shop_name }))
|
||||
)
|
||||
}
|
||||
if (kind === 'account') {
|
||||
const data = gatewayData(await AccountService.getAccounts({ ...pagination, username: name }))
|
||||
return result(
|
||||
data,
|
||||
(data.items || []).flatMap((x) => {
|
||||
const value = x.id ?? x.ID
|
||||
return value == null
|
||||
? []
|
||||
: [{ value, label: [x.username, x.shop_name].filter(Boolean).join(' · ') }]
|
||||
})
|
||||
)
|
||||
}
|
||||
if (kind === 'usage') {
|
||||
const data = gatewayData(
|
||||
await PackageSilenceService.usages({
|
||||
...pagination,
|
||||
view: 'all',
|
||||
...context,
|
||||
asset_identifier: name || context.asset_identifier
|
||||
})
|
||||
)
|
||||
return result(
|
||||
data,
|
||||
(data.items || []).flatMap((x) =>
|
||||
x.package_usage_id == null
|
||||
? []
|
||||
: [
|
||||
{
|
||||
value: x.package_usage_id,
|
||||
label: [
|
||||
x.package_name || '未命名套餐',
|
||||
x.asset_identifier,
|
||||
x.order_no || x.created_at
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ')
|
||||
}
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
const cards = async () => {
|
||||
const data = gatewayData(
|
||||
await CardService.getStandaloneIotCards({ ...pagination, keyword: name })
|
||||
)
|
||||
return result(
|
||||
data,
|
||||
(data.items || [])
|
||||
.filter((x) => x.iccid)
|
||||
.map((x) => ({
|
||||
value: kind === 'card' ? x.id : x.iccid,
|
||||
label: [x.iccid, x.virtual_no, x.shop_name].filter(Boolean).join(' · ')
|
||||
}))
|
||||
)
|
||||
}
|
||||
if (kind === 'card') return cards()
|
||||
const devices = async () => {
|
||||
const data = gatewayData(await DeviceService.getDevices({ ...pagination, keyword: name }))
|
||||
return result(
|
||||
data,
|
||||
(data.items || [])
|
||||
.filter((x) => x.virtual_no)
|
||||
.map((x) => ({
|
||||
value: x.virtual_no,
|
||||
label: [x.virtual_no, x.device_name, x.imei, x.shop_name].filter(Boolean).join(' · ')
|
||||
}))
|
||||
)
|
||||
}
|
||||
const results = await Promise.allSettled([cards(), devices()])
|
||||
const pages = results.flatMap((x) => (x.status === 'fulfilled' ? [x.value] : []))
|
||||
const failures = results.flatMap((x, index) =>
|
||||
x.status === 'rejected'
|
||||
? [`${index === 0 ? '网卡' : '设备'}选项加载失败:${gatewayError(x.reason)}`]
|
||||
: []
|
||||
)
|
||||
if (!pages.length) throw new Error(failures.join(';'))
|
||||
return {
|
||||
options: pages.flatMap((x) => x.options),
|
||||
hasMore: pages.some((x) => x.hasMore),
|
||||
...(failures.length ? { warning: failures.join(';') } : {})
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑已有政策时按详情补回名称,不用裸 ID 充当选项文案。
|
||||
export async function resolveBusinessOption(
|
||||
kind: BusinessOptionKind,
|
||||
value: number
|
||||
): Promise<BusinessOption> {
|
||||
if (kind === 'package') {
|
||||
const data = gatewayData(await PackageManageService.getPackageDetail(value))
|
||||
return { value, label: data.package_name }
|
||||
}
|
||||
if (kind === 'series') {
|
||||
const data = gatewayData(await PackageSeriesService.getPackageSeriesDetail(value))
|
||||
return { value, label: data.series_name }
|
||||
}
|
||||
throw new Error('不支持补全此选项')
|
||||
}
|
||||
@@ -13,6 +13,15 @@ import type {
|
||||
} from '@/types/api'
|
||||
|
||||
export class OrderService extends BaseService {
|
||||
static getPlatformOrders(params?: OrderQueryParams): Promise<BaseResponse<OrderListResponse>> {
|
||||
return this.get('/api/admin/orders/platform', params)
|
||||
}
|
||||
static getAgentOrders(params?: OrderQueryParams): Promise<BaseResponse<OrderListResponse>> {
|
||||
return this.get('/api/admin/orders/agent', params)
|
||||
}
|
||||
static getOnlineOrders(params?: OrderQueryParams): Promise<BaseResponse<OrderListResponse>> {
|
||||
return this.get('/api/admin/orders/online', params)
|
||||
}
|
||||
/**
|
||||
* 获取订单列表
|
||||
* @param params 查询参数
|
||||
|
||||
116
src/api/modules/packageSilence.ts
Normal file
116
src/api/modules/packageSilence.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import { BaseService } from '../BaseService'
|
||||
import type { BaseResponse } from '@/types/api/common'
|
||||
import type { SilenceSwitchState } from '@/types/api/packageSilence'
|
||||
import type {
|
||||
AssetFirstPurchaseRecordResponse,
|
||||
SilenceBatchPageResult,
|
||||
SilenceBatchResponse,
|
||||
SilenceEligibilityResponse,
|
||||
SilenceExceptionHandleParams,
|
||||
SilenceExtensionResponse,
|
||||
SilenceOrderPageResult,
|
||||
SilenceExtensionOrderResponse,
|
||||
SilenceOfflineOrderRequest,
|
||||
SilenceOnlineOrderRequest,
|
||||
SilenceQuoteResponse,
|
||||
SilenceSpecialRequest,
|
||||
SilencePolicyResponse,
|
||||
SilencePolicyRequest,
|
||||
SilencePolicyUpdateParams,
|
||||
SilencePolicyMatchResponse,
|
||||
SilenceRecordResponse,
|
||||
SilenceUsagePageResult,
|
||||
SilenceOrderQuery,
|
||||
SilenceBatchQuery,
|
||||
SilenceUsageQuery,
|
||||
SilencePolicyQuery
|
||||
} from '@/types/api/packageSilenceContract'
|
||||
|
||||
const root = '/api/admin/package-silence'
|
||||
const quiet = { requestOptions: { errorMessageMode: 'none' } }
|
||||
|
||||
export class PackageSilenceService extends BaseService {
|
||||
static eligibility(package_usage_id: number): Promise<BaseResponse<SilenceEligibilityResponse>> {
|
||||
return this.get(`${root}/eligibility`, { package_usage_id }, quiet)
|
||||
}
|
||||
static quote(
|
||||
package_usage_id: number,
|
||||
days: number
|
||||
): Promise<BaseResponse<SilenceQuoteResponse>> {
|
||||
return this.get(`${root}/quote`, { package_usage_id, days }, quiet)
|
||||
}
|
||||
static createQrcode(
|
||||
data: SilenceOnlineOrderRequest
|
||||
): Promise<BaseResponse<SilenceExtensionOrderResponse>> {
|
||||
return this.post(`${root}/orders/qrcode`, data, quiet)
|
||||
}
|
||||
static createOffline(
|
||||
data: SilenceOfflineOrderRequest
|
||||
): Promise<BaseResponse<SilenceExtensionOrderResponse>> {
|
||||
return this.post(`${root}/orders/offline`, data, quiet)
|
||||
}
|
||||
static special(data: SilenceSpecialRequest): Promise<BaseResponse<SilenceBatchResponse>> {
|
||||
return this.post(`${root}/special`, data, quiet)
|
||||
}
|
||||
static orders(params: SilenceOrderQuery): Promise<BaseResponse<SilenceOrderPageResult>> {
|
||||
return this.get(`${root}/orders`, params, quiet)
|
||||
}
|
||||
static order(id: number): Promise<BaseResponse<SilenceExtensionOrderResponse>> {
|
||||
return this.get(`${root}/orders/${id}`, undefined, quiet)
|
||||
}
|
||||
static batches(params: SilenceBatchQuery): Promise<BaseResponse<SilenceBatchPageResult>> {
|
||||
return this.get(`${root}/batches`, params, quiet)
|
||||
}
|
||||
static batch(id: number): Promise<BaseResponse<SilenceBatchResponse>> {
|
||||
return this.get(`${root}/batches/${id}`, undefined, quiet)
|
||||
}
|
||||
static handle(
|
||||
id: number,
|
||||
data: SilenceExceptionHandleParams
|
||||
): Promise<BaseResponse<SilenceExtensionResponse>> {
|
||||
return this.post(`${root}/extensions/${id}/handle`, data, quiet)
|
||||
}
|
||||
static usages(params: SilenceUsageQuery): Promise<BaseResponse<SilenceUsagePageResult>> {
|
||||
return this.get(`${root}/usages`, params, quiet)
|
||||
}
|
||||
static policies(params: SilencePolicyQuery = {}): Promise<BaseResponse<SilencePolicyResponse[]>> {
|
||||
return this.get(`${root}/policies`, params, quiet)
|
||||
}
|
||||
static policy(id: number): Promise<BaseResponse<SilencePolicyResponse>> {
|
||||
return this.get(`${root}/policies/${id}`, undefined, quiet)
|
||||
}
|
||||
static createPolicy(data: SilencePolicyRequest): Promise<BaseResponse<SilencePolicyResponse>> {
|
||||
return this.post(`${root}/policies`, data, quiet)
|
||||
}
|
||||
static updatePolicy(
|
||||
id: number,
|
||||
data: SilencePolicyUpdateParams
|
||||
): Promise<BaseResponse<SilencePolicyResponse>> {
|
||||
return this.put(`${root}/policies/${id}`, { ...data, id }, quiet)
|
||||
}
|
||||
static policyStatus(id: number, status: number): Promise<BaseResponse<SilencePolicyResponse>> {
|
||||
return this.put(`${root}/policies/${id}/status`, { id, status }, quiet)
|
||||
}
|
||||
static match(package_id: number): Promise<BaseResponse<SilencePolicyMatchResponse>> {
|
||||
return this.get(`${root}/policies/match`, { package_id }, quiet)
|
||||
}
|
||||
static records(package_usage_id: number): Promise<BaseResponse<SilenceRecordResponse[]>> {
|
||||
return this.get(`${root}/records`, { package_usage_id }, quiet)
|
||||
}
|
||||
static firstPurchase(
|
||||
assetType: 'card' | 'device',
|
||||
id: number
|
||||
): Promise<BaseResponse<AssetFirstPurchaseRecordResponse[]>> {
|
||||
return this.get(`/api/admin/assets/${assetType}/${id}/first-purchase-records`, undefined, quiet)
|
||||
}
|
||||
static getSwitch(): Promise<BaseResponse<SilenceSwitchState>> {
|
||||
return this.get('/api/admin/package-silence/switch')
|
||||
}
|
||||
static setSwitch(enabled: boolean): Promise<BaseResponse<unknown>> {
|
||||
return this.put(
|
||||
'/api/admin/package-silence/switch',
|
||||
{ enabled },
|
||||
{ requestOptions: { errorMessageMode: 'none' } }
|
||||
)
|
||||
}
|
||||
}
|
||||
32
src/api/modules/packageSilenceValidation.ts
Normal file
32
src/api/modules/packageSilenceValidation.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { PackageManageService } from './packageManage'
|
||||
import {
|
||||
assertSilenceResponse,
|
||||
validateSilenceExpiryOverride
|
||||
} from '@/utils/business/packageSilence'
|
||||
|
||||
// 复用既有套餐详情,不假设授权候选已携带新字段;全部校验完成后才写。
|
||||
export async function ensurePackageSilenceOverrides(
|
||||
items: { packageId: number | undefined; override?: string | null }[]
|
||||
) {
|
||||
const checks = items.filter((item) => item.override && item.override !== 'default')
|
||||
const packages = new Map<
|
||||
number,
|
||||
Awaited<ReturnType<typeof PackageManageService.getPackageDetail>>['data']
|
||||
>()
|
||||
for (let index = 0; index < checks.length; index += 4) {
|
||||
await Promise.all(
|
||||
checks.slice(index, index + 4).map(async (item) => {
|
||||
if (!Number.isSafeInteger(item.packageId) || Number(item.packageId) < 1)
|
||||
throw new Error('缺少套餐 ID,无法校验生效条件')
|
||||
const id = item.packageId!
|
||||
let pkg = packages.get(id)
|
||||
if (!pkg) {
|
||||
const response = assertSilenceResponse(await PackageManageService.getPackageDetail(id))
|
||||
pkg = response.data
|
||||
packages.set(id, pkg)
|
||||
}
|
||||
validateSilenceExpiryOverride(pkg, item.override)
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import { ensurePackageSilenceOverrides } from './packageSilenceValidation'
|
||||
import type {
|
||||
BaseResponse,
|
||||
CreateShopPackageBatchAllocationsRequest,
|
||||
@@ -17,9 +18,12 @@ export class ShopPackageAllocationService extends BaseService {
|
||||
* 创建店铺套餐分配
|
||||
* POST /api/admin/shop-package-allocations
|
||||
*/
|
||||
static createShopPackageAllocation(
|
||||
static async createShopPackageAllocation(
|
||||
data: CreateShopPackageAllocationRequest
|
||||
): Promise<BaseResponse<ShopPackageAllocationResponse>> {
|
||||
await ensurePackageSilenceOverrides([
|
||||
{ packageId: data.package_id, override: data.expiry_base_override }
|
||||
])
|
||||
return this.post<BaseResponse<ShopPackageAllocationResponse>>(
|
||||
'/api/admin/shop-package-allocations',
|
||||
data
|
||||
@@ -30,9 +34,12 @@ export class ShopPackageAllocationService extends BaseService {
|
||||
* 批量创建店铺套餐分配
|
||||
* POST /api/admin/shop-package-batch-allocations
|
||||
*/
|
||||
static createShopPackageBatchAllocations(
|
||||
static async createShopPackageBatchAllocations(
|
||||
data: CreateShopPackageBatchAllocationsRequest
|
||||
): Promise<BaseResponse<ShopPackageBatchAllocationsResponse>> {
|
||||
await ensurePackageSilenceOverrides(
|
||||
data.package_ids.map((packageId) => ({ packageId, override: data.expiry_base_override }))
|
||||
)
|
||||
return this.post<BaseResponse<ShopPackageBatchAllocationsResponse>>(
|
||||
'/api/admin/shop-package-batch-allocations',
|
||||
data
|
||||
@@ -43,10 +50,12 @@ export class ShopPackageAllocationService extends BaseService {
|
||||
* 更新店铺套餐分配生效条件
|
||||
* PATCH /api/admin/shop-package-allocations/{id}/expiry-base
|
||||
*/
|
||||
static updateShopPackageAllocationExpiryBase(
|
||||
static async updateShopPackageAllocationExpiryBase(
|
||||
id: number,
|
||||
data: UpdateShopPackageAllocationExpiryBaseRequest
|
||||
data: UpdateShopPackageAllocationExpiryBaseRequest,
|
||||
packageId?: number
|
||||
): Promise<BaseResponse<ShopPackageAllocationResponse>> {
|
||||
await ensurePackageSilenceOverrides([{ packageId, override: data.expiry_base_override }])
|
||||
return this.patch<BaseResponse<ShopPackageAllocationResponse>>(
|
||||
`/api/admin/shop-package-allocations/${id}/expiry-base`,
|
||||
data
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import { BaseService } from '../BaseService'
|
||||
import { ensurePackageSilenceOverrides } from './packageSilenceValidation'
|
||||
import type {
|
||||
ShopSeriesGrantResponse,
|
||||
ShopSeriesGrantQueryParams,
|
||||
@@ -31,9 +32,20 @@ export class ShopSeriesGrantService extends BaseService {
|
||||
* POST /api/admin/shop-series-grants
|
||||
* @param data 授权数据
|
||||
*/
|
||||
static createShopSeriesGrant(
|
||||
static async createShopSeriesGrant(
|
||||
data: CreateShopSeriesGrantRequest
|
||||
): Promise<BaseResponse<ShopSeriesGrantResponse>> {
|
||||
await ensurePackageSilenceOverrides(
|
||||
data.packages
|
||||
.filter((item) => !item.remove)
|
||||
.map((item) => ({
|
||||
packageId: item.package_id,
|
||||
override:
|
||||
item.expiry_base_override === undefined
|
||||
? data.expiry_base_override
|
||||
: item.expiry_base_override
|
||||
}))
|
||||
)
|
||||
return this.create<ShopSeriesGrantResponse>('/api/admin/shop-series-grants', data)
|
||||
}
|
||||
|
||||
@@ -88,10 +100,21 @@ export class ShopSeriesGrantService extends BaseService {
|
||||
* @param id 授权ID
|
||||
* @param data 套餐管理数据
|
||||
*/
|
||||
static manageGrantPackages(
|
||||
static async manageGrantPackages(
|
||||
id: number,
|
||||
data: ManageGrantPackagesRequest
|
||||
): Promise<BaseResponse<ShopSeriesGrantResponse>> {
|
||||
await ensurePackageSilenceOverrides(
|
||||
data.packages
|
||||
.filter((item) => !item.remove)
|
||||
.map((item) => ({
|
||||
packageId: item.package_id,
|
||||
override:
|
||||
item.expiry_base_override === undefined
|
||||
? data.expiry_base_override
|
||||
: item.expiry_base_override
|
||||
}))
|
||||
)
|
||||
return this.put<BaseResponse<ShopSeriesGrantResponse>>(
|
||||
`/api/admin/shop-series-grants/${id}/packages`,
|
||||
data
|
||||
|
||||
198
src/components/business/BusinessEntitySelect.vue
Normal file
198
src/components/business/BusinessEntitySelect.vue
Normal file
@@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<ElSelect
|
||||
v-model="selection"
|
||||
class="business-entity-select"
|
||||
:multiple="multiple"
|
||||
:disabled="disabled || !allowed"
|
||||
:clearable="clearable"
|
||||
:placeholder="placeholder || `搜索并选择${entityLabel}`"
|
||||
filterable
|
||||
remote
|
||||
remote-show-suffix
|
||||
:remote-method="search"
|
||||
:loading="loading"
|
||||
:no-data-text="error || '暂无匹配结果,请更换关键词'"
|
||||
@visible-change="(visible) => visible && search('')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="option in options"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
:label="option.label"
|
||||
/>
|
||||
<template v-if="hasMore || error" #footer>
|
||||
<span v-if="error" role="alert">{{ error }}</span>
|
||||
<ElButton v-if="error" link :loading="loading" @click="load(1)">重试</ElButton>
|
||||
<ElButton v-else link :loading="loading" @click="load(page + 1)">加载更多</ElButton>
|
||||
</template>
|
||||
</ElSelect>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch, onActivated, onDeactivated, onBeforeUnmount } from 'vue'
|
||||
import {
|
||||
searchBusinessOptions,
|
||||
resolveBusinessOption,
|
||||
BUSINESS_OPTION_LABELS,
|
||||
type BusinessOptionKind,
|
||||
type BusinessOption
|
||||
} from '@/api/modules/businessOptions'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import { gatewayError } from '@/utils/business/gateway'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue?: string | number | (string | number)[] | null
|
||||
entity: BusinessOptionKind
|
||||
multiple?: boolean
|
||||
clearable?: boolean
|
||||
disabled?: boolean
|
||||
allowed?: boolean
|
||||
placeholder?: string
|
||||
context?: { asset_identifier?: string; package_id?: number }
|
||||
includeSystem?: boolean
|
||||
}>(),
|
||||
{ clearable: true, allowed: true }
|
||||
)
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: string | number | (string | number)[] | undefined]
|
||||
}>()
|
||||
const user = useUserStore(),
|
||||
candidates = ref<BusinessOption[]>([]),
|
||||
retained = ref<BusinessOption[]>([])
|
||||
const loading = ref(false),
|
||||
error = ref(''),
|
||||
hasMore = ref(false),
|
||||
page = ref(1),
|
||||
keyword = ref('')
|
||||
const entityLabel = computed(() => BUSINESS_OPTION_LABELS[props.entity])
|
||||
const selection = computed({
|
||||
get: () => props.modelValue ?? undefined,
|
||||
set: (value) => {
|
||||
const selected = Array.isArray(value) ? value : [value]
|
||||
retained.value = options.value.filter((x) => selected.includes(x.value))
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
})
|
||||
const options = computed(() => {
|
||||
const selected = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue]
|
||||
const merged = new Map(
|
||||
[...retained.value.filter((x) => selected.includes(x.value)), ...candidates.value].map(
|
||||
(x) => [x.value, x]
|
||||
)
|
||||
)
|
||||
if (props.entity === 'account' && props.includeSystem)
|
||||
merged.set(0, { value: 0, label: '系统' })
|
||||
for (const value of selected) {
|
||||
if (value == null || value === '' || merged.has(value)) continue
|
||||
merged.set(value, {
|
||||
value,
|
||||
label:
|
||||
typeof value === 'string' && props.entity === 'asset'
|
||||
? value
|
||||
: `${entityLabel.value}名称待加载`
|
||||
})
|
||||
}
|
||||
return [...merged.values()]
|
||||
})
|
||||
let active = true,
|
||||
sequence = 0,
|
||||
version = 0
|
||||
async function search(value: string) {
|
||||
keyword.value = value
|
||||
await load(1)
|
||||
}
|
||||
async function load(nextPage: number) {
|
||||
if (!active || !props.allowed || props.disabled) return
|
||||
const current = ++sequence,
|
||||
currentVersion = version
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const result = await searchBusinessOptions(
|
||||
props.entity,
|
||||
keyword.value,
|
||||
nextPage,
|
||||
props.context
|
||||
)
|
||||
if (!active || current !== sequence || currentVersion !== version) return
|
||||
const selected = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue]
|
||||
retained.value = options.value.filter((x) => selected.includes(x.value))
|
||||
candidates.value = nextPage === 1 ? result.options : [...candidates.value, ...result.options]
|
||||
page.value = nextPage
|
||||
hasMore.value = result.hasMore
|
||||
error.value = result.warning || ''
|
||||
} catch (e) {
|
||||
if (active && current === sequence && currentVersion === version)
|
||||
error.value = gatewayError(e)
|
||||
} finally {
|
||||
if (current === sequence) loading.value = false
|
||||
}
|
||||
}
|
||||
async function hydrate() {
|
||||
if (!active || !props.allowed || !['package', 'series'].includes(props.entity)) return
|
||||
const currentVersion = version
|
||||
const values = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue]
|
||||
await Promise.all(
|
||||
values.map(async (value) => {
|
||||
if (typeof value !== 'number' || retained.value.some((x) => x.value === value)) return
|
||||
let option: BusinessOption
|
||||
try {
|
||||
option = await resolveBusinessOption(props.entity, value)
|
||||
} catch {
|
||||
option = { value, label: `${entityLabel.value}名称加载失败` }
|
||||
}
|
||||
if (active && currentVersion === version) retained.value.push(option)
|
||||
})
|
||||
)
|
||||
}
|
||||
function invalidate() {
|
||||
version++
|
||||
sequence++
|
||||
candidates.value = []
|
||||
retained.value = []
|
||||
loading.value = false
|
||||
error.value = ''
|
||||
hasMore.value = false
|
||||
page.value = 1
|
||||
keyword.value = ''
|
||||
}
|
||||
watch(
|
||||
() => [
|
||||
props.entity,
|
||||
props.allowed,
|
||||
props.disabled,
|
||||
pollingScope(user),
|
||||
JSON.stringify(props.context)
|
||||
],
|
||||
() => {
|
||||
invalidate()
|
||||
void hydrate()
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
() => void hydrate(),
|
||||
{ immediate: true }
|
||||
)
|
||||
onDeactivated(() => {
|
||||
active = false
|
||||
version++
|
||||
sequence++
|
||||
loading.value = false
|
||||
})
|
||||
onActivated(() => {
|
||||
active = true
|
||||
void hydrate()
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
active = false
|
||||
invalidate()
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
.business-entity-select {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -117,6 +117,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { assertSilenceResponse } from '@/utils/business/packageSilence'
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
@@ -356,7 +357,15 @@
|
||||
} else if (formData.refund_voucher_key.length) {
|
||||
data.refund_voucher_key = formData.refund_voucher_key
|
||||
}
|
||||
await RefundService.createRefund(data)
|
||||
const response = await RefundService.createRefund(data)
|
||||
if (response.code !== 0) {
|
||||
try {
|
||||
assertSilenceResponse(response)
|
||||
} catch (error) {
|
||||
ElMessage.error(error instanceof Error ? error.message : '退款申请失败')
|
||||
}
|
||||
return
|
||||
}
|
||||
ElMessage.success('退款申请创建成功')
|
||||
dialogVisible.value = false
|
||||
emit('success')
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
import { ExportTaskService } from '@/api/modules'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { getExportTaskSceneName } from '@/config/constants'
|
||||
import { isPollingPlatformExport } from '@/config/constants/exportTask'
|
||||
import { isPollingPlatformExport, canAccessExportTaskScene } from '@/config/constants/exportTask'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { isPollingPlatform } from '@/utils/business/pollingScheduler'
|
||||
import type { CreateExportTaskResponse, ExportTaskFormat, ExportTaskScene } from '@/types/api'
|
||||
@@ -89,14 +89,21 @@
|
||||
}
|
||||
)
|
||||
|
||||
const getNormalizedQuery = (): Record<string, string> => {
|
||||
const query: Record<string, string> = {}
|
||||
const getNormalizedQuery = (): Record<string, string | Record<string, unknown>> => {
|
||||
const query: Record<string, string | Record<string, unknown>> = {}
|
||||
|
||||
Object.entries(props.query || {}).forEach(([key, value]) => {
|
||||
if (value === undefined || value === null || value === '') return
|
||||
if (Array.isArray(value) && value.length === 0) return
|
||||
|
||||
if (typeof value === 'string') {
|
||||
if (
|
||||
key === 'filters' &&
|
||||
['order_platform', 'order_agent', 'order_online'].includes(props.scene) &&
|
||||
typeof value === 'object' &&
|
||||
!Array.isArray(value)
|
||||
) {
|
||||
query[key] = value as Record<string, unknown>
|
||||
} else if (typeof value === 'string') {
|
||||
query[key] = value
|
||||
} else if (typeof value === 'number' || typeof value === 'boolean') {
|
||||
query[key] = String(value)
|
||||
@@ -111,6 +118,10 @@
|
||||
}
|
||||
|
||||
const submit = async () => {
|
||||
if (!canAccessExportTaskScene(props.scene, user.info.user_type)) {
|
||||
ElMessage.warning('当前账号无权导出该类订单')
|
||||
return
|
||||
}
|
||||
if (isPollingPlatformExport(props.scene) && !isPollingPlatform(user.info.user_type)) {
|
||||
ElMessage.warning('仅平台账号可创建该导出任务')
|
||||
return
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { canEditRestrictedAsset } from '@/utils/business/packageSilence'
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
@@ -79,10 +81,11 @@
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!canEditRestrictedAsset(useUserStore().info.user_type)) return
|
||||
if (!formRef.value) return
|
||||
|
||||
await formRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
if (valid && canEditRestrictedAsset(useUserStore().info.user_type)) {
|
||||
submitLoading.value = true
|
||||
try {
|
||||
await AssetService.updateRealnameStatus(props.assetIdentifier, {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<div
|
||||
>{{ time ? formatDateTime(time) : '-' }}
|
||||
<ElButton v-if="assetId" link type="primary" @click="visible = true">记录</ElButton></div
|
||||
>
|
||||
<SilenceRecordsDialog
|
||||
v-if="visible"
|
||||
:asset-id="assetId"
|
||||
:asset-type="assetType"
|
||||
@close="visible = false"
|
||||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import SilenceRecordsDialog from './SilenceRecordsDialog.vue'
|
||||
const props = defineProps<{
|
||||
assetId: number
|
||||
assetType: 'card' | 'device'
|
||||
time?: string | null
|
||||
}>(),
|
||||
visible = ref(false)
|
||||
watch(
|
||||
() => [props.assetId, props.assetType],
|
||||
() => {
|
||||
visible.value = false
|
||||
}
|
||||
)
|
||||
</script>
|
||||
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<template v-if="packageType === 'formal'">
|
||||
<ElFormItem label="默认沉默期(天)" :required="required || expiryBase === 'from_activation'">
|
||||
<ElInputNumber
|
||||
v-model="days"
|
||||
:precision="0"
|
||||
:controls="false"
|
||||
placeholder="1–90 天;购买即生效可留空"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="支持付费延期"><ElSwitch v-model="enabled" /></ElFormItem>
|
||||
</template>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
defineProps<{ packageType: string; expiryBase?: string; required?: boolean }>()
|
||||
const days = defineModel<number | null>('days', { required: true })
|
||||
const enabled = defineModel<boolean>('enabled', { required: true })
|
||||
</script>
|
||||
284
src/components/business/package-silence/SilenceDetail.vue
Normal file
284
src/components/business/package-silence/SilenceDetail.vue
Normal file
@@ -0,0 +1,284 @@
|
||||
<template>
|
||||
<ElCard shadow="never" class="silence-detail">
|
||||
<div class="detail-header"
|
||||
><ElButton @click="router.back()">返回</ElButton
|
||||
><h2>{{ kind === 'orders' ? '延期订单详情' : '延期批次详情' }}</h2
|
||||
><ElButton :loading="loading" @click="load">刷新</ElButton></div
|
||||
>
|
||||
<ElAlert
|
||||
v-if="error || actionError"
|
||||
:title="error || actionError"
|
||||
type="error"
|
||||
:closable="false"
|
||||
/>
|
||||
<template v-if="data">
|
||||
<ElDescriptions :column="width < 640 ? 1 : 2" border
|
||||
><ElDescriptionsItem v-for="field in fields" :key="field.prop" :label="field.label">{{
|
||||
silenceDisplay(data, field.prop)
|
||||
}}</ElDescriptionsItem></ElDescriptions
|
||||
>
|
||||
<div
|
||||
v-if="kind === 'orders' && data.status === 'pending_payment' && data.qr_content"
|
||||
class="silence-qr"
|
||||
><QrcodeVue :value="data.qr_content" :size="200" /><p
|
||||
>支付截止:{{ data.expire_at ? formatDateTime(data.expire_at) : '-' }}</p
|
||||
></div
|
||||
>
|
||||
<ElAlert
|
||||
v-if="kind === 'orders' && data.status === 'pending_approval'"
|
||||
title="审批中,尚未生效。请以订单完成状态及实际截止日为准。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
/>
|
||||
<ElButton v-if="data.package_usage_id" @click="recordsId = data.package_usage_id"
|
||||
>沉默期流水</ElButton
|
||||
>
|
||||
<SilenceTable
|
||||
v-if="kind === 'batches'"
|
||||
:rows="data.items || []"
|
||||
:definitions="itemFields"
|
||||
@refresh="load"
|
||||
><ElTableColumn label="异常处理" width="190"
|
||||
><template #default="{ row }"
|
||||
><template
|
||||
v-if="
|
||||
allowed &&
|
||||
hasAuth(P.exception) &&
|
||||
(row.failure_code || row.failure_summary || row.status === 'exception')
|
||||
"
|
||||
><ElButton link :disabled="handling" @click="handle(row, 'retry')">重试</ElButton
|
||||
><ElButton link type="danger" :disabled="handling" @click="handle(row, 'close')"
|
||||
>关闭</ElButton
|
||||
></template
|
||||
></template
|
||||
></ElTableColumn
|
||||
></SilenceTable
|
||||
>
|
||||
<h3 v-if="data.evidence_refs?.length">申请依据</h3
|
||||
><PaymentVoucherDialog
|
||||
v-if="data.evidence_refs?.length"
|
||||
inline
|
||||
:file-keys="data.evidence_refs"
|
||||
/>
|
||||
<h3 v-if="data.payment_voucher_keys?.length">付款凭证</h3
|
||||
><PaymentVoucherDialog
|
||||
v-if="data.payment_voucher_keys?.length"
|
||||
inline
|
||||
:file-keys="data.payment_voucher_keys"
|
||||
/>
|
||||
</template>
|
||||
<SilenceRecordsDialog
|
||||
v-if="recordsId"
|
||||
:usage-id="recordsId"
|
||||
:allowed="allowed"
|
||||
@close="recordsId = undefined"
|
||||
/>
|
||||
</ElCard>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, onMounted, onBeforeUnmount, onDeactivated, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import QrcodeVue from 'qrcode.vue'
|
||||
import { PackageSilenceService as Service } from '@/api/modules/packageSilence'
|
||||
import {
|
||||
SILENCE_PAGES,
|
||||
PACKAGE_SILENCE_PERMISSIONS as P
|
||||
} from '@/config/constants/packageSilence'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { useSchedulerRequest } from '@/composables/useSchedulerRequest'
|
||||
import { silenceData, silenceDisplay, silenceId } from '@/utils/business/silenceExtension'
|
||||
import { pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import { gatewayError, requireGatewayAccess } from '@/utils/business/gateway'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import PaymentVoucherDialog from '@/components/business/PaymentVoucherDialog.vue'
|
||||
import SilenceRecordsDialog from './SilenceRecordsDialog.vue'
|
||||
import SilenceTable from './SilenceTable.vue'
|
||||
const props = defineProps<{ kind: 'orders' | 'batches' }>(),
|
||||
route = useRoute(),
|
||||
router = useRouter(),
|
||||
{ width } = useWindowSize(),
|
||||
{ hasAuth } = useAuth(),
|
||||
user = useUserStore()
|
||||
const allowed = computed(() => {
|
||||
const p = SILENCE_PAGES[props.kind]
|
||||
return hasAuth(p.page) && hasAuth(p.detailPage) && hasAuth(p.detail)
|
||||
})
|
||||
const { data, error, loading, load } = useSchedulerRequest<Record<string, any>>(
|
||||
async () => {
|
||||
const id = silenceId(Number(route.params.id))
|
||||
return props.kind === 'orders'
|
||||
? silenceData(await Service.order(id))
|
||||
: silenceData(await Service.batch(id))
|
||||
},
|
||||
() => allowed.value
|
||||
)
|
||||
const recordsId = ref<number>(),
|
||||
actionError = ref(''),
|
||||
handling = ref(false)
|
||||
const maps = {
|
||||
orders: [
|
||||
['order_no', '订单号'],
|
||||
['status_name', '状态'],
|
||||
['asset_identifier', '资产'],
|
||||
['package_name', '套餐'],
|
||||
['package_usage_id', '套餐记录 ID'],
|
||||
['source_name', '来源'],
|
||||
['input_days', '输入天数'],
|
||||
['extension_days', '实际延长天数'],
|
||||
['amount', '应付金额'],
|
||||
['paid_amount', '实收金额'],
|
||||
['payment_method', '支付方式'],
|
||||
['payment_merchant_name', '收款商户'],
|
||||
['third_party_trade_no', '交易流水号'],
|
||||
['offline_payment_method_name', '线下收款方式'],
|
||||
['offline_trade_no', '线下交易单号'],
|
||||
['paid_at', '支付时间'],
|
||||
['before_deadline_at', '原截止时间'],
|
||||
['expected_deadline_at', '预计新截止'],
|
||||
['completed_at', '实际生效时间'],
|
||||
['policy_name', '政策快照'],
|
||||
['approval_required', '需要审批'],
|
||||
['approval_instance_id', '审批实例'],
|
||||
['exception_code', '异常码'],
|
||||
['exception_summary', '异常说明'],
|
||||
['refund_no', '退款单号'],
|
||||
['refund_amount', '退款金额'],
|
||||
['refunded_at', '退款时间'],
|
||||
['created_at', '创建时间']
|
||||
],
|
||||
batches: [
|
||||
['batch_no', '批次号'],
|
||||
['path', '办理路径'],
|
||||
['extension_type', '延期类型'],
|
||||
['status', '批次状态'],
|
||||
['approval_required', '需要审批'],
|
||||
['approval_status', '审批状态'],
|
||||
['approval_instance_id', '审批实例'],
|
||||
['reason', '原因'],
|
||||
['basis', '依据'],
|
||||
['amount', '费用合计'],
|
||||
['requested_count', '明细数'],
|
||||
['succeeded_count', '成功数'],
|
||||
['failed_count', '失败数'],
|
||||
['requested_by', '发起人'],
|
||||
['requested_at', '发起时间'],
|
||||
['completed_at', '完成时间']
|
||||
]
|
||||
}
|
||||
const fields = computed(() => maps[props.kind].map(([prop, label]) => ({ prop, label })))
|
||||
const itemFields = [
|
||||
['row_no', '行号'],
|
||||
['id', '明细 ID'],
|
||||
['asset_identifier', '资产标识'],
|
||||
['package_name', '套餐'],
|
||||
['extension_type', '延期类型'],
|
||||
['extension_days', '延长天数'],
|
||||
['amount', '金额'],
|
||||
['status', '明细状态'],
|
||||
['before_deadline_at', '原截止'],
|
||||
['after_deadline_at', '实际新截止'],
|
||||
['executed_at', '执行时间'],
|
||||
['failure_code', '异常码'],
|
||||
['failure_summary', '异常原因']
|
||||
].map(([prop, label]) => ({ prop, label }))
|
||||
let timer: ReturnType<typeof setTimeout> | undefined,
|
||||
active = true
|
||||
function stop() {
|
||||
if (timer) clearTimeout(timer)
|
||||
timer = undefined
|
||||
}
|
||||
watch(data, (value) => {
|
||||
stop()
|
||||
if (
|
||||
active &&
|
||||
props.kind === 'orders' &&
|
||||
['pending_payment', 'paid'].includes(value?.status) &&
|
||||
allowed.value
|
||||
)
|
||||
timer = setTimeout(() => void load(), 3000)
|
||||
})
|
||||
watch(
|
||||
() => [route.fullPath, allowed.value, pollingScope(user)],
|
||||
() => {
|
||||
stop()
|
||||
recordsId.value = undefined
|
||||
actionError.value = ''
|
||||
void load()
|
||||
}
|
||||
)
|
||||
async function handle(row: Record<string, any>, action: 'retry' | 'close') {
|
||||
if (handling.value) return
|
||||
const scope = pollingScope(user),
|
||||
path = route.fullPath,
|
||||
id = silenceId(row.id)
|
||||
handling.value = true
|
||||
try {
|
||||
requireGatewayAccess(allowed.value && hasAuth(P.exception))
|
||||
const { value } = await ElMessageBox.prompt(
|
||||
action === 'close'
|
||||
? '填写关闭原因。在线订单关闭可能按冻结商户原路退款,请确认后继续。'
|
||||
: '填写重试原因,将按原快照重新执行。',
|
||||
'异常处理',
|
||||
{ inputValidator: (value) => !!value?.trim() || '请填写原因', type: 'warning' }
|
||||
)
|
||||
requireGatewayAccess(
|
||||
active &&
|
||||
allowed.value &&
|
||||
hasAuth(P.exception) &&
|
||||
scope === pollingScope(user) &&
|
||||
path === route.fullPath
|
||||
)
|
||||
silenceData(await Service.handle(id, { id, action, reason: value.trim() }))
|
||||
if (active && scope === pollingScope(user) && path === route.fullPath) await load()
|
||||
} catch (e) {
|
||||
if (active && e !== 'cancel' && e !== 'close') actionError.value = gatewayError(e)
|
||||
} finally {
|
||||
handling.value = false
|
||||
}
|
||||
}
|
||||
onMounted(load)
|
||||
onDeactivated(() => {
|
||||
active = false
|
||||
stop()
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
active = false
|
||||
stop()
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
.silence-detail {
|
||||
margin: 16px;
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.detail-header h2 {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.silence-qr {
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
:deep(.el-descriptions__cell) {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@media (width <= 640px) {
|
||||
.silence-detail {
|
||||
margin: 4px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
595
src/components/business/package-silence/SilenceExtendDialog.vue
Normal file
595
src/components/business/package-silence/SilenceExtendDialog.vue
Normal file
@@ -0,0 +1,595 @@
|
||||
<template>
|
||||
<ElDialog
|
||||
:model-value="true"
|
||||
title="办理沉默期延期"
|
||||
width="min(760px, 96vw)"
|
||||
destroy-on-close
|
||||
@close="$emit('close')"
|
||||
>
|
||||
<ElAlert
|
||||
title="金额和延期截止时间以服务端试算及处理结果为准;待审批或已支付不代表延期已生效。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/>
|
||||
<ElAlert
|
||||
v-if="error || eligibilityError"
|
||||
:title="error || eligibilityError"
|
||||
type="error"
|
||||
:closable="false"
|
||||
/>
|
||||
<ElForm label-width="140px" :disabled="submitting || !!order || !!batch">
|
||||
<ElFormItem label="办理方式"
|
||||
><ElSelect v-model="mode"
|
||||
><ElOption
|
||||
v-if="hasAuth(P.extend) && usageId"
|
||||
value="online"
|
||||
label="扫码付费延期" /><ElOption
|
||||
v-if="hasAuth(P.offline) && usageId"
|
||||
value="offline"
|
||||
label="登记线下付款" /><ElOption
|
||||
v-if="hasAuth(P.extend)"
|
||||
value="special"
|
||||
label="特殊延期" /></ElSelect
|
||||
></ElFormItem>
|
||||
<template v-if="usageId">
|
||||
<ElFormItem label="套餐记录"
|
||||
>{{ usageId }}
|
||||
<ElButton link :loading="eligibilityLoading" @click="loadEligibility"
|
||||
>刷新资格</ElButton
|
||||
></ElFormItem
|
||||
>
|
||||
<ElFormItem v-if="eligibility" label="延期资格"
|
||||
><span
|
||||
>{{
|
||||
eligibility.reason || (eligibility.can_extend ? '可以付费延期' : '不能付费延期')
|
||||
}};特殊延期:{{
|
||||
eligibility.special_extension_available ? '可申请' : '不可申请'
|
||||
}}</span
|
||||
></ElFormItem
|
||||
>
|
||||
<ElFormItem v-if="eligibility?.pending_order_no" label="待处理订单"
|
||||
>{{ eligibility.pending_order_no }}
|
||||
<ElButton link :disabled="submitting" @click="resumeOrder">查看订单</ElButton></ElFormItem
|
||||
>
|
||||
</template>
|
||||
<ElFormItem label="延期天数" required
|
||||
><ElInputNumber v-model="days" :min="1" :precision="0" :step="1" /><span
|
||||
v-if="mode !== 'special' && eligibility"
|
||||
>({{ eligibility.min_days ?? '-' }}~{{ eligibility.max_days ?? '-' }} 天)</span
|
||||
></ElFormItem
|
||||
>
|
||||
<template v-if="mode !== 'special'">
|
||||
<ElFormItem label="后端试算"
|
||||
><ElButton :loading="quoteLoading" :disabled="!eligibility?.can_extend" @click="loadQuote"
|
||||
>试算</ElButton
|
||||
><span v-if="quote"
|
||||
>实际延长 {{ quote.billed_days ?? '-' }} 天,{{ silenceAmount(quote.amount) }},新截止日
|
||||
{{ quote.new_deadline || '-' }}(当日 23:59:59)</span
|
||||
></ElFormItem
|
||||
>
|
||||
<ElFormItem v-if="mode === 'online'" label="支付方式"
|
||||
><ElSelect v-model="paymentMethod"
|
||||
><ElOption value="wechat" label="微信支付" /><ElOption
|
||||
value="alipay"
|
||||
label="支付宝" /></ElSelect
|
||||
></ElFormItem>
|
||||
</template>
|
||||
<template v-else>
|
||||
<ElFormItem label="延期类型" required
|
||||
><ElSelect v-model="specialType"
|
||||
><ElOption v-for="item in specialTypes" :key="item.value" v-bind="item" /></ElSelect
|
||||
></ElFormItem>
|
||||
<ElFormItem label="原因" required><ElInput v-model="reason" type="textarea" /></ElFormItem>
|
||||
<ElFormItem label="依据" required><ElInput v-model="basis" type="textarea" /></ElFormItem>
|
||||
<ElFormItem v-if="hasAuth(P.batch)" label="批量 CSV"
|
||||
><ElUpload :auto-upload="false" :show-file-list="false" accept=".csv" :on-change="readCsv"
|
||||
><ElButton>选择 CSV 明细</ElButton></ElUpload
|
||||
><p
|
||||
>表头 package_usage_id,days;每行一笔。选中后将替代当前单项。天数由后端按 30
|
||||
天向上取整。</p
|
||||
></ElFormItem
|
||||
>
|
||||
<ElFormItem v-if="batchItems.length" label="导入明细"
|
||||
><span>{{ batchItems.length }} 项</span
|
||||
><ElButton link @click="batchItems = []">清除</ElButton></ElFormItem
|
||||
>
|
||||
<ElFormItem v-if="specialType === 'discount'" label="实收合计(元)" required
|
||||
><ElInput v-model="paidYuan" inputmode="decimal"
|
||||
/></ElFormItem>
|
||||
</template>
|
||||
<template v-if="requiresReceipt">
|
||||
<ElFormItem label="线下收款方式" required
|
||||
><ElSelect
|
||||
v-model="methodId"
|
||||
filterable
|
||||
:loading="methodsLoading"
|
||||
@visible-change="(value) => value && loadMethods()"
|
||||
><ElOption
|
||||
v-for="item in methods"
|
||||
:key="item.id"
|
||||
:value="item.id"
|
||||
:label="item.name" /></ElSelect
|
||||
></ElFormItem>
|
||||
<ElFormItem label="交易单号" required><ElInput v-model="tradeNo" /></ElFormItem>
|
||||
<ElFormItem v-if="mode === 'offline'" label="实收金额(元)" required
|
||||
><ElInput v-model="paidYuan" inputmode="decimal"
|
||||
/></ElFormItem>
|
||||
<ElFormItem label="付款时间" required
|
||||
><ElDatePicker
|
||||
v-model="paidAt"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ssZ"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
/></ElFormItem>
|
||||
<ElFormItem label="收款凭证" required
|
||||
><VoucherUpload
|
||||
v-model="vouchers"
|
||||
:key="`vouchers-${mode}`"
|
||||
:max-count="5"
|
||||
@uploading-change="(value) => (uploadingReceipt = value)"
|
||||
/></ElFormItem>
|
||||
</template>
|
||||
<ElFormItem label="申请记录/截图"
|
||||
><VoucherUpload
|
||||
v-model="evidence"
|
||||
:max-count="5"
|
||||
@uploading-change="(value) => (uploadingEvidence = value)"
|
||||
/></ElFormItem>
|
||||
</ElForm>
|
||||
<ElAlert
|
||||
v-if="order"
|
||||
:title="`订单 ${order.order_no || '-'}:${order.status_name || order.status || '-'};实际生效以完成状态为准`"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/>
|
||||
<div v-if="order?.status === 'pending_payment' && order.qr_content" class="silence-qr"
|
||||
><QrcodeVue :value="order.qr_content" :size="200" level="M" /><p
|
||||
>支付截止:{{ order.expire_at ? formatDateTime(order.expire_at) : '-' }}</p
|
||||
></div
|
||||
>
|
||||
<ElButton v-if="order?.id" :loading="checking" @click="refreshOrder">刷新订单状态</ElButton>
|
||||
<ElAlert
|
||||
v-if="batch"
|
||||
:title="`批次 ${batch.batch_no || '-'}:${batch.status || '-'};审批 ${batch.approval_status || '-'};成功 ${batch.succeeded_count ?? '-'},失败 ${batch.failed_count ?? '-'}`"
|
||||
:closable="false"
|
||||
/>
|
||||
<SilenceTable v-if="batch?.items?.length" :rows="batch.items" :definitions="resultFields" />
|
||||
<ElTable v-if="rowErrors.length" :data="rowErrors"
|
||||
><ElTableColumn label="行号"
|
||||
><template #default="{ row }">{{ row.row_no ?? row.row ?? '-' }}</template></ElTableColumn
|
||||
><ElTableColumn label="失败原因"
|
||||
><template #default="{ row }">{{
|
||||
row.reason || row.message || '-'
|
||||
}}</template></ElTableColumn
|
||||
></ElTable
|
||||
>
|
||||
<template #footer
|
||||
><ElButton @click="$emit('close')">关闭</ElButton
|
||||
><ElButton
|
||||
v-if="!order && !batch"
|
||||
type="primary"
|
||||
:loading="submitting"
|
||||
:disabled="!canSubmit || uploadingReceipt || uploadingEvidence"
|
||||
@click="submit"
|
||||
>确认提交</ElButton
|
||||
></template
|
||||
>
|
||||
</ElDialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted, onBeforeUnmount, onDeactivated } from 'vue'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import type { UploadFile } from 'element-plus'
|
||||
import QrcodeVue from 'qrcode.vue'
|
||||
import { PackageSilenceService as Service } from '@/api/modules/packageSilence'
|
||||
import { EmployeeCollectionService } from '@/api/modules/employeeCollection'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { useSchedulerRequest } from '@/composables/useSchedulerRequest'
|
||||
import { pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import { PACKAGE_SILENCE_PERMISSIONS as P } from '@/config/constants/packageSilence'
|
||||
import {
|
||||
silenceData,
|
||||
silenceId,
|
||||
silenceDays,
|
||||
silenceFen,
|
||||
silenceDate,
|
||||
silenceAmount,
|
||||
parseSilenceCsv,
|
||||
silenceRowsError,
|
||||
SILENCE_SPECIAL_TYPES,
|
||||
silenceOptions
|
||||
} from '@/utils/business/silenceExtension'
|
||||
import { gatewayError, requireGatewayAccess } from '@/utils/business/gateway'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import type {
|
||||
SilenceExtensionOrderResponse,
|
||||
SilenceBatchResponse,
|
||||
SilenceSpecialItem
|
||||
} from '@/types/api/packageSilenceContract'
|
||||
import VoucherUpload from '@/components/business/VoucherUpload.vue'
|
||||
import SilenceTable from './SilenceTable.vue'
|
||||
const props = defineProps<{ usageId?: number; allowed?: boolean; batchMode?: boolean }>()
|
||||
const emit = defineEmits<{ close: []; changed: [] }>()
|
||||
const { hasAuth } = useAuth(),
|
||||
user = useUserStore()
|
||||
const mode = ref<'online' | 'offline' | 'special'>(
|
||||
props.batchMode ? 'special' : hasAuth(P.extend) ? 'online' : 'offline'
|
||||
)
|
||||
const days = ref<number | undefined>(),
|
||||
paymentMethod = ref('wechat'),
|
||||
specialType = ref('free'),
|
||||
reason = ref(''),
|
||||
basis = ref('')
|
||||
const methodId = ref<number>(),
|
||||
tradeNo = ref(''),
|
||||
paidYuan = ref(''),
|
||||
paidAt = ref(''),
|
||||
vouchers = ref<string[]>([]),
|
||||
evidence = ref<string[]>([])
|
||||
const batchItems = ref<SilenceSpecialItem[]>([]),
|
||||
specialUncertain = ref(false),
|
||||
error = ref(''),
|
||||
submitting = ref(false),
|
||||
checking = ref(false)
|
||||
const uploadingReceipt = ref(false),
|
||||
uploadingEvidence = ref(false),
|
||||
methodsLoading = ref(false),
|
||||
methods = ref<{ id: number; name: string }[]>([])
|
||||
const order = ref<SilenceExtensionOrderResponse>(),
|
||||
batch = ref<SilenceBatchResponse>(),
|
||||
rowErrors = ref<ReturnType<typeof silenceRowsError>>([])
|
||||
const specialTypes = silenceOptions(SILENCE_SPECIAL_TYPES)
|
||||
const allowed = () =>
|
||||
props.allowed !== false &&
|
||||
(mode.value === 'offline' ? hasAuth(P.offline) : hasAuth(P.extend)) &&
|
||||
(!props.batchMode || hasAuth(P.batch))
|
||||
const eligibilityAllowed = computed(() => allowed() && !!props.usageId)
|
||||
const {
|
||||
data: eligibility,
|
||||
loading: eligibilityLoading,
|
||||
error: eligibilityError,
|
||||
load: loadEligibility,
|
||||
clear: clearEligibility
|
||||
} = useSchedulerRequest(
|
||||
async () => silenceData(await Service.eligibility(silenceId(props.usageId))),
|
||||
() => eligibilityAllowed.value
|
||||
)
|
||||
const {
|
||||
data: quote,
|
||||
loading: quoteLoading,
|
||||
load: requestQuote,
|
||||
clear: clearQuote,
|
||||
error: quoteError
|
||||
} = useSchedulerRequest(
|
||||
async () => {
|
||||
const input = silenceDays(days.value),
|
||||
usage = silenceId(props.usageId)
|
||||
return { ...silenceData(await Service.quote(usage, input)), forDays: input, forUsage: usage }
|
||||
},
|
||||
() => eligibilityAllowed.value && !!eligibility.value?.can_extend
|
||||
)
|
||||
const requiresReceipt = computed(
|
||||
() =>
|
||||
mode.value === 'offline' ||
|
||||
(mode.value === 'special' && specialType.value === 'discount' && Number(paidYuan.value) > 0)
|
||||
)
|
||||
const canSubmit = computed(
|
||||
() =>
|
||||
allowed() &&
|
||||
!specialUncertain.value &&
|
||||
(mode.value === 'special'
|
||||
? batchItems.value.length
|
||||
? hasAuth(P.batch)
|
||||
: !!eligibility.value?.special_extension_available
|
||||
: !!eligibility.value?.can_extend &&
|
||||
!!quote.value?.valid &&
|
||||
quote.value.forDays === days.value &&
|
||||
quote.value.forUsage === props.usageId &&
|
||||
Number.isSafeInteger(quote.value.amount))
|
||||
)
|
||||
let active = true,
|
||||
version = 0,
|
||||
timer: ReturnType<typeof setTimeout> | undefined
|
||||
const requestIds = new Map<string, string>()
|
||||
function stop() {
|
||||
if (timer) clearTimeout(timer)
|
||||
timer = undefined
|
||||
}
|
||||
function invalidate() {
|
||||
version++
|
||||
stop()
|
||||
order.value = undefined
|
||||
batch.value = undefined
|
||||
rowErrors.value = []
|
||||
error.value = ''
|
||||
clearQuote()
|
||||
clearEligibility()
|
||||
vouchers.value = []
|
||||
evidence.value = []
|
||||
methods.value = []
|
||||
methodsLoading.value = false
|
||||
days.value = undefined
|
||||
reason.value = ''
|
||||
basis.value = ''
|
||||
methodId.value = undefined
|
||||
tradeNo.value = ''
|
||||
paidYuan.value = ''
|
||||
paidAt.value = ''
|
||||
batchItems.value = []
|
||||
}
|
||||
watch(
|
||||
() => [props.usageId, props.allowed, pollingScope(user)],
|
||||
() => {
|
||||
invalidate()
|
||||
if (props.usageId && allowed()) void loadEligibility()
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(
|
||||
() => [mode.value, days.value],
|
||||
() => {
|
||||
clearQuote()
|
||||
error.value = ''
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(
|
||||
() => allowed(),
|
||||
(value) => {
|
||||
if (!value) invalidate()
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(quoteError, (value) => {
|
||||
if (value) error.value = value
|
||||
})
|
||||
async function loadQuote() {
|
||||
await requestQuote()
|
||||
}
|
||||
async function loadMethods() {
|
||||
if (!allowed() || methodsLoading.value) return
|
||||
const current = version,
|
||||
scope = pollingScope(user)
|
||||
methodsLoading.value = true
|
||||
try {
|
||||
const result = silenceData(
|
||||
await EmployeeCollectionService.getPaymentMethods({
|
||||
page: 1,
|
||||
page_size: 100,
|
||||
enabled: true
|
||||
})
|
||||
)
|
||||
if (!active || current !== version || scope !== pollingScope(user) || !allowed()) return
|
||||
const values = Array.isArray(result) ? result : result.items || []
|
||||
methods.value = values.map((item) => ({ id: item.id, name: item.name }))
|
||||
} catch (e) {
|
||||
if (current === version) error.value = gatewayError(e)
|
||||
} finally {
|
||||
if (current === version) methodsLoading.value = false
|
||||
}
|
||||
}
|
||||
async function readCsv(file: UploadFile) {
|
||||
try {
|
||||
requireGatewayAccess(allowed() && hasAuth(P.batch))
|
||||
if (!file.raw || !file.name.toLowerCase().endsWith('.csv')) throw new Error('请选择 CSV 文件')
|
||||
const current = version,
|
||||
items = parseSilenceCsv(await file.raw.text())
|
||||
if (active && current === version && allowed() && hasAuth(P.batch)) batchItems.value = items
|
||||
} catch (e) {
|
||||
error.value = gatewayError(e)
|
||||
}
|
||||
}
|
||||
async function resumeOrder() {
|
||||
const no = eligibility.value?.pending_order_no,
|
||||
current = version
|
||||
if (!no || !allowed()) return
|
||||
try {
|
||||
const result = silenceData(await Service.orders({ order_no: no, page: 1, page_size: 20 }))
|
||||
if (active && current === version && allowed()) {
|
||||
order.value = result.items?.find((item) => item.order_no === no)
|
||||
schedule()
|
||||
}
|
||||
} catch (e) {
|
||||
if (current === version) error.value = gatewayError(e)
|
||||
}
|
||||
}
|
||||
function schedule() {
|
||||
stop()
|
||||
if (active && allowed() && ['pending_payment', 'paid'].includes(order.value?.status || ''))
|
||||
timer = setTimeout(() => void refreshOrder(), 3000)
|
||||
}
|
||||
async function refreshOrder() {
|
||||
stop()
|
||||
const id = order.value?.id,
|
||||
current = version,
|
||||
scope = pollingScope(user)
|
||||
if (!id || checking.value || !allowed()) return
|
||||
checking.value = true
|
||||
try {
|
||||
const result = silenceData(await Service.order(id))
|
||||
if (!active || current !== version || scope !== pollingScope(user) || !allowed()) return
|
||||
order.value = result
|
||||
if (result.status === 'completed') emit('changed')
|
||||
schedule()
|
||||
} catch (e) {
|
||||
if (current === version) error.value = gatewayError(e)
|
||||
} finally {
|
||||
checking.value = false
|
||||
}
|
||||
}
|
||||
async function submit() {
|
||||
if (submitting.value) return
|
||||
const current = version,
|
||||
scope = pollingScope(user),
|
||||
currentMode = mode.value
|
||||
submitting.value = true
|
||||
error.value = ''
|
||||
rowErrors.value = []
|
||||
let specialSent = false
|
||||
try {
|
||||
requireGatewayAccess(canSubmit.value && !uploadingReceipt.value && !uploadingEvidence.value)
|
||||
const input =
|
||||
currentMode === 'special' && batchItems.value.length ? 1 : silenceDays(days.value),
|
||||
usage =
|
||||
batchItems.value.length && currentMode === 'special'
|
||||
? undefined
|
||||
: silenceId(props.usageId)
|
||||
const common = { package_usage_id: usage!, days: input, evidence_refs: [...evidence.value] }
|
||||
const receipt = requiresReceipt.value
|
||||
? {
|
||||
offline_payment_method_id: silenceId(methodId.value, '收款方式'),
|
||||
offline_trade_no: tradeNo.value.trim(),
|
||||
paid_at: silenceDate(paidAt.value),
|
||||
payment_voucher_keys: [...vouchers.value]
|
||||
}
|
||||
: undefined
|
||||
if (
|
||||
receipt &&
|
||||
(!receipt.offline_trade_no ||
|
||||
receipt.payment_voucher_keys.length < 1 ||
|
||||
receipt.payment_voucher_keys.length > 5)
|
||||
)
|
||||
throw new Error('请填写交易单号,并上传 1~5 张收款凭证')
|
||||
const amount =
|
||||
currentMode === 'offline' || (currentMode === 'special' && specialType.value === 'discount')
|
||||
? silenceFen(paidYuan.value)
|
||||
: 0
|
||||
if (currentMode === 'offline' && amount !== quote.value?.amount)
|
||||
throw new Error('实收金额必须等于当前后端试算金额')
|
||||
const items = batchItems.value.length
|
||||
? batchItems.value.map((item) => ({ ...item }))
|
||||
: [{ package_usage_id: usage!, days: input }]
|
||||
if (currentMode === 'special' && (!reason.value.trim() || !basis.value.trim()))
|
||||
throw new Error('请填写特殊延期原因和依据')
|
||||
if (currentMode === 'special' && items.length > 1) requireGatewayAccess(hasAuth(P.batch))
|
||||
const body =
|
||||
currentMode === 'special'
|
||||
? {
|
||||
extension_type: specialType.value,
|
||||
items,
|
||||
reason: reason.value.trim(),
|
||||
basis: basis.value.trim(),
|
||||
amount,
|
||||
evidence_refs: [...evidence.value],
|
||||
...(receipt
|
||||
? {
|
||||
offline_payment_method_id: receipt.offline_payment_method_id,
|
||||
offline_trade_no: receipt.offline_trade_no,
|
||||
offline_paid_at: receipt.paid_at,
|
||||
payment_voucher_keys: receipt.payment_voucher_keys
|
||||
}
|
||||
: {})
|
||||
}
|
||||
: currentMode === 'offline'
|
||||
? { ...common, ...receipt!, paid_amount: amount }
|
||||
: { ...common, payment_method: paymentMethod.value }
|
||||
const fingerprint = JSON.stringify([currentMode, body])
|
||||
if (!requestIds.has(fingerprint)) requestIds.set(fingerprint, crypto.randomUUID())
|
||||
await ElMessageBox.confirm(
|
||||
currentMode === 'special'
|
||||
? `确认提交 ${items.length} 项特殊延期申请?结果以审批和逐项执行为准。`
|
||||
: '确认提交延期订单?待支付或待审批并不代表已生效。',
|
||||
'提交确认',
|
||||
{ type: 'warning' }
|
||||
)
|
||||
requireGatewayAccess(
|
||||
active &&
|
||||
current === version &&
|
||||
scope === pollingScope(user) &&
|
||||
currentMode === mode.value &&
|
||||
canSubmit.value
|
||||
)
|
||||
// 表单在确认框期间被锁定;同一快照重试复用幂等键,不自动重发写请求。
|
||||
specialSent = currentMode === 'special'
|
||||
const result =
|
||||
currentMode === 'special'
|
||||
? silenceData(await Service.special(body as Parameters<typeof Service.special>[0]))
|
||||
: currentMode === 'offline'
|
||||
? silenceData(
|
||||
await Service.createOffline({
|
||||
...body,
|
||||
request_id: requestIds.get(fingerprint)!
|
||||
} as Parameters<typeof Service.createOffline>[0])
|
||||
)
|
||||
: silenceData(
|
||||
await Service.createQrcode({
|
||||
...body,
|
||||
request_id: requestIds.get(fingerprint)!
|
||||
} as Parameters<typeof Service.createQrcode>[0])
|
||||
)
|
||||
if (!active || current !== version || scope !== pollingScope(user) || !allowed()) return
|
||||
if (currentMode === 'special') batch.value = result as SilenceBatchResponse
|
||||
else {
|
||||
order.value = result as SilenceExtensionOrderResponse
|
||||
schedule()
|
||||
}
|
||||
emit('changed')
|
||||
} catch (e) {
|
||||
if (active && current === version && e !== 'cancel' && e !== 'close') {
|
||||
error.value = gatewayError(e)
|
||||
rowErrors.value = silenceRowsError(e)
|
||||
if (
|
||||
specialSent &&
|
||||
!(e as { code?: unknown; response?: unknown })?.code &&
|
||||
!(e as { response?: unknown })?.response
|
||||
) {
|
||||
specialUncertain.value = true
|
||||
error.value += '。提交结果未确认,请先到延期批次列表核对,不要重复提交。'
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
const resultFields = [
|
||||
['row_no', '行号'],
|
||||
['asset_identifier', '资产'],
|
||||
['package_name', '套餐'],
|
||||
['status', '处理状态'],
|
||||
['after_deadline_at', '延期后截止'],
|
||||
['failure_summary', '失败原因']
|
||||
].map(([prop, label]) => ({ prop, label }))
|
||||
onMounted(() => {
|
||||
if (props.usageId) void loadEligibility()
|
||||
})
|
||||
onDeactivated(() => {
|
||||
active = false
|
||||
invalidate()
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
active = false
|
||||
invalidate()
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
.silence-qr {
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.el-alert {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.el-form-item p {
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
@media (width <= 640px) {
|
||||
:deep(.el-form-item) {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
:deep(.el-form-item__label) {
|
||||
justify-content: flex-start;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
:deep(.el-form-item__content) {
|
||||
flex-basis: 100%;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
633
src/components/business/package-silence/SilenceManagement.vue
Normal file
633
src/components/business/package-silence/SilenceManagement.vue
Normal file
@@ -0,0 +1,633 @@
|
||||
<template>
|
||||
<ArtTableFullScreen
|
||||
><div id="table-full-screen">
|
||||
<ArtSearchBar
|
||||
:filter="filters"
|
||||
:items="searchItems"
|
||||
:show-expand="searchItems.length >= 4"
|
||||
label-width="100px"
|
||||
@search="search"
|
||||
@reset="reset"
|
||||
/>
|
||||
<ElCard shadow="never" class="art-table-card">
|
||||
<ElAlert
|
||||
v-if="error || actionError"
|
||||
:title="error || actionError"
|
||||
type="error"
|
||||
:closable="false"
|
||||
/>
|
||||
<SilenceTable
|
||||
:rows="displayRows"
|
||||
:row-key="kind === 'usages' ? 'package_usage_id' : 'id'"
|
||||
:definitions="fields"
|
||||
:loading="loading"
|
||||
:total="kind === 'policies' ? undefined : total"
|
||||
:page="page"
|
||||
:size="size"
|
||||
@refresh="load"
|
||||
@page="
|
||||
(value) => {
|
||||
page = value
|
||||
load()
|
||||
}
|
||||
"
|
||||
@size="
|
||||
(value) => {
|
||||
size = value
|
||||
search()
|
||||
}
|
||||
"
|
||||
>
|
||||
<template #toolbar>
|
||||
<ElButton
|
||||
v-if="kind === 'policies' && canManagePolicy"
|
||||
type="primary"
|
||||
@click="editPolicy()"
|
||||
>新增政策</ElButton
|
||||
>
|
||||
<ElButton v-if="kind === 'policies' && canManagePolicy" @click="matchVisible = true"
|
||||
>查询套餐匹配政策</ElButton
|
||||
>
|
||||
<ElButton
|
||||
v-if="kind === 'batches' && allowed && hasAuth(P.extend) && hasAuth(P.batch)"
|
||||
type="primary"
|
||||
@click="batchVisible = true"
|
||||
>批量特殊延期</ElButton
|
||||
>
|
||||
<ElButton
|
||||
v-if="exportPermission && allowed && hasAuth(exportPermission)"
|
||||
@click="openExport"
|
||||
>导出</ElButton
|
||||
>
|
||||
</template>
|
||||
<ElTableColumn label="操作" fixed="right" min-width="200"
|
||||
><template #default="{ row }">
|
||||
<ElButton v-if="canDetail" type="primary" link @click="detail(row)">详情</ElButton>
|
||||
<template v-if="kind === 'usages' && row.silence">
|
||||
<ElButton link type="primary" @click="recordsId = row.package_usage_id"
|
||||
>沉默期流水</ElButton
|
||||
>
|
||||
<ElButton
|
||||
v-if="row.silence.extendable && (hasAuth(P.extend) || hasAuth(P.offline))"
|
||||
link
|
||||
type="primary"
|
||||
@click="extendId = row.package_usage_id"
|
||||
>延期</ElButton
|
||||
>
|
||||
</template>
|
||||
<template v-if="kind === 'policies' && canManagePolicy"
|
||||
><ElButton link type="primary" @click="editPolicy(row)">编辑</ElButton
|
||||
><ElButton link :disabled="changing" @click="togglePolicy(row)">{{
|
||||
row.status === 1 ? '停用' : '启用'
|
||||
}}</ElButton></template
|
||||
>
|
||||
</template></ElTableColumn
|
||||
>
|
||||
</SilenceTable>
|
||||
<div v-if="kind === 'policies'" class="policy-pager">
|
||||
<span>第 {{ page }} 页(接口未返回总数)</span>
|
||||
<ElButton :disabled="page <= 1 || loading" @click="previousPolicyPage">上一页</ElButton>
|
||||
<ElButton :disabled="rows.length < size || loading" @click="nextPolicyPage"
|
||||
>下一页</ElButton
|
||||
>
|
||||
</div>
|
||||
</ElCard>
|
||||
<ElDialog
|
||||
v-if="matchVisible"
|
||||
:model-value="true"
|
||||
title="查询套餐匹配政策"
|
||||
width="min(600px,96vw)"
|
||||
@close="closeMatch"
|
||||
>
|
||||
<ElForm label-width="80px">
|
||||
<ElFormItem label="套餐" required>
|
||||
<BusinessEntitySelect
|
||||
v-model="matchPackage"
|
||||
entity="package"
|
||||
:allowed="canManagePolicy"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton @click="closeMatch">取消</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:disabled="!matchPackage || !canManagePolicy"
|
||||
:loading="matching"
|
||||
@click="matchPolicy"
|
||||
>查询</ElButton
|
||||
>
|
||||
</template>
|
||||
</ElDialog>
|
||||
<ElDialog
|
||||
v-if="matchResult"
|
||||
:model-value="true"
|
||||
title="当前匹配政策"
|
||||
width="min(600px,96vw)"
|
||||
@close="matchResult = undefined"
|
||||
><ElDescriptions :column="1" border
|
||||
><ElDescriptionsItem label="是否匹配">{{
|
||||
matchResult.matched ? '是' : '否'
|
||||
}}</ElDescriptionsItem
|
||||
><ElDescriptionsItem label="政策">{{
|
||||
matchResult.policy?.name || '-'
|
||||
}}</ElDescriptionsItem
|
||||
><ElDescriptionsItem label="月单价">{{
|
||||
silenceAmount(matchResult.policy?.unit_price)
|
||||
}}</ElDescriptionsItem></ElDescriptions
|
||||
></ElDialog
|
||||
>
|
||||
<SilenceExtendDialog
|
||||
v-if="extendId || batchVisible"
|
||||
:usage-id="extendId"
|
||||
:batch-mode="batchVisible"
|
||||
:allowed="allowed"
|
||||
@close="closeExtension"
|
||||
@changed="load"
|
||||
/>
|
||||
<SilenceRecordsDialog
|
||||
v-if="recordsId"
|
||||
:usage-id="recordsId"
|
||||
:allowed="allowed"
|
||||
@close="recordsId = undefined"
|
||||
/>
|
||||
<SilencePolicyDialog
|
||||
v-if="policyVisible"
|
||||
:id="policyId"
|
||||
:allowed="canManagePolicy"
|
||||
@close="policyVisible = false"
|
||||
@saved="load"
|
||||
/>
|
||||
<ExportTaskCreateDialog
|
||||
v-if="exportVisible && exportScene"
|
||||
v-model="exportVisible"
|
||||
:scene="exportScene"
|
||||
:query="exportQuery"
|
||||
:confirm-permission="exportPermission"
|
||||
/> </div
|
||||
></ArtTableFullScreen>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
computed,
|
||||
onMounted,
|
||||
onBeforeUnmount,
|
||||
onActivated,
|
||||
onDeactivated,
|
||||
watch
|
||||
} from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { PackageSilenceService as Service } from '@/api/modules/packageSilence'
|
||||
import { useSchedulerRequest } from '@/composables/useSchedulerRequest'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import {
|
||||
silenceData,
|
||||
silenceRange,
|
||||
silenceDate,
|
||||
silenceId,
|
||||
silenceAmount,
|
||||
silenceOptions,
|
||||
SILENCE_ORDER_STATUS,
|
||||
SILENCE_SPECIAL_TYPES
|
||||
} from '@/utils/business/silenceExtension'
|
||||
import { compactGatewayQuery, gatewayError, requireGatewayAccess } from '@/utils/business/gateway'
|
||||
import {
|
||||
SILENCE_PAGES,
|
||||
PACKAGE_SILENCE_PERMISSIONS as P
|
||||
} from '@/config/constants/packageSilence'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { ExportTaskScene } from '@/types/api/exportTask'
|
||||
import type { SilencePolicyMatchResponse } from '@/types/api/packageSilenceContract'
|
||||
import SilenceTable from './SilenceTable.vue'
|
||||
import SilenceExtendDialog from './SilenceExtendDialog.vue'
|
||||
import SilenceRecordsDialog from './SilenceRecordsDialog.vue'
|
||||
import SilencePolicyDialog from './SilencePolicyDialog.vue'
|
||||
import ExportTaskCreateDialog from '@/components/business/ExportTaskCreateDialog.vue'
|
||||
import BusinessEntitySelect from '@/components/business/BusinessEntitySelect.vue'
|
||||
const props = defineProps<{ kind: 'orders' | 'batches' | 'usages' | 'policies' }>()
|
||||
const router = useRouter(),
|
||||
user = useUserStore(),
|
||||
{ hasAuth } = useAuth(),
|
||||
page = ref(1),
|
||||
size = ref(20)
|
||||
const allowed = computed(
|
||||
() =>
|
||||
hasAuth(SILENCE_PAGES[props.kind].page) && (props.kind !== 'policies' || hasAuth(P.policy))
|
||||
)
|
||||
const canManagePolicy = computed(() => allowed.value && hasAuth(P.policy))
|
||||
const canDetail = computed(
|
||||
() =>
|
||||
allowed.value &&
|
||||
(props.kind === 'orders' || props.kind === 'batches') &&
|
||||
hasAuth(SILENCE_PAGES[props.kind as 'orders' | 'batches'].detail) &&
|
||||
hasAuth(SILENCE_PAGES[props.kind as 'orders' | 'batches'].detailPage)
|
||||
)
|
||||
const filters = reactive<Record<string, any>>({}),
|
||||
actionError = ref(''),
|
||||
changing = ref(false)
|
||||
const recordsId = ref<number>(),
|
||||
extendId = ref<number>(),
|
||||
batchVisible = ref(false),
|
||||
policyVisible = ref(false),
|
||||
policyId = ref<number>(),
|
||||
matchResult = ref<SilencePolicyMatchResponse>()
|
||||
const matchVisible = ref(false),
|
||||
matchPackage = ref<number>(),
|
||||
matching = ref(false)
|
||||
let matchSequence = 0
|
||||
const exportVisible = ref(false),
|
||||
exportQuery = ref<Record<string, unknown>>({})
|
||||
const exportScene = computed<ExportTaskScene | undefined>(() =>
|
||||
props.kind === 'orders'
|
||||
? 'package_silence_order'
|
||||
: props.kind === 'usages'
|
||||
? 'package_silence_usage'
|
||||
: undefined
|
||||
)
|
||||
const exportPermission = computed(() =>
|
||||
props.kind === 'orders'
|
||||
? SILENCE_PAGES.orders.export
|
||||
: props.kind === 'usages'
|
||||
? SILENCE_PAGES.usages.export
|
||||
: ''
|
||||
)
|
||||
const queryKeys = {
|
||||
orders: [
|
||||
'package_usage_id',
|
||||
'package_id',
|
||||
'asset_identifier',
|
||||
'order_no',
|
||||
'status',
|
||||
'source',
|
||||
'payment_method',
|
||||
'merchant_name',
|
||||
'third_party_trade_no'
|
||||
],
|
||||
batches: ['batch_no', 'path', 'extension_type', 'status', 'has_exception'],
|
||||
usages: ['view', 'within_days', 'asset_identifier', 'package_id', 'shop_id'],
|
||||
policies: ['name', 'scope_type', 'status']
|
||||
}
|
||||
function query() {
|
||||
const value: Record<string, unknown> = {}
|
||||
for (const key of queryKeys[props.kind]) {
|
||||
const raw = filters[key]
|
||||
value[key] =
|
||||
['package_usage_id', 'package_id', 'shop_id', 'within_days'].includes(key) &&
|
||||
raw != null &&
|
||||
raw !== ''
|
||||
? silenceId(Number(raw), key)
|
||||
: raw
|
||||
}
|
||||
if (props.kind === 'usages')
|
||||
Object.assign(value, silenceRange(filters.time_range, 'deadline_start', 'deadline_end'))
|
||||
if (props.kind === 'orders')
|
||||
Object.assign(value, silenceRange(filters.time_range, 'paid_start', 'paid_end'))
|
||||
if (props.kind === 'policies' && filters.effective_at)
|
||||
value.effective_at = silenceDate(filters.effective_at)
|
||||
return compactGatewayQuery(value)
|
||||
}
|
||||
const { data, loading, error, load, clear } = useSchedulerRequest(
|
||||
async () => {
|
||||
const params = { ...query(), page: page.value, page_size: size.value }
|
||||
if (props.kind === 'orders') return silenceData(await Service.orders(params))
|
||||
if (props.kind === 'batches') return silenceData(await Service.batches(params))
|
||||
if (props.kind === 'usages') return silenceData(await Service.usages(params))
|
||||
return silenceData(await Service.policies(params))
|
||||
},
|
||||
() => allowed.value
|
||||
)
|
||||
const rows = computed(() => (Array.isArray(data.value) ? data.value : data.value?.items || []))
|
||||
const total = computed(() =>
|
||||
Array.isArray(data.value) ? data.value.length : data.value?.total || 0
|
||||
)
|
||||
const input = (prop: string, label: string): SearchFormItem => ({
|
||||
prop,
|
||||
label,
|
||||
type: 'input',
|
||||
config: { clearable: true }
|
||||
})
|
||||
const select = (prop: string, label: string, map: Record<string, string>): SearchFormItem => ({
|
||||
prop,
|
||||
label,
|
||||
type: 'select',
|
||||
options: silenceOptions(map),
|
||||
config: { clearable: true }
|
||||
})
|
||||
const number = (prop: string, label: string): SearchFormItem => ({
|
||||
prop,
|
||||
label,
|
||||
type: 'input',
|
||||
config: { inputmode: 'numeric', clearable: true }
|
||||
})
|
||||
const entity = (prop: string, label: string, kind: string): SearchFormItem => ({
|
||||
prop,
|
||||
label,
|
||||
type: 'business-select',
|
||||
config: {
|
||||
entity: kind,
|
||||
allowed: allowed.value,
|
||||
...(kind === 'usage'
|
||||
? {
|
||||
context: {
|
||||
asset_identifier: filters.asset_identifier || undefined,
|
||||
package_id: filters.package_id || undefined
|
||||
}
|
||||
}
|
||||
: {})
|
||||
}
|
||||
})
|
||||
const time: SearchFormItem = {
|
||||
prop: 'time_range',
|
||||
label: props.kind === 'orders' ? '支付起止时间' : '截止起止时间',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
type: 'datetimerange',
|
||||
rangeSeparator: '至',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ',
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
clearable: true
|
||||
}
|
||||
}
|
||||
const searchItems = computed<SearchFormItem[]>(() =>
|
||||
props.kind === 'orders'
|
||||
? [
|
||||
entity('asset_identifier', '资产', 'asset'),
|
||||
input('order_no', '订单号'),
|
||||
select('status', '订单状态', SILENCE_ORDER_STATUS),
|
||||
select('source', '来源', { client: '客户端', admin: '后台', offline: '线下' }),
|
||||
select('payment_method', '支付方式', {
|
||||
wechat: '微信',
|
||||
alipay: '支付宝',
|
||||
offline: '线下'
|
||||
}),
|
||||
input('merchant_name', '收款商户'),
|
||||
input('third_party_trade_no', '交易单号'),
|
||||
entity('package_usage_id', '套餐记录', 'usage'),
|
||||
entity('package_id', '套餐', 'package'),
|
||||
time
|
||||
]
|
||||
: props.kind === 'batches'
|
||||
? [
|
||||
input('batch_no', '批次号'),
|
||||
select('path', '办理路径', {
|
||||
online: '在线',
|
||||
offline: '线下',
|
||||
special: '特殊延期',
|
||||
adjust: '购买调整'
|
||||
}),
|
||||
select('extension_type', '延期类型', SILENCE_SPECIAL_TYPES),
|
||||
input('status', '批次状态编码'),
|
||||
{
|
||||
prop: 'has_exception',
|
||||
label: '含异常',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '是', value: true },
|
||||
{ label: '否', value: false }
|
||||
],
|
||||
config: { clearable: true }
|
||||
}
|
||||
]
|
||||
: props.kind === 'usages'
|
||||
? [
|
||||
select('view', '视图', { expiring: '即将过期', expired: '已过期', all: '全部' }),
|
||||
number('within_days', '临期天数'),
|
||||
entity('asset_identifier', '资产', 'asset'),
|
||||
entity('package_id', '套餐', 'package'),
|
||||
entity('shop_id', '店铺', 'shop'),
|
||||
time
|
||||
]
|
||||
: [
|
||||
input('name', '政策名称'),
|
||||
select('scope_type', '适用范围', {
|
||||
all: '全部套餐',
|
||||
series: '套餐系列',
|
||||
package: '指定套餐'
|
||||
}),
|
||||
{
|
||||
prop: 'status',
|
||||
label: '状态',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '停用', value: 0 }
|
||||
],
|
||||
config: { clearable: true }
|
||||
},
|
||||
{
|
||||
prop: 'effective_at',
|
||||
label: '生效于',
|
||||
type: 'datetime',
|
||||
config: { type: 'datetime', valueFormat: 'YYYY-MM-DDTHH:mm:ssZ', clearable: true }
|
||||
}
|
||||
]
|
||||
)
|
||||
const definitions = {
|
||||
orders: [
|
||||
['order_no', '订单号'],
|
||||
['asset_identifier', '资产标识'],
|
||||
['package_name', '套餐'],
|
||||
['status_name', '状态'],
|
||||
['source_name', '来源'],
|
||||
['extension_days', '延长天数'],
|
||||
['amount', '应付'],
|
||||
['paid_amount', '实付'],
|
||||
['payment_method', '支付方式'],
|
||||
['payment_merchant_name', '收款商户'],
|
||||
['third_party_trade_no', '交易流水号'],
|
||||
['paid_at', '支付时间'],
|
||||
['expected_deadline_at', '预计截止'],
|
||||
['completed_at', '生效时间'],
|
||||
['created_at', '创建时间']
|
||||
],
|
||||
batches: [
|
||||
['batch_no', '批次号'],
|
||||
['path', '办理路径'],
|
||||
['extension_type', '延期类型'],
|
||||
['status', '状态'],
|
||||
['approval_status', '审批状态'],
|
||||
['requested_count', '总项数'],
|
||||
['succeeded_count', '成功'],
|
||||
['failed_count', '失败'],
|
||||
['amount', '金额'],
|
||||
['requested_at', '发起时间'],
|
||||
['completed_at', '完成时间']
|
||||
],
|
||||
usages: [
|
||||
['asset_identifier', '资产标识'],
|
||||
['asset_type', '资产类型'],
|
||||
['shop_name', '店铺'],
|
||||
['package_name', '套餐'],
|
||||
['package_usage_id', '套餐记录 ID'],
|
||||
['silence_status_name', '沉默期状态'],
|
||||
['silence_deadline_at', '截止时间'],
|
||||
['silence_extended_days', '累计延期天数'],
|
||||
['order_no', '购买订单'],
|
||||
['created_at', '购买时间']
|
||||
],
|
||||
policies: [
|
||||
['name', '政策名称'],
|
||||
['scope_type_name', '适用范围'],
|
||||
['scope_ids', '范围 ID'],
|
||||
['unit_price', '月单价'],
|
||||
['free_extension_limit', '免费次数'],
|
||||
['paid_max_months', '付费累计最多月数'],
|
||||
['single_max_months', '单次最多月数'],
|
||||
['effective_from', '生效时间'],
|
||||
['effective_to', '失效时间'],
|
||||
['status', '状态'],
|
||||
['updated_at', '更新时间']
|
||||
]
|
||||
}
|
||||
const fields = computed(() => definitions[props.kind].map(([prop, label]) => ({ prop, label })))
|
||||
const displayRows = computed(() =>
|
||||
rows.value.map((row) =>
|
||||
props.kind === 'usages' ? { ...row, ...('silence' in row ? row.silence : {}) } : row
|
||||
)
|
||||
)
|
||||
// 用扁平显示行,同时保留原 silence 对象供操作入口判定。
|
||||
function search() {
|
||||
page.value = 1
|
||||
void load()
|
||||
}
|
||||
function previousPolicyPage() {
|
||||
page.value--
|
||||
void load()
|
||||
}
|
||||
function nextPolicyPage() {
|
||||
page.value++
|
||||
void load()
|
||||
}
|
||||
function closeExtension() {
|
||||
extendId.value = undefined
|
||||
batchVisible.value = false
|
||||
}
|
||||
function reset() {
|
||||
clear()
|
||||
Object.keys(filters).forEach((key) => delete filters[key])
|
||||
if (props.kind === 'usages') filters.view = 'expiring'
|
||||
search()
|
||||
}
|
||||
function detail(row: Record<string, any>) {
|
||||
requireGatewayAccess(canDetail.value)
|
||||
void router.push(`/package-management/silence-${props.kind}/detail/${silenceId(row.id)}`)
|
||||
}
|
||||
function editPolicy(row?: Record<string, any>) {
|
||||
if (!canManagePolicy.value) return
|
||||
policyId.value = row?.id
|
||||
policyVisible.value = true
|
||||
}
|
||||
function openExport() {
|
||||
try {
|
||||
requireGatewayAccess(allowed.value && hasAuth(exportPermission.value))
|
||||
exportQuery.value = { filters: query() }
|
||||
exportVisible.value = true
|
||||
} catch (e) {
|
||||
actionError.value = gatewayError(e)
|
||||
}
|
||||
}
|
||||
async function matchPolicy() {
|
||||
if (!canManagePolicy.value || !matchPackage.value || matching.value) return
|
||||
const scope = pollingScope(user),
|
||||
current = ++matchSequence,
|
||||
packageId = matchPackage.value
|
||||
matching.value = true
|
||||
try {
|
||||
requireGatewayAccess(active && canManagePolicy.value && scope === pollingScope(user))
|
||||
const result = silenceData(await Service.match(silenceId(packageId, '套餐')))
|
||||
if (
|
||||
active &&
|
||||
canManagePolicy.value &&
|
||||
scope === pollingScope(user) &&
|
||||
current === matchSequence &&
|
||||
packageId === matchPackage.value
|
||||
) {
|
||||
matchResult.value = result
|
||||
closeMatch()
|
||||
}
|
||||
} catch (e) {
|
||||
if (active && current === matchSequence && scope === pollingScope(user))
|
||||
actionError.value = gatewayError(e)
|
||||
} finally {
|
||||
if (current === matchSequence) matching.value = false
|
||||
}
|
||||
}
|
||||
function closeMatch() {
|
||||
matchSequence++
|
||||
matchVisible.value = false
|
||||
matchPackage.value = undefined
|
||||
matching.value = false
|
||||
}
|
||||
watch(
|
||||
() => [filters.asset_identifier, filters.package_id],
|
||||
() => {
|
||||
delete filters.package_usage_id
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
async function togglePolicy(row: Record<string, any>) {
|
||||
if (changing.value) return
|
||||
const scope = pollingScope(user),
|
||||
id = silenceId(row.id),
|
||||
status = row.status === 1 ? 0 : 1
|
||||
changing.value = true
|
||||
try {
|
||||
requireGatewayAccess(canManagePolicy.value)
|
||||
await ElMessageBox.confirm(`确认${status ? '启用' : '停用'} ${row.name}?`, '状态确认', {
|
||||
type: 'warning'
|
||||
})
|
||||
requireGatewayAccess(active && canManagePolicy.value && scope === pollingScope(user))
|
||||
silenceData(await Service.policyStatus(id, status))
|
||||
if (active && scope === pollingScope(user)) await load()
|
||||
} catch (e) {
|
||||
if (e !== 'cancel' && e !== 'close') actionError.value = gatewayError(e)
|
||||
} finally {
|
||||
changing.value = false
|
||||
}
|
||||
}
|
||||
watch(
|
||||
() => [allowed.value, pollingScope(user)],
|
||||
() => {
|
||||
recordsId.value = undefined
|
||||
extendId.value = undefined
|
||||
batchVisible.value = false
|
||||
policyVisible.value = false
|
||||
exportVisible.value = false
|
||||
matchResult.value = undefined
|
||||
closeMatch()
|
||||
actionError.value = ''
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
let active = true
|
||||
function closeDialogs() {
|
||||
recordsId.value = undefined
|
||||
closeExtension()
|
||||
policyVisible.value = false
|
||||
exportVisible.value = false
|
||||
matchResult.value = undefined
|
||||
closeMatch()
|
||||
}
|
||||
onDeactivated(() => {
|
||||
active = false
|
||||
closeDialogs()
|
||||
})
|
||||
onActivated(() => {
|
||||
active = true
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
active = false
|
||||
closeDialogs()
|
||||
})
|
||||
onMounted(() => {
|
||||
if (props.kind === 'usages') filters.view = 'expiring'
|
||||
void load()
|
||||
})
|
||||
</script>
|
||||
246
src/components/business/package-silence/SilencePolicyDialog.vue
Normal file
246
src/components/business/package-silence/SilencePolicyDialog.vue
Normal file
@@ -0,0 +1,246 @@
|
||||
<template>
|
||||
<ElDialog
|
||||
:model-value="true"
|
||||
:title="id ? '编辑延期政策' : '新增延期政策'"
|
||||
width="min(780px, 96vw)"
|
||||
destroy-on-close
|
||||
@close="$emit('close')"
|
||||
>
|
||||
<ElAlert
|
||||
title="同级范围及生效时间不能重叠;变更只影响之后发起的业务,不改变历史订单和审批快照。金额输入单位为元。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/>
|
||||
<ElAlert v-if="error" :title="error" type="error" :closable="false" />
|
||||
<ElForm v-loading="loading" label-width="160px" :disabled="saving || loading">
|
||||
<ElFormItem label="政策名称" required><ElInput v-model="form.name" /></ElFormItem>
|
||||
<ElFormItem label="适用范围" required
|
||||
><ElSelect v-model="form.scope_type" @change="form.scope_ids = []"
|
||||
><ElOption value="all" label="全部套餐" /><ElOption
|
||||
value="series"
|
||||
label="套餐系列" /><ElOption value="package" label="指定套餐" /></ElSelect
|
||||
></ElFormItem>
|
||||
<ElFormItem v-if="form.scope_type !== 'all'" label="适用系列/套餐" required
|
||||
><BusinessEntitySelect
|
||||
v-model="form.scope_ids"
|
||||
:entity="form.scope_type === 'package' ? 'package' : 'series'"
|
||||
:allowed="allowed"
|
||||
multiple
|
||||
/>
|
||||
<p>范围优先级:指定套餐 > 套餐系列 > 全部套餐。</p></ElFormItem
|
||||
>
|
||||
<ElFormItem label="月单价(元)" required
|
||||
><ElInput v-model="unitYuan" inputmode="decimal"
|
||||
/></ElFormItem>
|
||||
<ElFormItem label="免费延期次数"
|
||||
><ElInputNumber v-model="form.free_extension_limit" :min="0" :precision="0"
|
||||
/></ElFormItem>
|
||||
<ElFormItem label="付费累计最多月数"
|
||||
><ElInputNumber v-model="form.paid_max_months" :min="0" :precision="0"
|
||||
/></ElFormItem>
|
||||
<ElFormItem label="限制单次月数"><ElSwitch v-model="singleLimited" /></ElFormItem>
|
||||
<ElFormItem v-if="singleLimited" label="单次最多月数"
|
||||
><ElInputNumber v-model="form.single_max_months" :min="1" :precision="0"
|
||||
/></ElFormItem>
|
||||
<ElFormItem label="生效时间" required
|
||||
><ElDatePicker
|
||||
v-model="form.effective_from"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ssZ"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
/></ElFormItem>
|
||||
<ElFormItem label="失效时间"
|
||||
><ElDatePicker
|
||||
v-model="form.effective_to"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ssZ"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
clearable
|
||||
/><p>不填表示长期。</p></ElFormItem
|
||||
>
|
||||
<ElFormItem label="免审批场景"
|
||||
><ElSelect
|
||||
v-model="form.approval_exempt_types"
|
||||
multiple
|
||||
filterable
|
||||
allow-create
|
||||
default-first-option
|
||||
placeholder="空表示全部需要审批"
|
||||
><ElOption value="offline_paid" label="线下付费延期" /><ElOption
|
||||
value="batch"
|
||||
label="批量特殊延期" /><ElOption
|
||||
v-for="value in form.approval_exempt_types.filter(
|
||||
(x) => !['offline_paid', 'batch'].includes(x)
|
||||
)"
|
||||
:key="value"
|
||||
:value="value"
|
||||
:label="value" /></ElSelect
|
||||
><p>接口未枚举完整场景;其他场景须填写后端提供的精确编码,不填写显示文案。</p></ElFormItem
|
||||
>
|
||||
<ElFormItem label="启用"
|
||||
><ElSwitch v-model="form.status" :active-value="1" :inactive-value="0"
|
||||
/></ElFormItem>
|
||||
<ElFormItem label="备注"><ElInput v-model="form.remark" type="textarea" /></ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer
|
||||
><ElButton @click="$emit('close')">取消</ElButton
|
||||
><ElButton
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
:disabled="loading || !allowed || !loaded"
|
||||
@click="submit"
|
||||
>保存</ElButton
|
||||
></template
|
||||
>
|
||||
</ElDialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch, onBeforeUnmount } from 'vue'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { PackageSilenceService as Service } from '@/api/modules/packageSilence'
|
||||
import BusinessEntitySelect from '@/components/business/BusinessEntitySelect.vue'
|
||||
import {
|
||||
silenceData,
|
||||
silenceDate,
|
||||
silenceFen,
|
||||
silenceId,
|
||||
validateSilencePolicy
|
||||
} from '@/utils/business/silenceExtension'
|
||||
import { gatewayError, requireGatewayAccess } from '@/utils/business/gateway'
|
||||
import { pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import type { SilencePolicyRequest } from '@/types/api/packageSilenceContract'
|
||||
const props = defineProps<{ id?: number; allowed: boolean }>(),
|
||||
emit = defineEmits<{ close: []; saved: [] }>(),
|
||||
user = useUserStore()
|
||||
const form = reactive({
|
||||
name: '',
|
||||
scope_type: 'all',
|
||||
scope_ids: [] as (number | string)[],
|
||||
free_extension_limit: 0,
|
||||
paid_max_months: 0,
|
||||
single_max_months: 1,
|
||||
effective_from: '',
|
||||
effective_to: '' as string | null,
|
||||
approval_exempt_types: [] as string[],
|
||||
status: 1,
|
||||
remark: ''
|
||||
})
|
||||
const unitYuan = ref('0.00'),
|
||||
singleLimited = ref(false),
|
||||
loading = ref(false),
|
||||
saving = ref(false),
|
||||
loaded = ref(!props.id),
|
||||
error = ref('')
|
||||
let active = true,
|
||||
version = 0
|
||||
watch(
|
||||
() => [props.id, props.allowed, pollingScope(user)],
|
||||
() => {
|
||||
version++
|
||||
loaded.value = false
|
||||
error.value = ''
|
||||
emit('close')
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
onMounted(async () => {
|
||||
if (!props.id || !props.allowed) return
|
||||
const current = version
|
||||
loading.value = true
|
||||
try {
|
||||
const value = silenceData(await Service.policy(silenceId(props.id)))
|
||||
if (!active || current !== version || !props.allowed) return
|
||||
Object.assign(form, {
|
||||
name: value.name || '',
|
||||
scope_type: value.scope_type || 'all',
|
||||
scope_ids: value.scope_ids || [],
|
||||
free_extension_limit: value.free_extension_limit ?? 0,
|
||||
paid_max_months: value.paid_max_months ?? 0,
|
||||
single_max_months: value.single_max_months ?? 1,
|
||||
effective_from: value.effective_from || '',
|
||||
effective_to: value.effective_to || null,
|
||||
approval_exempt_types: value.approval_exempt_types || [],
|
||||
status: value.status ?? 1,
|
||||
remark: value.remark || ''
|
||||
})
|
||||
unitYuan.value = ((value.unit_price ?? 0) / 100).toFixed(2)
|
||||
singleLimited.value = value.single_max_months != null
|
||||
loaded.value = true
|
||||
} catch (e) {
|
||||
if (current === version) error.value = gatewayError(e)
|
||||
} finally {
|
||||
if (current === version) loading.value = false
|
||||
}
|
||||
})
|
||||
async function submit() {
|
||||
if (saving.value) return
|
||||
saving.value = true
|
||||
const current = version,
|
||||
scope = pollingScope(user)
|
||||
try {
|
||||
requireGatewayAccess(props.allowed && loaded.value)
|
||||
const body: SilencePolicyRequest = {
|
||||
...form,
|
||||
name: form.name.trim(),
|
||||
scope_ids:
|
||||
form.scope_type === 'all' ? [] : form.scope_ids.map((value) => silenceId(Number(value))),
|
||||
unit_price: silenceFen(unitYuan.value),
|
||||
single_max_months: singleLimited.value ? form.single_max_months : null,
|
||||
effective_from: silenceDate(form.effective_from),
|
||||
effective_to: form.effective_to ? silenceDate(form.effective_to) : null,
|
||||
approval_exempt_types: [...form.approval_exempt_types]
|
||||
}
|
||||
validateSilencePolicy(body)
|
||||
await ElMessageBox.confirm(
|
||||
'确认保存延期政策?历史订单和已提交审批不受此次修改影响。',
|
||||
'保存确认',
|
||||
{ type: 'warning' }
|
||||
)
|
||||
requireGatewayAccess(
|
||||
active && current === version && scope === pollingScope(user) && props.allowed
|
||||
)
|
||||
if (props.id) silenceData(await Service.updatePolicy(props.id, { ...body, id: props.id }))
|
||||
else silenceData(await Service.createPolicy(body))
|
||||
if (active && current === version && props.allowed) {
|
||||
emit('saved')
|
||||
emit('close')
|
||||
}
|
||||
} catch (e) {
|
||||
if (active && current === version && e !== 'cancel' && e !== 'close')
|
||||
error.value = gatewayError(e)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
onBeforeUnmount(() => {
|
||||
active = false
|
||||
version++
|
||||
})
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-alert {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
@media (width <= 640px) {
|
||||
:deep(.el-form-item) {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
:deep(.el-form-item__label) {
|
||||
justify-content: flex-start;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
:deep(.el-form-item__content) {
|
||||
flex-basis: 100%;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<ElFormItem label="沉默期(天)"
|
||||
><ElSwitch
|
||||
v-model="overrideEnabled"
|
||||
active-text="调整本次沉默期"
|
||||
inactive-text="使用默认值"
|
||||
:disabled="disabled" />
|
||||
<ElInputNumber
|
||||
v-if="overrideEnabled"
|
||||
v-model="days"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
:controls="false"
|
||||
clearable
|
||||
:disabled="disabled"
|
||||
placeholder="留空使用默认值"
|
||||
/></ElFormItem>
|
||||
<ElFormItem v-if="overrideEnabled" label="调整原因" :required="days != null"
|
||||
><ElInput v-model="reason" type="textarea" :disabled="disabled"
|
||||
/></ElFormItem>
|
||||
<p class="silence-help"
|
||||
>超过默认沉默期可能需审批,以后台返回结果为准;本次覆盖不受商品默认值 90 天上限限制。</p
|
||||
>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
const days = defineModel<number | null>('days', { required: true })
|
||||
const reason = defineModel<string>('reason', { required: true })
|
||||
const overrideEnabled = computed({
|
||||
get: () => days.value != null,
|
||||
set: (enabled: boolean) => {
|
||||
days.value = enabled ? 1 : null
|
||||
if (!enabled) reason.value = ''
|
||||
}
|
||||
})
|
||||
defineProps<{ disabled?: boolean }>()
|
||||
</script>
|
||||
<style scoped>
|
||||
.silence-help {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<ElDialog
|
||||
:model-value="true"
|
||||
:title="firstPurchase ? '首次购买套餐记录' : '沉默期流水'"
|
||||
width="min(1100px, 96vw)"
|
||||
destroy-on-close
|
||||
@close="$emit('close')"
|
||||
>
|
||||
<ElAlert v-if="error" :title="error" type="error" :closable="false" />
|
||||
<SilenceTable :rows="data || []" :definitions="fields" :loading="loading" @refresh="load" />
|
||||
</ElDialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, watch } from 'vue'
|
||||
import { PackageSilenceService as Service } from '@/api/modules/packageSilence'
|
||||
import { useSchedulerRequest } from '@/composables/useSchedulerRequest'
|
||||
import { silenceData, silenceId } from '@/utils/business/silenceExtension'
|
||||
import SilenceTable from './SilenceTable.vue'
|
||||
const props = defineProps<{
|
||||
usageId?: number
|
||||
assetId?: number
|
||||
assetType?: 'card' | 'device'
|
||||
allowed?: boolean
|
||||
}>()
|
||||
defineEmits<{ close: [] }>()
|
||||
const firstPurchase = computed(() => !!props.assetType)
|
||||
const { data, error, loading, load } = useSchedulerRequest<object[]>(
|
||||
async () => {
|
||||
if (props.assetType)
|
||||
return (
|
||||
silenceData(await Service.firstPurchase(props.assetType, silenceId(props.assetId))) || []
|
||||
)
|
||||
return silenceData(await Service.records(silenceId(props.usageId))) || []
|
||||
},
|
||||
() => props.allowed !== false
|
||||
)
|
||||
const fields = computed(() =>
|
||||
(firstPurchase.value
|
||||
? [
|
||||
['generation', '世代'],
|
||||
['first_purchase_at', '首次购买套餐时间'],
|
||||
['source_name', '来源'],
|
||||
['order_no', '订单号'],
|
||||
['ended_at', '世代结束时间'],
|
||||
['end_reason', '结束原因'],
|
||||
['created_at', '记录时间']
|
||||
]
|
||||
: [
|
||||
['created_at', '记录时间'],
|
||||
['event_name', '操作'],
|
||||
['before_status', '变更前状态'],
|
||||
['after_status', '变更后状态'],
|
||||
['before_deadline_at', '变更前截止'],
|
||||
['after_deadline_at', '变更后截止'],
|
||||
['change_days', '变化天数'],
|
||||
['operator_id', '操作人'],
|
||||
['operator_type', '操作人类型'],
|
||||
['reason', '原因'],
|
||||
['trigger_source', '触发来源'],
|
||||
['exchange_no', '换货单号']
|
||||
]
|
||||
).map(([prop, label]) => ({ prop, label }))
|
||||
)
|
||||
watch(() => [props.usageId, props.assetId, props.assetType], load)
|
||||
onMounted(load)
|
||||
</script>
|
||||
89
src/components/business/package-silence/SilenceSummary.vue
Normal file
89
src/components/business/package-silence/SilenceSummary.vue
Normal file
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<div v-if="silence" class="silence-summary">
|
||||
<ElTag :type="silence.silence_status === 'expired' ? 'danger' : 'info'">{{
|
||||
silenceStatusLabel(silence)
|
||||
}}</ElTag>
|
||||
<span
|
||||
>截止:{{
|
||||
silence.silence_deadline_at ? formatDateTime(silence.silence_deadline_at) : '-'
|
||||
}}</span
|
||||
>
|
||||
<span v-if="silence.silence_period_days != null"
|
||||
>初始 {{ silence.silence_period_days }} 天</span
|
||||
>
|
||||
<span v-if="silence.silence_extended_days != null"
|
||||
>累计延期 {{ silence.silence_extended_days }} 天</span
|
||||
>
|
||||
<ElTag v-if="silence.silence_adjust_pending" type="warning">调整审批中</ElTag>
|
||||
<span v-if="silence.silence_paid_extended_days != null"
|
||||
>付费延期 {{ silence.silence_paid_extended_days }} 天</span
|
||||
>
|
||||
<span v-if="silence.silence_extension_count != null"
|
||||
>延期 {{ silence.silence_extension_count }} 次</span
|
||||
>
|
||||
<span v-if="silence.silence_free_extension_used != null"
|
||||
>已用免费次数 {{ silence.silence_free_extension_used }}</span
|
||||
>
|
||||
<ElButton v-if="usageId" link type="primary" @click="recordsVisible = true"
|
||||
>沉默期流水</ElButton
|
||||
>
|
||||
<ElButton
|
||||
v-if="usageId && silence.extendable && (hasAuth(P.extend) || hasAuth(P.offline))"
|
||||
link
|
||||
type="primary"
|
||||
@click="extendVisible = true"
|
||||
>延期</ElButton
|
||||
>
|
||||
<SilenceRecordsDialog
|
||||
v-if="recordsVisible && usageId"
|
||||
:usage-id="usageId"
|
||||
@close="recordsVisible = false"
|
||||
/>
|
||||
<SilenceExtendDialog
|
||||
v-if="extendVisible && usageId"
|
||||
:usage-id="usageId"
|
||||
@close="closeExtension"
|
||||
@changed="dirty = true"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { PACKAGE_SILENCE_PERMISSIONS as P } from '@/config/constants/packageSilence'
|
||||
import SilenceRecordsDialog from './SilenceRecordsDialog.vue'
|
||||
import SilenceExtendDialog from './SilenceExtendDialog.vue'
|
||||
import type { PackageSilenceInfo } from '@/types/api/packageSilence'
|
||||
import { silenceStatusLabel } from '@/utils/business/packageSilence'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
const props = defineProps<{ silence?: PackageSilenceInfo | null; usageId?: number }>()
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
const { hasAuth } = useAuth()
|
||||
const recordsVisible = ref(false),
|
||||
extendVisible = ref(false),
|
||||
dirty = ref(false)
|
||||
function closeExtension() {
|
||||
extendVisible.value = false
|
||||
if (dirty.value) {
|
||||
dirty.value = false
|
||||
emit('changed')
|
||||
}
|
||||
}
|
||||
watch(
|
||||
() => [props.usageId, !!props.silence],
|
||||
() => {
|
||||
recordsVisible.value = false
|
||||
extendVisible.value = false
|
||||
dirty.value = false
|
||||
}
|
||||
)
|
||||
</script>
|
||||
<style scoped>
|
||||
.silence-summary {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
43
src/components/business/package-silence/SilenceTable.vue
Normal file
43
src/components/business/package-silence/SilenceTable.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<ArtTableHeader v-model:columns="columnChecks" @refresh="$emit('refresh')"
|
||||
><template #left><slot name="toolbar" /></template
|
||||
></ArtTableHeader>
|
||||
<ArtTable
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:row-key="rowKey || 'id'"
|
||||
:pagination="total != null"
|
||||
:current-page="page || 1"
|
||||
:page-size="size || 20"
|
||||
:total="total || 0"
|
||||
:margin-top="10"
|
||||
@current-change="(value) => $emit('page', value)"
|
||||
@size-change="(value) => $emit('size', value)"
|
||||
>
|
||||
<ElTableColumn
|
||||
v-for="column in columns"
|
||||
:key="column.prop"
|
||||
:prop="column.prop"
|
||||
:label="column.label"
|
||||
:min-width="column.width || 170"
|
||||
show-overflow-tooltip
|
||||
><template #default="{ row }">{{ silenceDisplay(row, column.prop) }}</template></ElTableColumn
|
||||
>
|
||||
<slot />
|
||||
</ArtTable>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useGatewayColumns } from '@/composables/useGateway'
|
||||
import { silenceDisplay } from '@/utils/business/silenceExtension'
|
||||
const props = defineProps<{
|
||||
rows: object[]
|
||||
rowKey?: string
|
||||
definitions: { prop: string; label: string; width?: number }[]
|
||||
loading?: boolean
|
||||
page?: number
|
||||
size?: number
|
||||
total?: number
|
||||
}>()
|
||||
defineEmits<{ refresh: []; page: [number]; size: [number] }>()
|
||||
const { columns, columnChecks } = useGatewayColumns(props.definitions)
|
||||
</script>
|
||||
@@ -69,18 +69,21 @@
|
||||
props.kind
|
||||
]
|
||||
)
|
||||
const permission = () => SCHEDULER_PERMISSIONS[props.kind].detailPage
|
||||
const { data, loading, error, load } = useSchedulerRequest<Record<string, any>>(
|
||||
async () => {
|
||||
const id = Number(route.params.id ?? route.params.carrier_id)
|
||||
validateGatewayInteger(id, 1, Number.MAX_SAFE_INTEGER, '记录 ID')
|
||||
if (props.kind === 'params') return gatewayData(await Service.getCarrierParam(id))
|
||||
if (props.kind === 'alerts') return gatewayData(await Service.getAlert(id))
|
||||
return gatewayData(await Service.getImport(id))
|
||||
},
|
||||
() =>
|
||||
hasAuth(permission()) && (props.kind !== 'imports' || isPollingPlatform(user.info.user_type))
|
||||
)
|
||||
const canReadDetail = () => {
|
||||
const permissions = SCHEDULER_PERMISSIONS[props.kind]
|
||||
return (
|
||||
hasAuth(permissions.detailPage) &&
|
||||
hasAuth(permissions.detail) &&
|
||||
(props.kind !== 'imports' || isPollingPlatform(user.info.user_type))
|
||||
)
|
||||
}
|
||||
const { data, loading, error, load } = useSchedulerRequest<Record<string, any>>(async () => {
|
||||
const id = Number(route.params.id ?? route.params.carrier_id)
|
||||
validateGatewayInteger(id, 1, Number.MAX_SAFE_INTEGER, '记录 ID')
|
||||
if (props.kind === 'params') return gatewayData(await Service.getCarrierParam(id))
|
||||
if (props.kind === 'alerts') return gatewayData(await Service.getAlert(id))
|
||||
return gatewayData(await Service.getImport(id))
|
||||
}, canReadDetail)
|
||||
const maps = {
|
||||
params: [
|
||||
['carrier_name', '运营商账户'],
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
<el-form :model="filter" :label-position="props.labelPosition">
|
||||
<el-row class="search-form-row" :gutter="props.gutter">
|
||||
<el-col
|
||||
v-for="item in useFormItemArr"
|
||||
v-for="(item, index) in props.items"
|
||||
:key="item.prop"
|
||||
v-show="index < visibleItemCount"
|
||||
:xs="24"
|
||||
:sm="12"
|
||||
:md="item.elColSpan || props.elColSpan"
|
||||
@@ -73,6 +74,7 @@
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import ArtSearchInput from './widget/art-search-input/index.vue'
|
||||
import ArtSearchSelect from './widget/art-search-select/index.vue'
|
||||
import ArtSearchBusinessSelect from './widget/art-search-business-select/index.vue'
|
||||
import ArtSearchRadio from './widget/art-search-radio/index.vue'
|
||||
import ArtSearchDate from './widget/art-search-date/index.vue'
|
||||
import ArtSearchTreeSelect from './widget/art-search-tree-select/index.vue'
|
||||
@@ -81,7 +83,7 @@
|
||||
const { width } = useWindowSize()
|
||||
const isMobile = computed(() => width.value < 500)
|
||||
|
||||
type FilterVo = string | number | undefined | null | unknown[]
|
||||
type FilterVo = string | number | boolean | undefined | null | unknown[]
|
||||
|
||||
interface PropsVO {
|
||||
filter: Record<string, FilterVo> // 查询参数
|
||||
@@ -113,15 +115,10 @@
|
||||
|
||||
const isShow = ref(false)
|
||||
|
||||
const useFormItemArr = computed(() => {
|
||||
const isshowLess = !props.isExpand && !isShow.value
|
||||
if (isshowLess) {
|
||||
const num = Math.floor(24 / props.elColSpan) - 1
|
||||
return props.items.slice(0, num)
|
||||
} else {
|
||||
return props.items
|
||||
}
|
||||
})
|
||||
// 收起时保留控件实例,避免远程选中项的名称和候选缓存在重新展开后丢失。
|
||||
const visibleItemCount = computed(() =>
|
||||
!props.isExpand && !isShow.value ? Math.floor(24 / props.elColSpan) - 1 : props.items.length
|
||||
)
|
||||
|
||||
const filter = computed({
|
||||
get: () => props.filter,
|
||||
@@ -132,6 +129,7 @@
|
||||
const componentsMap: Record<string, any> = {
|
||||
input: ArtSearchInput,
|
||||
select: ArtSearchSelect,
|
||||
'business-select': ArtSearchBusinessSelect,
|
||||
'tree-select': ArtSearchTreeSelect,
|
||||
radio: ArtSearchRadio,
|
||||
datetime: ArtSearchDate,
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<template>
|
||||
<BusinessEntitySelect
|
||||
v-model="value"
|
||||
v-bind="item.config"
|
||||
:entity="entity"
|
||||
:placeholder="item.placeholder"
|
||||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import BusinessEntitySelect from '@/components/business/BusinessEntitySelect.vue'
|
||||
import type { BusinessOptionKind } from '@/api/modules/businessOptions'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
const props = defineProps<{ value: unknown; item: SearchFormItem }>()
|
||||
const emit = defineEmits<{ 'update:value': [value: unknown] }>()
|
||||
const entity = computed(() => props.item.config?.entity as BusinessOptionKind)
|
||||
const value = computed({
|
||||
get: () => props.value as string | number | (string | number)[] | null | undefined,
|
||||
set: (value) => emit('update:value', value)
|
||||
})
|
||||
</script>
|
||||
@@ -52,5 +52,5 @@ export function useSchedulerRequest<T>(request: () => Promise<T>, allowed: () =>
|
||||
active = false
|
||||
clear()
|
||||
})
|
||||
return { data, loading, error, load }
|
||||
return { data, loading, error, load, clear }
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@ export interface ExportTaskScenePermissions {
|
||||
}
|
||||
|
||||
export const EXPORT_TASK_DETAIL_PAGE_PERMISSION = 'export_task:detail_page'
|
||||
export const canAccessExportTaskScene = (scene: ExportTaskScene | undefined, userType: unknown) =>
|
||||
scene === 'order_online'
|
||||
? [1, 2].includes(Number(userType))
|
||||
: ['order', 'order_platform', 'order_agent'].includes(scene || '')
|
||||
? [1, 2, 3].includes(Number(userType))
|
||||
: true
|
||||
export const isPollingPlatformExport = (scene?: ExportTaskScene) =>
|
||||
!!scene &&
|
||||
['polling_pause', 'polling_stop_refused_alert', 'stop_resume_rule_dry_run'].includes(scene)
|
||||
@@ -19,6 +25,56 @@ export interface ExportTaskSceneConfig {
|
||||
}
|
||||
|
||||
export const EXPORT_TASK_SCENE_CONFIG: Record<ExportTaskScene, ExportTaskSceneConfig> = {
|
||||
package_silence_order: {
|
||||
scene: 'package_silence_order',
|
||||
sceneName: '沉默期延期订单',
|
||||
pageTitle: '导出延期订单',
|
||||
permissions: {
|
||||
page: 'export_task:package_silence_order_page',
|
||||
detail: 'export_task:package_silence_order_detail',
|
||||
download: 'export_task:package_silence_order_download'
|
||||
}
|
||||
},
|
||||
package_silence_usage: {
|
||||
scene: 'package_silence_usage',
|
||||
sceneName: '沉默期套餐清单',
|
||||
pageTitle: '导出沉默期套餐',
|
||||
permissions: {
|
||||
page: 'export_task:package_silence_usage_page',
|
||||
detail: 'export_task:package_silence_usage_detail',
|
||||
download: 'export_task:package_silence_usage_download'
|
||||
}
|
||||
},
|
||||
order_platform: {
|
||||
scene: 'order_platform',
|
||||
sceneName: '平台订单',
|
||||
pageTitle: '导出平台订单',
|
||||
permissions: {
|
||||
page: 'export_task:order_platform_page',
|
||||
detail: 'export_task:order_platform_detail',
|
||||
download: 'export_task:order_platform_download'
|
||||
}
|
||||
},
|
||||
order_agent: {
|
||||
scene: 'order_agent',
|
||||
sceneName: '代理商订单',
|
||||
pageTitle: '导出代理商订单',
|
||||
permissions: {
|
||||
page: 'export_task:order_agent_page',
|
||||
detail: 'export_task:order_agent_detail',
|
||||
download: 'export_task:order_agent_download'
|
||||
}
|
||||
},
|
||||
order_online: {
|
||||
scene: 'order_online',
|
||||
sceneName: '在线支付订单',
|
||||
pageTitle: '导出在线支付订单',
|
||||
permissions: {
|
||||
page: 'export_task:order_online_page',
|
||||
detail: 'export_task:order_online_detail',
|
||||
download: 'export_task:order_online_download'
|
||||
}
|
||||
},
|
||||
polling_pause: {
|
||||
scene: 'polling_pause',
|
||||
sceneName: '不轮询清单',
|
||||
|
||||
29
src/config/constants/packageSilence.ts
Normal file
29
src/config/constants/packageSilence.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
export const PACKAGE_SILENCE_PERMISSIONS = {
|
||||
override: 'package_silence:override',
|
||||
extend: 'package_silence:extend',
|
||||
batch: 'package_silence:extend_batch',
|
||||
offline: 'package_silence:offline',
|
||||
exception: 'package_silence:exception',
|
||||
policy: 'package_silence:policy'
|
||||
} as const
|
||||
export const SILENCE_PAGES = {
|
||||
orders: {
|
||||
page: 'package_silence:orders_page',
|
||||
detail: 'package_silence:order_detail',
|
||||
detailPage: 'package_silence:order_detail_page',
|
||||
export: 'package_silence:order_export'
|
||||
},
|
||||
batches: {
|
||||
page: 'package_silence:batches_page',
|
||||
detail: 'package_silence:batch_detail',
|
||||
detailPage: 'package_silence:batch_detail_page'
|
||||
},
|
||||
usages: { page: 'package_silence:usages_page', export: 'package_silence:usage_export' },
|
||||
policies: { page: 'package_silence:policies_page' }
|
||||
} as const
|
||||
export const ORDER_CATEGORY_CONFIG = {
|
||||
all: { title: '订单列表', scene: 'order', page: '' },
|
||||
platform: { title: '平台订单', scene: 'order_platform', page: 'orders:platform_page' },
|
||||
agent: { title: '代理商订单', scene: 'order_agent', page: 'orders:agent_page' },
|
||||
online: { title: '在线支付订单', scene: 'order_online', page: 'orders:online_page' }
|
||||
} as const
|
||||
@@ -275,7 +275,11 @@ async function processBackendMenu(router: Router): Promise<void> {
|
||||
.map((menu) => convertBackendMenuToRoute(menu, routeMap))
|
||||
.filter((route) => route !== null)
|
||||
|
||||
const finalMenuList = mergeDefaultMenus(menuList, routeMap)
|
||||
const finalMenuList = filterMenuByRoles(
|
||||
mergeDefaultMenus(menuList, routeMap),
|
||||
userStore.info.roles || [],
|
||||
Number(userStore.info.user_type)
|
||||
)
|
||||
await registerAndStoreMenu(router, finalMenuList, closeLoading)
|
||||
} catch (error) {
|
||||
closeLoading()
|
||||
|
||||
@@ -7,6 +7,7 @@ import { AUGUST_PERMISSIONS } from '@/config/constants/augustIteration'
|
||||
import { GATEWAY_PERMISSIONS } from '@/config/constants/gateway'
|
||||
import { POLLING_CONFIG_PERMISSIONS } from '@/config/constants/pollingConfig'
|
||||
import { SCHEDULER_PERMISSIONS } from '@/config/constants/pollingScheduler'
|
||||
import { SILENCE_PAGES, PACKAGE_SILENCE_PERMISSIONS } from '@/config/constants/packageSilence'
|
||||
import { PAYMENT_MERCHANT_POOL_PERMISSIONS } from '@/config/constants/paymentMerchantPools'
|
||||
import {
|
||||
EXPORT_TASK_DETAIL_PAGE_PERMISSION,
|
||||
@@ -165,6 +166,64 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
icon: ''
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'silence-orders',
|
||||
name: 'SilenceOrders',
|
||||
component: RoutesAlias.SilenceOrders,
|
||||
meta: { title: '延期订单', keepAlive: true, permissions: [SILENCE_PAGES.orders.page] }
|
||||
},
|
||||
{
|
||||
path: 'silence-orders/detail/:id',
|
||||
name: 'SilenceOrderDetail',
|
||||
component: RoutesAlias.SilenceOrderDetail,
|
||||
meta: {
|
||||
title: '延期订单详情',
|
||||
isHide: true,
|
||||
keepAlive: false,
|
||||
permissions: [SILENCE_PAGES.orders.detailPage]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'silence-batches',
|
||||
name: 'SilenceBatches',
|
||||
component: RoutesAlias.SilenceBatches,
|
||||
meta: {
|
||||
title: '延期批次与异常',
|
||||
keepAlive: true,
|
||||
permissions: [SILENCE_PAGES.batches.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'silence-batches/detail/:id',
|
||||
name: 'SilenceBatchDetail',
|
||||
component: RoutesAlias.SilenceBatchDetail,
|
||||
meta: {
|
||||
title: '延期批次详情',
|
||||
isHide: true,
|
||||
keepAlive: false,
|
||||
permissions: [SILENCE_PAGES.batches.detailPage]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'silence-usages',
|
||||
name: 'SilenceUsages',
|
||||
component: RoutesAlias.SilenceUsages,
|
||||
meta: {
|
||||
title: '沉默期临期/过期套餐',
|
||||
keepAlive: true,
|
||||
permissions: [SILENCE_PAGES.usages.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'silence-policies',
|
||||
name: 'SilencePolicies',
|
||||
component: RoutesAlias.SilencePolicies,
|
||||
meta: {
|
||||
title: '延期政策',
|
||||
keepAlive: true,
|
||||
permissions: [SILENCE_PAGES.policies.page, PACKAGE_SILENCE_PERMISSIONS.policy]
|
||||
}
|
||||
},
|
||||
// 套餐系列
|
||||
{
|
||||
path: 'package-series',
|
||||
@@ -684,6 +743,42 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-order-platform',
|
||||
name: 'ExportPlatformOrder',
|
||||
component: RoutesAlias.ExportPlatformOrder,
|
||||
meta: {
|
||||
title: '导出平台订单',
|
||||
exportTaskScene: 'order_platform',
|
||||
keepAlive: true,
|
||||
allowedUserTypes: [1, 2, 3],
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.order_platform.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-order-agent',
|
||||
name: 'ExportAgentOrder',
|
||||
component: RoutesAlias.ExportAgentOrder,
|
||||
meta: {
|
||||
title: '导出代理商订单',
|
||||
exportTaskScene: 'order_agent',
|
||||
keepAlive: true,
|
||||
allowedUserTypes: [1, 2, 3],
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.order_agent.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-order-online',
|
||||
name: 'ExportOnlineOrder',
|
||||
component: RoutesAlias.ExportOnlineOrder,
|
||||
meta: {
|
||||
title: '导出在线支付订单',
|
||||
exportTaskScene: 'order_online',
|
||||
keepAlive: true,
|
||||
allowedUserTypes: [1, 2],
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.order_online.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-order',
|
||||
name: 'ExportOrderTaskList',
|
||||
@@ -835,6 +930,28 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.stop_resume_rule_dry_run.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-silence-order',
|
||||
name: 'ExportSilenceOrder',
|
||||
component: RoutesAlias.ExportSilenceOrder,
|
||||
meta: {
|
||||
title: '导出延期订单',
|
||||
exportTaskScene: 'package_silence_order',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.package_silence_order.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-silence-usage',
|
||||
name: 'ExportSilenceUsage',
|
||||
component: RoutesAlias.ExportSilenceUsage,
|
||||
meta: {
|
||||
title: '导出沉默期套餐',
|
||||
exportTaskScene: 'package_silence_usage',
|
||||
keepAlive: true,
|
||||
permissions: [EXPORT_TASK_SCENE_CONFIG.package_silence_usage.permissions.page]
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'export-task-detail',
|
||||
name: 'ExportTaskDetail',
|
||||
@@ -856,9 +973,43 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
component: RoutesAlias.Home,
|
||||
meta: {
|
||||
title: 'menus.orderManagement.title',
|
||||
allowedUserTypes: [1, 2, 3],
|
||||
icon: ''
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'platform-orders',
|
||||
name: 'PlatformOrderList',
|
||||
component: RoutesAlias.PlatformOrderList,
|
||||
meta: {
|
||||
title: '平台订单',
|
||||
keepAlive: true,
|
||||
allowedUserTypes: [1, 2, 3],
|
||||
permissions: ['orders:platform_page']
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'agent-orders',
|
||||
name: 'AgentOrderList',
|
||||
component: RoutesAlias.AgentOrderList,
|
||||
meta: {
|
||||
title: '代理商订单',
|
||||
keepAlive: true,
|
||||
allowedUserTypes: [1, 2, 3],
|
||||
permissions: ['orders:agent_page']
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'online-orders',
|
||||
name: 'OnlineOrderList',
|
||||
component: RoutesAlias.OnlineOrderList,
|
||||
meta: {
|
||||
title: '在线支付订单',
|
||||
keepAlive: true,
|
||||
allowedUserTypes: [1, 2],
|
||||
permissions: ['orders:online_page']
|
||||
}
|
||||
},
|
||||
// 订单列表
|
||||
{
|
||||
path: 'order-list',
|
||||
@@ -866,6 +1017,7 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
component: RoutesAlias.OrderList,
|
||||
meta: {
|
||||
title: 'menus.orderManagement.orderList',
|
||||
allowedUserTypes: [1, 2, 3],
|
||||
keepAlive: true
|
||||
}
|
||||
},
|
||||
@@ -876,6 +1028,7 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
component: RoutesAlias.OrderDetail,
|
||||
meta: {
|
||||
title: 'menus.orderManagement.orderDetail',
|
||||
allowedUserTypes: [1, 2, 3],
|
||||
isHide: true,
|
||||
keepAlive: false
|
||||
}
|
||||
@@ -1202,6 +1355,12 @@ export const asyncRoutes: AppRouteRecord[] = [
|
||||
roles: ['R_SUPER']
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'package-silence-switch',
|
||||
name: 'PackageSilenceSwitch',
|
||||
component: RoutesAlias.PackageSilenceSwitch,
|
||||
meta: { title: '沉默期总开关', keepAlive: false, allowedUserTypes: [1] }
|
||||
},
|
||||
// 系统配置
|
||||
{
|
||||
path: 'system-configs',
|
||||
|
||||
@@ -98,6 +98,21 @@ export enum RoutesAlias {
|
||||
|
||||
// 订单管理
|
||||
OrderList = '/order-management/order-list', // 订单列表
|
||||
PackageSilenceSwitch = '/settings/package-silence-switch',
|
||||
SilenceOrders = '/package-management/silence-orders',
|
||||
SilenceOrderDetail = '/package-management/silence-orders/detail',
|
||||
SilenceBatches = '/package-management/silence-batches',
|
||||
SilenceBatchDetail = '/package-management/silence-batches/detail',
|
||||
SilenceUsages = '/package-management/silence-usages',
|
||||
SilencePolicies = '/package-management/silence-policies',
|
||||
ExportSilenceOrder = '/asset-management/export-task-management/export-silence-order',
|
||||
ExportSilenceUsage = '/asset-management/export-task-management/export-silence-usage',
|
||||
PlatformOrderList = '/order-management/platform-orders',
|
||||
AgentOrderList = '/order-management/agent-orders',
|
||||
OnlineOrderList = '/order-management/online-orders',
|
||||
ExportPlatformOrder = '/asset-management/export-task-management/export-order-platform',
|
||||
ExportAgentOrder = '/asset-management/export-task-management/export-order-agent',
|
||||
ExportOnlineOrder = '/asset-management/export-task-management/export-order-online',
|
||||
OrderDetail = '/order-management/order-list/detail', // 订单详情
|
||||
// 财务管理
|
||||
AgentRecharge = '/finance/agent-recharge', // 代理充值
|
||||
|
||||
@@ -157,6 +157,7 @@ export interface AssetExchangeTrace {
|
||||
* 对应接口:GET /api/admin/assets/resolve/:identifier
|
||||
*/
|
||||
export interface AssetResolveResponse {
|
||||
first_purchase_at?: string | null
|
||||
asset_type: AssetType // 资产类型:card 或 device
|
||||
asset_id: number // 数据库 ID
|
||||
associated_phones?: string[] // 当前关联手机号列表(按资产数据范围返回完整手机号,无关联时为空数组)
|
||||
@@ -342,6 +343,7 @@ export type AssetRefreshResponse = AssetRealtimeStatusResponse
|
||||
* 对应接口:GET /api/admin/assets/:identifier/packages
|
||||
*/
|
||||
export interface AssetPackageUsageRecord {
|
||||
silence?: import('./packageSilence').PackageSilenceInfo | null
|
||||
id?: number // 兼容前端当前映射字段
|
||||
package_usage_id?: number // 套餐使用记录 ID
|
||||
package_id?: number // 套餐 ID
|
||||
|
||||
@@ -355,6 +355,8 @@ export enum StandaloneCardStatus {
|
||||
|
||||
// 单卡查询参数
|
||||
export interface StandaloneCardQueryParams extends PaginationParams {
|
||||
first_purchase_start?: string
|
||||
first_purchase_end?: string
|
||||
enable_polling?: boolean
|
||||
keyword?: string // 通用关键字搜索
|
||||
has_active_package?: boolean // has active package filter
|
||||
@@ -382,6 +384,7 @@ export interface StandaloneCardQueryParams extends PaginationParams {
|
||||
|
||||
// 单卡信息
|
||||
export interface StandaloneIotCard {
|
||||
first_purchase_at?: string | null
|
||||
gateway_card_imei?: string // 网关侧返回的卡 IMEI(可空)
|
||||
id: number // 卡ID
|
||||
iccid: string // ICCID
|
||||
|
||||
@@ -37,6 +37,7 @@ export type SwitchMode = '0' | '1' // 0=自动, 1=手动
|
||||
|
||||
// 设备信息
|
||||
export interface Device {
|
||||
first_purchase_at?: string | null
|
||||
enable_polling?: boolean
|
||||
id: number // 设备ID
|
||||
virtual_no: string // 虚拟号(原 device_no)
|
||||
@@ -84,6 +85,8 @@ export interface Device {
|
||||
|
||||
// 设备查询参数
|
||||
export interface DeviceQueryParams extends PaginationParams {
|
||||
first_purchase_start?: string
|
||||
first_purchase_end?: string
|
||||
enable_polling?: boolean
|
||||
has_active_package?: boolean // has active package filter
|
||||
real_name_status?: 0 | 1 // 实名状态:0 未实名 / 1 已实名
|
||||
|
||||
@@ -4,6 +4,11 @@ export type ExportTaskScene =
|
||||
| 'device'
|
||||
| 'iot_card'
|
||||
| 'order'
|
||||
| 'order_platform'
|
||||
| 'order_agent'
|
||||
| 'order_online'
|
||||
| 'package_silence_order'
|
||||
| 'package_silence_usage'
|
||||
| 'package'
|
||||
| 'agent_wallet_transaction'
|
||||
| 'agent_recharge'
|
||||
@@ -77,7 +82,7 @@ export interface ExportTaskListResponse {
|
||||
export interface CreateExportTaskRequest {
|
||||
scene: ExportTaskScene
|
||||
format: ExportTaskFormat
|
||||
query?: Record<string, string>
|
||||
query?: Record<string, string | Record<string, unknown>>
|
||||
}
|
||||
|
||||
export interface CreateExportTaskResponse {
|
||||
|
||||
@@ -155,6 +155,8 @@ export interface OrderListResponse {
|
||||
|
||||
// 创建订单请求
|
||||
export interface CreateOrderRequest {
|
||||
silence_period_days?: number
|
||||
silence_reason?: string
|
||||
order_type?: OrderType // 订单类型
|
||||
iot_card_id?: number | null // IoT卡ID
|
||||
device_id?: number | null // 设备ID
|
||||
|
||||
@@ -152,6 +152,9 @@ export interface ShopPackageBatchAllocationsResponse {
|
||||
* 套餐响应
|
||||
*/
|
||||
export interface PackageResponse extends PackageAllocationExpiryBaseFields {
|
||||
silence_period_days?: number | null
|
||||
silence_extension_enabled?: boolean
|
||||
silence_config_required?: boolean
|
||||
id: number
|
||||
package_code: string
|
||||
package_name: string
|
||||
@@ -190,6 +193,7 @@ export interface PackageResponse extends PackageAllocationExpiryBaseFields {
|
||||
* 套餐查询参数
|
||||
*/
|
||||
export interface PackageQueryParams extends PaginationParams {
|
||||
silence_unconfigured?: boolean
|
||||
package_name?: string // 套餐名称(模糊搜索)
|
||||
series_id?: number // 系列ID
|
||||
package_type?: string // 套餐类型
|
||||
@@ -201,6 +205,8 @@ export interface PackageQueryParams extends PaginationParams {
|
||||
* 创建套餐请求
|
||||
*/
|
||||
export interface CreatePackageRequest {
|
||||
silence_period_days?: number | null
|
||||
silence_extension_enabled?: boolean
|
||||
package_code: string // 套餐编码,必填
|
||||
package_name: string // 套餐名称,必填
|
||||
series_id?: number | null // 所属系列ID,可选
|
||||
@@ -222,6 +228,8 @@ export interface CreatePackageRequest {
|
||||
* 更新套餐请求
|
||||
*/
|
||||
export interface UpdatePackageRequest {
|
||||
silence_period_days?: number | null
|
||||
silence_extension_enabled?: boolean
|
||||
package_name?: string | null // 套餐名称,可选
|
||||
series_id?: number | null // 所属系列ID,可选
|
||||
package_type?: string | null // 套餐类型,可选 (formal:正式套餐, addon:附加套餐)
|
||||
|
||||
24
src/types/api/packageSilence.ts
Normal file
24
src/types/api/packageSilence.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export interface PackageSilenceInfo {
|
||||
silence_status: string
|
||||
silence_status_name?: string
|
||||
silence_deadline_at?: string | null
|
||||
silence_start_at?: string | null
|
||||
silence_period_days?: number | null
|
||||
silence_extended_days?: number
|
||||
silence_paid_extended_days?: number
|
||||
silence_extension_count?: number
|
||||
silence_free_extension_used?: number
|
||||
silence_expired_at?: string | null
|
||||
silence_adjust_pending?: boolean
|
||||
extendable: boolean
|
||||
}
|
||||
export interface SilenceSwitchCheck {
|
||||
code: string
|
||||
name: string
|
||||
passed: boolean
|
||||
count: number
|
||||
}
|
||||
export interface SilenceSwitchState {
|
||||
enabled: boolean
|
||||
precheck: SilenceSwitchCheck[]
|
||||
}
|
||||
667
src/types/api/packageSilenceContract.ts
Normal file
667
src/types/api/packageSilenceContract.ts
Normal file
@@ -0,0 +1,667 @@
|
||||
// Generated from docs/api/package-silence.openapi.json (Apifox, 2026-10-28).
|
||||
// Financial values use integer fen. Missing optional response fields are not fabricated.
|
||||
|
||||
export interface AssetFirstPurchaseRecordResponse {
|
||||
/** 资产 ID */
|
||||
asset_id?: number
|
||||
/** 资产标识快照 */
|
||||
asset_identifier?: string
|
||||
/** 资产类型 */
|
||||
asset_type?: string
|
||||
/** 记录时间 */
|
||||
created_at?: string
|
||||
/** 结束原因:exchange_return 换货回库 */
|
||||
end_reason?: string
|
||||
/** 该世代结束时间 */
|
||||
ended_at?: string | null
|
||||
/** 首次购买套餐时间 */
|
||||
first_purchase_at?: string
|
||||
/** 世代 */
|
||||
generation?: number
|
||||
/** 记录 ID */
|
||||
id?: number
|
||||
/** 订单号 */
|
||||
order_no?: string
|
||||
/** 来源:order 首次购买套餐 / backfill 历史回填 */
|
||||
source?: string
|
||||
/** 来源名称 */
|
||||
source_name?: string
|
||||
}
|
||||
|
||||
export interface SilenceBatchPageResult {
|
||||
/** 批次列表 */
|
||||
items?: Array<SilenceBatchResponse>
|
||||
/** 页码 */
|
||||
page?: number
|
||||
/** 每页数量 */
|
||||
page_size?: number
|
||||
/** 总数 */
|
||||
total?: number
|
||||
}
|
||||
|
||||
export interface SilenceBatchResponse {
|
||||
/** 费用(分) */
|
||||
amount?: number
|
||||
/** 审批实例 ID */
|
||||
approval_instance_id?: number | null
|
||||
/** 是否需要审批 */
|
||||
approval_required?: boolean
|
||||
/** 审批状态 */
|
||||
approval_status?: string
|
||||
/** 依据 */
|
||||
basis?: string
|
||||
/** 批次号 */
|
||||
batch_no?: string
|
||||
/** 完成时间 */
|
||||
completed_at?: string | null
|
||||
/** 附件 */
|
||||
evidence_refs?: Array<string>
|
||||
/** 延期类型 */
|
||||
extension_type?: string
|
||||
/** 失败数 */
|
||||
failed_count?: number
|
||||
/** 批次 ID */
|
||||
id?: number
|
||||
/** 明细 */
|
||||
items?: Array<SilenceExtensionResponse>
|
||||
/** 路径:online / offline / special / adjust */
|
||||
path?: string
|
||||
/** 原因 */
|
||||
reason?: string
|
||||
/** 发起时间 */
|
||||
requested_at?: string
|
||||
/** 发起人 */
|
||||
requested_by?: number
|
||||
/** 明细数 */
|
||||
requested_count?: number
|
||||
/** 批次状态 */
|
||||
status?: string
|
||||
/** 成功数 */
|
||||
succeeded_count?: number
|
||||
}
|
||||
|
||||
export interface SilenceExtensionResponse {
|
||||
/** 延期后截止时间 */
|
||||
after_deadline_at?: string | null
|
||||
/** 金额(分) */
|
||||
amount?: number
|
||||
/** 资产标识 */
|
||||
asset_identifier?: string
|
||||
/** 资产类型 */
|
||||
asset_type?: string
|
||||
/** 批次 ID */
|
||||
batch_id?: number
|
||||
/** 延期前截止时间 */
|
||||
before_deadline_at?: string | null
|
||||
/** 执行时间 */
|
||||
executed_at?: string | null
|
||||
/** 延长天数 */
|
||||
extension_days?: number
|
||||
/** 延期订单 ID */
|
||||
extension_order_id?: number | null
|
||||
/** 延期类型 */
|
||||
extension_type?: string
|
||||
/** 失败 / 异常原因码 */
|
||||
failure_code?: string
|
||||
/** 失败 / 异常说明 */
|
||||
failure_summary?: string
|
||||
/** 明细 ID */
|
||||
id?: number
|
||||
/** 输入天数 */
|
||||
input_days?: number
|
||||
/** 计费月数 */
|
||||
months?: number
|
||||
/** 套餐名称 */
|
||||
package_name?: string
|
||||
/** 套餐记录 ID */
|
||||
package_usage_id?: number
|
||||
/** 行号 */
|
||||
row_no?: number
|
||||
/** 明细状态 */
|
||||
status?: string
|
||||
}
|
||||
|
||||
export interface SilenceEligibilityResponse {
|
||||
/** 能否办理付费延期 */
|
||||
can_extend?: boolean
|
||||
/** 已累计延期天数 */
|
||||
extended_days?: number
|
||||
/** 套餐是否支持付费延期 */
|
||||
extension_enabled?: boolean
|
||||
/** 是否还能申请免费延期 */
|
||||
free_extension_available?: boolean
|
||||
/** 免费延期次数上限 */
|
||||
free_extension_limit?: number
|
||||
/** 已使用免费延期次数 */
|
||||
free_extension_used?: number
|
||||
/** 本次付费延期可输入的最多天数 */
|
||||
max_days?: number
|
||||
/** 本次付费延期最多月数(特殊延期不受此限) */
|
||||
max_months?: number
|
||||
/** 可输入的最少天数(付费与特殊延期都适用) */
|
||||
min_days?: number
|
||||
/** 最少延期月数 */
|
||||
min_months?: number
|
||||
/** min~max 每档计费天数、金额与新截止日期 */
|
||||
options?: Array<SilenceExtensionOption>
|
||||
/** 当前截止日期(YYYY-MM-DD) */
|
||||
original_deadline?: string
|
||||
/** 已过期天数 */
|
||||
overdue_days?: number
|
||||
/** 套餐记录 ID */
|
||||
package_usage_id?: number
|
||||
/** 其中付费延期累计天数 */
|
||||
paid_extended_days?: number
|
||||
/** 未结束的延期订单号(有则不能新建,需先完成或关闭) */
|
||||
pending_order_no?: string
|
||||
/** 当前匹配的延期政策 ID */
|
||||
policy_id?: number | null
|
||||
/** 当前匹配的延期政策名称 */
|
||||
policy_name?: string
|
||||
/** 付费延期不能办理的原因:not_expired/no_silence/extension_disabled/no_policy/exceeds_limit/refunded/order_pending/activated/adjust_pending */
|
||||
reason?: string
|
||||
/** 沉默期状态(待实名但已到期的先判定为过期) */
|
||||
silence_status?: string
|
||||
/** 能否申请特殊延期(只要求套餐已过期) */
|
||||
special_extension_available?: boolean
|
||||
/** 每月单价(分),取当前匹配的延期政策 */
|
||||
unit_price?: number
|
||||
}
|
||||
|
||||
export interface SilenceExtensionOption {
|
||||
/** 金额(分) */
|
||||
amount?: number
|
||||
/** 计费 / 延长天数(月数 × 30) */
|
||||
billed_days?: number
|
||||
/** 计费月数 */
|
||||
months?: number
|
||||
/** 新截止日期(YYYY-MM-DD,当日 23:59:59 截止) */
|
||||
new_deadline?: string
|
||||
}
|
||||
|
||||
export interface SilenceExceptionHandleParams {
|
||||
/** 处理方式:retry 重试执行 / close 关闭(在线订单关闭时原路退款) */
|
||||
action: string
|
||||
/** 延期明细 ID */
|
||||
id: number
|
||||
/** 处理原因 */
|
||||
reason: string
|
||||
}
|
||||
|
||||
export interface SilenceOrderPageResult {
|
||||
/** 订单列表 */
|
||||
items?: Array<SilenceExtensionOrderResponse>
|
||||
/** 页码 */
|
||||
page?: number
|
||||
/** 每页数量 */
|
||||
page_size?: number
|
||||
/** 总数 */
|
||||
total?: number
|
||||
}
|
||||
|
||||
export interface SilenceExtensionOrderResponse {
|
||||
/** 应付金额(分) */
|
||||
amount?: number
|
||||
/** 审批实例 ID */
|
||||
approval_instance_id?: number | null
|
||||
/** 是否需要审批 */
|
||||
approval_required?: boolean
|
||||
/** 资产 ID */
|
||||
asset_id?: number
|
||||
/** 资产标识快照 */
|
||||
asset_identifier?: string
|
||||
/** 资产类型 iot_card / device */
|
||||
asset_type?: string
|
||||
/** 批次号 */
|
||||
batch_no?: string
|
||||
/** 下单时截止时间 */
|
||||
before_deadline_at?: string
|
||||
/** 延期生效时间 */
|
||||
completed_at?: string | null
|
||||
/** 创建时间 */
|
||||
created_at?: string
|
||||
/** 后台创建人 */
|
||||
created_by?: number | null
|
||||
/** H5 下单的客户 */
|
||||
customer_id?: number | null
|
||||
/** 申请依据 */
|
||||
evidence_refs?: Array<string>
|
||||
/** 异常原因码 */
|
||||
exception_code?: string
|
||||
/** 异常说明 */
|
||||
exception_summary?: string
|
||||
/** 预计新截止时间 */
|
||||
expected_deadline_at?: string
|
||||
/** 支付截止时间 */
|
||||
expire_at?: string | null
|
||||
/** 计费 / 延长天数 */
|
||||
extension_days?: number
|
||||
/** 订单 ID */
|
||||
id?: number
|
||||
/** 输入天数 */
|
||||
input_days?: number
|
||||
/** 计费月数 */
|
||||
months?: number
|
||||
/** 线下收款方式 */
|
||||
offline_payment_method_name?: string
|
||||
/** 线下交易单号 */
|
||||
offline_trade_no?: string
|
||||
/** 订单号 */
|
||||
order_no?: string
|
||||
/** 套餐 ID */
|
||||
package_id?: number
|
||||
/** 套餐名称快照 */
|
||||
package_name?: string
|
||||
/** 套餐记录 ID */
|
||||
package_usage_id?: number
|
||||
/** 实付金额(分) */
|
||||
paid_amount?: number | null
|
||||
/** 支付时间 */
|
||||
paid_at?: string | null
|
||||
/** 收款商户名称(取已支付或已退款支付单快照) */
|
||||
payment_merchant_name?: string
|
||||
/** 支付方式:wechat/alipay/offline */
|
||||
payment_method?: string
|
||||
/** 支付单号 */
|
||||
payment_no?: string
|
||||
/** 线下收款凭证 */
|
||||
payment_voucher_keys?: Array<string>
|
||||
/** 政策名称快照 */
|
||||
policy_name?: string
|
||||
/** 支付内容(待支付时返回,前端渲染为二维码或跳转链接) */
|
||||
qr_content?: string
|
||||
/** 退款金额 */
|
||||
refund_amount?: number | null
|
||||
/** 原路退款单号(仅执行异常) */
|
||||
refund_no?: string
|
||||
/** 退款时间 */
|
||||
refunded_at?: string | null
|
||||
/** 下单时资产所属店铺 */
|
||||
shop_id?: number
|
||||
/** 来源:client / admin / offline */
|
||||
source?: string
|
||||
/** 来源名称 */
|
||||
source_name?: string
|
||||
/** 状态:pending_payment/pending_approval/rejected/paid/completed/closed/exception/refunded */
|
||||
status?: string
|
||||
/** 状态名称 */
|
||||
status_name?: string
|
||||
/** 交易流水号 */
|
||||
third_party_trade_no?: string
|
||||
/** 单价(分/月) */
|
||||
unit_price?: number
|
||||
}
|
||||
|
||||
export interface SilenceOfflineOrderRequest {
|
||||
/** 输入的延期天数 */
|
||||
days: number
|
||||
/** 客户申请依据 */
|
||||
evidence_refs?: Array<string> | null
|
||||
/** 线下收款方式(字典 ID) */
|
||||
offline_payment_method_id: number
|
||||
/** 线下交易单号(同一收款方式下唯一) */
|
||||
offline_trade_no: string
|
||||
/** 套餐记录 ID */
|
||||
package_usage_id: number
|
||||
/** 实收金额(分),必须等于系统计算金额 */
|
||||
paid_amount?: number
|
||||
/** 付款时间 */
|
||||
paid_at: string
|
||||
/** 收款凭证对象存储 Key(1~5 个) */
|
||||
payment_voucher_keys: Array<string> | null
|
||||
/** 幂等键 */
|
||||
request_id: string
|
||||
}
|
||||
|
||||
export interface SilenceOnlineOrderRequest {
|
||||
/** 输入的延期天数 */
|
||||
days: number
|
||||
/** 客户申请记录或截图对象存储 Key(后台创建时填写) */
|
||||
evidence_refs?: Array<string> | null
|
||||
/** 套餐记录 ID */
|
||||
package_usage_id: number
|
||||
/** 支付方式:wechat / alipay(经商户池路由) */
|
||||
payment_method: string
|
||||
/** 下单幂等键 */
|
||||
request_id: string
|
||||
}
|
||||
|
||||
export interface SilenceQuoteResponse {
|
||||
/** 金额(分) */
|
||||
amount?: number
|
||||
/** 计费 / 延长天数 */
|
||||
billed_days?: number
|
||||
/** 输入天数 */
|
||||
input_days?: number
|
||||
/** 计费月数 */
|
||||
months?: number
|
||||
/** 新截止日期 */
|
||||
new_deadline?: string
|
||||
/** 是否在可办理范围内 */
|
||||
valid?: boolean
|
||||
}
|
||||
|
||||
export interface SilenceSpecialRequest {
|
||||
/** 费用(分,免费为 0;优惠价为实收合计) */
|
||||
amount?: number
|
||||
/** 免费或优惠依据 */
|
||||
basis?: string
|
||||
/** 客户申请记录或截图 */
|
||||
evidence_refs?: Array<string> | null
|
||||
/** 延期类型:free 免费 / discount 优惠价 / complaint_compensation 客诉补偿 / system_compensation 系统异常补偿 / special_customer 特殊客户政策 */
|
||||
extension_type: string
|
||||
/** 批量导入的明细文件 Key */
|
||||
import_file_key?: string
|
||||
/** 明细(批量需 package_silence:extend_batch 权限) */
|
||||
items: Array<SilenceSpecialItem> | null
|
||||
/** 优惠价有收款时:付款时间 */
|
||||
offline_paid_at?: string | null
|
||||
/** 优惠价有收款时:线下收款方式 */
|
||||
offline_payment_method_id?: number | null
|
||||
/** 优惠价有收款时:交易单号 */
|
||||
offline_trade_no?: string
|
||||
/** 优惠价有收款时:收款凭证 */
|
||||
payment_voucher_keys?: Array<string> | null
|
||||
/** 原因 */
|
||||
reason: string
|
||||
}
|
||||
|
||||
export interface SilenceSpecialItem {
|
||||
/** 延期天数(按 30 天向上取整) */
|
||||
days: number
|
||||
/** 套餐记录 ID */
|
||||
package_usage_id: number
|
||||
}
|
||||
|
||||
export interface SilencePolicyResponse {
|
||||
/** 免审批场景 */
|
||||
approval_exempt_types?: Array<string>
|
||||
/** 创建时间 */
|
||||
created_at?: string
|
||||
/** 创建人 */
|
||||
creator?: number
|
||||
/** 生效时间 */
|
||||
effective_from?: string
|
||||
/** 失效时间 */
|
||||
effective_to?: string | null
|
||||
/** 免费延期次数 */
|
||||
free_extension_limit?: number
|
||||
/** 政策 ID */
|
||||
id?: number
|
||||
/** 政策名称 */
|
||||
name?: string
|
||||
/** 付费延期累计最多月数 */
|
||||
paid_max_months?: number
|
||||
/** 备注 */
|
||||
remark?: string
|
||||
/** 系列或套餐 ID 列表 */
|
||||
scope_ids?: Array<number>
|
||||
/** 适用范围 */
|
||||
scope_type?: string
|
||||
/** 适用范围名称 */
|
||||
scope_type_name?: string
|
||||
/** 单次付费延期最多月数 */
|
||||
single_max_months?: number | null
|
||||
/** 状态:0-停用 1-启用 */
|
||||
status?: number
|
||||
/** 每月单价(分) */
|
||||
unit_price?: number
|
||||
/** 更新时间 */
|
||||
updated_at?: string
|
||||
/** 更新人 */
|
||||
updater?: number
|
||||
}
|
||||
|
||||
export interface SilencePolicyRequest {
|
||||
/** 免审批场景(多选,空表示全部需审批) */
|
||||
approval_exempt_types?: Array<string> | null
|
||||
/** 生效时间 */
|
||||
effective_from: string
|
||||
/** 失效时间(为空表示长期) */
|
||||
effective_to?: string | null
|
||||
/** 每笔套餐免费延期次数 */
|
||||
free_extension_limit?: number
|
||||
/** 政策名称(唯一) */
|
||||
name: string
|
||||
/** 付费延期累计最多月数 */
|
||||
paid_max_months?: number
|
||||
/** 备注 */
|
||||
remark?: string
|
||||
/** 系列 ID 或套餐 ID 列表(all 时为空) */
|
||||
scope_ids?: Array<number> | null
|
||||
/** 适用范围:all-全部套餐 series-套餐系列 package-指定套餐 */
|
||||
scope_type: string
|
||||
/** 单次付费延期最多月数(为空表示不单独限制) */
|
||||
single_max_months?: number | null
|
||||
/** 状态:0-停用 1-启用(新增默认启用) */
|
||||
status?: number | null
|
||||
/** 每月单价(分),1 月 = 30 天 */
|
||||
unit_price?: number
|
||||
}
|
||||
|
||||
export interface SilencePolicyUpdateParams {
|
||||
/** 免审批场景(多选,空表示全部需审批) */
|
||||
approval_exempt_types?: Array<string> | null
|
||||
/** 生效时间 */
|
||||
effective_from: string
|
||||
/** 失效时间(为空表示长期) */
|
||||
effective_to?: string | null
|
||||
/** 每笔套餐免费延期次数 */
|
||||
free_extension_limit?: number
|
||||
/** 政策 ID */
|
||||
id: number
|
||||
/** 政策名称(唯一) */
|
||||
name: string
|
||||
/** 付费延期累计最多月数 */
|
||||
paid_max_months?: number
|
||||
/** 备注 */
|
||||
remark?: string
|
||||
/** 系列 ID 或套餐 ID 列表(all 时为空) */
|
||||
scope_ids?: Array<number> | null
|
||||
/** 适用范围:all-全部套餐 series-套餐系列 package-指定套餐 */
|
||||
scope_type: string
|
||||
/** 单次付费延期最多月数(为空表示不单独限制) */
|
||||
single_max_months?: number | null
|
||||
/** 状态:0-停用 1-启用(新增默认启用) */
|
||||
status?: number | null
|
||||
/** 每月单价(分),1 月 = 30 天 */
|
||||
unit_price?: number
|
||||
}
|
||||
|
||||
export interface SilencePolicyStatusParams {
|
||||
/** 政策 ID */
|
||||
id: number
|
||||
/** 状态:0-停用 1-启用 */
|
||||
status: number | null
|
||||
}
|
||||
|
||||
export interface SilencePolicyMatchResponse {
|
||||
/** 是否匹配到政策(未匹配时不能付费延期,特殊延期仍可申请) */
|
||||
matched?: boolean
|
||||
/** 套餐 ID */
|
||||
package_id?: number
|
||||
policy?: SilencePolicyResponse
|
||||
}
|
||||
|
||||
export interface SilenceRecordResponse {
|
||||
/** 变更后截止时间 */
|
||||
after_deadline_at?: string | null
|
||||
/** 变更后状态 */
|
||||
after_status?: string | null
|
||||
/** 审批实例 */
|
||||
approval_instance_id?: number | null
|
||||
/** 资产 ID */
|
||||
asset_id?: number
|
||||
/** 资产类型 */
|
||||
asset_type?: string
|
||||
/** 批次 */
|
||||
batch_id?: number | null
|
||||
/** 变更前截止时间 */
|
||||
before_deadline_at?: string | null
|
||||
/** 变更前状态 */
|
||||
before_status?: string | null
|
||||
/** 变化天数 */
|
||||
change_days?: number
|
||||
/** 时间 */
|
||||
created_at?: string
|
||||
/** 默认值快照 */
|
||||
default_days?: number | null
|
||||
/** 事件名称 */
|
||||
event_name?: string
|
||||
/** 事件:set/adjust/expired/ended/extend/exchange/backfill/realname_backfill */
|
||||
event_type?: string
|
||||
/** 换货单号 */
|
||||
exchange_no?: string
|
||||
/** 延期明细 */
|
||||
extension_id?: number | null
|
||||
/** 流水 ID */
|
||||
id?: number
|
||||
/** 是否调整 */
|
||||
is_adjusted?: boolean
|
||||
/** 操作人 */
|
||||
operator_id?: number
|
||||
/** 操作人类型 */
|
||||
operator_type?: string
|
||||
/** 套餐记录 ID */
|
||||
package_usage_id?: number
|
||||
/** 沉默期天数 */
|
||||
period_days?: number | null
|
||||
/** 原因 */
|
||||
reason?: string
|
||||
/** 触发来源 */
|
||||
trigger_source?: string
|
||||
}
|
||||
|
||||
export interface SilenceSwitchResponse {
|
||||
/** 总开关是否打开 */
|
||||
enabled?: boolean
|
||||
/** 打开前检查各项结果 */
|
||||
precheck?: Array<SilenceSwitchPrecheckItem>
|
||||
/** 打开前检查是否全部通过 */
|
||||
precheck_passed?: boolean
|
||||
}
|
||||
|
||||
export interface SilenceSwitchPrecheckItem {
|
||||
/** 检查项:unconfigured_packages / unbackfilled_usages / default_policy_missing / approval_scene_missing */
|
||||
code?: string
|
||||
/** 数量(前两项为未满足的数量,后两项为已具备的数量) */
|
||||
count?: number
|
||||
/** 检查项名称 */
|
||||
name?: string
|
||||
/** 是否满足 */
|
||||
passed?: boolean
|
||||
}
|
||||
|
||||
export interface SilenceSwitchRequest {
|
||||
/** 目标状态:true 打开 / false 关闭(应急关闭不做检查) */
|
||||
enabled: boolean | null
|
||||
}
|
||||
|
||||
export interface SilenceUsagePageResult {
|
||||
/** 列表 */
|
||||
items?: Array<SilenceUsageItem>
|
||||
/** 页码 */
|
||||
page?: number
|
||||
/** 每页数量 */
|
||||
page_size?: number
|
||||
/** 总数 */
|
||||
total?: number
|
||||
}
|
||||
|
||||
export interface SilenceUsageItem {
|
||||
/** 资产 ID */
|
||||
asset_id?: number
|
||||
/** 资产标识 */
|
||||
asset_identifier?: string
|
||||
/** 资产类型 */
|
||||
asset_type?: string
|
||||
/** 购买时间 */
|
||||
created_at?: string
|
||||
/** 订单号 */
|
||||
order_no?: string
|
||||
/** 套餐 ID */
|
||||
package_id?: number
|
||||
/** 套餐名称 */
|
||||
package_name?: string
|
||||
/** 套餐记录 ID */
|
||||
package_usage_id?: number
|
||||
/** 资产所属店铺 */
|
||||
shop_id?: number | null
|
||||
/** 店铺名称 */
|
||||
shop_name?: string
|
||||
silence?: PackageSilenceView
|
||||
}
|
||||
|
||||
export interface PackageSilenceView {
|
||||
/** 是否显示延期入口(沉默期已过期的待生效套餐) */
|
||||
extendable?: boolean
|
||||
/** 购买时调整沉默期的审批是否进行中 */
|
||||
silence_adjust_pending?: boolean
|
||||
/** 当前沉默期截止时间(截止日 23:59:59) */
|
||||
silence_deadline_at?: string | null
|
||||
/** 最近一次过期时间 */
|
||||
silence_expired_at?: string | null
|
||||
/** 累计已延期天数 */
|
||||
silence_extended_days?: number
|
||||
/** 累计延期次数 */
|
||||
silence_extension_count?: number
|
||||
/** 已使用免费延期次数 */
|
||||
silence_free_extension_used?: number
|
||||
/** 其中付费延期累计天数 */
|
||||
silence_paid_extended_days?: number
|
||||
/** 沉默期天数 */
|
||||
silence_period_days?: number | null
|
||||
/** 沉默期起算时间(购买支付成功时间) */
|
||||
silence_start_at?: string | null
|
||||
/** 沉默期状态:waiting-待实名 expired-沉默期已过期 ended-沉默期已结束;待实名但已过截止的按 expired 返回 */
|
||||
silence_status?: string
|
||||
/** 沉默期状态名称(待实名 / 延期待实名 / 沉默期已过期 / 沉默期已结束) */
|
||||
silence_status_name?: string
|
||||
}
|
||||
|
||||
export interface SilenceOrderQuery {
|
||||
page?: number
|
||||
page_size?: number
|
||||
package_usage_id?: number | null
|
||||
package_id?: number | null
|
||||
asset_identifier?: string
|
||||
order_no?: string
|
||||
status?: string
|
||||
source?: string
|
||||
payment_method?: string
|
||||
merchant_name?: string
|
||||
third_party_trade_no?: string
|
||||
paid_start?: string
|
||||
paid_end?: string
|
||||
}
|
||||
|
||||
export interface SilenceBatchQuery {
|
||||
page?: number
|
||||
page_size?: number
|
||||
batch_no?: string
|
||||
path?: string
|
||||
extension_type?: string
|
||||
status?: string
|
||||
has_exception?: boolean | null
|
||||
}
|
||||
|
||||
export interface SilenceUsageQuery {
|
||||
page?: number
|
||||
page_size?: number
|
||||
view?: string
|
||||
within_days?: number
|
||||
asset_identifier?: string
|
||||
package_id?: number | null
|
||||
shop_id?: number | null
|
||||
deadline_start?: string
|
||||
deadline_end?: string
|
||||
}
|
||||
|
||||
export interface SilencePolicyQuery {
|
||||
page?: number
|
||||
page_size?: number
|
||||
name?: string
|
||||
scope_type?: string
|
||||
status?: number | null
|
||||
effective_at?: string
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { BaseResponse, PaginationData, PaginationParams } from './common'
|
||||
|
||||
export type WecomBusinessType =
|
||||
| 'package_silence_approval'
|
||||
| 'refund_approval'
|
||||
| 'offline_recharge_approval'
|
||||
| 'employee_collection_approval'
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Option } from '../common'
|
||||
export type SearchComponentType =
|
||||
| 'input'
|
||||
| 'select'
|
||||
| 'business-select'
|
||||
| 'tree-select'
|
||||
| 'radio'
|
||||
| 'checkbox'
|
||||
|
||||
18
src/types/components.d.ts
vendored
18
src/types/components.d.ts
vendored
@@ -51,6 +51,7 @@ declare module 'vue' {
|
||||
ArtScatterChart: typeof import('./../components/core/charts/ArtScatterChart.vue')['default']
|
||||
ArtScreenLock: typeof import('./../components/core/layouts/art-screen-lock/index.vue')['default']
|
||||
ArtSearchBar: typeof import('./../components/core/forms/art-search-bar/index.vue')['default']
|
||||
ArtSearchBusinessSelect: typeof import('./../components/core/forms/art-search-bar/widget/art-search-business-select/index.vue')['default']
|
||||
ArtSearchDate: typeof import('./../components/core/forms/art-search-bar/widget/art-search-date/index.vue')['default']
|
||||
ArtSearchInput: typeof import('./../components/core/forms/art-search-bar/widget/art-search-input/index.vue')['default']
|
||||
ArtSearchRadio: typeof import('./../components/core/forms/art-search-bar/widget/art-search-radio/index.vue')['default']
|
||||
@@ -78,6 +79,7 @@ declare module 'vue' {
|
||||
BatchOperationDialog: typeof import('./../components/business/BatchOperationDialog.vue')['default']
|
||||
BatchRealnamePolicyDialog: typeof import('./../components/business/BatchRealnamePolicyDialog.vue')['default']
|
||||
BoxStyleSettings: typeof import('./../components/core/layouts/art-settings-panel/widget/BoxStyleSettings.vue')['default']
|
||||
BusinessEntitySelect: typeof import('./../components/business/BusinessEntitySelect.vue')['default']
|
||||
CardOperationDialog: typeof import('./../components/business/CardOperationDialog.vue')['default']
|
||||
CardStatusTag: typeof import('./../components/business/CardStatusTag.vue')['default']
|
||||
ChangePasswordDialog: typeof import('./../components/core/layouts/art-header-bar/ChangePasswordDialog.vue')['default']
|
||||
@@ -95,11 +97,9 @@ declare module 'vue' {
|
||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
||||
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
ElCalendar: typeof import('element-plus/es')['ElCalendar']
|
||||
ElCard: typeof import('element-plus/es')['ElCard']
|
||||
ElCascader: typeof import('element-plus/es')['ElCascader']
|
||||
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
|
||||
ElCol: typeof import('element-plus/es')['ElCol']
|
||||
ElCollapse: typeof import('element-plus/es')['ElCollapse']
|
||||
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
|
||||
@@ -127,19 +127,15 @@ declare module 'vue' {
|
||||
ElPopover: typeof import('element-plus/es')['ElPopover']
|
||||
ElProgress: typeof import('element-plus/es')['ElProgress']
|
||||
ElRadio: typeof import('element-plus/es')['ElRadio']
|
||||
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
|
||||
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
||||
ElResult: typeof import('element-plus/es')['ElResult']
|
||||
ElRow: typeof import('element-plus/es')['ElRow']
|
||||
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
|
||||
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
||||
ElSwitch: typeof import('element-plus/es')['ElSwitch']
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||
ElTabPane: typeof import('element-plus/es')['ElTabPane']
|
||||
ElTabs: typeof import('element-plus/es')['ElTabs']
|
||||
ElTag: typeof import('element-plus/es')['ElTag']
|
||||
ElTimeline: typeof import('element-plus/es')['ElTimeline']
|
||||
ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
|
||||
@@ -148,6 +144,7 @@ declare module 'vue' {
|
||||
ElUpload: typeof import('element-plus/es')['ElUpload']
|
||||
ElWatermark: typeof import('element-plus/es')['ElWatermark']
|
||||
ExportTaskCreateDialog: typeof import('./../components/business/ExportTaskCreateDialog.vue')['default']
|
||||
FirstPurchaseCell: typeof import('./../components/business/package-silence/FirstPurchaseCell.vue')['default']
|
||||
GatewayDynamicData: typeof import('./../components/business/gateway/GatewayDynamicData.vue')['default']
|
||||
GatewayOperationTable: typeof import('./../components/business/gateway/GatewayOperationTable.vue')['default']
|
||||
GatewayOptionsNotice: typeof import('./../components/business/gateway/GatewayOptionsNotice.vue')['default']
|
||||
@@ -160,6 +157,7 @@ declare module 'vue' {
|
||||
NullableNumber: typeof import('./../components/business/polling/NullableNumber.vue')['default']
|
||||
OperatorSelect: typeof import('./../components/business/OperatorSelect.vue')['default']
|
||||
PackageSelector: typeof import('./../components/business/PackageSelector.vue')['default']
|
||||
PackageSilenceFields: typeof import('./../components/business/package-silence/PackageSilenceFields.vue')['default']
|
||||
PaymentVoucherDialog: typeof import('./../components/business/PaymentVoucherDialog.vue')['default']
|
||||
PollingBatchDialog: typeof import('./../components/business/polling/PollingBatchDialog.vue')['default']
|
||||
PollingImportDialog: typeof import('./../components/business/polling/PollingImportDialog.vue')['default']
|
||||
@@ -178,6 +176,14 @@ declare module 'vue' {
|
||||
SettingItem: typeof import('./../components/core/layouts/art-settings-panel/widget/SettingItem.vue')['default']
|
||||
ShopCreditLimitDialog: typeof import('./../components/business/ShopCreditLimitDialog.vue')['default']
|
||||
SidebarSubmenu: typeof import('./../components/core/layouts/art-menus/art-sidebar-menu/widget/SidebarSubmenu.vue')['default']
|
||||
SilenceDetail: typeof import('./../components/business/package-silence/SilenceDetail.vue')['default']
|
||||
SilenceExtendDialog: typeof import('./../components/business/package-silence/SilenceExtendDialog.vue')['default']
|
||||
SilenceManagement: typeof import('./../components/business/package-silence/SilenceManagement.vue')['default']
|
||||
SilencePolicyDialog: typeof import('./../components/business/package-silence/SilencePolicyDialog.vue')['default']
|
||||
SilencePurchaseFields: typeof import('./../components/business/package-silence/SilencePurchaseFields.vue')['default']
|
||||
SilenceRecordsDialog: typeof import('./../components/business/package-silence/SilenceRecordsDialog.vue')['default']
|
||||
SilenceSummary: typeof import('./../components/business/package-silence/SilenceSummary.vue')['default']
|
||||
SilenceTable: typeof import('./../components/business/package-silence/SilenceTable.vue')['default']
|
||||
SpeedLimitDialog: typeof import('./../components/device/SpeedLimitDialog.vue')['default']
|
||||
StopResumeRecords: typeof import('./../components/business/gateway/StopResumeRecords.vue')['default']
|
||||
SwitchCardDialog: typeof import('./../components/device/SwitchCardDialog.vue')['default']
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios from 'axios'
|
||||
import { SILENCE_ERROR_MESSAGES } from './packageSilence'
|
||||
|
||||
export type ApiErrorKind =
|
||||
| 'auth'
|
||||
@@ -23,7 +24,8 @@ export const normalizeApiError = (error: unknown): NormalizedApiError => {
|
||||
const response = getResponse(error)
|
||||
const status = response?.status
|
||||
const code = response?.data?.code
|
||||
const backendMessage = response?.data?.msg || response?.data?.message
|
||||
const backendMessage =
|
||||
response?.data?.msg || response?.data?.message || SILENCE_ERROR_MESSAGES[Number(code)]
|
||||
const timeout = axios.isAxiosError(error) && error.code === 'ECONNABORTED'
|
||||
|
||||
if (timeout) {
|
||||
@@ -48,7 +50,7 @@ export const normalizeApiError = (error: unknown): NormalizedApiError => {
|
||||
kind: 'forbidden',
|
||||
status,
|
||||
code,
|
||||
message: '没有执行此操作的权限',
|
||||
message: SILENCE_ERROR_MESSAGES[Number(code)] ? backendMessage : '没有执行此操作的权限',
|
||||
unknownResult: false
|
||||
}
|
||||
if (status === 400)
|
||||
|
||||
114
src/utils/business/packageSilence.ts
Normal file
114
src/utils/business/packageSilence.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
import type { PackageSilenceInfo } from '@/types/api/packageSilence'
|
||||
|
||||
export type OrderCategory = 'all' | 'platform' | 'agent' | 'online'
|
||||
export function assertSilenceResponse<T extends { code: number; msg?: string; message?: string }>(
|
||||
response: T
|
||||
): T {
|
||||
if (response.code !== 0)
|
||||
throw new Error(
|
||||
response.msg || response.message || SILENCE_ERROR_MESSAGES[response.code] || '操作失败'
|
||||
)
|
||||
return response
|
||||
}
|
||||
export const canAccessOrderCategory = (userType: unknown, category: OrderCategory = 'all') =>
|
||||
(category === 'online' ? [1, 2] : [1, 2, 3]).includes(Number(userType))
|
||||
export const canEditRestrictedAsset = (userType: unknown) => [1, 2, 3].includes(Number(userType))
|
||||
|
||||
export function validateSilenceExpiryOverride(
|
||||
pkg: {
|
||||
package_type: string
|
||||
default_expiry_base?: string | null
|
||||
expiry_base?: string | null
|
||||
silence_period_days?: number | null
|
||||
},
|
||||
override?: string | null
|
||||
) {
|
||||
if (!override || override === 'default' || pkg.package_type !== 'formal') return
|
||||
const base = pkg.default_expiry_base || pkg.expiry_base
|
||||
if (base === 'from_activation' && override === 'from_purchase')
|
||||
throw new Error('实名即生效套餐不允许覆盖为购买即生效')
|
||||
if (
|
||||
base === 'from_purchase' &&
|
||||
override === 'from_activation' &&
|
||||
(!Number.isInteger(pkg.silence_period_days) ||
|
||||
Number(pkg.silence_period_days) < 1 ||
|
||||
Number(pkg.silence_period_days) > 90)
|
||||
)
|
||||
throw new Error('购买即生效套餐须先配置默认沉默期,才允许覆盖为实名即生效')
|
||||
if (!base) throw new Error('无法确认套餐默认生效条件,请刷新套餐信息')
|
||||
}
|
||||
|
||||
export function packageSilenceFields(
|
||||
value: {
|
||||
package_type: string
|
||||
expiry_base?: string | null
|
||||
silence_config_required?: boolean
|
||||
silence_period_days?: number | null
|
||||
silence_extension_enabled?: boolean
|
||||
},
|
||||
originalExpiryBase?: string | null
|
||||
) {
|
||||
if (value.package_type !== 'formal') return {}
|
||||
if (originalExpiryBase === 'from_activation' && value.expiry_base === 'from_purchase')
|
||||
throw new Error('实名即生效套餐不能改为购买即生效')
|
||||
const days = value.silence_period_days
|
||||
if (days == null && (value.expiry_base === 'from_activation' || value.silence_config_required))
|
||||
throw new Error('请配置默认沉默期(1–90 天)')
|
||||
if (days != null && (!Number.isInteger(days) || days < 1 || days > 90))
|
||||
throw new Error('默认沉默期须为 1–90 天的整数')
|
||||
return {
|
||||
silence_period_days: days ?? null,
|
||||
silence_extension_enabled: value.silence_extension_enabled ?? true
|
||||
}
|
||||
}
|
||||
|
||||
export function silencePurchaseFields(
|
||||
allowed: boolean,
|
||||
days: number | null | undefined,
|
||||
reason: string
|
||||
) {
|
||||
if (!allowed || days == null) return {}
|
||||
if (!Number.isSafeInteger(days) || days < 1) throw new Error('本次沉默期须为大于等于 1 的整数')
|
||||
if (!reason.trim()) throw new Error('填写本次沉默期时必须填写调整原因')
|
||||
return { silence_period_days: days, silence_reason: reason.trim() }
|
||||
}
|
||||
|
||||
export function firstPurchaseRange(range: unknown) {
|
||||
if (!Array.isArray(range) || !range.length) return {}
|
||||
if (range.length !== 2 || range.some((value) => !value))
|
||||
throw new Error('请选择完整首次购买时间范围')
|
||||
const dates = range.map((value) => new Date(value))
|
||||
if (dates.some((date) => !Number.isFinite(date.getTime())) || dates[0] > dates[1])
|
||||
throw new Error('首次购买时间范围无效')
|
||||
return {
|
||||
first_purchase_start: dates[0].toISOString().replace(/\.\d{3}Z$/, 'Z'),
|
||||
first_purchase_end: dates[1].toISOString().replace(/\.\d{3}Z$/, 'Z')
|
||||
}
|
||||
}
|
||||
|
||||
export function silenceStatusLabel(value: PackageSilenceInfo) {
|
||||
return (
|
||||
value.silence_status_name ||
|
||||
({ waiting: '待实名', expired: '沉默期已过期', ended: '沉默期已结束' }[value.silence_status] ??
|
||||
value.silence_status)
|
||||
)
|
||||
}
|
||||
|
||||
export const SILENCE_ERROR_MESSAGES: Record<number, string> = {
|
||||
1260: '沉默期天数不在允许范围',
|
||||
1261: '无权限调整沉默期',
|
||||
1262: '不允许变更该套餐的生效条件',
|
||||
1263: '该套餐当前不满足延期条件',
|
||||
1264: '该套餐不支持付费延期,可申请特殊延期',
|
||||
1265: '超过可延期期限',
|
||||
1266: '延期天数不在允许范围',
|
||||
1267: '免费延期次数已用完',
|
||||
1268: '沉默期已过期的套餐不能退款',
|
||||
1269: '延期政策重叠',
|
||||
1270: '未匹配到延期政策',
|
||||
1271: '已有未结束的延期订单或申请',
|
||||
1272: '线下交易单号已登记',
|
||||
1273: '实收金额与计算金额不一致',
|
||||
1274: '沉默期功能未开启',
|
||||
1275: '沉默期开启前检查未通过'
|
||||
}
|
||||
164
src/utils/business/silenceExtension.ts
Normal file
164
src/utils/business/silenceExtension.ts
Normal file
@@ -0,0 +1,164 @@
|
||||
import type { BaseResponse } from '@/types/api/common'
|
||||
import type { SilenceSpecialItem, SilencePolicyRequest } from '@/types/api/packageSilenceContract'
|
||||
import { formatDateTime } from './format'
|
||||
import { SILENCE_ERROR_MESSAGES } from './packageSilence'
|
||||
|
||||
export function silenceData<T>(response: BaseResponse<T>): T {
|
||||
if (response.code !== 0) {
|
||||
const error = new Error(
|
||||
response.msg || response.message || SILENCE_ERROR_MESSAGES[response.code] || '请求失败'
|
||||
)
|
||||
throw Object.assign(error, { details: response.data, code: response.code })
|
||||
}
|
||||
return response.data
|
||||
}
|
||||
export function silenceRowsError(
|
||||
error: unknown
|
||||
): { row_no?: number; row?: number; reason?: string; message?: string }[] {
|
||||
const value = error as {
|
||||
details?: { rows?: unknown[] }
|
||||
response?: { data?: { data?: { rows?: unknown[] } } }
|
||||
}
|
||||
const rows = value?.details?.rows || value?.response?.data?.data?.rows
|
||||
return Array.isArray(rows)
|
||||
? rows.filter(
|
||||
(row): row is { row_no?: number; row?: number; reason?: string; message?: string } =>
|
||||
!!row && typeof row === 'object'
|
||||
)
|
||||
: []
|
||||
}
|
||||
export function silenceId(value: unknown, label = '记录 ID'): number {
|
||||
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1)
|
||||
throw new Error(`${label}无效`)
|
||||
return value
|
||||
}
|
||||
export function silenceDays(value: unknown): number {
|
||||
return silenceId(value, '延期天数')
|
||||
}
|
||||
export function silenceFen(value: unknown): number {
|
||||
const text = String(value ?? '').trim()
|
||||
if (!/^\d+(\.\d{1,2})?$/.test(text)) throw new Error('金额须为非负数,最多两位小数')
|
||||
const [integer, decimal = ''] = text.split('.')
|
||||
const amount = Number(integer) * 100 + Number(decimal.padEnd(2, '0'))
|
||||
if (!Number.isSafeInteger(amount)) throw new Error('金额超出允许范围')
|
||||
return amount
|
||||
}
|
||||
export function silenceAmount(value: unknown): string {
|
||||
return typeof value === 'number' && Number.isFinite(value) ? `¥${(value / 100).toFixed(2)}` : '-'
|
||||
}
|
||||
export function silenceDate(value: unknown): string {
|
||||
const date = new Date(String(value ?? ''))
|
||||
if (!Number.isFinite(date.getTime())) throw new Error('请选择有效时间')
|
||||
return date.toISOString().replace(/\.\d{3}Z$/, 'Z')
|
||||
}
|
||||
export function silenceRange(value: unknown, start: string, end: string): Record<string, string> {
|
||||
if (!Array.isArray(value) || !value.length) return {}
|
||||
if (value.length !== 2 || value.some((item) => !item)) throw new Error('请选择完整时间范围')
|
||||
const a = silenceDate(value[0]),
|
||||
b = silenceDate(value[1])
|
||||
if (a > b) throw new Error('结束时间不能早于开始时间')
|
||||
return { [start]: a, [end]: b }
|
||||
}
|
||||
export const SILENCE_ORDER_STATUS = {
|
||||
pending_payment: '待支付',
|
||||
pending_approval: '待审批',
|
||||
rejected: '已驳回',
|
||||
paid: '已支付待生效',
|
||||
completed: '已完成',
|
||||
closed: '已关闭',
|
||||
exception: '执行异常',
|
||||
refunded: '已退款'
|
||||
} as const
|
||||
export const SILENCE_SPECIAL_TYPES = {
|
||||
free: '免费延期',
|
||||
discount: '优惠价延期',
|
||||
complaint_compensation: '客诉补偿',
|
||||
system_compensation: '系统异常补偿',
|
||||
special_customer: '特殊客户政策'
|
||||
} as const
|
||||
export const silenceOptions = (map: Record<string, string>) =>
|
||||
Object.entries(map).map(([value, label]) => ({ value, label }))
|
||||
export function silenceDisplay(row: Record<string, unknown>, key: string): string {
|
||||
const value = row[key]
|
||||
if (key === 'status_name')
|
||||
return String(
|
||||
value ||
|
||||
SILENCE_ORDER_STATUS[row.status as keyof typeof SILENCE_ORDER_STATUS] ||
|
||||
row.status ||
|
||||
'-'
|
||||
)
|
||||
if (key === 'source_name')
|
||||
return String(
|
||||
value ||
|
||||
(
|
||||
{
|
||||
order: '首次购买套餐',
|
||||
backfill: '历史回填',
|
||||
client: '客户端',
|
||||
admin: '后台',
|
||||
offline: '线下'
|
||||
} as Record<string, string>
|
||||
)[String(row.source)] ||
|
||||
row.source ||
|
||||
'-'
|
||||
)
|
||||
if (key === 'end_reason' && value === 'exchange_return') return '换货回库'
|
||||
if (key === 'status' && typeof value === 'number')
|
||||
return value === 1 ? '启用' : value === 0 ? '停用' : String(value)
|
||||
if (value == null || value === '') return '-'
|
||||
if (['amount', 'paid_amount', 'refund_amount', 'unit_price'].includes(key))
|
||||
return silenceAmount(value)
|
||||
if (/(?:_at|effective_from|effective_to|requested_at)$/.test(key))
|
||||
return formatDateTime(String(value))
|
||||
if (key === 'status')
|
||||
return String(
|
||||
row.status_name || SILENCE_ORDER_STATUS[value as keyof typeof SILENCE_ORDER_STATUS] || value
|
||||
)
|
||||
if (key === 'extension_type')
|
||||
return SILENCE_SPECIAL_TYPES[value as keyof typeof SILENCE_SPECIAL_TYPES] || String(value)
|
||||
if (typeof value === 'boolean') return value ? '是' : '否'
|
||||
if (Array.isArray(value)) return value.join('、') || '-'
|
||||
return String(value)
|
||||
}
|
||||
export function parseSilenceCsv(text: string): SilenceSpecialItem[] {
|
||||
// 两列均为纯整数;不接受有歧义的 CSV/Excel 科学计数法或错误表头。
|
||||
const lines = text
|
||||
.replace(/^\uFEFF/, '')
|
||||
.trim()
|
||||
.split(/\r?\n/)
|
||||
.filter((line) => line.trim())
|
||||
if (lines.shift()?.trim() !== 'package_usage_id,days')
|
||||
throw new Error('CSV 表头须为 package_usage_id,days')
|
||||
if (!lines.length) throw new Error('CSV 没有明细')
|
||||
const seen = new Set<number>()
|
||||
return lines.map((line, index) => {
|
||||
if (!/^\s*\d+\s*,\s*\d+\s*$/.test(line))
|
||||
throw new Error(`第 ${index + 2} 行须为套餐记录 ID、延期天数两个整数`)
|
||||
const [id, days] = line.split(',').map(Number)
|
||||
silenceId(id, `第 ${index + 2} 行套餐记录 ID`)
|
||||
silenceDays(days)
|
||||
if (seen.has(id)) throw new Error(`第 ${index + 2} 行套餐记录重复`)
|
||||
seen.add(id)
|
||||
return { package_usage_id: id, days }
|
||||
})
|
||||
}
|
||||
export function validateSilencePolicy(value: SilencePolicyRequest) {
|
||||
if (!value.name?.trim()) throw new Error('请填写政策名称')
|
||||
if (!['all', 'series', 'package'].includes(value.scope_type)) throw new Error('请选择适用范围')
|
||||
if (value.scope_type !== 'all' && !value.scope_ids?.length)
|
||||
throw new Error('请选择适用系列或套餐')
|
||||
value.scope_ids?.forEach((id) => silenceId(id, '适用范围 ID'))
|
||||
const from = silenceDate(value.effective_from)
|
||||
if (value.effective_to && silenceDate(value.effective_to) <= from)
|
||||
throw new Error('失效时间必须晚于生效时间')
|
||||
for (const key of [
|
||||
'unit_price',
|
||||
'free_extension_limit',
|
||||
'paid_max_months',
|
||||
'single_max_months'
|
||||
] as const) {
|
||||
const n = value[key]
|
||||
if (n != null && (!Number.isSafeInteger(n) || n < 0))
|
||||
throw new Error('金额、次数和月数须为非负整数')
|
||||
}
|
||||
}
|
||||
@@ -559,7 +559,10 @@
|
||||
{{ getBindingStopButtonText(bindingCard) }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="hasAuth('bound_card:update_realname_status')"
|
||||
v-if="
|
||||
canEditRestrictedAsset(userStore.info.user_type) &&
|
||||
hasAuth('bound_card:update_realname_status')
|
||||
"
|
||||
type="primary"
|
||||
size="default"
|
||||
@click="handleUpdateBindingCardRealnameStatus(bindingCard)"
|
||||
@@ -618,6 +621,25 @@
|
||||
<slot name="package-list" />
|
||||
</div>
|
||||
|
||||
<ElDescriptions v-if="cardInfo" :column="1" border
|
||||
><ElDescriptionsItem label="首次购买套餐时间"
|
||||
>{{ cardInfo.first_purchase_at ? formatDateTime(cardInfo.first_purchase_at) : '-'
|
||||
}}<ElButton
|
||||
v-if="cardInfo.asset_id > 0"
|
||||
link
|
||||
type="primary"
|
||||
@click="firstPurchaseVisible = true"
|
||||
>首次购买套餐记录</ElButton
|
||||
></ElDescriptionsItem
|
||||
></ElDescriptions
|
||||
>
|
||||
<SilenceRecordsDialog
|
||||
v-if="firstPurchaseVisible && cardInfo"
|
||||
:key="`${cardInfo.asset_type}:${cardInfo.asset_id}`"
|
||||
:asset-id="cardInfo.asset_id"
|
||||
:asset-type="cardInfo.asset_type"
|
||||
@close="firstPurchaseVisible = false"
|
||||
/>
|
||||
<!-- IoT卡操作按钮 -->
|
||||
<ElAlert
|
||||
v-if="startErrorMessage"
|
||||
@@ -659,7 +681,10 @@
|
||||
实名认证策略
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="hasAuth('iot_info:update_realname_status')"
|
||||
v-if="
|
||||
canEditRestrictedAsset(userStore.info.user_type) &&
|
||||
hasAuth('iot_info:update_realname_status')
|
||||
"
|
||||
type="primary"
|
||||
@click="handleShowUpdateRealnameStatus"
|
||||
>
|
||||
@@ -700,7 +725,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import {
|
||||
ElCard,
|
||||
@@ -728,6 +753,9 @@
|
||||
import { JULY_PERMISSIONS } from '@/config/constants'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import SilenceRecordsDialog from '@/components/business/package-silence/SilenceRecordsDialog.vue'
|
||||
const firstPurchaseVisible = ref(false)
|
||||
import { canEditRestrictedAsset } from '@/utils/business/packageSilence'
|
||||
import {
|
||||
getExpiryEstimateText,
|
||||
getExpiryEstimateTooltip,
|
||||
@@ -787,6 +815,7 @@
|
||||
gateway_extend?: string
|
||||
total_virtual_used_mb?: number | null
|
||||
total_virtual_remaining_mb?: number | null
|
||||
first_purchase_at?: string | null
|
||||
estimated_final_expires_at?: string | null
|
||||
days_until_final_expiry?: number | null
|
||||
expiry_estimate_status?: ExpiryEstimateStatus
|
||||
@@ -867,6 +896,12 @@
|
||||
})
|
||||
|
||||
const { hasAuth } = useAuth()
|
||||
watch(
|
||||
() => [props.cardInfo.asset_id, props.cardInfo.asset_type],
|
||||
() => {
|
||||
firstPurchaseVisible.value = false
|
||||
}
|
||||
)
|
||||
const userStore = useUserStore()
|
||||
const isSubjectActivityView = computed(() => [3, 4].includes(Number(userStore.info.user_type)))
|
||||
const auditTarget = computed(() => {
|
||||
@@ -932,7 +967,9 @@
|
||||
: 'device_info:auto_polling'
|
||||
})
|
||||
|
||||
const canShowPolling = computed(() => hasAuth(pollingPermission.value))
|
||||
const canShowPolling = computed(
|
||||
() => canEditRestrictedAsset(userStore.info.user_type) && hasAuth(pollingPermission.value)
|
||||
)
|
||||
|
||||
const canShowCardMonthUsage = computed(() => {
|
||||
const userType = Number(userStore.info.user_type ?? 0)
|
||||
@@ -1235,6 +1272,7 @@
|
||||
|
||||
// 处理轮询开关变化
|
||||
const handlePollingChange = (value: string | number | boolean) => {
|
||||
if (!canEditRestrictedAsset(userStore.info.user_type)) return
|
||||
emit('update:pollingEnabled', Boolean(value))
|
||||
}
|
||||
|
||||
@@ -1296,6 +1334,7 @@
|
||||
}
|
||||
|
||||
const handleShowUpdateRealnameStatus = () => {
|
||||
if (!canEditRestrictedAsset(userStore.info.user_type)) return
|
||||
emit('showUpdateRealnameStatus')
|
||||
}
|
||||
|
||||
@@ -1347,6 +1386,7 @@
|
||||
}
|
||||
|
||||
const handleUpdateBindingCardRealnameStatus = (card: BindingCard) => {
|
||||
if (!canEditRestrictedAsset(userStore.info.user_type)) return
|
||||
emit('updateBindingCardRealnameStatus', { card })
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
<ElAlert v-else-if="errorMsg" :title="errorMsg" type="warning" :closable="false" />
|
||||
|
||||
<template v-else-if="currentPackage">
|
||||
<SilenceSummary
|
||||
:silence="currentPackage.silence"
|
||||
:usage-id="currentPackage.package_usage_id ?? currentPackage.id"
|
||||
@changed="emit('refresh')"
|
||||
/>
|
||||
<!-- 流量使用情况 - 横向进度条卡片 -->
|
||||
<div v-if="shouldShowTrafficCard" class="flow-progress-card">
|
||||
<!-- 管理员视角:始终显示真流量和虚流量 -->
|
||||
@@ -278,6 +283,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import SilenceSummary from '@/components/business/package-silence/SilenceSummary.vue'
|
||||
import {
|
||||
ElDivider,
|
||||
ElButton,
|
||||
@@ -356,6 +362,7 @@
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
refresh: []
|
||||
showRecharge: []
|
||||
navigateToDevice: [deviceNo: string]
|
||||
}>()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<ElOption label="已失效" :value="4" />
|
||||
</ElSelect>
|
||||
<ElButton
|
||||
v-if="canAccessOrderCategory(userInfo.user_type)"
|
||||
type="primary"
|
||||
:disabled="Boolean(props.boundDeviceId)"
|
||||
@click="handleShowRecharge"
|
||||
@@ -50,6 +51,19 @@
|
||||
class="package-table"
|
||||
border
|
||||
>
|
||||
<ElTableColumn
|
||||
v-if="packageList.some((pkg) => !!pkg.silence)"
|
||||
label="沉默期"
|
||||
min-width="260"
|
||||
><template #default="{ row }"
|
||||
><SilenceSummary
|
||||
v-if="row.silence"
|
||||
:silence="row.silence"
|
||||
:usage-id="row.package_usage_id ?? row.id"
|
||||
@changed="emit('refresh')"
|
||||
/><span v-else>-</span></template
|
||||
></ElTableColumn
|
||||
>
|
||||
<ElTableColumn
|
||||
label="订单号"
|
||||
:width="orderNoColumnWidth"
|
||||
@@ -63,7 +77,10 @@
|
||||
type="primary"
|
||||
link
|
||||
@click="handleOrderNoClick(scope.row)"
|
||||
v-if="hasAuth('order:package_list_detail')"
|
||||
v-if="
|
||||
canAccessOrderCategory(userInfo.user_type) &&
|
||||
hasAuth('order:package_list_detail')
|
||||
"
|
||||
>
|
||||
<span
|
||||
class="order-no-link__text"
|
||||
@@ -422,6 +439,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import SilenceSummary from '@/components/business/package-silence/SilenceSummary.vue'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import {
|
||||
ElCard,
|
||||
@@ -450,6 +468,7 @@
|
||||
import { AssetService } from '@/api/modules'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { canEditRestrictedAsset, canAccessOrderCategory } from '@/utils/business/packageSilence'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import CreateRefundDialog from '@/components/business/CreateRefundDialog.vue'
|
||||
|
||||
@@ -467,6 +486,7 @@
|
||||
)
|
||||
const isProductionMode = import.meta.env.MODE === 'production'
|
||||
const canUseAdjustmentInCurrentEnv = (permission: string) => {
|
||||
if (!canEditRestrictedAsset(userInfo.value.user_type)) return false
|
||||
if (isProductionMode) {
|
||||
return userInfo.value.user_type === 2 && hasAuth(permission)
|
||||
}
|
||||
@@ -563,6 +583,7 @@
|
||||
}
|
||||
|
||||
const handleShowUsedDataDialog = (row: PackageInfo) => {
|
||||
if (!canUpdateUsedData.value) return
|
||||
selectedPackage.value = row
|
||||
usedDataForm.data_usage = row.real_used_mb ?? 0
|
||||
usedDataForm.unit = 'MB'
|
||||
@@ -570,6 +591,7 @@
|
||||
}
|
||||
|
||||
const handleShowExpiresAtDialog = (row: PackageInfo) => {
|
||||
if (!canUpdateExpiresAt.value) return
|
||||
selectedPackage.value = row
|
||||
expiresAtForm.expires_at = row.expires_at ? formatDateTime(row.expires_at) : ''
|
||||
expiresAtDialogVisible.value = true
|
||||
@@ -597,6 +619,7 @@
|
||||
)
|
||||
|
||||
const handleSubmitUsedData = async () => {
|
||||
if (!canUpdateUsedData.value) return
|
||||
if (!usedDataFormRef.value || !selectedPackage.value) return
|
||||
const packageUsageId = getPackageUsageId(selectedPackage.value)
|
||||
if (!props.assetIdentifier || packageUsageId === undefined) {
|
||||
@@ -605,7 +628,7 @@
|
||||
}
|
||||
|
||||
await usedDataFormRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
if (!valid || !canUpdateUsedData.value) return
|
||||
usedDataSubmitting.value = true
|
||||
try {
|
||||
const dataUsageMb = getUsedDataMb()
|
||||
@@ -622,6 +645,7 @@
|
||||
}
|
||||
|
||||
const handleSubmitExpiresAt = async () => {
|
||||
if (!canUpdateExpiresAt.value) return
|
||||
if (!expiresAtFormRef.value || !selectedPackage.value) return
|
||||
const packageUsageId = getPackageUsageId(selectedPackage.value)
|
||||
if (!props.assetIdentifier || packageUsageId === undefined) {
|
||||
@@ -630,7 +654,7 @@
|
||||
}
|
||||
|
||||
await expiresAtFormRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
if (!valid || !canUpdateExpiresAt.value) return
|
||||
expiresAtSubmitting.value = true
|
||||
try {
|
||||
await AssetService.updateAssetPackageExpiresAt(props.assetIdentifier, packageUsageId, {
|
||||
@@ -773,6 +797,7 @@
|
||||
}
|
||||
|
||||
const handleShowRecharge = () => {
|
||||
if (!canAccessOrderCategory(userInfo.value.user_type)) return
|
||||
emit('showRecharge')
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
title="套餐充值"
|
||||
width="40%"
|
||||
width="min(760px, 96vw)"
|
||||
@closed="handleDialogClosed"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="80px">
|
||||
<SilencePurchaseFields
|
||||
v-if="hasAuth(PACKAGE_SILENCE_PERMISSIONS.override)"
|
||||
v-model:days="form.silence_period_days"
|
||||
v-model:reason="form.silence_reason"
|
||||
:disabled="loading"
|
||||
/>
|
||||
<ElFormItem label="资产信息">
|
||||
<span style="font-weight: bold; color: #409eff">
|
||||
{{ assetIdentifier }}
|
||||
@@ -131,7 +137,16 @@
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import VoucherUpload from '@/components/business/VoucherUpload.vue'
|
||||
import { hasVoucherKeys, toVoucherKeyList } from '@/utils/business'
|
||||
import { normalizeApiError } from '@/utils/business/apiError'
|
||||
import { gatewayError } from '@/utils/business/gateway'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import {
|
||||
canAccessOrderCategory,
|
||||
silencePurchaseFields,
|
||||
assertSilenceResponse
|
||||
} from '@/utils/business/packageSilence'
|
||||
import { PACKAGE_SILENCE_PERMISSIONS } from '@/config/constants/packageSilence'
|
||||
import { pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import SilencePurchaseFields from '@/components/business/package-silence/SilencePurchaseFields.vue'
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
@@ -150,6 +165,7 @@
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const userStore = useUserStore()
|
||||
const { hasAuth } = useAuth()
|
||||
const formRef = ref<FormInstance>()
|
||||
const uploadRef = ref<InstanceType<typeof VoucherUpload>>()
|
||||
const loading = ref(false)
|
||||
@@ -159,10 +175,19 @@
|
||||
const packagesEmptyWithSeriesId = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
silence_period_days: null as number | null,
|
||||
silence_reason: '',
|
||||
package_id: undefined as number | undefined,
|
||||
payment_method: 'wallet' as 'wallet' | 'offline',
|
||||
payment_voucher_key: [] as string[]
|
||||
})
|
||||
watch(
|
||||
() => [props.assetIdentifier, form.package_id],
|
||||
() => {
|
||||
form.silence_period_days = null
|
||||
form.silence_reason = ''
|
||||
}
|
||||
)
|
||||
|
||||
const rules = computed<FormRules>(() => {
|
||||
const baseRules: FormRules = {
|
||||
@@ -313,6 +338,9 @@
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
const origin = pollingScope(userStore),
|
||||
identifier = props.assetIdentifier
|
||||
if (!canAccessOrderCategory(userStore.info.user_type) || loading.value) return
|
||||
if (!formRef.value) return
|
||||
if (voucherUploading.value) {
|
||||
ElMessage.warning('支付凭证上传中,请稍候')
|
||||
@@ -320,7 +348,13 @@
|
||||
}
|
||||
|
||||
const valid = await formRef.value.validate().catch(() => false)
|
||||
if (!valid) return
|
||||
if (
|
||||
!valid ||
|
||||
!canAccessOrderCategory(userStore.info.user_type) ||
|
||||
origin !== pollingScope(userStore) ||
|
||||
identifier !== props.assetIdentifier
|
||||
)
|
||||
return
|
||||
|
||||
if (!form.package_id) {
|
||||
ElMessage.error('请选择套餐')
|
||||
@@ -336,6 +370,11 @@
|
||||
|
||||
try {
|
||||
const data: CreateOrderRequest = {
|
||||
...silencePurchaseFields(
|
||||
hasAuth(PACKAGE_SILENCE_PERMISSIONS.override),
|
||||
form.silence_period_days,
|
||||
form.silence_reason
|
||||
),
|
||||
identifier: props.assetIdentifier,
|
||||
package_ids: [form.package_id],
|
||||
payment_method: form.payment_method
|
||||
@@ -345,7 +384,7 @@
|
||||
data.payment_voucher_key = toVoucherKeyList(form.payment_voucher_key)
|
||||
}
|
||||
|
||||
const response = await OrderService.createOrder(data)
|
||||
const response = assertSilenceResponse(await OrderService.createOrder(data))
|
||||
if (response.code !== 0) {
|
||||
ElMessage.error(response.msg || '订单创建失败')
|
||||
return
|
||||
@@ -364,13 +403,15 @@
|
||||
if (error === 'cancel') {
|
||||
return
|
||||
}
|
||||
console.error('创建订单失败:', error)
|
||||
ElMessage.error(gatewayError(error))
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleDialogClosed = () => {
|
||||
form.silence_period_days = null
|
||||
form.silence_reason = ''
|
||||
formRef.value?.resetFields()
|
||||
form.package_id = undefined
|
||||
form.payment_method = 'wallet'
|
||||
|
||||
@@ -238,6 +238,7 @@ export function useAssetInfo() {
|
||||
card_category: data.card_category || '',
|
||||
activation_status: data.activation_status,
|
||||
enable_polling: data.enable_polling,
|
||||
first_purchase_at: data.first_purchase_at,
|
||||
|
||||
// 设备专属字段 (asset_type === 'device')
|
||||
device_name: data.device_name || '',
|
||||
|
||||
@@ -4,6 +4,8 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { AssetService, DeviceService } from '@/api/modules'
|
||||
import { PollingSchedulerService } from '@/api/modules/pollingScheduler'
|
||||
import { gatewayData, gatewayError } from '@/utils/business/gateway'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { canEditRestrictedAsset } from '@/utils/business/packageSilence'
|
||||
import { formatRemainingTime, FrontendRateLimitError } from '@/utils/business/apiRateLimit'
|
||||
|
||||
/**
|
||||
@@ -11,6 +13,7 @@ import { formatRemainingTime, FrontendRateLimitError } from '@/utils/business/ap
|
||||
* Manages asset operation methods (enable/disable cards, device operations, etc.)
|
||||
*/
|
||||
export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Promise<void>) {
|
||||
const user = useUserStore()
|
||||
// Loading states
|
||||
const enableCardLoading = ref(false)
|
||||
const startFailureMessage = ref('')
|
||||
@@ -97,6 +100,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
|
||||
* Manually deactivate card with strong warning confirmation
|
||||
*/
|
||||
const manualDeactivateCard = async () => {
|
||||
if (!canEditRestrictedAsset(user.info.user_type)) return false
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'手动停用后卡片将永久停用,无法再次使用。此操作不可逆,请谨慎操作。确认要手动停用吗?',
|
||||
@@ -111,6 +115,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
|
||||
manualDeactivateCardLoading.value = true
|
||||
const identifier =
|
||||
cardInfo.value.asset_type === 'card' ? cardInfo.value.iccid : cardInfo.value.virtual_no
|
||||
if (!canEditRestrictedAsset(user.info.user_type)) return false
|
||||
const res = await AssetService.deactivateAsset(identifier)
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('手动停用成功')
|
||||
@@ -250,6 +255,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
|
||||
* Update polling status
|
||||
*/
|
||||
const updatePollingStatus = async (enabled: boolean) => {
|
||||
if (!canEditRestrictedAsset(user.info.user_type)) return false
|
||||
if (pollingLoading.value) return false
|
||||
if (!cardInfo.value) {
|
||||
ElMessage.warning('无法更新轮询状态:缺少资产信息')
|
||||
@@ -265,7 +271,7 @@ export function useAssetOperations(cardInfo: Ref<any>, refreshAssetFn?: () => Pr
|
||||
const lines = impact[enabled ? 'enable' : 'disable']
|
||||
if (!Array.isArray(lines) || !lines.length) throw new Error('未获取到有效操作影响说明')
|
||||
await ElMessageBox.confirm(lines.join('\n'), '确认轮询开关影响', { type: 'warning' })
|
||||
if (cardInfo.value !== target) return false
|
||||
if (cardInfo.value !== target || !canEditRestrictedAsset(user.info.user_type)) return false
|
||||
const response = await AssetService.updatePollingStatus(identifier, {
|
||||
enable_polling: enabled
|
||||
})
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<template #current-package>
|
||||
<CurrentPackageCard
|
||||
:current-package="currentPackage"
|
||||
@refresh="handlePackageRefresh"
|
||||
:loading="currentPackageLoading"
|
||||
:error-msg="currentPackageErrorMsg"
|
||||
:bound-device-id="cardInfo.bound_device_id"
|
||||
@@ -209,6 +210,8 @@
|
||||
import StopResumeRecords from '@/components/business/gateway/StopResumeRecords.vue'
|
||||
import PollingStateDialog from '@/components/business/polling/PollingStateDialog.vue'
|
||||
import { SCHEDULER_PERMISSIONS } from '@/config/constants/pollingScheduler'
|
||||
import { canEditRestrictedAsset, canAccessOrderCategory } from '@/utils/business/packageSilence'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import {
|
||||
formatRemainingTime,
|
||||
FrontendRateLimitError,
|
||||
@@ -670,6 +673,7 @@
|
||||
* 显示更新实名状态对话框
|
||||
*/
|
||||
const showUpdateRealnameStatusDialog = () => {
|
||||
if (!canEditRestrictedAsset(useUserStore().info.user_type)) return
|
||||
realnameStatusAsset = cardInfo.value
|
||||
updateRealnameStatusDialogVisible.value = true
|
||||
}
|
||||
@@ -687,6 +691,7 @@
|
||||
* 显示绑定卡更新实名状态对话框
|
||||
*/
|
||||
const handleUpdateBindingCardRealnameStatus = (payload: { card: any }) => {
|
||||
if (!canEditRestrictedAsset(useUserStore().info.user_type)) return
|
||||
bindingCardRealnameStatusAsset = cardInfo.value
|
||||
bindingCardRealnameStatusIccid.value = payload.card.iccid
|
||||
bindingCardRealnameStatusValue.value = payload.card.real_name_status ?? 0
|
||||
@@ -774,6 +779,7 @@
|
||||
* 显示套餐充值对话框
|
||||
*/
|
||||
const showRechargeDialog = () => {
|
||||
if (!canAccessOrderCategory(useUserStore().info.user_type)) return
|
||||
rechargeDialogVisible.value = true
|
||||
}
|
||||
|
||||
@@ -886,6 +892,7 @@
|
||||
* 跳转到订单详情
|
||||
*/
|
||||
const handleNavigateToOrder = (orderId: number) => {
|
||||
if (!canAccessOrderCategory(useUserStore().info.user_type)) return
|
||||
router.push(`${RoutesAlias.OrderDetail}/${orderId}`)
|
||||
}
|
||||
|
||||
|
||||
@@ -1023,6 +1023,8 @@
|
||||
import PollingBatchDialog from '@/components/business/polling/PollingBatchDialog.vue'
|
||||
import { SCHEDULER_PERMISSIONS } from '@/config/constants/pollingScheduler'
|
||||
import { canPollingBatch, pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import { firstPurchaseRange } from '@/utils/business/packageSilence'
|
||||
import FirstPurchaseCell from '@/components/business/package-silence/FirstPurchaseCell.vue'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import {
|
||||
getExpiryEstimateText,
|
||||
@@ -1370,6 +1372,7 @@
|
||||
|
||||
// 搜索表单初始值
|
||||
const initialSearchState = {
|
||||
first_purchase_range: [] as string[],
|
||||
enable_polling: undefined as boolean | undefined,
|
||||
virtual_no: '',
|
||||
imei: '',
|
||||
@@ -1433,6 +1436,18 @@
|
||||
|
||||
// 搜索表单配置
|
||||
const searchFormItems: SearchFormItem[] = [
|
||||
{
|
||||
label: '首次购买起止',
|
||||
prop: 'first_purchase_range',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
rangeSeparator: '至',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ',
|
||||
clearable: true
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '设备号',
|
||||
prop: 'virtual_no',
|
||||
@@ -1650,6 +1665,7 @@
|
||||
|
||||
// 列配置
|
||||
const columnOptions = [
|
||||
{ label: '首次购买套餐时间', prop: 'first_purchase_at' },
|
||||
{ label: '是否轮询', prop: 'enable_polling' },
|
||||
{ label: '设备号', prop: 'virtual_no' },
|
||||
{ label: 'IMEI', prop: 'imei' },
|
||||
@@ -1910,6 +1926,13 @@
|
||||
|
||||
// 动态列配置
|
||||
const { columnChecks, columns } = useCheckedColumns(() => [
|
||||
{
|
||||
prop: 'first_purchase_at',
|
||||
label: '首次购买套餐时间',
|
||||
width: 180,
|
||||
formatter: (row: Device) =>
|
||||
h(FirstPurchaseCell, { assetId: row.id, assetType: 'device', time: row.first_purchase_at })
|
||||
},
|
||||
{
|
||||
prop: 'virtual_no',
|
||||
label: '设备号',
|
||||
@@ -2248,6 +2271,7 @@
|
||||
device_name: searchForm.device_name || undefined,
|
||||
status: searchForm.status,
|
||||
enable_polling: searchForm.enable_polling ?? undefined,
|
||||
...firstPurchaseRange(searchForm.first_purchase_range),
|
||||
activation_status: searchForm.activation_status ?? undefined,
|
||||
real_name_status: searchForm.real_name_status ?? undefined,
|
||||
batch_no: searchForm.batch_no || undefined,
|
||||
@@ -2275,6 +2299,7 @@
|
||||
|
||||
const exportQuery = computed(() => {
|
||||
const query: Record<string, unknown> = {
|
||||
...firstPurchaseRange(searchForm.first_purchase_range),
|
||||
virtual_no: searchForm.virtual_no || undefined,
|
||||
imei: searchForm.imei || undefined,
|
||||
device_name: searchForm.device_name || undefined,
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<template><ExportTaskList /></template>
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
defineOptions({ name: 'ExportAgentOrder' })
|
||||
</script>
|
||||
@@ -0,0 +1,5 @@
|
||||
<template><ExportTaskList /></template>
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
defineOptions({ name: 'ExportOnlineOrder' })
|
||||
</script>
|
||||
@@ -0,0 +1,5 @@
|
||||
<template><ExportTaskList /></template>
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
defineOptions({ name: 'ExportPlatformOrder' })
|
||||
</script>
|
||||
@@ -0,0 +1,5 @@
|
||||
<template><ExportTaskList /></template>
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
defineOptions({ name: 'ExportSilenceOrder' })
|
||||
</script>
|
||||
@@ -0,0 +1,5 @@
|
||||
<template><ExportTaskList /></template>
|
||||
<script setup lang="ts">
|
||||
import ExportTaskList from '../export-task-list/index.vue'
|
||||
defineOptions({ name: 'ExportSilenceUsage' })
|
||||
</script>
|
||||
@@ -48,6 +48,7 @@
|
||||
} from '@/config/constants'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { isPollingPlatform } from '@/utils/business/pollingScheduler'
|
||||
import { canAccessExportTaskScene } from '@/config/constants/exportTask'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import type { ExportTaskDetail } from '@/types/api'
|
||||
import { ExportTaskStatus } from '@/types/api'
|
||||
@@ -70,6 +71,8 @@
|
||||
throw error
|
||||
}
|
||||
if (res.code !== 0 || !res.data) throw new Error(res.msg || '获取导出任务详情失败')
|
||||
if (!canAccessExportTaskScene(res.data.scene, user.info.user_type))
|
||||
throw Object.assign(new Error('当前账号无权访问该类订单导出'), { status: 403 })
|
||||
if (isPollingPlatformExport(res.data.scene) && !isPollingPlatform(user.info.user_type))
|
||||
throw Object.assign(new Error('仅平台账号可查看该导出任务'), { status: 403 })
|
||||
return res.data
|
||||
@@ -84,6 +87,7 @@
|
||||
const canViewDetail = computed(
|
||||
() =>
|
||||
!!taskPermissions.value &&
|
||||
canAccessExportTaskScene(taskDetail.value?.scene, user.info.user_type) &&
|
||||
hasAuth(taskPermissions.value.detail) &&
|
||||
(!isPollingPlatformExport(taskDetail.value?.scene) || isPollingPlatform(user.info.user_type))
|
||||
)
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
import { getExportTaskSceneConfig, isPollingPlatformExport } from '@/config/constants'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { isPollingPlatform } from '@/utils/business/pollingScheduler'
|
||||
import { canAccessExportTaskScene } from '@/config/constants/exportTask'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import type { ExportTaskDetail, ExportTaskItem, ExportTaskScene } from '@/types/api'
|
||||
import { ExportTaskStatus } from '@/types/api'
|
||||
@@ -61,7 +62,8 @@
|
||||
const { hasAuth } = useAuth()
|
||||
const user = useUserStore()
|
||||
const allowedScene = (scene: ExportTaskScene) =>
|
||||
!isPollingPlatformExport(scene) || isPollingPlatform(user.info.user_type)
|
||||
canAccessExportTaskScene(scene, user.info.user_type) &&
|
||||
(!isPollingPlatformExport(scene) || isPollingPlatform(user.info.user_type))
|
||||
const loading = ref(false)
|
||||
const taskList = ref<ExportTaskItem[]>([])
|
||||
const defaultSceneConfig = getExportTaskSceneConfig('device')!
|
||||
|
||||
@@ -1075,6 +1075,8 @@
|
||||
import PollingBatchDialog from '@/components/business/polling/PollingBatchDialog.vue'
|
||||
import { SCHEDULER_PERMISSIONS } from '@/config/constants/pollingScheduler'
|
||||
import { canPollingBatch, pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import { firstPurchaseRange } from '@/utils/business/packageSilence'
|
||||
import FirstPurchaseCell from '@/components/business/package-silence/FirstPurchaseCell.vue'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
@@ -1614,6 +1616,7 @@
|
||||
[key: string]: any
|
||||
} = {
|
||||
enable_polling: undefined,
|
||||
first_purchase_range: [] as string[],
|
||||
status: undefined,
|
||||
network_status: undefined,
|
||||
real_name_status: undefined,
|
||||
@@ -1976,6 +1979,18 @@
|
||||
})
|
||||
|
||||
const formItems: SearchFormItem[] = baseFormItems
|
||||
formItems.push({
|
||||
label: '首次购买起止',
|
||||
prop: 'first_purchase_range',
|
||||
type: 'datetimerange',
|
||||
config: {
|
||||
rangeSeparator: '至',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ',
|
||||
clearable: true
|
||||
}
|
||||
})
|
||||
formItems.push({
|
||||
label: '是否轮询',
|
||||
prop: 'enable_polling',
|
||||
@@ -1989,6 +2004,7 @@
|
||||
|
||||
// 列配置
|
||||
const columnOptions = [
|
||||
{ label: '首次购买套餐时间', prop: 'first_purchase_at' },
|
||||
{ label: 'ICCID', prop: 'iccid' },
|
||||
{ label: 'IMEI', prop: 'gateway_card_imei' },
|
||||
{ label: 'MSISDN', prop: 'msisdn' },
|
||||
@@ -2110,6 +2126,13 @@
|
||||
|
||||
// 动态列配置
|
||||
const { columnChecks, columns } = useCheckedColumns(() => [
|
||||
{
|
||||
prop: 'first_purchase_at',
|
||||
label: '首次购买套餐时间',
|
||||
width: 180,
|
||||
formatter: (row: StandaloneIotCard) =>
|
||||
h(FirstPurchaseCell, { assetId: row.id, assetType: 'card', time: row.first_purchase_at })
|
||||
},
|
||||
{
|
||||
prop: 'iccid',
|
||||
label: 'ICCID',
|
||||
@@ -2423,10 +2446,10 @@
|
||||
Object.entries(formFilters).forEach(([key, value]) => {
|
||||
if (value === undefined || value === null || value === '') return
|
||||
if (Array.isArray(value) && value.length === 0) return
|
||||
query[key] = value
|
||||
if (key !== 'first_purchase_range') query[key] = value
|
||||
})
|
||||
|
||||
return query
|
||||
return { ...query, ...firstPurchaseRange(formFilters.first_purchase_range) }
|
||||
})
|
||||
|
||||
const showExportDialog = () => {
|
||||
@@ -2444,8 +2467,10 @@
|
||||
const params: Record<string, any> = {
|
||||
page: pagination.page,
|
||||
page_size: pagination.pageSize,
|
||||
...formFilters
|
||||
...formFilters,
|
||||
...firstPurchaseRange(formFilters.first_purchase_range)
|
||||
}
|
||||
delete params.first_purchase_range
|
||||
Object.keys(params).forEach((key) => {
|
||||
if (params[key] === '' || params[key] === undefined) {
|
||||
delete params[key]
|
||||
|
||||
@@ -297,8 +297,8 @@
|
||||
{
|
||||
label: '资产标识',
|
||||
prop: 'asset_identifier',
|
||||
type: 'input',
|
||||
config: { clearable: true, placeholder: 'ICCID / 虚拟号 / IMEI / SN / 接入号(精确匹配)' }
|
||||
type: 'business-select',
|
||||
config: { entity: 'asset' }
|
||||
},
|
||||
{
|
||||
label: '手机号',
|
||||
|
||||
@@ -131,11 +131,8 @@
|
||||
{
|
||||
label: '资产标识符',
|
||||
prop: 'asset_identifier',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: 'ICCID或设备号'
|
||||
}
|
||||
type: 'business-select',
|
||||
config: { entity: 'asset' }
|
||||
},
|
||||
{
|
||||
label: '来源店铺',
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
<ElFormItem label="申请退款金额">
|
||||
<ElInputNumber
|
||||
v-model="resubmitForm.requested_refund_amount"
|
||||
:min="1"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="1"
|
||||
style="width: 100%"
|
||||
@@ -329,11 +329,8 @@
|
||||
{
|
||||
label: '资产标识',
|
||||
prop: 'asset_identifier',
|
||||
type: 'input',
|
||||
placeholder: '请输入ICCID或设备虚拟号',
|
||||
config: {
|
||||
clearable: true
|
||||
}
|
||||
type: 'business-select',
|
||||
config: { entity: 'asset' }
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
@@ -864,7 +861,8 @@
|
||||
const handleShowResubmit = (row: Refund) => {
|
||||
currentRefund.value = row
|
||||
// 预填充原有数据
|
||||
resubmitForm.requested_refund_amount = fenToYuan(row.requested_refund_amount) || undefined
|
||||
resubmitForm.requested_refund_amount =
|
||||
row.requested_refund_amount == null ? undefined : fenToYuan(row.requested_refund_amount)
|
||||
resubmitForm.method = ''
|
||||
resubmitForm.customer_account_name = ''
|
||||
resubmitForm.customer_account_number = ''
|
||||
|
||||
5
src/views/order-management/agent-orders/index.vue
Normal file
5
src/views/order-management/agent-orders/index.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template><OrderList category="agent" /></template>
|
||||
<script setup lang="ts">
|
||||
import OrderList from '../order-list/index.vue'
|
||||
defineOptions({ name: 'AgentOrderList' })
|
||||
</script>
|
||||
5
src/views/order-management/online-orders/index.vue
Normal file
5
src/views/order-management/online-orders/index.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template><OrderList category="online" /></template>
|
||||
<script setup lang="ts">
|
||||
import OrderList from '../order-list/index.vue'
|
||||
defineOptions({ name: 'OnlineOrderList' })
|
||||
</script>
|
||||
@@ -110,7 +110,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { h, onMounted, ref, computed } from 'vue'
|
||||
import { h, onMounted, ref, computed, watch } from 'vue'
|
||||
import { pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElButton, ElCard, ElIcon, ElMessage, ElTable, ElTableColumn, ElTag } from 'element-plus'
|
||||
import { ArrowLeft, Loading } from '@element-plus/icons-vue'
|
||||
@@ -124,6 +125,7 @@
|
||||
OrderOperatorType
|
||||
} from '@/types/api'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { canAccessOrderCategory } from '@/utils/business/packageSilence'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { hasVoucherKeys, toVoucherKeyList } from '@/utils/business'
|
||||
@@ -143,6 +145,13 @@
|
||||
|
||||
const loading = ref(false)
|
||||
const detailData = ref<OrderDetail | null>(null)
|
||||
watch(
|
||||
() => pollingScope(userStore),
|
||||
() => {
|
||||
detailData.value = null
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
const paymentVoucherFileKeys = ref<string[]>([])
|
||||
|
||||
// 格式化货币 - 将分转换为元
|
||||
@@ -424,6 +433,11 @@
|
||||
|
||||
// 获取详情数据
|
||||
const fetchDetail = async () => {
|
||||
const scope = pollingScope(userStore)
|
||||
if (!canAccessOrderCategory(userStore.info.user_type)) {
|
||||
detailData.value = null
|
||||
return
|
||||
}
|
||||
const id = Number(route.params.id)
|
||||
if (!id) {
|
||||
ElMessage.error('缺少ID参数')
|
||||
@@ -433,7 +447,11 @@
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await OrderService.getOrderById(id)
|
||||
if (res.code === 0) {
|
||||
if (
|
||||
scope === pollingScope(userStore) &&
|
||||
canAccessOrderCategory(userStore.info.user_type) &&
|
||||
res.code === 0
|
||||
) {
|
||||
detailData.value = res.data
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<template>
|
||||
<ArtTableFullScreen>
|
||||
<ArtTableFullScreen v-if="canReadCategory">
|
||||
<div class="order-list-page" id="table-full-screen">
|
||||
<!-- 搜索栏 -->
|
||||
<ArtSearchBar
|
||||
v-model:filter="searchForm"
|
||||
:filter="searchForm"
|
||||
@update:filter="(value) => Object.assign(searchForm, value)"
|
||||
:items="searchFormItems"
|
||||
show-expand
|
||||
:show-expand="searchFormItems.length >= 4"
|
||||
@reset="handleReset"
|
||||
label-width="90"
|
||||
@search="handleSearch"
|
||||
@@ -59,10 +60,16 @@
|
||||
<ElDialog
|
||||
v-model="createDialogVisible"
|
||||
:title="'创建订单'"
|
||||
width="40%"
|
||||
width="min(760px, 96vw)"
|
||||
@closed="handleCreateDialogClosed"
|
||||
>
|
||||
<ElForm ref="createFormRef" :model="createForm" :rules="createRules" label-width="80px">
|
||||
<SilencePurchaseFields
|
||||
v-if="hasAuth(PACKAGE_SILENCE_PERMISSIONS.override)"
|
||||
v-model:days="createForm.silence_period_days"
|
||||
v-model:reason="createForm.silence_reason"
|
||||
:disabled="createLoading"
|
||||
/>
|
||||
<ElFormItem :label="'订单类型'" prop="order_type">
|
||||
<ElSelect
|
||||
v-model="createForm.order_type"
|
||||
@@ -249,14 +256,15 @@
|
||||
<!-- 导出任务对话框 -->
|
||||
<ExportTaskCreateDialog
|
||||
v-model="exportDialogVisible"
|
||||
scene="order"
|
||||
:query="exportQuery"
|
||||
:scene="categoryConfig.scene"
|
||||
:query="props.category === 'all' ? exportQuery : { filters: exportQuery }"
|
||||
confirm-permission="orders:export"
|
||||
title="导出订单"
|
||||
:title="`导出${categoryConfig.title}`"
|
||||
/>
|
||||
</ElCard>
|
||||
</div>
|
||||
</ArtTableFullScreen>
|
||||
<ElEmpty v-else description="当前账号无权访问该类订单" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -303,8 +311,21 @@
|
||||
import ExportTaskCreateDialog from '@/components/business/ExportTaskCreateDialog.vue'
|
||||
import VoucherUpload from '@/components/business/VoucherUpload.vue'
|
||||
import { BULK_PURCHASE_PERMISSIONS } from '@/config/constants/bulkPurchase'
|
||||
import {
|
||||
ORDER_CATEGORY_CONFIG,
|
||||
PACKAGE_SILENCE_PERMISSIONS
|
||||
} from '@/config/constants/packageSilence'
|
||||
import {
|
||||
canAccessOrderCategory,
|
||||
assertSilenceResponse,
|
||||
silencePurchaseFields,
|
||||
type OrderCategory
|
||||
} from '@/utils/business/packageSilence'
|
||||
import { pollingScope } from '@/utils/business/pollingScheduler'
|
||||
import SilencePurchaseFields from '@/components/business/package-silence/SilencePurchaseFields.vue'
|
||||
|
||||
defineOptions({ name: 'OrderList' })
|
||||
const props = withDefaults(defineProps<{ category?: OrderCategory }>(), { category: 'all' })
|
||||
|
||||
type OrderSearchFormState = Omit<OrderQueryParams, 'is_expired'> & {
|
||||
is_expired?: number
|
||||
@@ -313,6 +334,10 @@
|
||||
const router = useRouter()
|
||||
const { hasAuth } = useAuth()
|
||||
const userStore = useUserStore()
|
||||
const canReadCategory = computed(() =>
|
||||
canAccessOrderCategory(userStore.info.user_type, props.category)
|
||||
)
|
||||
const categoryConfig = computed(() => ORDER_CATEGORY_CONFIG[props.category])
|
||||
|
||||
const loading = ref(false)
|
||||
const createLoading = ref(false)
|
||||
@@ -388,11 +413,9 @@
|
||||
{
|
||||
label: '资产标识符',
|
||||
prop: 'identifier',
|
||||
type: 'input',
|
||||
type: 'business-select',
|
||||
config: {
|
||||
maxlength: 30,
|
||||
clearable: true,
|
||||
placeholder: 'ICCID/VirtualNo/IMEI/MSISDN/SN'
|
||||
entity: 'asset'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -598,6 +621,8 @@
|
||||
})
|
||||
|
||||
const createForm = reactive({
|
||||
silence_period_days: null as number | null,
|
||||
silence_reason: '',
|
||||
order_type: 'single_card' as OrderType,
|
||||
package_id: undefined as number | undefined, // 前端使用单选
|
||||
iot_card_id: null as number | null,
|
||||
@@ -609,6 +634,16 @@
|
||||
})
|
||||
|
||||
const orderList = ref<Order[]>([])
|
||||
watch(
|
||||
() => pollingScope(userStore),
|
||||
() => {
|
||||
orderList.value = []
|
||||
createDialogVisible.value = false
|
||||
exportDialogVisible.value = false
|
||||
paymentVoucherFileKeys.value = []
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
|
||||
// 套餐搜索相关
|
||||
const packageOptions = ref<PackageResponse[]>([])
|
||||
@@ -1127,6 +1162,8 @@
|
||||
watch(
|
||||
() => createForm.package_id,
|
||||
(packageId) => {
|
||||
createForm.silence_period_days = null
|
||||
createForm.silence_reason = ''
|
||||
if (packageId) {
|
||||
const selectedPackage = packageOptions.value.find((pkg) => pkg.id === packageId)
|
||||
if (selectedPackage?.is_gift) {
|
||||
@@ -1142,6 +1179,11 @@
|
||||
|
||||
// 获取订单列表
|
||||
const getTableData = async () => {
|
||||
if (!canReadCategory.value) {
|
||||
orderList.value = []
|
||||
return
|
||||
}
|
||||
const scope = pollingScope(userStore)
|
||||
loading.value = true
|
||||
try {
|
||||
const params: OrderQueryParams = {
|
||||
@@ -1160,8 +1202,14 @@
|
||||
start_time: searchForm.start_time || undefined,
|
||||
end_time: searchForm.end_time || undefined
|
||||
}
|
||||
const res = await OrderService.getOrders(params)
|
||||
if (res.code === 0) {
|
||||
const res = await (props.category === 'platform'
|
||||
? OrderService.getPlatformOrders(params)
|
||||
: props.category === 'agent'
|
||||
? OrderService.getAgentOrders(params)
|
||||
: props.category === 'online'
|
||||
? OrderService.getOnlineOrders(params)
|
||||
: OrderService.getOrders(params))
|
||||
if (scope === pollingScope(userStore) && canReadCategory.value && res.code === 0) {
|
||||
orderList.value = res.data.items || []
|
||||
pagination.total = res.data.total || 0
|
||||
}
|
||||
@@ -1236,6 +1284,7 @@
|
||||
|
||||
// 显示创建订单对话框
|
||||
const showCreateDialog = async () => {
|
||||
if (!canReadCategory.value || !hasAuth('orders:add')) return
|
||||
createDialogVisible.value = true
|
||||
// IoT卡和设备列表在用户搜索时才加载,不在此处预加载
|
||||
}
|
||||
@@ -1271,6 +1320,8 @@
|
||||
|
||||
// 对话框关闭后的清理
|
||||
const handleCreateDialogClosed = () => {
|
||||
createForm.silence_period_days = null
|
||||
createForm.silence_reason = ''
|
||||
// 重置表单(会同时清除验证状态)
|
||||
createFormRef.value?.resetFields()
|
||||
|
||||
@@ -1294,6 +1345,8 @@
|
||||
|
||||
// 创建订单
|
||||
const handleCreateOrder = async (formEl: FormInstance | undefined) => {
|
||||
const origin = pollingScope(userStore)
|
||||
if (!canReadCategory.value || !hasAuth('orders:add') || createLoading.value) return
|
||||
if (!formEl) return
|
||||
if (voucherUploading.value) {
|
||||
ElMessage.warning('支付凭证上传中,请稍候')
|
||||
@@ -1301,7 +1354,12 @@
|
||||
}
|
||||
|
||||
await formEl.validate(async (valid) => {
|
||||
if (valid) {
|
||||
if (
|
||||
valid &&
|
||||
canReadCategory.value &&
|
||||
origin === pollingScope(userStore) &&
|
||||
hasAuth('orders:add')
|
||||
) {
|
||||
createLoading.value = true
|
||||
try {
|
||||
// 获取 identifier (ICCID 或 VirtualNo)
|
||||
@@ -1352,6 +1410,11 @@
|
||||
|
||||
// 创建订单(后端接收数组,前端单选转为单元素数组)
|
||||
const data: CreateOrderRequest = {
|
||||
...silencePurchaseFields(
|
||||
hasAuth(PACKAGE_SILENCE_PERMISSIONS.override),
|
||||
createForm.silence_period_days,
|
||||
createForm.silence_reason
|
||||
),
|
||||
identifier,
|
||||
package_ids: [createForm.package_id],
|
||||
payment_method: createForm.payment_method
|
||||
@@ -1365,7 +1428,7 @@
|
||||
data.payment_voucher_key = toVoucherKeyList(createForm.payment_voucher_key)
|
||||
}
|
||||
|
||||
const res = await OrderService.createOrder(data)
|
||||
const res = assertSilenceResponse(await OrderService.createOrder(data))
|
||||
if (res.code !== 0) return
|
||||
|
||||
// 根据支付方式显示不同的成功消息
|
||||
@@ -1383,7 +1446,7 @@
|
||||
if (error === 'cancel') {
|
||||
return
|
||||
}
|
||||
console.error(error)
|
||||
ElMessage.error(error?.response?.data?.msg || error?.message || '订单创建失败')
|
||||
} finally {
|
||||
createLoading.value = false
|
||||
}
|
||||
@@ -1393,6 +1456,7 @@
|
||||
|
||||
// 查看订单详情
|
||||
const showOrderDetail = (row: Order) => {
|
||||
if (!canReadCategory.value) return
|
||||
router.push({
|
||||
path: `${RoutesAlias.OrderList}/detail/${row.id}`
|
||||
})
|
||||
@@ -1409,6 +1473,7 @@
|
||||
|
||||
// 取消订单
|
||||
const handleCancelOrder = (row: Order) => {
|
||||
if (!canReadCategory.value) return
|
||||
// 已支付的订单不能取消
|
||||
if (row.payment_status === 2) {
|
||||
ElMessage.warning('已支付的订单无法取消')
|
||||
@@ -1421,6 +1486,7 @@
|
||||
type: 'warning'
|
||||
})
|
||||
.then(async () => {
|
||||
if (!canReadCategory.value) return
|
||||
try {
|
||||
await OrderService.cancelOrder(row.id)
|
||||
ElMessage.success('订单已取消')
|
||||
|
||||
5
src/views/order-management/platform-orders/index.vue
Normal file
5
src/views/order-management/platform-orders/index.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template><OrderList category="platform" /></template>
|
||||
<script setup lang="ts">
|
||||
import OrderList from '../order-list/index.vue'
|
||||
defineOptions({ name: 'PlatformOrderList' })
|
||||
</script>
|
||||
@@ -178,6 +178,22 @@
|
||||
}
|
||||
},
|
||||
{ label: '套餐默认生效条件', prop: 'default_expiry_base_name' },
|
||||
{
|
||||
label: '默认沉默期(天)',
|
||||
formatter: (_: unknown, data: PackageResponse) =>
|
||||
data.package_type === 'formal' ? String(data.silence_period_days ?? '未配置') : '不适用'
|
||||
},
|
||||
{
|
||||
label: '支持付费延期',
|
||||
formatter: (_: unknown, data: PackageResponse) =>
|
||||
data.package_type !== 'formal'
|
||||
? '不适用'
|
||||
: data.silence_extension_enabled == null
|
||||
? '-'
|
||||
: data.silence_extension_enabled
|
||||
? '是'
|
||||
: '否'
|
||||
},
|
||||
{
|
||||
label: '分配覆盖生效条件',
|
||||
prop: 'expiry_base_override_name',
|
||||
|
||||
@@ -60,11 +60,11 @@
|
||||
<ElDialog
|
||||
v-model="dialogVisible"
|
||||
:title="dialogType === 'add' ? '新增套餐' : '编辑套餐'"
|
||||
width="50%"
|
||||
width="min(960px, 96vw)"
|
||||
:close-on-click-modal="false"
|
||||
@closed="handleDialogClosed"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="150px">
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="12">
|
||||
<ElFormItem label="套餐编码" prop="package_code">
|
||||
@@ -197,6 +197,13 @@
|
||||
</ElCol>
|
||||
</ElRow>
|
||||
|
||||
<PackageSilenceFields
|
||||
:package-type="form.package_type"
|
||||
:expiry-base="form.expiry_base"
|
||||
:required="form.silence_config_required"
|
||||
v-model:days="form.silence_period_days"
|
||||
v-model:enabled="form.silence_extension_enabled"
|
||||
/>
|
||||
<!-- 真流量额度 -->
|
||||
<ElRow :gutter="20">
|
||||
<ElCol :span="12">
|
||||
@@ -265,6 +272,7 @@
|
||||
<ElFormItem label="到期计时基准" prop="expiry_base">
|
||||
<ElSelect
|
||||
v-model="form.expiry_base"
|
||||
:disabled="originalExpiryBase === 'from_activation'"
|
||||
placeholder="请选择到期计时基准"
|
||||
style="width: 100%"
|
||||
clearable
|
||||
@@ -391,6 +399,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import PackageSilenceFields from '@/components/business/package-silence/PackageSilenceFields.vue'
|
||||
import { packageSilenceFields, assertSilenceResponse } from '@/utils/business/packageSilence'
|
||||
import { h, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { PackageManageService, PackageSeriesService } from '@/api/modules'
|
||||
@@ -485,6 +495,7 @@
|
||||
|
||||
// 搜索表单初始值
|
||||
const initialSearchState = {
|
||||
silence_unconfigured: undefined as boolean | undefined,
|
||||
package_name: '',
|
||||
series_id: undefined as number | undefined,
|
||||
package_type: undefined as string | undefined,
|
||||
@@ -497,6 +508,13 @@
|
||||
|
||||
// 搜索表单配置
|
||||
const searchFormItems = computed<SearchFormItem[]>(() => [
|
||||
{
|
||||
label: '未配置沉默期',
|
||||
prop: 'silence_unconfigured',
|
||||
type: 'select',
|
||||
options: [{ label: '仅未配置', value: true }],
|
||||
config: { clearable: true }
|
||||
},
|
||||
{
|
||||
label: '套餐名称',
|
||||
prop: 'package_name',
|
||||
@@ -706,7 +724,11 @@
|
||||
})
|
||||
|
||||
// 表单数据
|
||||
const originalExpiryBase = ref<string | null>(null)
|
||||
const form = reactive<any>({
|
||||
silence_period_days: 30,
|
||||
silence_extension_enabled: true,
|
||||
silence_config_required: false,
|
||||
id: 0,
|
||||
package_code: '',
|
||||
package_name: '',
|
||||
@@ -786,7 +808,7 @@
|
||||
prop: 'package_name',
|
||||
label: '套餐名称',
|
||||
width: 200,
|
||||
fixed:true,
|
||||
fixed: true,
|
||||
showOverflowTooltip: true,
|
||||
formatter: (row: PackageResponse) => {
|
||||
const hasPermission = hasAuth('package:detail')
|
||||
@@ -1253,7 +1275,8 @@
|
||||
series_id: searchForm.series_id || undefined,
|
||||
package_type: searchForm.package_type || undefined,
|
||||
shelf_status: searchForm.shelf_status || undefined,
|
||||
status: searchForm.status ?? undefined
|
||||
status: searchForm.status ?? undefined,
|
||||
silence_unconfigured: searchForm.silence_unconfigured || undefined
|
||||
}
|
||||
const res = await PackageManageService.getPackages(params)
|
||||
if (res.code === 0) {
|
||||
@@ -1275,7 +1298,8 @@
|
||||
series_id: searchForm.series_id ?? undefined,
|
||||
package_type: searchForm.package_type || undefined,
|
||||
shelf_status: searchForm.shelf_status ?? undefined,
|
||||
status: searchForm.status ?? undefined
|
||||
status: searchForm.status ?? undefined,
|
||||
silence_unconfigured: searchForm.silence_unconfigured || undefined
|
||||
}
|
||||
|
||||
Object.keys(query).forEach((key) => {
|
||||
@@ -1318,6 +1342,10 @@
|
||||
|
||||
// 显示新增/编辑对话框
|
||||
const showDialog = async (type: string, row?: PackageResponse) => {
|
||||
originalExpiryBase.value = null
|
||||
form.silence_period_days = 30
|
||||
form.silence_extension_enabled = true
|
||||
form.silence_config_required = false
|
||||
dialogType.value = type
|
||||
|
||||
if (type === 'edit' && row) {
|
||||
@@ -1325,6 +1353,10 @@
|
||||
const res = await PackageManageService.getPackageDetail(row.id)
|
||||
if (res.code === 0 && res.data) {
|
||||
const data = res.data
|
||||
originalExpiryBase.value = data.expiry_base ?? null
|
||||
form.silence_period_days = data.silence_period_days ?? null
|
||||
form.silence_extension_enabled = data.silence_extension_enabled ?? true
|
||||
form.silence_config_required = data.silence_config_required ?? false
|
||||
form.id = data.id
|
||||
form.package_code = data.package_code
|
||||
form.package_name = data.package_name
|
||||
@@ -1461,6 +1493,7 @@
|
||||
const costPriceInCents = Math.round(form.cost_price * 100)
|
||||
|
||||
const data: any = {
|
||||
...packageSilenceFields(form, originalExpiryBase.value),
|
||||
package_name: form.package_name,
|
||||
package_type: form.package_type,
|
||||
duration_months: form.duration_months,
|
||||
@@ -1509,18 +1542,18 @@
|
||||
}
|
||||
|
||||
if (dialogType.value === 'add') {
|
||||
await PackageManageService.createPackage(data)
|
||||
assertSilenceResponse(await PackageManageService.createPackage(data))
|
||||
ElMessage.success('新增成功')
|
||||
} else {
|
||||
await PackageManageService.updatePackage(form.id, data)
|
||||
assertSilenceResponse(await PackageManageService.updatePackage(form.id, data))
|
||||
ElMessage.success('修改成功')
|
||||
}
|
||||
|
||||
dialogVisible.value = false
|
||||
formEl.resetFields()
|
||||
await getTableData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error?.response?.data?.msg || error?.message || '套餐保存失败')
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
|
||||
@@ -702,7 +702,8 @@
|
||||
packageForm.value.expiry_base_override === 'default'
|
||||
? null
|
||||
: packageForm.value.expiry_base_override
|
||||
}
|
||||
},
|
||||
packageForm.value.package_id
|
||||
)
|
||||
}
|
||||
await ShopSeriesGrantService.manageGrantPackages(grantId, {
|
||||
@@ -778,7 +779,8 @@
|
||||
expiryForm.value.expiry_base_override === 'default'
|
||||
? null
|
||||
: expiryForm.value.expiry_base_override
|
||||
}
|
||||
},
|
||||
expiryForm.value.package_id
|
||||
)
|
||||
if (response.code === 0) {
|
||||
ElMessage.success('生效条件更新成功')
|
||||
|
||||
@@ -480,7 +480,8 @@
|
||||
packageForm.value.expiry_base_override === 'default'
|
||||
? null
|
||||
: packageForm.value.expiry_base_override
|
||||
}
|
||||
},
|
||||
packageForm.value.package_id
|
||||
)
|
||||
}
|
||||
await ShopSeriesGrantService.manageGrantPackages(grantId.value, {
|
||||
@@ -514,7 +515,8 @@
|
||||
expiryForm.value.expiry_base_override === 'default'
|
||||
? null
|
||||
: expiryForm.value.expiry_base_override
|
||||
}
|
||||
},
|
||||
expiryForm.value.package_id
|
||||
)
|
||||
if (response.code === 0) {
|
||||
ElMessage.success('生效条件更新成功')
|
||||
|
||||
5
src/views/package-management/silence-batches/detail.vue
Normal file
5
src/views/package-management/silence-batches/detail.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template><SilenceDetail kind="batches" /></template>
|
||||
<script setup lang="ts">
|
||||
import SilenceDetail from '@/components/business/package-silence/SilenceDetail.vue'
|
||||
defineOptions({ name: 'SilenceBatchesDetail' })
|
||||
</script>
|
||||
5
src/views/package-management/silence-batches/index.vue
Normal file
5
src/views/package-management/silence-batches/index.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template><SilenceManagement kind="batches" /></template>
|
||||
<script setup lang="ts">
|
||||
import SilenceManagement from '@/components/business/package-silence/SilenceManagement.vue'
|
||||
defineOptions({ name: 'SilenceBatches' })
|
||||
</script>
|
||||
5
src/views/package-management/silence-orders/detail.vue
Normal file
5
src/views/package-management/silence-orders/detail.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template><SilenceDetail kind="orders" /></template>
|
||||
<script setup lang="ts">
|
||||
import SilenceDetail from '@/components/business/package-silence/SilenceDetail.vue'
|
||||
defineOptions({ name: 'SilenceOrdersDetail' })
|
||||
</script>
|
||||
5
src/views/package-management/silence-orders/index.vue
Normal file
5
src/views/package-management/silence-orders/index.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template><SilenceManagement kind="orders" /></template>
|
||||
<script setup lang="ts">
|
||||
import SilenceManagement from '@/components/business/package-silence/SilenceManagement.vue'
|
||||
defineOptions({ name: 'SilenceOrders' })
|
||||
</script>
|
||||
5
src/views/package-management/silence-policies/index.vue
Normal file
5
src/views/package-management/silence-policies/index.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template><SilenceManagement kind="policies" /></template>
|
||||
<script setup lang="ts">
|
||||
import SilenceManagement from '@/components/business/package-silence/SilenceManagement.vue'
|
||||
defineOptions({ name: 'SilencePolicies' })
|
||||
</script>
|
||||
5
src/views/package-management/silence-usages/index.vue
Normal file
5
src/views/package-management/silence-usages/index.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template><SilenceManagement kind="usages" /></template>
|
||||
<script setup lang="ts">
|
||||
import SilenceManagement from '@/components/business/package-silence/SilenceManagement.vue'
|
||||
defineOptions({ name: 'SilenceUsages' })
|
||||
</script>
|
||||
@@ -158,12 +158,17 @@
|
||||
],
|
||||
config: { clearable: true }
|
||||
},
|
||||
{ label: '资产标识', prop: 'identifier', type: 'input', config: { clearable: true } },
|
||||
{
|
||||
label: '关闭操作人 ID',
|
||||
label: '资产',
|
||||
prop: 'identifier',
|
||||
type: 'business-select',
|
||||
config: { entity: 'asset', allowed: platform.value && hasAuth(P.page) }
|
||||
},
|
||||
{
|
||||
label: '关闭操作人',
|
||||
prop: 'operator_id',
|
||||
type: 'input',
|
||||
config: { type: 'number', min: 0, clearable: true }
|
||||
type: 'business-select',
|
||||
config: { entity: 'account', includeSystem: true, allowed: platform.value && hasAuth(P.page) }
|
||||
},
|
||||
{
|
||||
label: '关闭时间起止',
|
||||
|
||||
@@ -220,10 +220,10 @@
|
||||
// 搜索表单配置
|
||||
const searchFormItems: SearchFormItem[] = [
|
||||
{
|
||||
label: '卡ID',
|
||||
label: '网卡',
|
||||
prop: 'card_id',
|
||||
type: 'input',
|
||||
config: { clearable: true, placeholder: '请输入卡ID' }
|
||||
type: 'business-select',
|
||||
config: { entity: 'card' }
|
||||
},
|
||||
{
|
||||
label: '任务类型',
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
assume_control_off: filters.assume_control_off.join(',')
|
||||
})
|
||||
}
|
||||
const { data, loading, error, load } = useSchedulerRequest(
|
||||
const { data, loading, error, load, clear } = useSchedulerRequest(
|
||||
async () => {
|
||||
const result = gatewayData(
|
||||
await Service.dryRun({ ...query(), page: page.value, page_size: size.value })
|
||||
@@ -184,6 +184,8 @@
|
||||
void load()
|
||||
}
|
||||
function reset() {
|
||||
// 重置不触发全量演练;同时使重置前的在途响应失效。
|
||||
clear()
|
||||
Object.assign(filters, {
|
||||
carrier_id: undefined,
|
||||
stop_reason: '',
|
||||
|
||||
87
src/views/settings/package-silence-switch/index.vue
Normal file
87
src/views/settings/package-silence-switch/index.vue
Normal file
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<ElCard shadow="never" v-if="user.isSuperAdmin">
|
||||
<h2>沉默期总开关</h2>
|
||||
<ElAlert
|
||||
title="默认关闭。开启前须通过全部后端检查;关闭不检查。此页面不会自动切换总开关。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
/>
|
||||
<p>当前状态:{{ data ? (data.enabled ? '已开启' : '已关闭') : '未获取' }}</p>
|
||||
<ElButton :loading="loading" :disabled="saving" @click="load">刷新检查</ElButton>
|
||||
<ElButton :loading="saving" :disabled="!data || loading" type="primary" @click="toggle">{{
|
||||
data?.enabled ? '关闭沉默期' : '开启沉默期'
|
||||
}}</ElButton>
|
||||
<ElAlert v-if="error" :title="error" type="error" :closable="false" />
|
||||
<ArtTable
|
||||
:data="failed.length ? failed : data?.precheck || []"
|
||||
:pagination="false"
|
||||
row-key="code"
|
||||
>
|
||||
<ElTableColumn prop="code" label="检查编码" min-width="180" /><ElTableColumn
|
||||
prop="name"
|
||||
label="检查项"
|
||||
min-width="200"
|
||||
/>
|
||||
<ElTableColumn label="是否通过" width="120"
|
||||
><template #default="{ row }">{{ row.passed ? '通过' : '未通过' }}</template></ElTableColumn
|
||||
><ElTableColumn prop="count" label="数量" width="100" />
|
||||
</ArtTable>
|
||||
</ElCard>
|
||||
<ElEmpty v-else description="仅超级管理员可访问" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { useSchedulerRequest } from '@/composables/useSchedulerRequest'
|
||||
import { PackageSilenceService } from '@/api/modules/packageSilence'
|
||||
import { gatewayData, gatewayError, requireGatewayAccess } from '@/utils/business/gateway'
|
||||
import type { SilenceSwitchCheck } from '@/types/api/packageSilence'
|
||||
defineOptions({ name: 'PackageSilenceSwitch' })
|
||||
const user = useUserStore(),
|
||||
saving = ref(false),
|
||||
failed = ref<SilenceSwitchCheck[]>([])
|
||||
const {
|
||||
data,
|
||||
loading,
|
||||
error,
|
||||
load: loadState
|
||||
} = useSchedulerRequest(
|
||||
async () => gatewayData(await PackageSilenceService.getSwitch()),
|
||||
() => user.isSuperAdmin
|
||||
)
|
||||
async function load() {
|
||||
failed.value = []
|
||||
await loadState()
|
||||
}
|
||||
async function toggle() {
|
||||
if (saving.value || loading.value || !data.value) return
|
||||
saving.value = true
|
||||
failed.value = []
|
||||
try {
|
||||
requireGatewayAccess(user.isSuperAdmin)
|
||||
const enabled = !data.value.enabled
|
||||
await ElMessageBox.confirm(
|
||||
enabled ? '确认开启沉默期?后端将重新检查全部前置条件。' : '确认关闭沉默期?',
|
||||
'切换确认',
|
||||
{ type: 'warning' }
|
||||
)
|
||||
requireGatewayAccess(user.isSuperAdmin)
|
||||
const response = await PackageSilenceService.setSwitch(enabled)
|
||||
if (response.code !== 0) {
|
||||
failed.value =
|
||||
(response.data as unknown as { failed_items?: SilenceSwitchCheck[] })?.failed_items || []
|
||||
throw new Error(response.msg || '切换失败')
|
||||
}
|
||||
await load()
|
||||
} catch (cause: any) {
|
||||
if (cause !== 'cancel' && cause !== 'close') {
|
||||
failed.value = cause?.response?.data?.data?.failed_items || failed.value
|
||||
error.value = gatewayError(cause)
|
||||
}
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
onMounted(load)
|
||||
</script>
|
||||
@@ -313,6 +313,7 @@
|
||||
|
||||
const getActions = (row: SystemConfigItem) =>
|
||||
row.readonly ||
|
||||
row.config_key === 'package.silence.enabled' ||
|
||||
([PAYMENT_CONFIG_KEYS.card, PAYMENT_CONFIG_KEYS.device].includes(row.config_key as never) &&
|
||||
!hasAuth(JULY_PERMISSIONS.systemConfig.payment))
|
||||
? []
|
||||
@@ -344,6 +345,7 @@
|
||||
}
|
||||
|
||||
const showEditDialog = (row: SystemConfigItem) => {
|
||||
if (row.config_key === 'package.silence.enabled') return
|
||||
currentConfig.value = row
|
||||
originalValue.value = row.value
|
||||
editValue.value = row.value
|
||||
@@ -358,7 +360,10 @@
|
||||
ElMessage.error('未选择要编辑的系统配置')
|
||||
return
|
||||
}
|
||||
if (currentConfig.value.readonly) {
|
||||
if (
|
||||
currentConfig.value.readonly ||
|
||||
currentConfig.value.config_key === 'package.silence.enabled'
|
||||
) {
|
||||
ElMessage.warning('当前配置为只读配置,不能保存')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
@change="handleBusinessTypeChange"
|
||||
>
|
||||
<ElOption label="退款审批" value="refund_approval" />
|
||||
<ElOption label="沉默期审批" value="package_silence_approval" />
|
||||
<ElOption label="线下代充值审批" value="offline_recharge_approval" />
|
||||
<ElOption label="员工代收款审批" value="employee_collection_approval" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user