This commit is contained in:
2024-07-22 10:42:32 +08:00
parent 6b1e74790b
commit a3f0288c92
6 changed files with 191 additions and 127 deletions

@@ -312,10 +312,15 @@ export default class CustomerCommunication {
const companyCode = div.querySelector('.title-company-code');
if (companyCode != null) {
if (nullOrEmpty(name)) {
div.querySelector('.title-company-name').innerText = r('P_WO_NOCUSTOMERASSIGNED', 'No Customer Assigned');
companyCode.innerText = ' /\n' + r('P_WO_SELECTCUSTOMER', 'Select Customer');
companyCode.style.display = '';
if (this._var.option.customerReadonly === true) {
div.style.display = 'none';
} else {
div.querySelector('.title-company-name').innerText = r('P_WO_NOCUSTOMERASSIGNED', 'No Customer Assigned');
companyCode.innerText = ' /\n' + r('P_WO_SELECTCUSTOMER', 'Select Customer');
companyCode.style.display = '';
}
} else {
div.style.display = '';
div.querySelector('.title-company-name').innerText = name;
companyCode.style.display = 'none';
}
@@ -474,7 +479,9 @@ export default class CustomerCommunication {
}),
createElement('span', span => {
span.className = 'title-company-code';
if (nullOrEmpty(option.companyName)) {
if (option.customerReadonly === true) {
span.style.display = 'none';
} else if (nullOrEmpty(option.companyName)) {
span.innerText = ' /\n' + r('P_WO_SELECTCUSTOMER', 'Select Customer');
} else if (!nullOrEmpty(option.companyCode)) {
span.innerText = ' / ' + option.companyCode;

@@ -54,7 +54,7 @@ export default class InspectionWizard extends OptionBase {
super(opt);
}
async create() {
async create(asset) {
const option = this._option;
const loading = flag => this._var.popup.loading = flag;
const assetSelector = new AssetSelector({
@@ -68,6 +68,7 @@ export default class InspectionWizard extends OptionBase {
loading,
requestTemplates: option.requestTemplates
});
this._var.templateSelector = templateSelector;
assetSelector.onSelected = asset => {
this._var.asset = asset;
this._var.template = null;
@@ -127,24 +128,43 @@ export default class InspectionWizard extends OptionBase {
});
this._var.popup = popup;
popup.create();
this._changePage(0);
if (asset) {
this._changePage(1);
this._var.asset = asset;
templateSelector.assetId = asset.Id;
const footerButtons = popup.container.querySelectorAll('.ui-popup-footer>.ui-popup-button');
footerButtons[0].style.display = 'none';
}
else
this._changePage(0);
popup.rect = { width: 1220 };
const mask = await popup.show();
assetSelector.init();
return mask;
}
show() {
show(asset) {
if (this._var.popup == null) {
return this.create();
return this.create(asset);
}
if (asset) {
this._var.asset = asset;
this._var.template = null;
this._changePage(1);
this._var.templateSelector._var.el.inputSearch.value = '';
this._var.templateSelector.assetId = asset.Id;
const footerButtons = this._var.popup.container.querySelectorAll('.ui-popup-footer>.ui-popup-button');
footerButtons[0].style.display = 'none';
}
else {
this._changePage(0);
const selector = this._var.assetSelector;
selector._var.el.inputSearch.value = '';
selector._var.el.dropAssetGroup.select('-1');
selector._var.el.dropJobsite.select('-1');
selector._var.el.dropJobsiteCode.select('-1');
selector.refresh();
}
this._changePage(0);
const selector = this._var.assetSelector;
selector._var.el.inputSearch.value = '';
selector._var.el.dropAssetGroup.select('-1');
selector._var.el.dropJobsite.select('-1');
selector._var.el.dropJobsiteCode.select('-1');
selector.refresh();
return this._var.popup.show();
}

@@ -90,6 +90,10 @@
}
}
&.ui-switch-red>span:first-of-type::before {
background-color: var(--red-color);
}
>input[type="checkbox"] {
display: none;
@@ -112,4 +116,33 @@
}
}
}
}
.ui-switch-group {
line-height: 1rem;
user-select: none;
display: inline-flex;
background-color: var(--switch-bg-color);
border-radius: 10px;
>label {
>span {
display: block;
padding: 4px 10px;
margin: 2px;
border-radius: 8px;
cursor: pointer;
}
}
>label>input[type="radio"] {
display: none;
&:checked+span {
background-color: white;
box-shadow: 1px 1px 8px rgb(0 0 0 / 20%);
transition: background-color .08s ease;
}
}
}

@@ -1433,6 +1433,10 @@ export class Grid {
});
grid.addEventListener('mousedown', e => {
if (e.target === this._var.el) {
if (e.offsetX < 0 || e.offsetX > e.target.clientWidth || e.offsetY < 0 || e.offsetY > e.target.clientHeight) {
// except scroll bars
return;
}
// cancel selections
const selectedIndexes = this._var.selectedIndexes;
if (selectedIndexes?.length > 0) {