addSetMeal.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div>
  3. <div class="search">
  4. <Search :SearchForm="SetMealSearchForm" @query="initData" @reset="reset"></Search>
  5. </div>
  6. <div class="addSetMeal">
  7. <a-button @click="breakFlos">返回</a-button>
  8. </div>
  9. <div class="table">
  10. <a-table row-key="id" :data="tableData" :columns="columnsTarrit" :pagination="pagination"
  11. :scroll="{ x: 'auto' }" @page-change="evChangePage">
  12. <template #status="{ record }">
  13. <a-tag :color="record.status == 1 ? '#7bc616' : '#86909c'">{{ record.status == 1 ? '上架' : '下架'
  14. }}</a-tag>
  15. </template>
  16. </a-table>
  17. </div>
  18. </div>
  19. </template>
  20. <script setup>
  21. import { defineEmits, defineProps, toRefs, ref, onMounted } from 'vue';
  22. import { CheckTariffPackages } from '@/api/path/tariffManagement.api'
  23. import { Getdictionary, tableFunction, filterDict } from '@/mixins/index.js'
  24. import Search from '@/components/Search/index.vue'
  25. import { columnsTarrit } from './config'
  26. import { tariffList} from "@/api/path/tariffManagement.api"
  27. const props = defineProps({
  28. id: [Array, String]
  29. })
  30. const emits = defineEmits(['break'])
  31. const state = ref({
  32. pagination: {
  33. total: 0,
  34. pageSize: 10,
  35. current: 1,
  36. simTerminalId: null
  37. },
  38. visible: false,
  39. puyType: [],
  40. cyciy: [],
  41. Currency: [],
  42. tariffListData: [],
  43. billingMethodList: [],
  44. Type: true,
  45. })
  46. const { pagination, visible, puyType, Currency, cyciy, tariffListData, formRef, billingMethodList, Type } = toRefs(state.value)
  47. const processData = (data) => {
  48. return (data.records || []).map((item, index) => {
  49. return {
  50. ...item,
  51. price: item.price + '/' + item.currency,
  52. typeName: item.type == 1 ? '服务时长' : "购买流量",
  53. profitPrice: item.profitPrice + '/' + item.currency,
  54. billingMethod: filterDict(billingMethodList.value, item.billingMethod),
  55. costPrice: item.costPrice + '/' + item.trafficCurrency,
  56. oldPrice: item.oldPrice + '/' + item.trafficCurrency
  57. }
  58. })
  59. }
  60. const { tableData, evChangePage, initData, reset } = tableFunction(pagination.value, CheckTariffPackages, processData)
  61. const breakFlos = ()=>{
  62. emits('break',true)
  63. }
  64. onMounted(async () => {
  65. let dict = await Getdictionary(['RechargeType', 'PuyCycle', 'currencyType', 'billingMethod'])
  66. puyType.value = dict[0]
  67. Form.value.type = puyType.value[0]?.value
  68. cyciy.value = dict[1]
  69. Form.value.timeUnit = cyciy.value[0]?.value
  70. Currency.value = dict[2]
  71. Form.value.currency = Currency.value[0]?.value
  72. billingMethodList.value = dict[3]
  73. let res = await tariffList({ current: 1, size: 99999 })
  74. if (res.code === 200) {
  75. tariffListData.value = (res.data.records || []).map(item => {
  76. return {
  77. ...item,
  78. value: item.id,
  79. label: item.label + '---' + item.userName
  80. }
  81. })
  82. }
  83. pagination.value.simTerminalId = props.id
  84. initData()
  85. })
  86. </script>
  87. <style scoped lang='less'>
  88. .search,
  89. .table {
  90. margin-top: 20px;
  91. }
  92. .addSetMeal{
  93. display: flex;
  94. justify-content: space-between;
  95. }
  96. </style>