From 0c5fd22a20dae1c6a54384185cdca4e0b93360f2 Mon Sep 17 00:00:00 2001
From: 祖安之光 <11848914+light-of-zuan@user.noreply.gitee.com>
Date: Wed, 02 Jul 2025 13:33:34 +0800
Subject: [PATCH] 修改新增
---
src/views/build/conpanyFunctionConsult/industryTemplate/index.vue | 45 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/src/views/build/conpanyFunctionConsult/industryTemplate/index.vue b/src/views/build/conpanyFunctionConsult/industryTemplate/index.vue
index 19c1ef3..b7b8c0f 100644
--- a/src/views/build/conpanyFunctionConsult/industryTemplate/index.vue
+++ b/src/views/build/conpanyFunctionConsult/industryTemplate/index.vue
@@ -21,9 +21,13 @@
</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-select v-model="data.queryParams.industryId" 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 >
@@ -43,7 +47,7 @@
</el-table-column>
<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-button link type="primary" @click="downloadFile(scope.row)">{{getName(scope.row.industryType) + '模板'}}</el-button>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
@@ -78,6 +82,8 @@
getIndustryTemp,
} from "@/api/staffManage/staff";
import useUserStore from "@/store/modules/user";
+import axios from "axios";
+import {getToken} from "@/utils/auth";
const userStore = useUserStore()
const { proxy } = getCurrentInstance();
const loading = ref(false);
@@ -86,11 +92,13 @@
queryParams: {
pageNum: 1,
pageSize: 10,
- companyId: null
+ companyId: null,
+ industryId: null
},
total: 0,
dataList: [],
companyList: [],
+ industryList: [],
isAdmin: false,
typeList: [
{
@@ -104,11 +112,12 @@
]
});
-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
@@ -141,14 +150,27 @@
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 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
+ window.open(link.href)
+ } else {
+ ElMessage({
+ type: 'warning',
+ message: '文件读取失败'
+ });
+ }
+ })
}
const getName =(type)=>{
@@ -156,7 +178,7 @@
}
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 +186,8 @@
data.queryParams = {
pageNum: 1,
pageSize: 10,
- companyId: null
+ companyId: null,
+ industryId: null
}
await getCompanyList()
await getList()
--
Gitblit v1.9.2