| | |
| | | @click="openDialog('add',{})" |
| | | >新增</el-button> |
| | | </el-form-item> |
| | | <el-form-item v-if="isAdmin" label="企业:" > |
| | | <el-form-item v-if="isAdmin" label="单位:" > |
| | | <el-select v-model="data.queryParams.companyId" placeholder="请选择" clearable> |
| | | <el-option |
| | | v-for="item in companyList" |
| | |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="文件名称:" > |
| | | <el-input v-model.trim="data.queryParams.templateName" placeholder="文件名称"></el-input> |
| | | </el-form-item> |
| | | <el-form-item > |
| | | <el-button v-if="isAdmin" type="primary" @click="getList">查询</el-button> |
| | | <el-button v-if="isAdmin" type="primary" plain @click="reset">重置</el-button> |
| | | <el-button type="primary" @click="getList">查询</el-button> |
| | | <el-button type="primary" plain @click="reset">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </div> |
| | | <!-- 表格数据 --> |
| | | <el-table v-loading="loading" :data="dataList" :border="true"> |
| | | <el-table v-loading="loading" :data="dataList" :border="true" @sort-change="handleSortChange"> |
| | | <el-table-column label="序号" type="index" align="center" width="80"/> |
| | | <el-table-column label="模板名称" prop="templateName" align="center"/> |
| | | <el-table-column label="模板文件" align="center"> |
| | | <el-table-column label="阶段" prop="stage" header-align="center" align="left"/> |
| | | <el-table-column label="模板名称" prop="templateName" header-align="center" align="left" sortable="custom"/> |
| | | <el-table-column label="模板文件" header-align="center" align="left"> |
| | | <template #default="scope"> |
| | | <el-button link type="primary" @click="downloadFile(scope.row.filePath)">{{scope.row.templateName + '模板'}}</el-button> |
| | | <el-link type="primary" @click="openFile(scope.row.filePath)">{{scope.row.templateName + '模板' + scope.row.format}}</el-link> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="行业" prop="industryTypeName" header-align="center" align="left"/> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width" > |
| | | <template #default="scope"> |
| | | <el-button link type="primary" @click="downloadFile(scope.row.filePath)">下载</el-button> |
| | | <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button> |
| | | <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button> |
| | | </template> |
| | |
| | | import editDialog from './components/editDialog.vue' |
| | | import useUserStore from "@/store/modules/user"; |
| | | import {getStandardTemp,delStandardTemp} from "@/api/standardSys/standardSys"; |
| | | import { renderAsync } from "docx-preview"; |
| | | |
| | | |
| | | const userStore = useUserStore() |
| | | const { proxy } = getCurrentInstance(); |
| | | const loading = ref(false); |
| | |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | companyId: null, |
| | | templateName:'', |
| | | sort:null, |
| | | templateType: 3 |
| | | }, |
| | | total: 0, |
| | |
| | | loading.value = true |
| | | const res = await getStandardTemp(data.queryParams) |
| | | if(res.code == 200){ |
| | | console.log(res.data,'data') |
| | | data.dataList = res.data.list || [] |
| | | data.total = res.data.total |
| | | }else{ |
| | |
| | | window.open(import.meta.env.VITE_APP_BASE_API + '/' + path) |
| | | } |
| | | |
| | | const openFile = async(path)=>{ |
| | | const ext = path.split('.').pop().toLowerCase(); |
| | | if (ext === 'doc' || ext === 'xlsx' || ext === 'xls') { |
| | | ElMessageBox.confirm('暂不支持线上预览.doc文件,是否下载查看?', '提示', { confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning' }).then(() => { |
| | | window.open(`${import.meta.env.VITE_APP_BASE_API}/${path}`, '_blank'); |
| | | }).catch(() => { |
| | | console.log('取消预览') |
| | | }); |
| | | return |
| | | }else if(ext === 'pdf'){ |
| | | window.open(`${import.meta.env.VITE_APP_BASE_API}/${path}`, '_blank'); |
| | | }else{ |
| | | 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); |
| | | } |
| | | |
| | | /** 重置新增的表单以及其他数据 */ |
| | | const reset= async()=> { |
| | | data.queryParams = { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | companyId: null, |
| | | templateType: 3 |
| | | if(data.isAdmin){ |
| | | data.queryParams = { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | companyId: null, |
| | | templateName:'', |
| | | sort:data.queryParams.sort, |
| | | templateType: 3 |
| | | } |
| | | await getCompanyList() |
| | | }else { |
| | | data.queryParams = { |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | companyId: data.queryParams.companyId, |
| | | templateName:'', |
| | | sort:data.queryParams.sort, |
| | | templateType: 3 |
| | | } |
| | | } |
| | | await getCompanyList() |
| | | |
| | | await getList() |
| | | } |
| | | const handleDelete = (val) => { |
| | |
| | | } |
| | | }) |
| | | } |
| | | const handleSortChange = (val) => { |
| | | console.log('bal',val) |
| | | if(val.order === 'ascending' ){ |
| | | data.queryParams.sort = 1 |
| | | }else if(val.order === "descending" ){ |
| | | data.queryParams.sort = 2 |
| | | } |
| | | getList() |
| | | } |
| | | |
| | | </script> |