12345678910111213141516171819 |
- // 备选数据返回id
- export function returnId(list, name) {
- let id = ""
- list.forEach(e => {
- if (e.name === name) {
- id = e.id
- }
- });
- return id===""?1:id
- }
- // 备选数据返回name
- export function returnName(list, id) {
- let index = list.findIndex(item => {
- return parseInt(item.id) === parseInt(id);
- });
- return index !== -1 ? list[index].name : "--";
- }
|