index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <ele-page flex-table :bodyStyle="{ padding: 0 }">
  3. <page-search @search="handleSearch" />
  4. <common-table ref="tableRef" :columns="columns" :page-config="pageConfig"
  5. @selection-change="handleSelectionChange">
  6. <template #toolbar>
  7. <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
  8. <!-- <el-button type="danger" :icon="Delete" @click="handleBatchDelete">批量删除</el-button> -->
  9. <el-button type="success" :icon="Upload" @click="handleImport">导入</el-button>
  10. <el-button type="warning" :icon="Download" @click="handleExport">导出</el-button>
  11. </template>
  12. <template #cover="{ row }">
  13. <el-image style="width: 50px; height: 70px" :src="row.cover" :preview-src-list="[row.cover]"
  14. fit="cover" />
  15. </template>
  16. <template #sellStatus="{ row }">
  17. <dict-data code="sell_status" v-model="row.sellStatus" type="tag"></dict-data>
  18. </template>
  19. <!-- <template #action="{ row }">
  20. <el-button type="danger" link @click="handleDelete(row)">删除</el-button>
  21. </template> -->
  22. </common-table>
  23. <booklist-add ref="addRef" @success="refreshData" />
  24. <booklist-import ref="importRef" @success="refreshData" />
  25. </ele-page>
  26. </template>
  27. <script setup>
  28. import { ref, reactive } from 'vue';
  29. import { Plus, Delete, Upload, Download } from '@element-plus/icons-vue';
  30. import { ElMessage, ElMessageBox } from 'element-plus';
  31. import CommonTable from '@/components/CommonPage/CommonTable.vue';
  32. import PageSearch from './components/PageSearch.vue';
  33. import BooklistAdd from './components/BooklistAdd.vue';
  34. import BooklistImport from './components/BooklistImport.vue';
  35. defineOptions({
  36. name: 'ShareDiscountBookList'
  37. });
  38. const tableRef = ref(null);
  39. const addRef = ref(null);
  40. const importRef = ref(null);
  41. const selection = ref([]);
  42. const pageConfig = reactive({
  43. pageUrl: '/activity/reduce/book/pagelist',
  44. exportUrl: '/activity/reduce/book/export',
  45. fileName: '降价营销书单',
  46. cacheKey: 'shareDiscountBookListTable',
  47. rowKey: 'id',
  48. tool: true
  49. });
  50. const columns = [
  51. { type: 'selection', width: 50 },
  52. { prop: 'cover', label: '封面', slot: 'cover', width: 80 },
  53. { prop: 'isbn', label: 'ISBN', width: 140 },
  54. { prop: 'bookName', label: '书名', minWidth: 150 },
  55. { prop: 'author', label: '作者', width: 120 },
  56. { prop: 'publish', label: '出版社', width: 150 },
  57. { prop: 'pubDate', label: '出版时间', width: 120 },
  58. { prop: 'price', label: '定价', width: 80 },
  59. { prop: 'productPrice', label: '售价', width: 80 },
  60. {
  61. prop: 'sellStatus',
  62. label: '销售状态',
  63. width: 100,
  64. slot: 'sellStatus',
  65. formatter: (row) => ['待上架', '出售中', '手动下架', '售罄', '黑名单'][row.sellStatus] || row.sellStatus
  66. },
  67. { prop: 'recycleDiscount', label: '回收折扣', width: 100 },
  68. { prop: 'recyclePrice', label: '回收价格', width: 100 },
  69. { prop: 'upsellPrice', label: '加价金额', width: 100 },
  70. { prop: 'createTime', label: '添加时间', width: 160 },
  71. // { prop: 'action', label: '操作', slot: 'action', width: 100, fixed: 'right' }
  72. ];
  73. const handleSearch = (params) => {
  74. tableRef.value?.reload(params);
  75. };
  76. const refreshData = () => {
  77. tableRef.value?.reload();
  78. };
  79. const handleSelectionChange = (val) => {
  80. selection.value = val;
  81. };
  82. const handleAdd = () => {
  83. addRef.value?.handleOpen();
  84. };
  85. const handleImport = () => {
  86. importRef.value?.handleOpen();
  87. };
  88. const handleExport = () => {
  89. tableRef.value?.exportData();
  90. };
  91. // const handleBatchDelete = () => {
  92. // if (selection.value.length === 0) {
  93. // ElMessage.warning('请选择要删除的记录');
  94. // return;
  95. // }
  96. // ElMessageBox.confirm('确认删除选中的记录吗?', '提示', {
  97. // type: 'warning'
  98. // }).then(async () => {
  99. // // No delete API available
  100. // });
  101. // };
  102. // const handleDelete = (row) => {
  103. // // No delete API available
  104. // };
  105. </script>