Compare commits

...

1 Commits

Author SHA1 Message Date
Vicent Llopis 8e2c192be6 import xls
gitea/salix/pipeline/head This commit looks good Details
2022-09-13 09:39:54 +02:00
4 changed files with 43567 additions and 3 deletions

View File

@ -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

View File

@ -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;

43553
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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": {