add.vue
9.9 KB
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
<template>
<div class="new-tmp">
<h2>新建活动模版</h2>
<hr/>
<div class="activity-wrap">
<div class="activity-content"><glsx-combi-form
ref="formRef"
:isEdit="true"
:isBlock="true"
:formObj="configForm"
:formData="formData"
:formRules="rule"
>
<template #merchantId>
<el-select
v-model="configForm.merchantId"
placeholder="请选择"
filterable
remote
:remote-method="remoteMethod"
v-reachbottom="onReachBottom"
@focus="selectFocus"
:loading="loading"
:disabled="disabled"
@change="change"
>
<el-option
v-for="item in merchantObj.data"
:key="item.confId"
:label="item.confName"
:value="item.confId"
></el-option>
<template v-if="merchantObj.nothing">
<div class="select-nothing">到底了!</div>
</template>
</el-select>
</template>
<template #pageTheme>
<div class="page-theme">
<el-form-item label="第一行" prop="theme1" >
<el-input v-model="configForm.theme1" maxlength="5" show-word-limit></el-input>
</el-form-item>
<el-form-item label="第二行" prop="theme2" >
<el-input v-model="configForm.theme2" maxlength="5" show-word-limit></el-input>
</el-form-item>
</div>
</template>
<p
slot="cardCover"
class="cover-tips"
>建议格式:高度88px,png</p>
<template #activityRuleDes>
<textBox style="width:45vw" @change="writeChange" ref="textBox" @forbid="forbidEdit"></textBox>
</template>
<template #physicalWinningCfg>
<div class="physical-winning">
<el-form-item
label="活动形式:"
prop="exchangeType"
class="m-t-20"
>
<el-radio-group
v-model="configForm.exchangeType"
class="fit-width radio"
>
<el-radio :label="0">快递到家</el-radio>
<el-radio :label="1">到店核销</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="填写信息:" prop="describeId" v-if="configForm.exchangeType == 0">
<el-checkbox-group v-model="configForm.describeId">
<el-checkbox v-for="(item,index) in expressList" :key="index" :label="item"><span>{{ item.describeMsg }}</span></el-checkbox>
</el-checkbox-group>
</el-form-item>
</div>
</template>
</glsx-combi-form></div>
<div class="redEnvelope-bg">
<img v-if="configForm.logo" :src="configForm.logo">
<p v-html="configForm.theme1"></p>
<p class="p2" v-html="configForm.theme2"></p>
</div>
</div>
<GLFooter>
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleSave">确定</el-button>
</GLFooter>
</div>
</template>
<script type="text/ecmascript-6">
import {getMerchantListMixin} from '@/mixins'
import textBox from '@/components/text-box'
export default {
name: 'add',
mixins: [getMerchantListMixin],
props: {
disabled: Boolean
},
components: {
textBox
},
data() {
return {
merchantObj: {
nothing: false,
data: [],
currentPage: 1,
name: '',
loading: false,
total: 0
},
expressList:[],
configForm: {
templateName: '',
merchantId: '',
activityType: '0',
theme1:'',
theme2:'',
logo: '',
merchantName: '',
pageTheme:'11',
exchangeType: '',
ruleDescribe:'',
describeId: [],
},
rule: {
templateName: [{required: true, message: '请输入模板名称', trigger: 'change'}],
merchantId: [{required: true, message: '请选择所属渠道', trigger: 'change'}],
activityType: [{required: true, message: '请选择活动形式', trigger: 'change'}],
logo: [{required: true, message: '请上传卡片封面', trigger: 'change'}],
pageTheme: [{required: true, message: '请输入页面主题'}],
exchangeType: [{required: true, message: '请选择活动形式', trigger: 'change'}],
describeId: [{required: true, message: '请选择填写信息', trigger: 'change'}]
},
formData: [
{
label: '模板名称',
name: 'templateName',
type: 'input',
maxlength: 25,
showLimit:true
},
{
label: '所属渠道',
type: 'select',
name: 'merchantId',
addHtml: 'merchantId'
},
{
label: '活动形式',
name: 'activityType',
type: 'radio',
optionList: [
{text: '随机红包', id: '0'}
],
optionId: 'id',
optionLabel: 'text',
},
{
label: '页面主题',
name: 'pageTheme',
addHtml: 'pageTheme'
},
{
label: 'logo图片',
name: 'logo',
type: 'upload',
width: '320px',
limitSize: 10,
maxPhotoNum: 1,
suffixSlot: 'cardCover',
handleUpload: async (e, file, targetItem) => {
let loading = this.$loading({
target: document.querySelector('.activity-img'),
})
try {
const imgFile = e.target.result,
arrBase64 = imgFile.split(',')[1],
str = file.name.split('.'),
base64 = str.at(-1) + '@' + arrBase64,
res = await this.$apis.common.pictureUpload({file: base64, fileType: 'image'})
if (res) {
this.configForm[targetItem.name] = res
this.formRef().validateField(targetItem.name)
loading.close()
} else throw '上传失败'
} catch (error) {
loading.close()
this.$message(error)
}
}
},
{
label: '活动规则描述',
addHtml: 'activityRuleDes'
},
{
label: '实物中奖配置',
addHtml: 'physicalWinningCfg'
}
],
}
},
watch: {},
mounted() {
this.getExpressInfo()
},
methods: {
getExpressInfo(){
this.$apis.redenvelope.expressConfigList({}
).then(res => {
this.expressList = res.map(item => ({'describeMsg':item.describeMsg,'describeId':item.describeId}))
})
},
validateForm() {
return new Promise((resolve, reject) => {
this.formRef().validate((valid) => {
if (valid) {
resolve();
} else {
reject(new Error('缺少必填内容'));
}
});
});
},
writeChange(val) {
this.configForm.ruleDescribe = val
},
change(id) {
this.configForm.merchantName = ''
if (id) {
this.configForm.merchantName = this.merchantObj.data.find(e => e.confId == id).confName
}
},
formRef() {
return this.$refs.formRef.$refs.formRef
},
handleCancel() {
sessionStorage.setItem('returnFromAddPage', 'ActiveTemplateManagement')
this.$router.back()
},
handleSave() {
this.validateForm().then(() => {
const {describeId,pageTheme,...params} = this.configForm
if (!params.theme1 && !params.theme2) return this.$message.error('请填写页面主题');
params.writeInfoList = [...describeId]
this.$apis.redenvelope.newActivityTemplate(params).then(res => {
if (res.code == 0){
this.$message.success('新建活动模板成功');
this.handleCancel()
}else{
this.$message.error(res.message);
}
})
}).catch(error => {
this.$message.error(error.message);
});
}
},
}
</script>
<style scoped lang="scss">
.new-tmp{
background: #fff;
h2{
padding: 10px 0 0 16px;
}
.activity-wrap{
display: flex;
.cover-tips{
position: absolute;
color: #999999;
left: 90px;
top: 60px;
}
.activity-content {
width: 70%;
padding: 20px;
.page-theme{
.el-form-item{
display: flex;
width: 340px;
/deep/.el-form-item__label{
margin-right: 8px;
}
}
}
.physical-winning {
background: #F9F9F9;
width: 400px;
padding: 10px;
.el-form-item{
/deep/.el-form-item__label{
width: auto;
}
}
}
}
.redEnvelope-bg{
position: relative;
width: 500px;
height: 800px;
background-image: url("./../../../../assets/redEnvelope-bg.png");
background-repeat: no-repeat;
img{
position: absolute;
width: 98px;
height: 33px;
top: 55px;
left:28px;
}
p{
position: absolute;
font-family: SourceHanSansCN-Heavy;
font-weight: 900;
font-size: 35.5px;
letter-spacing: 0;
text-align: center;
background: linear-gradient(to bottom, #FFFFFF, #FFD58E); /* 设置背景渐变 */
-webkit-background-clip: text; /* Safari/Chrome */
-webkit-text-fill-color: transparent; /* Safari/Chrome */
color: transparent; /* Firefox/Opera */
text-shadow: 0 1px 3px #ffe9e9de;
top: 100px;
left: 45px;
}
.p2{
top: 150px;
}
}
}
}
</style>