This commit is contained in:
2026-05-13 14:09:41 +08:00
parent 752bb23571
commit f3dfb6b68d
2 changed files with 45 additions and 4 deletions
+43 -2
View File
@@ -638,6 +638,7 @@ export default class AddWorkOrder extends OptionBase {
const data = await option.requestAssignedTo(asset.Id, loc?.ID ?? -1, this._var.el.dropDepartment.selected?.Id ?? -1) const data = await option.requestAssignedTo(asset.Id, loc?.ID ?? -1, this._var.el.dropDepartment.selected?.Id ?? -1)
this._var.el.dropAssignedTo.source = [{ IID: '', DisplayName: '' }, ...data]; this._var.el.dropAssignedTo.source = [{ IID: '', DisplayName: '' }, ...data];
} }
this.filterStatuses();
}; };
dropDepartment.onSelected = async dep => { dropDepartment.onSelected = async dep => {
// get assigned to // get assigned to
@@ -646,7 +647,11 @@ export default class AddWorkOrder extends OptionBase {
const data = await option.requestAssignedTo(asset.Id, this._var.el.dropLocation.selected?.ID ?? -1, dep?.Id ?? -1) const data = await option.requestAssignedTo(asset.Id, this._var.el.dropLocation.selected?.ID ?? -1, dep?.Id ?? -1)
this._var.el.dropAssignedTo.source = [{ IID: '', DisplayName: '' }, ...data]; this._var.el.dropAssignedTo.source = [{ IID: '', DisplayName: '' }, ...data];
} }
this.filterStatuses();
} }
dropWorkOrderType.onSelected = async loc => {
this.filterStatuses();
};
dateCompleted.value = new Date(); dateCompleted.value = new Date();
this._var.container = container; this._var.container = container;
const popup = new Popup({ const popup = new Popup({
@@ -905,8 +910,9 @@ export default class AddWorkOrder extends OptionBase {
dropDepartment.source = [{ Id: -1, Name: '' }, ...data.Departments]; dropDepartment.source = [{ Id: -1, Name: '' }, ...data.Departments];
this._var.params = data; this._var.params = data;
dropStatus.source = data.Statuses; this.filterStatuses();
const defaultStatus = data.Statuses.find(s => s.DefaultOnOpen); //dropStatus.source = data.Statuses;
const defaultStatus = dropStatus.source.find(s => s.DefaultOnOpen);
if (defaultStatus != null) { if (defaultStatus != null) {
dropStatus.select(defaultStatus.Id); dropStatus.select(defaultStatus.Id);
} }
@@ -914,4 +920,39 @@ export default class AddWorkOrder extends OptionBase {
textComplaint.focus(); textComplaint.focus();
return mask; return mask;
} }
filterStatuses() {
const wotype = this._var.el.dropWorkOrderType.selected?.Key;
let locs = [];
const loc = this._var.el.dropLocation.selected?.ID;
if (loc > 0)
locs.push(loc);
const subLocs = this._var.params?.Locations.filter(l => l.PId == loc).map(l => l.Id);
locs = locs.concat(subLocs);
let depts = [];
const dept = this._var.el.dropDepartment.selected?.Id;
if (dept > 0)
depts.push(dept);
const subDepts = this._var.params?.Departments.filter(d => d.PId == dept).map(d => d.Id);
depts = depts.concat(subDepts);
const workOrderStatus = this._var.params?.Statuses;
const ss = workOrderStatus.filter((s) => {
if (s.WorkOrderTypes?.length > 0 && !s.WorkOrderTypes.some(t => t.toLowerCase() == wotype?.toLowerCase()))
return false;
if (s.Locations?.length > 0 && !s.Locations.some(l => locs.includes(Number(l)))) {
return false
}
if (s.Departments?.length > 0 && !s.Departments.some(l => depts.includes(Number(l)))) {
return false
}
return true;
});
this._var.el.dropStatus.source = ss;
}
} }
+2 -2
View File
@@ -4386,7 +4386,7 @@ export class Grid {
this._var.refs.footer.parentElement.style.bottom = `${this._var.footerOffset - e.target.scrollTop}px`; this._var.refs.footer.parentElement.style.bottom = `${this._var.footerOffset - e.target.scrollTop}px`;
} }
const tti = this._topToIndex(top); const tti = this._topToIndex(top);
if (this.onBodyScrolled === 'function') { if (typeof this.onBodyScrolled === 'function') {
this.onBodyScrolled(e, tti.index, this._var.rowCount); this.onBodyScrolled(e, tti.index, this._var.rowCount);
} }
return; return;
@@ -4395,7 +4395,7 @@ export class Grid {
if (this.total != null) { if (this.total != null) {
this._var.refs.footer.parentElement.style.bottom = `${this._var.refs.table.offsetTop + this._var.footerOffset - e.target.scrollTop}px`; this._var.refs.footer.parentElement.style.bottom = `${this._var.refs.table.offsetTop + this._var.footerOffset - e.target.scrollTop}px`;
} }
if (this.onBodyScrolled === 'function') { if (typeof this.onBodyScrolled === 'function') {
this.onBodyScrolled(e, this._var.startIndex, this._var.rowCount); this.onBodyScrolled(e, this._var.startIndex, this._var.rowCount);
} }
if (this._var.isFirefox) { if (this._var.isFirefox) {