|
@ -5,12 +5,96 @@ |
|
|
<el-col> |
|
|
<el-col> |
|
|
<div class="inputClass uploadClass"> |
|
|
<div class="inputClass uploadClass"> |
|
|
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload" |
|
|
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload" |
|
|
:http-request="successSubmit1" accept=".xls,.xlsx,.csv"> |
|
|
:http-request="async opts => await successSubmit1(opts, 'a1')" accept=".xls,.xlsx,.csv"> |
|
|
<el-button type="success"> |
|
|
<el-button type="success"> |
|
|
<el-icon> |
|
|
<el-icon> |
|
|
<Upload /> |
|
|
<Upload /> |
|
|
</el-icon> |
|
|
</el-icon> |
|
|
<span>导入A表</span> |
|
|
<el-tooltip> |
|
|
|
|
|
<template #content> |
|
|
|
|
|
<div> |
|
|
|
|
|
<el-image style="width: 100px; height: 100px" :preview-src-list="[url1]" :src="url1" |
|
|
|
|
|
fit="scale-down" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
<span>导入A1表</span> |
|
|
|
|
|
</el-tooltip> |
|
|
|
|
|
</el-button> |
|
|
|
|
|
</el-upload> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="inputClass uploadClass"> |
|
|
|
|
|
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload" |
|
|
|
|
|
:http-request="async opts => await successSubmit1(opts, 'a2')" accept=".xls,.xlsx,.csv"> |
|
|
|
|
|
<el-button type="success"> |
|
|
|
|
|
<el-icon> |
|
|
|
|
|
<Upload /> |
|
|
|
|
|
</el-icon> |
|
|
|
|
|
<el-tooltip> |
|
|
|
|
|
<template #content> |
|
|
|
|
|
<div> |
|
|
|
|
|
<el-image style="width: 100px; height: 100px" :preview-src-list="[url2]" :src="url2" |
|
|
|
|
|
fit="scale-down" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
<span>导入A2表</span> |
|
|
|
|
|
</el-tooltip> |
|
|
|
|
|
</el-button> |
|
|
|
|
|
</el-upload> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="inputClass uploadClass"> |
|
|
|
|
|
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload" |
|
|
|
|
|
:http-request="async opts => await successSubmit1(opts, 'a3')" accept=".xls,.xlsx,.csv"> |
|
|
|
|
|
<el-button type="success"> |
|
|
|
|
|
<el-icon> |
|
|
|
|
|
<Upload /> |
|
|
|
|
|
</el-icon> |
|
|
|
|
|
<el-tooltip> |
|
|
|
|
|
<template #content> |
|
|
|
|
|
<div> |
|
|
|
|
|
<el-image style="width: 100px; height: 100px" :preview-src-list="[url3]" :src="url3" |
|
|
|
|
|
fit="scale-down" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
<span>导入A3表</span> |
|
|
|
|
|
</el-tooltip> |
|
|
|
|
|
</el-button> |
|
|
|
|
|
</el-upload> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="inputClass uploadClass"> |
|
|
|
|
|
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload" |
|
|
|
|
|
:http-request="async opts => await successSubmit1(opts, 'a4')" accept=".xls,.xlsx,.csv"> |
|
|
|
|
|
<el-button type="success"> |
|
|
|
|
|
<el-icon> |
|
|
|
|
|
<Upload /> |
|
|
|
|
|
</el-icon> |
|
|
|
|
|
<el-tooltip> |
|
|
|
|
|
<template #content> |
|
|
|
|
|
<div> |
|
|
|
|
|
<el-image style="width: 100px; height: 100px" :preview-src-list="[url4]" :src="url4" |
|
|
|
|
|
fit="scale-down" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
<span>导入A4表</span> |
|
|
|
|
|
</el-tooltip> |
|
|
|
|
|
</el-button> |
|
|
|
|
|
</el-upload> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div class="inputClass uploadClass"> |
|
|
|
|
|
<el-upload :show-file-list="false" v-model="fileOriData1" :before-upload="beforeAvatarUpload" |
|
|
|
|
|
:http-request="async opts => await successSubmit1(opts, 'a5')" accept=".xls,.xlsx,.csv"> |
|
|
|
|
|
<el-button type="success"> |
|
|
|
|
|
<el-icon> |
|
|
|
|
|
<Upload /> |
|
|
|
|
|
</el-icon> |
|
|
|
|
|
<el-tooltip> |
|
|
|
|
|
<template #content> |
|
|
|
|
|
<div> |
|
|
|
|
|
<el-image style="width: 100px; height: 100px" :preview-src-list="[url5]" :src="url5" |
|
|
|
|
|
fit="scale-down" /> |
|
|
|
|
|
</div> |
|
|
|
|
|
</template> |
|
|
|
|
|
<span>导入A5表</span> |
|
|
|
|
|
</el-tooltip> |
|
|
</el-button> |
|
|
</el-button> |
|
|
</el-upload> |
|
|
</el-upload> |
|
|
</div> |
|
|
</div> |
|
@ -37,6 +121,12 @@ |
|
|
</el-icon> |
|
|
</el-icon> |
|
|
<span>导出</span> |
|
|
<span>导出</span> |
|
|
</el-button> |
|
|
</el-button> |
|
|
|
|
|
<el-button type="danger" @click="refrash"> |
|
|
|
|
|
<el-icon> |
|
|
|
|
|
<Refresh /> |
|
|
|
|
|
</el-icon> |
|
|
|
|
|
<span>清空数据</span> |
|
|
|
|
|
</el-button> |
|
|
</el-col> |
|
|
</el-col> |
|
|
</el-row> |
|
|
</el-row> |
|
|
</div> |
|
|
</div> |
|
@ -48,8 +138,13 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import _, { min } from 'lodash' |
|
|
import _ from 'lodash' |
|
|
import dayjs from 'dayjs' |
|
|
import dayjs from 'dayjs' |
|
|
|
|
|
import urla1 from "../assets/images/a1.png" |
|
|
|
|
|
import urla2 from "../assets/images/a2.png" |
|
|
|
|
|
import urla3 from "../assets/images/a3.png" |
|
|
|
|
|
import urla4 from "../assets/images/a4.png" |
|
|
|
|
|
import urla5 from "../assets/images/a5.png" |
|
|
import * as XLSX from 'xlsx'; |
|
|
import * as XLSX from 'xlsx'; |
|
|
import ExcelJS from "exceljs"; |
|
|
import ExcelJS from "exceljs"; |
|
|
import tablecomponent from "../components/tablecomponent.vue" |
|
|
import tablecomponent from "../components/tablecomponent.vue" |
|
@ -62,17 +157,22 @@ export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
_: _, |
|
|
_: _, |
|
|
|
|
|
url1: urla1, |
|
|
|
|
|
url2: urla2, |
|
|
|
|
|
url3: urla3, |
|
|
|
|
|
url4: urla4, |
|
|
|
|
|
url5: urla5, |
|
|
dayjs: dayjs, |
|
|
dayjs: dayjs, |
|
|
tableHeader: [], |
|
|
tableHeader: [], |
|
|
fileOriData1: null, |
|
|
fileOriData1: null, |
|
|
fileData1: [], |
|
|
fileData1: [], |
|
|
fileData1Header: {}, |
|
|
|
|
|
fileOriData2: null, |
|
|
fileOriData2: null, |
|
|
fileData2: [], |
|
|
fileData2: [], |
|
|
tableData: [], |
|
|
tableData: [], |
|
|
loading: false, |
|
|
loading: false, |
|
|
chimaList: [], |
|
|
chimaList: [], |
|
|
otherChangeList: [], |
|
|
otherChangeList: [], |
|
|
|
|
|
atype: "", |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
@ -92,7 +192,7 @@ export default { |
|
|
return true |
|
|
return true |
|
|
}, |
|
|
}, |
|
|
//表格A增加数据 |
|
|
//表格A增加数据 |
|
|
async successSubmit1(opts) { |
|
|
async successSubmit1(opts, fun) { |
|
|
let that = this |
|
|
let that = this |
|
|
let file = opts.file |
|
|
let file = opts.file |
|
|
this.fileDealData = [] |
|
|
this.fileDealData = [] |
|
@ -104,6 +204,22 @@ export default { |
|
|
// 获取第一个工作表的名称 |
|
|
// 获取第一个工作表的名称 |
|
|
let sheetName = workbook.SheetNames[0]; |
|
|
let sheetName = workbook.SheetNames[0]; |
|
|
let sheetData = workbook.Sheets[sheetName]; |
|
|
let sheetData = workbook.Sheets[sheetName]; |
|
|
|
|
|
that.atype = fun |
|
|
|
|
|
that.chimaList = [] |
|
|
|
|
|
that.otherChangeList = [] |
|
|
|
|
|
that[fun](sheetData) |
|
|
|
|
|
} |
|
|
|
|
|
fileReader.onerror = function (error) { |
|
|
|
|
|
ElMessage({ |
|
|
|
|
|
message: `Error reading file:, ${error}`, |
|
|
|
|
|
type: 'error', |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
fileReader.readAsArrayBuffer(file) |
|
|
|
|
|
}, |
|
|
|
|
|
// 处理第一类表 |
|
|
|
|
|
async a1(sheetData) { |
|
|
|
|
|
let that = this |
|
|
let range = XLSX.utils.decode_range(sheetData['!ref']); |
|
|
let range = XLSX.utils.decode_range(sheetData['!ref']); |
|
|
let chima = _.sortBy(_.filter(sheetData["!merges"], o => o.s.r === 2 && o.e.r === 2), o => o.s.c) |
|
|
let chima = _.sortBy(_.filter(sheetData["!merges"], o => o.s.r === 2 && o.e.r === 2), o => o.s.c) |
|
|
let colRange = [_.get(chima[0], 's.c', 0), _.get(chima[0], 'e.c', 0)] |
|
|
let colRange = [_.get(chima[0], 's.c', 0), _.get(chima[0], 'e.c', 0)] |
|
@ -169,20 +285,230 @@ export default { |
|
|
} |
|
|
} |
|
|
allCells.push(newRow); |
|
|
allCells.push(newRow); |
|
|
} |
|
|
} |
|
|
that.fileData1Header = { ...allCells[3] } |
|
|
|
|
|
ElMessage({ |
|
|
ElMessage({ |
|
|
message: `导入成功,请导入下一个文件`, |
|
|
message: `导入成功,请导入下一个文件`, |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
|
|
|
duration: 500, |
|
|
}) |
|
|
}) |
|
|
that.fileData1 = allCells |
|
|
that.fileData1 = allCells |
|
|
|
|
|
}, |
|
|
|
|
|
// 处理第二类表 |
|
|
|
|
|
async a2(sheetData) { |
|
|
|
|
|
let that = this |
|
|
|
|
|
let range = XLSX.utils.decode_range(sheetData['!ref']); |
|
|
|
|
|
let chima = _.sortBy(_.filter(sheetData["!merges"], o => o.s.r === 2 && o.e.r === 2), o => o.s.c) |
|
|
|
|
|
let colRange = [_.get(chima[0], 's.c', 0), _.get(chima[0], 'e.c', 0)] |
|
|
|
|
|
// 获取合并单元格的范围信息 |
|
|
|
|
|
let mergeRanges = sheetData['!merges']; |
|
|
|
|
|
if (!mergeRanges) { |
|
|
|
|
|
mergeRanges = []; |
|
|
|
|
|
} |
|
|
|
|
|
let allCells = []; |
|
|
|
|
|
for (let rowIndex = range.s.r; rowIndex <= range.e.r; ++rowIndex) { |
|
|
|
|
|
let newRow = {}; |
|
|
|
|
|
for (let colIndex = range.s.c; colIndex <= range.e.c; ++colIndex) { |
|
|
|
|
|
let cell = sheetData[XLSX.utils.encode_cell({ |
|
|
|
|
|
c: colIndex, |
|
|
|
|
|
r: rowIndex |
|
|
|
|
|
})]; |
|
|
|
|
|
let cellContent = ''; |
|
|
|
|
|
// 获取尺码 |
|
|
|
|
|
if (rowIndex === 3 && colIndex >= colRange[0] && colIndex <= colRange[1]) { |
|
|
|
|
|
that.chimaList.push({ |
|
|
|
|
|
key: String.fromCharCode("a".charCodeAt() + colIndex), |
|
|
|
|
|
value: XLSX.utils.format_cell(cell) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
// 获取其他修改 |
|
|
|
|
|
if (rowIndex === 2) { |
|
|
|
|
|
that.otherChangeList.push({ |
|
|
|
|
|
key: String.fromCharCode("a".charCodeAt() + colIndex), |
|
|
|
|
|
value: XLSX.utils.format_cell(cell) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
if (cell && cell.t) { |
|
|
|
|
|
cellContent = XLSX.utils.format_cell(cell); |
|
|
|
|
|
} |
|
|
|
|
|
// 检查当前单元格是否在合并单元格范围内 |
|
|
|
|
|
let isMergedCell = false; |
|
|
|
|
|
for (let i = 0; i < mergeRanges.length; i++) { |
|
|
|
|
|
let mergeRange = mergeRanges[i]; |
|
|
|
|
|
if (rowIndex >= mergeRange.s.r && rowIndex <= mergeRange.e.r && |
|
|
|
|
|
colIndex >= mergeRange.s.c && colIndex <= mergeRange.e.c) { |
|
|
|
|
|
isMergedCell = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (isMergedCell) { |
|
|
|
|
|
// 如果是合并单元格,找到对应的合并单元格的左上角单元格内容作为填充内容 |
|
|
|
|
|
for (let i = 0; i < mergeRanges.length; i++) { |
|
|
|
|
|
let mergeRange = mergeRanges[i]; |
|
|
|
|
|
if (rowIndex >= mergeRange.s.r && rowIndex <= mergeRange.e.r && |
|
|
|
|
|
colIndex >= mergeRange.s.c && colIndex <= mergeRange.e.c) { |
|
|
|
|
|
let topLeftCell = sheetData[XLSX.utils.encode_cell({ |
|
|
|
|
|
c: mergeRange.s.c, |
|
|
|
|
|
r: mergeRange.s.r |
|
|
|
|
|
})]; |
|
|
|
|
|
if (topLeftCell && topLeftCell.t) { |
|
|
|
|
|
cellContent = XLSX.utils.format_cell(topLeftCell); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
newRow[String.fromCharCode("a".charCodeAt() + colIndex)] = cellContent; |
|
|
|
|
|
} |
|
|
|
|
|
allCells.push(newRow); |
|
|
} |
|
|
} |
|
|
fileReader.onerror = function (error) { |
|
|
|
|
|
ElMessage({ |
|
|
ElMessage({ |
|
|
message: `Error reading file:, ${error}`, |
|
|
message: `导入成功,请导入下一个文件`, |
|
|
type: 'error', |
|
|
type: 'success', |
|
|
|
|
|
duration: 500, |
|
|
}) |
|
|
}) |
|
|
|
|
|
that.fileData1 = allCells |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 处理第三类表 |
|
|
|
|
|
async a3(sheetData) { |
|
|
|
|
|
let that = this |
|
|
|
|
|
let range = XLSX.utils.decode_range(sheetData['!ref']); |
|
|
|
|
|
let chima = _.sortBy(_.filter(sheetData["!merges"], o => o.s.r === 2 && o.e.r === 2), o => o.s.c) |
|
|
|
|
|
let colRange = [_.get(chima[0], 's.c', 0), _.get(chima[0], 'e.c', 0)] |
|
|
|
|
|
// 获取合并单元格的范围信息 |
|
|
|
|
|
let mergeRanges = sheetData['!merges']; |
|
|
|
|
|
if (!mergeRanges) { |
|
|
|
|
|
mergeRanges = []; |
|
|
} |
|
|
} |
|
|
fileReader.readAsArrayBuffer(file) |
|
|
let allCells = []; |
|
|
|
|
|
for (let rowIndex = range.s.r; rowIndex <= range.e.r; ++rowIndex) { |
|
|
|
|
|
let newRow = {}; |
|
|
|
|
|
for (let colIndex = range.s.c; colIndex <= range.e.c; ++colIndex) { |
|
|
|
|
|
let cell = sheetData[XLSX.utils.encode_cell({ |
|
|
|
|
|
c: colIndex, |
|
|
|
|
|
r: rowIndex |
|
|
|
|
|
})]; |
|
|
|
|
|
let cellContent = ''; |
|
|
|
|
|
// 获取尺码 |
|
|
|
|
|
if (rowIndex === 3 && colIndex >= colRange[0] && colIndex <= colRange[1]) { |
|
|
|
|
|
that.chimaList.push({ |
|
|
|
|
|
key: String.fromCharCode("a".charCodeAt() + colIndex), |
|
|
|
|
|
value: XLSX.utils.format_cell(cell) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
// 获取其他修改 |
|
|
|
|
|
if (rowIndex === 2) { |
|
|
|
|
|
that.otherChangeList.push({ |
|
|
|
|
|
key: String.fromCharCode("a".charCodeAt() + colIndex), |
|
|
|
|
|
value: XLSX.utils.format_cell(cell) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
if (cell && cell.t) { |
|
|
|
|
|
cellContent = XLSX.utils.format_cell(cell); |
|
|
|
|
|
} |
|
|
|
|
|
// 检查当前单元格是否在合并单元格范围内 |
|
|
|
|
|
let isMergedCell = false; |
|
|
|
|
|
for (let i = 0; i < mergeRanges.length; i++) { |
|
|
|
|
|
let mergeRange = mergeRanges[i]; |
|
|
|
|
|
if (rowIndex >= mergeRange.s.r && rowIndex <= mergeRange.e.r && |
|
|
|
|
|
colIndex >= mergeRange.s.c && colIndex <= mergeRange.e.c) { |
|
|
|
|
|
isMergedCell = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (isMergedCell) { |
|
|
|
|
|
// 如果是合并单元格,找到对应的合并单元格的左上角单元格内容作为填充内容 |
|
|
|
|
|
for (let i = 0; i < mergeRanges.length; i++) { |
|
|
|
|
|
let mergeRange = mergeRanges[i]; |
|
|
|
|
|
if (rowIndex >= mergeRange.s.r && rowIndex <= mergeRange.e.r && |
|
|
|
|
|
colIndex >= mergeRange.s.c && colIndex <= mergeRange.e.c) { |
|
|
|
|
|
let topLeftCell = sheetData[XLSX.utils.encode_cell({ |
|
|
|
|
|
c: mergeRange.s.c, |
|
|
|
|
|
r: mergeRange.s.r |
|
|
|
|
|
})]; |
|
|
|
|
|
if (topLeftCell && topLeftCell.t) { |
|
|
|
|
|
cellContent = XLSX.utils.format_cell(topLeftCell); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
newRow[String.fromCharCode("a".charCodeAt() + colIndex)] = cellContent; |
|
|
|
|
|
} |
|
|
|
|
|
allCells.push(newRow); |
|
|
|
|
|
} |
|
|
|
|
|
ElMessage({ |
|
|
|
|
|
message: `导入成功,请导入下一个文件`, |
|
|
|
|
|
type: 'success', |
|
|
|
|
|
duration: 500, |
|
|
|
|
|
}) |
|
|
|
|
|
that.fileData1 = allCells |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 处理第四类表 |
|
|
|
|
|
async a4(sheetData) { |
|
|
|
|
|
let sheetDataTemp = XLSX.utils.sheet_to_json(sheetData) |
|
|
|
|
|
for (let key in sheetDataTemp[0]) { |
|
|
|
|
|
if (key === "商店") { |
|
|
|
|
|
this.otherChangeList.push({ |
|
|
|
|
|
key: key, |
|
|
|
|
|
value: "商店名称" |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (key === "箱数") { |
|
|
|
|
|
this.otherChangeList.push({ |
|
|
|
|
|
key: key, |
|
|
|
|
|
value: "箱数" |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (key === "SKU") { |
|
|
|
|
|
this.otherChangeList.push({ |
|
|
|
|
|
key: key, |
|
|
|
|
|
value: "条码贴" |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (!_.isNaN(parseInt(key))) { |
|
|
|
|
|
this.chimaList.push({ |
|
|
|
|
|
key: key, |
|
|
|
|
|
value: key |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
ElMessage({ |
|
|
|
|
|
message: `导入成功,请导入下一个文件`, |
|
|
|
|
|
type: 'success', |
|
|
|
|
|
duration: 500, |
|
|
|
|
|
}) |
|
|
|
|
|
this.fileData1 = _.cloneDeep(sheetDataTemp) |
|
|
|
|
|
}, |
|
|
|
|
|
// 处理第五类表 |
|
|
|
|
|
async a5(sheetData) { |
|
|
|
|
|
let sheetDataTemp = XLSX.utils.sheet_to_json(sheetData) |
|
|
|
|
|
for (let key in sheetDataTemp[0]) { |
|
|
|
|
|
if (key === "Store店铺") { |
|
|
|
|
|
this.otherChangeList.push({ |
|
|
|
|
|
key: key, |
|
|
|
|
|
value: "商店名称" |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (key === "箱数") { |
|
|
|
|
|
this.otherChangeList.push({ |
|
|
|
|
|
key: key, |
|
|
|
|
|
value: "箱数" |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (key === "Sku") { |
|
|
|
|
|
this.otherChangeList.push({ |
|
|
|
|
|
key: key, |
|
|
|
|
|
value: "条码贴" |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (!_.isNaN(parseInt(key))) { |
|
|
|
|
|
this.chimaList.push({ |
|
|
|
|
|
key: key, |
|
|
|
|
|
value: key |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
ElMessage({ |
|
|
|
|
|
message: `导入成功,请导入下一个文件`, |
|
|
|
|
|
type: 'success', |
|
|
|
|
|
duration: 500, |
|
|
|
|
|
}) |
|
|
|
|
|
this.fileData1 = _.cloneDeep(sheetDataTemp) |
|
|
}, |
|
|
}, |
|
|
//表格B增加数据 |
|
|
//表格B增加数据 |
|
|
async successSubmit2(opts) { |
|
|
async successSubmit2(opts) { |
|
@ -194,11 +520,20 @@ export default { |
|
|
let data = this.result |
|
|
let data = this.result |
|
|
let workbook = XLSX.read(data, { type: 'binary' }) |
|
|
let workbook = XLSX.read(data, { type: 'binary' }) |
|
|
let sheetName = workbook.SheetNames[0] |
|
|
let sheetName = workbook.SheetNames[0] |
|
|
let sheetData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]) |
|
|
let sheetData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName],) |
|
|
|
|
|
for (let i = 0; i < sheetData.length; i++) { |
|
|
|
|
|
let element = sheetData[i]; |
|
|
|
|
|
for (let key in element) { |
|
|
|
|
|
let keyTemp = key.replaceAll("\r", "") |
|
|
|
|
|
keyTemp = keyTemp.replaceAll("\n", "") |
|
|
|
|
|
element[keyTemp] = element[key] |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
that.dealData2(sheetData) |
|
|
that.dealData2(sheetData) |
|
|
ElMessage({ |
|
|
ElMessage({ |
|
|
message: `导入成功,请预览或者导出`, |
|
|
message: `导入成功,请预览或者导出`, |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
|
|
|
duration: 500, |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
fileReader.onerror = function (error) { |
|
|
fileReader.onerror = function (error) { |
|
@ -256,8 +591,25 @@ export default { |
|
|
} |
|
|
} |
|
|
for (let i = 0; i < itemTemp.length; i++) { |
|
|
for (let i = 0; i < itemTemp.length; i++) { |
|
|
let firstItem = itemTemp[i]; |
|
|
let firstItem = itemTemp[i]; |
|
|
let hasBarcodeIndex = _.findIndex(sheetData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem[sdmc] && _.trim(o.Barcode)) |
|
|
let hasBarcodeIndex |
|
|
let noBarcodeIndex = _.findIndex(sheetData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem[sdmc] && !_.trim(o.Barcode)) |
|
|
let noBarcodeIndex |
|
|
|
|
|
if (this.atype === "a1") { |
|
|
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}, `) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}, `) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
|
|
} else if (this.atype === "a2") { |
|
|
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
|
|
} else if (this.atype === "a3") { |
|
|
|
|
|
let typeTemp = firstItem.type.replace(/([0-9])([a-zA-Z])/g, '$1 $2').replace(/([a-zA-Z])([0-9])/g, '$1 $2') |
|
|
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
|
|
} else if (this.atype === "a4") { |
|
|
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
|
|
} else if (this.atype === "a5") { |
|
|
|
|
|
hasBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
noBarcodeIndex = _.findIndex(sheetData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && !_.trim(o.Barcode)) |
|
|
|
|
|
} |
|
|
if (hasBarcodeIndex !== -1) { |
|
|
if (hasBarcodeIndex !== -1) { |
|
|
let hasBarcode = sheetData[hasBarcodeIndex] |
|
|
let hasBarcode = sheetData[hasBarcodeIndex] |
|
|
// 修改原来的值 |
|
|
// 修改原来的值 |
|
@ -265,7 +617,19 @@ export default { |
|
|
hasBarcode["Quantity of containers"] += firstItem[xs] |
|
|
hasBarcode["Quantity of containers"] += firstItem[xs] |
|
|
hasBarcode["Quantity to deliver"] += firstItem[firstItem.typeKey] |
|
|
hasBarcode["Quantity to deliver"] += firstItem[firstItem.typeKey] |
|
|
hasBarcode["Quantity per container"] = firstItem[firstItem.typeKey] |
|
|
hasBarcode["Quantity per container"] = firstItem[firstItem.typeKey] |
|
|
let newItem = _.find(newData, o => _.startsWith(`${o.Description}`, `VESTIDO DISNEY DTR, ${firstItem.type}, AZUL MARINO WKM`) && o.Store === firstItem[sdmc] && _.trim(o.Barcode)) |
|
|
let newItem = "" |
|
|
|
|
|
if (this.atype === "a1") { |
|
|
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}, `) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
} else if (this.atype === "a2") { |
|
|
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
} else if (this.atype === "a3") { |
|
|
|
|
|
let typeTemp = firstItem.type.replace(/([0-9])([a-zA-Z])/g, '$1 $2').replace(/([a-zA-Z])([0-9])/g, '$1 $2') |
|
|
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(typeTemp)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
} else if (this.atype === "a4") { |
|
|
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
} else if (this.atype === "a5") { |
|
|
|
|
|
newItem = _.find(newData, o => _.toLower(o.Description).includes(`, ${_.toLower(firstItem.type)}`) && Number(o.Store) === Number(firstItem[sdmc]) && _.trim(o.Barcode)) |
|
|
|
|
|
} |
|
|
// 修改新添加的值 |
|
|
// 修改新添加的值 |
|
|
newItem["Quantity of containers"] += firstItem[xs] |
|
|
newItem["Quantity of containers"] += firstItem[xs] |
|
|
newItem["Quantity to deliver"] += firstItem[firstItem.typeKey] |
|
|
newItem["Quantity to deliver"] += firstItem[firstItem.typeKey] |
|
@ -277,8 +641,7 @@ export default { |
|
|
"Quantity to deliver": "", |
|
|
"Quantity to deliver": "", |
|
|
"Quantity per container": firstItem[firstItem.typeKey] |
|
|
"Quantity per container": firstItem[firstItem.typeKey] |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} else if (noBarcodeIndex !== -1) { |
|
|
if (noBarcodeIndex !== -1) { |
|
|
|
|
|
let noBarcode = sheetData[noBarcodeIndex] |
|
|
let noBarcode = sheetData[noBarcodeIndex] |
|
|
// 修改原有的值 |
|
|
// 修改原有的值 |
|
|
noBarcode["Barcode"] = firstItem[tmt] |
|
|
noBarcode["Barcode"] = firstItem[tmt] |
|
@ -412,6 +775,11 @@ export default { |
|
|
|
|
|
|
|
|
downloadExcel(); |
|
|
downloadExcel(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 清空数据 |
|
|
|
|
|
refrash() { |
|
|
|
|
|
// 重新加载本页面 |
|
|
|
|
|
location.reload(); |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
async mounted() { }, |
|
|
async mounted() { }, |
|
|
} |
|
|
} |
|
|