|
|
|
@ -19,6 +19,7 @@ |
|
|
|
</el-form-item> |
|
|
|
<el-form-item :label="' '"> |
|
|
|
<el-button type="primary" @click="getDataList">查询</el-button> |
|
|
|
<el-button type="primary" icon="el-icon-upload" @click="partCostUpload">导入物料成本</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
|
|
|
|
@ -160,17 +161,37 @@ |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" width="390px" style="height: 520px;" class="customer-dialog"> |
|
|
|
<el-form :inline="true" label-position="top" label-width="80px"> |
|
|
|
<el-button type="primary" @click="downloadFile()">下载文件模板</el-button> |
|
|
|
<el-row> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-upload class="customer-upload" drag action="javascript:void(0);" ref="uploadFile" :limit="1" accept=".xlsx,.xls" |
|
|
|
:before-upload="beforeUploadHandle" :on-change="onChange" :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" @click="saveUploadFile">保存</el-button> |
|
|
|
<el-button type="primary" @click="closeUploadDialog">关闭</el-button> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<choose-list-eam ref="baseList" @getBaseData="getBaseData"></choose-list-eam> |
|
|
|
|
|
|
|
</div> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import {partInformationSearch,partCostInformationEdit} from "@/api/part/partInformation"; |
|
|
|
import {partInformationSearch,partCostInformationEdit,savePartCostComponentByExcel} from "@/api/part/partInformation"; |
|
|
|
import Chooselist from "../common/Chooselist.vue"; |
|
|
|
import {getSiteAndBuByUserName} from "../../../api/qc/qc"; |
|
|
|
import {getSiteAndBuByUserName, queryFileId} from "../../../api/qc/qc"; |
|
|
|
import ChooseListEam from "../common/Chooselist_eam.vue"; |
|
|
|
import {costHistorySearch, verifyData} from "../../../api/part/partInformation"; |
|
|
|
import {getTableDefaultListLanguage, getTableUserListLanguage} from "../../../api/table"; |
|
|
|
import {downLoadObjectFile} from "../../../api/eam/eam_object_list"; |
|
|
|
|
|
|
|
export default { |
|
|
|
components: { |
|
|
|
@ -186,6 +207,10 @@ export default { |
|
|
|
pageSize: 50, |
|
|
|
totalPage: 0, |
|
|
|
userBuList: [], |
|
|
|
// 导入 |
|
|
|
titleCon: '文件导入', |
|
|
|
visible: false, |
|
|
|
fileList: [], |
|
|
|
// 条件查询 |
|
|
|
searchData: { |
|
|
|
site: '', |
|
|
|
@ -1008,6 +1033,96 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
partCostUpload () { |
|
|
|
this.visible = true |
|
|
|
}, |
|
|
|
|
|
|
|
// 关闭modal |
|
|
|
closeUploadDialog () { |
|
|
|
this.fileList = [] |
|
|
|
// 清空文件上传记录 |
|
|
|
this.$refs.uploadFile.clearFiles() |
|
|
|
// 关闭当前的页面 |
|
|
|
this.visible = false |
|
|
|
}, |
|
|
|
|
|
|
|
// 保修当前的数据 |
|
|
|
saveUploadFile () { |
|
|
|
// 判断文件是否上传 |
|
|
|
if (null == this.fileList || 0 === this.fileList.length) { |
|
|
|
this.$message.error("请先上传文件!") |
|
|
|
return false |
|
|
|
} |
|
|
|
const formData = new FormData() |
|
|
|
formData.append("file", this.fileList[0].raw) |
|
|
|
formData.append("updateBy", this.$store.state.user.name) |
|
|
|
formData.append("site", this.$store.state.user.site.toString()) |
|
|
|
savePartCostComponentByExcel(formData).then(({data}) => { |
|
|
|
if (data.code === 0) { |
|
|
|
this.$message.success(data.msg) |
|
|
|
// 关闭窗口并刷新页面 |
|
|
|
this.closeDialog() |
|
|
|
} else { |
|
|
|
this.$message.warning(data.msg) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 上传之前 |
|
|
|
beforeUploadHandle (file) { |
|
|
|
let extName = file[0].name.substring(file[0].name.lastIndexOf('.')).toLowerCase() |
|
|
|
if (!(extName === '.xlsx' || extName === '.xls')) { |
|
|
|
this.$message.error('数据导入失败,请选择正确的xlsx模板文件') |
|
|
|
return false |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 选择上传文件时 |
|
|
|
onChange (file) { |
|
|
|
this.fileList.push(file) |
|
|
|
}, |
|
|
|
|
|
|
|
// 下载 |
|
|
|
async downloadFile () { |
|
|
|
let file = { |
|
|
|
id: 0, |
|
|
|
fileName: '' |
|
|
|
} |
|
|
|
let tempData = { |
|
|
|
orderRef1: 'partCost', |
|
|
|
orderRef2: 'partCostFormat' |
|
|
|
} |
|
|
|
await queryFileId(tempData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
file.id = data.data.id |
|
|
|
file.fileName = data.data.fileName |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
await downLoadObjectFile(file).then(({data}) => { |
|
|
|
// 不限制文件下载类型 |
|
|
|
const blob = new Blob([data], {type: "application/octet-stream"}) |
|
|
|
// 下载文件名称 |
|
|
|
const fileName = file.fileName |
|
|
|
// a标签下载 |
|
|
|
const linkNode = document.createElement('a') |
|
|
|
// a标签的download属性规定下载文件的名称 |
|
|
|
linkNode.download = fileName |
|
|
|
linkNode.style.display = 'none' |
|
|
|
// 生成一个Blob URL |
|
|
|
linkNode.href = URL.createObjectURL(blob) |
|
|
|
document.body.appendChild(linkNode) |
|
|
|
// 模拟在按钮上的一次鼠标单击 |
|
|
|
linkNode.click() |
|
|
|
// 释放URL 对象 |
|
|
|
URL.revokeObjectURL(linkNode.href) |
|
|
|
document.body.removeChild(linkNode) |
|
|
|
}) |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|