...
|
...
|
@@ -86,7 +86,7 @@ |
|
|
<script>
|
|
|
import Api from 'api/api';
|
|
|
import dayjs from 'dayjs';
|
|
|
import xlsx from 'xlsx';
|
|
|
import XLSX from 'xlsx';
|
|
|
|
|
|
const api = new Api();
|
|
|
const forbidenTypeMap = {
|
...
|
...
|
@@ -316,7 +316,7 @@ export default { |
|
|
},
|
|
|
onBeforeUpload(file) {
|
|
|
const fileExt = file.name.split('.').pop().toLocaleLowerCase();
|
|
|
if (fileExt !== 'xlsx') {
|
|
|
if (fileExt !== 'XLSX') {
|
|
|
this.$Message.warning('文件格式错误');
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -340,10 +340,10 @@ export default { |
|
|
this.uploadTxt = '';
|
|
|
try {
|
|
|
const data = e.target.result;
|
|
|
const workbook = xlsx.read(data, { type: 'array' });
|
|
|
const workbook = XLSX.read(data, { type: 'array' });
|
|
|
const firstSheetName = workbook.SheetNames[0];
|
|
|
const worksheet = workbook.Sheets[firstSheetName];
|
|
|
const results = xlsx.utils.sheet_to_json(worksheet);
|
|
|
const results = XLSX.utils.sheet_to_json(worksheet);
|
|
|
|
|
|
this.formData.productLimitValue = results.map(r => r['商品编码']).filter(r => r).join(',');
|
|
|
|
...
|
...
|
@@ -356,12 +356,12 @@ export default { |
|
|
return false;
|
|
|
},
|
|
|
onExample() {
|
|
|
const wb = xlsx.utils.book_new();
|
|
|
const ws = xlsx.utils.json_to_sheet([{
|
|
|
const wb = XLSX.utils.book_new();
|
|
|
const ws = XLSX.utils.json_to_sheet([{
|
|
|
'商品编码': '123456'
|
|
|
}]);
|
|
|
xlsx.utils.book_append_sheet(wb, ws, '优惠券适用范围示例');
|
|
|
xlsx.writeFile(wb, '优惠券适用范围示例.xlsx');
|
|
|
XLSX.utils.book_append_sheet(wb, ws, '优惠券适用范围示例');
|
|
|
XLSX.writeFile(wb, '优惠券适用范围示例.xlsx');
|
|
|
}
|
|
|
}
|
|
|
};
|
...
|
...
|
|