|
@@ -139,13 +139,14 @@
|
|
|
>
|
|
|
|
|
|
<el-button
|
|
|
- icon="el-icon-setting"
|
|
|
- text
|
|
|
- @click="exportDataZip(row.id)"
|
|
|
- type="primary"
|
|
|
- v-if="row.workOrderState === '6'"
|
|
|
- :size="size"
|
|
|
- >生产数据包</el-button>
|
|
|
+ icon="el-icon-setting"
|
|
|
+ text
|
|
|
+ @click="exportDataZip(row.id)"
|
|
|
+ type="primary"
|
|
|
+ v-if="row.workOrderState === '6'"
|
|
|
+ :size="size"
|
|
|
+ >生产数据包</el-button
|
|
|
+ >
|
|
|
|
|
|
<!-- <el-button
|
|
|
icon="el-icon-notebook"
|
|
@@ -356,31 +357,30 @@ const showProExcel = async (id) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-const exportDataZip = async(id) => {
|
|
|
- const data=await exportDataInfo(1,id);
|
|
|
- console.log(data,'22')
|
|
|
- // if(code !== '200'){
|
|
|
- // ElMessage.error(msg);
|
|
|
- // }else{
|
|
|
- // downFile(data);
|
|
|
- // }
|
|
|
- // exportDataInfo(1,id).then((response) => {
|
|
|
- // if(response.data.code !== '200'){
|
|
|
- // console.log(JSON.stringify(response))
|
|
|
- // ElMessage.error(response.data.msg);
|
|
|
- // }else{
|
|
|
- // downFile(response);
|
|
|
- // }
|
|
|
- // });
|
|
|
+const exportDataZip = async (id) => {
|
|
|
+ exportDataInfo(1, id).then((response) => {
|
|
|
+ console.log(response);
|
|
|
+ try {
|
|
|
+ const decoder = new TextDecoder("utf-8");
|
|
|
+ const jsonString = decoder.decode(response.data);
|
|
|
+ const jsonObject = JSON.parse(jsonString);
|
|
|
+ const { code, msg } = jsonObject;
|
|
|
+ if (code != "200") {
|
|
|
+ ElMessage.error(msg);
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ downFile(response);
|
|
|
+ }
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
const downFile = (response) => {
|
|
|
const fileData = response.data;
|
|
|
const fileName = decodeURI(
|
|
|
- response.headers["content-disposition"].split(";")[1].split("=")[1]
|
|
|
+ response.headers["content-disposition"].split(";")[1].split("=")[1]
|
|
|
);
|
|
|
const fileType =
|
|
|
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8";
|
|
|
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8";
|
|
|
const blob = new Blob([fileData], { type: fileType });
|
|
|
const downloadUrl = window.URL.createObjectURL(blob);
|
|
|
const downloadLink = document.createElement("a");
|