index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. v-show="showSearch"
  5. :model="queryParams"
  6. ref="queryForm"
  7. :inline="true"
  8. size="small"
  9. @submit.native.prevent
  10. >
  11. <el-form-item label="券包名称" prop="title">
  12. <el-input
  13. v-model="queryParams.title"
  14. placeholder="请输入券包名称"
  15. clearable
  16. size="small"
  17. style="width: 240px"
  18. @keyup.enter.native="handleQuery"
  19. />
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button
  23. type="primary"
  24. icon="el-icon-search"
  25. @click="handleQuery"
  26. >搜索</el-button
  27. >
  28. <el-button icon="el-icon-refresh" @click="resetQuery"
  29. >重置</el-button
  30. >
  31. </el-form-item>
  32. </el-form>
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="10">
  35. <el-button
  36. type="primary"
  37. icon="el-icon-plus"
  38. size="mini"
  39. @click="$router.push({ name: 'CouponPkgAdd' })"
  40. v-hasPermi="['business:couponPkg:add']"
  41. >生成券包</el-button
  42. >
  43. </el-col>
  44. <right-toolbar
  45. :showSearch.sync="showSearch"
  46. @queryTable="getList"
  47. ></right-toolbar>
  48. </el-row>
  49. <el-table v-loading="loading" :data="list">
  50. <el-table-column label="券包编号" prop="id" width="80" align="center" />
  51. <el-table-column label="券包名称" prop="title" align="center" />
  52. <el-table-column label="券数量" prop="couponNum" />
  53. <el-table-column label="总面值">
  54. <template slot-scope="{ row }">
  55. ¥{{ $numberFormat(row.facePrice) }}
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="状态" prop="status">
  59. <template slot-scope="{ row }">
  60. <el-tag v-if="row.status == 0" type="info">待上架</el-tag>
  61. <el-tag v-else-if="row.status == 1" type="success">上架</el-tag>
  62. <el-tag v-else-if="row.status == 2" type="info">下架</el-tag>
  63. </template>
  64. </el-table-column>
  65. <el-table-column fixed="right" align="center" label="操作" width="230">
  66. <template slot-scope="{ row }">
  67. <el-button
  68. v-hasPermi="['business:couponPkg:query']"
  69. type="text"
  70. @click="
  71. $router.push({
  72. name: 'CouponPkgQuery',
  73. query: { id: row.id },
  74. })
  75. "
  76. >查看</el-button
  77. >
  78. <el-button
  79. v-if="row.status === 0"
  80. v-hasPermi="['business:couponPkg:edit']"
  81. type="text"
  82. @click="
  83. $router.push({
  84. name: 'CouponPkgEdit',
  85. query: { id: row.id },
  86. })
  87. "
  88. >编辑</el-button
  89. >
  90. <el-button
  91. v-if="row.status === 0 || row.status === 2"
  92. v-hasPermi="['business:couponPkg:on']"
  93. type="text"
  94. @click="setStatus(row, 1)"
  95. >上架</el-button
  96. >
  97. <el-button
  98. v-if="row.status === 1"
  99. v-hasPermi="['business:couponPkg:off']"
  100. type="text"
  101. @click="setStatus(row, 2)"
  102. >下架</el-button
  103. >
  104. <el-button
  105. v-if="row.status === 0"
  106. v-hasPermi="['business:couponPkg:remove']"
  107. class="del"
  108. type="text"
  109. @click="del(row)"
  110. >删除</el-button
  111. >
  112. </template>
  113. </el-table-column>
  114. </el-table>
  115. <pagination
  116. :total="total"
  117. :page.sync="queryParams.pageNum"
  118. :limit.sync="queryParams.pageSize"
  119. @pagination="getList()"
  120. />
  121. </div>
  122. </template>
  123. <script>
  124. import {
  125. getCouponList,
  126. delCoupon,
  127. setCouponPkgStatus,
  128. } from "@/api/business/couponPkg";
  129. export default {
  130. name: 'ListCouponPkg',
  131. data() {
  132. return {
  133. loading: false,
  134. showSearch: true,
  135. queryParams: {
  136. title: "",
  137. },
  138. // 分页
  139. pageParams: {
  140. pageNum: 1,
  141. pageSize: 10,
  142. },
  143. // 总条数
  144. total: 0,
  145. list: [],
  146. };
  147. },
  148. created() {
  149. this.getList();
  150. },
  151. methods: {
  152. getList() {
  153. this.loading = true;
  154. getCouponList(
  155. "pageNum=" +
  156. this.pageParams.pageNum +
  157. "&pageSize=" +
  158. this.pageParams.pageSize +
  159. "&",
  160. this.queryParams
  161. )
  162. .then((res) => {
  163. this.loading = false;
  164. if (res.code === 0) {
  165. this.list = res.rows;
  166. this.total = res.total;
  167. }
  168. })
  169. .catch(() => {
  170. this.loading = false;
  171. });
  172. },
  173. //搜索
  174. handleQuery() {
  175. this.pageParams.pageNum = 1;
  176. this.getList();
  177. },
  178. // 重置
  179. resetQuery() {
  180. this.resetForm("queryForm");
  181. this.pageParams.pageNum = 1;
  182. this.getList();
  183. },
  184. setStatus(item, status) {
  185. this.$confirm(
  186. `确认${status === "on" ? "上架" : "下架"}券包 “${item.title}” 吗?`,
  187. `${status === "on" ? "上架" : "下架"}券包`,
  188. {
  189. confirmButtonText: "确定",
  190. cancelButtonText: "取消",
  191. type: "warning",
  192. }
  193. ).then(() => {
  194. setCouponPkgStatus({
  195. id: item.id,
  196. status,
  197. }).then((res) => {
  198. if (res.code === 0) {
  199. this.$message.success("操作已完成!");
  200. this.getList();
  201. }
  202. });
  203. });
  204. },
  205. del(item) {
  206. this.$confirm(`确认删除券包 “${item.title}” 吗?`, "删除券", {
  207. confirmButtonText: "确定",
  208. cancelButtonText: "取消",
  209. type: "warning",
  210. }).then(() => {
  211. delCoupon(item.id).then((res) => {
  212. if (res.code === 0) {
  213. this.$message.success("操作已完成!");
  214. this.getList();
  215. }
  216. });
  217. });
  218. },
  219. },
  220. };
  221. </script>
  222. <style>
  223. </style>