помогите
parent
69525d37d2
commit
a1cc8e4e86
|
|
@ -664,31 +664,42 @@ impl MainTabViewer {
|
||||||
.show_inside(ui, &mut self.order_tabs);
|
.show_inside(ui, &mut self.order_tabs);
|
||||||
}
|
}
|
||||||
fn show_salary(&mut self, ui: &mut egui::Ui) {
|
fn show_salary(&mut self, ui: &mut egui::Ui) {
|
||||||
/*
|
ui.horizontal(|ui| {
|
||||||
* Чё надо:
|
if self.is_admin && ui.button("Добавить").clicked() {
|
||||||
* 1. Список платежей.
|
self.update_workers();
|
||||||
*/
|
self.salary_modal_state
|
||||||
|
.data
|
||||||
if self.is_admin && ui.button("Добавить").clicked() {
|
.insert("id".to_owned(), String::new());
|
||||||
self.salary_modal_state
|
self.salary_modal_state
|
||||||
.data
|
.data
|
||||||
.insert("id".to_owned(), String::new());
|
.insert("worker_id".to_owned(), String::new());
|
||||||
self.salary_modal_state
|
self.salary_modal_state
|
||||||
.data
|
.data
|
||||||
.insert("worker_id".to_owned(), String::new());
|
.insert("salary_size".to_owned(), String::new());
|
||||||
self.salary_modal_state
|
self.salary_modal_state
|
||||||
.data
|
.data
|
||||||
.insert("salary_size".to_owned(), String::new());
|
.insert("salary_date".to_owned(), String::new());
|
||||||
self.salary_modal_state
|
self.salary_modal_state
|
||||||
.data
|
.data
|
||||||
.insert("salary_date".to_owned(), String::new());
|
.insert("comment".to_owned(), String::new());
|
||||||
self.salary_modal_state
|
self.salary_modal_state.workers.clear();
|
||||||
.data
|
self.salary_modal_state.is_open = true;
|
||||||
.insert("comment".to_owned(), String::new());
|
self.salary_modal_state.status = ModalStatus::Add;
|
||||||
self.salary_modal_state.workers.clear();
|
}
|
||||||
self.salary_modal_state.is_open = true;
|
if ui.button("<-").clicked() {
|
||||||
self.salary_modal_state.status = ModalStatus::Add;
|
if self.salaries_page > 0 {
|
||||||
}
|
self.salaries_page -= 1;
|
||||||
|
self.update_salary();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.monospace(self.salaries_page.to_string());
|
||||||
|
if ui.button("->").clicked() {
|
||||||
|
if self.salaries.read().len().to_i32().unwrap() == misc::ELEMENTS_PER_PAGE {
|
||||||
|
self.salaries_page += 1;
|
||||||
|
self.update_salary();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
TableBuilder::new(ui)
|
TableBuilder::new(ui)
|
||||||
.striped(true)
|
.striped(true)
|
||||||
.columns(Column::auto(), 5)
|
.columns(Column::auto(), 5)
|
||||||
|
|
@ -795,19 +806,21 @@ impl MainTabViewer {
|
||||||
.close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside)
|
.close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside)
|
||||||
.show_ui(ui, |ui| {
|
.show_ui(ui, |ui| {
|
||||||
for wrkr in self.workers.read().clone().iter() {
|
for wrkr in self.workers.read().clone().iter() {
|
||||||
let mut checked =
|
if !wrkr.is_fired {
|
||||||
self.salary_modal_state.workers.contains(wrkr);
|
let mut checked =
|
||||||
let res = ui.add(egui::Checkbox::new(
|
self.salary_modal_state.workers.contains(wrkr);
|
||||||
&mut checked,
|
let res = ui.add(egui::Checkbox::new(
|
||||||
&wrkr.full_name,
|
&mut checked,
|
||||||
));
|
&wrkr.full_name,
|
||||||
if res.clicked() {
|
));
|
||||||
if checked {
|
if res.clicked() {
|
||||||
self.salary_modal_state
|
if checked {
|
||||||
.workers
|
self.salary_modal_state
|
||||||
.insert(wrkr.clone());
|
.workers
|
||||||
} else {
|
.insert(wrkr.clone());
|
||||||
self.salary_modal_state.workers.remove(wrkr);
|
} else {
|
||||||
|
self.salary_modal_state.workers.remove(wrkr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use bigdecimal::BigDecimal;
|
use bigdecimal::BigDecimal;
|
||||||
|
use bigdecimal::ToPrimitive;
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use sqlx::Row;
|
use sqlx::Row;
|
||||||
use sqlx::mysql::MySqlPool;
|
use sqlx::mysql::MySqlPool;
|
||||||
|
|
@ -24,10 +25,17 @@ impl DBOperator {
|
||||||
pool: MySqlPool::connect(&db_url).await.unwrap(),
|
pool: MySqlPool::connect(&db_url).await.unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub async fn get_position(&self) -> Result<Vec<Position>, sqlx::Error> {
|
pub async fn get_positions(
|
||||||
let rets: Vec<Position> = sqlx::query_as::<_, Position>("SELECT * FROM `position`")
|
&self,
|
||||||
.fetch_all(&self.pool)
|
start: i32,
|
||||||
.await?;
|
length: i32,
|
||||||
|
) -> Result<Vec<Position>, sqlx::Error> {
|
||||||
|
let rets: Vec<Position> =
|
||||||
|
sqlx::query_as::<_, Position>("SELECT * FROM `position` LIMIT ? OFFSET ?")
|
||||||
|
.bind(length)
|
||||||
|
.bind(start)
|
||||||
|
.fetch_all(&self.pool)
|
||||||
|
.await?;
|
||||||
Ok(rets)
|
Ok(rets)
|
||||||
}
|
}
|
||||||
pub async fn get_position_by_id(&self, id: i32) -> Result<Position, sqlx::Error> {
|
pub async fn get_position_by_id(&self, id: i32) -> Result<Position, sqlx::Error> {
|
||||||
|
|
@ -53,15 +61,11 @@ impl DBOperator {
|
||||||
.fetch_all(&self.pool)
|
.fetch_all(&self.pool)
|
||||||
.await?;
|
.await?;
|
||||||
let mut rets: Vec<Worker> = Vec::new();
|
let mut rets: Vec<Worker> = Vec::new();
|
||||||
let pos = self.get_position().await.unwrap();
|
|
||||||
for worker in pre_rets {
|
for worker in pre_rets {
|
||||||
let mut ppos = Position::default();
|
let ppos = self
|
||||||
for position in pos.clone() {
|
.get_position_by_id(worker.position_id)
|
||||||
if position.id == worker.position_id {
|
.await
|
||||||
ppos = position.clone();
|
.unwrap_or(Position::default());
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rets.push(Worker {
|
rets.push(Worker {
|
||||||
id: worker.id,
|
id: worker.id,
|
||||||
full_name: worker.full_name,
|
full_name: worker.full_name,
|
||||||
|
|
@ -187,8 +191,14 @@ impl DBOperator {
|
||||||
.await?;
|
.await?;
|
||||||
Ok(rets)
|
Ok(rets)
|
||||||
}
|
}
|
||||||
pub async fn get_materials(&self) -> Result<Vec<Material>, sqlx::Error> {
|
pub async fn get_materials(
|
||||||
let mats = sqlx::query_as::<_, MaterialRow>("SELECT * FROM `material`")
|
&self,
|
||||||
|
start: i32,
|
||||||
|
length: i32,
|
||||||
|
) -> Result<Vec<Material>, sqlx::Error> {
|
||||||
|
let mats = sqlx::query_as::<_, MaterialRow>("SELECT * FROM `material` LIMIT ? OFFSET ?")
|
||||||
|
.bind(length)
|
||||||
|
.bind(start)
|
||||||
.fetch_all(&self.pool)
|
.fetch_all(&self.pool)
|
||||||
.await?;
|
.await?;
|
||||||
let cats = self.get_mcat().await?;
|
let cats = self.get_mcat().await?;
|
||||||
|
|
@ -346,13 +356,16 @@ impl DBOperator {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_worker(&self, worker: Worker) -> Result<bool, sqlx::Error> {
|
pub async fn update_worker(&self, worker: Worker) -> Result<bool, sqlx::Error> {
|
||||||
match sqlx::query("UPDATE `worker` SET hire_date=?, is_fired=?, full_name=? WHERE id=?;")
|
match sqlx::query(
|
||||||
.bind(worker.hire_date)
|
"UPDATE `worker` SET hire_date=?, is_fired=?, full_name=?, fire_date=? WHERE id=?;",
|
||||||
.bind(worker.is_fired)
|
)
|
||||||
.bind(worker.full_name)
|
.bind(worker.hire_date)
|
||||||
.bind(worker.id)
|
.bind(worker.is_fired)
|
||||||
.execute(&self.pool)
|
.bind(worker.full_name)
|
||||||
.await
|
.bind(worker.fire_date)
|
||||||
|
.bind(worker.id)
|
||||||
|
.execute(&self.pool)
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => Ok(true),
|
Ok(_) => Ok(true),
|
||||||
Err(_) => Ok(false),
|
Err(_) => Ok(false),
|
||||||
|
|
@ -587,6 +600,24 @@ impl DBOperator {
|
||||||
Err(_) => Ok(false),
|
Err(_) => Ok(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub async fn get_mat_by_id(&self, mat_id: i32) -> Result<Material, sqlx::Error> {
|
||||||
|
let pret = sqlx::query_as::<_, MaterialRow>("SELECT * FROM material WHERE id=?")
|
||||||
|
.bind(mat_id)
|
||||||
|
.fetch_one(&self.pool)
|
||||||
|
.await?;
|
||||||
|
Ok(Material {
|
||||||
|
id: pret.id,
|
||||||
|
name: pret.name,
|
||||||
|
category: self.get_mcat_by_id(pret.category_id).await.unwrap(),
|
||||||
|
quantity: pret.quantity,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
pub async fn get_mcat_by_id(&self, mcat_id: i32) -> Result<MaterialCategory, sqlx::Error> {
|
||||||
|
sqlx::query_as::<_, MaterialCategory>("SELECT * FROM material_category WHERE id=?")
|
||||||
|
.bind(mcat_id)
|
||||||
|
.fetch_one(&self.pool)
|
||||||
|
.await
|
||||||
|
}
|
||||||
pub async fn update_recipe(&self, recipe: Recipe) -> Result<bool, sqlx::Error> {
|
pub async fn update_recipe(&self, recipe: Recipe) -> Result<bool, sqlx::Error> {
|
||||||
match sqlx::query("UPDATE `recipe` SET name=? WHERE id=?;")
|
match sqlx::query("UPDATE `recipe` SET name=? WHERE id=?;")
|
||||||
.bind(recipe.name)
|
.bind(recipe.name)
|
||||||
|
|
@ -605,10 +636,9 @@ impl DBOperator {
|
||||||
.fetch_all(&self.pool)
|
.fetch_all(&self.pool)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let mats = self.get_materials().await.unwrap();
|
|
||||||
let mut ret: Vec<RecipeElement> = Vec::new();
|
let mut ret: Vec<RecipeElement> = Vec::new();
|
||||||
for re in pre_ret.unwrap().iter() {
|
for re in pre_ret.unwrap().iter() {
|
||||||
let mat = mats.iter().find(|m| m.id == re.material_id);
|
let mat = self.get_mat_by_id(re.material_id).await.ok();
|
||||||
let eq = self.get_equipment_by_id(re.equipment_id).await.ok();
|
let eq = self.get_equipment_by_id(re.equipment_id).await.ok();
|
||||||
match (mat, eq) {
|
match (mat, eq) {
|
||||||
(Some(m), Some(e)) => {
|
(Some(m), Some(e)) => {
|
||||||
|
|
@ -704,7 +734,7 @@ impl DBOperator {
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
pub async fn get_client_by_id(&self, id: i32) -> Result<Client, sqlx::Error> {
|
pub async fn get_client_by_id(&self, id: i32) -> Result<Client, sqlx::Error> {
|
||||||
sqlx::query_as::<_, Client>("SELECT FROM `client` WHERE id=?")
|
sqlx::query_as::<_, Client>("SELECT * FROM `client` WHERE id=?")
|
||||||
.bind(id)
|
.bind(id)
|
||||||
.fetch_one(&self.pool)
|
.fetch_one(&self.pool)
|
||||||
.await
|
.await
|
||||||
|
|
@ -799,17 +829,56 @@ impl DBOperator {
|
||||||
.await?;
|
.await?;
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
pub async fn add_order_element(&self, order_elem: OrderElement) -> Result<(), sqlx::Error> {
|
pub async fn add_order_element(
|
||||||
match sqlx::query("INSERT INTO order_element (order_id, product_id, quantity, total_amount) VALUES(?, ?, ?, ?);")
|
&self,
|
||||||
.bind(self.get_order_id_by_order_element_id(order_elem.id).await.unwrap())
|
order_elems: BTreeSet<OrderElement>,
|
||||||
.bind(order_elem.product.id)
|
order_id: i32,
|
||||||
.bind(order_elem.quantity)
|
) -> Result<(), sqlx::Error> {
|
||||||
.bind(order_elem.total_price)
|
let mut tx = self.pool.begin().await?;
|
||||||
.execute(&self.pool).await{
|
for el in order_elems.iter() {
|
||||||
|
sqlx::query("INSERT INTO order_element (order_id, product_id, quantity, total_amount) VALUES(?, ?, ?, ?);")
|
||||||
|
.bind(order_id)
|
||||||
|
.bind(el.product.id)
|
||||||
|
.bind(el.quantity)
|
||||||
|
.bind(el.total_price.clone())
|
||||||
|
.execute(&mut *tx).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
match tx.commit().await {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub async fn remove_order_elements(&self, order_id: i32) -> Result<(), sqlx::Error> {
|
||||||
|
match sqlx::query("DELETE FROM order_element WHERE order_id=?")
|
||||||
|
.bind(order_id)
|
||||||
|
.execute(&self.pool)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub async fn add_order(&self, order: Order, incoming: bool) -> Result<i32, sqlx::Error> {
|
||||||
|
let res = sqlx::query("INSERT INTO `order` (client_id, order_date, total_price, is_incoming) VALUES(?, ?, ?, ?);").bind(order.client.id).bind(order.order_date).bind(order.total_price).bind(incoming).execute(&self.pool).await?;
|
||||||
|
Ok(res.last_insert_id().to_i32().unwrap())
|
||||||
|
}
|
||||||
|
pub async fn update_order(&self, order: Order, incoming: bool) -> Result<(), sqlx::Error> {
|
||||||
|
match sqlx::query("UPDATE `order` SET client_id=?, order_date=?, total_price=?, is_incoming=? WHERE id=?;").bind(order.client.id).bind(order.order_date).bind(order.total_price).bind(incoming).bind(order.id).execute(&self.pool).await{
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(e) => Err(e)
|
Err(e) => Err(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub async fn remove_order(&self, order_id: i32) -> Result<(), sqlx::Error> {
|
||||||
|
match sqlx::query("DELETE FROM `order` WHERE id=?")
|
||||||
|
.bind(order_id)
|
||||||
|
.execute(&self.pool)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
pub async fn get_clients(&self, start: i32, length: i32) -> Vec<Client> {
|
pub async fn get_clients(&self, start: i32, length: i32) -> Vec<Client> {
|
||||||
let pret = sqlx::query_as::<_, Client>("SELECT * FROM client LIMIT ? OFFSET ?")
|
let pret = sqlx::query_as::<_, Client>("SELECT * FROM client LIMIT ? OFFSET ?")
|
||||||
.bind(length)
|
.bind(length)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use egui_extras::{Column, TableBuilder};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::DBOperator,
|
database::DBOperator,
|
||||||
|
misc::ELEMENTS_PER_PAGE,
|
||||||
models::{Material, MaterialCategory, MaterialRow, ModalStatus, ModalWinState},
|
models::{Material, MaterialCategory, MaterialRow, ModalStatus, ModalWinState},
|
||||||
tab::{TABS_CAN_BE_WINDOWS, Tab, TabTypes},
|
tab::{TABS_CAN_BE_WINDOWS, Tab, TabTypes},
|
||||||
};
|
};
|
||||||
|
|
@ -19,6 +20,8 @@ pub struct MaterialTabViewer {
|
||||||
mat_cats: Arc<RwLock<Vec<MaterialCategory>>>,
|
mat_cats: Arc<RwLock<Vec<MaterialCategory>>>,
|
||||||
mats: Arc<RwLock<Vec<Material>>>,
|
mats: Arc<RwLock<Vec<Material>>>,
|
||||||
is_admin: bool,
|
is_admin: bool,
|
||||||
|
mat_page: i32,
|
||||||
|
mcat_page: i32,
|
||||||
}
|
}
|
||||||
impl MaterialTabViewer {
|
impl MaterialTabViewer {
|
||||||
pub fn new(is_admin: bool) -> Self {
|
pub fn new(is_admin: bool) -> Self {
|
||||||
|
|
@ -34,10 +37,12 @@ impl MaterialTabViewer {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
fn update_materials(&mut self) {
|
fn update_materials(&mut self) {
|
||||||
self.mats = Arc::new(RwLock::new(
|
self.mats = Arc::new(RwLock::new(self.rt.block_on(async {
|
||||||
self.rt
|
self.db_oper
|
||||||
.block_on(async { self.db_oper.get_materials().await.unwrap() }),
|
.get_materials(self.mat_page * ELEMENTS_PER_PAGE, ELEMENTS_PER_PAGE)
|
||||||
));
|
.await
|
||||||
|
.unwrap()
|
||||||
|
})));
|
||||||
}
|
}
|
||||||
fn show_material(&mut self, ui: &mut egui::Ui) {
|
fn show_material(&mut self, ui: &mut egui::Ui) {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
|
|
@ -546,9 +551,9 @@ impl Default for MaterialTabViewer {
|
||||||
let mat_cats = Arc::new(RwLock::new(
|
let mat_cats = Arc::new(RwLock::new(
|
||||||
rt.block_on(async { db_oper.get_mcat().await.unwrap() }),
|
rt.block_on(async { db_oper.get_mcat().await.unwrap() }),
|
||||||
));
|
));
|
||||||
let mats = Arc::new(RwLock::new(
|
let mats = Arc::new(RwLock::new(rt.block_on(async {
|
||||||
rt.block_on(async { db_oper.get_materials().await.unwrap() }),
|
db_oper.get_materials(0, ELEMENTS_PER_PAGE).await.unwrap()
|
||||||
));
|
})));
|
||||||
Self {
|
Self {
|
||||||
db_oper,
|
db_oper,
|
||||||
rt,
|
rt,
|
||||||
|
|
@ -588,6 +593,8 @@ impl Default for MaterialTabViewer {
|
||||||
mat_cats,
|
mat_cats,
|
||||||
mats,
|
mats,
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
|
mat_page: 0,
|
||||||
|
mcat_page: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ pub struct Client {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub address: String,
|
pub address: String,
|
||||||
}
|
}
|
||||||
#[derive(Default, PartialEq, PartialOrd, Eq, Ord)]
|
#[derive(Default, PartialEq, PartialOrd, Eq, Ord, Clone)]
|
||||||
pub struct Order {
|
pub struct Order {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub client: Client,
|
pub client: Client,
|
||||||
|
|
@ -159,7 +159,6 @@ pub struct OrderElementRow {
|
||||||
pub product_id: i32,
|
pub product_id: i32,
|
||||||
pub quantity: i32,
|
pub quantity: i32,
|
||||||
pub total_price: BigDecimal,
|
pub total_price: BigDecimal,
|
||||||
pub is_incoming: bool,
|
|
||||||
}
|
}
|
||||||
#[derive(Default, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
#[derive(Default, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub struct Product {
|
pub struct Product {
|
||||||
|
|
@ -213,6 +212,7 @@ pub struct WorkerModalState {
|
||||||
pub worker: Worker,
|
pub worker: Worker,
|
||||||
pub status: ModalStatus,
|
pub status: ModalStatus,
|
||||||
pub old_pos: Position,
|
pub old_pos: Position,
|
||||||
|
pub old_fired: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,7 @@ impl OrderTabViewer {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if self.is_admin {
|
if self.is_admin {
|
||||||
if ui.button("Добавить").clicked() {
|
if ui.button("Добавить").clicked() {
|
||||||
|
self.update_clients();
|
||||||
self.process_order_state.is_open = true;
|
self.process_order_state.is_open = true;
|
||||||
self.process_order_state.order = Order::default();
|
self.process_order_state.order = Order::default();
|
||||||
}
|
}
|
||||||
|
|
@ -226,9 +227,9 @@ impl OrderTabViewer {
|
||||||
.header(25.0, |mut heading| {
|
.header(25.0, |mut heading| {
|
||||||
heading.col(|ui| {
|
heading.col(|ui| {
|
||||||
ui.heading(if incoming_orders {
|
ui.heading(if incoming_orders {
|
||||||
"Заказчик"
|
"Заказчик "
|
||||||
} else {
|
} else {
|
||||||
"Клиент"
|
"Клиент "
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
heading.col(|ui| {
|
heading.col(|ui| {
|
||||||
|
|
@ -240,9 +241,13 @@ impl OrderTabViewer {
|
||||||
heading.col(|ui| {
|
heading.col(|ui| {
|
||||||
ui.heading("Дата создания");
|
ui.heading("Дата создания");
|
||||||
});
|
});
|
||||||
|
heading.col(|ui| {
|
||||||
|
ui.heading(" ");
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.body(|mut body| {
|
.body(|mut body| {
|
||||||
for or in orders.read().iter() {
|
for or in orders.read().iter() {
|
||||||
|
body.ui_mut().style_mut().interaction.selectable_labels = false;
|
||||||
body.row(25.0, |mut row| {
|
body.row(25.0, |mut row| {
|
||||||
let len = orders.read().iter().clone().len();
|
let len = orders.read().iter().clone().len();
|
||||||
row.col(|ui| {
|
row.col(|ui| {
|
||||||
|
|
@ -260,7 +265,21 @@ impl OrderTabViewer {
|
||||||
row.col(|ui| {
|
row.col(|ui| {
|
||||||
ui.label(or.order_date.date_naive().to_string());
|
ui.label(or.order_date.date_naive().to_string());
|
||||||
});
|
});
|
||||||
row.col(|ui| if ui.button("Удалить").clicked() {});
|
if self.is_admin {
|
||||||
|
row.col(|ui| {
|
||||||
|
if ui.button("Удалить").clicked() {
|
||||||
|
self.process_order_state.is_open = true;
|
||||||
|
self.process_order_state.order = or.clone();
|
||||||
|
self.process_order_state.status = ModalStatus::Remove;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if row.response().double_clicked() {
|
||||||
|
self.update_clients();
|
||||||
|
self.process_order_state.is_open = true;
|
||||||
|
self.process_order_state.order = or.clone();
|
||||||
|
self.process_order_state.status = ModalStatus::Edit;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -275,46 +294,155 @@ impl OrderTabViewer {
|
||||||
ui.label(self.process_order_state.order.id.to_string());
|
ui.label(self.process_order_state.order.id.to_string());
|
||||||
ui.end_row();
|
ui.end_row();
|
||||||
}
|
}
|
||||||
|
if self.process_order_state.status != ModalStatus::Remove {
|
||||||
ui.label(if incoming_orders {
|
ui.label(if incoming_orders {
|
||||||
"Заказчик"
|
"Заказчик"
|
||||||
} else {
|
} else {
|
||||||
"Клиент"
|
"Клиент"
|
||||||
});
|
|
||||||
egui::ComboBox::new("select_client_combobox", "")
|
|
||||||
.selected_text(&self.process_order_state.order.client.name)
|
|
||||||
.show_ui(ui, |ui| {});
|
|
||||||
ui.end_row();
|
|
||||||
|
|
||||||
ui.label("Элементы");
|
|
||||||
egui::ComboBox::new("order_process_combobox", "")
|
|
||||||
.close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside)
|
|
||||||
.selected_text(match self.process_order_state.order.elements.len() {
|
|
||||||
0 => "Пусто".to_owned(),
|
|
||||||
_ => format!("{} элем.", self.process_order_state.order.elements.len()),
|
|
||||||
})
|
|
||||||
.show_ui(ui, |ui| {
|
|
||||||
if ui.button("Новый элемент").clicked() {
|
|
||||||
self.process_element_state.is_open = true;
|
|
||||||
self.process_element_state.status = ModalStatus::Add;
|
|
||||||
self.process_element_state.element = OrderElement::default();
|
|
||||||
}
|
|
||||||
|
|
||||||
for el in self.process_order_state.order.elements.clone().iter() {
|
|
||||||
ui.horizontal(|ui| {
|
|
||||||
if ui.button("x").clicked() {
|
|
||||||
self.process_order_state.order.elements.remove(el);
|
|
||||||
}
|
|
||||||
ui.label(format!(
|
|
||||||
"{} ({})\n{}/шт.",
|
|
||||||
el.product.recipe.name,
|
|
||||||
el.quantity,
|
|
||||||
el.product.price_per_unit
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
egui::ComboBox::new("select_client_combobox", "")
|
||||||
|
.selected_text(&self.process_order_state.order.client.name)
|
||||||
|
.show_ui(ui, |ui| {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
if ui.button("<-").clicked() {
|
||||||
|
if self.client_page > 0 {
|
||||||
|
self.client_page -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.monospace(self.client_page.to_string());
|
||||||
|
if ui.button("->").clicked() {
|
||||||
|
if self.clients.read().len().to_i32().unwrap()
|
||||||
|
== misc::ELEMENTS_PER_PAGE
|
||||||
|
{
|
||||||
|
self.client_page += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for cl in self.clients.read().iter() {
|
||||||
|
ui.selectable_value(
|
||||||
|
&mut self.process_order_state.order.client,
|
||||||
|
cl.clone(),
|
||||||
|
&cl.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui.end_row();
|
||||||
|
|
||||||
|
ui.label("Элементы");
|
||||||
|
egui::ComboBox::new("order_process_combobox", "")
|
||||||
|
.close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside)
|
||||||
|
.selected_text(match self.process_order_state.order.elements.len() {
|
||||||
|
0 => "Пусто".to_owned(),
|
||||||
|
_ => format!(
|
||||||
|
"{} элем.",
|
||||||
|
self.process_order_state.order.elements.len()
|
||||||
|
),
|
||||||
|
})
|
||||||
|
.show_ui(ui, |ui| {
|
||||||
|
if ui.button("Новый элемент").clicked() {
|
||||||
|
self.process_element_state.is_open = true;
|
||||||
|
self.process_element_state.status = ModalStatus::Add;
|
||||||
|
self.process_element_state.element = OrderElement::default();
|
||||||
|
}
|
||||||
|
|
||||||
|
for el in self.process_order_state.order.elements.clone().iter() {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
if ui.button("x").clicked() {
|
||||||
|
self.process_order_state.order.elements.remove(el);
|
||||||
|
}
|
||||||
|
ui.label(format!(
|
||||||
|
"{} ({})\n{}/шт.",
|
||||||
|
el.product.recipe.name,
|
||||||
|
el.quantity,
|
||||||
|
el.product.price_per_unit
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui.end_row();
|
||||||
|
ui.label("Дата заказа: ");
|
||||||
|
let ndate = self.process_order_state.order.order_date.date_naive();
|
||||||
|
let mut date = misc::naivedate_to_jiff(ndate);
|
||||||
|
ui.add(egui_extras::DatePickerButton::new(&mut date));
|
||||||
|
if self.process_order_state.order.order_date.date_naive()
|
||||||
|
!= misc::jiff_to_naivedate(date)
|
||||||
|
{
|
||||||
|
self.process_order_state.order.order_date =
|
||||||
|
misc::jiff_to_naivedate(date)
|
||||||
|
.and_hms_opt(0, 0, 0)
|
||||||
|
.unwrap()
|
||||||
|
.and_local_timezone(chrono::Local)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
let btext = match self.process_order_state.status {
|
||||||
|
ModalStatus::Add => "Добавить",
|
||||||
|
ModalStatus::Edit => "Сохранить",
|
||||||
|
ModalStatus::Remove => "Удалить",
|
||||||
|
};
|
||||||
|
self.process_order_state.can_finish = match self.process_order_state.status {
|
||||||
|
ModalStatus::Remove => true,
|
||||||
|
_ => {
|
||||||
|
self.process_order_state.order.client.name.len() > 0
|
||||||
|
&& self.process_order_state.order.elements.len() > 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if ui
|
||||||
|
.add_enabled(
|
||||||
|
self.process_order_state.can_finish,
|
||||||
|
egui::Button::new(btext),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
self.rt.block_on(async {
|
||||||
|
match self.process_order_state.status {
|
||||||
|
ModalStatus::Add => {
|
||||||
|
let id = self
|
||||||
|
.db_oper
|
||||||
|
.add_order(
|
||||||
|
self.process_order_state.order.clone(),
|
||||||
|
incoming_orders,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
self.db_oper
|
||||||
|
.add_order_element(
|
||||||
|
self.process_order_state.order.elements.clone(),
|
||||||
|
id,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
ModalStatus::Edit => {
|
||||||
|
self.db_oper
|
||||||
|
.remove_order_elements(self.process_order_state.order.id)
|
||||||
|
.await;
|
||||||
|
self.db_oper
|
||||||
|
.update_order(
|
||||||
|
self.process_order_state.order.clone(),
|
||||||
|
incoming_orders,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
self.db_oper
|
||||||
|
.add_order_element(
|
||||||
|
self.process_order_state.order.elements.clone(),
|
||||||
|
self.process_order_state.order.id,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
ModalStatus::Remove => {
|
||||||
|
self.db_oper
|
||||||
|
.remove_order_elements(self.process_order_state.order.id)
|
||||||
|
.await;
|
||||||
|
self.db_oper
|
||||||
|
.remove_order(self.process_order_state.order.id)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
self.update_orders();
|
||||||
|
self.process_order_state.is_open = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if self.process_element_state.is_open {
|
if self.process_element_state.is_open {
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ use egui_extras::{Column, TableBuilder};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::DBOperator,
|
database::DBOperator,
|
||||||
misc,
|
misc::{self, ELEMENTS_PER_PAGE},
|
||||||
models::{
|
models::{
|
||||||
RecipeElementModalState, Equipment, Material, ModalStatus, Product, ProductModalState, Recipe,
|
Equipment, Material, ModalStatus, Product, ProductModalState, Recipe, RecipeElement,
|
||||||
RecipeElement, RecipeModalState,
|
RecipeElementModalState, RecipeModalState,
|
||||||
},
|
},
|
||||||
tab::{self, Tab, TabTypes},
|
tab::{self, Tab, TabTypes},
|
||||||
};
|
};
|
||||||
|
|
@ -34,6 +34,7 @@ pub struct RecipeTabViewer {
|
||||||
old_price: BigDecimal,
|
old_price: BigDecimal,
|
||||||
product_page: i32,
|
product_page: i32,
|
||||||
recipe_page: i32,
|
recipe_page: i32,
|
||||||
|
mat_page: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RecipeTabViewer {
|
impl RecipeTabViewer {
|
||||||
|
|
@ -68,6 +69,21 @@ impl RecipeTabViewer {
|
||||||
egui::ComboBox::new("material_select_combobox", "")
|
egui::ComboBox::new("material_select_combobox", "")
|
||||||
.selected_text(&self.process_element_status.element.material.name)
|
.selected_text(&self.process_element_status.element.material.name)
|
||||||
.show_ui(ui, |ui| {
|
.show_ui(ui, |ui| {
|
||||||
|
if ui.button("<-").clicked() {
|
||||||
|
if self.mat_page > 0 {
|
||||||
|
self.mat_page -= 1;
|
||||||
|
self.update_materials();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.monospace(self.mat_page.to_string());
|
||||||
|
if ui.button("->").clicked() {
|
||||||
|
if self.materials.read().len().to_i32().unwrap()
|
||||||
|
== misc::ELEMENTS_PER_PAGE
|
||||||
|
{
|
||||||
|
self.mat_page += 1;
|
||||||
|
self.update_materials();
|
||||||
|
}
|
||||||
|
}
|
||||||
for mat in self.materials.read().clone().iter() {
|
for mat in self.materials.read().clone().iter() {
|
||||||
ui.selectable_value(
|
ui.selectable_value(
|
||||||
&mut self.process_element_status.element.material,
|
&mut self.process_element_status.element.material,
|
||||||
|
|
@ -370,6 +386,15 @@ impl RecipeTabViewer {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_materials(&mut self) {
|
||||||
|
self.materials = Arc::new(RwLock::new(self.rt.block_on(async {
|
||||||
|
self.db_oper
|
||||||
|
.get_materials(self.mat_page, ELEMENTS_PER_PAGE)
|
||||||
|
.await
|
||||||
|
.unwrap_or(Vec::new())
|
||||||
|
})))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
impl egui_dock::TabViewer for RecipeTabViewer {
|
impl egui_dock::TabViewer for RecipeTabViewer {
|
||||||
type Tab = Tab;
|
type Tab = Tab;
|
||||||
|
|
@ -499,9 +524,12 @@ impl Default for RecipeTabViewer {
|
||||||
.await
|
.await
|
||||||
.unwrap_or(Vec::new())
|
.unwrap_or(Vec::new())
|
||||||
}))),
|
}))),
|
||||||
materials: Arc::new(RwLock::new(
|
materials: Arc::new(RwLock::new(rt.block_on(async {
|
||||||
rt.block_on(async { db_oper.get_materials().await.unwrap_or(Vec::new()) }),
|
db_oper
|
||||||
)),
|
.get_materials(0, ELEMENTS_PER_PAGE)
|
||||||
|
.await
|
||||||
|
.unwrap_or(Vec::new())
|
||||||
|
}))),
|
||||||
equipment: Arc::new(RwLock::new(rt.block_on(async {
|
equipment: Arc::new(RwLock::new(rt.block_on(async {
|
||||||
db_oper
|
db_oper
|
||||||
.get_equipment(0, 5, false)
|
.get_equipment(0, 5, false)
|
||||||
|
|
@ -530,7 +558,7 @@ impl Default for RecipeTabViewer {
|
||||||
|
|
||||||
product_page: 0,
|
product_page: 0,
|
||||||
recipe_page: 0,
|
recipe_page: 0,
|
||||||
|
mat_page: 0,
|
||||||
rt,
|
rt,
|
||||||
db_oper,
|
db_oper,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use bigdecimal::BigDecimal;
|
use bigdecimal::{BigDecimal, ToPrimitive};
|
||||||
use egui::mutex::RwLock;
|
use egui::mutex::RwLock;
|
||||||
use egui_extras::{Column, TableBuilder};
|
use egui_extras::{Column, TableBuilder};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
@ -26,6 +26,7 @@ pub struct WorkerTabViewer {
|
||||||
|
|
||||||
only_not_fired_workers: bool,
|
only_not_fired_workers: bool,
|
||||||
workers_page: i32,
|
workers_page: i32,
|
||||||
|
positions_page: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WorkerTabViewer {
|
impl WorkerTabViewer {
|
||||||
|
|
@ -39,7 +40,7 @@ impl WorkerTabViewer {
|
||||||
self.workers = Arc::new(RwLock::new(self.rt.block_on(async {
|
self.workers = Arc::new(RwLock::new(self.rt.block_on(async {
|
||||||
self.db_oper
|
self.db_oper
|
||||||
.get_workers(
|
.get_workers(
|
||||||
self.workers_page,
|
self.workers_page * ELEMENTS_PER_PAGE,
|
||||||
ELEMENTS_PER_PAGE,
|
ELEMENTS_PER_PAGE,
|
||||||
self.only_not_fired_workers,
|
self.only_not_fired_workers,
|
||||||
)
|
)
|
||||||
|
|
@ -48,21 +49,42 @@ impl WorkerTabViewer {
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
fn update_positions(&mut self) {
|
fn update_positions(&mut self) {
|
||||||
self.positions = Arc::new(RwLock::new(
|
self.positions = Arc::new(RwLock::new(self.rt.block_on(async {
|
||||||
self.rt
|
self.db_oper
|
||||||
.block_on(async { self.db_oper.get_position().await.unwrap() }),
|
.get_positions(self.positions_page * ELEMENTS_PER_PAGE, ELEMENTS_PER_PAGE)
|
||||||
));
|
.await
|
||||||
|
.unwrap()
|
||||||
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
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 self.is_admin {
|
||||||
self.process_worker_state.is_open = true;
|
if ui.button("Добавить").clicked() {
|
||||||
self.process_worker_state.worker = Worker::default();
|
self.process_worker_state.is_open = true;
|
||||||
};
|
self.process_worker_state.worker = Worker::default();
|
||||||
if ui.button("Обновить").clicked() {
|
};
|
||||||
self.update_workers();
|
|
||||||
}
|
}
|
||||||
|
if ui.button("<-").clicked() {
|
||||||
|
if self.workers_page > 0 {
|
||||||
|
self.workers_page -= 1;
|
||||||
|
self.update_workers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.monospace(self.workers_page.to_string());
|
||||||
|
if ui.button("->").clicked() {
|
||||||
|
if self.workers.read().len().to_i32().unwrap() == misc::ELEMENTS_PER_PAGE {
|
||||||
|
self.workers_page += 1;
|
||||||
|
self.update_workers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ui
|
||||||
|
.checkbox(&mut self.only_not_fired_workers, "Без уволенных")
|
||||||
|
.changed()
|
||||||
|
{
|
||||||
|
self.update_workers();
|
||||||
|
};
|
||||||
});
|
});
|
||||||
if self.process_worker_state.is_open {
|
if self.process_worker_state.is_open {
|
||||||
let pos = self.process_worker_state.worker.position.clone();
|
let pos = self.process_worker_state.worker.position.clone();
|
||||||
|
|
@ -90,6 +112,21 @@ impl WorkerTabViewer {
|
||||||
&self.process_worker_state.worker.position.name
|
&self.process_worker_state.worker.position.name
|
||||||
})
|
})
|
||||||
.show_ui(ui, |ui| {
|
.show_ui(ui, |ui| {
|
||||||
|
if ui.button("<-").clicked() {
|
||||||
|
if self.workers_page > 0 {
|
||||||
|
self.workers_page -= 1;
|
||||||
|
self.update_workers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.monospace(self.workers_page.to_string());
|
||||||
|
if ui.button("->").clicked() {
|
||||||
|
if self.workers.read().len().to_i32().unwrap()
|
||||||
|
== misc::ELEMENTS_PER_PAGE
|
||||||
|
{
|
||||||
|
self.workers_page += 1;
|
||||||
|
self.update_workers();
|
||||||
|
}
|
||||||
|
}
|
||||||
for pos in self.positions.read().clone().iter() {
|
for pos in self.positions.read().clone().iter() {
|
||||||
ui.selectable_value(
|
ui.selectable_value(
|
||||||
&mut self.process_worker_state.worker.position,
|
&mut self.process_worker_state.worker.position,
|
||||||
|
|
@ -165,6 +202,13 @@ impl WorkerTabViewer {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
if self.process_worker_state.worker.is_fired
|
||||||
|
!= self.process_worker_state.old_fired
|
||||||
|
{
|
||||||
|
self.process_worker_state.worker.fire_date =
|
||||||
|
Some(chrono::Local::now());
|
||||||
|
}
|
||||||
|
|
||||||
self.db_oper
|
self.db_oper
|
||||||
.update_worker(self.process_worker_state.worker.clone())
|
.update_worker(self.process_worker_state.worker.clone())
|
||||||
.await
|
.await
|
||||||
|
|
@ -214,13 +258,18 @@ impl WorkerTabViewer {
|
||||||
ui.label(&wk.position.name);
|
ui.label(&wk.position.name);
|
||||||
});
|
});
|
||||||
row.col(|ui| {
|
row.col(|ui| {
|
||||||
ui.label(if wk.is_fired { "Да" } else { "Нет" });
|
ui.label(if wk.is_fired {
|
||||||
|
wk.fire_date.unwrap().date_naive().to_string()
|
||||||
|
} else {
|
||||||
|
"Нет".to_owned()
|
||||||
|
});
|
||||||
});
|
});
|
||||||
if row.response().double_clicked() {
|
if row.response().double_clicked() {
|
||||||
self.process_worker_state.is_open = true;
|
self.process_worker_state.is_open = true;
|
||||||
self.process_worker_state.status = ModalStatus::Edit;
|
self.process_worker_state.status = ModalStatus::Edit;
|
||||||
self.process_worker_state.worker = wk.clone();
|
self.process_worker_state.worker = wk.clone();
|
||||||
self.process_worker_state.old_pos = wk.position.clone();
|
self.process_worker_state.old_pos = wk.position.clone();
|
||||||
|
self.process_worker_state.old_fired = wk.is_fired.clone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -229,22 +278,34 @@ impl WorkerTabViewer {
|
||||||
|
|
||||||
fn show_position(&mut self, ui: &mut egui::Ui) {
|
fn show_position(&mut self, ui: &mut egui::Ui) {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
if ui.button("Добавить").clicked() {
|
if self.is_admin {
|
||||||
// self.show_position_add_modal = true;
|
if ui.button("Добавить").clicked() {
|
||||||
self.process_position_state.is_open = true;
|
// self.show_position_add_modal = true;
|
||||||
self.process_position_state.status = ModalStatus::Add;
|
self.process_position_state.is_open = true;
|
||||||
self.process_position_state
|
self.process_position_state.status = ModalStatus::Add;
|
||||||
.data
|
self.process_position_state
|
||||||
.insert("id".into(), "0".to_string());
|
.data
|
||||||
self.process_position_state
|
.insert("id".into(), "0".to_string());
|
||||||
.data
|
self.process_position_state
|
||||||
.insert("name".into(), String::new());
|
.data
|
||||||
self.process_position_state
|
.insert("name".into(), String::new());
|
||||||
.data
|
self.process_position_state
|
||||||
.insert("wage".into(), String::from("0"));
|
.data
|
||||||
|
.insert("wage".into(), String::from("0"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ui.button("Обновить").clicked() {
|
if ui.button("<-").clicked() {
|
||||||
self.update_positions();
|
if self.positions_page > 0 {
|
||||||
|
self.positions_page -= 1;
|
||||||
|
self.update_positions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui.monospace(self.positions_page.to_string());
|
||||||
|
if ui.button("->").clicked() {
|
||||||
|
if self.positions.read().len().to_i32().unwrap() == ELEMENTS_PER_PAGE {
|
||||||
|
self.positions_page += 1;
|
||||||
|
self.update_positions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
TableBuilder::new(ui)
|
TableBuilder::new(ui)
|
||||||
|
|
@ -368,6 +429,7 @@ impl WorkerTabViewer {
|
||||||
match self.process_position_state.status {
|
match self.process_position_state.status {
|
||||||
ModalStatus::Add => {
|
ModalStatus::Add => {
|
||||||
let pos = self.process_position_state.data.clone();
|
let pos = self.process_position_state.data.clone();
|
||||||
|
|
||||||
self.rt.block_on(async {
|
self.rt.block_on(async {
|
||||||
self.db_oper
|
self.db_oper
|
||||||
.add_position(Position {
|
.add_position(Position {
|
||||||
|
|
@ -378,7 +440,8 @@ impl WorkerTabViewer {
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
})
|
})
|
||||||
.await;
|
.await
|
||||||
|
.unwrap();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ModalStatus::Edit => {
|
ModalStatus::Edit => {
|
||||||
|
|
@ -488,9 +551,10 @@ impl Default for WorkerTabViewer {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
let db_oper = rt.block_on(async { DBOperator::new().await });
|
let db_oper = rt.block_on(async { DBOperator::new().await });
|
||||||
let positions = Arc::new(RwLock::new(
|
let positions =
|
||||||
rt.block_on(async { db_oper.get_position().await.unwrap() }),
|
Arc::new(RwLock::new(rt.block_on(async {
|
||||||
));
|
db_oper.get_positions(0, ELEMENTS_PER_PAGE).await.unwrap()
|
||||||
|
})));
|
||||||
let workers = Arc::new(RwLock::new(rt.block_on(async {
|
let workers = Arc::new(RwLock::new(rt.block_on(async {
|
||||||
db_oper
|
db_oper
|
||||||
.get_workers(0, misc::ELEMENTS_PER_PAGE, false)
|
.get_workers(0, misc::ELEMENTS_PER_PAGE, false)
|
||||||
|
|
@ -520,6 +584,7 @@ impl Default for WorkerTabViewer {
|
||||||
process_worker_state: WorkerModalState {
|
process_worker_state: WorkerModalState {
|
||||||
is_open: false,
|
is_open: false,
|
||||||
can_finish: false,
|
can_finish: false,
|
||||||
|
old_fired: worker.is_fired,
|
||||||
worker,
|
worker,
|
||||||
status: ModalStatus::Add,
|
status: ModalStatus::Add,
|
||||||
old_pos: Position::default(),
|
old_pos: Position::default(),
|
||||||
|
|
@ -533,6 +598,7 @@ impl Default for WorkerTabViewer {
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
only_not_fired_workers: false,
|
only_not_fired_workers: false,
|
||||||
workers_page: 0,
|
workers_page: 0,
|
||||||
|
positions_page: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
1 - Добавить пагниацию там, где её ещё нет
|
1 - Добавить пагниацию там, где её ещё нет
|
||||||
2 - Доделать проверки при нажатии кнопок в модальных окнах
|
2 - Доделать проверки при нажатии кнопок в модальных окнах
|
||||||
3 - Написать часть с клиентом
|
3 - Сделать отчёты
|
||||||
4 - доделать заказы
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue