|
@@ -7,7 +7,15 @@
|
|
:on-change="importClick" :show-file-list="false"
|
|
:on-change="importClick" :show-file-list="false"
|
|
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
|
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
|
:auto-upload="false">
|
|
:auto-upload="false">
|
|
- <ws-button type="primary">导入</ws-button>
|
|
|
|
|
|
+ <ws-button type="primary">导入(销售)</ws-button>
|
|
|
|
+ </el-upload>
|
|
|
|
+ </template>
|
|
|
|
+ <template slot="left">
|
|
|
|
+ <el-upload style="margin-left: 8px;" class="upload-demo inline-block margin-right-10" action=""
|
|
|
|
+ :on-change="importClickYk" :show-file-list="false"
|
|
|
|
+ accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
|
|
|
+ :auto-upload="false">
|
|
|
|
+ <ws-button type="primary">导入(移库)</ws-button>
|
|
</el-upload>
|
|
</el-upload>
|
|
</template>
|
|
</template>
|
|
<!-- <template slot="left"> </template> -->
|
|
<!-- <template slot="left"> </template> -->
|
|
@@ -141,6 +149,7 @@
|
|
getweighing,
|
|
getweighing,
|
|
changeNo,
|
|
changeNo,
|
|
importWordSale,
|
|
importWordSale,
|
|
|
|
+ importWordYk,
|
|
goBack
|
|
goBack
|
|
} from '@/model/outboundManagement/index'
|
|
} from '@/model/outboundManagement/index'
|
|
import {
|
|
import {
|
|
@@ -299,6 +308,108 @@
|
|
reader.readAsBinaryString(f);
|
|
reader.readAsBinaryString(f);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+ importClickYk(file, fileList) {
|
|
|
|
+ this.fileTemp = file.raw
|
|
|
|
+ let fileName = file.raw.name
|
|
|
|
+ let fileType = fileName.substring(fileName.lastIndexOf('.') + 1)
|
|
|
|
+ // 判断上传文件格式
|
|
|
|
+ if (this.fileTemp) {
|
|
|
|
+ if (fileType == 'xlsx' || fileType == 'xls') {
|
|
|
|
+ this.importfYk(this.fileTemp)
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ type: 'warning',
|
|
|
|
+ message: '附件格式错误,请删除后重新上传!',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.$message({
|
|
|
|
+ type: 'warning',
|
|
|
|
+ message: '请上传附件!',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ importfYk(obj) {
|
|
|
|
+ this.excelFreightspace = []
|
|
|
|
+ // this.dialogVisible = true;
|
|
|
|
+ let _this = this;
|
|
|
|
+ let inputDOM = this.$refs.inputer; // 通过DOM取文件数据
|
|
|
|
+ this.file = event.currentTarget.files[0];
|
|
|
|
+ var rABS = false; //是否将文件读取为二进制字符串
|
|
|
|
+ var f = this.file;
|
|
|
|
+ var reader = new FileReader();
|
|
|
|
+ //if (!FileReader.prototype.readAsBinaryString) {
|
|
|
|
+ FileReader.prototype.readAsBinaryString = function(f) {
|
|
|
|
+ var binary = '';
|
|
|
|
+ var rABS = false; //是否将文件读取为二进制字符串
|
|
|
|
+ var pt = this;
|
|
|
|
+ var wb; //读取完成的数据
|
|
|
|
+ var outdata;
|
|
|
|
+ var reader = new FileReader();
|
|
|
|
+ reader.onload = function(e) {
|
|
|
|
+ var bytes = new Uint8Array(reader.result);
|
|
|
|
+ var length = bytes.byteLength;
|
|
|
|
+ for (var i = 0; i < length; i++) {
|
|
|
|
+ binary += String.fromCharCode(bytes[i]);
|
|
|
|
+ }
|
|
|
|
+ var XLSX = require('xlsx');
|
|
|
|
+ if (rABS) {
|
|
|
|
+ wb = XLSX.read(btoa(fixdata(binary)), { //手动转化
|
|
|
|
+ type: 'base64',
|
|
|
|
+ cellDates: true
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ wb = XLSX.read(binary, {
|
|
|
|
+ type: 'binary'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ // outdata就是你想要的东西 excel导入的数据
|
|
|
|
+ outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
|
|
|
|
+ // excel 数据再处理
|
|
|
|
+ let arr = []
|
|
|
|
+ outdata.map(v => {
|
|
|
|
+ // let jsonString = JSON.stringify(v).replace(/\*/g, '').replace(/\s/ig,'');
|
|
|
|
+ let jsonString = JSON.stringify(v).replace(/\//g, '').replace(/\s/ig, '');
|
|
|
|
+ v = JSON.parse(jsonString);
|
|
|
|
+ let obj = {}
|
|
|
|
+ //xxx代表列名
|
|
|
|
+ obj.number = v.业务编号
|
|
|
|
+ obj.inOutTaskNo = v.出库任务编号
|
|
|
|
+ obj.outType = v.运输方式
|
|
|
|
+ obj.carNumber = v.车牌号
|
|
|
|
+ obj.grossWeight = v.毛重
|
|
|
|
+ obj.tare = v.皮重
|
|
|
|
+ obj.netWeight = v.净重
|
|
|
|
+ obj.grossDate = _this.formatDate(v.出库日期, '-')
|
|
|
|
+ _this.excelFreightspace.push(obj)
|
|
|
|
+ })
|
|
|
|
+ if (_this.excelFreightspace) {
|
|
|
|
+ importWordYk({
|
|
|
|
+ warehouseName: _this.warehouseName,
|
|
|
|
+ weighingManagementList: _this.excelFreightspace
|
|
|
|
+ }).toPromise()
|
|
|
|
+ .then((response) => {
|
|
|
|
+ if (response == 'ok') {
|
|
|
|
+ this.$notify({
|
|
|
|
+ title: '成功',
|
|
|
|
+ message: '导入成功',
|
|
|
|
+ type: 'success'
|
|
|
|
+ });
|
|
|
|
+ _this.getList()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ reader.readAsArrayBuffer(f);
|
|
|
|
+ }
|
|
|
|
+ if (rABS) {
|
|
|
|
+ reader.readAsArrayBuffer(f);
|
|
|
|
+ } else {
|
|
|
|
+ reader.readAsBinaryString(f);
|
|
|
|
+ }
|
|
|
|
+
|
|
},
|
|
},
|
|
formatDate(numb, format) {
|
|
formatDate(numb, format) {
|
|
const old = numb - 1;
|
|
const old = numb - 1;
|