祖安之光
2 天以前 b7ebccdbc4f29cc7663582213886579091c84dd5
src/views/build/conpanyFunctionConsult/digitalFileDep/manageType/qualityManual/index.vue
@@ -32,17 +32,18 @@
      <el-table-column label="序号" type="index" align="center" width="80"/>
      <el-table-column label="质量手册" prop="fileName" align="center">
        <template #default="scope">
          <el-button link type="primary" @click="initFile()">{{scope.row.companyName + scope.row.qualityName + '.docx'}}</el-button>
          <el-button link type="primary" @click="initFile(scope.row.companyName)">{{scope.row.companyName + scope.row.qualityName + '.docx'}}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
<!--          <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button>-->
          <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
<!--    <org-tree :data="companyInfo.deptList" />-->
    <button @click="exportOrgChart">导出组织架构图</button>
    <pagination
        v-show="total > 0"
        :total="total"
@@ -50,8 +51,6 @@
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />
    <edit-dialog ref="dialogRef" @getList=getList></edit-dialog>
  </div>
</template>
@@ -59,17 +58,10 @@
import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import {delCompany, getCompany} from "@/api/onlineEducation/company";
import {delUser, getUser} from "@/api/onlineEducation/user";
import Cookies from "js-cookie";
import editDialog from './components/editDialog.vue'
import {generateWordDocument} from './components/exportDoc.js'
import {
  addIndustryTemp,
  delIndustryTemp,
  getIndustryTemp,
} from "@/api/staffManage/staff";
// import OrgTree from 'vue-org-tree'
import html2canvas from 'html2canvas'
import { saveAs } from 'file-saver'
import useUserStore from "@/store/modules/user";
import {
  addStandardQuality,
@@ -77,8 +69,6 @@
  getStandardDetail,
  getStandardQuality
} from "@/api/standardSys/standardSys";
import {getBasic} from "@/api/companyInfo/basicInfo";
import {getCom} from "@/api/companyInfo/overview";
const userStore = useUserStore()
const { proxy } = getCurrentInstance();
@@ -126,7 +116,7 @@
  ]
});
const { queryParams, total, dataList,companyList, isAdmin } = toRefs(data);
const { queryParams, total, dataList,companyList, isAdmin, companyInfo } = toRefs(data);
const userInfo = ref()
onMounted(async ()=>{
  if(userStore.roles.includes('admin')){
@@ -142,6 +132,27 @@
onUnmounted(()=>{
})
const exportOrgChart=()=> {
  const element = document.querySelector('.org-tree'); // 获取组织架构图的容器元素
  html2canvas(element).then(canvas => {
    // 创建一个图片元素
    let img = new Image();
    img.src = canvas.toDataURL('image/png');
    // 创建并触发下载
    img.onload = () => {
      let w = img.width;
      let h = img.height;
      let canvas2 = document.createElement('canvas');
      let ctx = canvas2.getContext('2d');
      canvas2.width = w;
      canvas2.height = h;
      ctx.drawImage(img, 0, 0, w, h);
      saveAs(canvas2.toDataURL('image/png'), '组织架构图.png');
    };
  });
}
const getList = async () => {
  loading.value = true
@@ -241,19 +252,19 @@
  return tableData
}
const initFile = async () => {
const initFile = async (name) => {
  await getInfo()
  const templatePath = '/qualityFile.docx'
  try {
    await generateWordDocument(
        templatePath,
        data.companyInfo,
        '质量手册.docx'
        name+'质量手册.docx'
    );
    ElMessage.success('文档生成成功!');
    ElMessage.success('手册导出成功!');
  } catch (error) {
    console.error('导出失败:', error);
    ElMessage.warning('文档生成失败');
    ElMessage.warning('手册导出失败');
  }
}