1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
| <template>
| <div class="product-add" v-loading="loading">
| <el-tabs v-model="activeName" type="card">
| <el-tab-pane label="基本信息" name="basic"></el-tab-pane>
| <el-tab-pane label="领取设置" name="set"></el-tab-pane>
| </el-tabs>
| <!--form表单-->
| <el-form size="small" ref="form" :model="form" label-width="180px" v-if="!loading">
| <!--基础信息-->
| <Basic v-show="activeName == 'basic'"></Basic>
| <!--高级设置-->
| <Set v-show="activeName == 'set'"></Set>
| <!--提交-->
| <div class="common-button-wrapper">
| <el-button size="small" type="info" @click="cancelFunc">取消</el-button>
| <el-button size="small" type="primary" @click="onSubmit" :disabled="save_loading">提交</el-button>
| </div>
| </el-form>
| </div>
| </template>
|
| <script>
| import CardApi from '@/api/card.js';
| import Basic from './part/Basic.vue';
| import Set from './part/set.vue';
| import {
| formatModel
| } from '@/utils/base.js';
| export default {
| components: {
| /*基础信息*/
| Basic,
| /*高级设置*/
| Set
| },
| data() {
| return {
| activeName: 'basic',
| /*会员卡ID*/
| card_id: 0,
| /*是否正在加载*/
| loading: true,
| /*是否正在提交保存*/
| save_loading: false,
| /*form表单数据*/
| form: {
| model:{
| card_name:'',
| type_id:'',
| card_style:'',
| sort:0,
| is_discount:0,
| discount:0,
| open_points:0,
| open_points_num:0,
| open_coupon:0,
| open_coupons:null,
| open_product: 0,
| open_products: null,
| month_points:0,
| month_points_num:0,
| month_coupon:0,
| month_coupons:null,
| expire:0,
| money:0,
| stock:'',
| status:0,
| content:'',
| sub_card:0,
| sub_num:0,
| default_style:'',
| is_default:0
| },
| /*会员卡类型*/
| typeList: [],
| /*优惠券*/
| couponList:[],
| /*副卡*/
| subList:[],
| image:[],
|
| },
| };
| },
| provide: function() {
| return {
| form: this.form
| };
| },
| created() {
| /*获取列表*/
| this.card_id = this.$route.query.card_id;
| this.getData();
|
| },
| methods: {
| /**
| * 获取基础数据
| */
| getData: function() {
| let self = this;
| CardApi.getEditData({
| card_id: self.card_id,
| },
| true
| )
| .then(res => {
| self.loading = false;
| Object.assign(self.form, res.data);
| this.form.month_points=this.form.month_points==1?true:false;
| this.form.month_coupon=this.form.month_coupon==1?true:false;
| })
| .catch(error => {
| self.loading = false;
| });
| },
|
| /*提交*/
| onSubmit: function() {
| let self = this;
| self.$refs.form.validate(valid => {
| if (valid) {
| let params = self.form.model;
| params.card_id = self.card_id;
| self.save_loading = true;
| CardApi.editcard({
| card_id: self.card_id,
| params: JSON.stringify(params)
| }, true)
| .then(data => {
| self.save_loading = false;
| self.$message({
| message: '保存成功',
| type: 'success'
| });
| self.cancelFunc();
| })
| .catch(error => {
| self.save_loading = false;
| });
| } else {
| self.$message({
| message: '请检查必填项是否填写完整',
| type: 'error'
| });
| }
| });
| },
|
| /*取消*/
| cancelFunc() {
| this.$router.back(-1);
| }
| }
| };
| </script>
|
| <style lang="scss" scoped>
| .basic-setting-content {}
|
| .product-add {
| padding-bottom: 50px;
| }
| </style>
|
|