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

309 lines
9.1 KiB
Vue
Raw Normal View History

2025-10-24 18:33:58 +08:00
<template>
<!-- 业绩库页面引用TableModel组件 -->
<el-card class="tool-container">
<!-- 返回按钮 -->
<div class="back-container">
<el-button type="default" size="small" @click="handleBack" class="back-btn">
返回
2025-10-24 18:33:58 +08:00
</el-button>
</div>
<div class="table-container">
<TableModel
:formLabel="formLabel"
:columnsList="columnsList"
:request-api="listPerformance"
:sendParams="{ enterpriseId: enterpriseId }"
:showOperation="true"
:showRightTools="false"
ref="performanceTableRef"
>
<!-- 表格标题插槽 -->
<template slot="tableTitle">
<h3>业绩库列表</h3>
</template>
<!-- 表格顶部操作按钮插槽新增按钮 -->
<template slot="tableActions">
<el-button
type="primary"
icon="el-icon-plus"
@click="handleAdd"
v-hasPermi="['enterpriseLibrary:performance:add']"
class="add-btn"
>
新增业绩
</el-button>
</template>
<!-- 合同金额格式化插槽适配金额保留2位小数 -->
<template slot="contractAmount" slot-scope="{ data }">
<span>{{ formatCurrency(data.contractAmount) }}</span>
</template>
<!-- 操作列插槽查看/编辑/删除 -->
<template slot="handle" slot-scope="{ data }">
2025-10-24 18:33:58 +08:00
<el-button
size="mini"
type="text"
@click="handleView(data)"
2025-10-24 18:33:58 +08:00
v-hasPermi="['enterpriseLibrary:performance:detail']"
class="action-btn"
2025-10-24 18:33:58 +08:00
>
查看
</el-button>
<el-button
size="mini"
type="text"
@click="handleEdit(data)"
2025-10-24 18:33:58 +08:00
v-hasPermi="['enterpriseLibrary:performance:edit']"
class="action-btn"
style="color: #EAA819;"
2025-10-24 18:33:58 +08:00
>
编辑
</el-button>
<el-button
size="mini"
type="text"
@click="handleDelete(data)"
2025-10-24 18:33:58 +08:00
v-hasPermi="['enterpriseLibrary:performance:del']"
class="action-btn"
style="color: #DB3E29;"
2025-10-24 18:33:58 +08:00
>
删除
</el-button>
</template>
</TableModel>
2025-10-24 18:33:58 +08:00
</div>
</el-card>
2025-10-24 18:33:58 +08:00
</template>
<script>
// 导入TableModel组件、配置文件、工具函数和接口
import TableModel from '@/components/TableModel2'
import { formLabel, columnsList } from './config'
import { encryptWithSM4, decryptWithSM4 } from '@/utils/sm'
import { listPerformance, delPerformance } from "@/api/enterpriseLibrary/performance/performance";
import { listAPI } from "@/api/enterpriseLibrary/personnel/personnel";
2025-10-24 18:33:58 +08:00
export default {
name: 'Performance',
components: { TableModel }, // 注册TableModel组件
2025-10-24 18:33:58 +08:00
data() {
return {
formLabel, // 导入查询表单配置
columnsList, // 导入表格列配置
listPerformance, // 导入列表查询接口
enterpriseId: decryptWithSM4(this.$route.query.enterpriseId) || '0' // 解密企业ID
2025-10-24 18:33:58 +08:00
}
},
created() {
this.loadVoltageLevelDict()
this.loadProjectManagers()
this.loadProjcetTypeDict()
// 初始化时给表格组件传递企业ID参数并加载列表
this.$nextTick(() => {
if (this.$refs.performanceTableRef) {
this.$refs.performanceTableRef.queryParams.enterpriseId = this.enterpriseId
this.$refs.performanceTableRef.getTableList()
}
})
2025-10-24 18:33:58 +08:00
},
methods: {
loadProjcetTypeDict() {
// getDicts 的参数是字典类型编码project_type
this.getDicts('project_type').then(response => {
const proTypeOptions = response.data.map(item => ({
label: item.dictLabel,
value: item.dictLabel
}))
const proTypeItem = this.formLabel.find(item => item.f_model === 'proType')
if (proTypeItem) {
proTypeItem.f_selList = proTypeOptions // 动态设置下拉选项
}
}).catch(error => {
console.error('加载项目类型字典失败:', error)
})
},
loadVoltageLevelDict() {
this.getDicts('voltage_level').then(response => {
const voltageOptions = response.data.map(item => ({
label: item.dictLabel,
value: item.dictLabel
}))
const voltageItem = this.formLabel.find(item => item.f_model === 'voltageLevel')
if (voltageItem) {
voltageItem.f_selList = voltageOptions // 动态设置下拉选项
}
2025-10-24 18:33:58 +08:00
}).catch(error => {
console.error('加载电压等级字典失败:', error)
2025-10-24 18:33:58 +08:00
})
},
loadProjectManagers() {
const params = {
enterpriseId: this.enterpriseId,
personnelPosition: 'project_manager'
};
listAPI(params).then(response => {
const projectManagerOptions = (response.rows || []).map(person => ({
label: person.personnelName,
value: person.personnelName
}));
const projectManagerItem = this.formLabel.find(item => item.f_model === 'projectManager');
if (projectManagerItem) {
projectManagerItem.f_selList = projectManagerOptions;
}
2025-10-24 18:33:58 +08:00
this.projectManager = projectManagerOptions;
}).catch(error => {
console.error('主组件获取项目经理列表失败:', error);
this.projectManager = [];
const projectManagerItem = this.formLabel.find(item => item.f_model === 'projectManager');
if (projectManagerItem) {
projectManagerItem.f_selList = [];
}
});
2025-10-24 18:33:58 +08:00
},
// 格式化金额保留2位小数
formatCurrency(amount) {
if (!amount) return '0.00'
return parseFloat(amount).toFixed(2)
},
// 新增业绩:跳转新增/编辑共用页面type=add
2025-10-24 18:33:58 +08:00
handleAdd() {
this.$router.push({
name: "PerformanceForm",
2025-10-24 18:33:58 +08:00
query: {
type: encryptWithSM4('add'),
id: encryptWithSM4(''),
enterpriseId: encryptWithSM4(this.enterpriseId)
2025-10-24 18:33:58 +08:00
},
title: '新增业绩'
})
},
// 查看业绩:跳转详情页
handleView(data) {
2025-10-24 18:33:58 +08:00
this.$router.push({
name: "PerformanceDetail",
query: {
id: encryptWithSM4((data.performanceId ?? '').toString()),
enterpriseId: encryptWithSM4(this.enterpriseId)
2025-10-24 18:33:58 +08:00
},
title: '业绩详情'
})
},
// 编辑业绩:跳转新增/编辑共用页面type=edit
handleEdit(data) {
2025-10-24 18:33:58 +08:00
this.$router.push({
name: "PerformanceForm", // 改为与新增共用同一页面组件
2025-10-24 18:33:58 +08:00
query: {
type: encryptWithSM4('edit'), // 传递操作类型为编辑
id: encryptWithSM4((data.performanceId ?? '').toString()), // 传递业绩ID
enterpriseId: encryptWithSM4(this.enterpriseId)
2025-10-24 18:33:58 +08:00
},
title: '编辑业绩'
})
},
// 删除业绩:调用接口并刷新列表
handleDelete(data) {
this.$confirm(`确定要删除【${data.proName}】吗?`, '警告', {
2025-10-24 18:33:58 +08:00
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$modal.loading("正在删除,请稍候...")
// 调用删除接口传递业绩ID和企业ID
delPerformance({
performanceId: data.performanceId,
enterpriseId: this.enterpriseId
}).then(res => {
this.$modal.closeLoading()
if (res.code === 200) {
this.$modal.msgSuccess("删除成功")
this.$refs.performanceTableRef.getTableList() // 重新加载表格
} else {
this.$modal.msgError(res.msg || "删除失败")
}
2025-10-24 18:33:58 +08:00
}).catch(error => {
this.$modal.closeLoading()
this.$modal.msgError(error.message || "删除失败")
2025-10-24 18:33:58 +08:00
})
})
},
// 返回上级页面
handleBack() {
const obj = {
path: "/enterpriseKnowledge/index",
query: {
enterpriseId: encryptWithSM4(this.enterpriseId || '0')
}
}
2025-10-24 18:33:58 +08:00
this.$tab.closeOpenPage(obj)
}
}
}
</script>
<style scoped lang="scss">
/* 样式与财务库保持一致,适配组件布局 */
.tool-container {
height: calc(100vh - 84px);
overflow: hidden;
2025-11-05 14:21:39 +08:00
background: linear-gradient(180deg, #F1F6FF 20%, #E5EFFF 100%);
2025-10-24 18:33:58 +08:00
}
.back-container {
2025-10-24 18:33:58 +08:00
display: flex;
justify-content: flex-end;
2025-10-24 18:33:58 +08:00
align-items: center;
margin-bottom: 20px;
padding: 0 20px;
2025-10-24 18:33:58 +08:00
.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;
2025-10-24 18:33:58 +08:00
&:hover {
background: #f5f5f5;
color: #409EFF;
box-shadow: 0px 6px 12px 0px rgba(76, 76, 76, 0.3);
2025-10-24 18:33:58 +08:00
}
}
}
.add-btn {
width: 121px;
height: 36px;
background: #1F72EA;
box-shadow: 0px 4px 8px 0px rgba(51, 135, 255, 0.5);
2025-10-24 18:33:58 +08:00
border-radius: 4px;
color: #fff;
border: none;
font-size: 14px;
transition: all 0.3s;
2025-10-24 18:33:58 +08:00
&:hover {
background: #4A8BFF;
box-shadow: 0px 6px 12px 0px rgba(51, 135, 255, 0.6);
2025-10-24 18:33:58 +08:00
}
}
.action-btn {
margin-right: 8px;
2025-10-24 18:33:58 +08:00
&:last-child {
margin-right: 0;
2025-10-24 18:33:58 +08:00
}
}
</style>