dev #12906
This commit is contained in:
parent
3fcfc72848
commit
f0dec336c9
@ -12,7 +12,7 @@ import { CookiesService } from './services/cookies.service';
|
|||||||
providers: [DialogService],
|
providers: [DialogService],
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit {
|
||||||
public opened: boolean = false;
|
public opened: boolean = true;
|
||||||
public isAuth!: boolean;
|
public isAuth!: boolean;
|
||||||
private messageComponent!: ComponentRef<Toast>;
|
private messageComponent!: ComponentRef<Toast>;
|
||||||
title = 'selfdelivery-admin-panel';
|
title = 'selfdelivery-admin-panel';
|
||||||
|
|||||||
@ -26,8 +26,9 @@ import { ScrollPanelModule } from 'primeng/scrollpanel';
|
|||||||
import { ToastModule } from 'primeng/toast';
|
import { ToastModule } from 'primeng/toast';
|
||||||
import { ConfirmDialogModule } from 'primeng/confirmdialog';
|
import { ConfirmDialogModule } from 'primeng/confirmdialog';
|
||||||
import { ConfirmationService } from 'primeng/api';
|
import { ConfirmationService } from 'primeng/api';
|
||||||
|
import { DropdownModule } from 'primeng/dropdown';
|
||||||
|
import { ChipsModule } from 'primeng/chips';
|
||||||
|
import { ButtonModule } from 'primeng/button';
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{ path: 'clients', component: ClientsComponent },
|
{ path: 'clients', component: ClientsComponent },
|
||||||
@ -67,6 +68,9 @@ const routes = [
|
|||||||
ConfirmDialogModule,
|
ConfirmDialogModule,
|
||||||
TableModule,
|
TableModule,
|
||||||
ScrollPanelModule,
|
ScrollPanelModule,
|
||||||
|
DropdownModule,
|
||||||
|
ChipsModule,
|
||||||
|
ButtonModule,
|
||||||
RouterModule.forRoot(routes)
|
RouterModule.forRoot(routes)
|
||||||
],
|
],
|
||||||
providers: [MessageService, { provide: APP_BASE_HREF, useValue: '/' }, ConfirmationService],
|
providers: [MessageService, { provide: APP_BASE_HREF, useValue: '/' }, ConfirmationService],
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
<th style="width: 16%">ID</th>
|
<th style="width: 16%">ID</th>
|
||||||
<th style="width: 16%">ID кассы ККМ</th>
|
<th style="width: 16%">ID кассы ККМ</th>
|
||||||
<th style="width: 16%">ID точки заказа</th>
|
<th style="width: 16%">ID точки заказа</th>
|
||||||
<th style="width: 16%">Список ID цехов готовки</th>
|
<th style="width: 16%">ID зон доставок</th>
|
||||||
<th style="width: 16%">Статус подключения</th>
|
<th style="width: 16%">Статус подключения</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
@ -56,22 +56,41 @@
|
|||||||
<th><input type="text" style="width: 400px; height: 30px; font-size:20px"></th>
|
<th><input type="text" style="width: 400px; height: 30px; font-size:20px"></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Введите ID точки заказа:</th>
|
<th>Выберите точку заказа:</th>
|
||||||
<th><input type="text" style="width: 400px; height: 30px; font-size:20px"></th>
|
|
||||||
</tr>
|
|
||||||
<!--<tr>
|
|
||||||
<th>Введите ID цехов готовки:</th>
|
|
||||||
|
|
||||||
<th>
|
<th>
|
||||||
<tbody *ngFor="let area of areas">
|
<p-dropdown autoWidth="false" [options]="divisions" optionLabel="name" [(ngModel)]="selectedDivision"></p-dropdown>
|
||||||
<tr>
|
|
||||||
<input type="checkbox" value="{{area.selected}}" id="ar" [(ngModel)]="area.selected">
|
</th>
|
||||||
<span>Цех: {{area.name}}</span>
|
</tr>
|
||||||
</tr>
|
<tr>
|
||||||
</tbody>-->
|
<th>Введите ID зон доставок:</th>
|
||||||
<!--</th>-->
|
<th>
|
||||||
|
|
||||||
|
<ul class="selectedAreasList" style="width: 400px; font-size:16px">
|
||||||
|
<p-dropdown autoWidth="false" [options]="areas" optionLabel="name" (onChange)="addAreaToSelected($event)"></p-dropdown>
|
||||||
|
<li *ngFor="let area of selectedAreas">
|
||||||
|
<span>{{area.name}}</span>
|
||||||
|
<button style="font-weight: bold" (click)="removeAreaFromSelected(area.id)">✖</button>
|
||||||
|
<!-- <p-button (click)="removeAreaFromSelected(area.id)" icon="pi pi-times-circle"></p-button> -->
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<!-- <p-chips [(ngModel)]="selectedAreas" [allowDuplicate]="false" inputId="chipInputField">
|
||||||
|
<ng-template let-item pTemplate="item">
|
||||||
|
{{item.name}} <i class="fa fa-close"></i>
|
||||||
|
</ng-template>
|
||||||
|
</p-chips> -->
|
||||||
|
</th>
|
||||||
|
|
||||||
<!--</tr>-->
|
<!-- <th>
|
||||||
|
<tbody *ngFor="let area of areas">
|
||||||
|
<tr>
|
||||||
|
<input type="checkbox" value="{{area.selected}}" id="ar" [(ngModel)]="area.selected">
|
||||||
|
<span>Цех: {{area.name}}</span>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</th> -->
|
||||||
|
|
||||||
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</p-table>
|
</p-table>
|
||||||
<div *ngIf="create; else change">
|
<div *ngIf="create; else change">
|
||||||
|
|||||||
@ -7,3 +7,42 @@ tr {
|
|||||||
width: calc(100% - 5px);
|
width: calc(100% - 5px);
|
||||||
table-layout: fixed;
|
table-layout: fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#chipInputField {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul.selectedAreasList {
|
||||||
|
padding: 0;
|
||||||
|
list-style-type: none;
|
||||||
|
display: inline-flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
overflow-wrap: normal;
|
||||||
|
|
||||||
|
li {
|
||||||
|
margin-left: 4px;
|
||||||
|
margin-top: 2px;
|
||||||
|
padding: 0 6px;
|
||||||
|
width: fit-content;
|
||||||
|
background-color: gray;
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
outline: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
button {
|
||||||
|
width: fit-content;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.ui-dropdown {
|
||||||
|
width: 200px;
|
||||||
|
height: 30px !important;
|
||||||
|
font-size:20px;
|
||||||
|
.p-dropdown {
|
||||||
|
height: 30px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { JsonrpcService, RpcService } from "src/app/services/jsonrpc.service";
|
import { JsonrpcService, RpcService } from "src/app/services/jsonrpc.service";
|
||||||
import { MessageService } from "primeng/api";
|
import { MessageService } from "primeng/api";
|
||||||
import { Terminals, Areas } from "src/app/interface/data";
|
import { Terminals, Areas, Divisions } from "src/app/interface/data";
|
||||||
import { ScrollPanelModule } from 'primeng/scrollpanel';
|
import { ScrollPanelModule } from 'primeng/scrollpanel';
|
||||||
import { ConfirmationService, FilterService, FilterMatchMode, SelectItem } from 'primeng/api';
|
import { ConfirmationService, FilterService, FilterMatchMode, SelectItem } from 'primeng/api';
|
||||||
|
|
||||||
@ -18,7 +18,9 @@ export class TerminalsComponent implements OnInit {
|
|||||||
public create = false;
|
public create = false;
|
||||||
public chooseName!: string;
|
public chooseName!: string;
|
||||||
public areas: Areas[] = [];
|
public areas: Areas[] = [];
|
||||||
public chooseArea: Array<string> = [];
|
public divisions: Divisions[] = [];
|
||||||
|
public selectedAreas: Areas[] = [];
|
||||||
|
public selectedDivision?: Divisions;
|
||||||
public matchModeOptions!: SelectItem[];
|
public matchModeOptions!: SelectItem[];
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +36,8 @@ export class TerminalsComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.choose) { this.getTerminals() };
|
if (this.choose) { this.getTerminals() };
|
||||||
|
this.getAreas();
|
||||||
|
this.getDivisions();
|
||||||
|
|
||||||
const customFilterName = "custom-contains";
|
const customFilterName = "custom-contains";
|
||||||
this.filterService.register(customFilterName, (value: any, filter: any): boolean => {
|
this.filterService.register(customFilterName, (value: any, filter: any): boolean => {
|
||||||
@ -90,8 +94,8 @@ export class TerminalsComponent implements OnInit {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAreas() {
|
getAreas() {
|
||||||
await this.jsonRpcService.rpc2({
|
this.jsonRpcService.rpc2({
|
||||||
method: 'getAreas',
|
method: 'getAreas',
|
||||||
params: {
|
params: {
|
||||||
"client_id": this.choose
|
"client_id": this.choose
|
||||||
@ -112,38 +116,82 @@ export class TerminalsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTerminal1(id: any, public_id: any, division_id: any, area_types: any) {
|
getDivisions() {
|
||||||
|
this.jsonRpcService.rpc2({
|
||||||
|
method: 'getDivisions',
|
||||||
|
params: {
|
||||||
|
"client_id": this.choose
|
||||||
|
}
|
||||||
|
}, RpcService.authService, false)
|
||||||
|
.subscribe({
|
||||||
|
next: (result) => {
|
||||||
|
let data = result.result;
|
||||||
|
this.divisions = data;
|
||||||
|
},
|
||||||
|
error: (err) => {
|
||||||
|
console.log('ERROR: ', err)
|
||||||
|
this.messageService.add({
|
||||||
|
severity: 'error',
|
||||||
|
summary: 'Произошла ошибка!',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateTerminal1(id: any, public_id: any, division_id: any, area_types: any[]) {
|
||||||
|
this.reset();
|
||||||
this.new_ter = false;
|
this.new_ter = false;
|
||||||
setTimeout(() => document.getElementsByTagName("input")[0].value = public_id, 100);
|
setTimeout(() => document.getElementsByTagName("input")[0].value = public_id, 100);
|
||||||
setTimeout(() => document.getElementsByTagName("input")[1].value = division_id, 100);
|
setTimeout(() => document.getElementsByTagName("input")[1].value = division_id, 100);
|
||||||
this.jsonRpcService.changeId = id;
|
this.jsonRpcService.changeId = id;
|
||||||
this.getAreas()
|
|
||||||
for (let i = 0; i < this.areas.length; i++) {
|
area_types.forEach(area_type => {
|
||||||
if (this.areas[i].name == area_types) {
|
const area = this.areas.find(area => area.id == area_type);
|
||||||
this.areas[i].selected = true
|
if (area) {
|
||||||
|
this.selectedAreas.push(area);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.selectedDivision = this.divisions.find(divivsion => divivsion.id == division_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
addAreaToSelected(event: any) {
|
||||||
|
const index = this.selectedAreas.findIndex(area => area.id == event.value.id);
|
||||||
|
if (index == -1) {
|
||||||
|
this.selectedAreas.push(event.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeAreaFromSelected(areaId: string) {
|
||||||
|
const index = this.selectedAreas.findIndex(area => area.id == areaId);
|
||||||
|
if (index > -1) {
|
||||||
|
this.selectedAreas.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.selectedAreas = [];
|
||||||
|
this.selectedDivision = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
updateTerminal() {
|
updateTerminal() {
|
||||||
this.chooseArea = [];
|
// this.chooseArea = [];
|
||||||
let address = document.getElementsByTagName("input")[1].value
|
let address = document.getElementsByTagName("input")[1].value
|
||||||
/* let areas = document.getElementsByTagName("input")[1].value*/
|
// let areas = document.getElementsByTagName("input")[1].value
|
||||||
let public_id = document.getElementsByTagName("input")[0].value
|
let public_id = document.getElementsByTagName("input")[0].value
|
||||||
for (let i = 0; i < this.areas.length; i++) {
|
for (let i = 0; i < this.areas.length; i++) {
|
||||||
|
|
||||||
if (this.areas[i].selected == true) {
|
if (this.areas[i].selected == true) {
|
||||||
this.chooseArea.push(this.areas[i].name)
|
// this.chooseArea.push(this.areas[i].name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.jsonRpcService.rpc2({
|
this.jsonRpcService.rpc2({
|
||||||
method: 'updateTerminal',
|
method: 'updateTerminal',
|
||||||
params: {
|
params: {
|
||||||
"client_id": this.choose,
|
"client_id": this.choose,
|
||||||
"terminal_id": this.jsonRpcService.changeId,
|
"terminal_id": this.jsonRpcService.changeId,
|
||||||
"address": address,
|
"address": this.selectedDivision?.id,
|
||||||
"areas": [1,2,3],
|
"areas": this.selectedAreas.map(area => area.id),
|
||||||
"public_id": public_id
|
"public_id": public_id
|
||||||
}
|
}
|
||||||
}, RpcService.authService, false)
|
}, RpcService.authService, false)
|
||||||
@ -191,21 +239,20 @@ export class TerminalsComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
registerTerminal() {
|
registerTerminal() {
|
||||||
|
this.reset();
|
||||||
this.new_ter = false;
|
this.new_ter = false;
|
||||||
this.create = true;
|
this.create = true;
|
||||||
this.getAreas()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerTerminal2() {
|
registerTerminal2() {
|
||||||
let public_id = document.getElementsByTagName("input")[0].value
|
let public_id = document.getElementsByTagName("input")[0].value;
|
||||||
let address = document.getElementsByTagName("input")[1].value
|
|
||||||
this.jsonRpcService.rpc2({
|
this.jsonRpcService.rpc2({
|
||||||
method: 'createTerminal',
|
method: 'createTerminal',
|
||||||
params: {
|
params: {
|
||||||
"client_id": this.jsonRpcService.ClientChoose,
|
"client_id": this.jsonRpcService.ClientChoose,
|
||||||
"public_id": public_id,
|
"public_id": public_id,
|
||||||
"address": address,
|
"address": this.selectedDivision?.id,
|
||||||
"areas": [1,2,3]
|
"areas": this.selectedAreas.map(area => area.id),
|
||||||
}
|
}
|
||||||
}, RpcService.authService, false)
|
}, RpcService.authService, false)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user