index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div class="couponManage app-container">
  3. <div class="search">
  4. <div>
  5. <el-input
  6. v-model="query.shopNameOrPhoneNum"
  7. size="small"
  8. placeholder="请输入优惠券名称"
  9. class="item-width-200"
  10. ></el-input>
  11. <el-date-picker
  12. v-model="date"
  13. size="small"
  14. value-format="timestamp"
  15. class="item-width-350 ml10"
  16. type="datetimerange"
  17. range-separator="至"
  18. start-placeholder="开始日期"
  19. end-placeholder="结束日期">
  20. </el-date-picker>
  21. <el-select
  22. v-model="query.shopMenuId"
  23. size="small"
  24. clearable
  25. class="item-width-200 ml10"
  26. placeholder="请选择类型"
  27. >
  28. <el-option
  29. v-for="item in options"
  30. :key="item.value"
  31. :label="item.label"
  32. :value="item.value"
  33. >
  34. </el-option>
  35. </el-select>
  36. <el-select
  37. v-model="query.state"
  38. size="small"
  39. class="item-width-200 ml10"
  40. placeholder="请选择状态"
  41. >
  42. <el-option
  43. v-for="item in options1"
  44. :key="item.value"
  45. :label="item.label"
  46. :value="item.value"
  47. >
  48. </el-option>
  49. </el-select>
  50. <el-button
  51. class="ml10"
  52. type="primary"
  53. size="small"
  54. icon="el-icon-search"
  55. @click="handleSearch"
  56. >
  57. 搜索
  58. </el-button>
  59. </div>
  60. <el-button
  61. class="add-btn"
  62. type="primary"
  63. size="small"
  64. @click="handleAdd(0)"
  65. >
  66. 添加
  67. </el-button>
  68. </div>
  69. <el-table
  70. :data="tableData"
  71. tooltip-effect="dark"
  72. border
  73. v-loading="loading"
  74. style="width: 100%"
  75. >
  76. <el-table-column
  77. align="center"
  78. label="优惠券名称"
  79. prop="shopName"
  80. show-overflow-tooltip
  81. >
  82. </el-table-column>
  83. <el-table-column
  84. prop="shopMenuId"
  85. align="center"
  86. label="优惠券类型"
  87. show-overflow-tooltip
  88. >
  89. </el-table-column>
  90. <el-table-column
  91. prop="shopMainName"
  92. align="center"
  93. label="优惠内容"
  94. show-overflow-tooltip
  95. >
  96. </el-table-column>
  97. <el-table-column
  98. prop="shopId"
  99. align="center"
  100. label="发放数量"
  101. show-overflow-tooltip
  102. >
  103. </el-table-column>
  104. <el-table-column
  105. prop="applyTime"
  106. align="center"
  107. label="已领取"
  108. show-overflow-tooltip
  109. >
  110. </el-table-column>
  111. <el-table-column
  112. prop="applyTime"
  113. align="center"
  114. label="剩余数量"
  115. show-overflow-tooltip
  116. >
  117. </el-table-column>
  118. <el-table-column
  119. prop="applyTime"
  120. align="center"
  121. label="已使用"
  122. show-overflow-tooltip
  123. >
  124. </el-table-column>
  125. <el-table-column
  126. prop="createTime"
  127. align="center"
  128. label="创建时间"
  129. show-overflow-tooltip
  130. >
  131. </el-table-column>
  132. <el-table-column
  133. align="center"
  134. prop="state"
  135. label="状态"
  136. show-overflow-tooltip
  137. >
  138. </el-table-column>
  139. <el-table-column prop="address" width="180px" fixed="right" align="center" label="操作">
  140. <template slot-scope="scope">
  141. <el-button
  142. type="text"
  143. size="small"
  144. @click="handleDetail(scope.row)"
  145. >查看</el-button
  146. >
  147. <el-button
  148. type="text"
  149. size="small"
  150. @click="handleDetail(scope.row)"
  151. >编辑</el-button
  152. >
  153. <el-button type="text" size="small" @click="handle(scope.row)">{{
  154. scope.row.state == 1 ? "停止" : "启用"
  155. }}</el-button>
  156. <el-button type="text" size="small" @click="handleDel(scope.row.shopId)"
  157. >删除</el-button
  158. >
  159. </template>
  160. </el-table-column>
  161. </el-table>
  162. <div class="page-box">
  163. <el-pagination
  164. @size-change="handleSizeChange"
  165. @current-change="handleCurrentChange"
  166. background
  167. :current-page="query.currentPage"
  168. :page-sizes="[10, 20, 30, 40]"
  169. :page-size="query.pageSize"
  170. layout="total, sizes, prev, pager, next, jumper"
  171. :total="total"
  172. >
  173. </el-pagination>
  174. </div>
  175. </div>
  176. </template>
  177. <script>
  178. import { debounce } from "@/utils/index";
  179. import { getList, updateState } from "@/api/shop";
  180. import {getMenuName} from '@/api/appConfig';
  181. import axios from 'axios'
  182. const BASE_URL = require('@/utils/config')
  183. export default {
  184. name: "couponManage",
  185. data() {
  186. return {
  187. tableData: [],
  188. options: [],
  189. options1: [
  190. {
  191. value: null,
  192. label: "全部状态",
  193. },
  194. {
  195. value: "1",
  196. label: "启用",
  197. },
  198. {
  199. value: "4",
  200. label: "禁用",
  201. },
  202. ],
  203. loading: false,
  204. query: {
  205. state: null,
  206. province: "",
  207. startTime:'',
  208. endTime:'',
  209. currentPage: 1,
  210. pageSize: 10,
  211. },
  212. total: 0,
  213. };
  214. },
  215. watch: {
  216. date(val){
  217. if(val){
  218. this.query.startTime = val[0]
  219. this.query.endTime = val[1]
  220. }else{
  221. this.query.startTime = ''
  222. this.query.endTime = ''
  223. }
  224. }
  225. },
  226. methods: {
  227. handleSearch(){
  228. this.query.currentPage = 1
  229. this.getList();
  230. },
  231. handleAdd(val) {
  232. this.$router.push({
  233. path: "/operationManage/couponManage/shopAdd" + (val || ""),
  234. });
  235. },
  236. handle(row) {
  237. let msg;
  238. if (row.state == 1) {
  239. msg = "禁用";
  240. } else {
  241. msg = "启用";
  242. }
  243. this.$confirm(`此操作将${msg}该商铺, 是否继续?`, "提示", {
  244. confirmButtonText: "确定",
  245. cancelButtonText: "取消",
  246. type: "warning",
  247. }).then(() => {
  248. updateState({
  249. shopId: row.shopId,
  250. state: row.state == 1 ? 4 : 1,
  251. }).then((res) => {
  252. if (res.state == "Success") {
  253. this.$notify({
  254. title: "成功",
  255. message: "操作成功",
  256. type: "success",
  257. });
  258. this.getList();
  259. }
  260. });
  261. });
  262. },
  263. handleEdit(id) {
  264. this.$router.push({
  265. path: "/operationManage/couponManage/shopAdd",
  266. query: {
  267. title: "店铺编辑",
  268. id,
  269. },
  270. });
  271. },
  272. handleDetail(id,title) {
  273. this.$router.push({
  274. path: "/operationManage/couponManage/shopAdd",
  275. query: {
  276. title: "店铺详情",
  277. id,
  278. },
  279. });
  280. },
  281. handleDel(shopId){
  282. this.$confirm(`此操作将删除该商铺, 是否继续?`, "提示", {
  283. confirmButtonText: "确定",
  284. cancelButtonText: "取消",
  285. type: "warning",
  286. }).then(() => {
  287. updateState({
  288. shopId,
  289. state: 3,
  290. }).then((res) => {
  291. if (res.state == "Success") {
  292. this.$notify({
  293. title: "成功",
  294. message: "操作成功",
  295. type: "success",
  296. });
  297. this.getList();
  298. }
  299. });
  300. });
  301. },
  302. handleSizeChange(val) {
  303. this.query.currentPage = 1;
  304. this.query.pageSize = val;
  305. this.getList();
  306. },
  307. handleCurrentChange(val) {
  308. this.query.currentPage = val;
  309. this.getList();
  310. },
  311. getList() {
  312. this.loading = true;
  313. getList(this.query).then((res) => {
  314. this.loading = false;
  315. if (res.state == "Success") {
  316. this.tableData = res.content.records;
  317. this.total = res.content.total;
  318. }
  319. });
  320. },
  321. },
  322. created() {
  323. this.getList();
  324. },
  325. };
  326. </script>
  327. <style lang="scss" scoped>
  328. .couponManage {
  329. .search {
  330. justify-content: space-between;
  331. .add-btn {
  332. // margin-right: 20px;
  333. }
  334. }
  335. }
  336. </style>