index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="p-2">
  3. <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
  4. <div v-show="showSearch" class="mb-[10px]">
  5. <el-card shadow="hover">
  6. <el-form ref="queryFormRef" :model="queryParams" :inline="true">
  7. <el-form-item label="推文标题" prop="title">
  8. <el-input v-model="queryParams.title" placeholder="请输入推文标题" clearable style="width: 240px" @keyup.enter="handleQuery" />
  9. </el-form-item>
  10. <el-form-item label="推文类别" prop="category">
  11. <el-select v-model="queryParams.category" placeholder="请选择" clearable style="width: 200px">
  12. <el-option
  13. v-for="item in purchaseCategoryOptions"
  14. :key="item.id"
  15. :label="item.categoryName"
  16. :value="item.id"
  17. />
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  22. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. </el-card>
  26. </div>
  27. </transition>
  28. <el-card shadow="never">
  29. <template #header>
  30. <div class="flex justify-between items-center">
  31. <span class="text-lg font-medium">产品推荐信息列表</span>
  32. <div>
  33. <el-button type="primary" icon="Plus" @click="handleAdd" >新增</el-button>
  34. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" style="display: inline-block; margin-left: 8px;"></right-toolbar>
  35. </div>
  36. </div>
  37. </template>
  38. <el-table v-loading="loading" border :data="programList">
  39. <el-table-column label="编号" align="center" prop="programNo" width="120" />
  40. <el-table-column label="封面图片" align="center" prop="coverImageUrl" width="120">
  41. <template #default="scope">
  42. <image-preview :src="scope.row.coverImageUrl" :width="60" :height="60"/>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="推文标题" align="center" prop="title" min-width="200" show-overflow-tooltip>
  46. <template #default="scope">
  47. <el-button link type="primary" @click="handleView(scope.row)">{{ scope.row.title }}</el-button>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="推文类型" align="center" prop="category" width="150">
  51. <template #default="scope">
  52. <span>{{ getCategoryName(scope.row.category) }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="是否显示" align="center" prop="isShow" width="100">
  56. <template #default="scope">
  57. <span :style="{ color: scope.row.isShow === '1' ? '#409eff' : '#f56c6c' }">
  58. {{ scope.row.isShow === '1' ? '显示' : '不显示' }}
  59. </span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="操作" align="center" width="120" fixed="right">
  63. <template #default="scope">
  64. <el-button link type="primary" @click="handleView(scope.row)">查看</el-button>
  65. <el-button link type="primary" @click="handleUpdate(scope.row)" >编辑</el-button>
  66. <el-button link type="danger" @click="handleDelete(scope.row)" >删除</el-button>
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
  71. </el-card>
  72. </div>
  73. </template>
  74. <script setup name="Program" lang="ts">
  75. import { listProgram, delProgram } from '@/api/pmsProduct/program';
  76. import { listPurchaseCategory } from '@/api/globalSetting/purchaseCategory';
  77. import { ProgramVO, ProgramQuery } from '@/api/pmsProduct/program/types';
  78. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  79. const router = useRouter();
  80. const programList = ref<ProgramVO[]>([]);
  81. const loading = ref(true);
  82. const showSearch = ref(true);
  83. const total = ref(0);
  84. const queryFormRef = ref<ElFormInstance>();
  85. // 下拉选项数据
  86. const purchaseCategoryOptions = ref<any[]>([]);
  87. const queryParams = ref<ProgramQuery>({
  88. pageNum: 1,
  89. pageSize: 10,
  90. title: undefined,
  91. category: undefined,
  92. params: {}
  93. });
  94. /** 获取采购分类列表 */
  95. const getPurchaseCategoryList = async () => {
  96. const res = await listPurchaseCategory({ isShow: 1 });
  97. purchaseCategoryOptions.value = res.rows || [];
  98. };
  99. /** 获取分类名称 */
  100. const getCategoryName = (id: any) => {
  101. if (!id) return '';
  102. const category = purchaseCategoryOptions.value.find(item => String(item.id) === String(id));
  103. return category ? category.categoryName : id;
  104. }
  105. /** 查询产品推荐列表 */
  106. const getList = async () => {
  107. loading.value = true;
  108. const res = await listProgram(queryParams.value);
  109. programList.value = res.rows;
  110. total.value = res.total;
  111. loading.value = false;
  112. }
  113. /** 搜索按钮操作 */
  114. const handleQuery = () => {
  115. queryParams.value.pageNum = 1;
  116. getList();
  117. }
  118. /** 重置按钮操作 */
  119. const resetQuery = () => {
  120. queryFormRef.value?.resetFields();
  121. handleQuery();
  122. }
  123. /** 新增按钮操作 */
  124. const handleAdd = () => {
  125. router.push({ path: '/product/productProgram/form' });
  126. }
  127. /** 查看按钮操作 */
  128. const handleView = (row: ProgramVO) => {
  129. router.push({ path: '/product/productProgram/form', query: { id: row.id, mode: 'view' } });
  130. }
  131. /** 修改按钮操作 */
  132. const handleUpdate = (row: ProgramVO) => {
  133. router.push({ path: '/product/productProgram/form', query: { id: row.id } });
  134. }
  135. /** 删除按钮操作 */
  136. const handleDelete = async (row: ProgramVO) => {
  137. await proxy?.$modal.confirm('是否确认删除该产品推荐?').finally(() => loading.value = false);
  138. await delProgram(row.id);
  139. proxy?.$modal.msgSuccess("删除成功");
  140. await getList();
  141. }
  142. onMounted(async () => {
  143. await getPurchaseCategoryList();
  144. getList();
  145. });
  146. </script>