SHARE
TWEET

Untitled

a guest Dec 11th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. componentDidMount() {
  2.     this.loadData()
  3. }
  4.  
  5. loadData() {
  6.     let data = [
  7.         {
  8.             categories: "Food"
  9.             created_at: "2019-12-01 06:54:01"
  10.             deleted_at: null
  11.             desc: "Karage Gurih"
  12.             id: 42
  13.             inf_categories_id: "5"
  14.             inf_modifier_set_id: null
  15.             multiple_price: null
  16.             name: "Karage"
  17.             sku: null
  18.             total: 20000
  19.         },
  20.         {
  21.             categories: "Food"
  22.             created_at: "2019-12-01 06:54:01"
  23.             deleted_at: null
  24.             desc: "Karage Gurih"
  25.             id: 41
  26.             inf_categories_id: "5"
  27.             inf_modifier_set_id: null
  28.             multiple_price: null
  29.             name: "Karage"
  30.             sku: null
  31.             total: 20000
  32.         }
  33.     ]
  34.  
  35.     this.setState({
  36.         data: data
  37.     })
  38. }
  39.  
  40.  async printData() {
  41.     let data = this.state.data
  42.     for(let i=0; i<data.length; i++){
  43.         await BluetoothEscposPrinter.printerLeftSpace(0);
  44.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  45.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  46.         ["Categories", data[i].categories], { fonttype: 1 });
  47.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  48.  
  49.         await BluetoothEscposPrinter.printerLeftSpace(0);
  50.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  51.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  52.         ["Create At", data[i].created_at], { fonttype: 1 });
  53.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  54.  
  55.         await BluetoothEscposPrinter.printerLeftSpace(0);
  56.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  57.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  58.         ["Deleted At", data[i].deleted_at], { fonttype: 1 });
  59.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  60.  
  61.         await BluetoothEscposPrinter.printerLeftSpace(0);
  62.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  63.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  64.         ["Desc", data[i].desc], { fonttype: 1 });
  65.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  66.  
  67.         await BluetoothEscposPrinter.printerLeftSpace(0);
  68.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  69.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  70.         ["ID", data[i].id], { fonttype: 1 });
  71.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  72.  
  73.         await BluetoothEscposPrinter.printerLeftSpace(0);
  74.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  75.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  76.         ["Inf Categories ID", data[i].inf_categories_id], { fonttype: 1 });
  77.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  78.        
  79.         await BluetoothEscposPrinter.printerLeftSpace(0);
  80.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  81.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  82.         ["Inf Modifier Set ID", data[i].inf_modifier_set_id], { fonttype: 1 });
  83.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  84.  
  85.         await BluetoothEscposPrinter.printerLeftSpace(0);
  86.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  87.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  88.         ["Multiple Price", data[i].multiple_price], { fonttype: 1 });
  89.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  90.  
  91.         await BluetoothEscposPrinter.printerLeftSpace(0);
  92.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  93.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  94.         ["Name", data[i].name], { fonttype: 1 });
  95.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  96.  
  97.         await BluetoothEscposPrinter.printerLeftSpace(0);
  98.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  99.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  100.         ["SKU", data[i].sku], { fonttype: 1 });
  101.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  102.  
  103.         await BluetoothEscposPrinter.printerLeftSpace(0);
  104.         await BluetoothEscposPrinter.printColumn([BluetoothEscposPrinter.width58 / 8 / 3, BluetoothEscposPrinter.width58 / 8 / 3 - 1, BluetoothEscposPrinter.width58 / 8 / 3 - 1],
  105.         [BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER, BluetoothEscposPrinter.ALIGN.CENTER],
  106.         ["Total", data[i].total], { fonttype: 1 });
  107.         await BluetoothEscposPrinter.printText("\r\n\r\n\r\n", {});
  108.     }
  109. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top