<el-table :data="tableData" style="width: 100%; max-height: 572px" row-key="id" border v-loading="loadingTable">
<el-table-column prop="area" label="地区" align="center">
<template #default="scope">
{{ referenceWayDictValue(scope.row.area, options1) }}
</template>
</el-table-column>
<el-table-column prop="projectName" label="项目部名称" align="center">
<template #default="scope">
{{ referenceWayDictdeptName(scope.row.projectName, options5) }}
</template>
</el-table-column>
<el-table-column prop="lineName" label="线路名称" align="center">
<template #default="scope">
{{ referenceWayDictLineName(scope.row.lineName, lineList) }}
</template>
</el-table-column>
<el-table-column prop="jobDescription" label="行别" align="center">
<template #default="scope">
{{ referenceWayDictValue(scope.row.jobDescription, options2) }}
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" align="center" width="180">
<template #default="scope">
<el-button type="text" @click="handleView(scope.row)">查看</el-button>
<el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
js函数放法:
//使用字段数据函数
referenceWayDictValue(congt, arr) {
for (let i = 0; i < arr.length; i++) {
if (arr[i].dictKey == congt) {
return arr[i].dictValue;
}
}
return '';
},
referenceWayDictLineName(congt, arr) {
for (let i = 0; i < arr.length; i++) {
if (arr[i].id == congt) {
return arr[i].lineName;
}
}
return '';
},
referenceWayDictdeptName(congt, arr) {
for (let i = 0; i < arr.length; i++) {
if (arr[i].id == congt) {
return arr[i].deptName;
}
}
return '';
},
这里我写了,好几个函数,懒得在改进封装了,哈哈,可以在加一个字段,公用同一个函数逻辑;