栏目名称判重修复

master
yujialong 2 months ago
parent 6f4d5c8432
commit 738fe9c15a
  1. 43
      src/pages/column/add/index.vue
  2. 2
      src/pages/column/list/index.vue

@ -478,32 +478,38 @@ export default {
}).catch(err => { })
},
//
nameChange () {
clearTimeout(this.nameTimer)
this.nameTimer = setTimeout(() => {
async queryNameRepeat () {
const { columnName, fatherId, id } = this.form
if (columnName && columnName !== this.originalName) {
const data = {
fatherId: fatherId.length ? fatherId[0] : 0,
fatherId: typeof fatherId === 'object' ? (fatherId.length ? fatherId[0] : 0) : fatherId,
siteId: this.site.id,
columnName,
}
if (id) data.id = +id
this.$post(this.api.sameLevelJudgment, data).then(res => {
try {
await this.$post(this.api.sameLevelJudgment, data)
this.nameRepeat = false
}).catch(res => {
} catch (e) {
this.nameRepeat = true
})
}
} else {
this.nameRepeat = false
}
return this.nameRepeat
},
//
nameChange () {
clearTimeout(this.nameTimer)
this.nameTimer = setTimeout(() => {
this.queryNameRepeat()
}, 500)
},
//
fatherIdChange (val) {
fatherIdChange () {
const check = this.$refs.fatherId.getCheckedNodes()
this.form.level = check.length ? check[0].level + 1 : 1 // level
this.nameChange()
this.queryNameRepeat()
},
//
customUpload (data) {
@ -614,11 +620,14 @@ export default {
}).catch(err => { })
},
//
submit (next) {
async submit (next) {
if (this.submiting) return false
const { form } = this
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('请填写分页条数')
const { fatherId } = form
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('请选择列表样式')
this.submiting = true
try {
if (this.isEdit) {
delete form.children
form.editorId = this.userId
this.$post(this.api.updateColumn, form).then(res => {
await this.$post(this.api.updateColumn, form)
this.updateFile(form, form.id)
//
if (form.typeId === 3 && this.originListStyle !== form.listStyleId) this.savePage(form.id)
Util.successMsg("修改成功")
next ? next() : this.$router.back()
}).catch(err => {
this.submiting = false
})
} else {
this.$post(this.api.saveColumn, form).then(({ data }) => {
const { data } = await this.$post(this.api.saveColumn, form)
this.updateFile(form, data)
//
form.typeId === 3 && this.savePage(data)
Util.successMsg("创建成功")
next ? next() : this.$router.back()
}).catch(err => {
}
} catch (e) {
this.submiting = false
})
}
},
//

@ -345,7 +345,7 @@ export default {
this.select(this.list, this.checkedKeys)
},
select (data, flag) {
data.map(row => {
data && data.map(row => {
this.$refs.table.toggleRowSelection(row, flag)
if (row.children != undefined) this.select(row.children, this.checkedKeys)
})

Loading…
Cancel
Save