Update
This commit is contained in:
parent
f8e73bad3a
commit
8d3385f673
@ -16,15 +16,6 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div v-if="reportData">
|
<div v-if="reportData">
|
||||||
<div class="row justify-content-center">
|
<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="col-3">
|
||||||
<div class="row col-10">
|
<div class="row col-10">
|
||||||
<h4>Category</h4>
|
<h4>Category</h4>
|
||||||
@ -41,13 +32,6 @@
|
|||||||
<div class=""><button class="btn btn-danger" v-on:click="selectedItem = []">Clear</button></div>
|
<div class=""><button class="btn btn-danger" v-on:click="selectedItem = []">Clear</button></div>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -88,17 +72,24 @@
|
|||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<div class="row col-10">
|
<div class="row col-10">
|
||||||
<h4>Department</h4>
|
<h4>Department</h4>
|
||||||
<multiselect v-model="selectedDepartment" :options="compDeptList" :multiple="true" group-values="departments" group-label="companyName"
|
<multiselect v-model="selectedSingleDepartment" :options="compDeptList" :multiple="false" group-values="departments" group-label="companyName"
|
||||||
:group-select="true" placeholder="Seach Department" track-by="departmentId" label="departmentName">
|
:group-select="false" placeholder="Search Department" track-by="departmentId" label="departmentName">
|
||||||
</multiselect>
|
</multiselect>
|
||||||
<div class=""><button class="btn btn-danger" v-on:click="selectedDepartment = []">Clear</button></div>
|
<div class=""><button class="btn btn-danger" v-on:click="selectedSingleDepartment = []">Clear</button></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<div class="row col-10">
|
<div class="row col-10">
|
||||||
<h4>Date filter</h4>
|
<h4>Date filter</h4>
|
||||||
<vue-date-picker v-model="selectedMonth" month-picker></vue-date-picker>
|
<vue-date-picker v-model="selectedMonth" month-picker auto-apply></vue-date-picker>
|
||||||
<div class=""><button class="btn btn-danger" v-on:click="selectedMonth = []">Clear</button></div>
|
<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>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@ -111,20 +102,13 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div v-if="reportData">
|
<div v-if="reportData">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
|
<div v-if="formResponse">
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<h4>Statistic</h4>
|
<h4>User List</h4>
|
||||||
<p>Total Number of Item Registered: {{ reportData.itemCountRegistered }}</p>
|
<multiselect v-model="selectedUser" :options="formResponse.userItemBalance" :multiple="false" placeholder="Select User" track-by="userId" label="userFullName"></multiselect>
|
||||||
<p>Total Number of Item Still in Stock: {{ reportData.itemCountStillInStock }}</p>
|
<div class=""><button class="btn btn-danger" v-on:click="selectedUser = []">Clear</button></div>
|
||||||
|
{{ selectedUser }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
|
||||||
<h4>Item Registered </h4>
|
|
||||||
<p>This Month: {{ reportData.itemCountRegisteredThisMonth }}</p>
|
|
||||||
<p>Last Month: {{ reportData.itemCountRegisteredLastMonth }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="col-3">
|
|
||||||
<h4>Item Stock Out </h4>
|
|
||||||
<p>This Month: {{ reportData.itemCountStockOutThisMonth }}</p>
|
|
||||||
<p>Last Month: {{ reportData.itemCountStockOutLastMonth }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -160,13 +144,22 @@
|
|||||||
productList: {},
|
productList: {},
|
||||||
categoryList:['Asset', 'Part', 'Disposable'],
|
categoryList:['Asset', 'Part', 'Disposable'],
|
||||||
monthList: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
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: [],
|
filteredProduct: [],
|
||||||
selectedMonth: [],
|
selectedMonth: null,
|
||||||
selectedDepartment: [],
|
selectedDepartment: [],
|
||||||
|
selectedSingleDepartment: null,
|
||||||
selectedItem: [],
|
selectedItem: [],
|
||||||
selectedCategory: [],
|
selectedCategory: [],
|
||||||
|
selectedPosition: [],
|
||||||
usersInfo: [],
|
usersInfo: [],
|
||||||
submitBody: null,
|
submitBody: null,
|
||||||
|
formResponse: null,
|
||||||
|
selectedUser: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -185,21 +178,48 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async generateReport(){
|
async generateReport(){
|
||||||
this.submitBody = {
|
if(this.selectedMonth == null || this.selectedSingleDepartment.length == 0 || this.selectedPosition.length == 0)
|
||||||
selectedMonth: this.selectedMonth,
|
{
|
||||||
selectedDepartment: this.selectedDepartment
|
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();
|
||||||
}
|
}
|
||||||
console.log(this.submitBody);
|
|
||||||
// this.fetchCurrentReport();
|
|
||||||
},
|
},
|
||||||
async fetchCurrentReport(){
|
async fetchCurrentReport(){
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/ReportingAPI/GetMonthlyReport/`, {
|
const response = await fetch(`/ReportingAPI/GetMonthlyReport/`, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(this.submitBody),
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
});
|
});
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data);
|
this.formResponse = data
|
||||||
|
console.log(this.formResponse);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.error(`Failed to fetch user: ${response.statusText}`);
|
console.error(`Failed to fetch user: ${response.statusText}`);
|
||||||
|
|||||||
@ -35,11 +35,11 @@ namespace PSTW_CentralSystem.Controllers.API
|
|||||||
|
|
||||||
public class ReportQuery
|
public class ReportQuery
|
||||||
{
|
{
|
||||||
string? FormDate { get; set; }
|
public string? FormDate { get; set; }
|
||||||
string? DeptId { get; set; }
|
public string? DeptId { get; set; }
|
||||||
int ToUser { get; set; }
|
public int ToUser { get; set; }
|
||||||
int ToStation { get; set; }
|
public int ToStation { get; set; }
|
||||||
int ToStore { get; set; }
|
public int ToStore { get; set; }
|
||||||
}
|
}
|
||||||
#region ItemReport
|
#region ItemReport
|
||||||
|
|
||||||
@ -135,10 +135,15 @@ namespace PSTW_CentralSystem.Controllers.API
|
|||||||
|
|
||||||
#region Monthly Report
|
#region Monthly Report
|
||||||
[HttpPost("GetMonthlyReport")]
|
[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
|
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 currentProductBalance = new List<ProductReport>();
|
||||||
var result = await _centralDbContext.Products
|
var result = await _centralDbContext.Products
|
||||||
.Select(p => new { p.ProductName, p.QuantityJSON })
|
.Select(p => new { p.ProductName, p.QuantityJSON })
|
||||||
@ -233,8 +238,10 @@ namespace PSTW_CentralSystem.Controllers.API
|
|||||||
ItemId = m.ItemId,
|
ItemId = m.ItemId,
|
||||||
ItemName = m.Item!.Product!.ProductName,
|
ItemName = m.Item!.Product!.ProductName,
|
||||||
Quantity = m.Quantity,
|
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();
|
.Where(u => u.Items.Count > 0).ToList();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user