update userinformation and fetchitemmovement

This commit is contained in:
ameerulrasyid 2025-03-05 09:45:35 +08:00
parent a0d84272aa
commit 7e5f3e3b36
3 changed files with 129 additions and 89 deletions

View File

@ -104,9 +104,13 @@
<strong>Latest Movement</strong>
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<!-- Movement Type -->
<h3 :class="movement.toOther === 'On Delivery' ? 'text-primary' : 'text-warning'"
class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;">
{{ movement.toOther === 'On Delivery' ? 'Receive' : 'Return' }}
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther !== 'On Delivery' && movement.action !== 'Assign',
'text-info': movement.action === 'Assign'}"
class="flex-shrink-0 text-nowrap"
style="max-width:90px; min-width:90px;">
{{ movement.action === 'Assign' ? 'Assign' : (movement.toOther === 'On Delivery' ? 'Receive' : 'Return') }}
</h3>
<!-- Send Date -->
@ -186,7 +190,7 @@
</div>
</div>
@* <!-- 📌 Single View History Button --> *@
<!-- 📌 Single View History Button -->
<button class="btn btn-light w-100 text-left" v-on:click="toggleHistory(itemId)">
<i :class="historyVisible[itemId] ? 'fas fa-chevron-up' : 'fas fa-chevron-down'"></i> View History
</button>
@ -195,9 +199,13 @@
<div v-for="(movement, i) in group.movements.slice(1)" :key="i" class="row mt-2">
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<!-- Movement Type -->
<h3 :class="movement.toOther === 'On Delivery' ? 'text-primary' : 'text-warning'"
class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;">
{{ movement.toOther === 'On Delivery' ? 'Receive' : 'Return' }}
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther !== 'On Delivery' && movement.action !== 'Assign',
'text-info': movement.action === 'Assign'}"
class="flex-shrink-0 text-nowrap"
style="max-width:90px; min-width:90px;">
{{ movement.action === 'Assign' ? 'Assign' : (movement.toOther === 'On Delivery' ? 'Receive' : 'Return') }}
</h3>
<!-- Send Date -->
@ -282,37 +290,37 @@
</div>
</div>
@* <div class="modal fade" id="remarkModal" tabindex="-1" aria-labelledby="remarkModalLabel" aria-hidden="true"> *@
@* <div class="modal-dialog"> *@
@* <div class="modal-content"> *@
@* <div class="modal-header"> *@
@* <h5 class="modal-title" id="remarkModalLabel">Remark</h5> *@
@* <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> *@
@* </div> *@
@* <div class="modal-body" id="remarkContent"> *@
@* <!-- Remark Content Here --> *@
@* </div> *@
@* <div class="modal-footer"> *@
@* <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> *@
@* </div> *@
@* </div> *@
@* </div> *@
@* </div> *@
@* <div class="modal fade" id="consignmentModal" tabindex="-1" aria-labelledby="consignmentModalLabel" aria-hidden="true"> *@
@* <div class="modal-dialog modal-xl"> *@
@* <div class="modal-content"> *@
@* <div class="modal-header"> *@
@* <h5 class="modal-title" id="consignmentModalLabel">Consignment Note</h5> *@
@* <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> *@
@* </div> *@
@* <div class="modal-body text-center"> *@
@* <img v-if="/\.(jpeg|jpg|png|gif)$/i.test(consignmentNoteUrl)" :src="consignmentNoteUrl" class="img-fluid" alt="Consignment Note Image"> *@
@* <iframe v-else-if="/\.pdf$/i.test(consignmentNoteUrl)" :src="consignmentNoteUrl" style="width:100%; height: 80vh;"></iframe> *@
@* <a v-else class="btn btn-primary">There's no Folder or Picture</a> *@
@* </div> *@
@* </div> *@
@* </div> *@
@* </div> *@
<div class="modal fade" id="remarkModal" tabindex="-1" aria-labelledby="remarkModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="remarkModalLabel">Remark</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="remarkContent">
<!-- Remark Content Here -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="consignmentModal" tabindex="-1" aria-labelledby="consignmentModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="consignmentModalLabel">Consignment Note</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body text-center">
<img v-if="/\.(jpeg|jpg|png|gif)$/i.test(consignmentNoteUrl)" :src="consignmentNoteUrl" class="img-fluid" alt="Consignment Note Image">
<iframe v-else-if="/\.pdf$/i.test(consignmentNoteUrl)" :src="consignmentNoteUrl" style="width:100%; height: 80vh;"></iframe>
<a v-else class="btn btn-primary">There's no Folder or Picture</a>
</div>
</div>
</div>
</div>
</div>
</div>
@ -338,36 +346,36 @@
const app = Vue.createApp({
data() {
return {
companies: [
{
companyId: 1,
companyName: "PSTW",
departments: [{ departmentId: 1, departmentName: "Air" }, { departmentId: 2, departmentName: "Marine" }, { departmentId: 3, departmentName: "River" }]
},
{
companyId: 2,
companyName: "TES",
departments: [{ departmentId: 1, departmentName: "Air" }],
},
],
company: "",
Dept: null,
teamTypes: ["Continuous", "Manual"],
teamType: "",
productName: null,
imageProduct: null,
productCategory: null,
serialNumber: "",
quantity: 1,
supplierName: null,
purchaseDate: null,
PO: null,
currency: "MYR",
DefaultPrice: 0.01,
currencyRate: 1,
convertPrice: 0.01,
DONo:null,
DODate: null,
// companies: [
// {
// companyId: 1,
// companyName: "PSTW",
// departments: [{ departmentId: 1, departmentName: "Air" }, { departmentId: 2, departmentName: "Marine" }, { departmentId: 3, departmentName: "River" }]
// },
// {
// companyId: 2,
// companyName: "TES",
// departments: [{ departmentId: 1, departmentName: "Air" }],
// },
// ],
// company: "",
// Dept: null,
// teamTypes: ["Continuous", "Manual"],
// teamType: "",
// productName: null,
// imageProduct: null,
// productCategory: null,
// serialNumber: "",
// quantity: 1,
// supplierName: null,
// purchaseDate: null,
// PO: null,
// currency: "MYR",
// DefaultPrice: 0.01,
// currencyRate: 1,
// convertPrice: 0.01,
// DONo:null,
// DODate: null,
warranty: 0,
EndWDate: null,
invoiceNo: null,
@ -378,16 +386,16 @@
stations: [],
stores: [],
users:[],
suppliers: [
{
supplierId: 1,
supplierName: "Pang",
},
{
supplierId: 2,
supplierName: "Ms Kim",
},
],
// suppliers: [
// {
// supplierId: 1,
// supplierName: "Pang",
// },
// {
// supplierId: 2,
// supplierName: "Ms Kim",
// },
// ],
isModalOpen: false,
selectedProduct: "",
selectedSupplier: "",
@ -395,15 +403,16 @@
selectedDepartment: "",
selectedTeamType: "",
selectedtoStation: "",
currencies: {},
consignmentNoteUrl: "",
// currencies: {},
showItemModal: false,
loading: false,
thisQRInfo: {
uniqueID: null,
departmentName: null,
serialNumber: null,
endWDate: null,
},
// thisQRInfo: {
// uniqueID: null,
// departmentName: null,
// serialNumber: null,
// endWDate: null,
// },
items: [],
currentUser: null,
currentUserCompanyDept: null,
@ -450,7 +459,27 @@
},
methods: {
remark(remark) {
document.getElementById("remarkContent").innerText = remark || "No remark message provide.";
let modal = new bootstrap.Modal(document.getElementById("remarkModal"));
modal.show();
},
consignmentNote(consignmentNote) {
if (!consignmentNote) {
this.consignmentNoteUrl = "No consignment note available.";
new bootstrap.Modal(document.getElementById('consignmentModal')).show();
return;
}
// Pastikan URL betul
this.consignmentNoteUrl = consignmentNote;
// Tunggu Vue update sebelum buka modal
this.$nextTick(() => {
new bootstrap.Modal(document.getElementById('consignmentModal')).show();
});
},
initiateTable() {
this.loading = true;
@ -590,10 +619,14 @@
const data = await response.json();
this.items = data.filter(item =>
item.toUser === this.currentUser.id ||
item.lastUser === this.currentUser.id
item.lastUser === this.currentUser.id ||
item.toStore === this.currentUser.store
);
console.log(this.items);
}
// const allowedKeys = ["toUser", "lastUser"];
// this.items = (await response.json()).filter(item => allowedKeys.some(key => item[key] === this.currentUser.id));

View File

@ -43,14 +43,19 @@ namespace PSTW_CentralSystem.Controllers.API
return NotFound(new { message = $"Unable to load user with ID '{_userManager.GetUserId(User)}'." });
}
var userInfo = await _identityDbContext.Users.Include(u => u.Department).Select(u => new
var storeId = await _identityDbContext.InventoryMasters.Where(s => s.UserId == user.Id).Select(s => s.StoreId).FirstOrDefaultAsync();
var userInfo = await _identityDbContext.Users.Include(u => u.Department)
.Include(u => u.Store)
.Select(u => new
{
id = u.Id,
email = u.NormalizedEmail,
company = u.Department!.Company!.CompanyName,
department = u.Department,
role = userRole,
}).Where(u => u.id == user.Id).FirstOrDefaultAsync();
store = storeId != 0 ? storeId : (int?)null
}).Where(u => u.id == user.Id).FirstOrDefaultAsync();
if (userInfo == null)
{

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Identity;
using PSTW_CentralSystem.Areas.Inventory.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@ -13,5 +14,6 @@ namespace PSTW_CentralSystem.Models
[ForeignKey("departmentId")]
public virtual DepartmentModel? Department { get; set; }
public virtual InventoryMasterModel? Store { get; set; }
}
}