Code Monkey home page Code Monkey logo

dcat-distpicker's Introduction

dcat-admin extension

Distpicker是一个**省市区三级联动选择组件,这个包是基于Distpickerdcat-admin扩展,用来将Distpicker集成进dcat-admin的表单中.

此扩展参考与引用:

截图

1、安装

composer require sparkinzy/dcat-distpicker

2、Dcat 后台发布资源

install

3、dcat-distpicker 使用方式

code

4、呈现效果

image-usage

表单中使用

比如在表中有三个字段province_name, city_name, district_name, 在form表单中使用它:

$form->distpicker(['province_name', 'city_name', 'district_name']);

设置默认值

$form->distpicker([
    'province_name' => '省份',
    'city_name' => '市',
    'district_name' => '区'
], '地域选择')->default([
    'province' => '黑龙江省',
    'city'     => '双鸭山市',
    'district' => '四方台区',
])->select2();

设置返回值类型

默认 name,可修改返回类型为code,但目前不推荐


$form->distpicker([
    'province_name' => '省份',
    'city_name' => '市',
    'district_name' => '区'
], '地域选择')->type('code');

可以设置每个字段的placeholder

$form->distpicker([
    'province_name' => '省',
    'city_name'     => '市',
    'district_name' => '区'
]);

设置label

$form->distpicker(['province_name', 'city_name', 'district_name'], '请选择区域');

设置自动选择, 可以设置1,2,3 表示自动选择到第几级

$form->distpicker(['province_name', 'city_name', 'district_name'])->autoselect(1);

启用select2进行渲染

$form->distpicker(['province_name', 'city_name', 'district_name']))->select2();

表格筛选中使用

默认展开 省 市 区

# province_name 为字段名
$filter->distpicker(['province_name', 'city_name', 'district_name'], '地域选择');

只展示 省

$filter->distpicker(['province_name', 'city_name', 'district_name'], '地域选择')
->level();

展示 省 市

$filter->distpicker(['province_name', 'city_name', 'district_name'], '地域选择')
->level(2);

使用code筛选

$filter->distpicker(['province_name', 'city_name', 'district_name'], '地域选择')->type('code');
# 只进行省市筛选
$filter->distpicker(['province_name', 'city_name', 'district_name'], '地域选择')->level(2)->type('code');

地区编码数据

Distpicker所使用的地域编码是基于国家统计局发布的数据, 数据字典为china_areas.sql文件.

Todo

  • 可以自定义是否返回code或者name
  • Grid filter扩展
  • 数据库文件

dcat-distpicker's People

Contributors

sparkinzy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dcat-distpicker's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.