mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-14 04:32:49 +00:00
perf: 支持项目调整排序
This commit is contained in:
parent
b825b5b063
commit
7c94f6bc9a
@ -785,7 +785,7 @@ export default {
|
|||||||
projectLists: {
|
projectLists: {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
if (!this.projectDragging) {
|
if (!this.projectDragging) {
|
||||||
this.projectDraggableList = val
|
this.projectDraggableList = $A.cloneJSON(val)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
@ -1061,12 +1061,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onProjectSortEnd() {
|
onProjectSortEnd() {
|
||||||
// 只对非置顶项进行排序更新
|
|
||||||
const nonPinnedItems = this.projectDraggableList.filter(item => !item.top_at)
|
const nonPinnedItems = this.projectDraggableList.filter(item => !item.top_at)
|
||||||
nonPinnedItems.forEach((item, index) => {
|
|
||||||
this.$store.dispatch("saveProject", {id: item.id, sort: index})
|
|
||||||
})
|
|
||||||
// 提交服务端保存
|
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'project/user/sort',
|
url: 'project/user/sort',
|
||||||
data: {
|
data: {
|
||||||
@ -1075,8 +1070,12 @@ export default {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
spinner: 2000
|
spinner: 2000
|
||||||
}).then(({msg}) => {
|
}).then(({msg}) => {
|
||||||
|
nonPinnedItems.forEach((item, index) => {
|
||||||
|
this.$store.dispatch("saveProject", {id: item.id, sort: index})
|
||||||
|
})
|
||||||
$A.messageSuccess(msg)
|
$A.messageSuccess(msg)
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
|
this.projectDraggableList = $A.cloneJSON(this.projectLists)
|
||||||
$A.modalError(msg)
|
$A.modalError(msg)
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.projectDragging = false
|
this.projectDragging = false
|
||||||
@ -1247,7 +1246,6 @@ export default {
|
|||||||
},
|
},
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.$store.dispatch("saveProject", data);
|
this.$store.dispatch("saveProject", data);
|
||||||
this.projectDraggableList = this.projectLists
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const active = this.$refs.menuProject.querySelector(".active")
|
const active = this.$refs.menuProject.querySelector(".active")
|
||||||
if (active) {
|
if (active) {
|
||||||
|
|||||||
@ -151,7 +151,7 @@ export default {
|
|||||||
projectLists: {
|
projectLists: {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
if (!this.projectDragging) {
|
if (!this.projectDragging) {
|
||||||
this.projectDraggableList = val
|
this.projectDraggableList = $A.cloneJSON(val)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
@ -184,12 +184,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
transformEmojiToHtml,
|
transformEmojiToHtml,
|
||||||
onProjectSortEnd() {
|
onProjectSortEnd() {
|
||||||
// 只对非置顶项进行排序更新
|
|
||||||
const nonPinnedItems = this.projectDraggableList.filter(item => !item.top_at)
|
const nonPinnedItems = this.projectDraggableList.filter(item => !item.top_at)
|
||||||
nonPinnedItems.forEach((item, index) => {
|
|
||||||
this.$store.dispatch("saveProject", {id: item.id, sort: index})
|
|
||||||
})
|
|
||||||
// 提交服务端保存
|
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'project/user/sort',
|
url: 'project/user/sort',
|
||||||
data: {
|
data: {
|
||||||
@ -198,8 +193,12 @@ export default {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
spinner: 2000
|
spinner: 2000
|
||||||
}).then(({msg}) => {
|
}).then(({msg}) => {
|
||||||
|
nonPinnedItems.forEach((item, index) => {
|
||||||
|
this.$store.dispatch("saveProject", {id: item.id, sort: index})
|
||||||
|
})
|
||||||
$A.messageSuccess(msg)
|
$A.messageSuccess(msg)
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
|
this.projectDraggableList = $A.cloneJSON(this.projectLists)
|
||||||
$A.modalError(msg)
|
$A.modalError(msg)
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.projectDragging = false
|
this.projectDragging = false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user