|
@@ -1,5 +1,6 @@
|
|
|
<script>
|
|
|
import { importData, fileImport} from '@/api/requisition/basic';
|
|
|
+import { changeImport, downloadFailData} from '@/api/changeApply/basic';
|
|
|
export default {
|
|
|
name:'BatchImport',
|
|
|
props:{},
|
|
@@ -7,52 +8,57 @@ export default {
|
|
|
return {
|
|
|
title:'批量导入',
|
|
|
visible:false,
|
|
|
- fileData:[]
|
|
|
+ fileData:[],
|
|
|
+ size:'mini',
|
|
|
}
|
|
|
},
|
|
|
methods:{
|
|
|
- beforeColse(){},
|
|
|
+ beforeColse(done){
|
|
|
+ this.cancal();
|
|
|
+ done();
|
|
|
+
|
|
|
+ },
|
|
|
handleClick(){
|
|
|
this.visible = true;
|
|
|
},
|
|
|
confirmUpdate(){
|
|
|
- if (this.fileData.length) {
|
|
|
+ if (this.fileData.length) {
|
|
|
|
|
|
- let formData = new FormData();
|
|
|
+ let formData = new FormData();
|
|
|
|
|
|
- formData.append('file', this.fileData[0].raw);
|
|
|
- importData(formData).then(res => {
|
|
|
- if (res.code == 200) {
|
|
|
- this.visible = false;
|
|
|
- this.fileData = [];
|
|
|
- if (res.data.flag) {
|
|
|
- this.failLoad = true;
|
|
|
- console.log(res.data.datas)
|
|
|
- let param = {failDatas: res.data.datas}
|
|
|
- if (null != param) {
|
|
|
+ formData.append('file', this.fileData[0].raw);
|
|
|
+ importData(formData).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.visible = false;
|
|
|
+ this.fileData = [];
|
|
|
+ if (res.data.flag) {
|
|
|
+ this.failLoad = true;
|
|
|
+ console.log(res.data.datas)
|
|
|
+ let param = {failDatas: res.data.datas}
|
|
|
+ if (null != param) {
|
|
|
|
|
|
- fileImport(param).then(res => {
|
|
|
- console.log('res',res)
|
|
|
- const isBlob = blobValidate(res);
|
|
|
- if (isBlob) {
|
|
|
- const blob = new Blob([res]);
|
|
|
- saveAs(blob, '导入失败的物料申请单数据.xlsx');
|
|
|
+ fileImport(param).then(res => {
|
|
|
+ console.log('res',res)
|
|
|
+ const isBlob = blobValidate(res);
|
|
|
+ if (isBlob) {
|
|
|
+ const blob = new Blob([res]);
|
|
|
+ saveAs(blob, '导入失败的物料申请单数据.xlsx');
|
|
|
+ }
|
|
|
+ this.failLoad = false;
|
|
|
+ })
|
|
|
}
|
|
|
- this.failLoad = false;
|
|
|
- })
|
|
|
+ }
|
|
|
+ this.$notify({
|
|
|
+ message: res.data.msg,
|
|
|
+ type: res.data.flag ? 'warning' : 'success'
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ message: res.msg,
|
|
|
+ type: res.code == 200 ? 'success' : 'warning'
|
|
|
+ });
|
|
|
}
|
|
|
- }
|
|
|
- this.$notify({
|
|
|
- message: res.data.msg,
|
|
|
- type: res.data.flag ? 'warning' : 'success'
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.$notify({
|
|
|
- message: res.msg,
|
|
|
- type: res.code == 200 ? 'success' : 'warning'
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
} else {
|
|
|
this.$notify({
|
|
|
title:'警告',
|
|
@@ -96,7 +102,7 @@ export default {
|
|
|
append-to-body
|
|
|
:before-close="beforeColse"
|
|
|
>
|
|
|
- <div>
|
|
|
+ <div style="display: flex;justify-content: center;">
|
|
|
<el-upload
|
|
|
accept=".xls, .xlsx"
|
|
|
ref="upload"
|
|
@@ -107,10 +113,10 @@ export default {
|
|
|
:on-change="handleChangeFile"
|
|
|
:limit="1"
|
|
|
>
|
|
|
- <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
|
|
|
+ <el-button slot="trigger" :size="size" type="primary">选取文件</el-button>
|
|
|
<el-button
|
|
|
style="margin-left: 10px;"
|
|
|
- size="small"
|
|
|
+ :size="size"
|
|
|
type="success"
|
|
|
@click="handleDownTemplate"
|
|
|
>下载模板
|
|
@@ -120,8 +126,8 @@ export default {
|
|
|
|
|
|
</div>
|
|
|
<span slot="footer">
|
|
|
- <el-button @click="cancal">取 消</el-button>
|
|
|
- <el-button type="primary" @click="confirmUpdate">确 定</el-button>
|
|
|
+ <el-button :size="size" @click="cancal">取 消</el-button>
|
|
|
+ <el-button type="primary" :size="size" @click="confirmUpdate">确 定</el-button>
|
|
|
</span>
|
|
|
</el-dialog>
|
|
|
</el-button>
|