|
@@ -9,6 +9,7 @@ import {
|
|
|
saveExcelTemplate,
|
|
|
updateExcelTemplate,
|
|
|
} from "@/api/project/template";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
|
|
|
const excelRef = ref(null);
|
|
|
const excelData = ref(null);
|
|
@@ -36,12 +37,23 @@ const onOpenTemplate = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-const onExportTemplate = () => {
|
|
|
- console.log(excelRef.value);
|
|
|
- if (excelRef.value) {
|
|
|
- excelRef.value.downloadExcel();
|
|
|
+const onExportTemplate = (code) => {
|
|
|
+ if (currentCode.value != code) {
|
|
|
+ ElMessage.warning("只能导出当前预览的模版");
|
|
|
+ }
|
|
|
+
|
|
|
+ let item = productList.value.find(
|
|
|
+ (item) => item.id === formData.engineeringId
|
|
|
+ );
|
|
|
+ if (item) {
|
|
|
+ let exportName = `${item.engineeringProductName}-${code}`;
|
|
|
+
|
|
|
+ if (excelRef.value) {
|
|
|
+ excelRef.value.downloadExcel(exportName);
|
|
|
+ } else {
|
|
|
+ ElMessage.warning("请先预览模版");
|
|
|
+ }
|
|
|
}
|
|
|
- console.log("onExportTemplate");
|
|
|
};
|
|
|
|
|
|
// ===== 右侧区域 =======
|
|
@@ -74,6 +86,7 @@ const proRemoteMethod = (query: string) => {
|
|
|
});
|
|
|
};
|
|
|
const onProductChange = (val) => {
|
|
|
+ console.log("onProductChange", val);
|
|
|
getProductCodeListById(formData.engineeringId).then((res) => {
|
|
|
codeAllList.value = res.data;
|
|
|
codeList.value = codeAllList.value;
|
|
@@ -97,8 +110,10 @@ const onSearchTestingData = async () => {
|
|
|
};
|
|
|
|
|
|
// 预览魔板
|
|
|
+const currentCode = ref("");
|
|
|
const previewExcel = (code) => {
|
|
|
excelData.value = null;
|
|
|
+ currentCode.value = code;
|
|
|
previewExcelTemplateData({
|
|
|
excelFormId: currentTemplate.value?.id || null,
|
|
|
productCode: code,
|
|
@@ -181,7 +196,7 @@ onMounted(() => {
|
|
|
<svg-icon
|
|
|
icon-class="downloadExcel"
|
|
|
size="20"
|
|
|
- @click.stop="onExportTemplate"
|
|
|
+ @click.stop="onExportTemplate(log.productCode)"
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|