Browse Source

报告模版 回显示excel。

jiaxiaoqiang 4 months ago
parent
commit
057e865ab5

+ 8 - 0
src/api/project/template.ts

@@ -65,3 +65,11 @@ export function updateExcelTemplate(data: any = {}): AxiosPromise<any> {
     data: data,
   });
 }
+
+// 获取excel表单详情
+export function getExcelTemplateDetail(id: string): AxiosPromise<any> {
+  return request({
+    url: `/api/v1/test/excelForm/get/${id}`,
+    method: "get",
+  });
+}

+ 1 - 1
src/components/ExcelView/index.vue

@@ -145,7 +145,7 @@ const resetOb = ref({
     cellMousedown: function (cell, position, sheetIndex) {
       positionVal.value.x = position.c;
       positionVal.value.y = position.r;
-      console.log(positionVal.value, "222");
+      // console.log(positionVal.value, "222");
       selectCellValue.value = window.luckysheet.getCellValue(
         position.c,
         position.r,

File diff suppressed because it is too large
+ 721 - 721
src/views/modules/project-config/configs/properites.ts


+ 7 - 2
src/views/modules/report-template/com/templateList.vue

@@ -1,5 +1,5 @@
 <script lang="ts" setup>
-import { getExcelList } from "@/api/project/template";
+import { getExcelList, getExcelTemplateDetail } from "@/api/project/template";
 
 const emits = defineEmits(["close", "selected"]);
 
@@ -10,6 +10,11 @@ const openDrawer = async () => {
   dataList.value = res.data;
 };
 
+const onClickChoose = async (row: any) => {
+  let res = await getExcelTemplateDetail(row.id);
+  emits("selected", res.data);
+};
+
 defineExpose({
   openDrawer,
 });
@@ -43,7 +48,7 @@ defineExpose({
             text
             size="small"
             type="primary"
-            @click="emits('selected', scope.row)"
+            @click="onClickChoose(scope.row)"
           >
             选择
           </el-button>

+ 18 - 7
src/views/modules/report-template/report-template.vue

@@ -10,6 +10,7 @@ import {
 } from "@/api/project/template";
 
 const excelRef = ref(null);
+const excelData = ref(null);
 
 // 打开模版
 const temsDrawerVisible = ref(false);
@@ -18,9 +19,16 @@ const currentTemplate = ref(null);
 const onSelectTemplate = (tem) => {
   currentTemplate.value = tem;
   temsDrawerVisible.value = false;
+
   formData.engineeringId = tem.engineeringId;
   formData.formName = tem.formName;
   formData.productCode = tem.productCode;
+  // 如果有值 并且是json字符串 则解析
+  excelData.value = null;
+  if (tem.excelData) {
+    excelData.value = JSON.parse(tem.excelData);
+  }
+  console.log("返回的exccel数据", excelData.value);
   getProductCodeListById(formData.engineeringId).then((res) => {
     codeAllList.value = res.data;
     codeList.value = codeAllList.value;
@@ -111,6 +119,7 @@ const onSaveTemplate = async () => {
 
   const res = excelRef.value.getExcelData();
 
+  console.log("保存的exccel数据", res);
   let p = {
     excelData: JSON.stringify(res),
     ...formData,
@@ -126,6 +135,7 @@ const onSaveTemplate = async () => {
   formRef.value && formRef.value.resetFields();
   currentTemplate.value = null;
 
+  excelData.value = null;
   ElMessage.success("保存成功");
 };
 
@@ -141,12 +151,13 @@ const onSearchTestingData = async () => {
 };
 // 点击测试数据的写入
 const onWriteTestingData = (item) => {
-  let toWriteValue = `{{${item.dataItem}}`; //{{温度}
-  console.log(
-    "onWriteTestingData",
-    toWriteValue,
-    excelRef.value.selectCellValue
-  );
+  let toWriteValue = `{{${item.dataItem}&${item.engineeringProjectId}}}`; //{{温度}
+  excelRef.value.setCellValue(toWriteValue);
+  // console.log(
+  //   "onWriteTestingData",
+  //   toWriteValue,
+  //   excelRef.value.setCellValue
+  // );
 };
 
 onMounted(() => {
@@ -186,7 +197,7 @@ onMounted(() => {
         </div>
       </div>
       <div class="excel-container">
-        <ExcelView ref="excelRef" />
+        <ExcelView ref="excelRef" v-if="excelData" :data="excelData" />
       </div>
     </div>
     <div class="right">