index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <!-- 流量包管理 -->
  2. <template>
  3. <div class="container">
  4. <div class="head-title">
  5. <span>{{ route.meta.title }} </span>
  6. </div>
  7. <!-- 搜索条件区 -->
  8. <div class="search-section">
  9. <a-form :model="searchForm" ref="formRef" layout="inline">
  10. <a-form-item field="status" :label="$t('dataPackage.price')">
  11. <a-input v-model="searchForm.price" :placeholder="$t('form.PleaseEnterThe') + $t('dataPackage.price')"
  12. allow-clear />
  13. </a-form-item>
  14. <a-form-item field="periodType" :label="$t('dataPackage.operatorType')">
  15. <a-input v-model="searchForm.periodType"
  16. :placeholder="$t('form.PleaseEnterThe') + $t('dataPackage.operatorType')" allow-clear />
  17. </a-form-item>
  18. <a-form-item>
  19. <a-space>
  20. <a-button type="primary" @click="handleSearch">{{ $t('form.Search') }}</a-button>
  21. <a-button @click="resetSearch">{{ $t('form.Reset') }}</a-button>
  22. </a-space>
  23. </a-form-item>
  24. </a-form>
  25. </div>
  26. <div class="audit-btn">
  27. <a-button @click="showNewDataPackageForm" type="text">
  28. <template #icon>
  29. <icon-plus-circle />
  30. </template>
  31. <template #default>{{ $t('form.Add') }}</template>
  32. </a-button>
  33. </div>
  34. <a-table :data="dataSource" :columns="columns" :pagination="pagination" :scroll="{ x: 'auto' }"
  35. @page-change="evChangePage">
  36. <template #id="{ record }">
  37. <a-button type="text" size="small" @click="handleEdit(record)">{{ $t('global.common.edit') }}</a-button>
  38. <a-button type="text" size="small" @click="handleDelete(record)">{{ $t('global.common.delete') }}</a-button>
  39. </template>
  40. </a-table>
  41. <new-data-package-form v-model:visible="newDataPackageFormVisible" :editMode="editMode" :editData="editData"
  42. @submit="handleNewDataPackageSubmit" />
  43. </div>
  44. </template>
  45. <script setup>
  46. import { onMounted, ref, getCurrentInstance } from "vue";
  47. import { useRoute } from "vue-router";
  48. import { columns } from "./config";
  49. import { Message, Notification } from '@arco-design/web-vue'
  50. import { dataPlanList } from "@/api/path/lotCard.api"
  51. import NewDataPackageForm from './NewDataPackageForm.vue';
  52. import { useI18n } from 'vue-i18n';
  53. const { t } = useI18n();
  54. const { proxy } = getCurrentInstance()
  55. const formRef = ref()
  56. const searchForm = ref({
  57. "status": "",
  58. "periodType": "",
  59. });
  60. const dataSource = ref([]);
  61. const route = useRoute();
  62. const pagination = ref({
  63. total: 0,
  64. pageSize: 10,
  65. current: 1,
  66. })
  67. // 运营商
  68. const operatorTypeOptions = [
  69. { value: '1', label: t('dataPackage.operatorTypes.chinamobile') },
  70. { value: '2', label: t('dataPackage.operatorTypes.chinaunicom') },
  71. { value: '3', label: t('dataPackage.operatorTypes.chinatelecom') },
  72. { value: '4', label: t('dataPackage.operatorTypes.international') },
  73. { value: '5', label: t('dataPackage.operatorTypes.foreign_local') },
  74. ];
  75. // 状态
  76. const statusList = [
  77. { value: '1', label: t('dataPackage.status.offline') },
  78. { value: '2', label: t('dataPackage.status.disabled') },
  79. { value: '3', label: t('dataPackage.status.normal') },
  80. ]
  81. const intData = async () => {
  82. const param = {
  83. current: pagination.value.current,
  84. size: pagination.value.pageSize,
  85. ...searchForm.value,
  86. }
  87. const { data } = await dataPlanList(param)
  88. dataSource.value = (data?.records || []).map((item, index) => {
  89. const sourceName = operatorTypeOptions.find(val => val.value == item.source)?.label
  90. const statusName = statusList.find(val => val.value == item.status)?.label
  91. return {
  92. ...item,
  93. packageCode: "NR0" + (index + 1),
  94. packageName: '监控1G月租',
  95. providerName: '泰国AIS',
  96. packageType: '定向',
  97. billingType: '流量',
  98. billingPeriod: '按月',
  99. packageSize: '1.00',
  100. packageUnit: 'G',
  101. standardPrice: '150.00',
  102. statusName,
  103. sourceName
  104. }
  105. })
  106. pagination.value.total = data.total
  107. }
  108. const evChangePage = (page) => {
  109. pagination.value.current = page
  110. }
  111. const resetSearch = () => {
  112. proxy.$refs.formRef.resetFields()
  113. intData()
  114. }
  115. const handleSearch = () => {
  116. intData()
  117. }
  118. // 弹窗-----------------------------------------------------
  119. // const showModel = ref(false)
  120. // const handleModal = () => {
  121. // showModel.value = true
  122. // }
  123. const newDataPackageFormVisible = ref(false);
  124. const editMode = ref(false);
  125. const editData = ref(null);
  126. const showNewDataPackageForm = () => {
  127. editMode.value = false;
  128. editData.value = null;
  129. newDataPackageFormVisible.value = true;
  130. };
  131. const handleEdit = (record) => {
  132. editMode.value = true;
  133. record.packageSize = Number(record.packageSize)
  134. record.standardPrice = Number(record.standardPrice)
  135. editData.value = { ...record };
  136. newDataPackageFormVisible.value = true;
  137. };
  138. const handleDelete = (record) => {
  139. // Implement delete logic
  140. Message.success(t('dataPackage.packageDeleted', { name: record.packageName }));
  141. };
  142. const handleNewDataPackageSubmit = (formData) => {
  143. if (editMode.value) {
  144. // Implement update logic
  145. Message.success(t('dataPackage.packageUpdated', { name: formData.packageName }));
  146. } else {
  147. // Implement add logic
  148. Message.success(t('dataPackage.packageAdded', { name: formData.packageName }));
  149. }
  150. newDataPackageFormVisible.value = false;
  151. };
  152. // -----------------------------------------------------
  153. onMounted(() => {
  154. intData()
  155. })
  156. </script>
  157. <style scoped lang="less">
  158. .search-section {
  159. margin-top: 20px;
  160. margin-bottom: 20px;
  161. }
  162. .container {
  163. .head-title {
  164. display: flex;
  165. justify-content: space-between;
  166. }
  167. .form-row {
  168. display: flex;
  169. .form-row-col {
  170. width: 25%;
  171. display: flex;
  172. align-items: center;
  173. .form-row-label {
  174. width: 120px;
  175. text-align: right;
  176. }
  177. }
  178. }
  179. }
  180. .audit-btn {
  181. margin-bottom: 10px;
  182. }
  183. </style>