searchExport: async function() {
this.$store.dispatch("showLoader");
let objP1 = {};
objP1.PartNumber = this.mdlPartNumber.trim();
objP1.CommentType = this.mdlCommentType.trim();
objP1.Pim = this.srchPim + "";
objP1.PimOwner = this.srchPimOnr + "";
objP1.Pbg = this.srchPbg + "";
objP1.GppOwner = this.srchGppOnr + "";
let obj = {};
obj.p1 = JSON.stringify(objP1);
obj.p2 = "";
obj.p3 = "";
obj.key = "cmnt_part_list_export";
obj.user = this.$store.state.LUser;
if (this.$store.state.LUser === "")
await this.$store.dispatch("loginUser");
await axios({
url: "Part/ExportCmntFile",
method: "POST",
data: obj,
responseType: "blob" // important
}).then(response => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", "Material_Comments.xlsx"); //or any other extension
document.body.appendChild(link);
link.click();
});
this.$store.dispatch("hideLoader");
},
templateExport: async function() {
this.$store.dispatch("showLoader");
let obj = {};
obj.p1 = "";
obj.p2 = "";
obj.p3 = "";
obj.key = "cmnt_template_export";
obj.user = this.$store.state.LUser;
if (this.$store.state.LUser === "")
await this.$store.dispatch("loginUser");
await axios({
url: "Part/GetTemplateExport",
method: "POST",
data: obj,
responseType: "blob" // important
}).then(response => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", "Material_Comments_Template.xlsx"); //or any other extension
document.body.appendChild(link);
link.click();
});
this.$store.dispatch("hideLoader");
},
uploadExport: async function() {
if(this.cmntFileData===null){
alert('Attachment required!');
return;
}
this.$store.dispatch("showLoader");
const fData = new FormData();
fData.append("file", this.cmntFileData);
fData.append("user", this.$store.state.LUser);
fData.append("configKey", "cmnt_load");
await axios({
method: "post",
url: "Part/cmntFileUpload",
data: fData,
headers: {
"Content-Type": "multipart/form-data",
fileName: this.fileName
}
})
.then(response => {
let res = response.data;
alert(res.Message);
this.cmntFileData = null;
this.$refs.cmntFileInput.value = null;
this.search();
})
.catch(function(err) {
console.log(err);
});
this.$store.dispatch("hideLoader");
}