Button
Last updated
Last updated
controlType button olduğunda tıklandığında yapılabilecek işlemin scripti yazılabillir. Rowaction eklenebilir.
{
"id": "BarcodeBtn",
"xSpan": 1,
"controlType": "button",
"buttonType": "icon",
"label": "Barcode Read",
"svgIcon": "barcode-scan",
"disabled": false,
"color": "accent",
"rowAction": {
"requirements": [],
"name": "",
"icon": "",
"startupMsg": "Are you sure?",
"successMsg": "Succsessfully.",
"failMsg": "Failed!",
"queue": [
{
"name": "script",
"script": "(async () => {\n try {\n let data = this.parent.recordService.formGroup.getRawValue();\n let insertGrid = this.parent.recordService.grids['insert-quick-invoice']\n .grid;\n\n console.log(data.TEXT_BARCODE.length, 'data.TEXT_BARCODE.lenght');\n let scaleBarcode = 0;\n let barcodQuantity = 0;\n if (\n (data.TEXT_BARCODE.length == 12 || data.TEXT_BARCODE.length == 13) &&\n data.TEXT_BARCODE.startsWith(28)\n ) {\n scaleBarcode = 1;\n }\n const newStock = await angus.api\n .select({\n Object: 'QA_STOCK_STOCKBARCODE',\n Select: [\n 'BARCODE',\n 'STOCKID',\n 'STOCKNAME',\n 'QUANTITY',\n 'UNITNAME',\n 'VAT',\n 'UNITPRICE',\n ],\n Where: [\n {\n Column: 'BARCODE',\n Operator: '=',\n Value: scaleBarcode\n ? data.TEXT_BARCODE.substring(0, 7)\n : data.TEXT_BARCODE,\n },\n ],\n Paging: {\n Current: 1,\n ItemsPerPage: 1,\n },\n })\n .then((resp) => {\n return resp.ResultSets?.[0]?.[0];\n });\n console.log('newStock', newStock);\n\n if (!newStock) {\n let msg = angus.languageService.staticTranslator.translate(\n 'Barcode not found. Would you like to assign this barcode?'\n );\n let confirmResp = await this.parent.recordService.component.angusDialog\n .confirm(msg)\n .toPromise();\n if (confirmResp) {\n const newRecordData = await this.parent.recordService.component.popupService\n .openRecord(\n 'quick-invoice-add-stock-for-barcode',\n null,\n {\n BARCODE: data.TEXT_BARCODE,\n },\n null,\n 'full'\n )\n .afterClosed()\n .toPromise();\n console.log('newRecordData', newRecordData);\n }\n this.parent.recordService.formGroup.controls.TEXT_BARCODE.setValue(null);\n return;\n }\n let updated = false;\n insertGrid.agGrid.api.forEachNode((insertRowNode) => {\n if (!updated && newStock.STOCKNAME === insertRowNode.data.STOCKID_NAME) {\n barcodQuantity = parseInt(data.TEXT_BARCODE.substr(7, 5)) / 1000;\n console.log('barcodQuantity', barcodQuantity);\n debugger;\n if (scaleBarcode) {\n insertGrid.changeCellValue(\n insertRowNode,\n 'InvoicedQuantity_Value',\n (insertRowNode.data.InvoicedQuantity_Value || 0) + barcodQuantity\n );\n } else {\n insertGrid.changeCellValue(\n insertRowNode,\n 'InvoicedQuantity_Value',\n (insertRowNode.data.InvoicedQuantity_Value || 0) + 1\n );\n }\n insertRowNode.setData(insertRowNode.data);\n insertGrid._qty(insertRowNode);\n this.parent.recordService.formGroup.controls.TEXT_BARCODE.setValue(\n null\n );\n updated = true;\n }\n });\n //stok ilk okutulduğunda çalışacak kod\n if (!updated) {\n let node = insertGrid.addNewRow();\n insertGrid.changeCellValue(node, 'STOCKID', newStock.STOCKID);\n insertGrid.changeCellValue(node, 'STOCKID_NAME', newStock.STOCKNAME);\n insertGrid.changeCellValue(node, 'STOCKID_UNITNAME', newStock.UNITNAME);\n insertGrid.changeCellValue(node, 'UNITPRICE', newStock.UNITPRICE);\n insertGrid.changeCellValue(\n node,\n 'EXCLUDEVATUNITPRICE',\n newStock.UNITPRICE / (1 + newStock.VAT / 100)\n );\n\n barcodQuantity = parseInt(data.TEXT_BARCODE.substr(7, 5)) / 1000;\n debugger;\n console.log(barcodQuantity, 'aaaaa');\n if (scaleBarcode) {\n insertGrid.changeCellValue(\n node,\n 'InvoicedQuantity_Value',\n barcodQuantity\n );\n } else {\n insertGrid.changeCellValue(node, 'InvoicedQuantity_Value', 1);\n }\n insertGrid.changeCellValue(node, 'TaxPercent', newStock.VAT);\n node.setData(node.data);\n insertGrid._qty(node);\n this.parent.recordService.formGroup.controls.TEXT_BARCODE.setValue(null);\n }\n\n scaleBarcode = 0;\n } catch (e) {\n this.parent.recordService.component.angusDialog.error(e);\n }\n})();"
}
]
}
}