index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <!-- 卡清单管理 -->
  3. <div class="container">
  4. <div class="head-title">
  5. <span>{{ route.meta.title }} </span>
  6. <span class="head-title-right">
  7. <a-popconfirm :content="$t('form.ImportConfirm')" :ok-text="$t('form.Confirm')" :cancel-text="$t('form.Cancel')"
  8. @ok="handleImport()">
  9. <!-- <a-button class="m-r-10" type="primary"> {{ $t('form.Import') }}</a-button> -->
  10. </a-popconfirm>
  11. </span>
  12. </div>
  13. <!-- 搜索条件区 -->
  14. <div class="search-section">
  15. <a-form :model="searchForm" ref="formRef" layout="inline">
  16. <a-form-item field="iccid" :label="$t('lotCard.iccid')">
  17. <a-input v-model="searchForm.iccid" :placeholder="$t('lotCard.please') + $t('lotCard.iccid')" allow-clear />
  18. </a-form-item>
  19. <a-form-item>
  20. <a-space>
  21. <a-button type="primary" @click="handleSearch">{{ $t('form.Search') }}</a-button>
  22. <a-button @click="resetSearch">{{ $t('form.Reset') }}</a-button>
  23. </a-space>
  24. </a-form-item>
  25. </a-form>
  26. </div>
  27. <a-table row-key="iccid" :data="dataSource" :columns="columns" :pagination="pagination"
  28. :row-selection="rowSelection" v-model:selectedKeys="selectedKeys" :scroll="{ x: 'auto' }" :expandable="expandable"
  29. @page-change="evChangePage">
  30. <template #id="{ record }">
  31. <!-- 查看流量消耗 -->
  32. <a class="a-link" href="javascript:;" style="margin-right: 1rem" @click="handletrafficUseDialog(record)">{{
  33. $t('lotCard.trafficUse') }}</a>
  34. </template>
  35. </a-table>
  36. <!-- 查看流量消耗 -->
  37. <trafficUseDialog ref="trafficUseDialogRef" />
  38. </div>
  39. </template>
  40. <script setup>
  41. import { onMounted, ref, reactive, getCurrentInstance, h } from "vue";
  42. import { useRoute } from "vue-router";
  43. import { columns } from "./config";
  44. import { Message, Notification } from '@arco-design/web-vue'
  45. import { cardInfoList, cardInfoImport, orderList, orderFlowData } from "@/api/path/lotCard.api"
  46. import trafficUseDialog from "./trafficUseDialog.vue";
  47. import { enum_dict } from "@/hooks/enum";
  48. import list from "./list.vue";
  49. const { proxy } = getCurrentInstance()
  50. const formRef = ref()
  51. const searchForm = ref({
  52. "iccid": "",
  53. });
  54. const statusList = ref([]);
  55. const sourceList = ref([]);
  56. const serviceList = ref([]);
  57. const dataSource = ref([]);
  58. const route = useRoute();
  59. const pagination = ref({
  60. total: 0,
  61. pageSize: 10,
  62. current: 1,
  63. })
  64. const rowSelection = reactive({
  65. type: 'checkbox',
  66. showCheckedAll: true,
  67. onlyCurrent: false,
  68. });
  69. const selectedKeys = ref([])
  70. const trafficUseDialogRef = ref()
  71. const intData = async () => {
  72. const param = {
  73. current: pagination.value.current,
  74. size: pagination.value.pageSize,
  75. ...searchForm.value,
  76. }
  77. const { data } = await cardInfoList(param)
  78. dataSource.value = (data.records || []).map((item) => {
  79. // 卡下级信息
  80. let orderArr = []
  81. orderList({ current: 1, size: 999, ICCID: item.iccid }).then(res => {
  82. res.data.records?.forEach(async (orderItem, index) => {
  83. // const dictList = JSON.parse(window.localStorage.getItem('dictList')) ?? []
  84. // const orderType = dictList.filter((item) => item.type_key == enum_dict.SOURCE)
  85. const params = {
  86. iccid: orderItem.ICCID,
  87. childOrderId: orderItem.id,
  88. subscriptionKey: orderItem.subscription_key,
  89. }
  90. let trafficList = []
  91. // if (item.iccid == '89852342022040149139' && index < 5 || !(item.iccid == '89852342022040149139')) {
  92. // const { data } = await orderFlowData(params)
  93. // trafficList = data.historyData || []
  94. // orderArr.push({
  95. // ...orderItem,
  96. // trafficList
  97. // })
  98. // }
  99. orderArr.push({
  100. ...orderItem,
  101. })
  102. })
  103. })
  104. // 处理卡列表信息
  105. const sourceName = sourceList.value.find(sourceItem => sourceItem.value == item.source)?.label || ''
  106. const serviceName = serviceList.value.find(serviceItem => serviceItem.value == item.service_usage_mode)?.label || ''
  107. const statusName = statusList.value.find(statusItem => statusItem.value == item.status)?.label || ''
  108. return {
  109. ...item,
  110. sourceName,
  111. serviceName,
  112. statusName,
  113. orderArr
  114. }
  115. })
  116. pagination.value.total = data.total
  117. }
  118. // const { data: orderData } = await orderList({ current: 1, size: 999, ICCID: ICCID.value })
  119. // orderData.records?.forEach(async (orderItem) => {
  120. // const params = {
  121. // // iccid: orderItem.ICCID,
  122. // iccid: '89852342022040149139',
  123. // childOrderId: orderItem.id,
  124. // subscriptionKey: "1824754463183432097",
  125. // }
  126. // let trafficList = []
  127. // const { data } = await orderFlowData(params)
  128. // trafficList = data.historyData || []
  129. // dataSource.value.push({
  130. // ...orderItem,
  131. // trafficList
  132. // })
  133. // })
  134. const expandable = {
  135. expandedRowRender: (record) => {
  136. if (record.orderArr && Array.isArray(record.orderArr) && record.orderArr.length > 0) {
  137. return h('div', {}, [
  138. h(list, { 'data': record.orderArr })
  139. ]);
  140. }
  141. return h('div', {}, '暂无数据')
  142. },
  143. };
  144. const handleImport = async () => {
  145. if (!searchForm.value.iccid) {
  146. Message.warning({
  147. content: '请先输入ICCID,可输入多个以逗号分隔,然后再点击导入!',
  148. duration: 2000,
  149. })
  150. return
  151. }
  152. const iccids = searchForm.value.iccid.split(',')
  153. const iccidList = iccids.map(item => {
  154. return {
  155. iccid: item
  156. }
  157. })
  158. const { code, data } = await cardInfoImport({ iccidList })
  159. if (code == 200) {
  160. Message.success({
  161. content: data,
  162. duration: 2000,
  163. })
  164. intData()
  165. }
  166. };
  167. const handletrafficUseDialog = (data) => {
  168. console.log(data.iccid, "data.iccid")
  169. trafficUseDialogRef.value.open(data.iccid)
  170. }
  171. const evChangePage = (page) => {
  172. pagination.value.current = page
  173. intData()
  174. }
  175. const handleSearch = () => {
  176. formRef.value.validate((errors) => {
  177. if (!errors) {
  178. intData()
  179. }
  180. });
  181. }
  182. // 获取字典
  183. const handleDictValue = () => {
  184. const dictList = JSON.parse(window.localStorage.getItem('dictList')) ?? []
  185. sourceList.value = dictList.filter((item) => item.type_key == enum_dict.SOURCE)
  186. statusList.value = dictList.filter((item) => item.type_key == enum_dict.MAIN_CARD_STATUS)
  187. serviceList.value = dictList.filter((item) => item.type_key == enum_dict.ACTIVATION_PACKAGE)
  188. }
  189. const resetSearch = () => {
  190. proxy.$refs.formRef.resetFields()
  191. intData()
  192. }
  193. onMounted(() => {
  194. handleDictValue()
  195. intData()
  196. })
  197. </script>
  198. <style scoped lang="less">
  199. .head-title-right {
  200. .m-r-10 {
  201. margin-right: 10px;
  202. }
  203. }
  204. .search-section {
  205. margin-top: 20px;
  206. margin-bottom: 20px;
  207. }
  208. .container {
  209. .head-title {
  210. display: flex;
  211. justify-content: space-between;
  212. }
  213. .form-row {
  214. display: flex;
  215. .form-row-col {
  216. width: 25%;
  217. display: flex;
  218. align-items: center;
  219. .form-row-label {
  220. width: 120px;
  221. text-align: right;
  222. }
  223. }
  224. }
  225. }
  226. </style>