{"version":3,"file":"list-MmpC22HL.js","sources":["../../../app/frontend/entrypoints/controllers/erp/pallet/overview/list.ts"],"sourcesContent":["import jQuery from 'jquery/dist/jquery';\nimport Swal from 'sweetalert2';\nimport * as bootstrap from 'bootstrap'\n\nimport Utils from '../../../../utils'\nimport DefaultController from \"../../../defaultController\";\nimport WarehouseLocationPalletEntity from \"../../warehouse_location_pallet/entity\";\n\nexport default class ErpPalletList extends DefaultController {\n tableElem: any;\n datatable: any;\n editModal: bootstrap.Modal | undefined;\n stockDatatable: any = null\n\n async init() {\n this.entity = \"erp/warehouse_location_pallets\"\n this.tableElem = jQuery('.datatables-users')\n this.createTable();\n this.editModal = new bootstrap.Modal((document.querySelector(\"#editWarehouseLocationPallet\") as HTMLElement));\n await super.init();\n }\n\n getEntityData(elem: any) {\n return WarehouseLocationPalletEntity.getEntityData(elem)\n }\n\n bindListeners() {\n (document.querySelector(\"#editWarehouseLocationPalletForm\") as HTMLFormElement).addEventListener(\"submit\", async (e) => {\n e.preventDefault()\n const form = (document.querySelector(\"#editWarehouseLocationPalletForm\") as HTMLFormElement);\n\n const palletId = (form.querySelector(\"#erp_warehouse_location_pallet_id\") as HTMLInputElement)?.value;\n const warehouseId = (form.querySelector(\"#warehouse_location_pallet_warehouse_id option:checked\") as HTMLSelectElement)?.value;\n const warehouseLocationId = (form.querySelector(\"#warehouse_location_pallet_warehouse_location_id option:checked\") as HTMLSelectElement)?.value;\n const palletName = (form.querySelector(\"#erp_warehouse_location_pallet_name\") as HTMLInputElement)?.value;\n\n await Utils.showLoader();\n await Utils.entity.upsert({name: palletName, uuid: palletId, warehouse_location_id: warehouseLocationId}, 'erp/warehouse_location_pallets')\n form.reset()\n await Utils.hideLoader();\n this.editModal.hide();\n this.datatable.ajax.reload();\n });\n jQuery(\"#editWarehouseLocationPalletForm #warehouse_location_pallet_warehouse_id\").on(\"select2:select\", (e: any) => {\n jQuery(\"#editWarehouseLocationPalletForm #warehouse_location_pallet_warehouse_location_id\").val(\"\").trigger(\"change\");\n });\n this.tableElem.delegate(\".edit-record\", \"click\", async (e: any) => {\n const id = e.currentTarget.getAttribute(\"data-id\")\n const requestData = await Utils.entity.get(id, this.entity)\n if (requestData.status === 200) {\n const data = requestData.data[0]\n const form = (document.querySelector(\"#editWarehouseLocationPalletForm\") as HTMLFormElement);\n Object.keys(data).forEach((key) => {\n const elem = form.querySelector(`#erp_warehouse_location_pallet_${key}`) as HTMLInputElement | null\n if(elem && data[key]) {\n elem.value = data[key]\n }\n });\n const $newOptionWarehouseLocation = jQuery(\"\").val(data.warehouse_location.id).text(data.warehouse_location.name)\n jQuery(\"#editWarehouseLocationPalletForm #warehouse_location_pallet_warehouse_location_id\").append($newOptionWarehouseLocation).trigger('change');\n\n\n const $newOptionWarehouse = jQuery(\"\").val(data.warehouse_location.warehouse.id).text(data.warehouse_location.warehouse.name)\n jQuery(\"#editWarehouseLocationPalletForm #warehouse_location_pallet_warehouse_id\").append($newOptionWarehouse).trigger('change');\n\n // @ts-ignore\n this.editModal.show();\n const mapData: any = {}\n\n let html = '
Product | Serials |
---|---|
${s.product.name} | ${s.serial} |