import xls
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
e6410f6b13
commit
8e2c192be6
|
@ -15,7 +15,6 @@
|
||||||
label="File"
|
label="File"
|
||||||
ng-model="$ctrl.import.file"
|
ng-model="$ctrl.import.file"
|
||||||
on-change="$ctrl.onFileChange($event)"
|
on-change="$ctrl.onFileChange($event)"
|
||||||
accept="application/json"
|
|
||||||
required="true">
|
required="true">
|
||||||
<append>
|
<append>
|
||||||
<vn-icon vn-none
|
<vn-icon vn-none
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import ngModule from '../../module';
|
import ngModule from '../../module';
|
||||||
import Section from 'salix/components/section';
|
import Section from 'salix/components/section';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
const XLSX = require('xlsx');
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
|
@ -17,14 +18,24 @@ class Controller extends Section {
|
||||||
const file = input.files[0];
|
const file = input.files[0];
|
||||||
|
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = event =>
|
reader.readAsBinaryString(file);
|
||||||
|
reader.onload = event => {
|
||||||
|
// let binaryData = event.target.result;
|
||||||
this.fillData(event.target.result);
|
this.fillData(event.target.result);
|
||||||
|
};
|
||||||
reader.readAsText(file, 'UTF-8');
|
reader.readAsText(file, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
fillData(raw) {
|
fillData(raw) {
|
||||||
const data = JSON.parse(raw);
|
const data = JSON.parse(raw);
|
||||||
const [invoice] = data.invoices;
|
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.$.$applyAsync(() => {
|
||||||
this.import.observation = invoice.tx_awb;
|
this.import.observation = invoice.tx_awb;
|
||||||
|
@ -56,7 +67,7 @@ class Controller extends Section {
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchBuys(buys) {
|
fetchBuys(buys) {
|
||||||
const params = {buys};
|
const params = {buys: buys.slice(0, 5)};
|
||||||
const query = `Entries/${this.$params.id}/importBuysPreview`;
|
const query = `Entries/${this.$params.id}/importBuysPreview`;
|
||||||
this.$http.get(query, {params}).then(res => {
|
this.$http.get(query, {params}).then(res => {
|
||||||
this.import.buys = res.data;
|
this.import.buys = res.data;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -45,6 +45,7 @@
|
||||||
"uuid": "^3.3.3",
|
"uuid": "^3.3.3",
|
||||||
"vn-loopback": "file:./loopback",
|
"vn-loopback": "file:./loopback",
|
||||||
"vn-print": "file:./print",
|
"vn-print": "file:./print",
|
||||||
|
"xlsx": "^0.18.5",
|
||||||
"xml2js": "^0.4.23"
|
"xml2js": "^0.4.23"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
Loading…
Reference in New Issue