|
|
@ -4,35 +4,102 @@ |
|
|
title="文件上传" |
|
|
title="文件上传" |
|
|
:close-on-click-modal="false" |
|
|
:close-on-click-modal="false" |
|
|
:visible.sync="visible" |
|
|
:visible.sync="visible" |
|
|
width="390px" |
|
|
|
|
|
|
|
|
width="1200px" |
|
|
|
|
|
append-to-body |
|
|
class="customer-dialog"> |
|
|
class="customer-dialog"> |
|
|
<el-form :inline="true" label-position="top" label-width="80px"> |
|
|
<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-row> |
|
|
<el-col :span="24"> |
|
|
<el-col :span="24"> |
|
|
<el-upload |
|
|
<el-upload |
|
|
class="customer-upload" |
|
|
class="customer-upload" |
|
|
drag |
|
|
|
|
|
multiple |
|
|
|
|
|
:file-list="fileList" |
|
|
|
|
|
action="javascript:void(0);" |
|
|
action="javascript:void(0);" |
|
|
ref="uploadFile" |
|
|
ref="uploadFile" |
|
|
|
|
|
multiple |
|
|
|
|
|
:show-file-list="false" |
|
|
:before-upload="beforeUploadHandle" |
|
|
:before-upload="beforeUploadHandle" |
|
|
:on-change="onChange" |
|
|
:on-change="onChange" |
|
|
accept="*" |
|
|
accept="*" |
|
|
:auto-upload="false" |
|
|
:auto-upload="false" |
|
|
style="text-align: left;"> |
|
|
|
|
|
<i class="el-icon-upload"></i> |
|
|
|
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em>(支持多选)</div> |
|
|
|
|
|
|
|
|
style="text-align: left; margin-bottom: 10px;"> |
|
|
|
|
|
<el-button type="primary">上传</el-button> |
|
|
</el-upload> |
|
|
</el-upload> |
|
|
</el-col> |
|
|
</el-col> |
|
|
</el-row> |
|
|
</el-row> |
|
|
|
|
|
<el-row> |
|
|
|
|
|
<el-col :span="24"> |
|
|
|
|
|
<div class="rq"> |
|
|
|
|
|
<el-table |
|
|
|
|
|
:data="fileList" |
|
|
|
|
|
border |
|
|
|
|
|
style="width: 100%;" |
|
|
|
|
|
height="400"> |
|
|
|
|
|
<el-table-column label="文件编码" min-width="150"> |
|
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
|
<el-input v-model="scope.row.fileNo" placeholder="请输入文件编码" size="small"></el-input> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
<el-table-column prop="fileName" label="文件名称" min-width="150" show-overflow-tooltip></el-table-column> |
|
|
|
|
|
<el-table-column label="文件类型" min-width="100"> |
|
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
|
<el-select v-model="scope.row.sopType" placeholder="请选择" size="small"> |
|
|
|
|
|
<el-option label="PD" value="PD"></el-option> |
|
|
|
|
|
<el-option label="SOP" value="SOP"></el-option> |
|
|
|
|
|
<el-option label="SIP" value="SIP"></el-option> |
|
|
|
|
|
<el-option label="TPI" value="TPI"></el-option> |
|
|
|
|
|
</el-select> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
<el-table-column prop="fileSuffix" label="文件后缀" min-width="80"></el-table-column> |
|
|
|
|
|
<el-table-column label="版本号" min-width="100"> |
|
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
|
<el-input v-model="scope.row.version" placeholder="请输入版本号" size="small"></el-input> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
<el-table-column label="工序" min-width="150"> |
|
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
|
<el-select v-model="scope.row.itemNo" clearable placeholder="请选择工序" size="small"> |
|
|
|
|
|
<el-option |
|
|
|
|
|
v-for="i in operationList" |
|
|
|
|
|
:key="i.id" |
|
|
|
|
|
:label="i.operationDesc" |
|
|
|
|
|
:value="i.operationDesc"> |
|
|
|
|
|
</el-option> |
|
|
|
|
|
</el-select> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
<el-table-column label="生效日期" min-width="160"> |
|
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
|
<el-date-picker |
|
|
|
|
|
v-model="scope.row.phaseInDate" |
|
|
|
|
|
type="date" |
|
|
|
|
|
value-format="yyyy-MM-dd" |
|
|
|
|
|
placeholder="选择日期" |
|
|
|
|
|
style="width: 100%" |
|
|
|
|
|
:picker-options="getPhaseInPickerOptions(scope.row)"> |
|
|
|
|
|
</el-date-picker> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
<el-table-column label="失效日期" min-width="160"> |
|
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
|
<el-date-picker |
|
|
|
|
|
v-model="scope.row.phaseOutDate" |
|
|
|
|
|
type="date" |
|
|
|
|
|
value-format="yyyy-MM-dd" |
|
|
|
|
|
placeholder="选择日期" |
|
|
|
|
|
style="width: 100%" |
|
|
|
|
|
:picker-options="getPhaseOutPickerOptions(scope.row)"> |
|
|
|
|
|
</el-date-picker> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
<el-table-column label="操作" width="80" align="center" fixed="right"> |
|
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
|
<el-button type="text" size="small" @click="removeFile(scope.$index)">删除</el-button> |
|
|
|
|
|
</template> |
|
|
|
|
|
</el-table-column> |
|
|
|
|
|
</el-table> |
|
|
|
|
|
</div> |
|
|
|
|
|
</el-col> |
|
|
|
|
|
</el-row> |
|
|
</el-form> |
|
|
</el-form> |
|
|
<span slot="footer" class="dialog-footer"> |
|
|
<span slot="footer" class="dialog-footer"> |
|
|
<el-button type="primary" :loading="saveLoading" @click="saveUploadFile">保存</el-button> |
|
|
<el-button type="primary" :loading="saveLoading" @click="saveUploadFile">保存</el-button> |
|
|
@ -43,7 +110,7 @@ |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { sopFileBatchUpload } from '@/api/qc/qc.js' |
|
|
|
|
|
|
|
|
import { sopFileBatchUpload, getStandardOperation } from '@/api/qc/qc.js' |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
data () { |
|
|
data () { |
|
|
@ -51,29 +118,81 @@ export default { |
|
|
visible: false, |
|
|
visible: false, |
|
|
saveLoading: false, |
|
|
saveLoading: false, |
|
|
fileList: [], |
|
|
fileList: [], |
|
|
|
|
|
operationList: [], |
|
|
pageData: { |
|
|
pageData: { |
|
|
partNo: '', |
|
|
|
|
|
site: '', |
|
|
site: '', |
|
|
buNo: '' |
|
|
buNo: '' |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
init (partNo, site, buNo) { |
|
|
|
|
|
|
|
|
init (site, buNo) { |
|
|
this.pageData = { |
|
|
this.pageData = { |
|
|
partNo: partNo || '', |
|
|
|
|
|
site: site || this.$store.state.user.site || '', |
|
|
site: site || this.$store.state.user.site || '', |
|
|
buNo: (buNo != null && buNo !== '') ? String(buNo) : (this.$store.state.user.buNo || '') |
|
|
buNo: (buNo != null && buNo !== '') ? String(buNo) : (this.$store.state.user.buNo || '') |
|
|
} |
|
|
} |
|
|
this.fileList = [] |
|
|
this.fileList = [] |
|
|
this.visible = true |
|
|
this.visible = true |
|
|
|
|
|
this.getStandardOperation(this.pageData.site) |
|
|
this.$nextTick(() => { |
|
|
this.$nextTick(() => { |
|
|
this.$refs.uploadFile && this.$refs.uploadFile.clearFiles() |
|
|
this.$refs.uploadFile && this.$refs.uploadFile.clearFiles() |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
getStandardOperation (site) { |
|
|
|
|
|
let tempData = { |
|
|
|
|
|
site: site |
|
|
|
|
|
} |
|
|
|
|
|
getStandardOperation(tempData).then(({data}) => { |
|
|
|
|
|
if (data.code === 0) { |
|
|
|
|
|
this.operationList = data.rows |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
beforeUploadHandle () {}, |
|
|
beforeUploadHandle () {}, |
|
|
onChange (file, fileList) { |
|
|
onChange (file, fileList) { |
|
|
this.fileList = fileList |
|
|
|
|
|
|
|
|
// Check if file is already in the list |
|
|
|
|
|
const exists = this.fileList.some(f => f.raw.uid === file.raw.uid) |
|
|
|
|
|
if (!exists) { |
|
|
|
|
|
const fileName = file.name |
|
|
|
|
|
const lastDotIndex = fileName.lastIndexOf('.') |
|
|
|
|
|
const nameWithoutSuffix = lastDotIndex > -1 ? fileName.substring(0, lastDotIndex) : fileName |
|
|
|
|
|
const suffix = lastDotIndex > -1 ? fileName.substring(lastDotIndex + 1) : '' |
|
|
|
|
|
|
|
|
|
|
|
this.fileList.push({ |
|
|
|
|
|
raw: file.raw, |
|
|
|
|
|
fileNo: nameWithoutSuffix, |
|
|
|
|
|
fileName: fileName, |
|
|
|
|
|
sopType: '', |
|
|
|
|
|
fileSuffix: suffix, |
|
|
|
|
|
version: 'A0', |
|
|
|
|
|
itemNo: '', |
|
|
|
|
|
phaseInDate: '', |
|
|
|
|
|
phaseOutDate: '' |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
removeFile (index) { |
|
|
|
|
|
this.fileList.splice(index, 1) |
|
|
|
|
|
}, |
|
|
|
|
|
getPhaseInPickerOptions (row) { |
|
|
|
|
|
return { |
|
|
|
|
|
disabledDate (time) { |
|
|
|
|
|
if (row.phaseOutDate) { |
|
|
|
|
|
return time.getTime() > new Date(row.phaseOutDate).getTime() |
|
|
|
|
|
} |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
getPhaseOutPickerOptions (row) { |
|
|
|
|
|
return { |
|
|
|
|
|
disabledDate (time) { |
|
|
|
|
|
if (row.phaseInDate) { |
|
|
|
|
|
return time.getTime() < new Date(row.phaseInDate).getTime() |
|
|
|
|
|
} |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
closeDialog () { |
|
|
closeDialog () { |
|
|
this.fileList = [] |
|
|
this.fileList = [] |
|
|
@ -82,29 +201,51 @@ export default { |
|
|
this.$emit('uploaded') |
|
|
this.$emit('uploaded') |
|
|
}, |
|
|
}, |
|
|
saveUploadFile () { |
|
|
saveUploadFile () { |
|
|
if (!this.pageData.partNo) { |
|
|
|
|
|
this.$message.warning('请先选择物料') |
|
|
|
|
|
|
|
|
if (!this.fileList || this.fileList.length === 0) { |
|
|
|
|
|
this.$message.error('请先选择要上传的文件') |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if (!this.pageData.buNo) { |
|
|
|
|
|
this.$message.warning('当前物料未带出部门(buNo),请确认已选中物料行') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validate required fields |
|
|
|
|
|
for (let i = 0; i < this.fileList.length; i++) { |
|
|
|
|
|
const file = this.fileList[i] |
|
|
|
|
|
if (!file.fileNo) { |
|
|
|
|
|
this.$message.error(`第 ${i + 1} 行文件编码不能为空`) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if (!this.fileList || this.fileList.length === 0) { |
|
|
|
|
|
this.$message.error('请先选择要上传的文件') |
|
|
|
|
|
|
|
|
if (!file.sopType) { |
|
|
|
|
|
this.$message.error(`第 ${i + 1} 行文件类型不能为空`) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const formData = new FormData() |
|
|
const formData = new FormData() |
|
|
|
|
|
const currentDate = new Date() |
|
|
|
|
|
const formatDate = currentDate.getFullYear() + '-' + |
|
|
|
|
|
String(currentDate.getMonth() + 1).padStart(2, '0') + '-' + |
|
|
|
|
|
String(currentDate.getDate()).padStart(2, '0') |
|
|
|
|
|
|
|
|
for (let i = 0; i < this.fileList.length; i++) { |
|
|
for (let i = 0; i < this.fileList.length; i++) { |
|
|
const raw = this.fileList[i].raw |
|
|
|
|
|
if (raw) { |
|
|
|
|
|
formData.append('file', raw) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const file = this.fileList[i] |
|
|
|
|
|
formData.append('file', file.raw) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const fileMetaData = this.fileList.map(file => ({ |
|
|
|
|
|
fileNo: file.fileNo || '', |
|
|
|
|
|
fileName: file.fileName || '', |
|
|
|
|
|
sopType: file.sopType || '', |
|
|
|
|
|
fileSuffix: file.fileSuffix || '', |
|
|
|
|
|
version: file.version || 'A0', |
|
|
|
|
|
itemNo: file.itemNo || '', |
|
|
|
|
|
phaseInDate: file.phaseInDate || formatDate, |
|
|
|
|
|
phaseOutDate: file.phaseOutDate || '' |
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
formData.append('fileMetaData', JSON.stringify(fileMetaData)) |
|
|
formData.append('site', String(this.pageData.site)) |
|
|
formData.append('site', String(this.pageData.site)) |
|
|
formData.append('buNo', String(this.pageData.buNo)) |
|
|
formData.append('buNo', String(this.pageData.buNo)) |
|
|
formData.append('partNo', String(this.pageData.partNo)) |
|
|
|
|
|
formData.append('createBy', this.$store.state.user.name || '') |
|
|
formData.append('createBy', this.$store.state.user.name || '') |
|
|
|
|
|
|
|
|
this.saveLoading = true |
|
|
this.saveLoading = true |
|
|
sopFileBatchUpload(formData).then(({ data }) => { |
|
|
sopFileBatchUpload(formData).then(({ data }) => { |
|
|
if (data && data.code === 0) { |
|
|
if (data && data.code === 0) { |
|
|
@ -127,4 +268,13 @@ export default { |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style scoped lang="scss"> |
|
|
<style scoped lang="scss"> |
|
|
|
|
|
::v-deep .el-table .cell { |
|
|
|
|
|
padding: 5px; |
|
|
|
|
|
} |
|
|
|
|
|
::v-deep .el-input__inner { |
|
|
|
|
|
padding: 0 5px; |
|
|
|
|
|
} |
|
|
|
|
|
::v-deep .el-dialog__body { |
|
|
|
|
|
padding: 10px 20px; |
|
|
|
|
|
} |
|
|
</style> |
|
|
</style> |