|
|
@ -478,32 +478,38 @@ export default { |
|
|
|
}).catch(err => { }) |
|
|
|
}).catch(err => { }) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 栏目名称判重 |
|
|
|
// 栏目名称判重 |
|
|
|
|
|
|
|
async queryNameRepeat () { |
|
|
|
|
|
|
|
const { columnName, fatherId, id } = this.form |
|
|
|
|
|
|
|
if (columnName && columnName !== this.originalName) { |
|
|
|
|
|
|
|
const data = { |
|
|
|
|
|
|
|
fatherId: typeof fatherId === 'object' ? (fatherId.length ? fatherId[0] : 0) : fatherId, |
|
|
|
|
|
|
|
siteId: this.site.id, |
|
|
|
|
|
|
|
columnName, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (id) data.id = +id |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
await this.$post(this.api.sameLevelJudgment, data) |
|
|
|
|
|
|
|
this.nameRepeat = false |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
this.nameRepeat = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.nameRepeat = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return this.nameRepeat |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 栏目名称输入回调 |
|
|
|
nameChange () { |
|
|
|
nameChange () { |
|
|
|
clearTimeout(this.nameTimer) |
|
|
|
clearTimeout(this.nameTimer) |
|
|
|
this.nameTimer = setTimeout(() => { |
|
|
|
this.nameTimer = setTimeout(() => { |
|
|
|
const { columnName, fatherId, id } = this.form |
|
|
|
this.queryNameRepeat() |
|
|
|
if (columnName && columnName !== this.originalName) { |
|
|
|
|
|
|
|
const data = { |
|
|
|
|
|
|
|
fatherId: fatherId.length ? fatherId[0] : 0, |
|
|
|
|
|
|
|
siteId: this.site.id, |
|
|
|
|
|
|
|
columnName, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (id) data.id = +id |
|
|
|
|
|
|
|
this.$post(this.api.sameLevelJudgment, data).then(res => { |
|
|
|
|
|
|
|
this.nameRepeat = false |
|
|
|
|
|
|
|
}).catch(res => { |
|
|
|
|
|
|
|
this.nameRepeat = true |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.nameRepeat = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, 500) |
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 上级选择回调 |
|
|
|
// 上级选择回调 |
|
|
|
fatherIdChange (val) { |
|
|
|
fatherIdChange () { |
|
|
|
const check = this.$refs.fatherId.getCheckedNodes() |
|
|
|
const check = this.$refs.fatherId.getCheckedNodes() |
|
|
|
this.form.level = check.length ? check[0].level + 1 : 1 // 更改了父级后要重新获取当前栏目level |
|
|
|
this.form.level = check.length ? check[0].level + 1 : 1 // 更改了父级后要重新获取当前栏目level |
|
|
|
this.nameChange() |
|
|
|
this.queryNameRepeat() |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 图片裁剪上传事件 |
|
|
|
// 图片裁剪上传事件 |
|
|
|
customUpload (data) { |
|
|
|
customUpload (data) { |
|
|
@ -614,11 +620,14 @@ export default { |
|
|
|
}).catch(err => { }) |
|
|
|
}).catch(err => { }) |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 提交 |
|
|
|
// 提交 |
|
|
|
submit (next) { |
|
|
|
async submit (next) { |
|
|
|
if (this.submiting) return false |
|
|
|
if (this.submiting) return false |
|
|
|
const { form } = this |
|
|
|
const { form } = this |
|
|
|
if (!form.columnName) return Util.errorMsg('请填写栏目名称') |
|
|
|
if (!form.columnName) return Util.errorMsg('请填写栏目名称') |
|
|
|
if (this.nameRepeat) return Util.errorMsg('同级下已存在重复栏目!') |
|
|
|
clearTimeout(this.nameTimer) |
|
|
|
|
|
|
|
const repeat = await this.queryNameRepeat() |
|
|
|
|
|
|
|
console.log("🚀 ~ submit ~ reepat:", repeat) |
|
|
|
|
|
|
|
if (repeat) return Util.errorMsg('同级下已存在重复栏目!') |
|
|
|
if (!form.pageSize) return Util.errorMsg('请填写分页条数') |
|
|
|
if (!form.pageSize) return Util.errorMsg('请填写分页条数') |
|
|
|
const { fatherId } = form |
|
|
|
const { fatherId } = form |
|
|
|
if (typeof fatherId === 'object') form.fatherId = fatherId.length ? fatherId[fatherId.length - 1] : 0 // 选择了上级后结果会是数组,直接取最后一个id |
|
|
|
if (typeof fatherId === 'object') form.fatherId = fatherId.length ? fatherId[fatherId.length - 1] : 0 // 选择了上级后结果会是数组,直接取最后一个id |
|
|
@ -637,28 +646,26 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
if (form.typeId !== 2 && !form.listStyleId) return Util.errorMsg('请选择列表样式') |
|
|
|
if (form.typeId !== 2 && !form.listStyleId) return Util.errorMsg('请选择列表样式') |
|
|
|
this.submiting = true |
|
|
|
this.submiting = true |
|
|
|
if (this.isEdit) { |
|
|
|
try { |
|
|
|
delete form.children |
|
|
|
if (this.isEdit) { |
|
|
|
form.editorId = this.userId |
|
|
|
delete form.children |
|
|
|
this.$post(this.api.updateColumn, form).then(res => { |
|
|
|
form.editorId = this.userId |
|
|
|
|
|
|
|
await this.$post(this.api.updateColumn, form) |
|
|
|
this.updateFile(form, form.id) |
|
|
|
this.updateFile(form, form.id) |
|
|
|
// 长页模板有重新修改,则需要重新保存长页模板 |
|
|
|
// 长页模板有重新修改,则需要重新保存长页模板 |
|
|
|
if (form.typeId === 3 && this.originListStyle !== form.listStyleId) this.savePage(form.id) |
|
|
|
if (form.typeId === 3 && this.originListStyle !== form.listStyleId) this.savePage(form.id) |
|
|
|
Util.successMsg("修改成功") |
|
|
|
Util.successMsg("修改成功") |
|
|
|
next ? next() : this.$router.back() |
|
|
|
next ? next() : this.$router.back() |
|
|
|
}).catch(err => { |
|
|
|
} else { |
|
|
|
this.submiting = false |
|
|
|
const { data } = await this.$post(this.api.saveColumn, form) |
|
|
|
}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.$post(this.api.saveColumn, form).then(({ data }) => { |
|
|
|
|
|
|
|
this.updateFile(form, data) |
|
|
|
this.updateFile(form, data) |
|
|
|
// 栏目类型选择了长页栏目,才需要保存长页 |
|
|
|
// 栏目类型选择了长页栏目,才需要保存长页 |
|
|
|
form.typeId === 3 && this.savePage(data) |
|
|
|
form.typeId === 3 && this.savePage(data) |
|
|
|
Util.successMsg("创建成功") |
|
|
|
Util.successMsg("创建成功") |
|
|
|
next ? next() : this.$router.back() |
|
|
|
next ? next() : this.$router.back() |
|
|
|
}).catch(err => { |
|
|
|
} |
|
|
|
this.submiting = false |
|
|
|
} catch (e) { |
|
|
|
}) |
|
|
|
this.submiting = false |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 保存长页模板 |
|
|
|
// 保存长页模板 |
|
|
|