hkw/tools

自用综合型扩展

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

pkg:composer/hkw/tools

v1.0.0 2025-12-23 08:28 UTC

This package is not auto-updated.

Last update: 2025-12-24 06:49:32 UTC


README

通过 composer 安装扩展

  composer require hkw/tools

已有表单组件(采用的是Naive UI)

     // 标签
     // each vComponent has watch method
    $form->vTags('tags')
        ->watch('list as field name', <<<JS
            (target, current, store) => {
                // the tag component of naive ui expect format: {label: string, value: string}
                current.options.push({label: target, value: target});
                
                store.request({method: 'get', url: '/admin'})
                    .then(res => console.log(res));
                console.log(store.forms.list)
            }
        JS);
    
    $form->vList('list')
        ->sortable() // 开启排序
        ->max(8); // 限制最大添加数量
        
    $form->vKeyValue('kvs')
        ->sortable() // 开启排序
        ->serial() // 开启固定有序索引 默认为字母A-Z
        ->keys(['一', '二', '三', '四']) // serial后自定义索引
        ->list(); // serial后只提交值,保存为一维数组(索引仅作为显示)
        
    $form->vSelect('select')
        ->options(['123', '456', 'A' => 'aaa']) // 选项
        ->concatKey('separator') // 显示键
        ->optionsFromKeyValue('kvs'); // 用于结合vKeyValue进行选项选择

    $form->vMultipleSelect('ms', '多选')
        ->options(['123', '456', 'A' => 'aaa']) // 选项
        ->concatKey('separator') // 显示键
        ->optionsFromKeyValue('kvs'); // 用于结合vKeyValue进行选项选择

    $form->vNumber('number', '数字')
        ->bothButton() // 按钮位置分离到两端
        ->step(2) // 步进
        ->min(2) // 最小值
        ->max(88) // 最大值
        ->precision(2); // 开启小数,精度

    $form->vIcon('icon', '图标') // icon vIcon oIcon
        ->withColorColumn('color') // 独立的hex颜色字段,默认是合并到图标类型后面
        ->closeColorPicker();