createConfigItem()

in spring-ai-alibaba-jmanus/src/main/resources/static/admin/js/admin-ui.js [225:297]


    createConfigItem(config) {
        const item = document.createElement('div');
        item.className = 'config-item';
        
        // 创建配置项标签
        const label = document.createElement('label');
        label.setAttribute('for', `config-${config.id}`);
        label.textContent = config.description;
        item.appendChild(label);
        
        // 根据配置类型创建输入元素
        let inputElem;
        switch (config.inputType) {
            case 'CHECKBOX':
                inputElem = document.createElement('input');
                inputElem.type = 'checkbox';
                inputElem.checked = config.configValue === 'true';
                break;
                
            case 'NUMBER':
                inputElem = document.createElement('input');
                inputElem.type = 'number';
                inputElem.value = config.configValue;
                break;
                
            case 'SELECT':
                inputElem = document.createElement('select');
                try {
                    const options = JSON.parse(config.optionsJson || '[]');
                    options.forEach(option => {
                        const optionElem = document.createElement('option');
                        optionElem.value = option.value;
                        optionElem.textContent = option.label;
                        optionElem.selected = option.value === config.configValue;
                        inputElem.appendChild(optionElem);
                    });
                } catch (e) {
                    console.error('解析选项JSON失败:', e);
                }
                break;
                
            case 'TEXTAREA':
                inputElem = document.createElement('textarea');
                inputElem.value = config.configValue;
                inputElem.rows = 3;
                break;
                
            default: // TEXT或其他类型
                inputElem = document.createElement('input');
                inputElem.type = 'text';
                inputElem.value = config.configValue;
                break;
        }
        
        // 设置通用属性
        inputElem.id = `config-${config.id}`;
        inputElem.className = 'config-input';
        inputElem.setAttribute('data-config-id', config.id);
        inputElem.setAttribute('data-config-type', config.inputType);
        
        // 添加事件处理
        inputElem.addEventListener('change', (e) => {
            const value = config.inputType === 'BOOLEAN' 
                ? e.target.checked.toString() 
                : e.target.value;
            
            // 更新配置模型中的值
            configModel.updateGroupConfigValue('manus', config.id, value);
        });
        
        item.appendChild(inputElem);
        return item;
    }