dealOptions.js 420 B

12345678910111213141516171819
  1. // 备选数据返回id
  2. export function returnId(list, name) {
  3. let id = ""
  4. list.forEach(e => {
  5. if (e.name === name) {
  6. id = e.id
  7. }
  8. });
  9. return id===""?1:id
  10. }
  11. // 备选数据返回name
  12. export function returnName(list, id) {
  13. let index = list.findIndex(item => {
  14. return parseInt(item.id) === parseInt(id);
  15. });
  16. return index !== -1 ? list[index].name : "--";
  17. }