多租户商城-商户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

416 lines
12 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <!--
  2. * @FileDescription: selectChannelCoupons
  3. * @Author: kahu
  4. * @Date: 2022/8/25
  5. * @LastEditors: kahu
  6. * @LastEditTime: 2022/8/25
  7. -->
  8. <template>
  9. <el-dialog :close-on-click-modal="false" title="选择渠道优惠券" :visible.sync="diaShow" width="60%" append-to-body
  10. :before-close="handleClose">
  11. <div class="content">
  12. <div class="formSearch">
  13. <el-form :inline="true" :model="formInline" class="demo-form-inline">
  14. <el-form-item label="优惠券名称">
  15. <el-input v-model="formInline.couponName" maxlength="20" clearable :placeholder="$t('common.defaulthint')" @blur="search" />
  16. </el-form-item>
  17. <el-form-item label="优惠券类型">
  18. <el-select v-model="formInline.couponType" placeholder="请选择优惠券类型" @change="search">
  19. <el-option :label="$t('common.all')" :value="null" />
  20. <el-option label="满减券" value="1" />
  21. <el-option label="折扣券" value="2" />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="状态">
  25. <el-select v-model="formInline.state" placeholder="请选择优惠券状态" @change="search">
  26. <el-option :label="$t('common.all')" :value="null" />
  27. <el-option label="未开始" value="0" />
  28. <el-option label="进行中" value="1" />
  29. <el-option label="已结束" value="2" />
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item :label="$t('common.createTime')">
  33. <el-date-picker v-model="formInline.dates" type="datetimerange"
  34. :range-separator="$t('common.betweentime')"
  35. :start-placeholder="$t('common.startdate')"
  36. :end-placeholder="$t('common.enddate')"
  37. value-format="yyyy-MM-dd HH:mm:ss" @change="search" />
  38. </el-form-item>
  39. <el-form-item>
  40. <el-button type="primary" plain @click="search">{{ $t('common.query') }}
  41. </el-button>
  42. <el-button type="primary" plain @click="clear">{{ $t('common.reset') }}
  43. </el-button>
  44. <!-- <el-button type="primary" plain @click="addActivity">新增
  45. </el-button> -->
  46. </el-form-item>
  47. </el-form>
  48. </div>
  49. <!-- 表格 -->
  50. <div class="tableBox">
  51. <el-table ref="multipleTable" :data="tableData" border
  52. :header-cell-style="{ background: '#EEF3FF', color: '#333333' }" tooltip-effect="dark" style="width: 100%"
  53. :row-key="row => row.shopCouponId" @selection-change="handleTableSelection">
  54. <el-table-column type="selection" reserve-selection />
  55. <el-table-column label="优惠券名称" width="220">
  56. <template slot-scope="scope">{{ scope.row.couponName }}</template>
  57. </el-table-column>
  58. <el-table-column label="类型" show-overflow-tooltip>
  59. <template slot-scope="scope">
  60. <span v-if="scope.row.couponType === 1">满减券</span>
  61. <span v-if="scope.row.couponType === 2">折扣券</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="状态" show-overflow-tooltip>
  65. <template slot-scope="scope">
  66. <span v-if="scope.row.state === 0">未开始</span>
  67. <span v-if="scope.row.state === 1">进行中</span>
  68. <span v-if="scope.row.state === 2">已结束</span>
  69. </template>
  70. </el-table-column>
  71. <el-table-column prop="content" label="内容" show-overflow-tooltip />
  72. <el-table-column prop="createTime" :label="$t('common.createTime')" show-overflow-tooltip />
  73. </el-table>
  74. <div class="fenye">
  75. <el-pagination :current-page="formInline.page" :page-sizes="[10, 20, 50, 100]" :page-size="10"
  76. layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
  77. @current-change="handleCurrentChange" />
  78. </div>
  79. </div>
  80. </div>
  81. <span slot="footer" class="dialog-footer">
  82. <el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
  83. <el-button type="primary" @click="handleConfirm">{{ $t('common.sure') }}</el-button>
  84. </span>
  85. </el-dialog>
  86. </template>
  87. <script>
  88. import { getCoupon, delCoupon, getCouponData, stopCoupon } from '@/api/marketing'
  89. import activityMixin from '@/views/marketing/mixin/index.js'
  90. function CouponQueryForm() {
  91. this.type = 2
  92. this.couponName = '' // 优惠券名称
  93. this.couponType = null // 优惠券类型
  94. this.dates = [] // 创建时间数组
  95. this.endTime = '' // 创建时间结束时间
  96. this.page = 1 // 当前页
  97. this.pageSize = 10 // 每页记录数
  98. this.startTime = '' // 创建时间开始时间
  99. this.state = '1' // 优惠券状态
  100. this.takeEnd = '2022-01-01 00:00:00' // 活动结束时间
  101. this.stockNumber = 1 // 库存限制
  102. }
  103. export default {
  104. name: 'ChannelManage',
  105. mixins: [activityMixin],
  106. model: {
  107. prop: 'showSelect',
  108. event: 'change'
  109. },
  110. props: {
  111. showSelect: {
  112. type: Boolean,
  113. default: () => false
  114. },
  115. defaultSelection: {
  116. type: Array,
  117. default() { return [] }
  118. },
  119. takeEnd: {
  120. type: String,
  121. default: () => '2022-01-01 00:00:00'
  122. },
  123. stockNumber: {
  124. type: Number,
  125. default: () => 1
  126. }
  127. },
  128. data() {
  129. return {
  130. formInline: new CouponQueryForm(),
  131. isDataVisible: false, // 数据效果展示
  132. dataInfo: [], // 商品使用数据
  133. total: 1,
  134. tableData: [],
  135. dataEffect: [],
  136. selection: [],
  137. }
  138. },
  139. computed: {
  140. diaShow: {
  141. get() {
  142. return this.showSelect
  143. },
  144. set(value) {
  145. this.$emit('change', value)
  146. }
  147. },
  148. },
  149. watch: {
  150. 'defaultSelection': {
  151. deep: true,
  152. handler(val) {
  153. this.$nextTick(() => {
  154. this.selection = val
  155. this.handleManageSelection()
  156. })
  157. }
  158. },
  159. 'diaShow'(val) {
  160. if (val) {
  161. this.formInline.takeEnd = this.takeEnd
  162. this.formInline.stockNumber = this.stockNumber
  163. this.getAll(this.formInline)
  164. } else {
  165. this.tableData = []
  166. }
  167. }
  168. },
  169. mounted() {
  170. // this.getAll(this.formInline)
  171. },
  172. methods: {
  173. handleManageSelection() {
  174. // 清空所有选中
  175. this.$refs.multipleTable?.clearSelection()
  176. this.tableData.forEach(tableData => {
  177. const find = this.defaultSelection.find(item => item.shopCouponId === tableData.shopCouponId);
  178. if (find) {
  179. // 勾选指定行
  180. this.$nextTick(() => {
  181. this.$refs.multipleTable.toggleRowSelection(tableData, true)
  182. })
  183. }
  184. })
  185. },
  186. handleTableSelection(selection) {
  187. this.selection = selection
  188. },
  189. handleClose() {
  190. this.$emit('cancel', this.selection)
  191. this.selection = []
  192. this.diaShow = false
  193. },
  194. handleConfirm() {
  195. this.$emit('confirm', this.selection)
  196. this.selection = []
  197. this.diaShow = false
  198. },
  199. closeModal() {
  200. this.$refs.addCoupon.resetData()
  201. },
  202. // 查询
  203. search() {
  204. this.total = 1
  205. this.formInline.page = 1
  206. if (this.formInline.dates && this.formInline.dates.length !== 0) {
  207. this.formInline.startTime = this.formInline.dates[0]
  208. this.formInline.endTime = this.formInline.dates[1]
  209. } else {
  210. delete (this.formInline.startTime)
  211. delete (this.formInline.endTime)
  212. }
  213. this.getAll(this.formInline)
  214. },
  215. // 清除
  216. clear() {
  217. this.formInline = new CouponQueryForm()
  218. this.formInline.takeEnd = this.takeEnd
  219. this.formInline.stockNumber = this.stockNumber
  220. this.getAll(this.formInline)
  221. },
  222. handleSizeChange(val) {
  223. this.formInline.pageSize = val
  224. this.getAll(this.formInline)
  225. },
  226. handleCurrentChange(val) {
  227. this.formInline.page = val
  228. this.getAll(this.formInline)
  229. },
  230. // 停止优惠券活动
  231. stopFn(id) {
  232. stopCoupon({ shopCouponId: id }).then(res => {
  233. if (res.code === '') {
  234. this.$message.success('停止成功')
  235. this.formInline.page = 1
  236. this.getAll(this.formInline)
  237. } else {
  238. this.$message.error(res.message)
  239. }
  240. })
  241. },
  242. // 初始化查询所有数据
  243. async getAll(formInline) {
  244. const res = await getCoupon(formInline)
  245. this.total = res.data.total
  246. this.tableData = res.data.list
  247. this.handleManageSelection()
  248. },
  249. // 显示数据效果
  250. showData(id) {
  251. getCouponData({ shopCouponId: id }).then(res => {
  252. if (res.code === '') {
  253. this.dataInfo = res.data
  254. } else {
  255. this.$message.error(res.message)
  256. }
  257. })
  258. this.isDataVisible = true
  259. },
  260. // 删除优惠券
  261. delCouponFn(data) {
  262. delCoupon({ shopCouponId: data.shopCouponId }).then(res => {
  263. if (res.code === '') {
  264. this.$message.success(this.$t('common.deletesuccess'))
  265. this.formInline.page = 1
  266. this.getAll(this.formInline)
  267. } else {
  268. this.$message.error(res.message)
  269. }
  270. })
  271. }
  272. }
  273. }
  274. </script>
  275. <style
  276. lang="scss"
  277. scoped
  278. >
  279. //@import url(); 引入公共css类
  280. @import url("../../../styles/elDialog.scss");
  281. .content {
  282. overflow: hidden;
  283. .el-form-item {
  284. label.el-form-item__label {
  285. font-size: 16px !important;
  286. color: red !important;
  287. }
  288. }
  289. .detail_title {
  290. font-size: 16px;
  291. font-weight: 500;
  292. padding-left: 10px;
  293. line-height: 16px;
  294. margin-bottom: 15px;
  295. margin-top: 10px;
  296. position: relative;
  297. &::before {
  298. content: "";
  299. height: 16px;
  300. width: 4px;
  301. background-color: #183ECD;
  302. position: absolute;
  303. left: 0px;
  304. display: block;
  305. font-weight: 500;
  306. }
  307. }
  308. ::v-deep .el-form-item__label {
  309. vertical-align: middle;
  310. float: left;
  311. padding: 0 12px 0 0;
  312. -webkit-box-sizing: border-box;
  313. box-sizing: border-box;
  314. font-size: 14px;
  315. font-family: PingFang SC;
  316. font-weight: 400;
  317. color: #404F64;
  318. line-height: 36px;
  319. text-align: left;
  320. }
  321. }
  322. .footer {
  323. height: 80px;
  324. line-height: 80px;
  325. font-size: 24px;
  326. position: relative;
  327. border-top: 1px solid #e0e5eb;
  328. .btn_list {
  329. position: absolute;
  330. right: 0;
  331. top: 0;
  332. height: 36px;
  333. span {
  334. padding: 0;
  335. margin: 0;
  336. width: 68px;
  337. height: 36px;
  338. line-height: 36px;
  339. text-align: center;
  340. display: inline-block;
  341. /* font-size: 16px; */
  342. border-radius: 4px;
  343. -webkit-box-sizing: border-box;
  344. box-sizing: border-box;
  345. font-size: 14px;
  346. font-family: PingFang SC;
  347. font-weight: 400;
  348. &:hover {
  349. cursor: pointer;
  350. }
  351. &:nth-child(1) {
  352. background: rgba(255, 255, 255, 1);
  353. order: 1px solid rgba(224, 229, 235, 1);
  354. margin-right: 10px;
  355. border: 1px solid rgba(224, 229, 235, 1);
  356. }
  357. &:nth-child(2) {
  358. background: #183ECD;
  359. color: #fff;
  360. }
  361. }
  362. }
  363. }
  364. .fenye {
  365. margin-top: 20px;
  366. }
  367. .dataEffect {
  368. .couponTit {
  369. margin: 20px 0;
  370. }
  371. .dataListBox {
  372. display: flex;
  373. justify-content: center;
  374. margin: 30px 0;
  375. .dataItem {
  376. width: 220px;
  377. height: 120px;
  378. border-radius: 8px;
  379. border: 1px solid #999999;
  380. text-align: center;
  381. margin: 0 10px;
  382. span {
  383. display: block;
  384. margin-top: 35px;
  385. }
  386. }
  387. }
  388. .tabListInfo {
  389. margin: 20px 0;
  390. }
  391. }
  392. </style>