Compare commits
1 Commits
dev
...
entry.buy_
Author | SHA1 | Date |
---|---|---|
Vicent Llopis | 8e2c192be6 |
|
@ -15,7 +15,6 @@
|
|||
label="File"
|
||||
ng-model="$ctrl.import.file"
|
||||
on-change="$ctrl.onFileChange($event)"
|
||||
accept="application/json"
|
||||
required="true">
|
||||
<append>
|
||||
<vn-icon vn-none
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import ngModule from '../../module';
|
||||
import Section from 'salix/components/section';
|
||||
import './style.scss';
|
||||
const XLSX = require('xlsx');
|
||||
|
||||
class Controller extends Section {
|
||||
constructor($element, $) {
|
||||
|
@ -17,14 +18,24 @@ class Controller extends Section {
|
|||
const file = input.files[0];
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = event =>
|
||||
reader.readAsBinaryString(file);
|
||||
reader.onload = event => {
|
||||
// let binaryData = event.target.result;
|
||||
this.fillData(event.target.result);
|
||||
};
|
||||
reader.readAsText(file, 'UTF-8');
|
||||
}
|
||||
|
||||
fillData(raw) {
|
||||
const data = JSON.parse(raw);
|
||||
const [invoice] = data.invoices;
|
||||
console.log(data, invoice);
|
||||
|
||||
// let workbook = XLSX.read(raw, {type: 'binary'});
|
||||
// workbook.SheetNames.forEach(sheet => {
|
||||
// const data = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]);
|
||||
// console.log(data);
|
||||
// });
|
||||
|
||||
this.$.$applyAsync(() => {
|
||||
this.import.observation = invoice.tx_awb;
|
||||
|
@ -56,7 +67,7 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
fetchBuys(buys) {
|
||||
const params = {buys};
|
||||
const params = {buys: buys.slice(0, 5)};
|
||||
const query = `Entries/${this.$params.id}/importBuysPreview`;
|
||||
this.$http.get(query, {params}).then(res => {
|
||||
this.import.buys = res.data;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -45,6 +45,7 @@
|
|||
"uuid": "^3.3.3",
|
||||
"vn-loopback": "file:./loopback",
|
||||
"vn-print": "file:./print",
|
||||
"xlsx": "^0.18.5",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in New Issue