This commit is contained in:
@@ -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}`)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user