leisure-core 0.1.9 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,194 @@
1
+ <template>
2
+ <div>
3
+ <el-table :data="tableData" border row-key="id" stripe style="width: 100%">
4
+ <el-table-column prop="title" label="标题"></el-table-column>
5
+ <el-table-column align="center" prop="ctype" label="类型">
6
+ <template slot-scope="scope">
7
+ <span v-if="scope.row.ctype == 1">满减</span>
8
+ <span v-if="scope.row.ctype == 2">折扣</span>
9
+ </template>
10
+ </el-table-column>
11
+ <el-table-column
12
+ align="center"
13
+ prop="minmoney"
14
+ label="门槛(单位:元)"
15
+ ></el-table-column>
16
+ <el-table-column align="center" prop="place" label="适用对象">
17
+ <template slot-scope="scope">
18
+ <span v-if="scope.row.place == 1">商城</span>
19
+ <span v-if="scope.row.place == 2">旅游</span>
20
+ <span v-if="scope.row.place == 3">商城,旅游均可以使用</span>
21
+ </template>
22
+ </el-table-column>
23
+ <el-table-column
24
+ align="center"
25
+ prop="quantity"
26
+ label="发放数量(张)"
27
+ ></el-table-column>
28
+ <el-table-column align="center" prop="receiveType" label="发放方式">
29
+ <template slot-scope="scope">
30
+ <span v-if="scope.row.receiveType == 0">人工发放</span>
31
+ <span v-if="scope.row.receiveType == 1">系统发放</span>
32
+ </template>
33
+ </el-table-column>
34
+ <el-table-column align="center" label="是否已启用">
35
+ <template slot-scope="scope">
36
+ {{ scope.row.enbled == 1 ? "已启用" : "已停用" }}
37
+ </template>
38
+ </el-table-column>
39
+ <el-table-column align="center" label="是否叠加">
40
+ <template slot-scope="scope">
41
+ {{ scope.row.is_can_superpose == 1 ? "是 " : "否" }}
42
+ </template>
43
+ </el-table-column>
44
+ <el-table-column
45
+ align="center"
46
+ prop="cdate"
47
+ label="发布日期 "
48
+ :formatter="dateFormatter"
49
+ ></el-table-column>
50
+ <el-table-column
51
+ fixed="right"
52
+ label="操作"
53
+ align="center"
54
+ width="320"
55
+ row
56
+ >
57
+ <template slot-scope="scope">
58
+ <el-button
59
+ v-if="scope.row.enbled != 1"
60
+ type="primary"
61
+ size="small"
62
+ @click="openCoupon(scope.row)"
63
+ >启用</el-button
64
+ >
65
+ <el-button
66
+ v-else
67
+ type="primary"
68
+ size="small"
69
+ @click="closeCoupon(scope.row)"
70
+ >停用</el-button
71
+ >
72
+ <el-button type="primary" size="small" @click="isSystem(scope.row)">{{
73
+ componBtnText(scope.row)
74
+ }}</el-button>
75
+ <el-button
76
+ type="primary"
77
+ size="small"
78
+ @click="openEditWindow(scope.row)"
79
+ >编辑</el-button
80
+ >
81
+ <el-popconfirm
82
+ :title="`该操作不可逆,确定删除?`"
83
+ @confirm="del(scope.row.id)"
84
+ >
85
+ <template #reference>
86
+ <el-button type="primary" size="small" style="margin-left: 10px"
87
+ >删除</el-button
88
+ >
89
+ </template>
90
+ </el-popconfirm>
91
+ </template>
92
+ </el-table-column>
93
+ </el-table>
94
+ <div style="text-align: center; margin-top: 30px">
95
+ <el-pagination
96
+ background
97
+ layout="prev, pager, next"
98
+ :total="searchData.total"
99
+ :page-size="10"
100
+ @current-change="current_change"
101
+ >></el-pagination
102
+ >
103
+ </div>
104
+ </div>
105
+ </template>
106
+ <script>
107
+ import moment from "moment";
108
+ import {
109
+ list,
110
+ edit,
111
+ del,
112
+ openCoupon,
113
+ closeCoupon,
114
+ isSystem,
115
+ } from "@/api/coupon";
116
+ export default {
117
+ name: "le-coupon",
118
+ data() {
119
+ return {
120
+ tableData: [],
121
+ searchData: {
122
+ pageNo: 1,
123
+ total: 1,
124
+ },
125
+ };
126
+ },
127
+ mounted() {
128
+ this.list();
129
+ },
130
+ methods: {
131
+ openCoupon(row) {
132
+ openCoupon(row.id).then((response) => {
133
+ this.list();
134
+ this.$message.success(response.data.info);
135
+ });
136
+ },
137
+ closeCoupon(row) {
138
+ closeCoupon(row.id).then((response) => {
139
+ this.list();
140
+ this.$message.success(response.data.info);
141
+ });
142
+ },
143
+ dateFormatter(row) {
144
+ return moment.unix(row.cdate).format("YYYY-MM-DD HH:mm:ss");
145
+ },
146
+ current_change(currentPage) {
147
+ this.searchData.pageNo = currentPage;
148
+ this.list();
149
+ },
150
+ list() {
151
+ let params = {
152
+ pageNo: this.searchData.pageNo,
153
+ };
154
+ list(params).then((res) => {
155
+ this.tableData = res.data.data.list;
156
+ this.searchData.total = res.data.data.count;
157
+ });
158
+ },
159
+ del(id) {
160
+ del(id).then((response) => {
161
+ this.list();
162
+ this.$message.success(response.data.info);
163
+ });
164
+ },
165
+ openEditWindow(item) {
166
+ let routeData = {
167
+ name: "coupon-edit",
168
+ params: JSON.parse(JSON.stringify(item)),
169
+ };
170
+ routeData.params.status = 0;
171
+ this.$router.push(routeData);
172
+ },
173
+ componBtnText(item) {
174
+ if (item.receiveType == 1) {
175
+ return "改为手工劵";
176
+ } else {
177
+ return "改为系统劵";
178
+ }
179
+ },
180
+ isSystem(item) {
181
+ let param = {};
182
+ param.id = item.id;
183
+ if (item.receiveType == 0) {
184
+ param.receiveType = 1;
185
+ } else {
186
+ param.receiveType = 0;
187
+ }
188
+ isSystem(param).then(() => {
189
+ item.receiveType = param.receiveType;
190
+ });
191
+ },
192
+ },
193
+ };
194
+ </script>
@@ -0,0 +1,362 @@
1
+ <template>
2
+ <div class="divContainer">
3
+ <el-form ref="form" :model="form" :rules="rules" label-width="130px">
4
+ <el-form-item label="优惠券标题" prop="title">
5
+ <el-input v-model="form.title"></el-input>
6
+ </el-form-item>
7
+ <el-form-item label="优惠券描述" prop="caption">
8
+ <el-input v-model="form.caption">
9
+ <template slot="append">例如:无门槛使用,满1000减100等 </template>
10
+ </el-input>
11
+ </el-form-item>
12
+ <el-form-item label="适用条件" prop="minmoney">
13
+ <el-input-number
14
+ v-model="form.minmoney"
15
+ :min="0"
16
+ :max="9999"
17
+ ></el-input-number>
18
+ <span style="padding-left: 10px"
19
+ >单位:元 (如果满1000减100,则需要填写1000)</span
20
+ >
21
+ </el-form-item>
22
+ <el-form-item label="优惠金额" prop="discount">
23
+ <el-input-number
24
+ v-model="form.discount"
25
+ :min="0"
26
+ :max="9999"
27
+ ></el-input-number>
28
+ <span style="padding-left: 10px"
29
+ >如果满1000减100,则需要填写100,如果8折,折需要填写0.8</span
30
+ >
31
+ </el-form-item>
32
+ <el-form-item label="优惠券类型" prop="ctype">
33
+ <el-row>
34
+ <el-col :span="6">
35
+ <el-radio-group v-model="form.ctype">
36
+ <el-radio :label="1">满减</el-radio>
37
+ <el-radio :label="2">折扣</el-radio>
38
+ </el-radio-group>
39
+ </el-col>
40
+ <el-col :span="18">
41
+ <span style="margin-left: 6px"
42
+ >例如:如果消费满1000减100;5.5折则代表总价*55%
43
+ </span>
44
+ </el-col>
45
+ </el-row>
46
+ </el-form-item>
47
+ <el-form-item label="优惠券属性" prop="is_can_superpose">
48
+ <el-row>
49
+ <el-col :span="6">
50
+ <el-radio-group v-model="form.is_can_superpose">
51
+ <el-radio :label="0">不能叠加</el-radio>
52
+ <el-radio :label="1">可以叠加</el-radio>
53
+ </el-radio-group>
54
+ </el-col>
55
+ <el-col :span="18">
56
+ <span style="margin-left: 6px"
57
+ >如果可以叠加,则游客在购物时,可以同时使用多张优惠券
58
+ </span>
59
+ </el-col>
60
+ </el-row>
61
+ </el-form-item>
62
+ <el-form-item v-if="false" label="优惠券有效期" prop="period">
63
+ <el-row>
64
+ <el-input-number
65
+ v-model="form.period"
66
+ :min="1"
67
+ :max="9999"
68
+ label="描述文字"
69
+ ></el-input-number>
70
+ <span style="margin-left: 6px">单位:天</span>
71
+ </el-row>
72
+ </el-form-item>
73
+ <!-- <el-form-item label="优惠券使用范围" prop="rang">
74
+ <el-input v-model="form.rang"></el-input>
75
+ </el-form-item> -->
76
+ <el-form-item label="优惠券数量" prop="quantity">
77
+ <el-input-number
78
+ v-model="form.quantity"
79
+ :min="1"
80
+ :max="9999999"
81
+ ></el-input-number>
82
+ <span style="margin-left: 6px">单位:张</span>
83
+ </el-form-item>
84
+ <el-form-item label="开始日期" prop="date_start">
85
+ <el-date-picker
86
+ value-format="timestamp"
87
+ v-model="form.date_start"
88
+ type="date"
89
+ placeholder="开始日期"
90
+ >
91
+ </el-date-picker>
92
+ </el-form-item>
93
+ <el-form-item label="结束日期" prop="date_end">
94
+ <el-date-picker
95
+ value-format="timestamp"
96
+ v-model="form.date_end"
97
+ type="date"
98
+ placeholder="结束日期"
99
+ >
100
+ </el-date-picker>
101
+ </el-form-item>
102
+ <el-form-item label="适用场景">
103
+ <el-select v-model="form.place" placeholder="请选择">
104
+ <el-option label="商城" value="1" key="1"></el-option>
105
+ <el-option label="旅游" value="2" key="2"></el-option>
106
+ <el-option label="全部" value="3" key="3"></el-option>
107
+ </el-select>
108
+ </el-form-item>
109
+ <el-form-item label="使用范围">
110
+ <el-radio-group v-model="form.crang">
111
+ <el-radio :label="1">全部商品</el-radio>
112
+ <el-radio :label="2">部分商品可用</el-radio>
113
+ <!-- <el-radio :label="3">部分商品不可用</el-radio> -->
114
+ </el-radio-group>
115
+ </el-form-item>
116
+ <el-form-item label="选择商品" v-if="form.crang == 2 || form.crang == 3">
117
+ <el-select
118
+ v-model="form.crang_product"
119
+ multiple
120
+ filterable
121
+ remote
122
+ reserve-keyword
123
+ placeholder="输入商品编码或名称关键字"
124
+ :remote-method="getGoodsMethod"
125
+ :loading="loading"
126
+ >
127
+ <el-option
128
+ v-for="item in goodsList"
129
+ :key="item.gcode + '-' + item.gname"
130
+ :label="item.gcode + '-' + item.gname"
131
+ :value="item.gcode + '-' + item.gname"
132
+ >
133
+ </el-option>
134
+ </el-select>
135
+ </el-form-item>
136
+ <el-form-item label="是否启用">
137
+ <el-select v-model="form.enbled">
138
+ <el-option label="是" value="1" key="1"></el-option>
139
+ <el-option label="否" value="0" key="0"></el-option>
140
+ </el-select>
141
+ </el-form-item>
142
+ <el-form-item label="使用须知" prop="note">
143
+ <el-input v-model="form.rules" type="textarea" :rows="5"></el-input>
144
+ </el-form-item>
145
+ <el-form-item label="备注" prop="note">
146
+ <el-input v-model="form.note"></el-input>
147
+ </el-form-item>
148
+ <el-form-item>
149
+ <el-button type="primary" @click="onSubmit">{{
150
+ btnText.dispComment
151
+ }}</el-button>
152
+ <el-button @click="resetForm()">返回</el-button>
153
+ </el-form-item>
154
+ </el-form>
155
+ </div>
156
+ </template>
157
+ <script>
158
+ import { add, edit } from "@/api/coupon";
159
+ import GoodsSpuApi from "@/api/goods_spu";
160
+ export default {
161
+ name: "le-coupon-sub",
162
+ data() {
163
+ return {
164
+ btnText: {
165
+ dispComment: this.$route.params.status == 1 ? "保存" : "保存",
166
+ },
167
+ loading: false,
168
+ goodsList: [],
169
+ form: {
170
+ id: "",
171
+ title: "",
172
+ discount: 0,
173
+ minmoney: 9999,
174
+ ctype: 1,
175
+ caption: "",
176
+ period: 0,
177
+ rules: "",
178
+ rang: "",
179
+ quantity: 99999,
180
+ is_can_superpose: 0,
181
+ place: "1",
182
+ date_start: "",
183
+ date_end: "",
184
+ enbled: "0",
185
+ note: "",
186
+ crang: 1,
187
+ crang_product: [], //限制商品范围
188
+ },
189
+ rules: {
190
+ title: [
191
+ { required: true, message: "请输入标题", trigger: "blur" },
192
+ {
193
+ min: 1,
194
+ max: 100,
195
+ message: "长度在 1 到 100 个字符",
196
+ trigger: "blur",
197
+ },
198
+ ],
199
+ discount: [
200
+ { required: true, message: "请输入折扣金额", trigger: "blur" },
201
+ ],
202
+ minmoney: [
203
+ {
204
+ required: true,
205
+ message: "请输入优惠券的使用条件",
206
+ trigger: "blur",
207
+ },
208
+ ],
209
+ ctype: [{ required: true, message: "请选择类型", trigger: "blur" }],
210
+ period: [
211
+ {
212
+ required: true,
213
+ message: "请输入有效期",
214
+ trigger: "blur",
215
+ },
216
+ {
217
+ type: "number",
218
+ message: "有效期必须是数字",
219
+ trigger: "blur",
220
+ },
221
+ ],
222
+ quantity: [
223
+ {
224
+ required: true,
225
+ message: "请输入优惠券数量",
226
+ trigger: "blur",
227
+ },
228
+ ],
229
+ place: [
230
+ {
231
+ required: true,
232
+ message: "请输入优惠券适用场景",
233
+ trigger: "blur",
234
+ },
235
+ ],
236
+ date_start: [
237
+ {
238
+ required: true,
239
+ message: "请选择开始日期",
240
+ trigger: "blur",
241
+ },
242
+ ],
243
+ date_end: [
244
+ {
245
+ required: true,
246
+ message: "请选择结束日期",
247
+ trigger: "blur",
248
+ },
249
+ ],
250
+ note: [
251
+ {
252
+ max: 200,
253
+ message: "长度在 0 到 200个字符",
254
+ trigger: "blur",
255
+ },
256
+ ],
257
+ },
258
+ };
259
+ },
260
+ mounted() {
261
+ if (this.$route.params.status === 0 || this.$route.params.status === 0) {
262
+ this.form = this.$route.params;
263
+
264
+ if (this.form.enbled == 1) {
265
+ this.form.enbled = "1";
266
+ } else {
267
+ this.form.enbled = "0";
268
+ }
269
+ this.form.place = this.form.place + "";
270
+
271
+ if (this.form.crang == 2 || this.form.crang == 3) {
272
+ if (
273
+ !this.form.crang_product ||
274
+ (this.form.crang_product && this.form.crang_product.length == 0)
275
+ ) {
276
+ this.form.crang_product = [];
277
+ } else {
278
+ this.form.crang_product = this.form.crang_product.split(",");
279
+ }
280
+ }
281
+ this.form.date_start = new Date(this.form.date_start * 1000);
282
+ this.form.date_end = new Date(this.form.date_end * 1000);
283
+ }
284
+ },
285
+ methods: {
286
+ onSubmit() {
287
+ this.$refs["form"].validate((valid) => {
288
+ if (valid) {
289
+ let param = JSON.parse(JSON.stringify(this.form));
290
+ param.uid = this.$store.getters.userinfo.id;
291
+ if (param.enbled == "1") {
292
+ param.enbled = 1;
293
+ } else {
294
+ param.enbled = 0;
295
+ }
296
+ if (param.date_start) {
297
+ param.date_start = new Date(param.date_start).getTime() / 1000;
298
+ }
299
+ if (param.date_end) {
300
+ param.date_end = new Date(param.date_end).getTime() / 1000;
301
+ }
302
+
303
+ if (param.crang == 2 || param.crang == 3) {
304
+ if (param.crang_product && param.crang_product.length > 0) {
305
+ param.crang_product = param.crang_product.toString();
306
+ } else {
307
+ this.$message.error(
308
+ "该优惠券设置部分商品可用,必须定义使用的商品!"
309
+ );
310
+ }
311
+ } else {
312
+ param.crang_product = "";
313
+ }
314
+
315
+ if (this.$route.params.status == 1) {
316
+ add(param).then((response) => {
317
+ this.$message.success(response.data.info);
318
+ this.resetForm();
319
+ });
320
+ } else {
321
+ edit(param).then((res) => {
322
+ this.$message.success(res.data.info);
323
+ this.resetForm();
324
+ });
325
+ }
326
+ } else {
327
+ return false;
328
+ }
329
+ });
330
+ },
331
+ getGoodsMethod(query) {
332
+ if (query !== "") {
333
+ this.loading = true;
334
+ let param = {};
335
+ param.searchComment = query;
336
+ GoodsSpuApi.listSearch({ params: param })
337
+ .then((res) => {
338
+ this.loading = false;
339
+ this.goodsList = res.data.data;
340
+ })
341
+ .catch(() => {
342
+ this.loading = false;
343
+ });
344
+ } else {
345
+ this.goodsList = [];
346
+ }
347
+ },
348
+ resetForm() {
349
+ let routeData = {
350
+ name: "coupon-list",
351
+ };
352
+ this.$router.push(routeData);
353
+ },
354
+ },
355
+ };
356
+ </script>
357
+ <style lang="scss" scoped>
358
+ .divContainer {
359
+ height: calc(100vh - 130px);
360
+ overflow: auto;
361
+ }
362
+ </style>
@@ -0,0 +1,12 @@
1
+ import LeHelp from "./src/main.vue";
2
+ import LeHelpDetail from "./src/detail.vue";
3
+
4
+ LeHelp.install = function (Vue) {
5
+ Vue.component(LeHelp.name, LeHelp);
6
+ };
7
+
8
+ LeHelpDetail.install = function (Vue) {
9
+ Vue.component(LeHelpDetail.name, LeHelpDetail);
10
+ };
11
+
12
+ export { LeHelp, LeHelpDetail };
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <div class="le-help">
3
+ <div class="title">{{ title }}</div>
4
+ <div class="comment" v-html="comment"></div>
5
+ </div>
6
+ </template>
7
+ <script>
8
+ export default {
9
+ name: "le-help-detail",
10
+ props: {
11
+ title: {
12
+ type: String,
13
+ default: "",
14
+ },
15
+ comment: {
16
+ type: String,
17
+ default: "",
18
+ },
19
+ },
20
+ methods: {},
21
+ };
22
+ </script>
23
+ <style lang="scss" scoped>
24
+ .le-help {
25
+ display: flex;
26
+ display: -webkit-flex;
27
+ flex-direction: column;
28
+
29
+ .title {
30
+ text-align: center;
31
+ font-weight: bold;
32
+ font-size: 26px;
33
+ }
34
+
35
+ .comment {
36
+ max-height: 650px;
37
+ overflow-y: auto;
38
+ }
39
+ }
40
+ </style>