index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <!--
  2. * @Description:
  3. * @Author: gcz
  4. * @Date: 2024-03-04 15:03:37
  5. * @LastEditors: gcz
  6. * @LastEditTime: 2024-03-14 15:21:15
  7. * @FilePath: \great_webui\src\views\marketing\coupon\index.vue
  8. * @Copyright: Copyright (c) 2016~2024 by gcz, All Rights Reserved.
  9. -->
  10. <template>
  11. <div class="app-container">
  12. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  13. <el-form-item label="优惠券名称" label-width="100px">
  14. <el-input
  15. v-model="queryParams.couponName"
  16. placeholder="请输入优惠券名称"
  17. clearable
  18. style="width: 140px;"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <!-- <el-form-item label="状态">
  23. <el-select
  24. v-model="queryParams.status"
  25. placeholder="状态"
  26. clearable
  27. style="width: 240px"
  28. >
  29. <el-option
  30. v-for="dict in statusList"
  31. :key="dict.value"
  32. :label="dict.name"
  33. :value="dict.value"
  34. />
  35. </el-select>
  36. </el-form-item> -->
  37. <el-form-item>
  38. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  39. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  40. </el-form-item>
  41. </el-form>
  42. <el-row :gutter="10" class="mb8">
  43. <el-col :span="1.5">
  44. <el-button
  45. type="primary"
  46. plain
  47. icon="el-icon-plus"
  48. size="mini"
  49. @click="handleAdd"
  50. v-hasPermi="['marketing:coupon:add']"
  51. >添加</el-button>
  52. </el-col>
  53. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  54. </el-row>
  55. <el-table ref="tables" v-loading="loading" :data="dataList" border>
  56. <!-- <el-table-column label="序号" align="center" type="index" width="50"></el-table-column> -->
  57. <el-table-column label="批次号" align="center" prop="couponBatch" width="140" />
  58. <el-table-column label="优惠劵名称" align="center" prop="couponName" />
  59. <el-table-column label="优惠额度" align="center" prop="quota">
  60. <template slot-scope="scope">
  61. <span>{{scope.row.quota}}{{ scope.row.type==1?'(元)':'(%)' }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="类型" align="center" prop="type">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.type==1?'满减':'折扣' }}</span>
  67. <!-- <dict-tag :options="dict.type.template_ident" :value="scope.row.templateIdent"/> -->
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="使用对象" align="center" prop="useUserType">
  71. <template slot-scope="scope">
  72. <span v-if="scope.row.useUserType==1">所有用户</span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="使用剧目" align="center" prop="usePerformName" />
  76. <el-table-column label="使用票务" align="center" prop="useGoodName" />
  77. <el-table-column label="使用时间类型" align="center" prop="useType">
  78. <template slot-scope="scope">
  79. <span v-if="scope.row.useType==1">指定周期</span>
  80. <span v-if="scope.row.useType==2">领取后计算</span>
  81. <!-- <dict-tag :options="dict.type.template_ident" :value="scope.row.templateIdent"/> -->
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="使用时间" align="center" prop="useStartDate">
  85. <template slot-scope="scope">
  86. <span v-if="scope.row.useType==1">{{scope.row.useStartDate}}至{{scope.row.useEndDate}}</span>
  87. <span v-if="scope.row.useType==2">领取{{scope.row.useDay}}天后失效</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="创建时间" align="center" prop="createTime" width="160">
  91. <template slot-scope="scope">
  92. <span>{{ parseTime(scope.row.createTime) }}</span>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
  96. <template slot-scope="scope">
  97. <!-- <el-button
  98. size="mini"
  99. type="text"
  100. @click="ionlineApi(scope.row)"
  101. v-hasPermi="['marketing:coupon:edit']"
  102. >{{scope.row.status == '1' ? '禁用' : '启用'}}</el-button> -->
  103. <el-button
  104. size="mini"
  105. type="text"
  106. @click="handleUpdate(scope.row)"
  107. v-hasPermi="['marketing:coupon:edit']"
  108. >编辑</el-button>
  109. <el-button
  110. size="mini"
  111. type="text"
  112. @click="handleDelete(scope.row,scope.index)"
  113. v-hasPermi="['marketing:coupon:delete']"
  114. >删除</el-button>
  115. </template>
  116. </el-table-column>
  117. </el-table>
  118. <pagination
  119. v-show="total>0"
  120. :total="total"
  121. :page.sync="queryParams.pageNum"
  122. :limit.sync="queryParams.pageSize"
  123. @pagination="getList"
  124. />
  125. <!-- 新增/编辑弹框 -->
  126. <add-and-edit
  127. ref="addAndEdit"
  128. :dict="dict"
  129. @getList="getList"
  130. />
  131. <el-dialog
  132. title="查看"
  133. :visible.sync="visibleStatus"
  134. width="600px"
  135. :destroy-on-close="true"
  136. :close-on-click-modal="false"
  137. >
  138. <div v-if="visibleType == 'img'">
  139. <el-image
  140. style="width: 400px; height: 100%"
  141. :src="newObj.mainImg"
  142. fit="cover"
  143. />
  144. </div>
  145. <div v-if="visibleType == 'html'">
  146. <div v-html="newObj.centent"></div>
  147. </div>
  148. <div slot="footer" class="dialog-footer">
  149. <el-button type="primary" @click="visibleStatus = false">确 定</el-button>
  150. </div>
  151. </el-dialog>
  152. </div>
  153. </template>
  154. <script>
  155. import { pageList, deleteById, ionline,resetPwd } from '@/api/coupon/coupon'
  156. import addAndEdit from "./dialog/addAndEdit.vue";
  157. export default {
  158. name: "agreement",
  159. dicts: ['template_ident'],
  160. components: { addAndEdit },
  161. data() {
  162. return {
  163. // 遮罩层
  164. loading: true,
  165. // 选中数组
  166. ids: [],
  167. // 非单个禁用
  168. single: true,
  169. // 非多个禁用
  170. multiple: true,
  171. // 显示搜索条件
  172. showSearch: true,
  173. // 总条数
  174. total: 0,
  175. // 用户表格数据
  176. dataList: null,
  177. // 弹出层标题
  178. title: "",
  179. // 是否显示弹出层
  180. open: false,
  181. // 日期范围
  182. dateRange: [],
  183. // 查询参数
  184. queryParams: {
  185. pageNum: 1,
  186. pageSize: 10,
  187. type: undefined
  188. },
  189. visibleStatus: false,
  190. newObj: {},
  191. visibleType: ''
  192. };
  193. },
  194. created() {
  195. this.getList();
  196. },
  197. methods: {
  198. /** 查询列表 */
  199. getList() {
  200. this.loading = true;
  201. pageList(this.addDateRange(this.queryParams, this.dateRange))
  202. .then(response => {
  203. this.dataList = response.data.rows;
  204. this.total = response.data.total;
  205. this.loading = false;
  206. }
  207. );
  208. },
  209. // 取消按钮
  210. cancel() {
  211. this.open = false;
  212. },
  213. /** 搜索按钮操作 */
  214. handleQuery() {
  215. this.queryParams.pageNum = 1;
  216. this.getList();
  217. },
  218. /** 重置按钮操作 */
  219. resetQuery() {
  220. this.dateRange = [];
  221. this.$set(this.queryParams, 'couponName', '');
  222. this.$set(this.queryParams, 'status', '');
  223. this.queryParams.pageNum = 1;
  224. this.handleQuery();
  225. },
  226. // 多选框选中数据
  227. handleSelectionChange(selection) {
  228. this.ids = selection.map(item => item.userId);
  229. this.single = selection.length != 1;
  230. this.multiple = !selection.length;
  231. },
  232. /** 新增按钮操作 */
  233. handleAdd() {
  234. this.$refs["addAndEdit"].openDialog("新增数据", null);
  235. },
  236. /** 修改按钮操作 */
  237. handleUpdate(row) {
  238. this.$refs["addAndEdit"].openDialog("修改数据", row);
  239. },
  240. /** 发布或者取消发布按钮操作 */
  241. ionlineApi(row) {
  242. this.$confirm("是否对-" + row.couponName + (row.status == 1 ? '-禁用?' : '-启用?'), '提示', {
  243. confirmButtonText: '确定',
  244. cancelButtonText: '取消',
  245. type: 'warning'
  246. }).then(() => {
  247. ionline({ id: row.id, status: row.status == 1 ? 0 : 1 }).then((res) => {
  248. if (res.code == 200) {
  249. this.$message({
  250. type: 'success',
  251. message: '操作成功!'
  252. });
  253. this.getList();
  254. }
  255. });
  256. }).catch(() => {});
  257. },
  258. /** 删除按钮操作 */
  259. handleDelete(row) {
  260. this.$modal.confirm('是否确认删除"' + row.couponName + '"的数据项?').then(function() {
  261. return deleteById(row.id);
  262. }).then(() => {
  263. this.getList();
  264. this.$modal.msgSuccess("删除成功");
  265. }).catch(() => {});
  266. },
  267. /** 查看按钮操作 */
  268. seeCenter(obj, type) {
  269. this.visibleStatus = true
  270. this.visibleType = type;
  271. this.newObj = obj;
  272. }
  273. }
  274. };
  275. </script>