hcong
2024-11-15 36c3a0fe4f6750891cb69f9622e141b2f74f38b9
src/views/fysp/data-product/ProdSceneReport.vue
@@ -13,21 +13,21 @@
    <template #main>
      <el-scrollbar class="el-scrollbar" v-loading="mainLoading">
        <CompSceneConstructionInfo
          v-if="curSubtask.data && curSubtask.data.sceneType == '工地'"
          v-if="curSubtask.data && curSubtask.data.sceneTypeId == 1"
          title="A、基本信息"
          :scene="formScene"
          :form-info="formSubScene"
          :scene-type="1"
        />
        <CompSceneWharfInfo
          v-else-if="curSubtask.data && curSubtask.data.sceneType == '码头'"
          v-else-if="curSubtask.data && curSubtask.data.sceneTypeId == 2"
          title="A、基本信息"
          :scene="formScene"
          :form-info="formSubScene"
          :scene-type="2"
        />
        <CompSceneMixingPlantInfo
          v-else-if="curSubtask.data && curSubtask.data.sceneType == '搅拌站'"
          v-else-if="curSubtask.data && curSubtask.data.sceneTypeId == 3"
          title="A、基本信息"
          :scene="formScene"
          :form-info="formSubScene"
@@ -94,7 +94,7 @@
    :max-select="1"
    :readonly="false"
    :subtask="curSubtask.data"
    @selectByAnyPhonoEvent="handleSelectAnyPhoto"
    @submit="handleSelectAnyPhoto"
    :defaultFile="[sceneImg]"
  >
  </ArbitraryPhoto>
@@ -113,7 +113,6 @@
</template>
<script setup>
import { ref, computed } from 'vue';
import { $fysp } from '@/api/index';
import taskApi from '@/api/fysp/taskApi';
import sceneApi from '@/api/fysp/sceneApi';
@@ -121,6 +120,7 @@
import evaluateApi from '@/api/fysp/evaluateApi';
import { formatDeviceList } from '@/model/fysp/device';
import { enumDevice, toLabel } from '@/enum/device/device';
import { enumScene } from '@/enum/scene';
import { exportDocx } from '@/utils/doc';
import right_triangle from '@/assets/image/right_triangle.png';
@@ -132,6 +132,7 @@
import CompImgInfo from '@/views/fysp/data-product/components/CompImgInfo.vue';
import CompProblemTable from './components/CompProblemTable.vue';
import dayjs from 'dayjs';
import { useCloned } from '@vueuse/core';
/************************* 左侧巡查任务选单 **********************************/
const curSubtask = ref({});
@@ -361,10 +362,33 @@
}
/************************* 生成报告 **********************************/
// 标准化属性名
function convertKeys(obj) {
  // 将一个js对象中所有w, mp, cs开头的属性全部改成去掉这些前缀并且重新变为驼峰式命名
  const newObj = {};
  for (const key in obj) {
    let newKey = key;
    if (key.startsWith('w')) {
      newKey = key.substring(1);
    } else if (key.startsWith('mp')) {
      newKey = key.substring(2);
    } else if (key.startsWith('cs')) {
      newKey = key.substring(2);
    }
    newKey = newKey.charAt(0).toLowerCase() + newKey.slice(1);
    newObj[newKey] = obj[key];
  }
  return newObj;
}
const docLoading = ref(false);
// 生成word报告
function genWord() {
  // 让原来的对象不受影响
  let formSceneCopy = ref(useCloned(formSubScene.value).cloned.value);
  // 标准化属性值
  let convertedFormScene = convertKeys(formSceneCopy.value);
  const _deviceList = [];
  for (let i = 0; i < deviceList.value.length; i += 2) {
    const d1 = deviceList.value[i];
@@ -381,21 +405,28 @@
  const param = {
    index: formScene.value.index,
    sceneName: formScene.value.name,
    projectType: formSubScene.value.csProjectType,
    stage: formSubScene.value.siExtension1,
    startTime: formSubScene.value.csStartTime,
    endTime: formSubScene.value.csEndTime,
    leftTime: formSubScene.value.csLeftTime,
    projectType: convertedFormScene.projectType,
    stage: convertedFormScene.siExtension1,
    startTime: convertedFormScene.startTime,
    endTime: convertedFormScene.endTime,
    leftTime: convertedFormScene.leftTime,
    location: formScene.value.location,
    floorSpace: formSubScene.value.csFloorSpace,
    constructionArea: formSubScene.value.csConstructionArea,
    constructionAreaPerMonth: formSubScene.value.csConstructionAreaPerMonth,
    floorSpace: convertedFormScene.floorSpace,
    constructionArea: convertedFormScene.constructionArea,
    constructionAreaPerMonth: convertedFormScene.constructionAreaPerMonth,
    contacts: formScene.value.contacts,
    contactst: formScene.value.contactst,
    securityOfficer: formSubScene.value.csSecurityOfficer,
    securityOfficerTel: formSubScene.value.csSecurityOfficerTel,
    constructionUnit: formSubScene.value.csConstructionUnit,
    employerUnit: formSubScene.value.csEmployerUnit,
    securityOfficer: convertedFormScene.securityOfficer,
    securityOfficerTel: convertedFormScene.securityOfficerTel,
    constructionUnit: convertedFormScene.constructionUnit,
    employerUnit: convertedFormScene.employerUnit,
    planningArea: convertedFormScene.planningArea,
    rentUnit: convertedFormScene.rentUnit,
    greenPlant: convertedFormScene.greenPlant,
    civillyPlant: convertedFormScene.civillyPlant,
    sceneType: formScene.value.type,
    imgTitle: imgTitle.value,
    imgTitle_url: sceneImg.value.url,
@@ -421,8 +452,14 @@
  console.log(param);
  docLoading.value = true;
  // 根据场景类型选择模板
  const sceneTypes = enumScene(2, false);
  const type = sceneTypes.filter(
    (item) => item.value == formScene.value.typeid
  )[0].label;
  const docxTemplatepath = `/单体模版(${type}).docx`;
  exportDocx(
    '/单体模版.docx',
    docxTemplatepath,
    param,
    `${param.sceneName}单体(${date}).docx`,
    {