index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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' }">
  29. <template #id="{ record }">
  30. <!-- 查看流量消耗 -->
  31. <!-- <a class="a-link" href="javascript:;" style="margin-right: 1rem" @click="handletrafficUseDialog(record)">{{
  32. $t('lotCard.trafficUse') }}</a> -->
  33. </template>
  34. </a-table>
  35. <!-- 查看流量消耗 -->
  36. <trafficUseDialog ref="trafficUseDialogRef" />
  37. </div>
  38. </template>
  39. <script setup>
  40. import { onMounted, ref, reactive, getCurrentInstance } from "vue";
  41. import { useRoute } from "vue-router";
  42. import { columns } from "./config";
  43. import { Message, Notification } from '@arco-design/web-vue'
  44. import { cardInfoList, cardInfoImport } from "@/api/path/lotCard.api"
  45. import trafficUseDialog from "./trafficUseDialog.vue";
  46. import { enum_dict } from "@/hooks/enum";
  47. const { proxy } = getCurrentInstance()
  48. const formRef = ref()
  49. const searchForm = ref({
  50. "iccid": "",
  51. });
  52. const statusList = ref([]);
  53. const sourceList = ref([]);
  54. const serviceList = ref([]);
  55. const dataSource = ref([]);
  56. const route = useRoute();
  57. const pagination = ref({
  58. total: 0,
  59. pageSize: 10,
  60. current: 1,
  61. })
  62. const rowSelection = reactive({
  63. type: 'checkbox',
  64. showCheckedAll: true,
  65. onlyCurrent: false,
  66. });
  67. const selectedKeys = ref([])
  68. const trafficUseDialogRef = ref()
  69. const intData = async () => {
  70. const param = {
  71. current: pagination.value.current,
  72. size: pagination.value.pageSize,
  73. ...searchForm.value,
  74. }
  75. const { data } = await cardInfoList(param)
  76. dataSource.value = (data.records || []).map(item => {
  77. const sourceName = sourceList.value.find(sourceItem => sourceItem.value == item.source)?.label || ''
  78. const serviceName = serviceList.value.find(serviceItem => serviceItem.value == item.service_usage_mode)?.label || ''
  79. const statusName = statusList.value.find(statusItem => statusItem.value == item.status)?.label || ''
  80. console.log(statusList, statusName, "statusList")
  81. return {
  82. ...item,
  83. sourceName,
  84. serviceName,
  85. statusName
  86. }
  87. })
  88. pagination.value.total = data.total
  89. }
  90. const handleImport = async () => {
  91. if (!searchForm.value.iccid) {
  92. Message.warning({
  93. content: '请先输入ICCID,可输入多个以逗号分隔,然后再点击导入!',
  94. duration: 2000,
  95. })
  96. return
  97. }
  98. const iccids = searchForm.value.iccid.split(',')
  99. const iccidList = iccids.map(item => {
  100. return {
  101. iccid: item
  102. }
  103. })
  104. const { code, data } = await cardInfoImport({ iccidList })
  105. if (code == 200) {
  106. Message.success({
  107. content: data,
  108. duration: 2000,
  109. })
  110. intData()
  111. }
  112. };
  113. const handletrafficUseDialog = (data) => {
  114. console.log(data.iccid, "data.iccid")
  115. trafficUseDialogRef.value.open(data.iccid)
  116. }
  117. const handleSearch = () => {
  118. formRef.value.validate((errors) => {
  119. if (!errors) {
  120. intData()
  121. }
  122. });
  123. }
  124. // 获取字典
  125. const handleDictValue = () => {
  126. const dictList = JSON.parse(window.localStorage.getItem('dictList')) ?? []
  127. sourceList.value = dictList.filter((item) => item.type_key == enum_dict.SOURCE)
  128. statusList.value = dictList.filter((item) => item.type_key == enum_dict.MAIN_CARD_STATUS)
  129. serviceList.value = dictList.filter((item) => item.type_key == enum_dict.ACTIVATION_PACKAGE)
  130. }
  131. const resetSearch = () => {
  132. proxy.$refs.formRef.resetFields()
  133. intData()
  134. }
  135. onMounted(() => {
  136. handleDictValue()
  137. intData()
  138. })
  139. </script>
  140. <style scoped lang="less">
  141. .head-title-right {
  142. .m-r-10 {
  143. margin-right: 10px;
  144. }
  145. }
  146. .search-section {
  147. margin-top: 20px;
  148. margin-bottom: 20px;
  149. }
  150. .container {
  151. .head-title {
  152. display: flex;
  153. justify-content: space-between;
  154. }
  155. .form-row {
  156. display: flex;
  157. .form-row-col {
  158. width: 25%;
  159. display: flex;
  160. align-items: center;
  161. .form-row-label {
  162. width: 120px;
  163. text-align: right;
  164. }
  165. }
  166. }
  167. }
  168. </style>