fix : package transfer

This commit is contained in:
zeinab.ashrafi
2025-05-15 12:04:49 +03:30
parent ba6cc0ef83
commit be15f1352c
6 changed files with 54 additions and 24 deletions
+17 -7
View File
@@ -114,13 +114,23 @@ export default {
}, },
async transfer() { async transfer() {
try { try {
const result = await this.transferItem({ let result = {}
itemId: this.getModalProperties.data.id, if (this.getModalProperties.type && this.getModalProperties.type === 'item') {
userId: this.selected.id, result = await this.transferItem({
isUser: this.$hasRole('User') itemId: this.getModalProperties.data.id,
}); userId: this.selected.id,
this.setResultModal(result); isUser: this.$hasRole('User')
this.closeModal(); });
} else if (this.getModalProperties.type && this.getModalProperties.type === 'package') {
result = await ApiService.post(urls.transferPackage(this.getModalProperties.data.id), {
user_id: this.selected.id,
});
}
if (result && result.status === 200) {
this.setResultModal(result);
this.closeModal();
return result;
}
} catch (e) { } catch (e) {
console.error("Transfer failed:", e); console.error("Transfer failed:", e);
} }
+3
View File
@@ -183,6 +183,9 @@ const urls = {
transferItem: function (id) { transferItem: function (id) {
return `/transfer-items/${id}`; return `/transfer-items/${id}`;
}, },
transferPackage: function (id) {
return `/transfer-packages/${id}`;
},
removeItem: function (id) { removeItem: function (id) {
return `Items/${id}`; return `Items/${id}`;
}, },
+5 -4
View File
@@ -44,7 +44,8 @@
<span>Filter</span> <span>Filter</span>
</v-tooltip> </v-tooltip>
<v-btn class="WM-Outline-Btn WM-Border mr-2 WM-Margin-BT-0 WM-Border-Black" @click="download()" style="padding: 10px 30px;"> <v-btn class="WM-Outline-Btn WM-Border mr-2 WM-Margin-BT-0 WM-Border-Black" @click="download()"
style="padding: 10px 30px;">
<v-icon class="black--text mr-2 caption">fas fa-share-square</v-icon> <v-icon class="black--text mr-2 caption">fas fa-share-square</v-icon>
<span class="black--text">EXPORT</span> <span class="black--text">EXPORT</span>
</v-btn> </v-btn>
@@ -288,8 +289,8 @@ export default {
getStatus(item) { getStatus(item) {
if (item.status === 'pending') { if (item.status === 'pending') {
return [ return [
{status: 'approved', label: 'approve', color: 'cyan', font_color : 'white', icon: 'fa-check'}, {status: 'approved', label: 'approve', color: 'cyan', font_color: 'white', icon: 'fa-check'},
{status: 'rejected', label: 'reject', color: 'light-gray',font_color : 'black', icon: 'fa-close'}, {status: 'rejected', label: 'reject', color: 'light-gray', font_color: 'black', icon: 'fa-close'},
] ]
} else { } else {
const nextStatus = item.status === 'rejected' ? 'approved' : 'rejected' const nextStatus = item.status === 'rejected' ? 'approved' : 'rejected'
@@ -316,7 +317,7 @@ export default {
async transfer(data) { async transfer(data) {
this.changeCurrentModal({ this.changeCurrentModal({
modal: "modal-user-list", modal: "modal-user-list",
properties: {data}, properties: {data, type: 'item'},
}); });
}, },
}, },
+1 -1
View File
@@ -235,7 +235,7 @@ export default {
async transfer(data) { async transfer(data) {
this.changeCurrentModal({ this.changeCurrentModal({
modal: "modal-user-list", modal: "modal-user-list",
properties: {data}, properties: {data, type: 'item'},
}); });
}, },
async generateBarcode(item, type = null) { async generateBarcode(item, type = null) {
+19 -10
View File
@@ -22,17 +22,19 @@
<v-flex xs12 sm6 md6 lg4 xl3 class="WM-Align-R"> <v-flex xs12 sm6 md6 lg4 xl3 class="WM-Align-R">
<v-tooltip bottom open-on-hover> <v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }"> <template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on" color="WM-Tooltip-Btn WM-Outline-Btn WM-Border WM-Margin-BT-0 WM-Border-Black mr-2" @click="load()"> <v-btn v-bind="attrs" v-on="on"
color="WM-Tooltip-Btn WM-Outline-Btn WM-Border WM-Margin-BT-0 WM-Border-Black mr-2"
@click="load()">
<v-icon class="black--text caption">fas fa-search</v-icon> <v-icon class="black--text caption">fas fa-search</v-icon>
</v-btn> </v-btn>
</template> </template>
<span>Filter</span> <span>Filter</span>
</v-tooltip> </v-tooltip>
<!-- <v-btn class="WM-Outline-Btn WM-Border mr-2 WM-Margin-BT-0 WM-Border-Black" style="padding: 10px 30px;"> <!-- <v-btn class="WM-Outline-Btn WM-Border mr-2 WM-Margin-BT-0 WM-Border-Black" style="padding: 10px 30px;">
<v-icon class="black&#45;&#45;text mr-2 caption">fas fa-share-square</v-icon> <v-icon class="black&#45;&#45;text mr-2 caption">fas fa-share-square</v-icon>
<span class="black&#45;&#45;text">EXPORT</span> <span class="black&#45;&#45;text">EXPORT</span>
</v-btn>--> </v-btn>-->
<router-link :to="{ name: 'AddPackage' }"> <router-link :to="{ name: 'AddPackage' }">
<v-btn class="WM-CyanBlueGradient-BG WM-Margin-BT-0" style="padding:10px 30px"> <v-btn class="WM-CyanBlueGradient-BG WM-Margin-BT-0" style="padding:10px 30px">
@@ -261,8 +263,8 @@ export default {
getStatus(item) { getStatus(item) {
if (item.status === 'pending') { if (item.status === 'pending') {
return [ return [
{status: 'approved', label: 'approve', color: 'cyan' , font_color : 'white', icon: 'fa-check'}, {status: 'approved', label: 'approve', color: 'cyan', font_color: 'white', icon: 'fa-check'},
{status: 'rejected', label: 'reject', color: 'light-gray' ,font_color : 'black', icon: 'fa-close'}, {status: 'rejected', label: 'reject', color: 'light-gray', font_color: 'black', icon: 'fa-close'},
] ]
} else { } else {
const nextStatus = item.status === 'rejected' ? 'approved' : 'rejected' const nextStatus = item.status === 'rejected' ? 'approved' : 'rejected'
@@ -293,11 +295,18 @@ export default {
} }
}, },
async transfer(data) { async transfer(data) {
this.changeCurrentModal({ const result = this.changeCurrentModal({
modal: "modal-user-list", modal: "modal-user-list",
properties: {data}, properties: {data, type:'package'},
}); });
} if (result && result.status === 200) {
for (const key in this.items) {
if (this.items.hasOwnProperty(key) && this.items[key].id === data.id) {
this.items.splice(key, 1);
}
}
}
},
}, },
computed: { computed: {
...mapGetters("modal", ["getModalResult"]) ...mapGetters("modal", ["getModalResult"])
+9 -2
View File
@@ -292,10 +292,17 @@ export default {
} }
}, },
async transfer(data) { async transfer(data) {
this.changeCurrentModal({ const result = this.changeCurrentModal({
modal: "modal-user-list", modal: "modal-user-list",
properties: {data}, properties: {data, type:'package'},
}); });
if (result && result.status === 200) {
for (const key in this.items) {
if (this.items.hasOwnProperty(key) && this.items[key].id === data.id) {
this.items.splice(key, 1);
}
}
}
}, },
async changeStatus(item, status) { async changeStatus(item, status) {
const result = await ApiService.post(urls.changePackageStatus(item.id), {status}) const result = await ApiService.post(urls.changePackageStatus(item.id), {status})