smart-bid-web/src/views/enterpriseLibrary/tool/index.vue

254 lines
8.1 KiB
Vue
Raw Normal View History

2025-10-27 16:41:20 +08:00
<template>
<!-- 工器具库 -->
<el-card class="tool-container">
<!-- 返回按钮 -->
<div class="back-container">
<el-button type="default" size="small" @click="handleBack" class="back-btn">
返回
</el-button>
</div>
2025-10-27 18:21:37 +08:00
<div class="table-container">
2025-10-31 13:29:10 +08:00
<TableModel :formLabel="formLabel" :showOperation="true" :showRightTools="false" ref="toolTableRef"
:columnsList="columnsList" :request-api="listAPI" :sendParams= "sendParams">
2025-10-27 18:21:37 +08:00
<template slot="tableTitle">
<h3>数据列表</h3>
</template>
<template slot="tableActions">
2025-10-31 13:29:10 +08:00
<el-button @click="handleModelExport" v-hasPermi="['enterpriseLibrary:tool:add']"
2025-10-27 18:21:37 +08:00
class="add-btn">导入模板下载</el-button>
2025-11-03 11:16:26 +08:00
<el-button @click="handleBathchImport" v-hasPermi="['enterpriseLibrary:tool:import']"
2025-10-31 13:29:10 +08:00
class="add-btn">批量导入</el-button>
<el-button @click="handleAdd" v-hasPermi="['enterpriseLibrary:tool:add']" class="add-btn"><i
2025-10-27 18:21:37 +08:00
class="el-icon-plus"></i> 新增工器具</el-button>
</template>
<template slot="deptName" slot-scope="{ data }">
<span>{{ data.dept.deptName || '--' }}</span>
</template>
<template slot="handle" slot-scope="{ data }">
2025-10-31 13:29:10 +08:00
<el-button type="text" v-hasPermi="['enterpriseLibrary:tool:detail']" class="action-btn"
2025-10-31 14:15:26 +08:00
@click="handleDetail(data)">
2025-10-27 18:21:37 +08:00
查看
</el-button>
2025-10-31 13:29:10 +08:00
<el-button type="text" v-hasPermi="['enterpriseLibrary:tool:edit']" class="action-btn"
2025-10-27 18:21:37 +08:00
style="color: #EAA819;" @click="handleUpdate(data)">
编辑
</el-button>
2025-10-31 13:29:10 +08:00
<el-button type="text" v-hasPermi="['enterpriseLibrary:tool:del']" class="action-btn"
2025-10-27 18:21:37 +08:00
style="color: #DB3E29;" @click="handleDelete(data)">
删除
</el-button>
2025-11-03 11:16:26 +08:00
2025-10-27 18:21:37 +08:00
</template>
</TableModel>
</div>
2025-10-27 16:41:20 +08:00
<!-- 添加方案类型弹窗 -->
<ToolForm ref="toolForm" v-if="isflag" :isAdd="isAdd" :rowData="row" @handleQuery="handleQuery" :title="title"
@closeDialog="closeDialog" :width="600" />
2025-10-31 17:55:55 +08:00
<!-- 批量导入弹窗 -->
<ImportExcelDialog
:visible.sync="importExcelDialogVisible"
ref="importExcelDialog"
title="工器具导入"
:upload-url="importExcelDialogUploadUrl"
@upload-success="handleImportSuccess"
@close="handleImportClose"
:maxFileTips="maxFileTips"
2025-11-03 11:16:26 +08:00
:params = "params"
2025-10-31 17:55:55 +08:00
/>
2025-10-27 16:41:20 +08:00
</el-card>
</template>
<script>
import TableModel from '@/components/TableModel2'
import { columnsList, formLabel } from './config'
import ToolForm from './components/ToolForm.vue'
2025-10-31 13:29:10 +08:00
import { listAPI, delDataAPI } from '@/api/enterpriseLibrary/tool/tool'
2025-10-27 16:41:20 +08:00
import { encryptWithSM4, decryptWithSM4 } from '@/utils/sm'
2025-10-31 15:55:40 +08:00
import { downloadFileWithLoading } from '@/utils/download'
2025-10-31 17:55:55 +08:00
import ImportExcelDialog from '@/views/common/ImportExcelDialog'
2025-11-03 11:16:26 +08:00
const IMPORT_URL = '/smartBid/mainDatabase/tool/importData';
2025-10-27 16:41:20 +08:00
export default {
2025-11-05 10:09:26 +08:00
name: 'Tools',
2025-10-27 16:41:20 +08:00
components: {
TableModel,
2025-10-31 17:55:55 +08:00
ToolForm,
ImportExcelDialog
2025-10-27 16:41:20 +08:00
},
data() {
return {
formLabel,
columnsList,
2025-10-31 13:29:10 +08:00
listAPI,
2025-10-27 16:41:20 +08:00
enterpriseId: decryptWithSM4(this.$route.query.enterpriseId) || '0',
title: "",
isflag: false,
isAdd: '',
row: {},
2025-11-03 11:16:26 +08:00
maxFileTips:'20MB',
2025-10-31 17:55:55 +08:00
importExcelDialogVisible: false,
// 批量导入上传地址需要根据实际API接口修改
2025-11-03 11:16:26 +08:00
importExcelDialogUploadUrl: process.env.VUE_APP_BASE_API + IMPORT_URL,
params:{
enterpriseId: decryptWithSM4(this.$route.query.enterpriseId) || '0',
},
2025-10-27 16:41:20 +08:00
}
},
created() {
2025-10-31 13:29:10 +08:00
},
computed:{
sendParams(){
return {
enterpriseId : this.enterpriseId
}
2025-10-27 16:41:20 +08:00
}
},
methods: {
// 返回上一页
handleBack() {
const obj = {
path: "/enterpriseKnowledge/index",
query: {
enterpriseId: encryptWithSM4(this.enterpriseId || '0'),
}
}
this.$tab.closeOpenPage(obj)
},
/** 新增按钮操作 */
handleAdd() {
this.title = "新增工器具";
this.isAdd = 'add';
2025-10-31 13:29:10 +08:00
this.row = {enterpriseId:this.enterpriseId};
2025-10-27 16:41:20 +08:00
this.isflag = true;
},
/** 修改操作 */
handleUpdate(row) {
2025-10-31 14:15:26 +08:00
this.title = "修改工器具";
2025-10-27 16:41:20 +08:00
this.isAdd = 'edit';
this.row = row;
this.isflag = true;
2025-10-31 13:29:10 +08:00
},
2025-10-31 14:15:26 +08:00
/* 查看操作 */
handleDetail(row){
2025-10-31 15:55:40 +08:00
this.title = "查看详情";
2025-10-31 14:15:26 +08:00
this.isAdd = 'detail';
this.row = row;
this.isflag = true;
2025-10-31 13:29:10 +08:00
},
// 模板下载
2025-10-31 15:55:40 +08:00
handleModelExport() {
downloadFileWithLoading(
'smartBid/commonDownload/downLoadToolModel',
'工器具导入模板.xlsx',
'正在下载模板,请稍候...'
)
2025-10-31 14:15:26 +08:00
},
// 批量导入
handleBathchImport(){
2025-10-31 17:55:55 +08:00
this.importExcelDialogVisible = true;
},
handleImportSuccess() {
this.handleQuery();
},
handleImportClose() {
this.handleQuery();
2025-10-27 16:41:20 +08:00
},
closeDialog() {
this.isflag = false;
},
/* 搜索操作 */
handleQuery() {
2025-10-31 13:29:10 +08:00
this.$refs.toolTableRef.getTableList()
2025-10-27 16:41:20 +08:00
},
/** 删除操作 */
handleDelete(row) {
2025-10-31 14:15:26 +08:00
this.$confirm(`确定要删除"${row.toolName}"吗?删除后将无法恢复!`, '操作提示', {
2025-10-31 13:29:10 +08:00
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
dangerouslyUseHTMLString: true,
customClass: 'delete-confirm-dialog'
}).then(() => {
delDataAPI(
{
2025-10-31 15:55:40 +08:00
toolId: row.toolId,
2025-10-31 13:29:10 +08:00
enterpriseId: this.enterpriseId
}
).then(res => {
2025-10-27 16:41:20 +08:00
if (res.code === 200) {
2025-10-31 13:29:10 +08:00
this.$message.success('删除成功');
2025-10-27 16:41:20 +08:00
this.handleQuery();
} else {
2025-10-31 13:29:10 +08:00
this.$message.error(res.msg || '删除失败');
2025-10-27 16:41:20 +08:00
}
}).catch(error => {
2025-10-31 13:29:10 +08:00
console.error('删除失败:', error);
2025-10-27 16:41:20 +08:00
});
2025-10-31 13:29:10 +08:00
})
2025-10-27 16:41:20 +08:00
},
},
}
</script>
<style scoped lang="scss">
.tool-container {
height: calc(100vh - 84px);
overflow: hidden;
2025-11-05 14:16:09 +08:00
//background: linear-gradient(180deg, #F1F6FF 20%, #E5EFFF 100%);
2025-10-27 16:41:20 +08:00
}
.back-container {
display: flex;
justify-content: flex-end;
align-items: center;
2025-10-27 18:21:37 +08:00
margin-bottom: 20px;
2025-10-27 16:41:20 +08:00
padding: 0 20px;
.back-btn {
width: 98px;
height: 36px;
background: #FFFFFF;
box-shadow: 0px 4px 8px 0px rgba(76, 76, 76, 0.2);
border-radius: 4px;
border: none;
color: #666;
font-size: 14px;
transition: all 0.3s ease;
&:hover {
background: #f5f5f5;
color: #409EFF;
box-shadow: 0px 6px 12px 0px rgba(76, 76, 76, 0.3);
}
}
}
.add-btn {
width: 121px;
height: 36px;
background: #1F72EA;
box-shadow: 0px 4px 8px 0px rgba(51, 135, 255, 0.5);
border-radius: 4px 4px 4px 4px;
color: #fff;
border: none;
font-size: 14px;
transition: all 0.3s;
&:hover {
background: #4A8BFF;
box-shadow: 0px 6px 12px 0px rgba(51, 135, 255, 0.6);
}
}
.action-btn {
margin-right: 8px;
&:last-child {
margin-right: 0;
}
}
</style>