Commit 3a5208bd by chenwq

fix(mallConfig): 修复专场名称校验及置顶功能问题

- 添加专场名称重复校验及系统预设名称检查
- 修复置顶专场后索引未重置问题
- 优化专场名称自动生成逻辑
- 调整专场名称输入框最大长度及错误提示
1 parent c99a3239
......@@ -17,8 +17,7 @@
<template slot="specialEvents">
<div class="banner-box">
<el-button type="primary" plain class="add-banner-btn" :size="size" @click="handleBannerAdd" @change="handleBannerChange">+ 新增专场</el-button>
<!-- <img class="icon-edit" :src="require('@/assets/images/edit.png')" alt="" @click="editBannerName" /> -->
<el-button type="primary" class="edit-banner" icon="el-icon-edit"></el-button>
<el-button type="primary" class="edit-banner" icon="el-icon-edit" @click="editBannerName"></el-button>
<el-tabs v-if="editForm.specialEvents.length" v-model="bannerIdx" type="card" class="home-set-tabs" closable @tab-remove="handleBannerDelete">
<el-tab-pane v-for="(subItem, subIndex) in editForm.specialEvents" :key="subIndex" :label="subItem.eventName" :name="subIndex">
<div class="item-box">
......@@ -43,10 +42,10 @@
<el-button class="p-0 m-l-10" type="text" @click="handleProTop(scope)">置顶</el-button>
</span>
</GLTable>
<el-button style="margin-top: 20px" type="primary" plain :size="size" @click="handleUpEvent(subIndex)">置顶专场</el-button>
</div>
</glsx-combi-form>
</div>
<el-button style="margin: 20px 0 20px 154px" type="primary" plain :size="size" @click="handleUpEvent(subIndex)">置顶专场</el-button>
</div>
</el-tab-pane>
</el-tabs>
......@@ -227,13 +226,14 @@ export default {
},
editBannerForm: [
{
label: 'Banner名称:',
label: '专场名称:',
name: 'eventName',
type: 'input'
type: 'input',
maxlength: 10
}
],
bannerRules: {
eventName: [{ required: true, message: '请选择前端分类', trigger: 'blur' }]
eventName: [{ required: true, message: '请输入专场名称', trigger: 'blur' }]
},
eventEditFormData: [
{
......@@ -306,6 +306,25 @@ export default {
},
methods: {
handleBannerConfirm(form) {
let presetList = ['新增专场1', '新增专场2', '新增专场3', '新增专场4', '新增专场5']
presetList.splice(this.bannerIdx, 1)
const nameList = this.editForm.specialEvents.filter((item, idx) => idx != this.bannerIdx).map(item => item.eventName)
if (nameList.includes(form.eventName)) {
this.$message({
message: '专场名称已存在',
type: 'error',
customClass: 'msgHierarchy'
})
return true
}
if (presetList.includes(form.eventName)) {
this.$message({
message: '此为系统预设名称,请重新输入',
type: 'error',
customClass: 'msgHierarchy'
})
return true
}
this.editForm.specialEvents[this.bannerIdx].eventName = form.eventName
this.selectVisible()
},
......@@ -355,7 +374,9 @@ export default {
},
changeTabName() {
this.editForm.specialEvents.forEach((item, idx) => {
item.eventName = '新增专场' + (idx + 1)
if (item.eventName.includes('新增专场')) {
item.eventName = '新增专场' + (idx + 1)
}
})
},
handleBannerAdd() {
......@@ -369,9 +390,10 @@ export default {
if (!this.editForm.specialEvents.length) {
this.bannerIdx = '0'
}
let eventName = '新增专场' + (this.editForm.specialEvents.length + 1)
this.editForm.specialEvents.push({
...this.$common.utils.deepClone(this.specialEventsItem),
eventName: '新增专场' + (this.editForm.specialEvents.length + 1)
eventName: eventName
})
},
handleBannerChange(name) {
......@@ -440,6 +462,7 @@ export default {
handleUpEvent(idx) {
const [targetItem] = this.editForm.specialEvents.splice(idx, 1)
this.editForm.specialEvents.unshift(targetItem)
this.bannerIdx = '0'
this.changeTabName()
},
// 商品选择-end
......@@ -572,6 +595,10 @@ export default {
border: 1px solid #ffffff !important;
border-bottom: none !important;
}
.microStore.home-set .el-tabs__item {
min-width: 120px;
width: auto !important;
}
.home-set .home-img-w-h {
width: 264px;
height: 108px;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!