weizong song 5 years ago
parent af3cb9d730
commit 795a185ecd

@ -9,6 +9,8 @@ class ProjectForm extends Form
{
public function buildForm()
{
$this->add("latitude", Field::HIDDEN);
$this->add("longitude", Field::HIDDEN);
$this->add("name", Field::TEXT, ["label" => "名称", "rules" => "required"]);
$this->add("address", Field::TEXT, ["label" => "地址", "rules" => "required"]);
$this->add("logo", Field::TEXT, ["label" => "logo", "attr" => ["data-plugin" => "uploader"]]);

@ -10,6 +10,7 @@ use App\Models\ApprovalItems;
use App\Models\Balance;
use App\Models\Building;
use App\Models\FactorItems;
use App\Models\ManagerProject;
use App\Models\OrderItems;
use App\Models\Orders;
use App\Models\Paramedic;
@ -35,31 +36,24 @@ class OrdersController extends CommonController
/**
* @OA\Get(
* path="/manager/get-projects",
* summary="获取项目/医院列表",
* description="获取项目/医院列表",
* summary="V2 获取医院列表",
* description="获取医院列表",
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
* description="获取项目/医院列表"
* description="获取医院列表"
* )
* )
*/
public function getProjects()
{
$projects = $this->manager->projects()->with(["paramedicLevels", "defaultProduct" => function ($query) {
$query->with([
"defaultItem",
"productItems",
"project",
"productParamedicLevels" => function ($query) {
$query->with("paramedicLevel");
},
"factors" => function ($query) {
$query->with("factorItems");
}
]);
}])->get();
$projects = (new Project())
->join("manager_project", 'project.id', '=', 'manager_project.project_id')
->join('managers', 'managers.id', '=', 'manager_project.manager_id')
->whereRaw("managers.id = " . $this->manager->id)
->select("project.id", "project.name", "project.address", "project.latitude", "project.longitude")
->get();
return response()->json($projects->toArray());
}
@ -230,7 +224,7 @@ class OrdersController extends CommonController
$order = (new Orders())->with([
"orderItems" => function ($query) {
$query->with([
"bed" => function($query) {
"bed" => function ($query) {
$query->with(["room", "building"]);
},
"room",

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateProjectAddGps extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table("project",function(Blueprint $table) {
$table->string("latitude")->nullable();
$table->string("longitude")->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

@ -9,7 +9,19 @@
<div class="col-12">
<div class="card">
<div class="card-body">
@include("public._form")
{!! form_start($form) !!}
@foreach($form->getFields() as $field)
{!! form_row($form->{$field->getName()},isset($vo[$field->getName()]) ? ["value"=>$vo[$field->getName()],"selected"=>$vo[$field->getName()]] : []) !!}
@if($field->getName()=="address")
<div class="mapimg" id="mapimg-box" style="position: relative">
<img style="position: absolute;top: 43%;left: 53%;transform: translate(-50%, -50%);z-index: 1;"
src="https://3gimg.qq.com/lightmap/api_v2/2/4/117/theme/default/imgs/marker.png"
alt="">
<div id="mapcontainer" style="height:200px"></div>
</div>
@endif
@endforeach
{!!form_end($form)!!}
</div>
</div>
</div>
@ -17,10 +29,86 @@
@endsection
@push("footer")
<script type="text/javascript"
src="https://map.qq.com/api/js?v=2.exp&key=D3HBZ-RAMHJ-KFHFR-KLK5H-OGWJ7-RNB63"></script>
<script>
function uploaderCallback(file, data, index) {
$('input[data-uploader-index=' + index + ']').val("/storage/" + (data.folder ? data.folder + "/" : "") + data.name);
return true;
}
$(function () {
if ($("#address").length) {
var mapimgBox = $("#mapimg-box");
$("#address").before(mapimgBox.clone());
mapimgBox.remove();
initMap();
$("#mapcontainer").bind("DOMNodeInserted", function (e) {
var tempCount = 0;
$("#mapcontainer .smnoprint").siblings().each(function () {
tempCount++;
if (tempCount == 2 || tempCount == 3) {
$(this).remove();
}
});
});
$("#address").blur(codeAddress);
}
});
var citylocation, map, geocoder = null;
var initMap = function () {
var latitude = $("input[name=latitude]").val();
var longitude = $("input[name=longitude]").val();
map = new qq.maps.Map(document.getElementById('mapcontainer'), {
// center: center,
zoom: 16,
});
if (latitude != "" && longitude != "") {
var center = new qq.maps.LatLng(latitude, longitude);
} else {
var center = new qq.maps.LatLng(31.835727, 119.905098);
}
map.panTo(center);
qq.maps.event.addListener(map, 'dragend', function () {
//地图移动停止后 获取经纬度
$('#latitude').val(map.getCenter().lat);
$('#longitude').val(map.getCenter().lng);
var coord = new qq.maps.LatLng(map.getCenter().lat, map.getCenter().lng);
geocoder.getAddress(coord);
});
//获取城市列表接口设置中心点
citylocation = new qq.maps.CityService({
complete: function (result) {
map.setCenter(result.detail.latLng);
}
});
//调用地址解析类
geocoder = new qq.maps.Geocoder({
complete: function (result) {
map.setCenter(result.detail.location);
//请求成功后 给经纬度赋值
$('#address').val(result.detail.address);
$('input[name=latitude]').val(result.detail.location.lat);
$('input[name=longitude]').val(result.detail.location.lng);
}
});
//调用searchLocalCity();方法 根据用户IP查询城市信息。
if (latitude == "" && longitude == "") {
citylocation.searchLocalCity();
}
};
function codeAddress() {
var address = $("#address").val();
//通过getLocation();方法获取位置信息值
if (address != "") {
geocoder.getLocation(address);
} else {
$.NotificationApp.send("提示", "请输入地址以查询坐标!", 'top-center', '#ffbc00', 'warning');
}
}
</script>
@endpush

Loading…
Cancel
Save