Commit f31c3783 authored by Xuguangxing's avatar Xuguangxing

feat: 增加导航上移/下移功能

parent e824211d
......@@ -27,8 +27,12 @@
>
<div class="navigator-list-item_title">
<span>一级导航</span>
<div class="operation">
<Button type="primary" size="small" :disabled="index == 0" @click="sort(index, 1)">上移</Button>
<Button type="primary" size="small" :disabled="index == navigatorData.length - 1" @click="sort(index, 2)">下移</Button>
<Icon type="close-round" @click="deleteNavigatorConfigItem(index)"></Icon>
</div>
</div>
<div class="navigator-list-item_content">
<span><i>*</i>导航名称</span>
<Input v-model="item.name" placeholder="请输入导航名称" />
......@@ -238,6 +242,9 @@ export default {
},
addNavigatorConfig() {
// 添加导航配置
if (this.navigatorData.length === 5) {
return this.$toast('最多支持配置5个导航');
}
this.navigatorData.push(Object.assign({}, this.standardEditDataModel));
},
deleteNavigatorConfigItem(index) {
......@@ -255,6 +262,10 @@ export default {
this.$toast('请配置导航');
return false;
}
if (this.navigatorData.length < 2 || this.navigatorData.length > 5) {
this.$toast('导航配置数量范围2-5个');
return false;
}
if (this.bgColor && !reg.test(this.bgColor)) {
this.$toast('导航背景色格式错误,请重新填写');
return false;
......@@ -323,6 +334,17 @@ export default {
},
changeColor(evnet, data) {
data = /^(?:#[A-Fa-f0-9]{3}|#[A-Fa-f0-9]{6})$/.test(evnet.target.value) ? evnet.target.value : ""
},
sort(index, type) {
/**
* feat: 上移下移
* index: 当前点击的元素索引
* type: 移动类型,1上移,2下移
*/
const arr = this.navigatorData.concat([]);
const targetIndex = type === 1 ? index - 1 : index + 1;
arr[index] = arr.splice(targetIndex, 1, arr[index])[0];
this.navigatorData = arr;
}
},
}
......@@ -376,6 +398,16 @@ export default {
display: flex;
align-items: center;
justify-content: space-between;
.operation{
display: flex;
align-items: center;
button{
margin-right: 12px;
&:first-child{
margin-right: 6px;
}
}
}
/deep/ .ivu-icon{
cursor: pointer;
}
......@@ -386,7 +418,7 @@ export default {
align-items: center;
span{
display: inline-block;
width: 60px;
width: 80px;
flex-shrink: 0;
margin-right: 10px;
i{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment