index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <!-- 资费管理 -->
  2. <template>
  3. <div class="container">
  4. <!-- 搜索条件区 -->
  5. <div class="search-section">
  6. <Search :SearchForm="trafficSearchFrom" @query="intData" @reset="reset" />
  7. </div>
  8. <div class="audit-btn">
  9. <a-button type="text" @click="dictShowModel(1, false)" v-if="role.getRole == 1">
  10. <template #icon>
  11. <icon-plus-circle />
  12. </template>
  13. <template #default>{{ $t('form.Add') }}</template>
  14. </a-button>
  15. </div>
  16. <a-table row-key="id" :data="dataSource" :columns="columns" :pagination="pagination" :scroll="{ x: 'auto' }"
  17. @page-change="evChangePage">
  18. <template #id="{ record }">
  19. <!-- 修改 -->
  20. <a class="a-link" href="javascript:;" style="margin-right: 1rem" @click="dictShowModel(2, record)"
  21. v-if="role.getRole == 1">{{
  22. $t('form.alter')
  23. }}</a>
  24. <a class="a-link" href="javascript:;" style="margin-right: 1rem" @click="meal(record)">{{
  25. $t('tariffManagement.SetMeal') }}</a>
  26. <!-- 删除 -->
  27. <a-popconfirm :content="$t('form.Delete')" :ok-text="$t('form.Confirm')" :cancel-text="$t('form.Cancel')"
  28. @ok="handleDel(record.id)">
  29. <a class="a-link" href="javascript:;" style="margin-right: 1rem" v-if="role.getRole == 1">{{
  30. $t('form.Delete')
  31. }}</a>
  32. </a-popconfirm>
  33. </template>
  34. </a-table>
  35. <a-modal width="70%" :visible="planVisible" :title="$t('tariffManagement.SelectiveTrafficPacket')"
  36. @ok="handleSubmitPlan" @cancel="handleCancel">
  37. <!-- 搜索条件区 -->
  38. <div class="search-section">
  39. <a-form :model="formData" layout="inline">
  40. <a-form-item field="label" :label="$t('tariffManagement.label')">
  41. <a-input v-model="formData.label" :placeholder="$t('lotCard.please') + $t('tariffManagement.label')"
  42. allow-clear />
  43. </a-form-item>
  44. <a-form-item>
  45. <a-space>
  46. <a-button type="primary" @click="handleSearchPlan">{{ $t('form.Search') }}</a-button>
  47. <a-button @click="resetSearchPlan">{{ $t('form.Reset') }}</a-button>
  48. </a-space>
  49. </a-form-item>
  50. </a-form>
  51. </div>
  52. <a-table row-key="id" :data="planList" :columns="planColumns" :scroll="{ x: 'auto' }"
  53. :row-selection="rowSelectionPlan" v-model:selectedKeys="selectedKeysPlan">
  54. </a-table>
  55. </a-modal>
  56. <Meal v-model:model-value="modealShow" :traffIds="ids" @submit="intData()" />
  57. <Add v-model:model-value="visible" :type-index="typeCurrent" ref="addDetaile" @submit="intData()"></Add>
  58. </div>
  59. </template>
  60. <script setup>
  61. import { onMounted, ref, toRefs, getCurrentInstance } from "vue";
  62. import { useRoute } from "vue-router";
  63. import { columns, planColumns, trafficSearchFrom } from "./config";
  64. import { deleteTariff, tariffList } from "@/api/path/tariffManagement.api"
  65. import { Getdictionary } from '@/mixins/index.js'
  66. import { useSystemStore } from '@/store/modules/systemStore'
  67. import Meal from './Management/meal.vue'
  68. import Add from './Management/add.vue'
  69. import Search from '@/components/Search/index.vue'
  70. import { useI18n } from 'vue-i18n'
  71. import { Message } from '@arco-design/web-vue'
  72. const { t } = useI18n();
  73. const role = useSystemStore()
  74. const { proxy } = getCurrentInstance()
  75. const route = useRoute();
  76. const state = ref({
  77. searchForm: {},
  78. currency: [],
  79. dataSource: [],
  80. pagination: {
  81. total: 0,
  82. pageSize: 10,
  83. current: 1,
  84. },
  85. planList: [],
  86. visible: false,
  87. typeCurrent: null,
  88. sourceList: [],
  89. cycleist: [],
  90. modealShow: false,
  91. planVisible: false,
  92. formData: {},
  93. selectedKeysPlan: [],
  94. rowSelectionPlan: {
  95. type: 'radio',
  96. showCheckedAll: true,
  97. onlyCurrent: false,
  98. },
  99. ids: null,
  100. methodList: []
  101. })
  102. const {
  103. searchForm,
  104. currency,
  105. dataSource,
  106. pagination,
  107. planList,
  108. visible,
  109. typeCurrent,
  110. sourceList,
  111. cycleist,
  112. modealShow,
  113. planVisible,
  114. formData,
  115. selectedKeysPlan,
  116. rowSelectionPlan,
  117. ids,
  118. methodList
  119. } = toRefs(state.value);
  120. const addDetaile = ref(null)
  121. const intData = async (item) => {
  122. if (item) {
  123. searchForm.value = item
  124. }
  125. const param = {
  126. current: pagination.value.current,
  127. size: pagination.value.pageSize,
  128. ...searchForm.value,
  129. }
  130. const { data } = await tariffList(param)
  131. dataSource.value = (data.records || []).map((item, index) => {
  132. const sourceName = sourceList.value.find(val => val.value == item.source)?.label
  133. const billingCycleName = cycleist.value.find(val => val.value == item.billingCycle)?.label
  134. const pricingCurrty = currency.value.find(val => val.value == item.currency)?.label || '人民币'
  135. const Activated = item.trafficBilling + item.trafficBillingType
  136. const bagSize = item.pricing + '/' + item.mrcAmount + '/' + item.networkAccessFee
  137. const billingMethodName = methodList.value.find(val => val.value == item.billingMethod)?.label
  138. delete item.children
  139. let pricingName;
  140. if (item.billingMethod == 1) {
  141. pricingName = item.trafficBillingAmount + '/' + pricingCurrty
  142. } else if (item.billingMethod == 2) {
  143. pricingName = item.pricing + '/' + pricingCurrty
  144. }
  145. return {
  146. ...item,
  147. sourceName,
  148. pricingName,
  149. billingCycleName,
  150. Activated: Activated,
  151. status: "正常",
  152. bagSize,
  153. billingMethodName,
  154. Number: index + 1
  155. }
  156. })
  157. pagination.value.total = data.total
  158. }
  159. const reset = (item) => {
  160. searchForm.value = item
  161. pagination.value.current = 1
  162. intData()
  163. }
  164. // 删除
  165. const handleDel = async (id) => {
  166. const { code } = await deleteTariff({ id })
  167. if (code == 200) {
  168. Message.success({
  169. content: t('setting.deleteSuccess'),
  170. duration: 2000,
  171. })
  172. intData()
  173. }
  174. };
  175. const evChangePage = (page) => {
  176. pagination.value.current = page
  177. intData()
  178. }
  179. // 弹框
  180. const dictShowModel = (type, data) => {
  181. addDetaile.value.detaile(data)
  182. typeCurrent.value = type;
  183. visible.value = true;
  184. }
  185. const resetSearchPlan = () => {
  186. }
  187. const handleSearchPlan = () => {
  188. }
  189. const handleCancel = () => {
  190. planVisible.value = false
  191. }
  192. const handleSubmitPlan = () => {
  193. if (selectedKeysPlan.value.length > 0) {
  194. formState.value.simDataPlanId = String(selectedKeysPlan.value[0])
  195. planVisible.value = false
  196. }
  197. }
  198. const handleDictValue = async () => {
  199. sourceList.value = await Getdictionary('source')
  200. cycleist.value = await Getdictionary('Billingcycle')
  201. currency.value = await Getdictionary('currencyType')
  202. methodList.value = await Getdictionary('billingMethod')
  203. }
  204. const meal = (data) => {
  205. ids.value = data.id
  206. modealShow.value = true
  207. }
  208. onMounted(async () => {
  209. await handleDictValue()
  210. await intData()
  211. })
  212. </script>
  213. <style scoped lang="less">
  214. .head-title-right {
  215. .m-r-10 {
  216. margin-right: 10px;
  217. }
  218. }
  219. .search-section {
  220. margin-top: 20px;
  221. margin-bottom: 20px;
  222. }
  223. .container {
  224. .head-title {
  225. display: flex;
  226. justify-content: space-between;
  227. }
  228. .form-row {
  229. display: flex;
  230. .form-row-col {
  231. width: 25%;
  232. display: flex;
  233. align-items: center;
  234. .form-row-label {
  235. width: 120px;
  236. text-align: right;
  237. }
  238. }
  239. }
  240. }
  241. .audit-btn {
  242. margin-bottom: 10px;
  243. }
  244. .formTitle {
  245. font-size: 18px;
  246. margin-bottom: 20px;
  247. display: flex;
  248. align-items: center
  249. }
  250. .formTitle::before {
  251. content: "";
  252. display: inline-block;
  253. width: 4px;
  254. height: 20px;
  255. background-color: green;
  256. margin-right: 10px;
  257. }
  258. </style>