Merge branch 'Beta_1.2' of https://git.pstw.com.my/catalyx/PSTW_CentralizeSystem into Beta_1.2
This commit is contained in:
commit
eab7931951
@ -16,15 +16,6 @@
|
||||
<div class="card-body">
|
||||
<div v-if="reportData">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-3">
|
||||
<div class="row col-10">
|
||||
<h4>Department</h4>
|
||||
<multiselect v-model="selectedDepartment" :options="compDeptList" :multiple="true" group-values="departments" group-label="companyName"
|
||||
:group-select="true" placeholder="Seach Department" track-by="departmentId" label="departmentName">
|
||||
</multiselect>
|
||||
<div class=""><button class="btn btn-danger" v-on:click="selectedDepartment = []">Clear</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="row col-10">
|
||||
<h4>Category</h4>
|
||||
@ -41,13 +32,6 @@
|
||||
<div class=""><button class="btn btn-danger" v-on:click="selectedItem = []">Clear</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="row col-10">
|
||||
<h4>Date filter</h4>
|
||||
<vue-date-picker v-model="selectedMonth" month-picker range></vue-date-picker>
|
||||
<div class=""><button class="btn btn-danger" v-on:click="selectedMonth = []">Clear</button></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -78,6 +62,58 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">User Report</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div v-if="reportData">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-3">
|
||||
<div class="row col-10">
|
||||
<h4>Department</h4>
|
||||
<multiselect v-model="selectedSingleDepartment" :options="compDeptList" :multiple="false" group-values="departments" group-label="companyName"
|
||||
:group-select="false" placeholder="Search Department" track-by="departmentId" label="departmentName">
|
||||
</multiselect>
|
||||
<div class=""><button class="btn btn-danger" v-on:click="selectedSingleDepartment = []">Clear</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="row col-10">
|
||||
<h4>Date filter</h4>
|
||||
<vue-date-picker v-model="selectedMonth" month-picker auto-apply></vue-date-picker>
|
||||
<div class=""><button class="btn btn-danger" v-on:click="selectedMonth = null">Clear</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="row col-10">
|
||||
<h4>Position Filter</h4>
|
||||
<multiselect v-model="selectedPosition" :options="positionList" :multiple="false" placeholder="Search Position" track-by="positionId" label="positionName"></multiselect>
|
||||
<div class=""><button class="btn btn-danger" v-on:click="selectedPosition = []">Clear</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<button class="btn btn-primary" v-on:click="generateReport">Generate Report</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="card-body">
|
||||
<div v-if="reportData">
|
||||
<div class="row justify-content-center">
|
||||
<div v-if="formResponse">
|
||||
<div class="col-3">
|
||||
<h4>User List</h4>
|
||||
<multiselect v-model="selectedUser" :options="formResponse.userItemBalance" :multiple="false" placeholder="Select User" track-by="userId" label="userFullName"></multiselect>
|
||||
<div class=""><button class="btn btn-danger" v-on:click="selectedUser = []">Clear</button></div>
|
||||
{{ selectedUser }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts {
|
||||
@{
|
||||
@ -108,17 +144,27 @@
|
||||
productList: {},
|
||||
categoryList:['Asset', 'Part', 'Disposable'],
|
||||
monthList: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
positionList: [
|
||||
{ positionId: 1, positionName: 'User' },
|
||||
{ positionId: 2, positionName: 'Station' },
|
||||
{ positionId: 3, positionName: 'Store' }
|
||||
],
|
||||
filteredProduct: [],
|
||||
selectedMonth: [],
|
||||
selectedMonth: null,
|
||||
selectedDepartment: [],
|
||||
selectedSingleDepartment: null,
|
||||
selectedItem: [],
|
||||
selectedCategory: []
|
||||
selectedCategory: [],
|
||||
selectedPosition: [],
|
||||
usersInfo: [],
|
||||
submitBody: null,
|
||||
formResponse: null,
|
||||
selectedUser: [],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchUser();
|
||||
this.fetchProductList();
|
||||
this.fetchCurrentReport();
|
||||
this.fetchDepartmentsCompaniesList();
|
||||
},
|
||||
watch: {
|
||||
@ -131,14 +177,49 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async generateReport(){
|
||||
if(this.selectedMonth == null || this.selectedSingleDepartment.length == 0 || this.selectedPosition.length == 0)
|
||||
{
|
||||
var msg = [];
|
||||
if(this.selectedMonth == null)
|
||||
{
|
||||
msg.push("Date");
|
||||
}
|
||||
if(this.selectedSingleDepartment.length == 0)
|
||||
{
|
||||
msg.push("Department");
|
||||
}
|
||||
if(this.selectedPosition.length == 0)
|
||||
{
|
||||
msg.push("Position");
|
||||
}
|
||||
alert(msg.length > 1 ? msg.join(" & ") + " cannot be empty" : msg[0] + " cannot be empty");
|
||||
}
|
||||
else{
|
||||
this.submitBody = {
|
||||
formDate: new Date(this.selectedMonth.year, this.selectedMonth.month + 1, 0, 23, 59, 59).toISOString().slice(0, 19),
|
||||
// selectedCategory: this.selectedCategory,
|
||||
deptId: this.selectedSingleDepartment.departmentCode,
|
||||
toUser: this.selectedPosition.positionId == 1 ? 1 : 0,
|
||||
toStation: this.selectedPosition.positionId == 2 ? 1 : 0,
|
||||
toStore: this.selectedPosition.positionId == 3 ? 1 : 0,
|
||||
}
|
||||
this.fetchCurrentReport();
|
||||
}
|
||||
},
|
||||
async fetchCurrentReport(){
|
||||
try {
|
||||
const response = await fetch(`/ReportingAPI/GetMonthlyReport/`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(this.submitBody),
|
||||
method: 'POST',
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
console.log(data);
|
||||
this.formResponse = data
|
||||
console.log(this.formResponse);
|
||||
}
|
||||
else {
|
||||
console.error(`Failed to fetch user: ${response.statusText}`);
|
||||
|
||||
@ -35,11 +35,11 @@ namespace PSTW_CentralSystem.Controllers.API
|
||||
|
||||
public class ReportQuery
|
||||
{
|
||||
string? FormDate { get; set; }
|
||||
string? DeptId { get; set; }
|
||||
int ToUser { get; set; }
|
||||
int ToStation { get; set; }
|
||||
int ToStore { get; set; }
|
||||
public string? FormDate { get; set; }
|
||||
public string? DeptId { get; set; }
|
||||
public int ToUser { get; set; }
|
||||
public int ToStation { get; set; }
|
||||
public int ToStore { get; set; }
|
||||
}
|
||||
#region ItemReport
|
||||
|
||||
@ -135,10 +135,15 @@ namespace PSTW_CentralSystem.Controllers.API
|
||||
|
||||
#region Monthly Report
|
||||
[HttpPost("GetMonthlyReport")]
|
||||
public async Task<IActionResult> GetMonthlyReport([FromBody] string FormDate = "2026/1/31", string DeptId = "PA", int ToUser = 1, int ToStation = 0, int ToStore = 0)
|
||||
public async Task<IActionResult> GetMonthlyReport([FromBody] ReportQuery reportQuery)
|
||||
{
|
||||
try
|
||||
{
|
||||
string FormDate = reportQuery.FormDate!;
|
||||
string DeptId = reportQuery.DeptId!;
|
||||
int ToUser = reportQuery.ToUser;
|
||||
int ToStation = reportQuery.ToStation;
|
||||
int ToStore = reportQuery.ToStore;
|
||||
var currentProductBalance = new List<ProductReport>();
|
||||
var result = await _centralDbContext.Products
|
||||
.Select(p => new { p.ProductName, p.QuantityJSON })
|
||||
@ -209,8 +214,8 @@ namespace PSTW_CentralSystem.Controllers.API
|
||||
.ToListAsync();
|
||||
|
||||
var latestItemMovements = await _centralDbContext.ItemMovements
|
||||
//.Include(m => m.Item)
|
||||
//.Include(m => m.Item!.Product)
|
||||
.Include(m => m.Item)
|
||||
.Include(m => m.Item!.Product)
|
||||
.Include(m => m.NextUser)
|
||||
.Where(m => m.ItemId != null && (ToUser > 0 ? m.ToUser != null : m.ToUser > 0) && (ToStation > 0 ? m.ToStation != null : m.ToStation > 0) && (ToStore > 0 ? m.ToStore != null : m.ToStore > 0))
|
||||
.GroupBy(m => m.ItemId)
|
||||
@ -233,8 +238,10 @@ namespace PSTW_CentralSystem.Controllers.API
|
||||
ItemId = m.ItemId,
|
||||
ItemName = m.Item!.Product!.ProductName,
|
||||
Quantity = m.Quantity,
|
||||
ItemPrice = m.Item!.ConvertPrice,
|
||||
})
|
||||
.ToList()
|
||||
.ToList(),
|
||||
TotalItemPrice = latestItemMovements.Where(m => m.ToUser == u.Id).Sum(m => m!.Item!.ConvertPrice * m.Quantity),
|
||||
})
|
||||
.Where(u => u.Items.Count > 0).ToList();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user