|
|
|
@ -14,6 +14,7 @@ |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="fatherId" label="设置上级"> |
|
|
|
|
<el-cascader |
|
|
|
|
ref="fatherId" |
|
|
|
|
v-model="form.fatherId" |
|
|
|
|
:options="columns" |
|
|
|
|
:props="columnProps" |
|
|
|
@ -535,12 +536,12 @@ export default { |
|
|
|
|
nameChange(){ |
|
|
|
|
clearTimeout(this.nameTimer) |
|
|
|
|
this.nameTimer = setTimeout(() => { |
|
|
|
|
const { columnName, level, id } = this.form |
|
|
|
|
const { columnName, fatherId, id } = this.form |
|
|
|
|
if (columnName && columnName !== this.originalName) { |
|
|
|
|
const data = { |
|
|
|
|
fatherId: fatherId.length ? fatherId[0] : 0, |
|
|
|
|
siteId: this.site.id, |
|
|
|
|
columnName, |
|
|
|
|
level: +level, |
|
|
|
|
} |
|
|
|
|
if (id) data.id = +id |
|
|
|
|
this.$post(this.api.sameLevelJudgment, data).then(res => { |
|
|
|
@ -553,23 +554,10 @@ export default { |
|
|
|
|
} |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
// 获取设置上级的level |
|
|
|
|
getLevel(list, id) { |
|
|
|
|
for (const e of list) { |
|
|
|
|
if (e.id == id) { |
|
|
|
|
this.level = e.level |
|
|
|
|
break |
|
|
|
|
} else if (e.children) { |
|
|
|
|
this.getLevel(e.children, id) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 上级选择回调 |
|
|
|
|
fatherIdChange(val) { |
|
|
|
|
const id= val[val.length - 1] |
|
|
|
|
this.getLevel(this.columns, id) |
|
|
|
|
this.form.level = this.level |
|
|
|
|
this.form.id = id |
|
|
|
|
const check = this.$refs.fatherId.getCheckedNodes() |
|
|
|
|
this.form.level = check.length ? check[0].level + 1 : 1 // 更改了父级后要重新获取当前栏目level |
|
|
|
|
this.nameChange() |
|
|
|
|
}, |
|
|
|
|
// 图片裁剪上传事件 |
|
|
|
@ -680,7 +668,8 @@ export default { |
|
|
|
|
if (!form.columnName) return Util.errorMsg('请填写栏目名称') |
|
|
|
|
if (this.nameRepeat) return Util.errorMsg('同级下已存在重复栏目!') |
|
|
|
|
if (!form.pageSize) return Util.errorMsg('请填写分页条数') |
|
|
|
|
if (typeof form.fatherId === 'object') form.fatherId = form.fatherId[form.fatherId.length - 1] // 选择了上级后结果会是数组,直接取最后一个id |
|
|
|
|
const { fatherId } = form |
|
|
|
|
if (typeof fatherId === 'object') form.fatherId = fatherId.length ? fatherId[fatherId.length - 1] : 0 // 选择了上级后结果会是数组,直接取最后一个id |
|
|
|
|
if (form.typeId === 2 && form.connectionType !== 2) { |
|
|
|
|
const { links, article, otherLink, otherArticle } = this |
|
|
|
|
if (form.connectionType === 1) { |
|
|
|
|