| | |
| | | <div class="app-container"> |
| | | <div style="display: flex;justify-content: space-between"> |
| | | <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;" > |
| | | <el-form-item> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | | icon="Plus" |
| | | @click="openDialog('add',{})" |
| | | v-hasPermi="['innerReviewSheet:list:add']" |
| | | >新增</el-button> |
| | | </el-form-item> |
| | | <el-form-item v-if="isAdmin" label="企业:" > |
| | | <!-- <el-form-item>--> |
| | | <!-- <el-button--> |
| | | <!-- type="primary"--> |
| | | <!-- plain--> |
| | | <!-- icon="Plus"--> |
| | | <!-- @click="openDialog('add',{})"--> |
| | | <!-- v-hasPermi="['innerReviewSheet:list:add']"--> |
| | | <!-- >新增</el-button>--> |
| | | <!-- </el-form-item>--> |
| | | <el-form-item v-if="isAdmin" label="单位:" > |
| | | <el-select v-model="data.queryParams.companyId" placeholder="请选择" clearable> |
| | | <el-option |
| | | v-for="item in companyList" |
| | |
| | | <el-button v-if="isAdmin" type="primary" @click="getList">查询</el-button> |
| | | <el-button v-if="isAdmin" type="primary" plain @click="reset">重置</el-button> |
| | | </el-form-item> |
| | | <el-form-item style="margin-left: -20px"> |
| | | <el-button |
| | | type="primary" |
| | | @click="exportData" |
| | | >导出</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <!-- 表格数据 --> |
| | | <el-table v-loading="loading" :data="dataList" :border="true"> |
| | | <el-table-column type="index" label="序号"></el-table-column> |
| | | <el-table v-loading="loading" :data="dataList" :border="true" @selection-change="handleSelectionChange"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column type="index" align="center" label="序号" width="80"></el-table-column> |
| | | <el-table-column label="检查表" align="center"> |
| | | <template #default="scope"> |
| | | {{scope.row.deptName }}内审检查表 |
| | | {{scope.row.year}}年{{scope.row.deptName }}内审检查表 |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="受审核部门" prop="deptName" align="center"></el-table-column> |
| | | <el-table-column label="操作" align="center"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" @click="openDialog('review',scope.row)">查看</el-button> |
| | | <el-button link type="primary" @click="openDialog('edit',scope.row)" v-hasPermi="['innerReviewSheet:list:edit']">编辑</el-button> |
| | | <el-button link type="primary" @click="downloadFile(scope.row.id)">导出</el-button> |
| | | <el-button link type="danger" @click="handleDelete(scope.row)" v-hasPermi="['innerReviewSheet:list:del']">删除</el-button> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | const { proxy } = getCurrentInstance(); |
| | | const loading = ref(false); |
| | | const dialogRef = ref(); |
| | | const choosedData = ref([]) |
| | | const data = reactive({ |
| | | queryParams: { |
| | | pageNum: 1, |
| | |
| | | data.isAdmin = true |
| | | await getCompanyList() |
| | | }else{ |
| | | |
| | | data.isAdmin = false |
| | | data.queryParams.companyId = userStore.companyId |
| | | } |
| | |
| | | if(res.code == 200){ |
| | | data.dataList = res.data.list || [] |
| | | data.total = res.data.total |
| | | console.log('x',data.dataList) |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | |
| | | const downloadFile = async (id)=>{ |
| | | const res = await getInternalAuditCheckInfo({id: id}) |
| | | if(res.code == 200){ |
| | | if(res.data){ |
| | | let tableData = res.data |
| | | tableData.content = res.data.caluseNum.split('、').map((i,index)=>i + res.data.caluseContent.split(';\n')[index]).join('\n') |
| | | tableData.interPeople = res.data.internalAuditCheckPeople.map(i=>i.auditUserName) |
| | | try { |
| | | generateWordDocument('/interCheck.docx', tableData, tableData.deptName +'内审检查表.docx'); |
| | | } catch (error){ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '导出失败' |
| | | }); |
| | | } |
| | | }else{ |
| | | ElMessage.warning('暂无数据') |
| | | } |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | |
| | | const openFile = async(path)=>{ |
| | | const ext = path.split('.').pop().toLowerCase(); |
| | | if (ext === 'doc') { |
| | | ElMessageBox.confirm('暂不支持线上预览.doc文件,是否下载查看?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => { |
| | | window.open(`${import.meta.env.VITE_APP_BASE_API}/${path}`, '_blank'); |
| | | }).catch(() => { |
| | | console.log('取消预览') |
| | | }); |
| | | return |
| | | } |
| | | try { |
| | | // 1. 获取文件 |
| | | const response = await fetch(import.meta.env.VITE_APP_BASE_API + '/' + path); |
| | | const arrayBuffer = await response.arrayBuffer(); |
| | | // 2. 创建新窗口 |
| | | const win = window.open('', '_blank'); |
| | | win.document.write(` |
| | | <!DOCTYPE html> |
| | | <html> |
| | | <head> |
| | | <title>预览</title> |
| | | <style> |
| | | body { margin: 20px; font-family: Arial; } |
| | | .docx-container { width: 100%; height: 100%; } |
| | | </style> |
| | | </head> |
| | | <body> |
| | | <div id="container" class="docx-container"></div> |
| | | </body> |
| | | </html> |
| | | `); |
| | | // 3. 渲染 DOCX |
| | | await renderAsync(arrayBuffer, win.document.getElementById('container')); |
| | | |
| | | } catch (error) { |
| | | console.error('预览失败:', error); |
| | | alert(`预览失败: ${error.message}`); |
| | | } |
| | | } |
| | | |
| | | const openDialog = (type, value) => { |
| | | |
| | | dialogRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin, data.companyList); |
| | | } |
| | | |
| | |
| | | pageSize: 10, |
| | | companyId: null |
| | | } |
| | | choosedData.value = [] |
| | | await getCompanyList() |
| | | await getList() |
| | | } |
| | |
| | | } |
| | | }) |
| | | } |
| | | const handleSelectionChange = (val) => { |
| | | choosedData.value = val |
| | | } |
| | | const exportData = () => { |
| | | if(choosedData.value && choosedData.value.length === 0){ |
| | | ElMessage.warning('请选择需要导出的数据') |
| | | }else { |
| | | startGeneration() |
| | | } |
| | | } |
| | | const templatePath = ref('') |
| | | const startGeneration = async () => { |
| | | const data = JSON.parse(JSON.stringify(choosedData.value)) |
| | | data.forEach(item => { |
| | | templatePath.value = '/innerReviewExport.docx' |
| | | item.tableData = item.checkCatalogues.map((i,index) => { |
| | | return{ |
| | | ...i, |
| | | well: i.result == 1, |
| | | fine: i.result == 2, |
| | | bad: i.result == 3, |
| | | |
| | | } |
| | | }) |
| | | console.log('11',item.tableData) |
| | | item.checkTime = item.startTime +'-'+item.endTime.slice(11) |
| | | try { |
| | | generateWordDocument(templatePath.value, item, item.year+'年'+item.deptName+'_内审检查表.docx',['pointKey', 'find']); |
| | | } catch (error){ |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: '导出失败' |
| | | }); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | </script> |