index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. watch: {
  149. $route: {
  150. handler: function (val, oldVal) {
  151. if (val.name == "ListCouponPkg") {
  152. this.getList();
  153. }
  154. },
  155. },
  156. },
  157. created() {
  158. this.getList();
  159. },
  160. methods: {
  161. getList() {
  162. this.loading = true;
  163. getCouponList(
  164. "pageNum=" +
  165. this.pageParams.pageNum +
  166. "&pageSize=" +
  167. this.pageParams.pageSize +
  168. "&",
  169. this.queryParams
  170. )
  171. .then((res) => {
  172. this.loading = false;
  173. if (res.code === 0) {
  174. this.list = res.rows;
  175. this.total = res.total;
  176. }
  177. })
  178. .catch(() => {
  179. this.loading = false;
  180. });
  181. },
  182. //搜索
  183. handleQuery() {
  184. this.pageParams.pageNum = 1;
  185. this.getList();
  186. },
  187. // 重置
  188. resetQuery() {
  189. this.resetForm("queryForm");
  190. this.pageParams.pageNum = 1;
  191. this.getList();
  192. },
  193. setStatus(item, status) {
  194. this.$confirm(
  195. `确认${status === "on" ? "上架" : "下架"}券包 “${item.title}” 吗?`,
  196. `${status === "on" ? "上架" : "下架"}券包`,
  197. {
  198. confirmButtonText: "确定",
  199. cancelButtonText: "取消",
  200. type: "warning",
  201. }
  202. ).then(() => {
  203. setCouponPkgStatus({
  204. id: item.id,
  205. status,
  206. }).then((res) => {
  207. if (res.code === 0) {
  208. this.$message.success("操作已完成!");
  209. this.getList();
  210. }
  211. });
  212. });
  213. },
  214. del(item) {
  215. this.$confirm(`确认删除券包 “${item.title}” 吗?`, "删除券", {
  216. confirmButtonText: "确定",
  217. cancelButtonText: "取消",
  218. type: "warning",
  219. }).then(() => {
  220. delCoupon(item.id).then((res) => {
  221. if (res.code === 0) {
  222. this.$message.success("操作已完成!");
  223. this.getList();
  224. }
  225. });
  226. });
  227. },
  228. },
  229. };
  230. </script>
  231. <style>
  232. </style>