| | |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <!-- <el-form-item label="文件类型:" >--> |
| | | <!-- <el-select v-model="data.queryParams.knowledgeType" placeholder="请选择" clearable>--> |
| | | <!-- <el-option--> |
| | | <!-- v-for="item in typeList"--> |
| | | <!-- :key="item.id"--> |
| | | <!-- :label="item.name"--> |
| | | <!-- :value="item.id">--> |
| | | <!-- </el-option>--> |
| | | <!-- </el-select>--> |
| | | <!-- </el-form-item>--> |
| | | <el-form-item > |
| | | <el-button type="primary" @click="getList">查询</el-button> |
| | | <el-button type="primary" plain @click="reset">重置</el-button> |
| | | <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="exportInData">导入</el-button> |
| | | <vue3-json-excel |
| | | :json-data="expertData" |
| | | :fields="fields" |
| | |
| | | </el-table-column> |
| | | <el-table-column label="文件" prop="filePath" align="center"> |
| | | <template #default="scope"> |
| | | <el-link style="" type="primary" @click="openFile(scope.row.filePath)">{{scope.row.name}}</el-link> |
| | | <el-link v-if="scope.row.filePath && scope.row.filePath !== ''" style="" type="primary" @click="openFile(scope.row.filePath)">{{scope.row.name}}</el-link> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="上传日期" prop="updateTime" align="center" /> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width" > |
| | | <template #default="scope"> |
| | | <el-button link type="primary" @click="downloadFile(scope.row)">下载</el-button> |
| | | <el-button link type="primary" :disabled="!scope.row.filePath || scope.row.filePath == ''" @click="downloadFile(scope.row)">下载</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> |
| | |
| | | v-model:limit="queryParams.pageSize" |
| | | @pagination="getList" |
| | | /> |
| | | |
| | | <el-dialog |
| | | v-model="state.exportDialog" |
| | | title="导入模板" |
| | | width="550px" |
| | | :before-close="handleCloseExport" |
| | | :close-on-press-escape="false" |
| | | :close-on-click-modal="false" |
| | | > |
| | | <el-form :model="state.form" size="default" ref="superRef" :rules="state.formRules" label-width="110px" > |
| | | <el-form-item label="企业名称:" v-if="data.isAdmin" style="margin-left: 20px" prop="companyId"> |
| | | <el-select v-model="state.form.companyId" filterable placeholder="请选择" clearable> |
| | | <el-option |
| | | v-for="item in data.companyList" |
| | | :key="item.id" |
| | | style="width: 100%" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="表格模板:"> |
| | | <el-button @click="downloadFileTable" size="default" :icon="Download" type="primary" plain>下载模板</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="导入文件" prop="filePath"> |
| | | <el-upload |
| | | accept=".xlsx,.xls" |
| | | :before-upload="beforeUpload" |
| | | v-model:file-list="state.exportFileList" |
| | | action="#" |
| | | :auto-upload="false" |
| | | :on-change="handleChange" |
| | | style="width: 100%" |
| | | > |
| | | <el-button :icon="Upload" size="default" type="primary">点击上传</el-button> |
| | | </el-upload> |
| | | </el-form-item> |
| | | </el-form> |
| | | <template #footer> |
| | | <span class="dialog-footer"> |
| | | <el-button @click="handleCloseExport" size="default">取 消</el-button> |
| | | <el-button type="primary" @click="onUpload" size="default">导入</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | <edit-dialog ref="dialogRef" @getList=getList></edit-dialog> |
| | | </div> |
| | | </template> |
| | |
| | | delExternalKnowledge, |
| | | delInternalKnowledge, |
| | | getExternalKnowledgeList, |
| | | getInternalKnowledgeList |
| | | getInternalKnowledgeList, uploadExternalKnowledge, uploadInternalKnowledge |
| | | } from "@/api/assetManage/assetMng"; |
| | | import {getStandingBookList} from "@/api/infrastructureMng/ledger"; |
| | | const userStore = useUserStore() |
| | |
| | | dataList: [], |
| | | companyList: [], |
| | | isAdmin: false, |
| | | expertData: [] |
| | | expertData: [], |
| | | typeList: [ |
| | | { |
| | | id: 1, |
| | | name: '标准' |
| | | }, |
| | | { |
| | | id: 2, |
| | | name: '规范' |
| | | }, |
| | | { |
| | | id: 3, |
| | | name: '法律法规' |
| | | }, |
| | | { |
| | | id: 4, |
| | | name: '其他' |
| | | } |
| | | ] |
| | | }); |
| | | |
| | | const { queryParams, total, dataList,companyList,isAdmin, expertData } = toRefs(data); |
| | | const checkFiles = (rule, value, callback) => { |
| | | if (state.exportFileList.length == 0) { |
| | | callback(new Error('请上传导入文件')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | const state = reactive({ |
| | | form: { |
| | | id: null, |
| | | filePath: '', |
| | | companyId: null |
| | | }, |
| | | exportDialog: false, |
| | | formRules:{ |
| | | companyId: [{ required: true, message: '请选择企业', trigger: 'blur' }], |
| | | filePath: [{ required: true, validator: checkFiles, trigger: 'blur' }] |
| | | }, |
| | | exportFileList: [], |
| | | }) |
| | | const superRef = ref(); |
| | | const { queryParams, total, dataList,companyList,isAdmin, expertData, typeList } = toRefs(data); |
| | | const userInfo = ref() |
| | | onMounted(async ()=>{ |
| | | if(userStore.roles.includes('admin')){ |
| | |
| | | }else{ |
| | | data.isAdmin = false |
| | | data.queryParams.companyId = userStore.companyId |
| | | state.form.companyId = userStore.companyId |
| | | } |
| | | await getList() |
| | | }) |
| | |
| | | }) |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | | } |
| | | |
| | | const exportInData = () => { |
| | | state.exportDialog = true |
| | | } |
| | | |
| | | const handleCloseExport = () => { |
| | | getList() |
| | | state.exportFileList = [] |
| | | state.exportDialog = false |
| | | } |
| | | const beforeUpload = (file) => { |
| | | state.exportFileList = [...state.exportFileList, file] |
| | | state.exportFileList = state.exportFileList.slice(-1) |
| | | return false; |
| | | } |
| | | const downloadFileTable = () => { |
| | | const filePath = '/internalKnowledgeFile.xls'; |
| | | const link = document.createElement('a'); |
| | | link.href = filePath; |
| | | link.download = filePath.substr(filePath.lastIndexOf('/') + 1); |
| | | link.click(); |
| | | } |
| | | const fileBinaryList = ref([]) |
| | | const handleChange = (file, files) => { |
| | | fileBinaryList.value = files; |
| | | }; |
| | | |
| | | const onUpload = async () => { |
| | | const valid = await superRef.value.validate() |
| | | if(valid){ |
| | | const formData = new FormData(); |
| | | fileBinaryList.value.forEach((file) => { |
| | | formData.append('file', file.raw) |
| | | }) |
| | | formData.append('companyId', state.form.companyId) |
| | | uploadExternalKnowledge(formData).then(async (res) => { |
| | | if(res.code == 200){ |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '导入成功' |
| | | }) |
| | | superRef.value.clearValidate(); |
| | | superRef.value.resetFields() |
| | | state.exportFileList = [] |
| | | state.exportDialog = false |
| | | await getList() |
| | | }else{ |
| | | ElMessage({ |
| | | type: 'error', |
| | | message: res.message |
| | | }); |
| | | } |
| | | }).catch(async () =>{ |
| | | state.exportFileList = [] |
| | | state.exportDialog = false |
| | | await getList() |
| | | }) |
| | | }else{ |
| | | ElMessage.warning('请完善信息') |
| | | } |
| | | } |
| | | |
| | |
| | | /** 重置新增的表单以及其他数据 */ |
| | | const reset= async()=> { |
| | | data.queryParams = { |
| | | ...data.queryParams, |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | companyId: null |
| | | pageSize: 10 |
| | | } |
| | | await getCompanyList() |
| | | await getList() |