5 changed files with 163 additions and 7 deletions
-
2src/api/qc/qc.js
-
1src/views/modules/qc/qcPartAttribute.vue
-
130src/views/modules/qc/sopFileManagementUpload.vue
-
8src/views/modules/qc/sopFileUpload.vue
-
29src/views/modules/qc/sopListComponent.vue
@ -0,0 +1,130 @@ |
|||
<template> |
|||
<div class="customer-css"> |
|||
<el-dialog |
|||
title="文件上传" |
|||
:close-on-click-modal="false" |
|||
:visible.sync="visible" |
|||
width="390px" |
|||
class="customer-dialog"> |
|||
<el-form :inline="true" label-position="top" label-width="80px"> |
|||
<el-row> |
|||
<el-col :span="24"> |
|||
<el-form-item class="customer-item" label="物料编码"> |
|||
<el-input v-model="pageData.partNo" style="width: 340px;" disabled></el-input> |
|||
</el-form-item> |
|||
</el-col> |
|||
</el-row> |
|||
<el-row> |
|||
<el-col :span="24"> |
|||
<el-upload |
|||
class="customer-upload" |
|||
drag |
|||
multiple |
|||
:file-list="fileList" |
|||
action="javascript:void(0);" |
|||
ref="uploadFile" |
|||
:before-upload="beforeUploadHandle" |
|||
:on-change="onChange" |
|||
accept="*" |
|||
:auto-upload="false" |
|||
style="text-align: left;"> |
|||
<i class="el-icon-upload"></i> |
|||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em>(支持多选)</div> |
|||
</el-upload> |
|||
</el-col> |
|||
</el-row> |
|||
</el-form> |
|||
<span slot="footer" class="dialog-footer"> |
|||
<el-button type="primary" :loading="saveLoading" @click="saveUploadFile">保存</el-button> |
|||
<el-button @click="closeDialog">关闭</el-button> |
|||
</span> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { sopFileBatchUpload } from '@/api/qc/qc.js' |
|||
|
|||
export default { |
|||
data () { |
|||
return { |
|||
visible: false, |
|||
saveLoading: false, |
|||
fileList: [], |
|||
pageData: { |
|||
partNo: '', |
|||
site: '', |
|||
buNo: '' |
|||
} |
|||
} |
|||
}, |
|||
methods: { |
|||
init (partNo, site, buNo) { |
|||
this.pageData = { |
|||
partNo: partNo || '', |
|||
site: site || this.$store.state.user.site || '', |
|||
buNo: (buNo != null && buNo !== '') ? String(buNo) : (this.$store.state.user.buNo || '') |
|||
} |
|||
this.fileList = [] |
|||
this.visible = true |
|||
this.$nextTick(() => { |
|||
this.$refs.uploadFile && this.$refs.uploadFile.clearFiles() |
|||
}) |
|||
}, |
|||
beforeUploadHandle () {}, |
|||
onChange (file, fileList) { |
|||
this.fileList = fileList |
|||
}, |
|||
closeDialog () { |
|||
this.fileList = [] |
|||
this.$refs.uploadFile && this.$refs.uploadFile.clearFiles() |
|||
this.visible = false |
|||
this.$emit('uploaded') |
|||
}, |
|||
saveUploadFile () { |
|||
if (!this.pageData.partNo) { |
|||
this.$message.warning('请先选择物料') |
|||
return |
|||
} |
|||
if (!this.pageData.buNo) { |
|||
this.$message.warning('当前物料未带出部门(buNo),请确认已选中物料行') |
|||
return |
|||
} |
|||
if (!this.fileList || this.fileList.length === 0) { |
|||
this.$message.error('请先选择要上传的文件') |
|||
return |
|||
} |
|||
const formData = new FormData() |
|||
for (let i = 0; i < this.fileList.length; i++) { |
|||
const raw = this.fileList[i].raw |
|||
if (raw) { |
|||
formData.append('file', raw) |
|||
} |
|||
} |
|||
formData.append('site', String(this.pageData.site)) |
|||
formData.append('buNo', String(this.pageData.buNo)) |
|||
formData.append('partNo', String(this.pageData.partNo)) |
|||
formData.append('createBy', this.$store.state.user.name || '') |
|||
this.saveLoading = true |
|||
sopFileBatchUpload(formData).then(({ data }) => { |
|||
if (data && data.code === 0) { |
|||
const n = (data.rows && data.rows.length) || this.fileList.length |
|||
this.$message.success(`成功上传 ${n} 个文件并已写入文件库`) |
|||
this.fileList = [] |
|||
this.$refs.uploadFile && this.$refs.uploadFile.clearFiles() |
|||
this.$emit('uploaded') |
|||
} else { |
|||
this.$message.warning((data && data.msg) || '上传失败') |
|||
} |
|||
}).catch(() => { |
|||
this.$message.error('上传失败') |
|||
}).finally(() => { |
|||
this.saveLoading = false |
|||
}) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped lang="scss"> |
|||
</style> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue