import{f as X,g as Y,h as Z,i as ee}from"./project-BXefkNgD.js";import{r as p,C as te,D as ae,e as u,E as q,o as h,c as oe,f as a,h as o,G as y,J as b,m as _,i as l,K as G,k as P,B as ne,v as le}from"./index-C1_1_QXk.js";const re={class:"app-container"},ie=P("div",{id:"container"},null,-1),se={class:"dialog-footer"},ue=ne({name:"Post"}),me=Object.assign(ue,{setup(de){const{proxy:n}=le(),d=p(!1),w=p([]),k=p(!0),x=p(!0);p(!0),p(!0);const C=p(""),D=te({form:{},queryParams:{pro_id:n.$route.query.proId},rules:{range:[{required:!0,message:"请输入范围",trigger:"blur"}],address:[{required:!0,message:"请输入接站地点,并点击定位按钮进行获取经纬度",trigger:"blur"}]}}),{queryParams:U,form:e,rules:j}=ae(D);v();var r,m,S,c;function V(){c=new TMap.LatLng(39.916527,116.397128),r=new TMap.Map("container",{center:c}),S=new TMap.service.Geocoder,m=new TMap.MultiMarker({map:r,geometries:[]}),r.on("click",t=>{e.value.x=t.latLng.toString().split(",")[0],e.value.y=t.latLng.toString().split(",")[1],m.updateGeometries([{id:"main",position:t.latLng}])})}function B(){m.setGeometries([]),S.getLocation({address:e.value.address}).then(t=>{m.updateGeometries([{id:"main",position:t.result.location}]),r.setCenter(t.result.location),console.log(t.result.location),e.value.x=t.result.location.toString().split(",")[0],e.value.y=t.result.location.toString().split(",")[1]})}function v(){k.value=!0,X(U.value).then(t=>{w.value=t.data,k.value=!1})}function E(){d.value=!1}function I(t){}function R(){if(w.value.length==5){n.$modal.msgError("最多只能维护5条数据！");return}e.value={},d.value=!0,C.value="考勤坐标",n.$nextTick(()=>{r==null||r==null?V():(m.setGeometries([]),c=new TMap.LatLng(39.916527,116.397128),r.setCenter(c))})}function N(t){e.value=t,d.value=!0,C.value="坐标维护",n.$nextTick(()=>{(r==null||r==null)&&V(),c=new TMap.LatLng(e.value.x,e.value.y),r.setCenter(c),m.updateGeometries([{id:"main",position:c}])})}function Q(){if(e.value.pro_id=n.$route.query.proId,e.value.basecode=n.$route.query.basecode,e.value.x==null||e.value.x==""){n.$modal.msgError("请在地图上标记坐标点");return}n.$refs.postRef.validate(t=>{t&&(e.value.id?Y(e.value).then(i=>{n.$modal.msgSuccess("修改成功"),d.value=!1,v()}):Z(e.value).then(i=>{n.$modal.msgSuccess("新增成功"),d.value=!1,v()}))})}function A(t){n.$modal.confirm("您确定要删除吗？").then(function(){return ee({id:t.id})}).then(()=>{v(),n.$modal.msgSuccess("删除成功")}).catch(()=>{})}return(t,i)=>{const f=u("el-button"),$=u("el-col"),F=u("right-toolbar"),J=u("el-row"),g=u("el-table-column"),K=u("el-table"),M=u("el-input"),T=u("el-form-item"),O=u("el-form"),z=u("el-dialog"),L=q("hasPermi"),H=q("loading");return h(),oe("div",re,[a(J,{gutter:10,class:"mb8"},{default:o(()=>[a($,{span:1.5},{default:o(()=>[y((h(),b(f,{type:"primary",plain:"",icon:"Plus",onClick:R},{default:o(()=>[_("新增")]),_:1})),[[L,["project:coordinate:add"]]])]),_:1}),a(F,{showSearch:l(x),"onUpdate:showSearch":i[0]||(i[0]=s=>G(x)?x.value=s:null),onQueryTable:v},null,8,["showSearch"])]),_:1}),y((h(),b(K,{data:l(w),onSelectionChange:I},{default:o(()=>[a(g,{label:"项目名称",align:"center",prop:"name",width:"200"}),a(g,{label:"经度",align:"center",prop:"x",width:"200"}),a(g,{label:"纬度",align:"center",prop:"y"}),a(g,{label:"范围（米）",align:"center",prop:"range"}),a(g,{label:"操作",width:"400",align:"center","class-name":"small-padding fixed-width",fixed:"right"},{default:o(({row:s})=>[y((h(),b(f,{link:"",type:"primary",onClick:W=>N(s),icon:"EditPen"},{default:o(()=>[_("编辑")]),_:2},1032,["onClick"])),[[L,["project:coordinate:edit"]]]),y((h(),b(f,{link:"",type:"primary",onClick:W=>A(s),icon:"Delete"},{default:o(()=>[_("删除")]),_:2},1032,["onClick"])),[[L,["project:coordinate:delete"]]])]),_:1})]),_:1},8,["data"])),[[H,l(k)]]),a(z,{title:l(C),modelValue:l(d),"onUpdate:modelValue":i[3]||(i[3]=s=>G(d)?d.value=s:null),width:"800px","append-to-body":""},{footer:o(()=>[P("div",se,[a(f,{type:"primary",onClick:Q},{default:o(()=>[_("确 定")]),_:1}),a(f,{onClick:E},{default:o(()=>[_("取 消")]),_:1})])]),default:o(()=>[a(O,{ref:"postRef",model:l(e),rules:l(j),"label-width":"100px"},{default:o(()=>[a(T,{label:"范围（米）",prop:"range"},{default:o(()=>[a($,{span:6},{default:o(()=>[a(M,{modelValue:l(e).range,"onUpdate:modelValue":i[1]||(i[1]=s=>l(e).range=s),type:"number",oninput:"if(value){value=value.replace(/[^\\d]/g,'')} if(value<=0){value='0'} if(value>1000){value=1000}"},null,8,["modelValue"])]),_:1})]),_:1}),a(T,{label:"地点名称",prop:"address"},{default:o(()=>[a($,{span:18,style:{display:"flex","justify-content":"space-between"}},{default:o(()=>[a(M,{modelValue:l(e).address,"onUpdate:modelValue":i[2]||(i[2]=s=>l(e).address=s),placeholder:"",style:{width:"calc(100% - 80px)"}},null,8,["modelValue"]),a(f,{type:"primary",plain:"",onClick:B},{default:o(()=>[_("定位")]),_:1})]),_:1})]),_:1}),ie]),_:1},8,["model","rules"])]),_:1},8,["title","modelValue"])])}}});export{me as default};
