diff --git a/fe/PC/src/api/wms-api.js b/fe/PC/src/api/wms-api.js index 53e23dbc3..27ad86c46 100644 --- a/fe/PC/src/api/wms-api.js +++ b/fe/PC/src/api/wms-api.js @@ -125,6 +125,7 @@ export function postImport(data, url,isSpecial) { headers: { 'Content-Type': 'multipart/form-data;' }, + responseType: 'blob', data }) } diff --git a/fe/PC/src/api/wms-auth.js b/fe/PC/src/api/wms-auth.js index fb00d9258..e93410557 100644 --- a/fe/PC/src/api/wms-auth.js +++ b/fe/PC/src/api/wms-auth.js @@ -179,9 +179,9 @@ export function SetUserWorkgroupPermissions(data,id) { }) } //加载用户登录信息 -export function loadLoginUserInfo() { +export function loadLoginUserInfo(id) { return request({ - url: baseURL + '/identity/my-profile', + url: baseURL + '/identity/users/' + id, method: 'get' }) } diff --git a/fe/PC/src/mixins/mixins.js b/fe/PC/src/mixins/mixins.js index 88447e802..9b32dcd01 100644 --- a/fe/PC/src/mixins/mixins.js +++ b/fe/PC/src/mixins/mixins.js @@ -185,45 +185,6 @@ export const mixins = { }) }) }, - //导出存储 - // blob(res) { - // // const name = decodeURIComponent (res.disposition.slice(res.disposition.indexOf('=') + 1)) - // const name = filters.Roles(this.$route.name) - // // delete res.disposition - // let blob = new Blob([res], { - // type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - // }) - // const href = URL.createObjectURL(blob) //创建新的URL表示指定的blob对象 - // const a = document.createElement('a') //创建a标签 - // a.style.display = 'none' - // a.href = href // 指定下载链接 - // a.download = name //指定下载文件名 - // a.click() //触发下载 - // URL.revokeObjectURL(a.href) //释放URL对象 - // }, - downloadFile(data, fileName) { - var byteString = atob(data) - var arrayBuffer = new ArrayBuffer(byteString.length) // 创建缓冲数组 - var intArray = new Uint8Array(arrayBuffer) // 创建视图 - for (var i = 0; i < byteString.length; i++) { - intArray[i] = byteString.charCodeAt(i) - } - const blob = new Blob([intArray], { type: '' }) - // 获取heads中的filename文件名 - const downloadElement = document.createElement('a') - // 创建下载的链接 - const href = window.URL.createObjectURL(blob) - downloadElement.href = href - // 下载后文件名 - downloadElement.download = fileName - document.body.appendChild(downloadElement) - // 点击下载 - downloadElement.click() - // 下载完成移除元素 - document.body.removeChild(downloadElement) - // 释放掉blob对象 - window.URL.revokeObjectURL(href) - }, //导出存储-新 blob(res, fileName) { let blob = new Blob([res], { @@ -251,102 +212,58 @@ export const mixins = { let { formFile } = val[1] + + // 特殊导入接口判断 + let _uploadURL = that.importUploadURL || that.URL + let _isSpecial = that.importUploadURL ? true : false + let fd = new FormData(); - let fileName = '' - let rd = new FileReader(); // 创建文件读取对象 - // formFile.forEach((item) => { - // fd.append("formFile", item) - // fd.append("method", val[1].method) - // fd.append("isAllowPartImport", val[1].isAllowPartImport=='0'?true:false) - // }) - // 目前只有单文件上传,写法只适用于单文件上传 - fileName = formFile[0].name - rd.readAsDataURL(formFile[0]) - rd.onloadend = function(){ - var arrayBuffer = rd.result - let params = { - fileName: fileName, - bytes: arrayBuffer.substring(arrayBuffer.indexOf(',') + 1, arrayBuffer.length) - } - // 特殊导入接口判断 - let _uploadURL = that.importUploadURL || that.URL - let _isSpecial = that.importUploadURL ? true : false - // fileStorageCreate(params).then( createRes => { - // let importParams = { - // fileType: 1, //文件类型 固定1 - // method: val[1].method, //导入方式 0 更新 1 追加 2 覆盖 - // isAllowPartImport: val[1].isAllowPartImport=='0'?true:false, //是否部分错误导入 - // route: _isSpecial ? _uploadURL : _uploadURL + '/import', //路由 - // function: menuName, //菜单名 - // blobName: menuName, - // file: params.bytes - // } - let importParams = { - fileType: null, //文件类型 固定1 - method: 'Append', //导入方式 0 更新 1 追加 2 覆盖 - isAllowPartImport: null, //是否部分错误导入 - route: null, //路由 - function: null, //菜单名 - blobName: null, - file: params.bytes - } - postImport(importParams, _uploadURL, _isSpecial).then(res => { - // 判断是否有错误记录 - if (res.errorNum > 0) { - that.$alert('发现导入错误数据共:' + res.errorNum + '条', '错误报告', { - confirmButtonText: '下载错误报告', - callback: action => { - if (action == 'confirm') { - fileStorage({blobName: res.fileCode}).then( fileStorageRes => { - that.downloadFile(fileStorageRes.bytes, fileStorageRes.fileName) - }).catch( err => { - console.log(err) - }) - } - } - }) - } else if (res.exceptionMessage != null) { - that.$alert('错误信息:' + res.exceptionMessage, '错误', { - confirmButtonText: '确定', - callback: action => { - } - }) - // that.$alert('导入模板错误,请导入正确的模板文件!', '模板错误', { - // confirmButtonText: '确定', - // callback: action => { - // } - // }) - } else { - // that.$successMsg('全部导入成功') - that.$alert('全部导入成功,是否下载导入报告', '导入报告', { - confirmButtonText: '下载导入报告', - cancelButtonText: '取消', - callback: action => { - if (action == 'confirm') { - fileStorage({blobName: res.fileCode}).then( fileStorageRes => { - that.downloadFile(fileStorageRes.bytes, fileStorageRes.fileName) - }).catch( err => { - console.log(err) - }) - } - } - }) - + fd.append("fileType", 1) //文件类型 固定1 + fd.append("method", val[1].method) //导入方式 0 更新 1 追加 2 覆盖 + fd.append("isAllowPartImport", val[1].isAllowPartImport=='0'?true:false) //是否部分错误导入 + fd.append("route", _isSpecial ? _uploadURL : _uploadURL + '/import') //路由 + fd.append("function", menuName) //菜单名 + fd.append("blobName", menuName) + fd.append("file", formFile[0]) + + postImport(fd, _uploadURL, _isSpecial).then(res => { + // 判断是否有错误记录 + if (res.errorNum > 0) { + that.$alert('发现导入错误数据共:' + res.errorNum + '条', '错误报告', { + confirmButtonText: '下载错误报告', + callback: action => { + if (action == 'confirm') { + that.blob(res.bytes, menuName + '错误报告') + } } - that.Loading.importLoading = false - that.FormRemove(val[0]); - that.displayDialog.importDialog = false; - that.paging() - }).catch(err => { - that.Loading.importLoading = false - that.FormRemove(val[0]); - that.displayDialog.importDialog = false; - that.paging() }) - // }).catch(err => { - // console.log(err) - // }) - } + } else if (res.exceptionMessage != null) { + that.$alert('错误信息:' + res.exceptionMessage, '错误', { + confirmButtonText: '确定', + callback: action => { + } + }) + } else { + that.$alert('全部导入成功,是否下载导入报告', '导入报告', { + confirmButtonText: '下载导入报告', + cancelButtonText: '取消', + callback: action => { + if (action == 'confirm') { + that.blob(res, menuName + '导入报告') + } + } + }) + } + that.Loading.importLoading = false + that.FormRemove(val[0]); + that.displayDialog.importDialog = false; + that.paging() + }).catch(err => { + that.Loading.importLoading = false + that.FormRemove(val[0]); + that.displayDialog.importDialog = false; + that.paging() + }) } else { that.$errorMsg('请按照提示继续操作') that.displayDialog.importDialog = false; @@ -355,45 +272,133 @@ export const mixins = { }); } }, - //导入文件 应该暂无使用 - // importClick(val) { + + // downloadFile(data, fileName) { + // var byteString = atob(data) + // var arrayBuffer = new ArrayBuffer(byteString.length) // 创建缓冲数组 + // var intArray = new Uint8Array(arrayBuffer) // 创建视图 + // for (var i = 0; i < byteString.length; i++) { + // intArray[i] = byteString.charCodeAt(i) + // } + // const blob = new Blob([intArray], { type: '' }) + // // 获取heads中的filename文件名 + // const downloadElement = document.createElement('a') + // // 创建下载的链接 + // const href = window.URL.createObjectURL(blob) + // downloadElement.href = href + // // 下载后文件名 + // downloadElement.download = fileName + // document.body.appendChild(downloadElement) + // // 点击下载 + // downloadElement.click() + // // 下载完成移除元素 + // document.body.removeChild(downloadElement) + // // 释放掉blob对象 + // window.URL.revokeObjectURL(href) + // }, + //导入文件-旧 + // postImportMergeClick(val) { + // let that = this + // let menuName = this.$route.meta.title // if (val[0][0] == 0) { - // this.FormRemove(val[0]); - // this.displayDialog.importDialog = false; + // that.FormRemove(val[0]); + // that.displayDialog.importDialog = false; // } else { // val[0][1].validate((valid) => { // if (valid) { - // this.Loading.importLoading = true; + // that.Loading.importLoading = true; // let { // formFile // } = val[1] // let fd = new FormData(); - // formFile.forEach((item) => { - // fd.append("formFile", item) - // }) - // postImport(fd, this.URL).then(res => { - // if (res.failList.length === 0) { - // this.$successMsg('全部导入成功') - // } else { - // let failListCode = '' - // res.failList.forEach(key => { - // failListCode = failListCode.concat(key.code + ';') - // }) - // this.$errorMsg('部分导入失败,失败代码为:' + failListCode) + // let fileName = '' + // let rd = new FileReader(); // 创建文件读取对象 + // // formFile.forEach((item) => { + // // fd.append("formFile", item) + // // fd.append("method", val[1].method) + // // fd.append("isAllowPartImport", val[1].isAllowPartImport=='0'?true:false) + // // }) + // // 目前只有单文件上传,写法只适用于单文件上传 + // fileName = formFile[0].name + // rd.readAsDataURL(formFile[0]) + // rd.onloadend = function(){ + // var arrayBuffer = rd.result + // let params = { + // fileName: fileName, + // bytes: arrayBuffer.substring(arrayBuffer.indexOf(',') + 1, arrayBuffer.length) // } - // this.Loading.importLoading = false - // this.FormRemove(val[0]); - // this.displayDialog.importDialog = false; - // this.paging() - // }).catch(err => { - // this.Loading.importLoading = false - // this.FormRemove(val[0]); - // this.displayDialog.importDialog = false; - // this.paging() - // }) + // // 特殊导入接口判断 + // let _uploadURL = that.importUploadURL || that.URL + // let _isSpecial = that.importUploadURL ? true : false + // fileStorageCreate(params).then( createRes => { + // let importParams = { + // fileType: 1, //文件类型 固定1 + // method: val[1].method, //导入方式 0 更新 1 追加 2 覆盖 + // isAllowPartImport: val[1].isAllowPartImport=='0'?true:false, //是否部分错误导入 + // route: _isSpecial ? _uploadURL : _uploadURL + '/import', //路由 + // function: menuName, //菜单名 + // blobName: createRes, + // company: window.SITE_CONFIG['company'] + // } + // postImport(importParams, _uploadURL, _isSpecial).then(res => { + // // 判断是否有错误记录 + // if (res.errorNum > 0) { + // that.$alert('发现导入错误数据共:' + res.errorNum + '条', '错误报告', { + // confirmButtonText: '下载错误报告', + // callback: action => { + // if (action == 'confirm') { + // fileStorage({blobName: res.fileCode}).then( fileStorageRes => { + // that.downloadFile(fileStorageRes.bytes, fileStorageRes.fileName) + // }).catch( err => { + // console.log(err) + // }) + // } + // } + // }) + // } else if (res.exceptionMessage != null) { + // that.$alert('错误信息:' + res.exceptionMessage, '错误', { + // confirmButtonText: '确定', + // callback: action => { + // } + // }) + // // that.$alert('导入模板错误,请导入正确的模板文件!', '模板错误', { + // // confirmButtonText: '确定', + // // callback: action => { + // // } + // // }) + // } else { + // // that.$successMsg('全部导入成功') + // that.$alert('全部导入成功,是否下载导入报告', '导入报告', { + // confirmButtonText: '下载导入报告', + // cancelButtonText: '取消', + // callback: action => { + // if (action == 'confirm') { + // fileStorage({blobName: res.fileCode}).then( fileStorageRes => { + // that.downloadFile(fileStorageRes.bytes, fileStorageRes.fileName) + // }).catch( err => { + // console.log(err) + // }) + // } + // } + // }) + // } + // that.Loading.importLoading = false + // that.FormRemove(val[0]); + // that.displayDialog.importDialog = false; + // that.paging() + // }).catch(err => { + // that.Loading.importLoading = false + // that.FormRemove(val[0]); + // that.displayDialog.importDialog = false; + // that.paging() + // }) + // }).catch(err => { + // console.log(err) + // }) + // } // } else { - // this.$errorMsg('请按照提示继续操作') - // this.displayDialog.importDialog = false; + // that.$errorMsg('请按照提示继续操作') + // that.displayDialog.importDialog = false; // return false; // } // }); diff --git a/fe/PC/src/views/basicData/BomManage/Bom.vue b/fe/PC/src/views/basicData/BomManage/Bom.vue index ca31f71ad..9124f64a2 100644 --- a/fe/PC/src/views/basicData/BomManage/Bom.vue +++ b/fe/PC/src/views/basicData/BomManage/Bom.vue @@ -38,6 +38,7 @@ :Options="editOptions" :Handle="editHandle" :Rules="formReveal ? editRules.cerateRule : editRules.editRule" + @push="selectDataPush" @FormSubmit="FormSubmit" @close="FormClose" @goBack="goBack" @@ -79,6 +80,7 @@ import { drawerMixins } from "@/mixins/drawerMixins" import { TableHeaderMixins } from "@/mixins/TableHeaderMixins" import { newAndEdiDialogMixins } from "@/mixins/newAndEdiDialogMixins" import { mixins } from "@/mixins/mixins" +import { filterSelectMixins } from '@/mixins/filter-Select' export default { name: "Bom", mixins: [ @@ -87,6 +89,7 @@ export default { drawerMixins, TableHeaderMixins, mixins, + filterSelectMixins, newAndEdiDialogMixins ], computed: { @@ -141,12 +144,17 @@ export default { distributionType: 1, truncType: 1, plannedSplitRule: 1, - concurrencyStamp: null + concurrencyStamp: null, + component: null }, editOptions: {}, CreateForm: [ - { type: "input", label: "父物料号", prop: "product", colSpan: 12 }, - { type: "input", label: "子物料号", prop: 'component', colSpan: 12 }, + { type: "filterSelect", label: "父物料号", prop: "product", optionsLabel: "name", optionsValue: "code", + focus: (type,val) => { return this.getFilterList(type, val, "basedata/Item-Basic")}, + searchButton: (val) => { this.showSerarchPage(val, 'basedata/Item-Basic', 'ItemBasic', '物料选择', this.CreateFormData) }, colSpan: 12 }, + { type: "filterSelect", label: "子物料号", prop: "component", optionsLabel: "name", optionsValue: "code", + focus: (type,val) => { return this.getFilterList(type, val, "basedata/Item-Basic")}, + searchButton: (val) => { this.showSerarchPage(val, 'basedata/Item-Basic', 'ItemBasic', '物料选择', this.CreateFormData) }, colSpan: 12 }, { type: "input", label: "子物料用量", prop: 'componentQty', colSpan: 12, validType:'pointNumber' }, { type: "input", label: "子物料用量单位", prop: 'componentUom', colSpan: 12 }, { type: "dateTime", label: "开始时间", prop: "beginTime", colSpan: 12 }, @@ -161,6 +169,7 @@ export default { ], editForm: [ { type: "input", label: "父物料号", prop: "product",disabled:"true", colSpan: 12 }, + { type: "input", label: "子物料号", prop: 'component', disabled:"true", colSpan: 12 }, { type: "input", label: "子物料用量", prop: 'componentQty', colSpan: 12, validType:'pointNumber' }, { type: "input", label: "子物料用量单位", prop: 'componentUom', colSpan: 12 }, { type: "dateTime", label: "开始时间", prop: "beginTime", colSpan: 12 }, @@ -175,7 +184,7 @@ export default { ], editRules: { cerateRule: { - componentQty: [{ required: true, message: '不可为空', type: "number", trigger: 'blur' },], + componentQty: [{ required: true, message: '不可为空', trigger: 'blur' },], componentUom: [{ required: true, message: '不可为空', trigger: 'blur' },], beginTime: [{ required: true, message: '不可为空', trigger: 'blur' },], endTime: [{ required: true, message: '不可为空', trigger: 'blur' },], @@ -183,7 +192,7 @@ export default { component: [{ required: true, trigger: "blur", message: "不可为空" }], }, editRule: { - componentQty: [{ required: true, message: '不可为空', type: "number", trigger: 'blur' },], + componentQty: [{ required: true, message: '不可为空', trigger: 'blur' },], componentUom: [{ required: true, message: '不可为空', trigger: 'blur' },], beginTime: [{ required: true, message: '不可为空', trigger: 'blur' },], endTime: [{ required: true, message: '不可为空', trigger: 'blur' },], @@ -223,6 +232,18 @@ export default { mounted () { this.paging(); }, + methods: { + // input下拉框 其他赋值处理 + selectDataPush(val) { + if (val[1].prop == "component") { + if (this.displayDialog.newDialog) { + this.CreateFormData.componentUom = val[0].basicUom + } else { + this.editFormData.componentUom = val[0].basicUom + } + } + }, + } };