detaile.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <a-modal v-model:visible="modelValue" width="800px" :title="$t('order.OrderDetails')" :closable="false">
  3. <div class="detail-box">
  4. <div class="detail-item-box">
  5. <div class="detail-item">
  6. <div class="item-label">{{ $t('order.OrderNum') }}</div>
  7. <div class="item-content">{{ FormDataList.id }}</div>
  8. </div>
  9. <div class="detail-item">
  10. <div class="item-label">{{ $t('lotCard.orderType') }}</div>
  11. <div class="item-content">
  12. <a-tag color="#168cff" v-if="FormDataList.tmsStatus == 1">{{ $t('order.unshipped') }}</a-tag>
  13. <a-tag color="#00b42a" v-if="FormDataList.tmsStatus == 2">{{ $t('order.shipped') }}</a-tag>
  14. </div>
  15. </div>
  16. </div>
  17. <div class="detail-item-box">
  18. <div class="detail-item">
  19. <div class="item-label">{{ $t('lotCard.operator') }}</div>
  20. <div class="item-content">{{ FormDataList.sourceName }}</div>
  21. </div>
  22. <div class="detail-item">
  23. <div class="item-label">{{ $t('order.TariffName') }}</div>
  24. <div class="item-content">{{ tariffForm.label }}</div>
  25. </div>
  26. </div>
  27. <div class="detail-item-box">
  28. <div class="detail-item">
  29. <div class="item-label">{{ $t('order.BillingMode') }}</div>
  30. <div class="item-content">{{ tariffForm.billingMethodName }}</div>
  31. </div>
  32. <div class="detail-item">
  33. <div class="item-label">{{ $t('order.SettlementCycle') }}</div>
  34. <div class="item-content">{{ tariffForm.billingcycleName }}</div>
  35. </div>
  36. </div>
  37. <div class="detail-item-box">
  38. <div class="detail-item">
  39. <div class="item-label">{{ $t('order.CardType') }}</div>
  40. <div class="item-content">{{ FormDataList.cardType }}</div>
  41. </div>
  42. <div class="detail-item">
  43. <div class="item-label">{{ $t('order.FlowPool') }}</div>
  44. <div class="item-content">{{ FormDataList.isTrafficPool == 1 ? $t('lotCard.Yes') : $t('lotCard.No')
  45. }}</div>
  46. </div>
  47. </div>
  48. <div class="detail-item-box">
  49. <div class="detail-item">
  50. <div class="item-label">{{ $t('order.CardNum') }}</div>
  51. <div class="item-content">{{ dataDetail.length<=10?dataDetail.length:tableDataList.length }}
  52. <a-button type="primary" @click="showCard = true" style="margin-left:10px;"
  53. v-if="userType == 1 && FormDataList.moderationStatus == 2">{{
  54. $t('order.AllocationCardNumber') }}</a-button>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="detail-table">
  60. <a-table :columns="columnsDetail" @page-change="evChangePage" :data="dataDetail"
  61. :pagination="dataDetail.length == 10 ? pagination : false" />
  62. </div>
  63. <template #footer>
  64. <a-button @click="cancel">{{ $t('form.Cancel') }}</a-button>
  65. </template>
  66. </a-modal>
  67. <!-- 分配卡号 -->
  68. <a-modal v-model:visible="showCard" :title="$t('order.AllocationCardNumber')"
  69. @cancel="closeModal(showCard, FormDataList)" @before-ok="showCard = false" :okText="$t('form.Confirm')"
  70. :cancelText="$t('form.Cancel')">
  71. <div style="display: flex;justify-content: space-between;">
  72. <div>
  73. <Upload listType="" minx="1" accept=".xlsx" :handelUpload="customRequest" :showRemoveButton="false">
  74. </Upload>
  75. <span style="color: #ccc;margin-top: 10px;display: inline-block;">请上传.xlsx文件</span>
  76. </div>
  77. <div>
  78. <a-button type="primary" @click="DownloadSampleFile">下载示例文件</a-button>
  79. </div>
  80. </div>
  81. </a-modal>
  82. </template>
  83. <script setup>
  84. import { ref, onMounted, toRefs, toRef, watch } from 'vue';
  85. import { AcquireOrdertariff, DistributionCard, ReturntheOrderCard } from '@/api/path/order'
  86. import { Message } from '@arco-design/web-vue';
  87. import Upload from "@/components/upload/index.vue";
  88. import { Getdictionary } from '@/mixins/index.js'
  89. import { downloadFile } from '@/utils/xlsx.js'
  90. import { useI18n } from 'vue-i18n'
  91. const { t } = useI18n();
  92. const props = defineProps({
  93. modelValue: {
  94. type: Boolean,
  95. default: false
  96. },
  97. FormDataList: {
  98. type: Object,
  99. default: () => ({})
  100. }
  101. })
  102. const modelValue = toRef(props, 'modelValue')
  103. const FormDataList = toRef(props, 'FormDataList')
  104. const emit = defineEmits(['update:modelValue', 'submit'])
  105. const state = ref({
  106. tariffForm: {},
  107. showCard: false,
  108. res1: [],
  109. res2: [],
  110. res3: [],
  111. userType: JSON.parse(localStorage.getItem('user_login_information'))?.userType, // 1平台 2用户
  112. })
  113. const { tariffForm, showCard, res1, res2, res3, userType } = toRefs(state.value)
  114. const columnsDetail = [{ title: 'ICCID', dataIndex: 'iccid' }, { title: t('order.CardStatus'), dataIndex: 'status' }, { title: t('order.CreationTime'), dataIndex: 'createdAt' }
  115. ]
  116. // 初始数据
  117. const tableDataList = ref([])
  118. // 处理后的数据
  119. const dataDetail = ref([])
  120. const pagination = ref({
  121. current: 1,
  122. pageSize: 10,
  123. total: 0
  124. })
  125. // 分配卡号
  126. const customRequest = (options) => {
  127. const formData = new FormData();
  128. formData.append('file', options.fileItem.file); // 这里将文件添加到 FormDataList 中
  129. formData.append('orderId', FormDataList.value.id);
  130. DistributionCard(formData).then(res => {
  131. if (res.code == 200) {
  132. Message.success(res.message)
  133. if (res.data[0].length <= 10) {
  134. res.data[0].forEach(val => {
  135. dataDetail.value.push({ iccid: val, status: val.status == 1 ? t('order.normal') : t('order.unsubscribe') })
  136. })
  137. } else {
  138. // 更新完整数据
  139. tableDataList.value = res.data[0];
  140. // 更新总条目数
  141. pagination.value.total = res.data[0].length;
  142. updatePageData();
  143. }
  144. }
  145. })
  146. }
  147. const cancel = () => {
  148. emit('update:modelValue', false)
  149. }
  150. const closeModal = () => {
  151. showCard.value = false
  152. }
  153. watch(() => FormDataList.value, val => {
  154. if (Object.keys(val).length === 0) return
  155. pagination.value.total = 0
  156. pagination.value.current = 1
  157. pagination.value.pageSize = 10
  158. AcquireOrdertariff({ id: val.trafficId }).then(res => {
  159. tariffForm.value = res.data
  160. tariffForm.value.billingcycleName = res1.value.filter(val => val.value == res.data.billingCycle)[0]?.label;
  161. tariffForm.value.billingMethodName = res2.value.filter(val => val.value == res.data.billingMethod)[0]?.label;
  162. tariffForm.value.TariffInfomr = res.data.trafficBilling + '/' + res.data.trafficBillingType
  163. tariffForm.value.pricingName = tariffForm.value.pricing !== '' ? tariffForm.value.pricing + '/' + res3.value.filter(val => val.value == res.data.currency)[0]?.label : '';
  164. })
  165. dataDetail.value = []
  166. ReturntheOrderCard({ id: val.id }).then(res => {
  167. console.log(res);
  168. if (res.data.length <= 10) {
  169. dataDetail.value.push(...res.data.map(val => ({ ...val, status: val.status == 1 ? t('order.normal') : t('order.unsubscribe') })))
  170. } else {
  171. // 更新完整数据
  172. tableDataList.value = res.data;
  173. // 更新总条目数
  174. pagination.value.total = res.data.length;
  175. updatePageData();
  176. }
  177. })
  178. }, { deep: true })
  179. const evChangePage = (page) => {
  180. pagination.value.current = page
  181. updatePageData();
  182. }
  183. // 更新分页数据方法
  184. const updatePageData = () => {
  185. const startIndex = (pagination.value.current - 1) * pagination.value.pageSize;
  186. const endIndex = startIndex + pagination.value.pageSize; // 每次切 10 条
  187. dataDetail.value = tableDataList.value.slice(startIndex, endIndex);
  188. };
  189. const DownloadSampleFile = () => {
  190. // 下载示例文件
  191. downloadFile(['ICCID'], [['8968099000011939']])
  192. }
  193. onMounted(async () => {
  194. res1.value = await Getdictionary('Billingcycle')
  195. res2.value = await Getdictionary('billingMethod')
  196. res3.value = await Getdictionary('currencyType')
  197. })
  198. </script>
  199. <style scoped lang="less">
  200. .detail-box {
  201. .detail-item-box {
  202. display: flex;
  203. justify-content: space-between;
  204. align-items: center;
  205. margin-bottom: 10px;
  206. .detail-item {
  207. //styleName: Body/Medium;
  208. font-family: PingFang SC;
  209. font-size: 14px;
  210. font-weight: 400;
  211. line-height: 22px;
  212. text-align: left;
  213. display: flex;
  214. align-items: center;
  215. min-width: 350px;
  216. .item-label {
  217. color: rgba(0, 0, 0, 0.4);
  218. width: 120px;
  219. text-align: right;
  220. margin-right: 10px;
  221. }
  222. .item-content {
  223. color: rgba(51, 51, 51, 1);
  224. }
  225. }
  226. }
  227. }
  228. </style>