trafficUseDialog.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <a-modal width="80%" :visible="visible" :title="$t('lotCard.CardDetails') + Card_info.iccid" :hide-cancel='true'
  3. :okText="$t('form.Confirm')" :cancelText="$t('form.Cancel')" @ok="handleSubmit" @cancel="visible = false" 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="资费名称">
  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="流量包过期日期">
  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. </a-table>
  123. </a-tab-pane>
  124. <a-tab-pane key="3" :title="$t('lotCard.EarlyWarningInformation')">
  125. Content of Tab Panel 3
  126. </a-tab-pane>
  127. <a-tab-pane key="4" :title="$t('lotCard.RechargeRecord')">
  128. <a-table :columns="columnsTopup" :data="dataTopup" :scroll="{ x: 'auto' }" :pagination="pagination"
  129. @page-change="evChangePageCardPuy">
  130. <template #puyStatus="{ record }">
  131. <a-tag :color="record.payStatus == 'SUCCESS' ? '#00b42a' : ''">{{ record.puyStatus }}</a-tag>
  132. </template>
  133. </a-table>
  134. </a-tab-pane>
  135. <a-tab-pane key="5" :title="$t('lotCard.UsageAmount')">
  136. <a-table :columns="columnsAmount" :data="dataAmount" :scroll="{ x: 'auto' }"
  137. @page-change="handelChangePageAounmt" :pagination="pageDataAounmt" />
  138. </a-tab-pane>
  139. <a-tab-pane key="6" :title="$t('lotCard.OperationRecord')">
  140. <a-table :columns="columnsOperation" :data="dataOperation" :scroll="{ x: 'auto' }"
  141. @page-change="evChangePage" :pagination="pageData" />
  142. </a-tab-pane>
  143. </a-tabs>
  144. </a-col>
  145. </a-row>
  146. <template #footer>
  147. <div class="footer_button">
  148. <!-- <a-button type="primary" status="warning">同步卡信息 V</a-button> -->
  149. <a-button type="primary" status="warning" @click="SIMCardService(0)">{{ $t('lotCard.SuspensionService')
  150. }}</a-button>
  151. <a-button type="primary" status="warning" @click="SIMCardService(1)">{{ $t('lotCard.RestoreService')
  152. }}</a-button>
  153. <!-- <a-button type="primary" status="warning" @click="SIMCardService(2)">{{ $t('lotCard.CloseCard') }}</a-button> -->
  154. </div>
  155. </template>
  156. </a-modal>
  157. </template>
  158. <script setup>
  159. import { onMounted, ref, h, toRefs } from "vue";
  160. import { getDataCDR, PauseSIMService, RecoverSIMService, OperationRecord, OffSIMCard, getOrderCard, getFlowData } from '@/api/path/lotCard.api'
  161. import { Getdictionary, filterDict } from '@/mixins/index'
  162. import { Message, Modal } from '@arco-design/web-vue'
  163. // 图表插件
  164. import * as echarts from "echarts";
  165. import { useI18n } from 'vue-i18n'
  166. import { columnsCard, columnsTopup, columnsAmount, columnsOperation } from './config'
  167. const { t } = useI18n();
  168. const userType = ref(JSON.parse(localStorage.getItem('user_login_information'))?.userType) // 1平台 2用户
  169. const emit = defineEmits(['submit']);
  170. const state = ref({
  171. visible: false,
  172. Card_info: {},
  173. dataPackage: null,
  174. dataSource: [],
  175. pageData: {
  176. total: 0,
  177. size: 10,
  178. current: 1,
  179. },
  180. pageDataAounmt: {
  181. total: 0,
  182. size: 10,
  183. current: 1,
  184. source: '',
  185. iccid: ''
  186. },
  187. pagination: {
  188. total: 0,
  189. size: 10,
  190. current: 1,
  191. },
  192. option: {
  193. xAxis: {
  194. type: 'category',
  195. 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')]
  196. },
  197. yAxis: {
  198. type: 'value'
  199. },
  200. series: [
  201. {
  202. data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  203. type: 'bar',
  204. }
  205. ],
  206. tooltip: {
  207. // 触发类型,默认数据触发,可选为:'item' | 'axis'
  208. trigger: 'axis',
  209. // 坐标轴触发,支持的坐标轴有:'x' | 'y' | 'radius' | 'angle'
  210. axisPointer: {
  211. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  212. },
  213. // 自定义的 formatter 函数
  214. formatter: function (params) {
  215. var res = params[0].name + '使用量' + params[0].value.toFixed(2) + 'KB';
  216. return res
  217. }
  218. },
  219. },
  220. dataCard: [],
  221. dataTopup: [],
  222. dataAmount: [],
  223. dataOperation: []
  224. })
  225. const {visible,Card_info,dataPackage,dataSource,pageData,pageDataAounmt,pagination,option,dataCard,dataTopup,dataAmount,dataOperation} = toRefs(state.value)
  226. const open = async (data) => {
  227. if (!data) {
  228. return
  229. }
  230. dataSource.value = []
  231. Card_info.value = data
  232. dataPackage.value = data.dataPackage[0]
  233. // 卡套餐信息
  234. dataCard.value = (data.dataPackage || []).map(val => {
  235. return {
  236. ...val,
  237. dataTotal: val.dataTotal == -1 ? t('lotCard.UnlimitedFlow') : val.dataTotal,
  238. tariffName: val.tariffName,
  239. dataUsage: val.dataUsage + '/MB',
  240. dataTotal: val.dataTotal + '/MB',
  241. dataToday: val.dataToday + '/MB',
  242. }
  243. })
  244. pageDataAounmt.value.iccid = data.iccid
  245. pageDataAounmt.value.source = data.source
  246. await getAountData()
  247. await optionsRecordSetting()
  248. intData()
  249. ICCIDPuyData(data.iccid)
  250. visible.value = true
  251. }
  252. const getAountData = async () => {
  253. let res = await getFlowData(pageDataAounmt.value)
  254. if (res.code == 200) {
  255. dataAmount.value = res.data.records || []
  256. }
  257. pageDataAounmt.value.total = res.data.total
  258. }
  259. const handelChangePageAounmt = (e) => {
  260. pageDataAounmt.value.current = e
  261. getAountData()
  262. }
  263. const ICCIDPuyData = async (id) => {
  264. let res = await getOrderCard({ iccid: id, ...pagination.value })
  265. let res1 = await Getdictionary('puyType')
  266. dataTopup.value = (res.data.records || []).map(val => {
  267. return {
  268. ...val,
  269. puyStatus: filterDict(res1, val.payStatus),
  270. payAmount: val.payAmount + val.currency
  271. }
  272. })
  273. pagination.value.total = res.data.total
  274. }
  275. const evChangePageCardPuy = (e) => {
  276. console.log(e);
  277. pagination.value.current = e
  278. ICCIDPuyData(Card_info.value.iccid)
  279. }
  280. // 月用量
  281. const intData = async () => {
  282. // 获取当前年份
  283. const currentYear = new Date().getFullYear();
  284. // 获取今年的第一天(2025-01-01)
  285. const startDate = `${currentYear}-01-01`;
  286. // 获取今年的最后一天(2025-12-31)
  287. const endDateTime = `${currentYear}-12-31`;
  288. // 调用你的 getDataCDR 方法
  289. let res = await getDataCDR({
  290. iccid: Card_info.value.iccid,
  291. source: Card_info.value.source,
  292. startDate: startDate, // 今年的第一天
  293. endDate: endDateTime // 今天的日期
  294. });
  295. option.value.series[0].data = res.data.yAxis
  296. initChart()
  297. }
  298. // SIM卡操作
  299. const SIMCardService = async (index) => {
  300. if (index !== 2) {
  301. const Inform = {
  302. iccid: Card_info.value.iccid, source: Card_info.value.source
  303. }
  304. // 暂停SIM卡
  305. let res = index == 0 ? await PauseSIMService(Inform) : (index == 1 ? await RecoverSIMService(Inform) : '')
  306. if (res.code === 200) {
  307. Message.success({
  308. content: res.message,
  309. duration: 2000,
  310. })
  311. handleSubmit()
  312. }
  313. } else {
  314. Modal.info({
  315. title: '关闭卡',
  316. cancelText: '关闭',
  317. content: () => {
  318. return h('div', { style: 'color:red;text-align: center;font-size:18px' }, '当前操作不可逆,请确定是否关闭当前卡!!')
  319. },
  320. onOk: async () => {
  321. // let res = await OffSIMCard()
  322. }
  323. });
  324. }
  325. }
  326. const handleSubmit = () => {
  327. emit('submit', true);
  328. visible.value = false
  329. };
  330. // 图表
  331. const initChart = () => {
  332. const dom = echarts.init(document.getElementById("chartContainer"));
  333. dom.setOption(option.value);
  334. window.addEventListener("resize", () => {
  335. dom.resize();
  336. })
  337. }
  338. const evChangePage = (e) => {
  339. pageData.value.current = e
  340. optionsRecordSetting()
  341. }
  342. // 操作日志
  343. const optionsRecordSetting = async () => {
  344. let res = await OperationRecord({
  345. current: pageData.value.current,
  346. size: pageData.value.size,
  347. iccid: Card_info.value.iccid
  348. })
  349. let res1 = await Getdictionary('source')
  350. dataOperation.value = res.data.records.map(res => {
  351. return {
  352. ...res,
  353. source: res1.filter(item => item.value == res.source)[0]?.label
  354. }
  355. })
  356. }
  357. defineExpose({ open })
  358. </script>
  359. <style scoped lang="less">
  360. .toal_Form {
  361. padding-bottom: 10px;
  362. border-bottom: 1px solid #ccc;
  363. }
  364. p {
  365. font-size: 20px;
  366. color: black;
  367. }
  368. .line {
  369. margin: 15px 0;
  370. border-bottom: 1px solid #ccc;
  371. width: 100%;
  372. }
  373. .footer_button {
  374. display: flex;
  375. justify-content: start;
  376. button {
  377. margin-right: 15px;
  378. }
  379. }
  380. .chart {
  381. height: 310px;
  382. width: 100%;
  383. }
  384. </style>