added models
This commit is contained in:
parent
d6859376b6
commit
beb36a4db4
@ -22,11 +22,11 @@ public class DriverController {
|
|||||||
}
|
}
|
||||||
@PostMapping("/driver")
|
@PostMapping("/driver")
|
||||||
public Driver createDriver(@RequestBody Driver driver) {
|
public Driver createDriver(@RequestBody Driver driver) {
|
||||||
return DriverService.addDriver(driver.getName(), driver.getAge(), driver.getPhone(), driver.getEmail());
|
return DriverService.addDriver(driver.getName(), driver.getBirthday(), driver.getPhone(), driver.getEmail());
|
||||||
}
|
}
|
||||||
@PutMapping("/driver/{id}")
|
@PutMapping("/driver/{id}")
|
||||||
public Driver updateDriver(@PathVariable Long id, @RequestBody Driver driver) {
|
public Driver updateDriver(@PathVariable Long id, @RequestBody Driver driver) {
|
||||||
return DriverService.updateDriver(id, driver.getName(), driver.getAge(), driver.getPhone(), driver.getEmail());
|
return DriverService.updateDriver(id, driver.getName(), driver.getBirthday(), driver.getPhone(), driver.getEmail());
|
||||||
}
|
}
|
||||||
@DeleteMapping("/driver/{id}")
|
@DeleteMapping("/driver/{id}")
|
||||||
public Driver deleteDriver(@PathVariable Long id) {
|
public Driver deleteDriver(@PathVariable Long id) {
|
||||||
|
@ -23,11 +23,11 @@ public class OrderController {
|
|||||||
}
|
}
|
||||||
@PostMapping("/order")
|
@PostMapping("/order")
|
||||||
public Order createOrder(@RequestBody OrderDto orderDto) {
|
public Order createOrder(@RequestBody OrderDto orderDto) {
|
||||||
return OrderService.addOrder(orderDto.getValue(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
|
return OrderService.addOrder(orderDto.getValue(), orderDto.getStatus(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
|
||||||
}
|
}
|
||||||
@PutMapping("/order/{id}")
|
@PutMapping("/order/{id}")
|
||||||
public Order updateOrder(@PathVariable Long id, @RequestBody OrderDto orderDto) {
|
public Order updateOrder(@PathVariable Long id, @RequestBody OrderDto orderDto) {
|
||||||
return OrderService.updateOrder(id, orderDto.getValue(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
|
return OrderService.updateOrder(id, orderDto.getValue(), orderDto.getStatus(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
|
||||||
}
|
}
|
||||||
@DeleteMapping("/order/{id}")
|
@DeleteMapping("/order/{id}")
|
||||||
public Order deleteOrder(@PathVariable Long id) {
|
public Order deleteOrder(@PathVariable Long id) {
|
||||||
|
@ -2,13 +2,15 @@ package com.subd.subd.Dtos;
|
|||||||
|
|
||||||
public class OrderDto {
|
public class OrderDto {
|
||||||
private Double value;
|
private Double value;
|
||||||
|
private String status;
|
||||||
private Long clientId;
|
private Long clientId;
|
||||||
private Long sourcePickUpPointId;
|
private Long sourcePickUpPointId;
|
||||||
private Long destPickUpPointId;
|
private Long destPickUpPointId;
|
||||||
private Long carId;
|
private Long carId;
|
||||||
public OrderDto() {}
|
public OrderDto() {}
|
||||||
public OrderDto(Double value, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
|
public OrderDto(Double value, String status, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.status = status;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.sourcePickUpPointId = sourcePickUpPointId;
|
this.sourcePickUpPointId = sourcePickUpPointId;
|
||||||
this.destPickUpPointId = destPickUpPointId;
|
this.destPickUpPointId = destPickUpPointId;
|
||||||
@ -17,6 +19,9 @@ public class OrderDto {
|
|||||||
public Double getValue() {
|
public Double getValue() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
public String getStatus() {
|
||||||
|
return this.status;
|
||||||
|
}
|
||||||
public Long getClientId() {
|
public Long getClientId() {
|
||||||
return this.clientId;
|
return this.clientId;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import jakarta.persistence.GeneratedValue;
|
|||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -14,13 +15,13 @@ public class Driver {
|
|||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
private Integer age;
|
private Date birthday;
|
||||||
private String phone;
|
private String phone;
|
||||||
private String email;
|
private String email;
|
||||||
Driver() {}
|
Driver() {}
|
||||||
public Driver(String name, Integer age, String phone, String email) {
|
public Driver(String name, Date birthday, String phone, String email) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.age = age;
|
this.birthday = birthday;
|
||||||
this.phone = phone;
|
this.phone = phone;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
@ -28,8 +29,8 @@ public class Driver {
|
|||||||
public void setId(Long id) { this.id = id; }
|
public void setId(Long id) { this.id = id; }
|
||||||
public String getName() { return this.name; }
|
public String getName() { return this.name; }
|
||||||
public void setName(String name) { this.name = name; }
|
public void setName(String name) { this.name = name; }
|
||||||
public Integer getAge() { return this.age; }
|
public Date getBirthday() { return this.birthday; }
|
||||||
public void setAge(Integer age) { this.age = age; }
|
public void setBirthday(Date birthday) { this.birthday = birthday; }
|
||||||
public String getPhone() { return this.phone; }
|
public String getPhone() { return this.phone; }
|
||||||
public void setPhone(String phone) { this.phone = phone; }
|
public void setPhone(String phone) { this.phone = phone; }
|
||||||
public String getEmail() { return this.email; }
|
public String getEmail() { return this.email; }
|
||||||
@ -43,19 +44,19 @@ public class Driver {
|
|||||||
Driver driver = (Driver) o;
|
Driver driver = (Driver) o;
|
||||||
return Objects.equals(this.id, driver.id) &&
|
return Objects.equals(this.id, driver.id) &&
|
||||||
Objects.equals(this.name, driver.name) &&
|
Objects.equals(this.name, driver.name) &&
|
||||||
Objects.equals(this.age, driver.age) &&
|
Objects.equals(this.birthday, driver.birthday) &&
|
||||||
Objects.equals(this.phone, driver.phone) &&
|
Objects.equals(this.phone, driver.phone) &&
|
||||||
Objects.equals(this.email, driver.email);
|
Objects.equals(this.email, driver.email);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(this.id, this.name, this.age, this.phone, this.email);
|
return Objects.hash(this.id, this.name, this.birthday, this.phone, this.email);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Client{" + "id=" + this.id +
|
return "Client{" + "id=" + this.id +
|
||||||
", name='" + this.name + '\'' +
|
", name='" + this.name + '\'' +
|
||||||
", age='" + this.age + '\'' +
|
", birthday='" + this.birthday + '\'' +
|
||||||
", phone='" + this.phone + '\'' +
|
", phone='" + this.phone + '\'' +
|
||||||
", email='" + this.email + '\'' +
|
", email='" + this.email + '\'' +
|
||||||
'}';
|
'}';
|
||||||
|
@ -11,6 +11,7 @@ public class Order {
|
|||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
private Double value;
|
private Double value;
|
||||||
|
private String status;
|
||||||
@ManyToOne( cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER)
|
@ManyToOne( cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "Client_id", nullable = true)
|
@JoinColumn(name = "Client_id", nullable = true)
|
||||||
private Client client;
|
private Client client;
|
||||||
@ -24,8 +25,9 @@ public class Order {
|
|||||||
@JoinColumn(name = "Car_id", referencedColumnName = "id")
|
@JoinColumn(name = "Car_id", referencedColumnName = "id")
|
||||||
private Car car;
|
private Car car;
|
||||||
Order() {}
|
Order() {}
|
||||||
public Order(Double value, Client client, PickUpPoint sourcePickUpPoint, PickUpPoint destPickUpPoint, Car car) {
|
public Order(Double value, String status, Client client, PickUpPoint sourcePickUpPoint, PickUpPoint destPickUpPoint, Car car) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.status = status;
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.sourcePickUpPoint = sourcePickUpPoint;
|
this.sourcePickUpPoint = sourcePickUpPoint;
|
||||||
this.destPickUpPoint = destPickUpPoint;
|
this.destPickUpPoint = destPickUpPoint;
|
||||||
@ -43,6 +45,12 @@ public class Order {
|
|||||||
public void setValue(Double value) {
|
public void setValue(Double value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
public String getStatus() {
|
||||||
|
return this.status;
|
||||||
|
}
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
public Client getClient() {
|
public Client getClient() {
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
@ -81,6 +89,7 @@ public class Order {
|
|||||||
Order order = (Order) o;
|
Order order = (Order) o;
|
||||||
return Objects.equals(this.id, order.id) &&
|
return Objects.equals(this.id, order.id) &&
|
||||||
Objects.equals(this.value, order.value) &&
|
Objects.equals(this.value, order.value) &&
|
||||||
|
Objects.equals(this.status, order.status) &&
|
||||||
Objects.equals(this.client, order.client) &&
|
Objects.equals(this.client, order.client) &&
|
||||||
Objects.equals(this.sourcePickUpPoint, order.sourcePickUpPoint) &&
|
Objects.equals(this.sourcePickUpPoint, order.sourcePickUpPoint) &&
|
||||||
Objects.equals(this.destPickUpPoint, order.destPickUpPoint) &&
|
Objects.equals(this.destPickUpPoint, order.destPickUpPoint) &&
|
||||||
@ -88,12 +97,13 @@ public class Order {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(this.id, this.value, this.client, this.sourcePickUpPoint, destPickUpPoint, car);
|
return Objects.hash(this.id, this.value, this.status, this.client, this.sourcePickUpPoint, destPickUpPoint, car);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Client{" + "id=" + this.id +
|
return "Client{" + "id=" + this.id +
|
||||||
", value='" + this.value + '\'' +
|
", value='" + this.value + '\'' +
|
||||||
|
", status='" + this.status + '\'' +
|
||||||
", client='" + this.client + '\'' +
|
", client='" + this.client + '\'' +
|
||||||
", sourcePickUpPoint='" + this.sourcePickUpPoint + '\'' +
|
", sourcePickUpPoint='" + this.sourcePickUpPoint + '\'' +
|
||||||
", destPickUpPoint='" + this.destPickUpPoint + '\'' +
|
", destPickUpPoint='" + this.destPickUpPoint + '\'' +
|
||||||
|
@ -6,6 +6,7 @@ import com.subd.subd.Repositories.DriverRepository;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -16,8 +17,8 @@ public class DriverService {
|
|||||||
this.driverRepository = driverRepository;
|
this.driverRepository = driverRepository;
|
||||||
}
|
}
|
||||||
@Transactional
|
@Transactional
|
||||||
public Driver addDriver(String name, Integer age, String phone, String email) {
|
public Driver addDriver(String name, Date birthday, String phone, String email) {
|
||||||
final Driver driver = new Driver(name, age, phone, email);
|
final Driver driver = new Driver(name, birthday, phone, email);
|
||||||
return driverRepository.save(driver);
|
return driverRepository.save(driver);
|
||||||
}
|
}
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@ -30,13 +31,13 @@ public class DriverService {
|
|||||||
return driverRepository.findAll();
|
return driverRepository.findAll();
|
||||||
}
|
}
|
||||||
@Transactional
|
@Transactional
|
||||||
public Driver updateDriver(Long id, String name, Integer age, String phone, String email) {
|
public Driver updateDriver(Long id, String name, Date birthday, String phone, String email) {
|
||||||
final Driver currentDriver = findDriver(id);
|
final Driver currentDriver = findDriver(id);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
currentDriver.setName(name);
|
currentDriver.setName(name);
|
||||||
}
|
}
|
||||||
if (age != null) {
|
if (birthday != null) {
|
||||||
currentDriver.setAge(age);
|
currentDriver.setBirthday(birthday);
|
||||||
}
|
}
|
||||||
if (phone != null) {
|
if (phone != null) {
|
||||||
currentDriver.setPhone(phone);
|
currentDriver.setPhone(phone);
|
||||||
|
@ -31,7 +31,7 @@ public class OrderService {
|
|||||||
this.carRepository = carRepository;
|
this.carRepository = carRepository;
|
||||||
}
|
}
|
||||||
@Transactional
|
@Transactional
|
||||||
public Order addOrder(Double value, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
|
public Order addOrder(Double value, String status, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
|
||||||
final Client client = clientRepository.findById(clientId)
|
final Client client = clientRepository.findById(clientId)
|
||||||
.orElseThrow(() -> new ClientNotFoundException(clientId));
|
.orElseThrow(() -> new ClientNotFoundException(clientId));
|
||||||
final PickUpPoint sourcePickUpPoint = pickUpPointRepository.findById(sourcePickUpPointId)
|
final PickUpPoint sourcePickUpPoint = pickUpPointRepository.findById(sourcePickUpPointId)
|
||||||
@ -40,7 +40,7 @@ public class OrderService {
|
|||||||
.orElseThrow(() -> new PickUpPointNotFoundException(destPickUpPointId));
|
.orElseThrow(() -> new PickUpPointNotFoundException(destPickUpPointId));
|
||||||
final Car car = carRepository.findById(carId)
|
final Car car = carRepository.findById(carId)
|
||||||
.orElseThrow(() -> new CarNotFoundException(carId));
|
.orElseThrow(() -> new CarNotFoundException(carId));
|
||||||
final Order order = new Order(value, client, sourcePickUpPoint, destPickUpPoint, car);
|
final Order order = new Order(value, status, client, sourcePickUpPoint, destPickUpPoint, car);
|
||||||
return orderRepository.save(order);
|
return orderRepository.save(order);
|
||||||
}
|
}
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@ -53,11 +53,14 @@ public class OrderService {
|
|||||||
return orderRepository.findAll();
|
return orderRepository.findAll();
|
||||||
}
|
}
|
||||||
@Transactional
|
@Transactional
|
||||||
public Order updateOrder(Long id, Double value, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
|
public Order updateOrder(Long id, Double value, String status, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
|
||||||
final Order currentOrder = findOrder(id);
|
final Order currentOrder = findOrder(id);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
currentOrder.setValue(value);
|
currentOrder.setValue(value);
|
||||||
}
|
}
|
||||||
|
if (status != null) {
|
||||||
|
currentOrder.setStatus(status);
|
||||||
|
}
|
||||||
if (clientId != null) {
|
if (clientId != null) {
|
||||||
final Client client = clientRepository.findById(clientId)
|
final Client client = clientRepository.findById(clientId)
|
||||||
.orElseThrow(() -> new ClientNotFoundException(clientId));
|
.orElseThrow(() -> new ClientNotFoundException(clientId));
|
||||||
|
30
SUBD-front/main.js
Normal file
30
SUBD-front/main.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { createApp } from 'vue'
|
||||||
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
|
import './style.css'
|
||||||
|
import App from './App.vue'
|
||||||
|
import Catalogs from './components/Catalogs.vue'
|
||||||
|
import CatalogStudents from './components/CatalogStudents.vue'
|
||||||
|
import CatalogGroups from './components/CatalogGroups.vue'
|
||||||
|
import CatalogDisciplines from './components/CatalogDisciplines.vue'
|
||||||
|
import Reports from './components/Reports.vue'
|
||||||
|
import ReportGroupStudents from './components/ReportGroupStudents.vue'
|
||||||
|
import ReportGroupDisciplines from './components/ReportGroupDisciplines.vue'
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
{ path: '/', redirect: '/catalogs/students' },
|
||||||
|
{ path: '/catalogs', component: Catalogs, meta: { label: 'Справочники' } },
|
||||||
|
{ path: '/catalogs/students', component: CatalogStudents },
|
||||||
|
{ path: '/catalogs/groups', component: CatalogGroups },
|
||||||
|
{ path: '/catalogs/disciplines', component: CatalogDisciplines },
|
||||||
|
{ path: '/reports', component: Reports, meta: { label: 'Отчеты' } },
|
||||||
|
{ path: '/reports/group-students', component: ReportGroupStudents },
|
||||||
|
{ path: '/reports/group-disciplines', component: ReportGroupDisciplines }
|
||||||
|
]
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createWebHistory(),
|
||||||
|
linkActiveClass: 'active',
|
||||||
|
routes
|
||||||
|
})
|
||||||
|
|
||||||
|
createApp(App).use(router).mount('#app')
|
@ -1,5 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import Header from './components/Header.vue';
|
import Header from './components/Header.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Header
|
Header
|
||||||
@ -9,5 +10,10 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Header></Header>
|
<Header></Header>
|
||||||
<router></router>
|
<div class="container-fluid">
|
||||||
|
<router-view></router-view>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
||||||
|
44
SUBD-front/src/components/CatalogDisciplines.vue
Normal file
44
SUBD-front/src/components/CatalogDisciplines.vue
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<script>
|
||||||
|
import CatalogMixins from '../mixins/CatalogMixins.js';
|
||||||
|
import Discipline from "../models/Discipline";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [
|
||||||
|
CatalogMixins
|
||||||
|
],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
getAllUrl: 'disciplines',
|
||||||
|
dataUrl: 'disciplines/',
|
||||||
|
transformer: (data) => new Discipline(data),
|
||||||
|
headers: [
|
||||||
|
{ name: 'name', label: 'Название дисциплины' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ToolBar
|
||||||
|
@add="showAddModal"
|
||||||
|
@edit="showEditModal"
|
||||||
|
@remove="removeSelectedItems">
|
||||||
|
</ToolBar>
|
||||||
|
<DataTable
|
||||||
|
:headers="this.headers"
|
||||||
|
:items="this.items"
|
||||||
|
:selectedItems="this.selectedItems"
|
||||||
|
@dblclick="showEditModalDblClick">
|
||||||
|
</DataTable>
|
||||||
|
<Modal
|
||||||
|
:header="this.modal.header"
|
||||||
|
:confirm="this.modal.confirm"
|
||||||
|
v-model:visible="this.modalShow"
|
||||||
|
@done="saveItem">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="name" class="form-label">Название дисциплины</label>
|
||||||
|
<input type="text" class="form-control" id="name" required v-model="data.name">
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
44
SUBD-front/src/components/CatalogGroups.vue
Normal file
44
SUBD-front/src/components/CatalogGroups.vue
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<script>
|
||||||
|
import CatalogMixins from '../mixins/CatalogMixins.js';
|
||||||
|
import Group from "../models/Group";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [
|
||||||
|
CatalogMixins
|
||||||
|
],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
getAllUrl: 'groups',
|
||||||
|
dataUrl: 'groups/',
|
||||||
|
transformer: (data) => new Group(data),
|
||||||
|
headers: [
|
||||||
|
{ name: 'name', label: 'Название группы' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ToolBar
|
||||||
|
@add="showAddModal"
|
||||||
|
@edit="showEditModal"
|
||||||
|
@remove="removeSelectedItems">
|
||||||
|
</ToolBar>
|
||||||
|
<DataTable
|
||||||
|
:headers="this.headers"
|
||||||
|
:items="this.items"
|
||||||
|
:selectedItems="this.selectedItems"
|
||||||
|
@dblclick="showEditModalDblClick">
|
||||||
|
</DataTable>
|
||||||
|
<Modal
|
||||||
|
:header="this.modal.header"
|
||||||
|
:confirm="this.modal.confirm"
|
||||||
|
v-model:visible="this.modalShow"
|
||||||
|
@done="saveItem">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="name" class="form-label">Название группы</label>
|
||||||
|
<input type="text" class="form-control" id="name" required v-model="data.name">
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
82
SUBD-front/src/components/CatalogStudents.vue
Normal file
82
SUBD-front/src/components/CatalogStudents.vue
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<script>
|
||||||
|
import CatalogMixins from '../mixins/CatalogMixins.js';
|
||||||
|
import Student from "../models/Student";
|
||||||
|
import Group from '../models/Group';
|
||||||
|
import DataService from '../services/DataService';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [
|
||||||
|
CatalogMixins
|
||||||
|
],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
getAllUrl: 'students?_expand=group',
|
||||||
|
dataUrl: 'students/',
|
||||||
|
transformer: (data) => new Student(data),
|
||||||
|
headers: [
|
||||||
|
{ name: 'name', label: 'ФИО' },
|
||||||
|
{ name: 'birthday', label: 'Дата рождения' },
|
||||||
|
{ name: 'phone', label: 'Номер телефона' },
|
||||||
|
{ name: 'groupName', label: 'Группа' }
|
||||||
|
],
|
||||||
|
groupsUrl: 'groups',
|
||||||
|
groups: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
DataService.readAll(this.groupsUrl, (data) => new Group(data))
|
||||||
|
.then(data => {
|
||||||
|
this.groups = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ToolBar
|
||||||
|
@add="showAddModal"
|
||||||
|
@edit="showEditModal"
|
||||||
|
@remove="removeSelectedItems">
|
||||||
|
</ToolBar>
|
||||||
|
<DataTable
|
||||||
|
:headers="this.headers"
|
||||||
|
:items="this.items"
|
||||||
|
:selectedItems="this.selectedItems"
|
||||||
|
@dblclick="showEditModalDblClick">
|
||||||
|
</DataTable>
|
||||||
|
<Modal
|
||||||
|
:header="this.modal.header"
|
||||||
|
:confirm="this.modal.confirm"
|
||||||
|
v-model:visible="this.modalShow"
|
||||||
|
@done="saveItem">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="lastName" class="form-label">Фамилия</label>
|
||||||
|
<input type="text" class="form-control" id="lastName" required v-model="data.lastName">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="firstName" class="form-label">Имя</label>
|
||||||
|
<input type="text" class="form-control" id="firstName" required v-model="data.firstName">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="birthday" class="form-label">Дата рождения</label>
|
||||||
|
<input type="date" class="form-control" id="birthday" required v-model="data.birthday">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="phone" class="form-label">Номер телефона</label>
|
||||||
|
<input type="tel" class="form-control" id="phone" required pattern="8 [0-9]{3} [0-9]{3} [0-9]{4}"
|
||||||
|
placeholder="8 999 999 9999"
|
||||||
|
v-model="data.phone">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="groups" class="form-label">Группа</label>
|
||||||
|
<select class="form-select" id="group" required v-model="data.groupId">
|
||||||
|
<option disabled value="">Укажите группу</option>
|
||||||
|
<option v-for="group in this.groups"
|
||||||
|
:value="group.id"
|
||||||
|
:selected="data.groupId && group.id === data.groupId">
|
||||||
|
{{ group.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
23
SUBD-front/src/components/Catalogs.vue
Normal file
23
SUBD-front/src/components/Catalogs.vue
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
catalogs: [
|
||||||
|
{ name: 'groups', label: 'Группы' },
|
||||||
|
{ name: 'students', label: 'Студенты' },
|
||||||
|
{ name: 'disciplines', label: 'Дисциплины' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="list-group">
|
||||||
|
<router-link v-for="catalog in this.catalogs"
|
||||||
|
:to="'/catalogs/' + catalog.name"
|
||||||
|
class="list-group-item list-group-item-action">
|
||||||
|
{{ catalog.label }}
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
67
SUBD-front/src/components/DataTable.vue
Normal file
67
SUBD-front/src/components/DataTable.vue
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
headers: Array,
|
||||||
|
items: Array,
|
||||||
|
selectedItems: Array
|
||||||
|
},
|
||||||
|
emits: {
|
||||||
|
dblclick: null
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
rowClick(id) {
|
||||||
|
if (this.isSelected(id)) {
|
||||||
|
var index = this.selectedItems.indexOf(id);
|
||||||
|
if (index !== -1) {
|
||||||
|
this.selectedItems.splice(index, 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.selectedItems.push(id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rowDblClick(id) {
|
||||||
|
this.$emit('dblclick', id);
|
||||||
|
},
|
||||||
|
isSelected(id) {
|
||||||
|
return this.selectedItems.includes(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th v-for="header in this.headers"
|
||||||
|
:id="header.name"
|
||||||
|
scope="col">{{ header.label }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(item, index) in this.items"
|
||||||
|
@click="rowClick(item.id)"
|
||||||
|
@dblclick="rowDblClick(item.id)"
|
||||||
|
:class="{selected: isSelected(item.id)}">
|
||||||
|
<th scope="row">{{ index + 1 }}</th>
|
||||||
|
<td v-for="header in this.headers">
|
||||||
|
{{ item[header.name] }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
tbody tr:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
tr.selected {
|
||||||
|
background-color: #0d6efd;
|
||||||
|
opacity: 80%;
|
||||||
|
}
|
||||||
|
tbody tr {
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,45 +1,35 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
methods: {
|
||||||
|
getRoutes() {
|
||||||
|
return this.$router.options.routes.filter(route => route.meta?.hasOwnProperty('label'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<nav class="navbar navbar-dark navbar-expand-lg sticky-top">
|
<nav class="navbar navbar-expand-lg bg-light">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<button class="btn me-3 border-0" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasScrolling" aria-controls="offcanvasScrolling">
|
<a class="navbar-brand" href="/">
|
||||||
<img class="width-2rem" src="../images/hamburger.png">
|
<i class="fa-solid fa-book"></i>
|
||||||
</button>
|
Деканат
|
||||||
<!-- <a class="navbar-brand" href="index.html">LOGO</a>
|
</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Переключатель навигации">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||||
|
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button> -->
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
<ul class="navbar-nav mb-2 mb-lg-0 justify-content-between align-content-center w-100">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item align-self-center mb-2 mb-md-0">
|
<li class="nav-item"
|
||||||
<!-- <button class="btn btn-primary p-1 border-0 d-inline-flex align-items-center me-2">
|
v-for="route in this.getRoutes()">
|
||||||
<div class="d-inline-flex flex-row align-items-center rounded-1 pe-1 ps-1" id="buttonHeaderRandomInside">
|
<router-link class="nav-link" :to="route.path">{{ route.meta.label }}</router-link>
|
||||||
<img class="m-0 p-0 width-2rem" src="../images/gamecube.png"/>
|
|
||||||
<p class="mb-0">Великий рандом!</p>
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
<a href="#"><img src="../images/search.png" class="width-2rem"/></a> -->
|
|
||||||
</li>
|
|
||||||
<li class="nav-item d-flex align-self-center align-content-center">
|
|
||||||
<!-- <button type="button" class="btn btn-primary me-4" data-bs-toggle="modal" data-bs-target="#enterModal">Войти</button>
|
|
||||||
<div class="vr"></div>
|
|
||||||
<button type="button" class="btn position-relative border-0">
|
|
||||||
<img src="../images/bell.png" class="width-2rem">
|
|
||||||
<span class="position-absolute top-25 start-50 p-1 bg-danger border border-light rounded-circle">
|
|
||||||
<span class="visually-hidden">Новые уведомления</span>
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
<div class="vr me-3"></div>
|
|
||||||
<div class="dropdown">
|
|
||||||
<a class="nav-link dropdown-toggle drop" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
||||||
<img src="../images/user.png" class="rounded-1 width-2rem">
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-dark dropdown-menu-end">
|
|
||||||
<li><a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#enterModal" href="#">Войти</a></li>
|
|
||||||
</ul>
|
|
||||||
</div> -->
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
63
SUBD-front/src/components/Modal.vue
Normal file
63
SUBD-front/src/components/Modal.vue
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
header: String,
|
||||||
|
confirm: String,
|
||||||
|
visible: Boolean
|
||||||
|
},
|
||||||
|
emits: {
|
||||||
|
done: null,
|
||||||
|
'update:visible': (value) => {
|
||||||
|
if (typeof value !== 'boolean') {
|
||||||
|
throw 'Value is not a boolean';
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
hide() {
|
||||||
|
this.$emit('update:visible', false);
|
||||||
|
},
|
||||||
|
done() {
|
||||||
|
if (this.$refs.form.checkValidity()) {
|
||||||
|
this.$emit('done');
|
||||||
|
this.hide();
|
||||||
|
} else {
|
||||||
|
this.$refs.form.reportValidity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="modal fade" tabindex="-1" aria-hidden="true"
|
||||||
|
:class="{ 'modal-show': this.visible, 'show': this.visible }">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h1 class="modal-title fs-5" id="exampleModalLabel">{{ header }}</h1>
|
||||||
|
<button type="button" class="btn-close" aria-label="Close"
|
||||||
|
@click.prevent="hide"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form @submit.prevent="done" ref="form">
|
||||||
|
<slot></slot>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary"
|
||||||
|
@click.prevent="hide">Закрыть</button>
|
||||||
|
<button type="button" class="btn btn-primary"
|
||||||
|
@click.prevent="done">{{ confirm }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.modal-show {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
</style>
|
60
SUBD-front/src/components/ReportGroupDisciplines.vue
Normal file
60
SUBD-front/src/components/ReportGroupDisciplines.vue
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<script>
|
||||||
|
import DataService from '../services/DataService';
|
||||||
|
import Group from "../models/Group";
|
||||||
|
import Discipline from '../models/Discipline';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
groupsUrl: 'groups',
|
||||||
|
groups: [],
|
||||||
|
groupId: undefined,
|
||||||
|
disciplinesUrl: 'groups/%id%/groupDisciplines?_expand=discipline',
|
||||||
|
disciplines: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
DataService.readAll(this.groupsUrl, (data) => new Group(data))
|
||||||
|
.then(data => {
|
||||||
|
this.groups = data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
formReport() {
|
||||||
|
if (!this.groupId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataService.readAll(this.disciplinesUrl.replace('%id%', this.groupId),
|
||||||
|
(data) => new Discipline(data.discipline))
|
||||||
|
.then(data => {
|
||||||
|
this.disciplines = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<select class="form-select" v-model="groupId">
|
||||||
|
<option disabled value="" selected>Выберите группу</option>
|
||||||
|
<option v-for="group in groups" :value="group.id">{{ group.name }}</option>
|
||||||
|
</select>
|
||||||
|
<button class="btn btn-outline-secondary" type="button" id="report-button"
|
||||||
|
@click.prevent="formReport">Сформировать</button>
|
||||||
|
</div>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Название предмета</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(discipline, index) in disciplines">
|
||||||
|
<th scope="row">{{ index + 1 }}</th>
|
||||||
|
<td>{{ discipline.name }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</template>
|
64
SUBD-front/src/components/ReportGroupStudents.vue
Normal file
64
SUBD-front/src/components/ReportGroupStudents.vue
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<script>
|
||||||
|
import DataService from '../services/DataService';
|
||||||
|
import Group from "../models/Group";
|
||||||
|
import Student from '../models/Student';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
groupsUrl: 'groups',
|
||||||
|
groups: [],
|
||||||
|
groupId: undefined,
|
||||||
|
studentsUrl: 'groups/%id%/students',
|
||||||
|
students: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
DataService.readAll(this.groupsUrl, (data) => new Group(data))
|
||||||
|
.then(data => {
|
||||||
|
this.groups = data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
formReport() {
|
||||||
|
if (!this.groupId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataService.readAll(this.studentsUrl.replace('%id%', this.groupId), (data) => new Student(data))
|
||||||
|
.then(data => {
|
||||||
|
this.students = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<select class="form-select" v-model="groupId">
|
||||||
|
<option disabled value="" selected>Выберите группу</option>
|
||||||
|
<option v-for="group in groups"
|
||||||
|
:value="group.id">{{ group.name }}</option>
|
||||||
|
</select>
|
||||||
|
<button class="btn btn-outline-secondary" type="button" id="report-button"
|
||||||
|
@click.prevent="formReport">Сформировать</button>
|
||||||
|
</div>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Фамилия</th>
|
||||||
|
<th scope="col">Имя</th>
|
||||||
|
<th scope="col">Номер телефона</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(student, index) in students">
|
||||||
|
<th scope="row">{{ index + 1 }}</th>
|
||||||
|
<td>{{ student.lastName }}</td>
|
||||||
|
<td>{{ student.firstName }}</td>
|
||||||
|
<td>{{ student.phone }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</template>
|
21
SUBD-front/src/components/Reports.vue
Normal file
21
SUBD-front/src/components/Reports.vue
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
reports: [
|
||||||
|
{ name: 'group-students', label: 'Список студентов' },
|
||||||
|
{ name: 'group-disciplines', label: 'Список дисциплин' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="list-group">
|
||||||
|
<router-link v-for="report in this.reports"
|
||||||
|
:to="'/reports/' + report.name" class="list-group-item list-group-item-action">
|
||||||
|
{{ report.label }}
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
46
SUBD-front/src/components/ToolBar.vue
Normal file
46
SUBD-front/src/components/ToolBar.vue
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
|
||||||
|
},
|
||||||
|
emits: {
|
||||||
|
add: null,
|
||||||
|
edit: null,
|
||||||
|
remove: null
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
add() {
|
||||||
|
this.$emit('add');
|
||||||
|
},
|
||||||
|
edit() {
|
||||||
|
this.$emit('edit');
|
||||||
|
},
|
||||||
|
remove() {
|
||||||
|
this.$emit('remove');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="btn-group mt-2" role="group">
|
||||||
|
<button type="button" class="btn btn-success"
|
||||||
|
@click.prevent="add">
|
||||||
|
Добавить
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-warning"
|
||||||
|
@click.prevent="edit">
|
||||||
|
Изменить
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-danger"
|
||||||
|
@click.prevent="remove">
|
||||||
|
Удалить
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.btn {
|
||||||
|
min-width: 140px;
|
||||||
|
}
|
||||||
|
</style>
|
Binary file not shown.
Before Width: | Height: | Size: 7.5 KiB |
@ -1,25 +0,0 @@
|
|||||||
import { createApp } from 'vue'
|
|
||||||
import App from './App.vue';
|
|
||||||
import Orders from './components/Orders.vue'
|
|
||||||
// import Clients from './components/Clients.vue'
|
|
||||||
// import Cars from './components/Cars.vue'
|
|
||||||
// import Drivers from './components/Drivers.vue'
|
|
||||||
|
|
||||||
// import './assets/main.css'
|
|
||||||
|
|
||||||
const routes = [
|
|
||||||
{ path: '/', redirect: '/orders' },
|
|
||||||
{ path: '/orders', component: Orders },
|
|
||||||
// { path: '/clients', component: Clients},
|
|
||||||
// { path: '/cars', component: Cars},
|
|
||||||
// { path: '/drivers', component: Drivers}
|
|
||||||
]
|
|
||||||
|
|
||||||
const router = createRouter({
|
|
||||||
history: createWebHistory(),
|
|
||||||
linkActiveClass: 'active',
|
|
||||||
routes
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
const app = createApp(App).use(router).mount('#app')
|
|
99
SUBD-front/src/mixins/CatalogMixins.js
Normal file
99
SUBD-front/src/mixins/CatalogMixins.js
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
import ToolBar from '../components/ToolBar.vue';
|
||||||
|
import DataTable from '../components/DataTable.vue';
|
||||||
|
import Modal from '../components/Modal.vue';
|
||||||
|
import DataService from '../services/DataService';
|
||||||
|
|
||||||
|
const CatalogMixin = {
|
||||||
|
components: {
|
||||||
|
ToolBar, DataTable, Modal
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
getAllUrl: undefined,
|
||||||
|
dataUrl: undefined,
|
||||||
|
transformer: undefined,
|
||||||
|
headers: [],
|
||||||
|
items: [],
|
||||||
|
selectedItems: [],
|
||||||
|
modal: {
|
||||||
|
header: undefined,
|
||||||
|
confirm: undefined,
|
||||||
|
},
|
||||||
|
modalShow: false,
|
||||||
|
data: undefined,
|
||||||
|
isEdit: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getItems();
|
||||||
|
this.data = this.transformer();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getItems() {
|
||||||
|
DataService.readAll(this.getAllUrl, this.transformer)
|
||||||
|
.then(data => {
|
||||||
|
this.items = data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
showAddModal() {
|
||||||
|
this.isEdit = false;
|
||||||
|
this.data = this.transformer();
|
||||||
|
this.modal.header = 'Добавление элемента';
|
||||||
|
this.modal.confirm = 'Добавить';
|
||||||
|
this.modalShow = true;
|
||||||
|
},
|
||||||
|
showEditModal() {
|
||||||
|
if (this.selectedItems.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.showEditModalDblClick(this.selectedItems[0]);
|
||||||
|
},
|
||||||
|
showEditModalDblClick(editId) {
|
||||||
|
DataService.read(this.dataUrl + editId, this.transformer)
|
||||||
|
.then(data => {
|
||||||
|
this.data = data;
|
||||||
|
this.isEdit = true;
|
||||||
|
this.modal.header = 'Редактирование элемента';
|
||||||
|
this.modal.confirm = 'Сохранить';
|
||||||
|
this.modalShow = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
saveItem() {
|
||||||
|
if (!this.isEdit) {
|
||||||
|
DataService.create(this.dataUrl, this.data)
|
||||||
|
.then(() => {
|
||||||
|
this.getItems();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
DataService.update(this.dataUrl + this.data.id, this.data)
|
||||||
|
.then(() => {
|
||||||
|
this.getItems();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeSelectedItems() {
|
||||||
|
if (this.selectedItems.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (confirm('Удалить выбранные элементы?')) {
|
||||||
|
const promises = [];
|
||||||
|
const self = this;
|
||||||
|
this.selectedItems.forEach(item => {
|
||||||
|
promises.push(DataService.delete(this.dataUrl + item));
|
||||||
|
});
|
||||||
|
Promise.all(promises).then((results) => {
|
||||||
|
results.forEach(function (id) {
|
||||||
|
const index = self.selectedItems.indexOf(id);
|
||||||
|
if (index === - 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.selectedItems.splice(index, 1);
|
||||||
|
});
|
||||||
|
this.getItems();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CatalogMixin;
|
47
SUBD-front/src/models/Car.js
Normal file
47
SUBD-front/src/models/Car.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
export default class Car {
|
||||||
|
constructor(data) {
|
||||||
|
this._id = data?.id;
|
||||||
|
this._gosNumber = data?.gosNumber;
|
||||||
|
this._vin = data?.vin;
|
||||||
|
this._driver = data?.driver;
|
||||||
|
this._driverId = data?.driverId;
|
||||||
|
}
|
||||||
|
|
||||||
|
get id() {
|
||||||
|
return this._id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get gosNumber() {
|
||||||
|
return this._gosNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
set gosNumber(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New gosNumber value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._gosNumber = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get vin() {
|
||||||
|
return this._vin;
|
||||||
|
}
|
||||||
|
|
||||||
|
set vin(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New vin value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._vin = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get driverId() {
|
||||||
|
return this._groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
set driverId(value) {
|
||||||
|
this._groupId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get driverName() {
|
||||||
|
return this.driver?.name;
|
||||||
|
}
|
||||||
|
}
|
45
SUBD-front/src/models/Client.js
Normal file
45
SUBD-front/src/models/Client.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
export default class Student {
|
||||||
|
constructor(data) {
|
||||||
|
this._id = data?.id;
|
||||||
|
this._name = data?.name;
|
||||||
|
this._phone = data?.phone;
|
||||||
|
this._email = data?.email;
|
||||||
|
}
|
||||||
|
|
||||||
|
get id() {
|
||||||
|
return this._id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get name() {
|
||||||
|
return this._name;
|
||||||
|
}
|
||||||
|
|
||||||
|
set name(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New name value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._name = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get phone() {
|
||||||
|
return this._phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
set phone(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New phone value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._phone = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get email() {
|
||||||
|
return this._email;
|
||||||
|
}
|
||||||
|
|
||||||
|
set email(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New email value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._email = value;
|
||||||
|
}
|
||||||
|
}
|
54
SUBD-front/src/models/Driver.js
Normal file
54
SUBD-front/src/models/Driver.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
export default class Driver {
|
||||||
|
constructor(data) {
|
||||||
|
this._id = data?.id;
|
||||||
|
this._name = data?.name;
|
||||||
|
this._birthday = data?.birthday;
|
||||||
|
this._phone = data?.phone;
|
||||||
|
this._email = data?.email;
|
||||||
|
}
|
||||||
|
|
||||||
|
get id() {
|
||||||
|
return this._id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get name() {
|
||||||
|
return this._name;
|
||||||
|
}
|
||||||
|
|
||||||
|
set name(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New name value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._name = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get birthday() {
|
||||||
|
return this._age;
|
||||||
|
}
|
||||||
|
|
||||||
|
set birthday(value) {
|
||||||
|
this._birthday = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get phone() {
|
||||||
|
return this._phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
set phone(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New phone value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._phone = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get email() {
|
||||||
|
return this._email;
|
||||||
|
}
|
||||||
|
|
||||||
|
set email(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New email value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._email = value;
|
||||||
|
}
|
||||||
|
}
|
86
SUBD-front/src/models/Order.js
Normal file
86
SUBD-front/src/models/Order.js
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
export default class Order {
|
||||||
|
constructor(data) {
|
||||||
|
this._id = data?.id;
|
||||||
|
this._value = data?.value;
|
||||||
|
this._status = data?.status;
|
||||||
|
this._client = data?.client;
|
||||||
|
this._clientId = data?.clientId;
|
||||||
|
this._sourcePickUpPoint = data?.sourcePickUpPoint;
|
||||||
|
this._sourcePickUpPointId = data?.sourcePickUpPointId;
|
||||||
|
this._destPickUpPoint = data?.destPickUpPoint;
|
||||||
|
this._destPickUpPointId = data?.destPickUpPointId;
|
||||||
|
this._car = data?.car;
|
||||||
|
this._carId = data?.carId;
|
||||||
|
}
|
||||||
|
|
||||||
|
get id() {
|
||||||
|
return this._id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get value() {
|
||||||
|
return this._value;
|
||||||
|
}
|
||||||
|
|
||||||
|
set value(data) {
|
||||||
|
this._value = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
get status() {
|
||||||
|
return this._status;
|
||||||
|
}
|
||||||
|
|
||||||
|
set status(data) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New status value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._status = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clientId() {
|
||||||
|
return this._firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
set clientId(value) {
|
||||||
|
this._clientId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get clientName() {
|
||||||
|
return this._client?.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
get sourcePickUpPointId() {
|
||||||
|
return this._sourcePickUpPointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
set sourcePickUpPointId(value) {
|
||||||
|
this._sourcePickUpPointId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get sourcePickUpPointAddress() {
|
||||||
|
return this._sourcePickUpPoint?.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
get destPickUpPointId() {
|
||||||
|
return this._destPickUpPointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
set destPickUpPointId(value) {
|
||||||
|
this._destPickUpPointId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get destPickUpPointAddress() {
|
||||||
|
return this._destPickUpPoint?.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
get carId() {
|
||||||
|
return this._carId;
|
||||||
|
}
|
||||||
|
|
||||||
|
set carId(value) {
|
||||||
|
this._carId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
get carNumber() {
|
||||||
|
return this.car?.gosNumber;
|
||||||
|
}
|
||||||
|
}
|
21
SUBD-front/src/models/PickUpPoint.js
Normal file
21
SUBD-front/src/models/PickUpPoint.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
export default class PickUpPoint {
|
||||||
|
constructor(data) {
|
||||||
|
this._id = data?.id;
|
||||||
|
this._address = data?.address;
|
||||||
|
}
|
||||||
|
|
||||||
|
get id() {
|
||||||
|
return this._id;
|
||||||
|
}
|
||||||
|
|
||||||
|
get address() {
|
||||||
|
return this._address;
|
||||||
|
}
|
||||||
|
|
||||||
|
set address(value) {
|
||||||
|
if (typeof value !== 'string' || value === null || value.length == 0) {
|
||||||
|
throw 'New address value ' + value + ' is not a string or empty';
|
||||||
|
}
|
||||||
|
this._address = value;
|
||||||
|
}
|
||||||
|
}
|
@ -7,22 +7,22 @@ function toJSON(data) {
|
|||||||
if (data[field] === undefined) {
|
if (data[field] === undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
jsonObj[field.substring(0)] = data[field];
|
jsonObj[field.substring(1)] = data[field];
|
||||||
}
|
}
|
||||||
return jsonObj;
|
return jsonObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class DataService {
|
export default class DataService {
|
||||||
static dataUrlPrefix = 'http://127.0.0.1:8080/';
|
static dataUrlPrefix = 'http://localhost:8080/';
|
||||||
|
|
||||||
static async readAll(url, transformer) {
|
static async readAll(url, transformer) {
|
||||||
const response = await axios.get(this.dataUrlPrefix + url);
|
const response = await axios.get(this.dataUrlPrefix + url);
|
||||||
return response.data.map(item => transformer(item));
|
return response.data.map(item => transformer(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
static async read(url) {
|
static async read(url, transformer) {
|
||||||
const response = await axios.get(this.dataUrlPrefix + url);
|
const response = await axios.get(this.dataUrlPrefix + url);
|
||||||
return response.data;
|
return transformer(response.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async create(url, data) {
|
static async create(url, data) {
|
||||||
|
0
SUBD-front/style.css
Normal file
0
SUBD-front/style.css
Normal file
Loading…
Reference in New Issue
Block a user