PHPackages                             super-eggs/dcat-distpicker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. super-eggs/dcat-distpicker

ActiveLibrary

super-eggs/dcat-distpicker
==========================

Distpicker extension for dcat-admin

2.1.3(3y ago)7911.9k↓42.3%16[4 issues](https://github.com/super-eggs/dcat-distpicker/issues)MITPHPPHP &gt;=7.1.0

Since Dec 1Pushed 3y ago2 watchersCompare

[ Source](https://github.com/super-eggs/dcat-distpicker)[ Packagist](https://packagist.org/packages/super-eggs/dcat-distpicker)[ Docs](https://github.com/super-eggs/dcat-distpicker)[ RSS](/packages/super-eggs-dcat-distpicker/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (1)Versions (15)Used By (0)

dcat-distpicker
===============

[](#dcat-distpicker)

[Distpicker](https://github.com/fengyuanchen/distpicker) 是一个中国省市区三级联动选择组件，这个包是基于 `Distpicker` 的 `dcat-admin`扩展，用来将 `Distpicker` 集成进 `dcat-admin`的表单中。如果此插件给你带来的帮助，麻烦给我一个 `star`。如果在使用过程中发现地区不完整的情况，欢迎随时反馈给我。

推荐环境
----

[](#推荐环境)

- php &gt;= 7.4
- laravel &gt;= v8.0.0
- dcat-admin &gt;= v2.2.0

截图
--

[](#截图)

[![image-20200628150204971](https://camo.githubusercontent.com/65a379d9543d0bedd206d13c48e24aaab3c62f2dc8f31c135ef4fb345fb6a89f/68747470733a2f2f747661312e73696e61696d672e636e2f6c617267652f30303753385a496c6c7931676738306b67697770636a333230303069616a74392e6a7067)](https://camo.githubusercontent.com/65a379d9543d0bedd206d13c48e24aaab3c62f2dc8f31c135ef4fb345fb6a89f/68747470733a2f2f747661312e73696e61696d672e636e2f6c617267652f30303753385a496c6c7931676738306b67697770636a333230303069616a74392e6a7067)

安装
--

[](#安装)

首先

```
# jqhph/dcat-admin 1.x
composer require "super-eggs/dcat-distpicker:^1.0"

# jqhph/dcat-admin 2.x
composer require "super-eggs/dcat-distpicker:^2.0"
```

然后: (dcat-admin 2.x 无需执行!!!)

```
php artisan admin:import dcat-distpicker
```

开启扩展
----

[](#开启扩展)

后台开启

- dcat-admin 1.x [![image-20200628150337687](https://camo.githubusercontent.com/d2cf888ddcbcb0fec8f399b8baf8c7ddfd49a78433dd9d342291f91ec8d9e128/68747470733a2f2f747661312e73696e61696d672e636e2f6c617267652f30303753385a496c6c7931676738306d30786266386a3332316d3069617135622e6a7067)](https://camo.githubusercontent.com/d2cf888ddcbcb0fec8f399b8baf8c7ddfd49a78433dd9d342291f91ec8d9e128/68747470733a2f2f747661312e73696e61696d672e636e2f6c617267652f30303753385a496c6c7931676738306d30786266386a3332316d3069617135622e6a7067)
- dcat-admin 2.x [![image-20201201230850804](https://camo.githubusercontent.com/389060fb97d173f1c733f2d690c3c538abf07a04c094ad0734d989826629db9f/68747470733a2f2f692e6c6f6c692e6e65742f323032302f31322f30312f637162523746496945725a547a65592e706e67)](https://camo.githubusercontent.com/389060fb97d173f1c733f2d690c3c538abf07a04c094ad0734d989826629db9f/68747470733a2f2f692e6c6f6c692e6e65742f323032302f31322f30312f637162523746496945725a547a65592e706e67)

使用
--

[](#使用)

### 数据表单中使用

[](#数据表单中使用)

比如在表中有三个字段`province_id`, `city_id`, `district_id`, 在form表单中使用它：

```
$form->distpicker(['province_id', 'city_id', 'district_id']);
```

设置默认值

```
$form->distpicker([
    'province_id' => '省份',
    'city_id' => '市',
    'district_id' => '区'
], '地域选择')->default([
    'province' => 130000,
    'city'     => 130200,
    'district' => 130203,
]);
```

可以设置每个字段的placeholder

```
// 省、市、区
$form->distpicker([
    'province_id' => '省',
    'city_id'     => '市',
    'district_id' => '区'
]);
// 省、市 (Available in v2.1.0+)
$form->distpicker([
    'province_id' => '省',
    'city_id'     => '市',
]);
// 只显示省 (Available in v2.1.0+)
$form->distpicker([
    'province_id' => '省',
]);
```

设置label

```
$form->distpicker(['province_id', 'city_id', 'district_id'], '请选择区域');
```

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

```
$form->distpicker(['province_id', 'city_id', 'district_id'])->autoselect(1);
```

### 表格筛选中使用

[](#表格筛选中使用)

```
$filter->distpicker('province_id', 'city_id', 'district_id', '地域选择');
```

筛选同样支持多级选择:

```
// 省、市 (Available in v2.1.0+)
$filter->distpicker('province_id', 'city_id','', '地域选择');
//or
$filter->distpicker('province_id', 'city_id');
// 只显示省 (Available in v2.1.0+)
$filter->distpicker('province_id','','', '地域选择');
//or
$filter->distpicker('province_id');
```

### 数据表格中使用

[](#数据表格中使用)

省市区名称回显 (Available in v2.1.0+):

```
$grid->column('province_id')->distpicker();
$grid->column('city_id')->distpicker();
$grid->column('district_id')->distpicker();
```

并且提供了一个全局可用的辅助函数:

```
use SuperEggs\DcatDistpicker\DcatDistpickerHelper;

DcatDistpickerHelper::getAreaName($code); // return string
```

地区编码数据
------

[](#地区编码数据)

[Distpicker](https://github.com/fengyuanchen/distpicker) 所使用的地域编码是基于国家统计局发布的数据, 数据字典为`china_area.json`文件.

鸣谢
--

[](#鸣谢)

由衷感谢以下开源软件、框架等（包括但不限于）

- [laravel](https://laravel.com)
- [jqhph/dcat-admin](https://github.com/jqhph/dcat-admin)
- [fengyuanchen/distpicker](https://github.com/fengyuanchen/distpicker)
- [laravel-admin-extensions/china-distpicker](https://github.com/laravel-admin-extensions/china-distpicker)

License
-------

[](#license)

licensed under [The MIT License (MIT)](LICENSE).

###  Health Score

35

—

LowBetter than 81% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~68 days

Recently: every ~78 days

Total

12

Last Release

1186d ago

Major Versions

1.0.x-dev → 2.0.12021-03-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/63485dc068ee3d268e23e11c4402432f81a2807118cced441368fe6f9af4174c?d=identicon)[super-eggs](/maintainers/super-eggs)

---

Top Contributors

[![super-eggs](https://avatars.githubusercontent.com/u/35519664?v=4)](https://github.com/super-eggs "super-eggs (9 commits)")

---

Tags

extensiondcat admindistpicker

### Embed Badge

![Health badge](/badges/super-eggs-dcat-distpicker/health.svg)

```
[![Health](https://phpackages.com/badges/super-eggs-dcat-distpicker/health.svg)](https://phpackages.com/packages/super-eggs-dcat-distpicker)
```

###  Alternatives

[sparkinzy/dcat-distpicker

省市区地址选择器，支持select2

262.6k1](/packages/sparkinzy-dcat-distpicker)[super-eggs/dcat-admin-extensions-distpicker

Distpicker extension for dcat-admin

261.0k](/packages/super-eggs-dcat-admin-extensions-distpicker)[abbotton/dcat-sku-plus

基于Dcat Admin的SKU扩展增强版

542.2k](/packages/abbotton-dcat-sku-plus)[abovesky/dcat-media-player

Dcat Admin 音视频预览扩展

202.3k](/packages/abovesky-dcat-media-player)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
