added main front page and filter for orders in back

This commit is contained in:
root 2023-04-22 22:07:28 +04:00
parent beb36a4db4
commit 2d00c781be
24 changed files with 458 additions and 361 deletions

View File

@ -5,6 +5,7 @@ import com.subd.subd.Models.Order;
import com.subd.subd.Services.OrderService;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
@RestController
@ -21,13 +22,24 @@ public class OrderController {
public List<Order> getOrders() {
return OrderService.findAllOrders();
}
@GetMapping("/order/filter")
public List<Order> getFilteredOrders(@RequestParam(value = "id", required = false) Long id,
@RequestParam(value = "value", required = false) Double value,
@RequestParam(value = "status", required = false) String status,
@RequestParam(value = "date", required = false) Date date,
@RequestParam(value = "clientId", required = false) Long clientId,
@RequestParam(value = "sourcePickUpPointId", required = false) Long sourcePickUpPointId,
@RequestParam(value = "destPickUpPointId", required = false) Long destPickUpPointId,
@RequestParam(value = "carId", required = false) Long carId) {
return OrderService.findfilteredOrders(id, value, status, date, clientId, sourcePickUpPointId, destPickUpPointId, carId);
}
@PostMapping("/order")
public Order createOrder(@RequestBody OrderDto orderDto) {
return OrderService.addOrder(orderDto.getValue(), orderDto.getStatus(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
return OrderService.addOrder(orderDto.getValue(), orderDto.getStatus(), orderDto.getDate(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
}
@PutMapping("/order/{id}")
public Order updateOrder(@PathVariable Long id, @RequestBody OrderDto orderDto) {
return OrderService.updateOrder(id, orderDto.getValue(), orderDto.getStatus(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
return OrderService.updateOrder(id, orderDto.getValue(), orderDto.getStatus(), orderDto.getDate(), orderDto.getClientId(), orderDto.getSourcePickUpPointId(), orderDto.getDestPickUpPointId(), orderDto.getCarId());
}
@DeleteMapping("/order/{id}")
public Order deleteOrder(@PathVariable Long id) {

View File

@ -1,16 +1,24 @@
package com.subd.subd.Dtos;
import com.subd.subd.Models.PickUpPoint;
import jakarta.annotation.Nullable;
import java.util.Date;
public class OrderDto {
private Double value;
private String status;
private Date date;
private Long clientId;
private Long sourcePickUpPointId;
@Nullable
private Long destPickUpPointId;
private Long carId;
public OrderDto() {}
public OrderDto(Double value, String status, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
public OrderDto(Double value, String status, Date date, Long clientId, Long sourcePickUpPointId, @Nullable Long destPickUpPointId, Long carId) {
this.value = value;
this.status = status;
this.date = date;
this.clientId = clientId;
this.sourcePickUpPointId = sourcePickUpPointId;
this.destPickUpPointId = destPickUpPointId;
@ -19,15 +27,19 @@ public class OrderDto {
public Double getValue() {
return this.value;
}
public String getStatus() {
public String getStatus() {
return this.status;
}
public Date getDate() {
return this.date;
}
public Long getClientId() {
return this.clientId;
}
public Long getSourcePickUpPointId() {
return this.sourcePickUpPointId;
}
@Nullable
public Long getDestPickUpPointId() {
return this.destPickUpPointId;
}

View File

@ -1,7 +1,9 @@
package com.subd.subd.Models;
import jakarta.annotation.Nullable;
import jakarta.persistence.*;
import java.util.Date;
import java.util.Objects;
@Entity
@ -12,12 +14,14 @@ public class Order {
private Long id;
private Double value;
private String status;
private Date date;
@ManyToOne( cascade = {CascadeType.MERGE}, fetch = FetchType.EAGER)
@JoinColumn(name = "Client_id", nullable = true)
private Client client;
@OneToOne()
@JoinColumn(name = "sourcePickUpPoint_id", referencedColumnName = "id")
private PickUpPoint sourcePickUpPoint;
@Nullable
@OneToOne()
@JoinColumn(name = "destPickUpPoint_id", referencedColumnName = "id")
private PickUpPoint destPickUpPoint;
@ -25,9 +29,10 @@ public class Order {
@JoinColumn(name = "Car_id", referencedColumnName = "id")
private Car car;
Order() {}
public Order(Double value, String status, Client client, PickUpPoint sourcePickUpPoint, PickUpPoint destPickUpPoint, Car car) {
public Order(Double value, String status, Date date, Client client, PickUpPoint sourcePickUpPoint, @Nullable PickUpPoint destPickUpPoint, Car car) {
this.value = value;
this.status = status;
this.date = date;
this.client = client;
this.sourcePickUpPoint = sourcePickUpPoint;
this.destPickUpPoint = destPickUpPoint;
@ -51,6 +56,12 @@ public class Order {
public void setStatus(String status) {
this.status = status;
}
public Date getDate() {
return this.date;
}
public void setDate(Date date) {
this.date = date;
}
public Client getClient() {
return client;
}

View File

@ -12,11 +12,11 @@ import com.subd.subd.Repositories.CarRepository;
import com.subd.subd.Repositories.ClientRepository;
import com.subd.subd.Repositories.OrderRepository;
import com.subd.subd.Repositories.PickUpPointRepository;
import jakarta.annotation.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.*;
@Service
public class OrderService {
@ -31,16 +31,21 @@ public class OrderService {
this.carRepository = carRepository;
}
@Transactional
public Order addOrder(Double value, String status, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
public Order addOrder(Double value, String status, Date date, Long clientId, Long sourcePickUpPointId, @Nullable Long destPickUpPointId, Long carId) {
final Client client = clientRepository.findById(clientId)
.orElseThrow(() -> new ClientNotFoundException(clientId));
final PickUpPoint sourcePickUpPoint = pickUpPointRepository.findById(sourcePickUpPointId)
.orElseThrow(() -> new PickUpPointNotFoundException(sourcePickUpPointId));
final PickUpPoint destPickUpPoint = pickUpPointRepository.findById(destPickUpPointId)
.orElseThrow(() -> new PickUpPointNotFoundException(destPickUpPointId));
final Car car = carRepository.findById(carId)
.orElseThrow(() -> new CarNotFoundException(carId));
final Order order = new Order(value, status, client, sourcePickUpPoint, destPickUpPoint, car);
final Order order;
if (destPickUpPointId != null) {
final PickUpPoint destPickUpPoint = pickUpPointRepository.findById(destPickUpPointId)
.orElseThrow(() -> new PickUpPointNotFoundException(destPickUpPointId));
order = new Order(value, status, date, client, sourcePickUpPoint, destPickUpPoint, car);
} else {
order = new Order(value, status, date, client, sourcePickUpPoint, null, car);
}
return orderRepository.save(order);
}
@Transactional(readOnly = true)
@ -52,8 +57,45 @@ public class OrderService {
public List<Order> findAllOrders() {
return orderRepository.findAll();
}
@Transactional(readOnly = true)
public List<Order> findfilteredOrders(Long id, Double value, String status, Date date, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
List<Order> allOrders = orderRepository.findAll();
List<Order> result = new ArrayList<>();
for (Order order : allOrders) {
boolean flag = true;
if (id != null && !Objects.equals(order.getId(), id)) {
flag = false;
}
if (value != null && !Objects.equals(order.getValue(), value)) {
flag = false;
}
if (status != null && !Objects.equals(order.getStatus(), status)) {
flag = false;
}
if (date != null && !Objects.equals(order.getDate(), date)) {
flag = false;
}
if (clientId != null && !Objects.equals(order.getClient().getId(), clientId)) {
flag = false;
}
if (sourcePickUpPointId != null && !Objects.equals(order.getSourcePickUpPoint().getId(), sourcePickUpPointId)) {
flag = false;
}
if (destPickUpPointId != null && !Objects.equals(order.getDestPickUpPoint().getId(), destPickUpPointId)) {
flag = false;
}
if (carId != null && !Objects.equals(order.getCar().getId(), carId)) {
flag = false;
}
if (flag) {
result.add(order);
}
}
return result;
}
@Transactional
public Order updateOrder(Long id, Double value, String status, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
public Order updateOrder(Long id, Double value, String status, Date date, Long clientId, Long sourcePickUpPointId, Long destPickUpPointId, Long carId) {
final Order currentOrder = findOrder(id);
if (value != null) {
currentOrder.setValue(value);
@ -61,6 +103,9 @@ public class OrderService {
if (status != null) {
currentOrder.setStatus(status);
}
if (date != null) {
currentOrder.setDate(date);
}
if (clientId != null) {
final Client client = clientRepository.findById(clientId)
.orElseThrow(() -> new ClientNotFoundException(clientId));

View File

@ -0,0 +1,13 @@
package com.subd.subd;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
}
}

View File

@ -1,7 +1,7 @@
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.hibernate.ddl-auto=none
spring.datasource.initialization-mode=always
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://109.197.199.134:5432/subd
spring.datasource.username=postgres
spring.datasource.password=250303Zyzf-d-grad
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=false

12
SUBD-front/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:5174",
"webRoot": "${workspaceFolder}/src"
}
]
}

View File

@ -1,30 +0,0 @@
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')

View File

@ -8,6 +8,8 @@
"name": "subd-front",
"version": "0.0.0",
"dependencies": {
"@eonasdan/tempus-dominus": "^6.4.4",
"@popperjs/core": "^2.11.7",
"axios": "^1.3.6",
"bootstrap": "^5.2.3",
"vue": "^3.2.47",
@ -465,6 +467,22 @@
"node": ">=6.9.0"
}
},
"node_modules/@eonasdan/tempus-dominus": {
"version": "6.4.4",
"resolved": "https://registry.npmjs.org/@eonasdan/tempus-dominus/-/tempus-dominus-6.4.4.tgz",
"integrity": "sha512-QPxUlu+ZaJR0sERiKx1dRDxuq1NJh1jSZqf+IB7ZNG8CXBL7wOBsYAYEwSu6web3KGdzWlxfRmpgzwtR3EFgSg==",
"funding": {
"url": "https://ko-fi.com/eonasdan"
},
"peerDependencies": {
"@popperjs/core": "^2.11.6"
},
"peerDependenciesMeta": {
"@popperjs/core\"": {
"optional": true
}
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.17.15",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.15.tgz",
@ -875,7 +893,6 @@
"version": "2.11.7",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.7.tgz",
"integrity": "sha512-Cr4OjIkipTtcXKjAsm8agyleBuDHvxzeBoa1v543lbv1YaIwQjESsVcmjiWiPEbC1FIeHOG/Op9kdCmAmiS3Kw==",
"peer": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/popperjs"

View File

@ -1,44 +0,0 @@
<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>

View File

@ -1,44 +0,0 @@
<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>

View File

@ -1,82 +0,0 @@
<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>

View File

@ -3,9 +3,9 @@
data() {
return {
catalogs: [
{ name: 'groups', label: 'Группы' },
{ name: 'students', label: 'Студенты' },
{ name: 'disciplines', label: 'Дисциплины' }
{ name: 'orders', label: 'Заказы' },
// { name: 'students', label: 'Студенты' },
// { name: 'disciplines', label: 'Дисциплины' }
]
}
}

View File

@ -24,6 +24,21 @@
},
isSelected(id) {
return this.selectedItems.includes(id);
},
dataConvert(data) {
if (data == "accepted") {
return "Принят";
}
if (data == "inDelivery") {
return "В пути";
}
if (data == "delvered") {
return "Доставлен";
}
if (data == "issued") {
return "Выдан";
}
return data;
}
}
}
@ -46,7 +61,7 @@
:class="{selected: isSelected(item.id)}">
<th scope="row">{{ index + 1 }}</th>
<td v-for="header in this.headers">
{{ item[header.name] }}
{{ dataConvert(item[header.name]) }}
</td>
</tr>
</tbody>

View File

@ -13,7 +13,7 @@
<div class="container-fluid">
<a class="navbar-brand" href="/">
<i class="fa-solid fa-book"></i>
Деканат
Рабочее место оператора пункта выдачи заказов
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">

View File

@ -0,0 +1,247 @@
<script>
import CatalogMixins from '../mixins/CatalogMixins.js';
import Order from "../models/Order";
import Car from '../models/Car';
import Client from '../models/Client';
import PickUpPoint from '../models/PickUpPoint';
import DataService from '../services/DataService';
export default {
mixins: [
CatalogMixins
],
data() {
return {
getAllUrl: 'order',
dataUrl: 'order',
transformer: (data) => new Order(data),
headers: [
{ name: 'value', label: 'Оценочная стоимость' },
{ name: 'status', label: 'Статус' },
{ name: 'date', label: 'Дата' },
{ name: 'clientName', label: 'Клиент' },
{ name: 'sourcePickUpPointAddress', label: 'Пункт отправления' },
{ name: 'destPickUpPointAddress', label: 'Пункт выдачи' },
{ name: 'carNumber', label: 'Автомобиль' }
],
dataFilterUrl: 'order/filter?',
carUrl: 'car',
cars: [],
pickUpPointUrl: 'pickUpPoint',
pickUpPoints: [],
clientUrl: 'client',
clients: [],
}
},
created() {
DataService.readAll(this.carUrl, (data) => new Car(data))
.then(data => {
this.cars = data;
});
DataService.readAll(this.pickUpPointUrl, (data) => new PickUpPoint(data))
.then(data => {
this.pickUpPoints = data;
});
DataService.readAll(this.clientUrl, (data) => new Client(data))
.then(data => {
this.clients = data;
});
},
methods: {
filter() {
let urlParams = ""
if (document.getElementById('idFilterInput').value != "") {
if (urlParams != "") {
urlParams += "&";
}
urlParams += "id=" + this.id;
}
if (document.getElementById('valueFilterInput').value != "") {
if (urlParams != "") {
urlParams += "&";
}
urlParams += "value=" + this.value;
}
if (document.getElementById('statusFilterSelect').value != "") {
if (urlParams != "") {
urlParams += "&";
}
urlParams += "status=" + this.status;
}
if (document.getElementById('dateFilterInput').value != "") {
if (urlParams != "") {
urlParams += "&";
}
urlParams += "date=" + this.date;
}
if (document.getElementById('clientFilterSelect').value != "") {
if (urlParams != "") {
urlParams += "&";
}
urlParams += "clientId=" + this.clientId;
}
if (document.getElementById('sourcePickUpPointFilterSelect').value != "") {
if (urlParams != "") {
urlParams += "&";
}
urlParams += "sourcePickUpPointId=" + this.sourcePickUpPointId;
}
if (document.getElementById('destPickUpPointFilterSelect').value != "") {
if (urlParams != "") {
urlParams += "&";
}
urlParams += "destPickUpPointId=" + this.destPickUpPointId;
}
if (document.getElementById('carFilterSelect').value != "") {
if (urlParams != "") {
urlParams += "&";
}
urlParams += "carId=" + this.carId;
}
DataService.readAll(this.dataFilterUrl + urlParams, (data) => new Order(data))
.then(data => {
this.items = data;
});
},
clearFilters() {
this.loadItems();
this.id = null;
this.value = null;
this.status = null;
this.date = null;
this.clientId = null;
this.sourcePickUpPointId = null;
this.destPickUpPointId = null;
this.destPickUpPointId = null;
this.carId = null;
}
}
}
</script>
<template>
<div class="input-group mb-3">
<input type="text" class="form-control" id="idFilterInput" placeholder="Номер заказа" required v-model="id">
<input type="text" class="form-control" id="valueFilterInput" placeholder="Оценочная стоимость" required v-model="value">
<select class="form-select" id="statusFilterSelect" v-model="status">
<option disabled value="" selected>Выберите статус</option>
<option value="accepted">Принят</option>
<option value="inDelivery">В пути</option>
<option value="delivered">Доставлен</option>
<option value="issued">Выдан</option>
</select>
<input type="date" class="form-control" id="dateFilterInput" placeholder="Дата" required v-model="date">
<select class="form-select" id="clientFilterSelect" v-model="clientId">
<option disabled value="" selected>Выберите клиента</option>
<option v-for="client in clients" :value="client.id">{{ client.name }}</option>
</select>
<select class="form-select" id="sourcePickUpPointFilterSelect" v-model="sourcePickUpPointId">
<option disabled value="" selected>Выберите пункт отправления</option>
<option v-for="sourcePickUpPoint in pickUpPoints" :value="sourcePickUpPoint.id">{{ sourcePickUpPoint.address }}</option>
</select>
<select class="form-select" id="destPickUpPointFilterSelect" v-model="destPickUpPointId">
<option disabled value="" selected>Выберите пункт получения</option>
<option v-for="destPickUpPoint in pickUpPoints" :value="destPickUpPoint.id">{{ destPickUpPoint.address }}</option>
</select>
<select class="form-select" id="carFilterSelect" v-model="carId">
<option disabled value="" selected>Выберите автомобиль</option>
<option v-for="car in cars" :value="car.id">{{ car.gosNumber }}</option>
</select>
<button class="btn btn-primary" type="button" id="report-button"
@click.prevent="filter">Сформировать</button>
<button class="btn btn-outline-secondary" type="button" id="report-button"
@click.prevent="clearFilters">Очистить</button>
</div>
<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="value" class="form-label">Оценочная стоимость</label>
<input type="text" class="form-control" id="value" required v-model="data.value">
</div>
<div class="mb-3">
<label for="status" class="form-label">Статус</label>
<div class="form-check">
<input class="form-check-input" type="radio" name="status" id="statusAccepted" v-model="data.status" value="accepted" checked>
<label class="form-check-label" for="statusAccepted">
Принят
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="status" id="statusIssued" v-model="data.status" value="issued">
<label class="form-check-label" for="statusIssued">
Выдан
</label>
</div>
</div>
<div class="mb-3">
<label for="date" class="form-label">Дата</label>
<input type="date" class="form-control" id="date" required v-model="data.date">
</div>
<div class="mb-3">
<label for="clients" class="form-label">Клиент</label>
<select class="form-select" id="client" required v-model="data.clientId">
<option disabled value="">Выберите клиента</option>
<option v-for="client in this.clients"
:value="client.id"
:selected="data.clientId && client.id === data.clientId">
{{ client.name }}
</option>
</select>
</div>
<div class="mb-3">
<label for="pickUpPoints" class="form-label">Пункт отправления</label>
<select class="form-select" id="sourcePickUpPoint" required v-model="data.sourcePickUpPointId">
<option disabled value="">Выберите пункт отправления</option>
<option v-for="sourcePickUpPoint in this.pickUpPoints"
:value="sourcePickUpPoint.id"
:selected="data.sourcePickUpPointId && sourcePickUpPoint.id === data.sourcePickUpPointId">
{{ sourcePickUpPoint.address }}
</option>
</select>
</div>
<div class="mb-3">
<label for="pickUpPoints" class="form-label">Пункт выдачи</label>
<select class="form-select" id="destPickUpPoint" v-model="data.destPickUpPointId">
<option disabled value="">Выберите пункт выдачи</option>
<option v-for="destPickUpPoint in this.pickUpPoints"
:value="destPickUpPoint.id"
:selected="data.destPickUpPointId && destPickUpPoint.id === data.destPickUpPointId">
{{ destPickUpPoint.address }}
</option>
</select>
</div>
<div class="mb-3">
<label for="cars" class="form-label">Автомобиль</label>
<select class="form-select" id="car" required v-model="data.carId">
<option disabled value="">Выберите автомобиль</option>
<option v-for="car in this.cars"
:value="car.id"
:selected="data.carId && car.id === data.carId">
{{ car.vin }}
</option>
</select>
</div>
</Modal>
</template>

View File

@ -1,60 +0,0 @@
<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>

View File

@ -1,64 +0,0 @@
<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>

27
SUBD-front/src/main.js Normal file
View File

@ -0,0 +1,27 @@
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import './style.css'
import App from './App.vue'
import CatalogOrders from './components/Orders.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: '/orders' },
{ path: '/orders', component: CatalogOrders, meta: { label: 'Заказы' }},
// { 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')

View File

@ -25,10 +25,13 @@ const CatalogMixin = {
}
},
created() {
this.getItems();
this.data = this.transformer();
this.loadItems();
},
methods: {
loadItems() {
this.getItems();
this.data = this.transformer();
},
getItems() {
DataService.readAll(this.getAllUrl, this.transformer)
.then(data => {
@ -49,7 +52,7 @@ const CatalogMixin = {
this.showEditModalDblClick(this.selectedItems[0]);
},
showEditModalDblClick(editId) {
DataService.read(this.dataUrl + editId, this.transformer)
DataService.read(this.dataUrl + "/" + editId, this.transformer)
.then(data => {
this.data = data;
this.isEdit = true;
@ -65,7 +68,7 @@ const CatalogMixin = {
this.getItems();
});
} else {
DataService.update(this.dataUrl + this.data.id, this.data)
DataService.update(this.dataUrl + "/" + this.data.id, this.data)
.then(() => {
this.getItems();
});

View File

@ -4,7 +4,7 @@ export default class Car {
this._gosNumber = data?.gosNumber;
this._vin = data?.vin;
this._driver = data?.driver;
this._driverId = data?.driverId;
this._driverId = data?.driver.id;
}
get id() {
@ -17,7 +17,7 @@ export default class Car {
set gosNumber(value) {
if (typeof value !== 'string' || value === null || value.length == 0) {
throw 'New gosNumber value ' + value + ' is not a string or empty';
throw 'New gos number value ' + value + ' is not a string or empty';
}
this._gosNumber = value;
}

View File

@ -3,14 +3,15 @@ export default class Order {
this._id = data?.id;
this._value = data?.value;
this._status = data?.status;
this._date = data?.date.split('T')[0];
this._client = data?.client;
this._clientId = data?.clientId;
this._clientId = data?.client.id;
this._sourcePickUpPoint = data?.sourcePickUpPoint;
this._sourcePickUpPointId = data?.sourcePickUpPointId;
this._sourcePickUpPointId = data?.sourcePickUpPoint.id;
this._destPickUpPoint = data?.destPickUpPoint;
this._destPickUpPointId = data?.destPickUpPointId;
this._destPickUpPointId = data?.destPickUpPoint?.id;
this._car = data?.car;
this._carId = data?.carId;
this._carId = data?.car.id;
}
get id() {
@ -30,14 +31,19 @@ export default class Order {
}
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 date() {
return this._date;
}
set date(data) {
this._date = data;
}
get clientId() {
return this._firstName;
return this._clientId;
}
set clientId(value) {
@ -81,6 +87,6 @@ export default class Order {
}
get carNumber() {
return this.car?.gosNumber;
return this._car?.gosNumber;
}
}

View File

@ -11,5 +11,6 @@ export default defineConfig({
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})
},
server: {cors: false}
})