trafficUseDialog.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <a-modal width="70%" :visible="visible" :title="$t('lotCard.CardDetails') + Card_info.iccid" :hide-cancel='true'
  3. :okText="$t('form.Confirm')" :cancelText="$t('form.Cancel')" @ok="handleSubmit" @cancel="handleCancel" draggable>
  4. <!-- 卡片信息 -->
  5. <a-row class="grid-demo" :gutter="24">
  6. <a-col :span="12">
  7. <a-form :model="Card_info" auto-label-width label-align="left" class="toal_Form">
  8. <a-row :gutter="10">
  9. <a-col :span="12">
  10. <a-form-item label="ICCID">
  11. {{ Card_info.iccid }}
  12. </a-form-item>
  13. </a-col>
  14. <a-col :span="12">
  15. <a-form-item label="IMSI">
  16. {{ Card_info.currentImsi }}
  17. </a-form-item>
  18. </a-col>
  19. <!-- <a-col :span="12">
  20. <a-form-item :label="$t('lotCard.currencyBalance')">
  21. {{ Card_info.moneyBalances }}
  22. </a-form-item>
  23. </a-col> -->
  24. <a-col :span="12">
  25. <a-form-item :label="$t('lotCard.ActivationDate')">
  26. {{ Card_info.activeTime }}
  27. </a-form-item>
  28. </a-col>
  29. <a-col :span="12">
  30. <a-form-item :label="$t('lotCard.DueDate')">
  31. {{ Card_info.expireTime }}
  32. </a-form-item>
  33. </a-col>
  34. <a-col :span="12">
  35. <a-form-item :label="$t('lotCard.validity')">
  36. {{ Card_info.expireDay }}
  37. </a-form-item>
  38. </a-col>
  39. <a-col :span="12">
  40. <a-form-item :label="$t('lotCard.supplier')">
  41. {{ Card_info.source }}
  42. </a-form-item>
  43. </a-col>
  44. <!-- <a-col :span="12">
  45. <a-form-item :label="$t('lotCard.UsedpackFlow')">
  46. {{ Card_info.source }}
  47. </a-form-item>
  48. </a-col>
  49. <a-col :span="12">
  50. <a-form-item :label="$t('lotCard.FuelPackFlowAvailable')">
  51. {{ Card_info.source }}
  52. </a-form-item>
  53. </a-col> -->
  54. </a-row>
  55. </a-form>
  56. <p>{{ $t('lotCard.CurrentPackageInformation') }}</p>
  57. <a-form :model="dataPackage" auto-label-width label-align="left">
  58. <a-row :gutter="10" wrap>
  59. <a-col :span="12">
  60. <a-form-item :label="$t('lotCard.PackageName')">
  61. {{ Card_info?.tariffName }}
  62. </a-form-item>
  63. </a-col>
  64. <a-col :span="12">
  65. <a-form-item :label="$t('lotCard.PackageStatus')">
  66. {{
  67. dataPackage?.status
  68. }}
  69. </a-form-item>
  70. </a-col>
  71. <!-- <a-col :span="12">
  72. <a-form-item :label="$t('lotCard.validity')">
  73. {{ dataPackage?.validDays }} {{ $t('lotCard.month') }}
  74. </a-form-item>
  75. </a-col> -->
  76. <a-col :span="12">
  77. <a-form-item :label="$t('lotCard.WhetherToGive')">
  78. {{ dataPackage?.present == 0 ? $t('lotCard.No') : $t('lotCard.Yes') }}
  79. </a-form-item>
  80. </a-col>
  81. <a-col :span="12">
  82. <a-form-item :label="$t('lotCard.PackageActivationDate')">
  83. {{ dataPackage?.activeTime }}
  84. </a-form-item>
  85. </a-col>
  86. <a-col :span="12">
  87. <a-form-item :label="$t('lotCard.PackageExpirationDate')">
  88. {{ dataPackage?.expiryTime }}
  89. </a-form-item>
  90. </a-col>
  91. <!-- <a-col :span="12">
  92. <a-form-item :label="$t('lotCard.PackageValidDays')">
  93. {{ dataPackage?.validDays }}
  94. </a-form-item>
  95. </a-col> -->
  96. <!-- <div class="line"></div>
  97. <a-col :span="12">
  98. <a-form-item :label="$t('lotCard.PlaAvailableData')">
  99. {{ dataPackage?.dataTotal == -1 ? $t('lotCard.UnlimitedFlow') : dataPackage?.dataTotal }}MB
  100. </a-form-item>
  101. </a-col>
  102. <a-col :span="12">
  103. <a-form-item :label="$t('lotCard.PlanUsedData')">
  104. {{ dataPackage?.dataUsage }}MB
  105. </a-form-item>
  106. </a-col>
  107. <a-col :span="12">
  108. <a-form-item :label="$t('lotCard.PackageUseTrafficToday')">
  109. {{ dataPackage?.dataToday }}MB
  110. </a-form-item>
  111. </a-col> -->
  112. </a-row>
  113. </a-form>
  114. </a-col>
  115. <a-col :span="12">
  116. <a-tabs>
  117. <a-tab-pane key="1" :title="$t('lotCard.MonthlyConsumption')">
  118. <div class="chart" style="width:100%" id="chartContainer" />
  119. </a-tab-pane>
  120. <a-tab-pane key="2" :title="$t('lotCard.CardPackageInformation')">
  121. <a-table :columns="columnsCard" :data="dataCard" :scroll="{ x: 'auto' }" :pagination="false">
  122. <template #name="{ record }">
  123. <span>{{ userType == 1 ? record.productName : record.tariffName }}</span>
  124. </template>
  125. </a-table>
  126. </a-tab-pane>
  127. <a-tab-pane key="3" :title="$t('lotCard.EarlyWarningInformation')">
  128. Content of Tab Panel 3
  129. </a-tab-pane>
  130. <a-tab-pane key="4" :title="$t('lotCard.RechargeRecord')">
  131. <a-table :columns="columnsTopup" :data="dataTopup" :scroll="{ x: 'auto' }" :pagination="pagination"
  132. @page-change="evChangePageCardPuy">
  133. <template #puyStatus="{ record }">
  134. <a-tag :color="record.payStatus == 'SUCCESS' ? '#00b42a' : ''">{{ record.puyStatus }}</a-tag>
  135. </template>
  136. </a-table>
  137. </a-tab-pane>
  138. <a-tab-pane key="5" :title="$t('lotCard.UsageAmount')">
  139. <a-table :columns="columnsAmount" :data="dataAmount" :scroll="{ x: 'auto' }" :pagination="pageDataAounmt"
  140. @page-change="evChangePageAounmt" />
  141. </a-tab-pane>
  142. <a-tab-pane key="6" :title="$t('lotCard.OperationRecord')">
  143. <a-table :columns="columnsOperation" :data="dataOperation" :scroll="{ x: 'auto' }"
  144. @page-change="evChangePage" :pagination="pageData" />
  145. </a-tab-pane>
  146. </a-tabs>
  147. </a-col>
  148. </a-row>
  149. <template #footer>
  150. <div class="footer_button">
  151. <!-- <a-button type="primary" status="warning">同步卡信息 V</a-button> -->
  152. <a-button type="primary" status="warning" @click="SIMCardService(0)">{{ $t('lotCard.SuspensionService')
  153. }}</a-button>
  154. <a-button type="primary" status="warning" @click="SIMCardService(1)">{{ $t('lotCard.RestoreService')
  155. }}</a-button>
  156. <!-- <a-button type="primary" status="warning" @click="SIMCardService(2)">{{ $t('lotCard.CloseCard') }}</a-button> -->
  157. </div>
  158. </template>
  159. </a-modal>
  160. </template>
  161. <script setup>
  162. import { onMounted, ref, h } from "vue";
  163. import { getDataCDR, PauseSIMService, RecoverSIMService, OperationRecord, OffSIMCard, getOrderCard, getFlowData } from '@/api/path/lotCard.api'
  164. import { Getdictionary } from '@/mixins/index'
  165. import { Message, Modal } from '@arco-design/web-vue'
  166. // 图表插件
  167. import * as echarts from "echarts";
  168. import { useI18n } from 'vue-i18n'
  169. import { columnsCard, columnsTopup, columnsAmount, columnsOperation } from './config'
  170. const { t } = useI18n();
  171. const props = defineProps({});
  172. const userType = ref(JSON.parse(localStorage.getItem('user_login_information'))?.userType) // 1平台 2用户
  173. const emit = defineEmits(['submit']);
  174. const visible = ref(false)
  175. const Card_info = ref({})
  176. const dataPackage = ref()
  177. const dataSource = ref([]);
  178. const pageData = ref({
  179. total: 0,
  180. size: 10,
  181. current: 1,
  182. })
  183. const pageDataAounmt = ref({
  184. total: 0,
  185. size: 10,
  186. current: 1,
  187. source: '',
  188. iccid: ''
  189. })
  190. const pagination = ref({
  191. total: 0,
  192. size: 10,
  193. current: 1,
  194. })
  195. // 图表插件
  196. const option = ref({
  197. xAxis: {
  198. type: 'category',
  199. data: [t('lotCard.Jan'), t('lotCard.February'), t('lotCard.March'), t('lotCard.April'), t('lotCard.May'), t('lotCard.June'), t('lotCard.July'), t('lotCard.August'), t('lotCard.September'), t('lotCard.October'), t('lotCard.November'), t('lotCard.December')]
  200. },
  201. yAxis: {
  202. type: 'value'
  203. },
  204. series: [
  205. {
  206. data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  207. type: 'bar',
  208. }
  209. ],
  210. tooltip: {
  211. // 触发类型,默认数据触发,可选为:'item' | 'axis'
  212. trigger: 'axis',
  213. // 坐标轴触发,支持的坐标轴有:'x' | 'y' | 'radius' | 'angle'
  214. axisPointer: {
  215. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  216. },
  217. // 自定义的 formatter 函数
  218. formatter: function (params) {
  219. var res = params[0].name + '使用量' + params[0].value.toFixed(2) + 'KB';
  220. return res
  221. }
  222. },
  223. })
  224. // 卡套餐信息
  225. const dataCard = ref([])
  226. // 充值信息
  227. const dataTopup = ref([])
  228. // 使用量
  229. const dataAmount = ref([])
  230. // 操作记录
  231. const dataOperation = ref([])
  232. const open = (data) => {
  233. if (!data) {
  234. return
  235. }
  236. dataSource.value = []
  237. Card_info.value = data
  238. dataPackage.value = data.dataPackage[0]
  239. // 卡套餐信息
  240. dataCard.value = (data.dataPackage || []).map(val => {
  241. const tatal = val.dataTotal == -1 ? t('lotCard.UnlimitedFlow') : val.dataTotal
  242. return {
  243. ...val,
  244. dataTotal: tatal,
  245. tariffName: data.tariffName,
  246. dataUsage: val.dataUsage + '/MB',
  247. dataTotal: val.dataTotal + '/MB',
  248. dataToday: val.dataToday + '/MB',
  249. }
  250. })
  251. pageDataAounmt.value.iccid = data.iccid
  252. pageDataAounmt.value.source = data.source
  253. getAountData(pageDataAounmt.value)
  254. optionsRecordSetting()
  255. intData()
  256. visible.value = true
  257. ICCIDPuyData(data.iccid)
  258. }
  259. const getAountData = async (type) => {
  260. let res = await getFlowData(type)
  261. if (res.code == 200) {
  262. dataAmount.value = res.data.records || []
  263. }
  264. pageDataAounmt.value.total = res.total
  265. }
  266. const evChangePageAounmt = (e) => {
  267. pageDataAounmt.value.current = e
  268. getAountData(pageDataAounmt.value)
  269. }
  270. const ICCIDPuyData = async (id) => {
  271. let res = await getOrderCard({ iccid: id, ...pagination.value })
  272. let res1 = await Getdictionary('puyType')
  273. dataTopup.value = (res.data.records || []).map(val => {
  274. const payType = res1.filter(item => item.value == val.payStatus)[0]?.label
  275. return {
  276. ...val,
  277. puyStatus: payType,
  278. payAmount: val.payAmount + '/' + val.currency
  279. }
  280. })
  281. pagination.value.total = res.data.total
  282. }
  283. const evChangePageCardPuy = (e) => {
  284. pagination.value.current = e
  285. ICCIDPuyData(Card_info.value.iccid)
  286. }
  287. // 使用量
  288. const intData = async () => {
  289. // 获取当前年份
  290. const currentYear = new Date().getFullYear();
  291. // 获取今年的第一天(2025-01-01)
  292. const startDate = `${currentYear}-01-01`;
  293. // 获取今年的最后一天(2025-12-31)
  294. const endDateTime = `${currentYear}-12-31`;
  295. // 调用你的 getDataCDR 方法
  296. let res = await getDataCDR({
  297. iccid: Card_info.value.iccid,
  298. source: Card_info.value.source,
  299. startDate: startDate, // 今年的第一天
  300. endDate: endDateTime // 今天的日期
  301. });
  302. option.value.series[0].data = res.data.yAxis
  303. initChart()
  304. }
  305. // SIM卡操作
  306. const SIMCardService = async (index) => {
  307. if (index !== 2) {
  308. const Inform = {
  309. iccid: Card_info.value.iccid, source: Card_info.value.source
  310. }
  311. // 暂停SIM卡
  312. let res = index == 0 ? await PauseSIMService(Inform) : (index == 1 ? await RecoverSIMService(Inform) : '')
  313. if (res.code === 200) {
  314. Message.success({
  315. content: res.message,
  316. duration: 2000,
  317. })
  318. handleSubmit()
  319. }
  320. } else {
  321. Modal.info({
  322. title: '关闭卡',
  323. cancelText: '关闭',
  324. content: () => {
  325. return h('div', { style: 'color:red;text-align: center;font-size:18px' }, '当前操作不可逆,请确定是否关闭当前卡!!')
  326. },
  327. onOk: async () => {
  328. // let res = await OffSIMCard()
  329. }
  330. });
  331. }
  332. }
  333. const handleSubmit = () => {
  334. emit('submit', true);
  335. visible.value = false
  336. };
  337. const handleCancel = () => {
  338. visible.value = false
  339. };
  340. // 图表
  341. const initChart = () => {
  342. const dom = echarts.init(document.getElementById("chartContainer"));
  343. dom.setOption(option.value);
  344. window.addEventListener("resize", () => {
  345. dom.resize();
  346. })
  347. }
  348. const evChangePage = (e) => {
  349. pageData.value.current = e
  350. optionsRecordSetting()
  351. }
  352. // 操作日志
  353. const optionsRecordSetting = async () => {
  354. let res = await OperationRecord({
  355. current: pageData.value.current,
  356. size: pageData.value.size,
  357. iccid: Card_info.value.iccid
  358. })
  359. let res1 = await Getdictionary('source')
  360. dataOperation.value = res.data.records.map(res => {
  361. return {
  362. ...res,
  363. source: res1.data.filter(item => item.value == res.source)[0]?.label
  364. }
  365. })
  366. }
  367. defineExpose({ open })
  368. </script>
  369. <style scoped lang="less">
  370. .toal_Form {
  371. padding-bottom: 10px;
  372. border-bottom: 1px solid #ccc;
  373. }
  374. p {
  375. font-size: 20px;
  376. color: black;
  377. }
  378. .line {
  379. margin: 15px 0;
  380. border-bottom: 1px solid #ccc;
  381. width: 100%;
  382. }
  383. .footer_button {
  384. display: flex;
  385. justify-content: start;
  386. button {
  387. margin-right: 15px;
  388. }
  389. }
  390. .chart {
  391. height: 310px;
  392. width: 100%;
  393. }
  394. </style>