| | |
| | | { |
| | | "name": "ruoyi", |
| | | "version": "3.8.6", |
| | | "description": "智慧安评", |
| | | "description": "新疆维吾尔自治区智慧安评服务平台", |
| | | "author": "若依", |
| | | "license": "MIT", |
| | | "scripts": { |
| | |
| | | "@wangeditor/editor-for-vue": "^5.1.12", |
| | | "@wangeditor/plugin-upload-attachment": "^1.1.0", |
| | | "axios": "0.27.2", |
| | | "docxtemplater": "^3.60.2", |
| | | "echarts": "5.4.0", |
| | | "element-plus": "2.2.27", |
| | | "file-saver": "2.0.5", |
| | |
| | | "js-base64": "^3.7.5", |
| | | "js-cookie": "3.0.1", |
| | | "jsencrypt": "3.3.1", |
| | | "jszip-utils": "^0.1.0", |
| | | "nprogress": "0.2.0", |
| | | "pinia": "2.0.22", |
| | | "pizzip": "^3.1.8", |
| | | "quill": "^2.0.0-dev.3", |
| | | "tinymce": "^5.10.2", |
| | | "vue": "3.2.45", |
| | |
| | | }) |
| | | } |
| | | |
| | | export function getProjectDetail(data) { |
| | | return request({ |
| | | url: '/manage/project/detail/' + data, |
| | | method: 'get' |
| | | |
| | | }) |
| | | } |
| | | |
| | | |
| | | export function getProjectStatistics(params) { |
| | | return request({ |
| | | url: '/manage/project/statistics', |
| | |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-form> |
| | | <div style="display: flex;margin-top: 25px;"> |
| | | <el-button type="primary" style="margin-right: 20px" @click="exportWord">导出从业告知书word</el-button> |
| | | <el-upload |
| | | style="margin-top: 25px;width: 250px" |
| | | style="width: 250px" |
| | | :disabled="projectType === 'view' || isEnd" |
| | | accept=".pdf" |
| | | :action="state.uploadUrl" |
| | |
| | | </template> |
| | | </el-upload> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | <script setup> |
| | | |
| | | import {defineEmits, defineProps, onMounted, reactive, ref, watchEffect} from "vue" |
| | | import {generateWordDocument} from "@/views/safetyReview/projectManage/components/exportWord"; |
| | | import {ElMessage, ElMessageBox} from "element-plus" |
| | | import {Search} from '@element-plus/icons-vue' |
| | | import {addWorkRecord, editWorkRecord, getWorkDetail} from "@/api/projectManage/employNoticeRcd" |
| | |
| | | import { useRoute } from 'vue-router' |
| | | import {getToken} from "@/utils/auth"; |
| | | import {getFiles} from "@/api/projectManage/siteCheckRcd"; |
| | | import {delAccessoryFile} from "@/api/projectManage/project"; |
| | | import {delAccessoryFile, getProjectDetail} from "@/api/projectManage/project"; |
| | | import axios from "axios"; |
| | | const route = useRoute() |
| | | const state = reactive({ |
| | |
| | | if(props.projectId){ |
| | | getWorksList(props.projectId) |
| | | getProcessFiles(props.projectId); |
| | | getPDetail(props.projectId) |
| | | } |
| | | isEnd.value = Cookies.get('end') |
| | | |
| | |
| | | const url = file.url |
| | | window.open(url) |
| | | } |
| | | |
| | | const templatePath = '/example.docx' |
| | | const exportWord = async () => { |
| | | const data = state.formData |
| | | for (let key in projectDeatil.value) { |
| | | if (projectDeatil.value.hasOwnProperty(key)) { |
| | | if(key != 'agency') |
| | | data[key] = projectDeatil.value[key]; |
| | | } |
| | | } |
| | | const agencyInfo = projectDeatil.value.agency |
| | | for (let key in agencyInfo) { |
| | | if (agencyInfo.hasOwnProperty(key)) { |
| | | if(key != 'address' && key != 'name' ) |
| | | data[key] = agencyInfo[key]; |
| | | } |
| | | } |
| | | data.leaderName = projectDeatil.value.leader.name |
| | | data.leaderPhone = projectDeatil.value.leader.phone |
| | | |
| | | data.type = '安全评价' |
| | | data.to = data.city + '应急管理局' |
| | | data.notice = '系统告知' |
| | | data.investigationPlanDate = state.formData.investigationPlanDate.substring(0,10) |
| | | data.serviceStartDate = state.formData.serviceStartDate.substring(0,10) |
| | | data.serviceEndDate = state.formData.serviceEndDate.substring(0,10) |
| | | data.tableData = state.planPersons.map(item => { |
| | | return { |
| | | ...item, |
| | | name: item.person.name |
| | | } |
| | | }) |
| | | console.log('res',data) |
| | | const date = new Date() |
| | | const options = { |
| | | year: 'numeric', |
| | | month: '2-digit', |
| | | day: '2-digit' |
| | | } |
| | | data.time = date.toLocaleDateString('zh-CN',options).replace(/\//g, '年') |
| | | .replace(/年(\d{2})年/, '年$1月') |
| | | .replace(/月(\d{2})$/, '月$1日') |
| | | try { |
| | | generateWordDocument(templatePath, data, '从业告知书.docx'); |
| | | } catch (error){ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '失败' |
| | | }); |
| | | } |
| | | } |
| | | |
| | | const projectDeatil = ref() |
| | | const getPDetail = async (val) => { |
| | | const res = await getProjectDetail(val) |
| | | if(res.code == 200){ |
| | | projectDeatil.value = res.data |
| | | |
| | | }else { |
| | | ElMessage.warning(res.message) |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | defineExpose({ |
| | | riskOpen |
| | | }); |
对比新文件 |
| | |
| | | //引入工具 |
| | | import PizZip from 'pizzip'; |
| | | import Docxtemplater from 'docxtemplater'; |
| | | import JSZipUtils from 'jszip-utils'; |
| | | import { saveAs } from 'file-saver'; |
| | | |
| | | // 加载 .docx 模板文件 |
| | | function loadFile(url, callback) { |
| | | JSZipUtils.getBinaryContent(url, callback); |
| | | } |
| | | |
| | | // 下载生成的文档 |
| | | export function download(file, name) { |
| | | |
| | | } |
| | | |
| | | // 生成并下载 Word 文档(templatePath是word文档模版地址,data是对应的数据) |
| | | export function generateWordDocument(templatePath, data, name) { |
| | | loadFile(templatePath, function (error, content) { |
| | | if (error) { |
| | | throw error |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | // 加载模板文件内容到 PizZip |
| | | const zip = new PizZip(content); |
| | | const doc = new Docxtemplater(zip, { |
| | | paragraphLoop: true, |
| | | linebreaks: true, |
| | | }); |
| | | |
| | | // 设置模板中的占位符数据 |
| | | doc.setData(data); |
| | | |
| | | // 渲染文档 |
| | | doc.render(); |
| | | |
| | | // 生成最终的文档 Blob |
| | | const fileWord = doc.getZip().generate({ |
| | | type: 'blob', |
| | | mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
| | | }); |
| | | |
| | | saveAs(fileWord, name); |
| | | |
| | | // // 返回生成的文档 Blob |
| | | // resolve(fileWord); |
| | | } catch (error) { |
| | | console.error('Error rendering document:', error); |
| | | throw error |
| | | } |
| | | }); |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | const getArea = async ()=>{ |
| | | const type = 1 |
| | | const type = 0 |
| | | const res = await getRegionTree({name: '',parentId: null,regionType: type}) |
| | | if(res.code == 200){ |
| | | state.addressList = res.data |
| | | const data = res.data.map(item => { |
| | | return { |
| | | ...item, |
| | | children: null |
| | | } |
| | | }) |
| | | const area = { |
| | | id: 469, |
| | | name: "新疆维吾尔自治区", |
| | | children: data |
| | | } |
| | | state.addressList = [area] |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |