|
@@ -24,16 +24,6 @@
|
|
|
<div class="item-content">{{ tariffForm.terminalName }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="detail-item-box">
|
|
|
- <div class="detail-item">
|
|
|
- <div class="item-label">{{ $t('order.BillingMode') }}</div>
|
|
|
- <div class="item-content">{{ tariffForm.billingMethodName }}</div>
|
|
|
- </div>
|
|
|
- <div class="detail-item">
|
|
|
- <div class="item-label">{{ $t('order.SettlementCycle') }}</div>
|
|
|
- <div class="item-content">{{ tariffForm.billingcycleName }}</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
<div class="detail-item-box">
|
|
|
<div class="detail-item">
|
|
|
<div class="item-label">{{ $t('order.CardType') }}</div>
|
|
@@ -50,9 +40,9 @@
|
|
|
<div class="item-label">{{ $t('order.CardNum') }}</div>
|
|
|
<div class="item-content">{{ dataDetail.length }}
|
|
|
<template v-if="!show">
|
|
|
- <a-button type="primary" @click="showCard = true" style="margin-left:10px;"
|
|
|
- v-if="userType == 1 && FormDataList.moderationStatus == 2">{{
|
|
|
- $t('order.AllocationCardNumber') }}</a-button>
|
|
|
+ <a-button type="primary" @click="showCard = true" style="margin-left:10px;"
|
|
|
+ v-if="userType == 1 && FormDataList.moderationStatus == 2">{{
|
|
|
+ $t('order.AllocationCardNumber') }}</a-button>
|
|
|
</template>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -81,7 +71,8 @@
|
|
|
:cancelText="$t('form.Cancel')" unmount-on-close>
|
|
|
<div style="display: flex;justify-content: space-between;">
|
|
|
<div>
|
|
|
- <Upload listType="" minx="1" accept=".xlsx" :handelUpload="customRequest" :showRemoveButton="false" v-if="showCard">
|
|
|
+ <Upload listType="" minx="1" accept=".xlsx" :handelUpload="customRequest" :showRemoveButton="false"
|
|
|
+ v-if="showCard">
|
|
|
</Upload>
|
|
|
<span style="color: #ccc;margin-top: 10px;display: inline-block;">请上传.xlsx文件</span>
|
|
|
</div>
|
|
@@ -97,10 +88,11 @@ import { ref, onMounted, toRefs, toRef, watch } from 'vue';
|
|
|
import { AcquireOrdertariff, DistributionCard, ReturntheOrderCard, GuideCardProgress } from '@/api/path/order'
|
|
|
import { Message } from '@arco-design/web-vue';
|
|
|
import Upload from "@/components/upload/index.vue";
|
|
|
-import { Getdictionary } from '@/mixins/index.js'
|
|
|
+import { Getdictionary, filterDict } from '@/mixins/index.js'
|
|
|
import { downloadFile } from '@/utils/xlsx.js'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
const { t } = useI18n();
|
|
|
+// 定义 props
|
|
|
const props = defineProps({
|
|
|
modelValue: {
|
|
|
type: Boolean,
|
|
@@ -110,10 +102,12 @@ const props = defineProps({
|
|
|
type: Object,
|
|
|
default: () => ({})
|
|
|
}
|
|
|
-})
|
|
|
-const modelValue = toRef(props, 'modelValue')
|
|
|
-const FormDataList = toRef(props, 'FormDataList')
|
|
|
-const emit = defineEmits(['update:modelValue', 'submit'])
|
|
|
+});
|
|
|
+
|
|
|
+// 将 props 转为 ref
|
|
|
+const modelValue = toRef(props, 'modelValue');
|
|
|
+const FormDataList = toRef(props, 'FormDataList');
|
|
|
+const emit = defineEmits(['update:modelValue', 'submit']);
|
|
|
|
|
|
const state = ref({
|
|
|
tariffForm: {},
|
|
@@ -124,20 +118,21 @@ const state = ref({
|
|
|
userType: JSON.parse(localStorage.getItem('user_login_information'))?.userType, // 1平台 2用户
|
|
|
show: false,
|
|
|
schedule: 0, // 进度
|
|
|
- ids: null
|
|
|
-})
|
|
|
+});
|
|
|
+const { tariffForm, showCard, res1, res2, res3, userType, show, schedule } = toRefs(state.value);
|
|
|
|
|
|
-const { tariffForm, showCard, res1, res2, res3, userType, show, schedule, ids } = toRefs(state.value)
|
|
|
+// 表格列定义
|
|
|
const columnsDetail = [
|
|
|
{ title: 'ICCID', dataIndex: 'iccid' },
|
|
|
{ title: t('order.CardStatus'), dataIndex: 'status' },
|
|
|
{ title: t('order.CreationTime'), dataIndex: 'createdAt' }
|
|
|
-]
|
|
|
+];
|
|
|
+
|
|
|
+// 数据详情
|
|
|
+const dataDetail = ref([]);
|
|
|
|
|
|
-const dataDetail = ref([])
|
|
|
-let timer;
|
|
|
|
|
|
-// 分配卡号并开始进度监控
|
|
|
+// 分配卡号并处理进度
|
|
|
const customRequest = async (options) => {
|
|
|
const formData = new FormData();
|
|
|
formData.append('file', options.fileItem.file); // 文件
|
|
@@ -147,107 +142,77 @@ const customRequest = async (options) => {
|
|
|
if (res.code === 200) {
|
|
|
Message.success(res.message);
|
|
|
showCard.value = false;
|
|
|
-
|
|
|
- const progressRes = await GuideCardProgress({ id: FormDataList.value.id });
|
|
|
- handleProgressResponse(progressRes);
|
|
|
+ await CardProgress();
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
// 关闭弹窗
|
|
|
const cancel = () => emit('update:modelValue', false);
|
|
|
const closeModal = () => showCard.value = false;
|
|
|
|
|
|
+
|
|
|
// 监听 FormDataList 的变化
|
|
|
-watch(() => FormDataList.value, val => {
|
|
|
+watch(() => FormDataList.value, async (val) => {
|
|
|
if (Object.keys(val).length === 0) return;
|
|
|
-
|
|
|
- ids.value = val.id;
|
|
|
- fetchTariffData(val.trafficId);
|
|
|
- fetchOrderCardData(val.id);
|
|
|
+ tariffForm.value = val;
|
|
|
+ await fetchOrderCardData(val.id);
|
|
|
}, { immediate: true });
|
|
|
|
|
|
+
|
|
|
// 下载示例文件
|
|
|
const DownloadSampleFile = () => downloadFile(['ICCID'], [['8968099000011939']]);
|
|
|
|
|
|
-// 获取和处理订单资费数据
|
|
|
-const fetchTariffData = async (trafficId) => {
|
|
|
- const res = await AcquireOrdertariff({ id: trafficId });
|
|
|
- tariffForm.value = res.data;
|
|
|
- tariffForm.value.billingcycleName = res1.value.find(item => item.value === res.data.billingCycle)?.label;
|
|
|
- tariffForm.value.billingMethodName = res2.value.find(item => item.value === res.data.billingMethod)?.label;
|
|
|
- tariffForm.value.TariffInfomr = `${res.data.trafficBilling}/${res.data.trafficBillingType}`;
|
|
|
- tariffForm.value.pricingName = res.data.pricing ? `${res.data.pricing}/${res3.value.find(item => item.value === res.data.currency)?.label}` : '';
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
// 获取和处理订单卡信息
|
|
|
const fetchOrderCardData = async (orderId) => {
|
|
|
const res = await ReturntheOrderCard({ id: orderId });
|
|
|
dataDetail.value = res.data?.map(item => ({
|
|
|
- ...item, status: item.status === 1 ? t('order.normal') : t('order.unsubscribe')
|
|
|
+ ...item,
|
|
|
+ status: item.status === 1 ? t('order.normal') : t('order.unsubscribe')
|
|
|
})) || [];
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
-// 处理导卡进度响应
|
|
|
-const handleProgressResponse = (progressRes) => {
|
|
|
- if (progressRes.code === 200) {
|
|
|
- show.value = progressRes.data !== 0 && progressRes.data !== 100;
|
|
|
- schedule.value = progressRes.data;
|
|
|
- if (progressRes.data === 100) {
|
|
|
- clearInterval(timer);
|
|
|
- getICCIDDetaile();
|
|
|
- } else if(progressRes.data==0){
|
|
|
- clearInterval(timer);
|
|
|
- }else{
|
|
|
- startProgressMonitor(progressRes.data);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
-// 启动定时器监控导卡进度
|
|
|
-function startProgressMonitor(initialProgress) {
|
|
|
- if (timer) clearInterval(timer);
|
|
|
-
|
|
|
- timer = setInterval(async () => {
|
|
|
- const progressRes = await GuideCardProgress({ id: FormDataList.value.id });
|
|
|
- if (progressRes.code === 200) {
|
|
|
- show.value = progressRes.data !== 0 && progressRes.data !== 100;
|
|
|
- if (progressRes.data === 100) {
|
|
|
- clearInterval(timer);
|
|
|
- getICCIDDetaile();
|
|
|
- }
|
|
|
- schedule.value = progressRes.data;
|
|
|
- }
|
|
|
- }, 5000); // 每10秒检查一次
|
|
|
-}
|
|
|
|
|
|
// 获取 ICCID 详情
|
|
|
-const getICCIDDetaile = () => {
|
|
|
- ReturntheOrderCard({ id: ids.value }).then(res => {
|
|
|
- dataDetail.value = res.data?.map(item => ({
|
|
|
- ...item, status: item.status === 1 ? t('order.normal') : t('order.unsubscribe')
|
|
|
- })) || [];
|
|
|
- });
|
|
|
-}
|
|
|
+const getICCIDDetaile = async () => {
|
|
|
+ const res = await ReturntheOrderCard({ id: tariffForm.value.id });
|
|
|
+ dataDetail.value = res.data?.map(item => ({
|
|
|
+ ...item,
|
|
|
+ status: item.status === 1 ? t('order.normal') : t('order.unsubscribe')
|
|
|
+ })) || [];
|
|
|
+};
|
|
|
+
|
|
|
|
|
|
// 监听导卡进度
|
|
|
-watch(() => modelValue.value, (val) => {
|
|
|
+watch(() => modelValue.value, async (val) => {
|
|
|
if (val) {
|
|
|
- CardProgress();
|
|
|
- } else {
|
|
|
- clearInterval(timer);
|
|
|
+ await CardProgress();
|
|
|
}
|
|
|
}, { immediate: true });
|
|
|
|
|
|
+
|
|
|
// 卡进度检查
|
|
|
const CardProgress = async () => {
|
|
|
const res = await GuideCardProgress({ id: FormDataList.value.id });
|
|
|
- handleProgressResponse(res);
|
|
|
-}
|
|
|
+ if (res.code === 200) {
|
|
|
+ show.value = res.data !== 0 && res.data != '\r总体进度:10/10 (100.00%)';
|
|
|
+ schedule.value = res.data;
|
|
|
+ if (res.data == '\r总体进度:10/10 (100.00%)') {
|
|
|
+ getICCIDDetaile();
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
+
|
|
|
+// 组件挂载时获取字典数据
|
|
|
onMounted(async () => {
|
|
|
- res1.value = await Getdictionary('Billingcycle');
|
|
|
- res2.value = await Getdictionary('billingMethod');
|
|
|
- res3.value = await Getdictionary('currencyType');
|
|
|
+ const dict = await Getdictionary(['Billingcycle', 'billingMethod', 'currencyType']);
|
|
|
+ res1.value = dict[0];
|
|
|
+ res2.value = dict[1];
|
|
|
+ res3.value = dict[2];
|
|
|
});
|
|
|
|
|
|
</script>
|
|
@@ -256,7 +221,8 @@ onMounted(async () => {
|
|
|
margin: 30px auto;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
- .title{
|
|
|
+
|
|
|
+ .title {
|
|
|
text-align: center;
|
|
|
font-size: 16px;
|
|
|
}
|