function setIdValueTrans(from, to, content, colList) {
if (!content) {
return content
}
console.log('nameIdMap',colList[0].nameIdMap)
console.log('rowData',colList[0].rowData)
console.log()
let name2Id = content
const nameIdMap = colList.reduce((pre, next) => {
pre[next[from]] = next[to]
con
return pre
}, {})
// console.log('colList',colList);
console.log(nameIdMap);
console.log()
const on = content.match(/\[(.+?)\]/g)
console.log(on,'on')
if (on) {
on.forEach(itm => {
const ele = itm.slice(1, -1)
name2Id = name2Id.replace(itm, nameIdMap[ele])
})
}
return name2Id
}
let from='id';
let to='value';
let content='baidu.com/s?wd=321&w=[3d5ae808-1f74-44ee-9e30-33b236e95720]&rdate=[854299a9-d6ac-47eb-b6bd-e31d58e7b985]&cdate=[fcf172c1-da85-4b94-b859-5d2adb0a5f7b]&money=[b88069e0-df45-4513-9062-d057c13f44a2]&dis=[03c75b4e-0208-4fc9-a4ce-194d18e7a746]';
let colList=[{"id":"03c75b4e-0208-4fc9-a4ce-194d18e7a746","value":"社区获得性肺炎(儿童,首次住院)","rowData":{"C_c5a230c5d9d0285421fe3ef082d6d06c":"2930.35","C_57e79553e7ba3aba9f9889c865ef68f8":"2021-12-12 15:01","C_85b9734a9b75bd895f0e39d23785e28f":"1664.31","C_1a2ddc2db4693cfd16d534cde5572cc1":"","C_707c4addc8e923f96b5399887f00178d":"4","C_546828ec00361082df9d454948ce09f3":"2021-12-17 12:00","C_5e2a3da748700c84863a802e1e594899":"","C_412ebb2097d7532320e593d56b9c8d3b":"175","C_f1a543f5a2c5d49bc5dde298fcf716e4":"社区获得性肺炎(儿童,首次住院)","C_b713e6323a68d3ddabf4855826c50148":"04a6bdb14564246dba4b73b916ffa41e"},"nameIdMap":{"C_1a2ddc2db4693cfd16d534cde5572cc1":"3d5ae808-1f74-44ee-9e30-33b236e95720","C_f1a543f5a2c5d49bc5dde298fcf716e4":"03c75b4e-0208-4fc9-a4ce-194d18e7a746","C_b713e6323a68d3ddabf4855826c50148":"d01e47d1-897b-4de7-b50c-d60381ccacf9","C_57e79553e7ba3aba9f9889c865ef68f8":"854299a9-d6ac-47eb-b6bd-e31d58e7b985","C_546828ec00361082df9d454948ce09f3":"fcf172c1-da85-4b94-b859-5d2adb0a5f7b","C_707c4addc8e923f96b5399887f00178d":"88616845-e1f6-46b5-95c1-b7009d4ef5b8","C_5e2a3da748700c84863a802e1e594899":"4f91f0fe-a162-46e3-bb94-cacee3044f6d","C_c5a230c5d9d0285421fe3ef082d6d06c":"84ee861f-42d8-41a2-875e-77e3b8cdd6c2","C_85b9734a9b75bd895f0e39d23785e28f":"b88069e0-df45-4513-9062-d057c13f44a2","C_412ebb2097d7532320e593d56b9c8d3b":"2f1546be-d90a-4d1a-b5c5-9eb315405468"}}]
console.log(setIdValueTrans(from,to,content,colList))
console