Browse Source

2026-03-23

SOP文件上传
master
fengyuan_yang 4 weeks ago
parent
commit
f85eec072c
  1. 2
      src/api/qc/qc.js
  2. 1
      src/views/modules/qc/qcPartAttribute.vue
  3. 130
      src/views/modules/qc/sopFileManagementUpload.vue
  4. 8
      src/views/modules/qc/sopFileUpload.vue
  5. 29
      src/views/modules/qc/sopListComponent.vue

2
src/api/qc/qc.js

@ -252,6 +252,8 @@ export const getCustomerList = data => createAPI(`/pms/qc/getCustomerList`,'post
// ===================================== SOP清单 =====================================
export const sopListSearch = data => createAPI(`/pms/qc/sopListSearch`,'post',data)
export const sopAvailableFiles = data => createAPI(`/pms/qc/sopAvailableFiles`,'post',data)
/** 物料SOP「文件上传」弹窗:批量本地上传,写入 file_management(D:\\sop_files + UspInsertSOP) */
export const sopFileBatchUpload = data => createAPI(`/pms/qc/sopFileBatchUpload`, 'post', data)
// 查询检验页面的SOP文件列表(IPQC/IQC/FQC/OQC/过程检验)
export const searchQcSopFileList = data => createAPI(`/pms/qc/searchQcSopFileList`,'post',data)
export const sopFileUploadSave = data => createAPI(`/pms/qc/sopFileUploadSave`,'post',data)

1
src/views/modules/qc/qcPartAttribute.vue

@ -401,6 +401,7 @@
v-if="activeTable === 'partSop'"
:part-no="partCurrentRow.partNo"
:site="partCurrentRow.site"
:bu-no="partCurrentRow.buNo"
:table-height="secondHeight - 98">
</sop-list-component>
</el-tab-pane>

130
src/views/modules/qc/sopFileManagementUpload.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>

8
src/views/modules/qc/sopFileUpload.vue

@ -213,6 +213,7 @@ export default {
visible: false,
currentPartNo: '',
currentSite: '',
currentBuNo: '',
searchForm: {
fileNo: '',
fileName: '',
@ -245,13 +246,14 @@ export default {
})
},
init (partNo, site) {
init (partNo, site, buNo) {
this.visible = true
this.currentPartNo = partNo || ''
this.currentSite = site || this.$store.state.user.site
this.currentBuNo = (buNo != null && buNo !== '') ? String(buNo) : (this.$store.state.user.buNo || '')
this.resetData()
this.getFileList()
this.getStandardOperation(site)
//this.getStandardOperation(site)
},
resetData () {
this.searchForm = {
@ -416,7 +418,7 @@ export default {
String(currentDate.getDate()).padStart(2, '0')
const saveData = this.uploadedFileList.map(file => ({
site: this.currentSite,
buNo: file.buNo || this.$store.state.user.buNo,
buNo: file.buNo || this.currentBuNo || this.$store.state.user.buNo,
partNo: this.currentPartNo,
sopNo: file.fileNo,
sopName: file.fileName,

29
src/views/modules/qc/sopListComponent.vue

@ -2,7 +2,8 @@
<div class="sop-list-component" style="padding: 2px !important">
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
<el-form-item>
<el-button type="primary" @click="fileUploadHandle()">文件上传</el-button>
<el-button type="primary" @click="localFileUploadHandle()">上传文件</el-button>
<el-button @click="fileLibraryHandle()">从文件库添加</el-button>
<el-button type="danger" @click="batchDeleteHandle()" :disabled="dataListSelections.length === 0" :loading="deleteLoading">删除</el-button>
</el-form-item>
</el-form>
@ -114,6 +115,10 @@
</el-pagination>
<!-- 文件上传弹窗 -->
<sop-file-management-upload
ref="sopFileManagementUpload"
@uploaded="getDataList">
</sop-file-management-upload>
<sop-file-upload
v-if="sopFileUploadVisible"
ref="sopFileUpload"
@ -123,12 +128,14 @@
</template>
<script>
import SopFileManagementUpload from './sopFileManagementUpload'
import SopFileUpload from './sopFileUpload'
import { sopListSearch, sopRecordDelete, downloadSopFile } from '@/api/qc/qc.js'
export default {
name: 'SopListComponent',
components: {
SopFileManagementUpload,
SopFileUpload
},
props: {
@ -140,6 +147,10 @@ export default {
type: [String, Number],
default: ''
},
buNo: {
type: String,
default: ''
},
tableHeight: {
type: Number,
default: 200
@ -213,15 +224,25 @@ export default {
selectionChangeHandle (val) {
this.dataListSelections = val
},
//
fileUploadHandle () {
// file_management IPQC
localFileUploadHandle () {
if (!this.partNo) {
this.$message.warning('请先选择物料')
return
}
this.$nextTick(() => {
this.$refs.sopFileManagementUpload.init(this.partNo, this.site, this.buNo)
})
},
//
fileLibraryHandle () {
if (!this.partNo) {
this.$message.warning('请先选择物料')
return
}
this.sopFileUploadVisible = true
this.$nextTick(() => {
this.$refs.sopFileUpload.init(this.partNo, this.site)
this.$refs.sopFileUpload.init(this.partNo, this.site, this.buNo)
})
},
//

Loading…
Cancel
Save