channel.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div>
  3. <div class="card table-search">
  4. <el-row :gutter="10">
  5. <el-col :span="16">
  6. <el-button type="primary" :icon="CirclePlus" @click="handleCreate">新建推广渠道</el-button>
  7. </el-col>
  8. <el-col :span="8" class="text-right">
  9. <div class="flex">
  10. <el-input v-model="query.key" placeholder="输入推广者名称搜索关键词搜索" clearable></el-input>
  11. <el-button class="ml-2" type="primary" plain :icon="Search" @click="onSearch">搜索</el-button>
  12. </div>
  13. </el-col>
  14. </el-row>
  15. </div>
  16. <div class="card mt-4">
  17. <el-table :data="state.list" style="width: 100%">
  18. <el-table-column prop="name" label="推广渠道名称"> </el-table-column>
  19. <el-table-column prop="remark" label="备注信息"> </el-table-column>
  20. <el-table-column prop="name" label="操作" width="width">
  21. <template #default="{ row }">
  22. <el-button type="primary" :icon="Grid" @click="handleViewCode(row)" link>推广码</el-button>
  23. <el-button type="primary" :icon="Edit" link @click="handleEdit(row)">编辑</el-button>
  24. <el-popconfirm
  25. title="确定要删除这个推广渠道吗?删除后,该推广渠道的所有推广链接将失效,已推广订单不会受到影响"
  26. @confirm="handleDelete(row)"
  27. width="330px"
  28. >
  29. <template #reference>
  30. <el-button type="danger" :icon="Delete" link>删除</el-button>
  31. </template>
  32. </el-popconfirm>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. <div class="flex justify-end mt-5">
  37. <Pagination
  38. :pageable="{
  39. ...query,
  40. total: state.total
  41. }"
  42. :handle-size-change="handleSizeChange"
  43. :handle-current-change="handleCurrentChange"
  44. ></Pagination>
  45. </div>
  46. </div>
  47. <DialogEditPromotionChannel
  48. v-model:show="state.visible"
  49. @success="getList"
  50. :row-data="{ ...state.rowData }"
  51. ></DialogEditPromotionChannel>
  52. <DialogPromotionCode
  53. v-model:show="state.visibleCode"
  54. @success="getList"
  55. :row-data="{ ...state.rowData }"
  56. ></DialogPromotionCode>
  57. </div>
  58. </template>
  59. <script setup lang="tsx" name="promotionChannel">
  60. import { onMounted, reactive } from "vue";
  61. import { CirclePlus, Search, Edit, Delete, Grid } from "@element-plus/icons-vue";
  62. import { promotionSitePaginate, promotionSiteDelete } from "@/api/modules/promotion";
  63. import Pagination from "@/components/ProTable/components/Pagination.vue";
  64. import DialogEditPromotionChannel from "./components/DialogEditPromotionChannel.vue";
  65. import DialogPromotionCode from "./components/DialogPromotionCode.vue";
  66. import { ElMessage } from "element-plus";
  67. const query = reactive({
  68. page: 1,
  69. pageSize: 10,
  70. key: ""
  71. });
  72. const state = reactive({
  73. list: [],
  74. total: 0,
  75. visible: false,
  76. visibleCode: false,
  77. rowData: {}
  78. });
  79. const onSearch = () => {
  80. query.page = 1;
  81. getList();
  82. };
  83. const getList = async () => {
  84. let { data } = await promotionSitePaginate(query);
  85. state.list = data.list;
  86. state.total = data.total;
  87. };
  88. const handleSizeChange = (val: number) => {
  89. query.pageSize = val;
  90. getList();
  91. };
  92. const handleCurrentChange = (val: number) => {
  93. query.page = val;
  94. getList();
  95. };
  96. const handleEdit = (row: any) => {
  97. state.visible = true;
  98. state.rowData = row;
  99. };
  100. const handleCreate = () => {
  101. state.visible = true;
  102. state.rowData = {};
  103. };
  104. const handleDelete = async (row: any) => {
  105. let { message } = await promotionSiteDelete({ id: row.id });
  106. ElMessage.success(message);
  107. getList();
  108. };
  109. const handleViewCode = (row: any) => {
  110. state.visibleCode = true;
  111. state.rowData = row;
  112. };
  113. onMounted(() => {
  114. getList();
  115. });
  116. </script>