mirror of
https://github.com/cjango/dcat-vue.git
synced 2025-12-06 22:40:03 +08:00
一些优化,新增行政区划
This commit is contained in:
@@ -13,7 +13,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.0",
|
"php": "^8.0",
|
||||||
|
"laravel/framework": "^9.0",
|
||||||
"dcat/laravel-admin": "~2.0",
|
"dcat/laravel-admin": "~2.0",
|
||||||
"iidestiny/laravel-filesystem-oss": "^3.1",
|
"iidestiny/laravel-filesystem-oss": "^3.1",
|
||||||
"overtrue/laravel-filesystem-qiniu": "^2.1",
|
"overtrue/laravel-filesystem-qiniu": "^2.1",
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
.file-list-wrap[data-v-25c6ecfc]{margin-top:2px!important}.cropper-container{direction:ltr;font-size:0;line-height:0;position:relative;touch-action:none;user-select:none}.cropper-container img{display:block;height:100%;image-orientation:0deg;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}.cropper-wrap-box,.cropper-canvas,.cropper-drag-box,.cropper-crop-box,.cropper-modal{bottom:0;left:0;position:absolute;right:0;top:0}.cropper-wrap-box,.cropper-canvas{overflow:hidden}.cropper-drag-box{background-color:#fff;opacity:0}.cropper-modal{background-color:#000;opacity:.5}.cropper-view-box{display:block;height:100%;outline:1px solid #39f;outline-color:#3399ffbf;overflow:hidden;width:100%}.cropper-dashed{border:0 dashed #eee;display:block;opacity:.5;position:absolute}.cropper-dashed.dashed-h{border-bottom-width:1px;border-top-width:1px;height:33.3333333333%;left:0;top:33.3333333333%;width:100%}.cropper-dashed.dashed-v{border-left-width:1px;border-right-width:1px;height:100%;left:33.3333333333%;top:0;width:33.3333333333%}.cropper-center{display:block;height:0;left:50%;opacity:.75;position:absolute;top:50%;width:0}.cropper-center:before,.cropper-center:after{background-color:#eee;content:" ";display:block;position:absolute}.cropper-center:before{height:1px;left:-3px;top:0;width:7px}.cropper-center:after{height:7px;left:0;top:-3px;width:1px}.cropper-face,.cropper-line,.cropper-point{display:block;height:100%;opacity:.1;position:absolute;width:100%}.cropper-face{background-color:#fff;left:0;top:0}.cropper-line{background-color:#39f}.cropper-line.line-e{cursor:ew-resize;right:-3px;top:0;width:5px}.cropper-line.line-n{cursor:ns-resize;height:5px;left:0;top:-3px}.cropper-line.line-w{cursor:ew-resize;left:-3px;top:0;width:5px}.cropper-line.line-s{bottom:-3px;cursor:ns-resize;height:5px;left:0}.cropper-point{background-color:#39f;height:5px;opacity:.75;width:5px}.cropper-point.point-e{cursor:ew-resize;margin-top:-3px;right:-3px;top:50%}.cropper-point.point-n{cursor:ns-resize;left:50%;margin-left:-3px;top:-3px}.cropper-point.point-w{cursor:ew-resize;left:-3px;margin-top:-3px;top:50%}.cropper-point.point-s{bottom:-3px;cursor:s-resize;left:50%;margin-left:-3px}.cropper-point.point-ne{cursor:nesw-resize;right:-3px;top:-3px}.cropper-point.point-nw{cursor:nwse-resize;left:-3px;top:-3px}.cropper-point.point-sw{bottom:-3px;cursor:nesw-resize;left:-3px}.cropper-point.point-se{bottom:-3px;cursor:nwse-resize;height:20px;opacity:1;right:-3px;width:20px}@media (min-width: 768px){.cropper-point.point-se{height:15px;width:15px}}@media (min-width: 992px){.cropper-point.point-se{height:10px;width:10px}}@media (min-width: 1200px){.cropper-point.point-se{height:5px;opacity:.75;width:5px}}.cropper-point.point-se:before{background-color:#39f;bottom:-50%;content:" ";display:block;height:200%;opacity:0;position:absolute;right:-50%;width:200%}.cropper-invisible{opacity:0}.cropper-bg{background-image:url(../images/bg.png)}.cropper-hide{display:block;height:0;position:absolute;width:0}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed}.n-modal-container{z-index:99999999!important}.modal-container[data-v-7a8a7584]{display:flex;flex-direction:column}.modal-container .cropper-container[data-v-7a8a7584]{width:480px;height:270px}.modal-container .cropper-container img[data-v-7a8a7584]{max-width:100%;display:block}.modal-container .large[data-v-7a8a7584]{width:960px!important;height:540px!important}.modal-container .cropper-controls[data-v-7a8a7584]{height:50px;display:flex;align-items:center}.modal-container .cropper-controls .controls-first[data-v-7a8a7584]{margin-left:12px}.file-list-wrap[data-v-4917ac86]{margin-top:2px!important}.preview[data-v-4917ac86]{width:138px;height:138px;border:1px solid #dae1e7;border-radius:10px;background-color:#f1f1f1;display:flex;justify-content:center;align-items:center}.preview img[data-v-4917ac86]{max-width:100%;max-height:100%;border-radius:4px;padding:1px}.preview[data-v-4917ac86]:hover{border:1px dashed #2dd3c4}.custom-upload-dragger[data-v-4917ac86]{width:138px;height:138px;display:flex;justify-content:center;align-items:center;border-radius:10px}.custom-upload-dragger .btn-plus[data-v-4917ac86]{font-size:88px;color:#b0b0b0}.add[data-v-f1fb3bdc]{font-size:20px}
|
.file-list-wrap[data-v-25c6ecfc]{margin-top:2px!important}.cropper-container{direction:ltr;font-size:0;line-height:0;position:relative;touch-action:none;user-select:none}.cropper-container img{backface-visibility:hidden;display:block;height:100%;image-orientation:0deg;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}.cropper-wrap-box,.cropper-canvas,.cropper-drag-box,.cropper-crop-box,.cropper-modal{bottom:0;left:0;position:absolute;right:0;top:0}.cropper-wrap-box,.cropper-canvas{overflow:hidden}.cropper-drag-box{background-color:#fff;opacity:0}.cropper-modal{background-color:#000;opacity:.5}.cropper-view-box{display:block;height:100%;outline:1px solid #39f;outline-color:#3399ffbf;overflow:hidden;width:100%}.cropper-dashed{border:0 dashed #eee;display:block;opacity:.5;position:absolute}.cropper-dashed.dashed-h{border-bottom-width:1px;border-top-width:1px;height:33.3333333333%;left:0;top:33.3333333333%;width:100%}.cropper-dashed.dashed-v{border-left-width:1px;border-right-width:1px;height:100%;left:33.3333333333%;top:0;width:33.3333333333%}.cropper-center{display:block;height:0;left:50%;opacity:.75;position:absolute;top:50%;width:0}.cropper-center:before,.cropper-center:after{background-color:#eee;content:" ";display:block;position:absolute}.cropper-center:before{height:1px;left:-3px;top:0;width:7px}.cropper-center:after{height:7px;left:0;top:-3px;width:1px}.cropper-face,.cropper-line,.cropper-point{display:block;height:100%;opacity:.1;position:absolute;width:100%}.cropper-face{background-color:#fff;left:0;top:0}.cropper-line{background-color:#39f}.cropper-line.line-e{cursor:ew-resize;right:-3px;top:0;width:5px}.cropper-line.line-n{cursor:ns-resize;height:5px;left:0;top:-3px}.cropper-line.line-w{cursor:ew-resize;left:-3px;top:0;width:5px}.cropper-line.line-s{bottom:-3px;cursor:ns-resize;height:5px;left:0}.cropper-point{background-color:#39f;height:5px;opacity:.75;width:5px}.cropper-point.point-e{cursor:ew-resize;margin-top:-3px;right:-3px;top:50%}.cropper-point.point-n{cursor:ns-resize;left:50%;margin-left:-3px;top:-3px}.cropper-point.point-w{cursor:ew-resize;left:-3px;margin-top:-3px;top:50%}.cropper-point.point-s{bottom:-3px;cursor:s-resize;left:50%;margin-left:-3px}.cropper-point.point-ne{cursor:nesw-resize;right:-3px;top:-3px}.cropper-point.point-nw{cursor:nwse-resize;left:-3px;top:-3px}.cropper-point.point-sw{bottom:-3px;cursor:nesw-resize;left:-3px}.cropper-point.point-se{bottom:-3px;cursor:nwse-resize;height:20px;opacity:1;right:-3px;width:20px}@media (min-width: 768px){.cropper-point.point-se{height:15px;width:15px}}@media (min-width: 992px){.cropper-point.point-se{height:10px;width:10px}}@media (min-width: 1200px){.cropper-point.point-se{height:5px;opacity:.75;width:5px}}.cropper-point.point-se:before{background-color:#39f;bottom:-50%;content:" ";display:block;height:200%;opacity:0;position:absolute;right:-50%;width:200%}.cropper-invisible{opacity:0}.cropper-bg{background-image:url(../images/bg.png)}.cropper-hide{display:block;height:0;position:absolute;width:0}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed}.n-modal-container{z-index:99999999!important}.modal-container[data-v-7a8a7584]{display:flex;flex-direction:column}.modal-container .cropper-container[data-v-7a8a7584]{width:480px;height:270px}.modal-container .cropper-container img[data-v-7a8a7584]{max-width:100%;display:block}.modal-container .large[data-v-7a8a7584]{width:960px!important;height:540px!important}.modal-container .cropper-controls[data-v-7a8a7584]{height:50px;display:flex;align-items:center}.modal-container .cropper-controls .controls-first[data-v-7a8a7584]{margin-left:12px}.file-list-wrap[data-v-4917ac86]{margin-top:2px!important}.preview[data-v-4917ac86]{width:138px;height:138px;border:1px solid #dae1e7;border-radius:10px;background-color:#f1f1f1;display:flex;justify-content:center;align-items:center}.preview img[data-v-4917ac86]{max-width:100%;max-height:100%;border-radius:4px;padding:1px}.preview[data-v-4917ac86]:hover{border:1px dashed #2dd3c4}.custom-upload-dragger[data-v-4917ac86]{width:138px;height:138px;display:flex;justify-content:center;align-items:center;border-radius:10px}.custom-upload-dragger .btn-plus[data-v-4917ac86]{font-size:88px;color:#b0b0b0}.add[data-v-f1fb3bdc]{font-size:20px}.map-container{margin-top:18px;height:var(--3c04e933)}.map-container canvas{border-radius:10px;box-shadow:1px 1px 6px #aaa}
|
||||||
|
|||||||
36
resources/assets/js/helper.js
Normal file
36
resources/assets/js/helper.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
if (!window.dv) {
|
||||||
|
window.dv = {instances: {}, maps: {wemap: false}}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 腾讯地图加载
|
||||||
|
window.addEventListener('import.map.wemap', () => {
|
||||||
|
if (window.dv.maps.wemap) {
|
||||||
|
window.dispatchEvent(new CustomEvent('imported.map.wemap'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
window.loadedWeMap = function () {
|
||||||
|
window.dv.maps.wemap = true
|
||||||
|
window.dispatchEvent(new CustomEvent('imported.map.wemap'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const script = document.createElement('script')
|
||||||
|
script.src = 'https://map.qq.com/api/gljs?v=1.exp&key=ZZQBZ-WE6E2-FCMUZ-CBUZ7-ZW5I3-I7BIX&libraries=service&callback=loadedWeMap'
|
||||||
|
// script.src = 'https://map.qq.com/api/js?v=2.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77&callback=loadedWeMap'
|
||||||
|
// script.src = 'https://wemapvis.map.qq.com/api/gljs/v2?v=1.exp&key=ZZQBZ-WE6E2-FCMUZ-CBUZ7-ZW5I3-I7BIX&callback=loadedWeMap'
|
||||||
|
document.head.appendChild(script)
|
||||||
|
})
|
||||||
|
|
||||||
|
// 实例清理
|
||||||
|
setInterval(() => {
|
||||||
|
for (let instance in window.dv.instances) {
|
||||||
|
if (window.dv.instances[instance]) {
|
||||||
|
if (!document.getElementById(window.dv.instances[instance]._container.id)) {
|
||||||
|
window.dv.instances[instance].unmount()
|
||||||
|
delete window.dv.instances[instance]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delete window.dv.instances[instance]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 3000)
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,10 +1,8 @@
|
|||||||
@php($id = join('_', (array)str_replace(['[', ']'], '', $name)) . '_' . Str::random(6))
|
|
||||||
|
|
||||||
<div class="{{$viewClass['form-group']}}" >
|
<div class="{{$viewClass['form-group']}}" >
|
||||||
|
|
||||||
<label class="{{$viewClass['label']}} control-label pt-0">{!! $label !!}</label>
|
<label class="{{$viewClass['label']}} control-label pt-0">{!! $label !!}</label>
|
||||||
|
|
||||||
<div class="{{$viewClass['field']}}" id="{{ $id }}">
|
<div class="{{$viewClass['field']}}" id="{{ $mountId }}">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -13,5 +11,11 @@
|
|||||||
const App = app()
|
const App = app()
|
||||||
|
|
||||||
App.provide('provides', @json($provides, true))
|
App.provide('provides', @json($provides, true))
|
||||||
App.mount('#{{ $id }}')
|
App.mount('#{{ $mountId }}')
|
||||||
|
|
||||||
|
if (!window.dv) {
|
||||||
|
window.dv = {instances: {}, maps: {wemap: false}}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.dv.instances["{{ $mountId }}"] = App
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ namespace Weiwait\DcatVue;
|
|||||||
use Dcat\Admin\Extend\ServiceProvider;
|
use Dcat\Admin\Extend\ServiceProvider;
|
||||||
use Dcat\Admin\Admin;
|
use Dcat\Admin\Admin;
|
||||||
use Dcat\Admin\Form;
|
use Dcat\Admin\Form;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
use Weiwait\DcatVue\Field\DateRange;
|
use Weiwait\DcatVue\Field\DateRange;
|
||||||
|
use Weiwait\DcatVue\Field\Distpicker;
|
||||||
use Weiwait\DcatVue\Field\File;
|
use Weiwait\DcatVue\Field\File;
|
||||||
use Weiwait\DcatVue\Field\Image;
|
use Weiwait\DcatVue\Field\Image;
|
||||||
use Weiwait\DcatVue\Field\KeyValue;
|
use Weiwait\DcatVue\Field\KeyValue;
|
||||||
@@ -20,7 +22,7 @@ use Weiwait\DcatVue\Models\FilesystemConfig;
|
|||||||
class DcatVueServiceProvider extends ServiceProvider
|
class DcatVueServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
protected $js = [
|
protected $js = [
|
||||||
'js/index.js',
|
'js/helper.js',
|
||||||
];
|
];
|
||||||
protected $css = [
|
protected $css = [
|
||||||
'css/index.css',
|
'css/index.css',
|
||||||
@@ -35,6 +37,8 @@ class DcatVueServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
|
$this->loadMigrationsFrom(__DIR__ . '/../migrations');
|
||||||
|
|
||||||
$this->hackConfigs();
|
$this->hackConfigs();
|
||||||
|
|
||||||
// Form::extend('vue', Vue::class);
|
// Form::extend('vue', Vue::class);
|
||||||
@@ -45,9 +49,10 @@ class DcatVueServiceProvider extends ServiceProvider
|
|||||||
Form::extend('vTags', Tag::class);
|
Form::extend('vTags', Tag::class);
|
||||||
Form::extend('vList', ListField::class);
|
Form::extend('vList', ListField::class);
|
||||||
Form::extend('vKeyValue', KeyValue::class);
|
Form::extend('vKeyValue', KeyValue::class);
|
||||||
// Form::extend('dateRange', DateRange::class);
|
Form::extend('vDistpicker', Distpicker::class);
|
||||||
|
Form::extend('vDateRange', DateRange::class);
|
||||||
|
|
||||||
Admin::asset()->css(Admin::asset()->getAlias('@weiwait.dcat-vue')['css']);
|
Admin::requireAssets('@weiwait.dcat-vue');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingForm()
|
public function settingForm()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Weiwait\DcatVue\Field;
|
|||||||
|
|
||||||
use Dcat\Admin\Form\Field;
|
use Dcat\Admin\Form\Field;
|
||||||
use Dcat\Admin\Support\Helper;
|
use Dcat\Admin\Support\Helper;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class DateRange extends Field\DateRange
|
class DateRange extends Field\DateRange
|
||||||
{
|
{
|
||||||
@@ -49,6 +50,7 @@ class DateRange extends Field\DateRange
|
|||||||
{
|
{
|
||||||
$this->addVariables([
|
$this->addVariables([
|
||||||
'component' => 'DateRange',
|
'component' => 'DateRange',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
167
src/Field/Distpicker.php
Normal file
167
src/Field/Distpicker.php
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Weiwait\DcatVue\Field;
|
||||||
|
|
||||||
|
use Dcat\Admin\Form\Field;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class Distpicker extends Field
|
||||||
|
{
|
||||||
|
protected $view = 'weiwait.dcat-vue::common';
|
||||||
|
// 地图高度
|
||||||
|
protected string $height = '380px';
|
||||||
|
// 模板id
|
||||||
|
protected string $areaId = '';
|
||||||
|
// 关闭地图
|
||||||
|
protected bool $disableMap = false;
|
||||||
|
// 地址详细字段
|
||||||
|
protected string $detailField = '';
|
||||||
|
// 经度字段
|
||||||
|
protected string $lngField = '';
|
||||||
|
// 纬度字段
|
||||||
|
protected string $latField = '';
|
||||||
|
// 省字段
|
||||||
|
protected string $provinceField = '';
|
||||||
|
// 市字段
|
||||||
|
protected string $cityField = '';
|
||||||
|
// 区字段
|
||||||
|
protected string $districtField = '';
|
||||||
|
// 地图缩放字段
|
||||||
|
protected string $zoomField = '';
|
||||||
|
// 地图缩放
|
||||||
|
protected float $zoom = 13.14;
|
||||||
|
// 禁止选择
|
||||||
|
protected array $disables = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function __construct($label)
|
||||||
|
{
|
||||||
|
$this->areaId = md5(Str::uuid());
|
||||||
|
parent::__construct([], [$label]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dist(string $province = null, string $city = null, string $district = null): self
|
||||||
|
{
|
||||||
|
if ($province) {
|
||||||
|
$this->column[$province] = $province;
|
||||||
|
$this->provinceField = $province;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($city) {
|
||||||
|
$this->column[$city] = $city;
|
||||||
|
$this->cityField = $city;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($district) {
|
||||||
|
$this->column[$district] = $district;
|
||||||
|
$this->districtField = $district;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function coordinate(string $lat, string $lng): self
|
||||||
|
{
|
||||||
|
$this->column[$lat] = $lat;
|
||||||
|
$this->column[$lng] = $lng;
|
||||||
|
|
||||||
|
$this->latField = $lat;
|
||||||
|
$this->lngField = $lng;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detail(string $detail): self
|
||||||
|
{
|
||||||
|
$this->column[$detail] = $detail;
|
||||||
|
|
||||||
|
$this->detailField = $detail;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mapHeight(int $height, string $unit = 'px'): self
|
||||||
|
{
|
||||||
|
$this->height = $height . $unit;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disableMap(bool $disable = true): self
|
||||||
|
{
|
||||||
|
$this->disableMap = $disable;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mapZoom(float $zoom = 13.14, string $column = ''): self
|
||||||
|
{
|
||||||
|
$this->zoom = $zoom;
|
||||||
|
|
||||||
|
if ($column) {
|
||||||
|
$this->column[$column] = $column;
|
||||||
|
|
||||||
|
$this->zoomField = $column;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disableRegions(array $regions): self
|
||||||
|
{
|
||||||
|
$this->disables = $regions;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function withProvides()
|
||||||
|
{
|
||||||
|
$this->addVariables([
|
||||||
|
'component' => 'DistPicker',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
|
'height' => $this->height,
|
||||||
|
'areaId' => $this->areaId,
|
||||||
|
'provinceField' => $this->provinceField,
|
||||||
|
'cityField' => $this->cityField,
|
||||||
|
'districtField' => $this->districtField,
|
||||||
|
'detailField' => $this->detailField,
|
||||||
|
'lngField' => $this->lngField,
|
||||||
|
'latField' => $this->latField,
|
||||||
|
'disableMap' => $this->disableMap,
|
||||||
|
'zoom' => $this->zoom,
|
||||||
|
'zoomField' => $this->zoomField,
|
||||||
|
'disables' => $this->disables,
|
||||||
|
'urls' => [
|
||||||
|
'address2ll' => route('dcat.admin.weiwait.distpicker.address2ll'),
|
||||||
|
'll2address' => route('dcat.admin.weiwait.distpicker.ll2address'),
|
||||||
|
'regions' => route('dcat.admin.weiwait.distpicker.regions'),
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
if (! $this->shouldRender()) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setDefaultClass();
|
||||||
|
|
||||||
|
$this->callComposing();
|
||||||
|
|
||||||
|
$this->withScript();
|
||||||
|
|
||||||
|
/****************************** custom ************************************/
|
||||||
|
|
||||||
|
$this->withProvides();
|
||||||
|
|
||||||
|
$this->addVariables([
|
||||||
|
'provides' => $this->variables(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view($this->view(), $this->variables());
|
||||||
|
}
|
||||||
|
}
|
||||||
61
src/Field/Editor.php
Normal file
61
src/Field/Editor.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Weiwait\DcatVue\Field;
|
||||||
|
|
||||||
|
use Dcat\Admin\Form\Field;
|
||||||
|
use Dcat\Admin\Support\Helper;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Weiwait\DcatVue\Field\Traits\UploadTrait;
|
||||||
|
|
||||||
|
class Editor extends Field\Editor
|
||||||
|
{
|
||||||
|
use UploadTrait;
|
||||||
|
|
||||||
|
protected $view = 'weiwait.dcat-vue::common';
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
/****************************** parent ************************************/
|
||||||
|
|
||||||
|
$this->addVariables([
|
||||||
|
'options' => $this->formatOptions(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/****************************** field ************************************/
|
||||||
|
|
||||||
|
if (!$this->shouldRender()) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setDefaultClass();
|
||||||
|
|
||||||
|
$this->callComposing();
|
||||||
|
|
||||||
|
$this->withScript();
|
||||||
|
|
||||||
|
/****************************** custom ************************************/
|
||||||
|
|
||||||
|
$this->withProvides();
|
||||||
|
|
||||||
|
$this->withUpload();
|
||||||
|
|
||||||
|
$this->addVariables([
|
||||||
|
'provides' => $this->variables(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return view($this->view(), $this->variables());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function formatAttributes()
|
||||||
|
{
|
||||||
|
return $this->attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function withProvides()
|
||||||
|
{
|
||||||
|
$this->addVariables([
|
||||||
|
'component' => 'Editor',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Weiwait\DcatVue\Field;
|
namespace Weiwait\DcatVue\Field;
|
||||||
|
|
||||||
use Dcat\Admin\Form\Field;
|
use Dcat\Admin\Form\Field;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
||||||
|
|
||||||
class File extends Field\File
|
class File extends Field\File
|
||||||
@@ -49,6 +50,7 @@ class File extends Field\File
|
|||||||
|
|
||||||
$this->addVariables([
|
$this->addVariables([
|
||||||
'component' => 'File',
|
'component' => 'File',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'disk' => $this->disk ?? $disk,
|
'disk' => $this->disk ?? $disk,
|
||||||
'dir' => $this->getDirectory(),
|
'dir' => $this->getDirectory(),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Weiwait\DcatVue\Field;
|
|||||||
|
|
||||||
use Dcat\Admin\Form\Field;
|
use Dcat\Admin\Form\Field;
|
||||||
use Dcat\Admin\Support\Helper;
|
use Dcat\Admin\Support\Helper;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
||||||
|
|
||||||
class Image extends Field\Image
|
class Image extends Field\Image
|
||||||
@@ -54,6 +55,7 @@ class Image extends Field\Image
|
|||||||
|
|
||||||
$this->addVariables([
|
$this->addVariables([
|
||||||
'component' => 'Image',
|
'component' => 'Image',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'disk' => $this->disk ?? $disk,
|
'disk' => $this->disk ?? $disk,
|
||||||
'dir' => $this->getDirectory(),
|
'dir' => $this->getDirectory(),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use Dcat\Admin\Form\Field;
|
|||||||
use Dcat\Admin\Support\Helper;
|
use Dcat\Admin\Support\Helper;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use function Swoole\Coroutine\map;
|
use function Swoole\Coroutine\map;
|
||||||
|
|
||||||
class KeyValue extends Field\KeyValue
|
class KeyValue extends Field\KeyValue
|
||||||
@@ -143,6 +144,7 @@ class KeyValue extends Field\KeyValue
|
|||||||
{
|
{
|
||||||
$this->addVariables([
|
$this->addVariables([
|
||||||
'component' => 'KeyValue',
|
'component' => 'KeyValue',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Weiwait\DcatVue\Field;
|
|||||||
|
|
||||||
use Dcat\Admin\Form\Field;
|
use Dcat\Admin\Form\Field;
|
||||||
use Dcat\Admin\Support\Helper;
|
use Dcat\Admin\Support\Helper;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class ListField extends Field\ListField
|
class ListField extends Field\ListField
|
||||||
{
|
{
|
||||||
@@ -54,6 +55,7 @@ class ListField extends Field\ListField
|
|||||||
{
|
{
|
||||||
$this->addVariables([
|
$this->addVariables([
|
||||||
'component' => 'List',
|
'component' => 'List',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Weiwait\DcatVue\Field;
|
namespace Weiwait\DcatVue\Field;
|
||||||
|
|
||||||
use Dcat\Admin\Form\Field;
|
use Dcat\Admin\Form\Field;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
||||||
|
|
||||||
class MultipleFile extends Field\MultipleFile
|
class MultipleFile extends Field\MultipleFile
|
||||||
@@ -49,6 +50,7 @@ class MultipleFile extends Field\MultipleFile
|
|||||||
|
|
||||||
$this->addVariables([
|
$this->addVariables([
|
||||||
'component' => 'File',
|
'component' => 'File',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'disk' => $this->disk ?? $disk,
|
'disk' => $this->disk ?? $disk,
|
||||||
'dir' => $this->getDirectory(),
|
'dir' => $this->getDirectory(),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Weiwait\DcatVue\Field;
|
|||||||
|
|
||||||
use Dcat\Admin\Form\Field;
|
use Dcat\Admin\Form\Field;
|
||||||
use Dcat\Admin\Support\Helper;
|
use Dcat\Admin\Support\Helper;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
||||||
|
|
||||||
class MultipleImage extends Field\MultipleImage
|
class MultipleImage extends Field\MultipleImage
|
||||||
@@ -54,6 +55,7 @@ class MultipleImage extends Field\MultipleImage
|
|||||||
|
|
||||||
$this->addVariables([
|
$this->addVariables([
|
||||||
'component' => 'Image',
|
'component' => 'Image',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'disk' => $this->disk ?? $disk,
|
'disk' => $this->disk ?? $disk,
|
||||||
'dir' => $this->getDirectory(),
|
'dir' => $this->getDirectory(),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Weiwait\DcatVue\Field;
|
|||||||
|
|
||||||
use Dcat\Admin\Form\Field;
|
use Dcat\Admin\Form\Field;
|
||||||
use Dcat\Admin\Support\Helper;
|
use Dcat\Admin\Support\Helper;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class Tag extends Field\Tags
|
class Tag extends Field\Tags
|
||||||
{
|
{
|
||||||
@@ -63,6 +64,7 @@ class Tag extends Field\Tags
|
|||||||
{
|
{
|
||||||
$this->addVariables([
|
$this->addVariables([
|
||||||
'component' => 'Tag',
|
'component' => 'Tag',
|
||||||
|
'mountId' => 'id' . md5(Str::uuid()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
28
src/Field/Traits/UploadTrait.php
Normal file
28
src/Field/Traits/UploadTrait.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Weiwait\DcatVue\Field\Traits;
|
||||||
|
|
||||||
|
trait UploadTrait
|
||||||
|
{
|
||||||
|
use \Dcat\Admin\Form\Field\UploadField;
|
||||||
|
|
||||||
|
public function withUpload()
|
||||||
|
{
|
||||||
|
$this->addVariables([
|
||||||
|
'uploader' => [
|
||||||
|
'disk' => $this->disk,
|
||||||
|
'dir' => $this->getDirectory(),
|
||||||
|
'uploaded_url' => route('dcat.admin.weiwait.file.uploaded'),
|
||||||
|
'obs_config_url' => route('dcat.admin.weiwait.file.obs-config'),
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function defaultDirectory()
|
||||||
|
{
|
||||||
|
return config('admin.upload.directory.file');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,11 @@ use Dcat\Admin\Layout\Content;
|
|||||||
use Dcat\Admin\Admin;
|
use Dcat\Admin\Admin;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Routing\Controller;
|
use Illuminate\Routing\Controller;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Qiniu\Config;
|
use Qiniu\Config;
|
||||||
use Weiwait\DcatVue\Forms\FilesystemConfig;
|
use Weiwait\DcatVue\Forms\FilesystemConfig;
|
||||||
|
use Weiwait\DcatVue\Models\ChinaArea;
|
||||||
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
use Weiwait\DcatVue\Models\WeiwaitUpload;
|
||||||
|
|
||||||
class DcatVueController extends Controller
|
class DcatVueController extends Controller
|
||||||
@@ -43,10 +45,14 @@ class DcatVueController extends Controller
|
|||||||
);
|
);
|
||||||
|
|
||||||
case 'qiniu':
|
case 'qiniu':
|
||||||
$url = (new Config())->getUpHost(
|
$config = new Config();
|
||||||
|
$config->useHTTPS = 'https' == $request->getScheme();
|
||||||
|
|
||||||
|
$url = $config->getUpHost(
|
||||||
config('filesystems.disks.qiniu.access_key'),
|
config('filesystems.disks.qiniu.access_key'),
|
||||||
config('filesystems.disks.qiniu.bucket')
|
config('filesystems.disks.qiniu.bucket')
|
||||||
);
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'token' => Storage::disk('qiniu')->getAdapter()->getUploadToken($request['filename'], 3600),
|
'token' => Storage::disk('qiniu')->getAdapter()->getUploadToken($request['filename'], 3600),
|
||||||
'host' => $url,
|
'host' => $url,
|
||||||
@@ -86,4 +92,27 @@ class DcatVueController extends Controller
|
|||||||
return $content
|
return $content
|
||||||
->body(new FilesystemConfig());
|
->body(new FilesystemConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function regions(Request $request)
|
||||||
|
{
|
||||||
|
$items = ChinaArea::query()->where('pcode', $request->get('pcode', 0))
|
||||||
|
->get(['code as value', 'name as label', 'pcode']);
|
||||||
|
|
||||||
|
return response()->json(['items' => $items]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function address2ll(Request $request)
|
||||||
|
{
|
||||||
|
$sign = 'rYRi7PfL5beOtUfcABaF4MIFHaHGDPE';
|
||||||
|
|
||||||
|
$uri = "/ws/geocoder/v1/?address={$request['address']}&key=ZZQBZ-WE6E2-FCMUZ-CBUZ7-ZW5I3-I7BIX";
|
||||||
|
$uri .= '&sig=' . md5($uri . $sign);
|
||||||
|
|
||||||
|
return Http::get('https://apis.map.qq.com' . $uri)->body();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ll2address(Request $request)
|
||||||
|
{
|
||||||
|
return Http::get("https://apis.map.qq.com/ws/geocoder/v1/?location={$request['lat']},{$request['lng']}&key=ZZQBZ-WE6E2-FCMUZ-CBUZ7-ZW5I3-I7BIX&get_poi=1")->body();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,3 +14,12 @@ Route::post('weiwait/file/uploaded', [Controllers\DcatVueController::class, 'upl
|
|||||||
// 本地上传
|
// 本地上传
|
||||||
Route::post('weiwait/file/upload', [Controllers\DcatVueController::class, 'upload'])
|
Route::post('weiwait/file/upload', [Controllers\DcatVueController::class, 'upload'])
|
||||||
->name('weiwait.file.upload');
|
->name('weiwait.file.upload');
|
||||||
|
// 区划
|
||||||
|
Route::get('weiwait/distpicker/regions', [Controllers\DcatVueController::class, 'regions'])
|
||||||
|
->name('weiwait.distpicker.regions');
|
||||||
|
// 地址解析
|
||||||
|
Route::get('weiwait/distpicker/address2ll', [Controllers\DcatVueController::class, 'address2ll'])
|
||||||
|
->name('weiwait.distpicker.address2ll');
|
||||||
|
// 坐标位置信息
|
||||||
|
Route::get('weiwait/distpicker/ll2address', [Controllers\DcatVueController::class, 'll2address'])
|
||||||
|
->name('weiwait.distpicker.ll2address');
|
||||||
|
|||||||
26
src/Models/ChinaArea.php
Normal file
26
src/Models/ChinaArea.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Weiwait\DcatVue\Models;
|
||||||
|
|
||||||
|
use Dcat\Admin\Traits\HasDateTimeFormatter;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ChinaArea extends Model
|
||||||
|
{
|
||||||
|
use HasDateTimeFormatter;
|
||||||
|
|
||||||
|
public static function provinces()
|
||||||
|
{
|
||||||
|
return self::query()->where('level', 1)->get(['code as value', 'name as label', 'pcode']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function cities()
|
||||||
|
{
|
||||||
|
return self::query()->where('level', 2)->get(['code as value', 'name as label', 'pcode']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function districts()
|
||||||
|
{
|
||||||
|
return self::query()->where('level', 3)->get(['code as value', 'name as label', 'pcode']);
|
||||||
|
}
|
||||||
|
}
|
||||||
25546
updates/ChinaAreaTableSeeder.php
Normal file
25546
updates/ChinaAreaTableSeeder.php
Normal file
File diff suppressed because it is too large
Load Diff
34
updates/create_china_areas_table.php
Normal file
34
updates/create_china_areas_table.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class CreateChinaArea extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('china_areas', function (Blueprint $table) {
|
||||||
|
$table->id('code');
|
||||||
|
$table->string('name')->comment('地区');
|
||||||
|
$table->unsignedTinyInteger('level')->index();
|
||||||
|
$table->unsignedBigInteger('pcode')->index()->comment('上级区划');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('china_areas');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class CreateFielsystemConfigTable extends Migration
|
class CreateFielsystemConfig extends Migration
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
|
|||||||
@@ -13,14 +13,12 @@ class CreateWeiwaitUpload extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
if (!Schema::hasTable('weiwait_uploads')) {
|
Schema::create('weiwait_uploads', function (Blueprint $table) {
|
||||||
Schema::create('weiwait_uploads', function (Blueprint $table) {
|
$table->increments('id');
|
||||||
$table->increments('id');
|
$table->string('name')->comment('文件');
|
||||||
$table->string('name')->comment('文件');
|
$table->string('disk')->nullable()->comment('磁盘');
|
||||||
$table->string('disk')->nullable()->comment('磁盘');
|
$table->timestamps();
|
||||||
$table->timestamps();
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,4 +43,10 @@ return [
|
|||||||
'2.1.2' => [
|
'2.1.2' => [
|
||||||
'优化配置注入'
|
'优化配置注入'
|
||||||
],
|
],
|
||||||
|
'2.2.0' => [
|
||||||
|
'一些优化',
|
||||||
|
'新增行政区划选择',
|
||||||
|
'create_china_areas_table.php',
|
||||||
|
'ChinaAreaTableSeeder.php',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user