Тунгджамин Нетансахур
parent
20ed3009b3
commit
4c97e8f322
|
|
@ -1143,6 +1143,7 @@ dependencies = [
|
||||||
"ahash 0.8.12",
|
"ahash 0.8.12",
|
||||||
"egui",
|
"egui",
|
||||||
"enum-map",
|
"enum-map",
|
||||||
|
"jiff",
|
||||||
"log",
|
"log",
|
||||||
"mime_guess2",
|
"mime_guess2",
|
||||||
"profiling",
|
"profiling",
|
||||||
|
|
@ -1990,6 +1991,33 @@ version = "1.0.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jiff"
|
||||||
|
version = "0.2.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f00b5dbd620d61dfdcb6007c9c1f6054ebd75319f163d886a9055cec1155073d"
|
||||||
|
dependencies = [
|
||||||
|
"jiff-static",
|
||||||
|
"js-sys",
|
||||||
|
"log",
|
||||||
|
"portable-atomic",
|
||||||
|
"portable-atomic-util",
|
||||||
|
"serde_core",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jiff-static"
|
||||||
|
version = "0.2.24"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e000de030ff8022ea1da3f466fbb0f3a809f5e51ed31f6dd931c35181ad8e6d7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.117",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jni"
|
name = "jni"
|
||||||
version = "0.22.4"
|
version = "0.22.4"
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ dotenvy = "0.15.7"
|
||||||
eframe = "0.34.2"
|
eframe = "0.34.2"
|
||||||
egui = "0.34.2"
|
egui = "0.34.2"
|
||||||
egui_dock = "0.19.1"
|
egui_dock = "0.19.1"
|
||||||
egui_extras = "0.34.2"
|
egui_extras = {version = "0.34.2", features = ["datepicker"]}
|
||||||
rust_decimal = {version = "1.42.0", features = ["macros"]}
|
rust_decimal = {version = "1.42.0", features = ["macros"]}
|
||||||
sqlx = {version="0.8.6", features = ["runtime-tokio", "mysql","bigdecimal","chrono"]}
|
sqlx = {version="0.8.6", features = ["runtime-tokio", "mysql","bigdecimal","chrono"]}
|
||||||
tokio={version = "1.52.3", features = ["full"]}
|
tokio={version = "1.52.3", features = ["full"]}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use chrono::NaiveDate;
|
||||||
use egui::mutex::RwLock;
|
use egui::mutex::RwLock;
|
||||||
use egui_dock::{DockArea, Style, TabViewer};
|
use egui_dock::{DockArea, Style, TabViewer};
|
||||||
use sqlx::{Connection, MySqlConnection, MySqlPool};
|
use sqlx::{Connection, MySqlConnection, MySqlPool};
|
||||||
|
|
@ -247,22 +248,73 @@ impl egui_dock::TabViewer for MainTabViewer{
|
||||||
struct WorkerTabViewer{
|
struct WorkerTabViewer{
|
||||||
workers: Arc<RwLock<Option<Vec<Worker>>>>,
|
workers: Arc<RwLock<Option<Vec<Worker>>>>,
|
||||||
positions: Arc<RwLock<Option<Vec<Position>>>>,
|
positions: Arc<RwLock<Option<Vec<Position>>>>,
|
||||||
add_modal: egui::Modal,
|
show_add_modal: bool,
|
||||||
|
add_worker_name: String,
|
||||||
|
selected_position: String,
|
||||||
|
add_worker_hire_date: String,
|
||||||
|
can_add: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WorkerTabViewer{
|
impl WorkerTabViewer{
|
||||||
fn show_worker(&mut self, ui: &mut egui::Ui){
|
fn show_worker(&mut self, ui: &mut egui::Ui){
|
||||||
ui.horizontal(|ui|{
|
ui.horizontal(|ui|{
|
||||||
if ui.button("Добавить").clicked() {
|
if ui.button("Добавить").clicked() {
|
||||||
&self.add_modal.show(ui.ctx(), |ui|{
|
self.show_add_modal = true;
|
||||||
ui.label("goida");
|
self.add_worker_name = String::new();
|
||||||
});
|
self.selected_position = String::new();
|
||||||
|
|
||||||
};
|
};
|
||||||
if ui.button("Уволить").clicked() {
|
if ui.button("Уволить").clicked() {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if self.show_add_modal{
|
||||||
|
egui::Modal::new("add".into()).show(ui.ctx(), |ui|{
|
||||||
|
if ui.button("Закрыть").clicked(){
|
||||||
|
self.show_add_modal = false;
|
||||||
|
}
|
||||||
|
ui.horizontal(|ui|{
|
||||||
|
ui.vertical(|ui|{
|
||||||
|
ui.label("Имя сотрудника:");
|
||||||
|
ui.label("Дата найма:");
|
||||||
|
ui.label("Должность:");
|
||||||
|
});
|
||||||
|
ui.vertical(|ui|{
|
||||||
|
ui.text_edit_singleline(&mut self.add_worker_name);
|
||||||
|
|
||||||
|
|
||||||
|
ui.text_edit_singleline(&mut self.add_worker_hire_date);
|
||||||
|
|
||||||
|
|
||||||
|
egui::ComboBox::from_label("Выбрать!")
|
||||||
|
.selected_text(format!("{}",self.selected_position))
|
||||||
|
.show_ui(ui, |ui|{
|
||||||
|
ui.selectable_value(&mut self.selected_position, "Гойдазовчик".to_owned(), "Гойдазовчик");
|
||||||
|
ui.selectable_value(&mut self.selected_position, "Гойдазовчик1".to_owned(), "Гойдазовчик");
|
||||||
|
ui.selectable_value(&mut self.selected_position, "Гойдазовчик2".to_owned(), "Гойдазовчик");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if(chrono::NaiveDate::parse_from_str(&self.add_worker_hire_date, "%d-%m-%Y").is_err()){
|
||||||
|
ui.label(egui::RichText::new("ДАТА УКАЗАНА НЕВЕРНО").color(egui::Color32::RED));
|
||||||
|
self.can_add = false;
|
||||||
|
}else{
|
||||||
|
self.can_add = true;
|
||||||
|
}
|
||||||
|
ui.vertical_centered(|ui|{
|
||||||
|
let resp = ui.add_enabled(self.can_add, egui::Button::new("Добавить"));
|
||||||
|
if resp.clicked(){
|
||||||
|
println!("Гойда!!");
|
||||||
|
}
|
||||||
|
// if ui.button("Добавить").clicked(){
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
for wk in self.workers.read().clone().unwrap().iter(){
|
for wk in self.workers.read().clone().unwrap().iter(){
|
||||||
ui.push_id(format!("{}:{}",&wk.full_name,&wk.id),|ui| {
|
ui.push_id(format!("{}:{}",&wk.full_name,&wk.id),|ui| {
|
||||||
egui::CollapsingHeader::new(format!("#{:08} | {}",&wk.id,&wk.full_name))
|
egui::CollapsingHeader::new(format!("#{:08} | {}",&wk.id,&wk.full_name))
|
||||||
|
|
@ -333,7 +385,11 @@ impl Default for WorkerTabViewer{
|
||||||
let db_oper = rt.block_on(async{DBOperator::new().await});
|
let db_oper = rt.block_on(async{DBOperator::new().await});
|
||||||
Self { workers: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_workers().await.unwrap()})))) ,
|
Self { workers: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_workers().await.unwrap()})))) ,
|
||||||
positions: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_position().await.unwrap()})))),
|
positions: Arc::new(RwLock::new(Option::Some(rt.block_on(async{db_oper.get_position().await.unwrap()})))),
|
||||||
add_modal: egui::Modal::new(egui::Id::new("Добавление")),
|
show_add_modal: false,
|
||||||
|
add_worker_name: String::new(),
|
||||||
|
selected_position: String::new(),
|
||||||
|
add_worker_hire_date: String::new(),
|
||||||
|
can_add: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue