function getShowLable( currentValue, list, currentValueName, showValueName ) { let _list = []; if (list !== undefined) { _list = list.filter((item) => { return ( currentValue !== "" && (currentValue === item[currentValueName] || currentValue === Number(item[currentValueName]) || currentValue === String(item[currentValueName])) ); }); } if (_list.length > 0) { return _list[0][showValueName]; } else { return ""; } }
let levelList = [ { dictValue: 1, dictLabel: "一级" }, { dictValue: 2, dictLabel: "二级" }, ],
使用方法:
<el-table-column label="部门级别" prop="deptLevel" align="center"> <template slot-scope="scope"> <span>{{ getShowLable( scope.row.deptLevel, levelList, "dictValue", "dictLabel" ) }}</span> </template> </el-table-column>