| | |
| | | }); |
| | | return time_str; |
| | | } |
| | | /** |
| | | * 将逗号分隔的字符串转换为对应的label字符串 |
| | | * @param {string} str - 逗号分隔的字符串,如 "2,3,1" |
| | | * @param {Array} options - 选项数组,格式: [{value: "1", label: "选项1"}, ...] |
| | | * @returns {string} - 逗号分隔的label字符串 |
| | | */ |
| | | export function getLabelsFromString(str, options) { |
| | | if (!str || !options || !Array.isArray(options)) { |
| | | return ""; |
| | | } |
| | | |
| | | // 将字符串分割为数组 |
| | | const valueArray = str |
| | | .split(",") |
| | | .map(item => item.trim()) |
| | | .filter(item => item !== ""); |
| | | |
| | | if (valueArray.length === 0) { |
| | | return ""; |
| | | } |
| | | |
| | | // 创建value到label的映射 |
| | | const valueToLabelMap = {}; |
| | | options.forEach(option => { |
| | | if (option.value !== undefined && option.label !== undefined) { |
| | | valueToLabelMap[option.value] = option.label; |
| | | } |
| | | }); |
| | | |
| | | // 获取对应的label |
| | | const labelArray = valueArray.map(value => { |
| | | return valueToLabelMap[value] || value; // 如果找不到对应label,就返回原值 |
| | | }); |
| | | |
| | | // 返回逗号分隔的label字符串 |
| | | return labelArray.join(","); |
| | | } |
| | | export function donatebaseinfoEdit(data) { |
| | | updateDonatebaseinfo(data); |
| | | } |