У меня проблемы с обновлением devextreme-datagrid.Не могли бы вы помочь?
lineController.js
router.put("/:id", (req, res) => {
if (!ObjectId.isValid(req.params.id))
return res.status(400).send(`No record with given id : ${req.params.id}`);
console.log({
msg: "Line guncelleme işlemi",
gelenveri: req.body
});
var emp = {
bant: req.body.bant,
tarih: req.body.tarih,
isKazasi: req.body.isKazasi,
ramakKala: req.body.ramakKala,
tamirAdedi: req.body.tamirAdedi,
ikinciKaliteAdedi: req.body.ikinciKaliteAdedi,
sevkiyattanGelenHata: req.body.sevkiyattanGelenHata,
diger: req.body.diger,
koliCikisAdedi: req.body.koliCikisAdedi,
planlananAdet: req.body.planlananAdet,
sam: req.body.sam,
calisilanToplamSure: req.body.calisilanToplamSure,
bantKisiSayisi: req.body.bantKisiSayisi,
ilaveCalisilanDk: req.body.ilaveCalisilanDk,
iseGelmeyenlerinToplamSuresi: req.body.iseGelmeyenlerinToplamSuresi,
hataOrani:
((req.body.tamirAdedi +
req.body.ikinciKaliteAdedi +
req.body.sevkiyattanGelenHata +
req.body.diger) /
(req.body.koliCikisAdedi + req.body.ikinciKaliteAdedi)) *
100,
ikinciKaliteOrani:
(req.body.ikinciKaliteAdedi /
(req.body.koliCikisAdedi + req.body.ikinciKaliteAdedi)) *
100,
planlamayaUyum: (req.body.koliCikisAdedi / req.body.planlananAdet) * 100,
hatVerimliligi:
(req.body.koliCikisAdedi * req.body.sam) /
(req.body.calisilanToplamSure * req.body.bantKisiSayisi),
ilaveCalisma: (req.body.ilaveCalisilanDk * req.body.bantKisiSayisi) / 60,
devamsizlikYuzdesi:
(req.body.iseGelmeyenlerinToplamSuresi / (req.body.bantKisiSayisi * 9)) * 100
};
Line.findByIdAndUpdate(
req.params.id,
{ $set: emp },
{ new: true },
(err, doc) => {
if (!err) {
res.send(doc);
} else {
console.log(
"satır güncelleme hatası:" + JSON.stringify(err, undefined, 2)
);
}
}
);
});
line.service.ts
import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Line} from './line.model';
@Injectable({
providedIn: 'root'
})
export class LineService {
selectedLine: Line;
lines: Line[];
readonly baseURL = 'http://localhost:3000/lines';
constructor(private http: HttpClient) { }
postLine(emp: Line) {
return this.http.post(this.baseURL, emp);
}
getLineList() {
return this.http.get(this.baseURL);
}
// putLine(id, emp: Line) {
// return this.http.put(this.baseURL + `/${id}`, emp);
// }
putLine(emp: Line) {
return this.http.put(this.baseURL + `/${emp._id}`, emp);
}
deleteLine(_id: string) {
return this.http.delete(this.baseURL + `/${_id}`);
}
}
line.component.html
<dx-data-grid
id="gridContainer"
[dataSource]="lineService.lines"
title="SQDCM Veri Gİrişi"
keyExpr="_id"
[columnAutoWidth]="true"
[showBorders]="true"
(onRowInserted)="onEdit($event)"
(onRowUpdated)="onUpdate($event)"
(onRowRemoved)="onDelete($event)"
>
line.component.ts
onUpdate(event) {
console.log(event);
const merged = {_id: event.key, ...event.data};
this.lineService.putLine(merged).subscribe(res => { });
}
Когда я обновляю данные, они записывают их в консоль.
{ключ: "5c6ac45adb48bf3850eebc74", данные: {…}, компонент: наследник, элемент: dx-данные-grıd # gridContainer.dx-widget.dx-visibility-change-handler} Компонент: наследник {_events: {…}, _eventsStrategy: NgEventsStrategy, callBase: undefined, _ $ element: initRender (1), NAME: "dxDataGrid",…} Data: isKazasi: 8 proto : Элемент объекта: dx-data-grıd # gridContainer.dx-widget.dx-visibility-change-handler key: "5c6ac45adb48bf3850eebc74" proto :Объект
и выдает ошибку:
{msg: 'Line guncelleme işlemi', gelenveri: {_id: '5c6ac45adb48bf3850eebc74', isKazasi:8}} satır güncelleme hatası: {"message ":" Ошибка приведения к числу для значения \ "NaN \" по пути \ "devamsizlikYuzdesi \" "," name ":" CastError "," stringValue ":" \ "NaN \" "," kind ":" number"," value ": null," path ":" devamsizlikYuzdesi "}