栏目更换上级

master
yujialong 2 years ago
parent ca7ec9e12d
commit c1cad822e5
  1. 25
      src/pages/column/add/index.vue

@ -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) {

Loading…
Cancel
Save