diff --git a/src/pages/article/add/index.vue b/src/pages/article/add/index.vue index d6e2976..ed3e5cb 100644 --- a/src/pages/article/add/index.vue +++ b/src/pages/article/add/index.vue @@ -637,7 +637,9 @@ export default { classifications: [], classVisible: false, labels: [], - labelVisible: false + labelVisible: false, + originalName: '', + originColumnId: '' }; }, computed: { @@ -802,6 +804,7 @@ export default { }).catch(err => {}) } this.originalName = data.title + this.originColumnId = data.columnId this.form = data data.siteSelection && this.getOtherColumn() this.getColumn() @@ -868,8 +871,6 @@ export default { // 获取指定站点的栏目列表 getOtherColumn(val) { this.$post(this.api.listWithTree, { - - siteId: this.form.siteSelection, columnName: '', templateId: '', @@ -1241,6 +1242,7 @@ export default { const tId = form.articleTemplate // 如果是发布 if (isRelease) { + // 每个模板需要展示的字段不一样,因此要根据模板id来判断必填 if (tId !== 25) { if (!form.releaseTime) return Util.errorMsg('请选择发布日期') } @@ -1290,7 +1292,7 @@ export default { this.$post(this.api.updateArticle, form).then(res => { this.updateFile(fileId, form, form.id) Util.successMsg('修改成功') - next ? next() : this.$router.push(`list?columnId=` + form.columnId) + next ? next() : this.$router.push(`list?columnId=` + form.columnId + (form.columnId != this.originColumnId ? '&last=1' : '')) }).catch(err => { this.submiting = false }) diff --git a/src/pages/article/list/index.vue b/src/pages/article/list/index.vue index 3ebec88..0e4df5b 100644 --- a/src/pages/article/list/index.vue +++ b/src/pages/article/list/index.vue @@ -37,7 +37,11 @@ - + + + @@ -93,6 +97,7 @@ import ColumnConst from '@/const/column' export default { data() { return { + last: this.$route.query.last, // 是否直接跳到最后一页的文章(编辑文章的时候改了所属栏目,返回到列表后则需要跳到最后一页文章) types: ColumnConst.types, siteName: this.$store.state.content.site.siteName, columns: [], @@ -126,7 +131,7 @@ export default { total: 0, modifiedTimeSort: '', publicationTimeSort: '', - ordinalSort: 0, + topSort: 0, multipleSelection: [], originSettings: [], settings: [ @@ -232,7 +237,7 @@ export default { columnIds: [id], pageNum: this.page, pageSize: this.pageSize, - ordinalSort: this.ordinalSort, + topSort: this.topSort, title: this.field === 'title' ? keyword : '', founder: this.field === 'founder' ? keyword : '', column: this.field === 'column' ? keyword : '', @@ -247,7 +252,15 @@ export default { }) this.originList = JSON.parse(JSON.stringify(data.records)) this.list = data.records - this.total = +data.total + const total = +data.total + this.total = total + if (this.last) { + let page = parseInt(total / 10) + total % 10 && page++ + this.page = page + this.last = '' + this.getData() + } }).catch(err => {}) }, // 重置栏位筛选 @@ -333,19 +346,19 @@ export default { this.modifiedTimeSort = order ? order === 'ascending' ? 1 : 0 : '' if (order) { this.publicationTimeSort = '' - this.ordinalSort = '' + this.topSort = '' } } if (column.prop === 'releaseTime') { this.publicationTimeSort = order ? order === 'ascending' ? 1 : 0 : '' if (order) { this.modifiedTimeSort = '' - this.ordinalSort = '' + this.topSort = '' } } // 序号排序 0默认升序 1倒序 if (column.prop === 'sequence') { - this.ordinalSort = order ? order === 'ascending' ? 0 : 1 : '' + this.topSort = order ? order === 'ascending' ? 0 : 1 : '' if (order) { this.publicationTimeSort = '' this.modifiedTimeSort = '' diff --git a/src/pages/column/add/index.vue b/src/pages/column/add/index.vue index 81c2975..7cbf2ed 100644 --- a/src/pages/column/add/index.vue +++ b/src/pages/column/add/index.vue @@ -9,7 +9,7 @@ v-model="form.columnName" clearable maxlength="40" - @change="nameChange" + @input="nameChange" > @@ -17,7 +17,8 @@ v-model="form.fatherId" :options="columns" :props="columnProps" - clearable> + clearable + @change="fatherIdChange">
@@ -305,7 +306,9 @@ export default { cropperModel: false, isUpload: false, file: {}, // 当前被选择的图片文件 - fileId: '' + fileId: '', + level: 0, + nameTimer: null }; }, components: { @@ -372,8 +375,6 @@ export default { // 获取当前站点的栏目列表 getList() { this.$post(this.api.listWithTree, { - - siteId: this.site.id, columnName: '', templateId: '', @@ -504,8 +505,6 @@ export default { // 获取指定站点的栏目列表 getOtherColumn(val) { this.form.siteSelection && this.$post(this.api.listWithTree, { - - siteId: this.form.siteSelection, columnName: '', templateId: '', @@ -522,22 +521,45 @@ export default { }, // 栏目名称判重 nameChange(){ - const { columnName, level, id } = this.form - if (columnName && columnName !== this.originalName) { - this.$post(this.api.sameLevelJudgment, { - siteId: this.site.id, - columnName, - level: +level, - id: +id || '' - }).then(res => { + clearTimeout(this.nameTimer) + this.nameTimer = setTimeout(() => { + const { columnName, level, id } = this.form + if (columnName && columnName !== this.originalName) { + const data = { + siteId: this.site.id, + columnName, + level: +level, + } + 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 - }).catch(res => { - this.nameRepeat = true - }) - }else{ - this.nameRepeat = false + } + }, 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 + this.nameChange() + }, // 图片裁剪上传事件 customUpload(data) { const formData = new FormData() diff --git a/src/pages/column/list/index.vue b/src/pages/column/list/index.vue index 4bafbbe..77ae44d 100644 --- a/src/pages/column/list/index.vue +++ b/src/pages/column/list/index.vue @@ -237,8 +237,6 @@ export default { methods: { getData() { this.$post(this.api.listWithTree, { - - siteId: this.siteId, columnName: this.keyword, templateId: '', @@ -339,7 +337,7 @@ export default { }, // 更改排序 sort() { - // this.$post(this.api.deleteUselessData).then(res => {}).catch(err => {}) + this.$post(this.api.deleteUselessData).then(res => {}).catch(err => {}) this.$post(this.api.listWithTree, { siteId: this.siteId,