бебебебабаба
parent
dba801f34f
commit
6f784d149b
|
|
@ -10,8 +10,9 @@ use crate::{
|
|||
material_tab::MaterialTabViewer,
|
||||
misc,
|
||||
models::{
|
||||
Equipment, EquipmentModalState, LoginModalState, LoginStatus, Material, MaterialCategory,
|
||||
MaterialRow, ModalStatus, ModalWinState, Position, Salary, SalaryModalState, Worker,
|
||||
Equipment, EquipmentFilter, EquipmentModalState, LoginModalState, LoginStatus, Material,
|
||||
MaterialCategory, MaterialRow, ModalStatus, ModalWinState, Position, Salary,
|
||||
SalaryModalState, Worker,
|
||||
},
|
||||
recipe_tab::RecipeTabViewer,
|
||||
reports::Reporter,
|
||||
|
|
@ -244,6 +245,7 @@ impl Default for MainTabViewer {
|
|||
can_finish: false,
|
||||
equipment: Equipment::default(),
|
||||
status: ModalStatus::Add,
|
||||
filters: EquipmentFilter::default(),
|
||||
},
|
||||
salary_modal_state: SalaryModalState {
|
||||
is_open: false,
|
||||
|
|
@ -327,7 +329,11 @@ impl MainTabViewer {
|
|||
}
|
||||
});
|
||||
}
|
||||
let mut table = TableBuilder::new(ui)
|
||||
ui.add(egui::Checkbox::new(
|
||||
&mut self.equipment_modal_state.filters.without_written_offs,
|
||||
"Без списанных",
|
||||
));
|
||||
TableBuilder::new(ui)
|
||||
.striped(true)
|
||||
.resizable(false)
|
||||
.vscroll(false)
|
||||
|
|
@ -359,6 +365,10 @@ impl MainTabViewer {
|
|||
.body(|mut body| {
|
||||
body.ui_mut().style_mut().interaction.selectable_labels = false;
|
||||
for eq in self.equipment.read().clone().iter() {
|
||||
if (self.equipment_modal_state.filters.without_written_offs
|
||||
&& !eq.is_written_off)
|
||||
|| !self.equipment_modal_state.filters.without_written_offs
|
||||
{
|
||||
body.row(20.0, |mut row| {
|
||||
row.col(|ui| {
|
||||
ui.label(&eq.name);
|
||||
|
|
@ -391,6 +401,7 @@ impl MainTabViewer {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
if self.equipment_modal_state.is_open {
|
||||
egui::Modal::new(egui::Id::new("process_equipment_modal")).show(ui.ctx(), |ui| {
|
||||
|
|
@ -441,13 +452,6 @@ impl MainTabViewer {
|
|||
ui.end_row();
|
||||
|
||||
ui.label("Дата последнего\nтехобслуживания");
|
||||
// let mut date = self
|
||||
// .equipment_modal_state
|
||||
// .equipment
|
||||
// .maintenance_date
|
||||
// .date_naive()
|
||||
// .to_string();
|
||||
// let bdate = date.clone();
|
||||
let ndate = self
|
||||
.equipment_modal_state
|
||||
.equipment
|
||||
|
|
@ -469,25 +473,6 @@ impl MainTabViewer {
|
|||
.and_local_timezone(chrono::Local)
|
||||
.unwrap();
|
||||
}
|
||||
// if date != bdate {
|
||||
// self.equipment_modal_state.equipment.maintenance_date =
|
||||
// match NaiveDate::parse_from_str(&date, "%Y-%m-%d") {
|
||||
// Ok(o) => {date_okay = true;
|
||||
// o
|
||||
// .and_hms_opt(0, 0, 0)
|
||||
// .unwrap()
|
||||
// .and_local_timezone(chrono::Local)
|
||||
// .unwrap()},
|
||||
// Err(e) => {
|
||||
// date_okay = false;
|
||||
// NaiveDate::default()
|
||||
// .and_hms_opt(0, 0, 0)
|
||||
// .unwrap()
|
||||
// .and_local_timezone(chrono::Local)
|
||||
// .unwrap()
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
});
|
||||
} else {
|
||||
ui.label("Вы уверены, что хотите удалить:");
|
||||
|
|
@ -508,7 +493,9 @@ impl MainTabViewer {
|
|||
}
|
||||
_ => {
|
||||
self.equipment_modal_state.can_finish =
|
||||
self.equipment_modal_state.equipment.name.len() > 0 && date_okay
|
||||
self.equipment_modal_state.equipment.name.len() > 0
|
||||
&& self.equipment_modal_state.equipment.inv_number.len() > 0
|
||||
&& self.equipment_modal_state.equipment.worker.id != 0;
|
||||
}
|
||||
}
|
||||
let resp = ui.add_enabled(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use bigdecimal::ToPrimitive;
|
||||
use chrono::Datelike;
|
||||
|
||||
|
|
@ -17,3 +19,9 @@ pub fn jiff_to_naivedate(date: jiff::civil::Date) -> chrono::NaiveDate {
|
|||
)
|
||||
.unwrap()
|
||||
}
|
||||
pub fn is_date_okay(date: String) -> bool {
|
||||
match chrono::NaiveDate::from_str(&date) {
|
||||
Ok(_) => true,
|
||||
Err(_) => false,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,11 +156,12 @@ pub struct Promotion {
|
|||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct EquipmentModalState{
|
||||
pub struct EquipmentModalState {
|
||||
pub is_open: bool,
|
||||
pub can_finish: bool,
|
||||
pub equipment: Equipment,
|
||||
pub status: ModalStatus,
|
||||
pub filters: EquipmentFilter,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -220,3 +221,7 @@ pub enum LoginStatus {
|
|||
Login,
|
||||
Finished,
|
||||
}
|
||||
#[derive(Default)]
|
||||
pub struct EquipmentFilter {
|
||||
pub without_written_offs: bool,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue