From 92ba3755f447d1c4f12b476d44552decc5ed3b62 Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: Thu, 03 Jul 2025 14:07:49 +0800
Subject: [PATCH] 修改新增
---
src/views/build/conpanyFunctionConsult/industryTemplate/index.vue | 81 +++++++++++++++++++++++++---------------
1 files changed, 50 insertions(+), 31 deletions(-)
diff --git a/src/views/build/conpanyFunctionConsult/industryTemplate/index.vue b/src/views/build/conpanyFunctionConsult/industryTemplate/index.vue
index 19c1ef3..632ba9c 100644
--- a/src/views/build/conpanyFunctionConsult/industryTemplate/index.vue
+++ b/src/views/build/conpanyFunctionConsult/industryTemplate/index.vue
@@ -20,10 +20,14 @@
</el-option>
</el-select>
</el-form-item>
- <el-form-item v-if="isAdmin" label="行业:" >
- <el-select v-model="data.queryParams.companyId" placeholder="请选择" clearable>
- <el-option key="1" label="化工" :value="1"></el-option>
- <el-option key="2" label="安防" :value="2"></el-option>
+ <el-form-item label="行业:" >
+ <el-select v-model="data.queryParams.industryType" placeholder="请选择" clearable>
+ <el-option
+ v-for="item in industryList"
+ :key="item.id"
+ :label="item.name"
+ :value="item.id">
+ </el-option>
</el-select>
</el-form-item>
<el-form-item >
@@ -36,14 +40,10 @@
<el-table v-loading="loading" :data="dataList" :border="true">
<el-table-column label="序号" type="index" align="center" width="80"/>
<el-table-column label="模板名称" prop="templateName" align="center"/>
- <el-table-column label="行业" prop="industryType" align="center">
- <template #default="scope">
- {{getName(scope.row.industryType)}}
- </template>
- </el-table-column>
+ <el-table-column label="行业" prop="industryName" align="center" />
<el-table-column label="模板文件" prop="fileName" align="center">
<template #default="scope">
- <el-button link type="primary" @click="downloadFile(scope.row.filePath)">{{getName(scope.row.industryType) + '模板'}}</el-button>
+ <el-link style="" type="primary" @click="downloadFile(scope.row)">{{scope.row.fileName}}</el-link>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
@@ -78,6 +78,9 @@
getIndustryTemp,
} from "@/api/staffManage/staff";
import useUserStore from "@/store/modules/user";
+import axios from "axios";
+import {getToken} from "@/utils/auth";
+import {getIndustry} from "@/api/system/industry";
const userStore = useUserStore()
const { proxy } = getCurrentInstance();
const loading = ref(false);
@@ -86,34 +89,29 @@
queryParams: {
pageNum: 1,
pageSize: 10,
- companyId: null
+ companyId: null,
+ industryType: null
},
total: 0,
dataList: [],
companyList: [],
+ industryList: [],
isAdmin: false,
- typeList: [
- {
- value: 1,
- name: '化工'
- },
- {
- value: 2,
- name: '安防'
- }
- ]
+ typeList: []
});
-const { queryParams, total, dataList,companyList, isAdmin } = toRefs(data);
+const { queryParams, total, dataList,companyList,industryList, isAdmin } = toRefs(data);
const userInfo = ref()
onMounted(async ()=>{
if(userStore.roles.includes('admin')){
data.isAdmin = true
+ data.queryParams.companyId = null
await getCompanyList()
}else{
data.isAdmin = false
data.queryParams.companyId = userStore.companyId
}
+ await getIndustryList()
await getList()
})
@@ -133,6 +131,14 @@
loading.value = false
}
+const getIndustryList = async () => {
+ const res = await getIndustry()
+ if(res.code == 200){
+ data.industryList = res.data.data
+ }else{
+ ElMessage.warning(res.message)
+ }
+}
const getCompanyList = async ()=>{
const queryParams = {
pageNum: 1,
@@ -141,22 +147,34 @@
const res = await getCompany(queryParams)
if (res.code == 200) {
data.companyList = res.data.list?res.data.list:[]
- data.queryParams.companyId = data.companyList[0].id
+ // data.queryParams.companyId = data.companyList[0].id
} else {
ElMessage.warning(res.message)
}
}
-const downloadFile = (path)=>{
- window.open(import.meta.env.VITE_APP_BASE_API + '/' + path)
-}
-
-const getName =(type)=>{
- return data.typeList.find(i=> i.value == type)?.name
+const downloadFile = (e)=>{
+ axios.get(import.meta.env.VITE_APP_BASE_API + '/' +e.filePath,{headers:{'Content-Type': 'application/json','Authorization': `${getToken()}`},responseType: 'blob'}).then(res=>{
+ if (res) {
+ const link = document.createElement('a')
+ let blob = new Blob([res.data],{type: res.data.type})
+ link.style.display = "none";
+ link.href = URL.createObjectURL(blob); // 创建URL
+ link.setAttribute("download", e.fileName);
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ } else {
+ ElMessage({
+ type: 'warning',
+ message: '文件读取失败'
+ });
+ }
+ })
}
const openDialog = (type, value) => {
- dialogRef.value.openDialog(type, value, data.queryParams.companyId);
+ dialogRef.value.openDialog(type, value, data.queryParams.companyId, data.isAdmin, data.companyList);
}
/** 重置新增的表单以及其他数据 */
@@ -164,7 +182,8 @@
data.queryParams = {
pageNum: 1,
pageSize: 10,
- companyId: null
+ companyId: null,
+ industryType: null
}
await getCompanyList()
await getList()
--
Gitblit v1.9.2