index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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" width="120"/>
  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" width="100">
  71. <template slot-scope="scope">
  72. <span v-if="scope.row.useUserType==1">所有用户</span>
  73. <span v-if="scope.row.useUserType==2">指定分销商</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="使用剧目" align="center" prop="usePerformName" width="120" />
  77. <el-table-column label="使用票务" align="center" prop="useGoodName" />
  78. <el-table-column label="使用时间类型" align="center" prop="useType" width="120">
  79. <template slot-scope="scope">
  80. <span v-if="scope.row.useType==1">指定周期</span>
  81. <span v-if="scope.row.useType==2">领取后计算</span>
  82. <!-- <dict-tag :options="dict.type.template_ident" :value="scope.row.templateIdent"/> -->
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="使用时间" align="center" prop="useStartDate" width="140">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.useType==1">{{scope.row.useStartDate}}至{{scope.row.useEndDate}}</span>
  88. <span v-if="scope.row.useType==2">领取{{scope.row.useDay}}小时后失效</span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column label="创建时间" align="center" prop="createTime" width="160">
  92. <template slot-scope="scope">
  93. <span>{{ parseTime(scope.row.createTime) }}</span>
  94. </template>
  95. </el-table-column>
  96. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  97. <template slot-scope="scope">
  98. <!-- <el-button
  99. size="mini"
  100. type="text"
  101. @click="ionlineApi(scope.row)"
  102. v-hasPermi="['marketing:coupon:edit']"
  103. >{{scope.row.status == '1' ? '禁用' : '启用'}}</el-button> -->
  104. <el-button
  105. size="mini"
  106. type="text"
  107. @click="handleUpdate(scope.row)"
  108. v-hasPermi="['marketing:coupon:edit']"
  109. >编辑</el-button>
  110. <el-button
  111. size="mini"
  112. type="text"
  113. @click="handleDelete(scope.row,scope.index)"
  114. v-hasPermi="['marketing:coupon:delete']"
  115. >删除</el-button>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. <pagination
  120. v-show="total>0"
  121. :total="total"
  122. :page.sync="queryParams.pageNum"
  123. :limit.sync="queryParams.pageSize"
  124. @pagination="getList"
  125. />
  126. <!-- 新增/编辑弹框 -->
  127. <add-and-edit
  128. ref="addAndEdit"
  129. :dict="dict"
  130. @getList="getList"
  131. />
  132. <el-dialog
  133. title="查看"
  134. :visible.sync="visibleStatus"
  135. width="600px"
  136. :destroy-on-close="true"
  137. :close-on-click-modal="false"
  138. >
  139. <div v-if="visibleType == 'img'">
  140. <el-image
  141. style="width: 400px; height: 100%"
  142. :src="newObj.mainImg"
  143. fit="cover"
  144. />
  145. </div>
  146. <div v-if="visibleType == 'html'">
  147. <div v-html="newObj.centent"></div>
  148. </div>
  149. <div slot="footer" class="dialog-footer">
  150. <el-button type="primary" @click="visibleStatus = false">确 定</el-button>
  151. </div>
  152. </el-dialog>
  153. </div>
  154. </template>
  155. <script>
  156. import { pageList, deleteById, ionline,resetPwd } from '@/api/coupon/coupon'
  157. import addAndEdit from "./dialog/addAndEdit.vue";
  158. export default {
  159. name: "Coupon",
  160. dicts: ['template_ident'],
  161. components: { addAndEdit },
  162. data() {
  163. return {
  164. // 遮罩层
  165. loading: true,
  166. // 选中数组
  167. ids: [],
  168. // 非单个禁用
  169. single: true,
  170. // 非多个禁用
  171. multiple: true,
  172. // 显示搜索条件
  173. showSearch: true,
  174. // 总条数
  175. total: 0,
  176. // 用户表格数据
  177. dataList: null,
  178. // 弹出层标题
  179. title: "",
  180. // 是否显示弹出层
  181. open: false,
  182. // 日期范围
  183. dateRange: [],
  184. // 查询参数
  185. queryParams: {
  186. pageNum: 1,
  187. pageSize: 10,
  188. type: undefined
  189. },
  190. visibleStatus: false,
  191. newObj: {},
  192. visibleType: ''
  193. };
  194. },
  195. created() {
  196. this.getList();
  197. },
  198. methods: {
  199. /** 查询列表 */
  200. getList() {
  201. this.loading = true;
  202. pageList(this.addDateRange(this.queryParams, this.dateRange))
  203. .then(response => {
  204. this.dataList = response.data.rows;
  205. this.total = response.data.total;
  206. this.loading = false;
  207. }
  208. );
  209. },
  210. // 取消按钮
  211. cancel() {
  212. this.open = false;
  213. },
  214. /** 搜索按钮操作 */
  215. handleQuery() {
  216. this.queryParams.pageNum = 1;
  217. this.getList();
  218. },
  219. /** 重置按钮操作 */
  220. resetQuery() {
  221. this.dateRange = [];
  222. this.$set(this.queryParams, 'couponName', '');
  223. this.$set(this.queryParams, 'status', '');
  224. this.queryParams.pageNum = 1;
  225. this.handleQuery();
  226. },
  227. // 多选框选中数据
  228. handleSelectionChange(selection) {
  229. this.ids = selection.map(item => item.userId);
  230. this.single = selection.length != 1;
  231. this.multiple = !selection.length;
  232. },
  233. /** 新增按钮操作 */
  234. handleAdd() {
  235. this.$refs["addAndEdit"].openDialog("新增数据", null);
  236. },
  237. /** 修改按钮操作 */
  238. handleUpdate(row) {
  239. this.$refs["addAndEdit"].openDialog("修改数据", row);
  240. },
  241. /** 发布或者取消发布按钮操作 */
  242. ionlineApi(row) {
  243. this.$confirm("是否对-" + row.couponName + (row.status == 1 ? '-禁用?' : '-启用?'), '提示', {
  244. confirmButtonText: '确定',
  245. cancelButtonText: '取消',
  246. type: 'warning'
  247. }).then(() => {
  248. ionline({ id: row.id, status: row.status == 1 ? 0 : 1 }).then((res) => {
  249. if (res.code == 200) {
  250. this.$message({
  251. type: 'success',
  252. message: '操作成功!'
  253. });
  254. this.getList();
  255. }
  256. });
  257. }).catch(() => {});
  258. },
  259. /** 删除按钮操作 */
  260. handleDelete(row) {
  261. this.$modal.confirm('是否确认删除"' + row.couponName + '"的数据项?').then(function() {
  262. return deleteById(row.id);
  263. }).then(() => {
  264. this.getList();
  265. this.$modal.msgSuccess("删除成功");
  266. }).catch(() => {});
  267. },
  268. /** 查看按钮操作 */
  269. seeCenter(obj, type) {
  270. this.visibleStatus = true
  271. this.visibleType = type;
  272. this.newObj = obj;
  273. }
  274. }
  275. };
  276. </script>