AI Skill Report Card
Generated Skill
BMSF Dictionary Component Implementation
Quick Start
HTML<div id="apply_type"></div> <script> layui.define(['bkadmin'], function (exports) { var bkadmin = layui.bkadmin; bkadmin.getDic([{ elem: '#apply_type', code: 'apply_type', type: 'select', fieldName: 'projectType', val: '4444' // Default value }]); }); </script>
Recommendation▾
Consider adding more specific examples
Workflow
Progress:
- Configure dictionary in System Management > Dictionary Management
- Add HTML placeholders with unique IDs
- Call bkadmin.getDic() with configuration array
- Set default values using
valparameter - Add event handlers if needed
Step-by-Step Process
-
Configure Dictionary Data
- Go to System Management > Dictionary Management
- Add dictionary type in left panel, record the type identifier
- Add dictionary items with identifiers and descriptions in right panel
-
Create HTML Placeholders
HTML<div id="apply_type"></div> <div id="sex"></div> -
Initialize Dictionary Components
JavaScriptbkadmin.getDic([{ elem: '#apply_type', code: 'apply_type', type: 'select', fieldName: 'projectType', val: 'default_value' }]);
Recommendation▾
Include edge cases
Examples
Example 1: Select Dropdown with Default
JavaScriptbkadmin.getDic([{ elem: '#searchProjectType', code: 'apply_type', type: 'select', fieldName: 'projectType', onlyLeaf: true, val: '4444', // Sets default selection addAllOption: true, addAllOptionText: '全部' }]);
Example 2: Radio Buttons with Default
JavaScriptbkadmin.getDic([{ elem: '.sex', code: 'sex', type: 'radio', fieldName: 'sex', val: '0' // Default selected value }]);
Example 3: Checkboxes with Multiple Defaults
JavaScriptbkadmin.getDic([{ elem: '.status', code: 'status_type', type: 'checkbox', fieldName: 'status', val: ['0', '1'] // Array for multiple defaults }]);
Example 4: Multi-level Dictionary
JavaScriptbkadmin.getDic([{ elem: '#category', code: 'category_tree', type: 'select', fieldName: 'category', onlyLeaf: true, expanded: false, showLevel: 2, val: 'leaf_node_value' }]);
Core Parameters
| Parameter | Description | Type | Default |
|---|---|---|---|
code | Dictionary type identifier | String | Required |
elem | HTML container selector | String | Required |
type | Component type: 'select', 'radio', 'checkbox' | String | Required |
fieldName | Form field name attribute | String | Required |
val | Default value(s) | String/Array | null |
required | Make field required | Boolean | false |
disabled | Disable component | Boolean | false |
Setting Default Values
For Select Components
JavaScriptval: 'dictionary_code' // Single value
For Radio Components
JavaScriptval: 'dictionary_code' // Single value
For Checkbox Components
JavaScriptval: ['code1', 'code2'] // Array of values
Dynamic Value Setting
JavaScript// For single-level select form.val('filter_name', {'fieldName': 'new_value'}); // For multi-level select xmSelect.get('#container').setValue(['value'], null, true); // For radio buttons form.val('lay-filter', {'fieldName': 'new_value'});
Best Practices
- Call getDic() before loading business data to ensure proper dictionary assignment
- Use unique IDs for each dictionary container to avoid conflicts
- Set meaningful fieldName attributes that match your form processing
- Include val parameter for default selections to improve user experience
- Use onlyLeaf: true for multi-level dictionaries when only leaf nodes should be selectable
- Add event handlers using success callback for dynamic behavior
Common Pitfalls
- Don't call getDic() after business data loads - dictionary values may not assign correctly
- Don't forget to configure dictionaries in System Management before using them
- Don't use same elem selector for multiple dictionary components
- Don't mix val types - use string for single values, array for multiple checkbox values
- Don't rely on form.val() for multi-level select components - use xmSelect.setValue() instead