mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 01:34:24 +08:00
code refactor
This commit is contained in:
+1
-1
@@ -373,7 +373,7 @@ app.use(router);
|
|||||||
app.component('VChart', VChart);
|
app.component('VChart', VChart);
|
||||||
app.component('PerfectScrollbar', PerfectScrollbar);
|
app.component('PerfectScrollbar', PerfectScrollbar);
|
||||||
app.component('VueDatePicker', VueDatePicker);
|
app.component('VueDatePicker', VueDatePicker);
|
||||||
app.component('draggable', draggable);
|
app.component('DraggableList', draggable);
|
||||||
|
|
||||||
app.component('PinCodeInput', PinCodeInput);
|
app.component('PinCodeInput', PinCodeInput);
|
||||||
|
|
||||||
|
|||||||
@@ -86,14 +86,14 @@ function updateAccountToAccountList(state, account) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAccountDisplayOrderInAccountList(state, { account, from, to, onlyUpdateGlobalList }) {
|
function updateAccountDisplayOrderInAccountList(state, { account, from, to, updateListOrder, updateGlobalListOrder }) {
|
||||||
let fromAccount = null;
|
let fromAccount = null;
|
||||||
let toAccount = null;
|
let toAccount = null;
|
||||||
|
|
||||||
if (state.allCategorizedAccounts[account.category]) {
|
if (state.allCategorizedAccounts[account.category]) {
|
||||||
const accountList = state.allCategorizedAccounts[account.category].accounts;
|
const accountList = state.allCategorizedAccounts[account.category].accounts;
|
||||||
|
|
||||||
if (!onlyUpdateGlobalList) {
|
if (updateListOrder) {
|
||||||
fromAccount = accountList[from];
|
fromAccount = accountList[from];
|
||||||
toAccount = accountList[to];
|
toAccount = accountList[to];
|
||||||
accountList.splice(to, 0, accountList.splice(from, 1)[0]);
|
accountList.splice(to, 0, accountList.splice(from, 1)[0]);
|
||||||
@@ -108,7 +108,7 @@ function updateAccountDisplayOrderInAccountList(state, { account, from, to, only
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromAccount && toAccount) {
|
if (updateGlobalListOrder && fromAccount && toAccount) {
|
||||||
let globalFromIndex = -1;
|
let globalFromIndex = -1;
|
||||||
let globalToIndex = -1;
|
let globalToIndex = -1;
|
||||||
|
|
||||||
@@ -756,7 +756,7 @@ export const useAccountsStore = defineStore('accounts', {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
changeAccountDisplayOrder({ accountId, from, to, onlyUpdateGlobalList }) {
|
changeAccountDisplayOrder({ accountId, from, to, updateListOrder, updateGlobalListOrder }) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const account = self.allAccountsMap[accountId];
|
const account = self.allAccountsMap[accountId];
|
||||||
|
|
||||||
@@ -777,7 +777,8 @@ export const useAccountsStore = defineStore('accounts', {
|
|||||||
account: account,
|
account: account,
|
||||||
from: from,
|
from: from,
|
||||||
to: to,
|
to: to,
|
||||||
onlyUpdateGlobalList: onlyUpdateGlobalList
|
updateListOrder: updateListOrder,
|
||||||
|
updateGlobalListOrder: updateGlobalListOrder
|
||||||
});
|
});
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
|
|||||||
@@ -102,7 +102,7 @@
|
|||||||
|
|
||||||
<v-row class="pl-4 pr-8" v-if="categorizedAccounts[activeAccountCategory.id] && categorizedAccounts[activeAccountCategory.id].accounts && categorizedAccounts[activeAccountCategory.id].accounts.length">
|
<v-row class="pl-4 pr-8" v-if="categorizedAccounts[activeAccountCategory.id] && categorizedAccounts[activeAccountCategory.id].accounts && categorizedAccounts[activeAccountCategory.id].accounts.length">
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
<draggable
|
<draggable-list
|
||||||
class="list-group"
|
class="list-group"
|
||||||
item-key="id"
|
item-key="id"
|
||||||
handle=".drag-handle"
|
handle=".drag-handle"
|
||||||
@@ -197,7 +197,7 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</draggable>
|
</draggable-list>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -417,7 +417,8 @@ export default {
|
|||||||
accountId: moveEvent.element.id,
|
accountId: moveEvent.element.id,
|
||||||
from: moveEvent.oldIndex,
|
from: moveEvent.oldIndex,
|
||||||
to: moveEvent.newIndex,
|
to: moveEvent.newIndex,
|
||||||
onlyUpdateGlobalList: true
|
updateListOrder: false,
|
||||||
|
updateGlobalListOrder: true
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
self.displayOrderModified = true;
|
self.displayOrderModified = true;
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@@ -440,7 +441,7 @@ export default {
|
|||||||
self.loading = false;
|
self.loading = false;
|
||||||
|
|
||||||
if (!error.processed) {
|
if (!error.processed) {
|
||||||
self.$toast(error.message || error);
|
self.$refs.snackbar.showError(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -338,7 +338,9 @@ export default {
|
|||||||
self.accountsStore.changeAccountDisplayOrder({
|
self.accountsStore.changeAccountDisplayOrder({
|
||||||
accountId: id,
|
accountId: id,
|
||||||
from: event.from - 1, // first item in the list is title, so the index need minus one
|
from: event.from - 1, // first item in the list is title, so the index need minus one
|
||||||
to: event.to - 1
|
to: event.to - 1,
|
||||||
|
updateListOrder: true,
|
||||||
|
updateGlobalListOrder: true
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
self.displayOrderModified = true;
|
self.displayOrderModified = true;
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|||||||
Reference in New Issue
Block a user