Update
This commit is contained in:
parent
d6d151a3c7
commit
6e44454808
@ -80,14 +80,14 @@
|
|||||||
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
|
<div class="modal-dialog modal-dialog-centered modal-xl" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title" id="addItemModalLabel">{{editSection? 'Edit Item' : 'Add Item'}}</h5>
|
<h5 class="modal-title" id="addItemModalLabel">Add Item</h5>
|
||||||
<button type="button" class="closeModal" data-dismiss="modal" aria-label="Close" v-on:click="showItemModal=false">
|
<button type="button" class="closeModal" data-dismiss="modal" aria-label="Close" v-on:click="showItemModal=false">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<form v-on:submit.prevent="editSection ? submitEditItem() : addItem()" data-aos="fade-right">
|
<form v-on:submit.prevent="addItem" data-aos="fade-right">
|
||||||
<div class=" register" data-aos="fade-right">
|
<div class=" register" data-aos="fade-right">
|
||||||
<div class="row" data-aos="fade-right">
|
<div class="row" data-aos="fade-right">
|
||||||
|
|
||||||
@ -95,7 +95,7 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="tab-content" id="myTabContent">
|
<div class="tab-content" id="myTabContent">
|
||||||
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
|
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
|
||||||
<h3 class="register-heading">{{editSection? 'EDIT ITEM' : 'REGISTRATION ITEM'}}</h3>
|
<h3 class="register-heading">REGISTRATION ITEM</h3>
|
||||||
<div class="row register-form">
|
<div class="row register-form">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
|
||||||
@ -288,7 +288,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="DONo" class="col-sm-4">Enter DO Number:</label>
|
<label for="DONo" class="col-sm-4">Enter DO Number:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="text" id="DONo" name="DONo" class="form-control" v-model="DONo" placeholder="DO123456" required>
|
<input type="text" id="DONo" name="DONo" class="form-control" v-model="DONo" placeholder="DO123456">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -296,7 +296,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="DODate" class="col-sm-4">Enter DO Date:</label>
|
<label for="DODate" class="col-sm-4">Enter DO Date:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="date" id="DODate" name="DODate" class="form-control" v-on:input="calculateWarrantyEndDate()" v-model="DODate" required>
|
<input type="date" id="DODate" name="DODate" class="form-control" v-on:input="calculateWarrantyEndDate()" v-model="DODate">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -304,7 +304,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="warranty" class="col-sm-4">Enter Warranty (Months):</label>
|
<label for="warranty" class="col-sm-4">Enter Warranty (Months):</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="number" id="warranty" name="warranty" class="form-control" placeholder="0 , 1 , 2 , 3, ..." step="1" min="0" v-on:input="calculateWarrantyEndDate()" v-model="warranty" required>
|
<input type="number" id="warranty" name="warranty" class="form-control" placeholder="0 , 1 , 2 , 3, ..." step="1" min="0" v-on:input="calculateWarrantyEndDate()" required v-model="warranty">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -320,7 +320,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="invoiceNo" class="col-sm-4">Invoice Number:</label>
|
<label for="invoiceNo" class="col-sm-4">Invoice Number:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="text" id="invoiceNo" name="invoiceNo" class="form-control" v-model="invoiceNo" placeholder="Invoice123456" required>
|
<input type="text" id="invoiceNo" name="invoiceNo" class="form-control" v-model="invoiceNo" placeholder="Invoice123456">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -328,7 +328,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="invoiceDate" class="col-sm-4">Invoice Date:</label>
|
<label for="invoiceDate" class="col-sm-4">Invoice Date:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="date" id="invoiceDate" name="invoiceDate" class="form-control" v-model="invoiceDate" required>
|
<input type="date" id="invoiceDate" name="invoiceDate" class="form-control" v-model="invoiceDate">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -367,8 +367,6 @@
|
|||||||
$('#addItemBtn').on('click', function () {
|
$('#addItemBtn').on('click', function () {
|
||||||
// Show the modal with the ID 'addManufacturerModal'.
|
// Show the modal with the ID 'addManufacturerModal'.
|
||||||
$('#registerItemModal').modal('show');
|
$('#registerItemModal').modal('show');
|
||||||
this.addSection = true;
|
|
||||||
this.editSection = false;
|
|
||||||
});
|
});
|
||||||
$('.closeModal').on('click', function () {
|
$('.closeModal').on('click', function () {
|
||||||
// Show the modal with the ID 'addManufacturerModal'.
|
// Show the modal with the ID 'addManufacturerModal'.
|
||||||
@ -396,22 +394,19 @@
|
|||||||
teamType: "",
|
teamType: "",
|
||||||
productName: null,
|
productName: null,
|
||||||
imageProduct: null,
|
imageProduct: null,
|
||||||
addSection: false,
|
|
||||||
editSection: false,
|
|
||||||
productCategory: null,
|
productCategory: null,
|
||||||
itemID: null,
|
|
||||||
serialNumber: "",
|
serialNumber: "",
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
supplierName: null,
|
supplierName: null,
|
||||||
purchaseDate: null,
|
purchaseDate: null,
|
||||||
PO: null,
|
PO: null,
|
||||||
currency: "MYR",
|
currency: "MYR",
|
||||||
DefaultPrice: null,
|
DefaultPrice: 0.01,
|
||||||
currencyRate: 1,
|
currencyRate: 1,
|
||||||
convertPrice: 0.01,
|
convertPrice: 0.01,
|
||||||
DONo: null,
|
DONo: null,
|
||||||
DODate: null,
|
DODate: null,
|
||||||
warranty: null,
|
warranty: 0,
|
||||||
EndWDate: null,
|
EndWDate: null,
|
||||||
invoiceNo: null,
|
invoiceNo: null,
|
||||||
invoiceDate: null,
|
invoiceDate: null,
|
||||||
@ -455,19 +450,6 @@
|
|||||||
this.fetchCompanies();
|
this.fetchCompanies();
|
||||||
this.fetchProducts();
|
this.fetchProducts();
|
||||||
this.fetchSuppliers();
|
this.fetchSuppliers();
|
||||||
|
|
||||||
document.getElementById('addItemBtn').addEventListener('click', () => {
|
|
||||||
this.resetForm();
|
|
||||||
this.addSection = true;
|
|
||||||
this.editSection = false;
|
|
||||||
$('#registerItemModal').modal('show');
|
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelectorAll('.closeModal').forEach(btn => {
|
|
||||||
btn.addEventListener('click', () => {
|
|
||||||
$('.modal').modal('hide');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
filteredDepartments() {
|
filteredDepartments() {
|
||||||
@ -480,7 +462,7 @@
|
|||||||
},
|
},
|
||||||
showProduct() {
|
showProduct() {
|
||||||
if (!this.selectedProduct) {
|
if (!this.selectedProduct) {
|
||||||
return []; // No company selected, return empty listx`
|
return []; // No company selected, return empty list
|
||||||
}
|
}
|
||||||
const product = this.products.find(c => c.productId === this.selectedProduct);
|
const product = this.products.find(c => c.productId === this.selectedProduct);
|
||||||
return product ? product : {};
|
return product ? product : {};
|
||||||
@ -491,18 +473,6 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async addItem() {
|
async addItem() {
|
||||||
|
|
||||||
// List of required fields
|
|
||||||
const requiredFields = ['DefaultPrice', 'DONo', 'DODate', 'warranty', 'invoiceNo', 'invoiceDate'];
|
|
||||||
|
|
||||||
// Loop through required fields and check if any are null or empty
|
|
||||||
for (let field of requiredFields) {
|
|
||||||
if (this[field] === null || this[field] === '') {
|
|
||||||
alert('Item Error', `Please fill in required fields: ${field}.`, 'warning');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.showProduct.category == "Disposable") {
|
if (this.showProduct.category == "Disposable") {
|
||||||
this.serialNumber = "";
|
this.serialNumber = "";
|
||||||
}
|
}
|
||||||
@ -519,11 +489,9 @@
|
|||||||
DefaultPrice: this.DefaultPrice,
|
DefaultPrice: this.DefaultPrice,
|
||||||
CurrencyRate: this.currencyRate,
|
CurrencyRate: this.currencyRate,
|
||||||
ConvertPrice: this.convertPrice,
|
ConvertPrice: this.convertPrice,
|
||||||
DONo: this.DONo,
|
|
||||||
DODate: this.DODate,
|
DODate: this.DODate,
|
||||||
Warranty: this.warranty,
|
Warranty: this.warranty,
|
||||||
EndWDate: this.EndWDate,
|
EndWDate: this.EndWDate,
|
||||||
InvoiceNo: this.invoiceNo,
|
|
||||||
InvoiceDate: this.invoiceDate,
|
InvoiceDate: this.invoiceDate,
|
||||||
CreatedByUserId: this.currentUser.id,
|
CreatedByUserId: this.currentUser.id,
|
||||||
TeamType: this.selectedTeamType,
|
TeamType: this.selectedTeamType,
|
||||||
@ -632,7 +600,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Price(RM)",
|
"title": "Price(RM)",
|
||||||
"data": (row) => parseFloat(row.convertPrice).toFixed(2),
|
"data": "convertPrice",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Register Date",
|
"title": "Register Date",
|
||||||
@ -658,15 +626,6 @@
|
|||||||
Station: ${currentStation}`
|
Station: ${currentStation}`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"title": "Edit",
|
|
||||||
"data": "itemID",
|
|
||||||
"render": function (data) {
|
|
||||||
var editButton = `<button type="button" class="btn btn-success edit-btn" data-id="${data}">Edit</button>`;
|
|
||||||
return editButton;
|
|
||||||
},
|
|
||||||
"className": "align-middle",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Delete",
|
"title": "Delete",
|
||||||
"data": "itemID",
|
"data": "itemID",
|
||||||
@ -712,12 +671,6 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Attach click event listener to the edit buttons
|
|
||||||
$('#itemDatatable tbody').off('click', '.edit-btn').on('click', '.edit-btn', function () {
|
|
||||||
const itemId = $(this).data('id');
|
|
||||||
self.editItem(itemId);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Attach click event listener to the delete buttons
|
// Attach click event listener to the delete buttons
|
||||||
$('#itemDatatable tbody').off('click', '.delete-btn').on('click', '.delete-btn', function () {
|
$('#itemDatatable tbody').off('click', '.delete-btn').on('click', '.delete-btn', function () {
|
||||||
const itemId = $(this).data('id');
|
const itemId = $(this).data('id');
|
||||||
@ -843,6 +796,48 @@
|
|||||||
console.error('Error fetching currency data:', error);
|
console.error('Error fetching currency data:', error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
convertCurrency() {
|
||||||
|
// Your currency conversion logic here
|
||||||
|
console.log('Selected currency:', this.currency);
|
||||||
|
},
|
||||||
|
resetForm() {
|
||||||
|
this.company = '';
|
||||||
|
this.Dept = null;
|
||||||
|
this.productName = null;
|
||||||
|
this.imageProduct = null;
|
||||||
|
this.serialNumber = '';
|
||||||
|
this.quantity = 1;
|
||||||
|
this.supplierName = null;
|
||||||
|
this.purchaseDate = null;
|
||||||
|
this.PO = null;
|
||||||
|
this.currency = 'MYR';
|
||||||
|
this.DefaultPrice = 0.01;
|
||||||
|
this.currencyRate = 1;
|
||||||
|
this.convertPrice = 0.01;
|
||||||
|
this.DODate = null;
|
||||||
|
this.warranty = 0;
|
||||||
|
this.EndWDate = null;
|
||||||
|
this.invoiceDate = null;
|
||||||
|
this.selectedProduct = '';
|
||||||
|
this.selectedSupplier = '';
|
||||||
|
this.selectedCompany = this.currentUserCompanyDept.companyId;
|
||||||
|
this.selectedDepartment = '';
|
||||||
|
this.selectedTeamType = '';
|
||||||
|
this.partNumber = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
// FRONT END FUNCTIONS
|
||||||
|
//----------------------//
|
||||||
|
//Calculate Total Price
|
||||||
|
convertCurrency() {
|
||||||
|
const total = this.DefaultPrice * this.currencyRate;
|
||||||
|
this.convertPrice = total.toFixed(2);
|
||||||
|
this.DefaultPrice = this.DefaultPrice
|
||||||
|
// .replace(/[^0-9.]/g, '') // Remove non-numeric characters except decimal points
|
||||||
|
// .replace(/(\..*)\..*/g, '$1') // Allow only one decimal point
|
||||||
|
// .replace(/^(\d*\.\d{0,2})\d*$/, '$1'); // Limit to two decimal places
|
||||||
|
|
||||||
|
},
|
||||||
calculateWarrantyEndDate() {
|
calculateWarrantyEndDate() {
|
||||||
// Check if DODate and warranty are valid
|
// Check if DODate and warranty are valid
|
||||||
if (!this.DODate || isNaN(Date.parse(this.DODate))) {
|
if (!this.DODate || isNaN(Date.parse(this.DODate))) {
|
||||||
@ -861,51 +856,6 @@
|
|||||||
this.EndWDate = null;
|
this.EndWDate = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
convertCurrency() {
|
|
||||||
// Your currency conversion logic here
|
|
||||||
console.log('Selected currency:', this.currency);
|
|
||||||
},
|
|
||||||
resetForm() {
|
|
||||||
this.company = '';
|
|
||||||
this.Dept = null;
|
|
||||||
this.productName = null;
|
|
||||||
this.imageProduct = null;
|
|
||||||
this.serialNumber = '';
|
|
||||||
this.quantity = 1;
|
|
||||||
this.supplierName = null;
|
|
||||||
this.purchaseDate = null;
|
|
||||||
this.PO = null;
|
|
||||||
this.currency = 'MYR';
|
|
||||||
this.DefaultPrice = null;
|
|
||||||
this.currencyRate = 1;
|
|
||||||
this.convertPrice = 0.01;
|
|
||||||
this.DODate = null;
|
|
||||||
this.warranty = null;
|
|
||||||
this.DONo = null;
|
|
||||||
this.invoiceNo = null;
|
|
||||||
this.EndWDate = null;
|
|
||||||
this.invoiceDate = null;
|
|
||||||
this.selectedProduct = '';
|
|
||||||
this.selectedSupplier = '';
|
|
||||||
// this.selectedCompany = this.currentUserCompanyDept.companyId;
|
|
||||||
// this.selectedDepartment = '';
|
|
||||||
this.selectedTeamType = '';
|
|
||||||
this.partNumber = null;
|
|
||||||
},
|
|
||||||
|
|
||||||
// FRONT END FUNCTIONS
|
|
||||||
//----------------------//
|
|
||||||
//Calculate Total Price
|
|
||||||
convertCurrency() {
|
|
||||||
const total = this.DefaultPrice * this.currencyRate;
|
|
||||||
this.convertPrice = total.toFixed(2);
|
|
||||||
this.DefaultPrice = this.DefaultPrice
|
|
||||||
// .replace(/[^0-9.]/g, '') // Remove non-numeric characters except decimal points
|
|
||||||
// .replace(/(\..*)\..*/g, '$1') // Allow only one decimal point
|
|
||||||
// .replace(/^(\d*\.\d{0,2})\d*$/, '$1'); // Limit to two decimal places
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
async deleteItem(itemId) {
|
async deleteItem(itemId) {
|
||||||
if (!confirm("Are you sure you want to delete this item?")) {
|
if (!confirm("Are you sure you want to delete this item?")) {
|
||||||
return;
|
return;
|
||||||
@ -936,127 +886,6 @@
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async editItem(itemID) {
|
|
||||||
// Cari data item yang dipilih
|
|
||||||
const item = this.items.find(s => s.itemID === itemID);
|
|
||||||
if (!item) {
|
|
||||||
alert('Error', 'Item not found!', 'warning');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate form fields
|
|
||||||
this.itemID = itemID;
|
|
||||||
this.selectedCompany = item.companyId;
|
|
||||||
this.selectedDepartment = item.departmentId;
|
|
||||||
this.selectedProduct = item.productId;
|
|
||||||
this.serialNumber = item.serialNumber;
|
|
||||||
this.quantity = item.quantity;
|
|
||||||
this.selectedSupplier = item.supplier;
|
|
||||||
this.purchaseDate = item.purchaseDate.split('/').reverse().join('-');
|
|
||||||
this.PO = item.poNo;
|
|
||||||
this.currency = item.currency;
|
|
||||||
this.DefaultPrice = item.defaultPrice;
|
|
||||||
this.currencyRate = item.currencyRate;
|
|
||||||
this.convertPrice = item.convertPrice;
|
|
||||||
this.DONo = item.doNo;
|
|
||||||
this.DODate = item.doDate ? item.doDate.split('T')[0] : null;
|
|
||||||
this.warranty = item.warranty;
|
|
||||||
this.EndWDate = item.endWDate.split('/').reverse().join('-');
|
|
||||||
this.invoiceNo = item.invoiceNo;
|
|
||||||
this.invoiceDate = item.invoiceDate.split('/').reverse().join('-');
|
|
||||||
this.selectedTeamType = item.teamType;
|
|
||||||
this.partNumber = item.partNumber;
|
|
||||||
// Tunjukkan modal edit
|
|
||||||
$('#registerItemModal').modal('show');
|
|
||||||
this.addSection = false;
|
|
||||||
this.editSection = true;
|
|
||||||
},
|
|
||||||
|
|
||||||
async submitEditItem() {
|
|
||||||
|
|
||||||
// List of required fields
|
|
||||||
const requiredFields = ['DefaultPrice', 'DONo', 'DODate', 'warranty', 'invoiceNo', 'invoiceDate'];
|
|
||||||
|
|
||||||
// Loop through required fields and check if any are null or empty
|
|
||||||
for (let field of requiredFields) {
|
|
||||||
if (this[field] === null || this[field] === '') {
|
|
||||||
alert('Item Error', `Please fill in required fields: ${field}.`, 'warning');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.showProduct.category == "Disposable") {
|
|
||||||
this.serialNumber = "";
|
|
||||||
}
|
|
||||||
const formData = {
|
|
||||||
itemId : this.itemID,
|
|
||||||
CompanyId: this.selectedCompany,
|
|
||||||
DepartmentId: this.selectedDepartment,
|
|
||||||
ProductId: this.selectedProduct,
|
|
||||||
SerialNumber: this.serialNumber,
|
|
||||||
Quantity: this.quantity,
|
|
||||||
Supplier: this.selectedSupplier,
|
|
||||||
PurchaseDate: this.purchaseDate,
|
|
||||||
PONo: this.PO,
|
|
||||||
Currency: this.currency,
|
|
||||||
DefaultPrice: this.DefaultPrice,
|
|
||||||
CurrencyRate: this.currencyRate,
|
|
||||||
ConvertPrice: this.convertPrice,
|
|
||||||
DONo: this.DONo,
|
|
||||||
DODate: this.DODate,
|
|
||||||
Warranty: this.warranty,
|
|
||||||
EndWDate: this.EndWDate,
|
|
||||||
InvoiceNo: this.invoiceNo,
|
|
||||||
InvoiceDate: this.invoiceDate,
|
|
||||||
TeamType: this.selectedTeamType,
|
|
||||||
PartNumber: this.partNumber,
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
// Additional specific checks
|
|
||||||
if (this.showSerialNumber) {
|
|
||||||
this.quantity = 0;
|
|
||||||
if (this.serialNumber === null || this.serialNumber === '') {
|
|
||||||
alert('Serial Number Error', 'Serial Number must be filled when selecting Item or Part.', 'warning');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.serialNumber = null;
|
|
||||||
if (this.quantity === 0 || this.quantity === null || this.quantity === '') {
|
|
||||||
alert('quantity Error', 'Quantity is required when selecting Disposable.', 'warning');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const response = await fetch('/InvMainAPI/EditItem', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify(formData)
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
const errorData = await response.json();
|
|
||||||
console.error('Error response:', errorData);
|
|
||||||
this.errorMessage = 'Error: ' + (errorData.message || 'Unknown error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refresh station list and reset form
|
|
||||||
alert('Success!', 'Item form has been successfully submitted.', 'success');
|
|
||||||
this.fetchItem();
|
|
||||||
this.resetForm();
|
|
||||||
this.editSection = false;
|
|
||||||
this.addSection = false;
|
|
||||||
$('.modal').modal('hide');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error editing Item:', error);
|
|
||||||
this.errorMessage = 'Error: ' + error.message;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async printItem(itemId, imgSrc) {
|
async printItem(itemId, imgSrc) {
|
||||||
try {
|
try {
|
||||||
this.thisQRInfo.uniqueID = itemId;
|
this.thisQRInfo.uniqueID = itemId;
|
||||||
@ -1069,7 +898,7 @@
|
|||||||
|
|
||||||
// Safely set image content
|
// Safely set image content
|
||||||
const sanitizedImgSrc = encodeURI(imgSrc); // Sanitize the URL
|
const sanitizedImgSrc = encodeURI(imgSrc); // Sanitize the URL
|
||||||
container.innerHTML = `<img src="${sanitizedImgSrc}" alt="QR Code" class="text-center " />`;
|
container.innerHTML = `<img src="${sanitizedImgSrc}" alt="QR Code" class="text-center" style="width: 127px; height: 127px"; />`;
|
||||||
|
|
||||||
// Fetch QR information
|
// Fetch QR information
|
||||||
const qrInfo = this.getPrintedQR(uniqueQR);
|
const qrInfo = this.getPrintedQR(uniqueQR);
|
||||||
@ -1123,26 +952,26 @@
|
|||||||
printQRInfo() {
|
printQRInfo() {
|
||||||
// Create a virtual DOM element
|
// Create a virtual DOM element
|
||||||
const virtualElement = document.createElement('div');
|
const virtualElement = document.createElement('div');
|
||||||
virtualElement.style.width = '330px '; // Match label size for 2 inches at 203 DPI
|
virtualElement.style.width = '360px '; // Match label size for 2 inches at 203 DPI
|
||||||
virtualElement.style.height = '160px';
|
virtualElement.style.height = '180px';
|
||||||
virtualElement.style.position = 'absolute';
|
virtualElement.style.position = 'absolute';
|
||||||
virtualElement.style.left = '-9999px'; // Position offscreen to avoid rendering on the main UI
|
virtualElement.style.left = '-9999px'; // Position offscreen to avoid rendering on the main UI
|
||||||
// virtualElement.style.border = '1px solid #000'; // Optional: Add a border for debugging dimensions
|
// virtualElement.style.border = '1px solid #000'; // Optional: Add a border for debugging dimensions
|
||||||
|
|
||||||
// Populate the virtual DOM with content
|
// Populate the virtual DOM with content
|
||||||
virtualElement.innerHTML = `
|
virtualElement.innerHTML = `
|
||||||
<div class="container-fluid my-3 QrPrintFont" style="font-family: 'OCR A', monospace;">
|
<div class="container my-3 QrPrintFont" style="font-family: 'OCR A', monospace;">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-5 text-center d-flex align-items-center justify-content-center">
|
<div class="col-5 text-center d-flex align-items-center justify-content-center">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div>${this.thisQRInfo.imgContainer}</div>
|
<div>${this.thisQRInfo.imgContainer}</div>
|
||||||
<div class="col-12 h4"style="font-family: 'Arial', monospace;"><b>${this.thisQRInfo.uniqueID}</b></div>
|
<div class="col-12 my-1 h4"style="font-family: 'Arial', monospace;"><b>${this.thisQRInfo.uniqueID}</b></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-7 d-flex align-items-center justify-content-left">
|
<div class="col-7 d-flex align-items-center justify-content-left">
|
||||||
<div class="row-fluid">
|
<div class="row">
|
||||||
<div class="col-12 h3"style="font-family: 'Verdana', monospace;"><b>${this.thisQRInfo.departmentName}</b></div>
|
<div class="col-12 h3"style="font-family: 'Verdana', monospace;"><b>${this.thisQRInfo.departmentName}</b></div>
|
||||||
<div class="col-12 h4"style="font-family: 'Arial', monospace;"><b>${this.thisQRInfo.productShortName}</b></div>
|
<div class="col-12 h4"style="font-family: 'Arial', monospace;"><b>${this.thisQRInfo.productShortName}</b></div>
|
||||||
<div class="col-12 h4"style="font-family: 'Arial', monospace;"><b>${this.thisQRInfo.serialNumber ?? "-"}</b></div>
|
<div class="col-12 h4"style="font-family: 'Arial', monospace;"><b>${this.thisQRInfo.serialNumber ?? "-"}</b></div>
|
||||||
@ -1176,7 +1005,7 @@
|
|||||||
style: `
|
style: `
|
||||||
@@media print {
|
@@media print {
|
||||||
@@page {
|
@@page {
|
||||||
margin: 5px 5px 0px 5px;
|
margin: 0px 0px 0px 0px;
|
||||||
}
|
}
|
||||||
body { margin: 0; }
|
body { margin: 0; }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user