import{B as oe,C as re,G as se,H as ne,c as de,P as ie,D as pe,k as ce}from"./element-plus.ae8e286c.js";import{y as me}from"./@element-plus.d6eabd08.js";import{P as fe}from"./index.a9e38e26.js";import{r as y,a as _e,e as S,d as ge}from"./index.71fc8348.js";import"./lodash.e92d81a1.js";import{a as ve,b as be,c as ye,d as Fe,e as Be,f as Ve}from"./common.e26c7223.js";import{a as Ee}from"./useDictOptions.40b26c73.js";import{g as P}from"./land.24df685b.js";import{d as I,s as j,r as b,b as Ae,_ as A,o as r,c as p,T as t,K as o,u as B,U as _,a6 as g,a as we,J as c}from"./@vue.108c970a.js";function ze(d){return y.get({url:"/farm.farm/lists",params:d})}function De(d){return y.post({url:"/farm.farm/add",params:d})}function Ce(d){return y.post({url:"/farm.farm/edit",params:d})}function Ge(d){return y.post({url:"/farm.farm/delete",params:d})}function Oe(d){return y.get({url:"/farm.farm/detail",params:d})}const ke={class:"edit-popup"},Ue={class:"avatar-uploader-icon"},he=["src"],Le=I({name:"farmEdit"}),xe=I({...Le,props:{dictData:{type:Object,default:()=>({})}},emits:["success","close"],setup(d,{expose:R,emit:w}){const D=j(),V=j(),F=b("add"),T=b(".png, .jpg, .jpeg, image/png, image/jpeg"),q=b(`${S.baseUrl}${S.urlPrefix}/upload/image`),M=_e();b(""),b(!1),b(!1);const N=(u,a)=>{if(u.code==0){ce.error(u.msg);return}l.pic.push(u.data.uri)},$=Ae(()=>(F.value=="edit"&&(k(),U(),h(),L(),x()),F.value=="edit"?"\u7F16\u8F91\u517B\u6B96\u57FA\u5730":"\u65B0\u589E\u517B\u6B96\u57FA\u5730")),l=A({id:"",farm_name:"",user_id:0,farm_type:"",breed_type:"",form_scale:"",master:"",master_contact:"",province:"",city:"",area:"",street:"",village:"",bridge:"",address:"",pic:[],longitude:"",latitude:""}),z=A({}),{optionsData:C}=Ee({user:{api:P}}),E=b(!1),G=async u=>{E.value=!0;const a=await P({keyword:u!=null?u:""});C.user=a,E.value=!1},O=async u=>{for(const a in l)u[a]!=null&&u[a]!=null&&(l[a]=u[a])},H=async u=>{const a=await Oe({id:u.id});O(a)},J=async()=>{var a,v;await((a=D.value)==null?void 0:a.validate());const u={...l};F.value=="edit"?await Ce(u):await De(u),(v=V.value)==null||v.close(),w("success")},K=(u="add")=>{var a;F.value=u,(a=V.value)==null||a.open()},Q=()=>{w("close")},i=A({provinceOptions:[],cityOptions:[],areaOptions:[],streetOptions:[],villageOptions:[],brigadeOptions:[]});function W(u){k()}function X(u){U()}function Y(u){h()}function Z(u){L()}function ee(u){x()}const ae=async()=>{const u=await ve({});i.provinceOptions=u},k=async()=>{const u=await be({city:l.province});i.cityOptions=u},U=async()=>{const u=await ye({area:l.city});i.areaOptions=u},h=async()=>{const u=await Fe({street:l.area});i.streetOptions=u},L=async()=>{const u=await Be({village:l.street});i.villageOptions=u},x=async()=>{const u=await Ve();i.brigadeOptions=u};return ae(),R({open:K,setFormData:O,getDetail:H}),(u,a)=>{const v=oe,n=re,m=se,f=ne,le=de,ue=ie,te=pe;return r(),p("div",ke,[t(fe,{ref_key:"popupRef",ref:V,title:B($),async:!0,width:"550px",onConfirm:J,onClose:Q},{default:o(()=>[t(te,{ref_key:"formRef",ref:D,model:l,"label-width":"90px",rules:z},{default:o(()=>[t(n,{label:"\u540D\u79F0",prop:"farm_name"},{default:o(()=>[t(v,{modelValue:l.farm_name,"onUpdate:modelValue":a[0]||(a[0]=e=>l.farm_name=e),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u540D\u79F0"},null,8,["modelValue"])]),_:1}),t(n,{label:"\u6240\u5C5E\u7528\u6237",prop:"user_id"},{default:o(()=>[t(f,{modelValue:l.user_id,"onUpdate:modelValue":a[1]||(a[1]=e=>l.user_id=e),remote:"",filterable:"",placeholder:"\u8BF7\u8F93\u5165\u7528\u6237\u4FE1\u606F","remote-method":G,loading:E.value},{default:o(()=>[(r(!0),p(_,null,g(B(C).user,(e,s)=>(r(),c(m,{key:s,label:e.userinfo,value:e.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue","loading"])]),_:1}),t(n,{label:"\u517B\u6B96\u57FA\u5730\u7C7B\u578B",prop:"farm_type"},{default:o(()=>[t(f,{class:"flex-1",modelValue:l.farm_type,"onUpdate:modelValue":a[2]||(a[2]=e=>l.farm_type=e),clearable:"",placeholder:"\u8BF7\u9009\u62E9\u517B\u6B96\u57FA\u5730\u7C7B\u578B"},{default:o(()=>[(r(!0),p(_,null,g(d.dictData.farm_type,(e,s)=>(r(),c(m,{key:s,label:e.name,value:parseInt(e.value)},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(n,{label:"\u517B\u6B96\u79CD\u7C7B",prop:"breed_type"},{default:o(()=>[t(f,{class:"flex-1",modelValue:l.breed_type,"onUpdate:modelValue":a[3]||(a[3]=e=>l.breed_type=e),clearable:"",placeholder:"\u8BF7\u9009\u62E9\u517B\u6B96\u79CD\u7C7B"},{default:o(()=>[(r(!0),p(_,null,g(d.dictData.breed_type,(e,s)=>(r(),c(m,{key:s,label:e.name,value:parseInt(e.value)},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(n,{label:"\u517B\u6B96\u573A\u89C4\u6A21",prop:"form_scale"},{default:o(()=>[t(v,{modelValue:l.form_scale,"onUpdate:modelValue":a[4]||(a[4]=e=>l.form_scale=e),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u517B\u6B96\u573A\u89C4\u6A21"},null,8,["modelValue"])]),_:1}),t(n,{label:"\u8D1F\u8D23\u4EBA",prop:"master"},{default:o(()=>[t(v,{modelValue:l.master,"onUpdate:modelValue":a[5]||(a[5]=e=>l.master=e),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u8D1F\u8D23\u4EBA"},null,8,["modelValue"])]),_:1}),t(n,{label:"\u8054\u7CFB\u65B9\u5F0F",prop:"master_contact"},{default:o(()=>[t(v,{modelValue:l.master_contact,"onUpdate:modelValue":a[6]||(a[6]=e=>l.master_contact=e),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u8054\u7CFB\u65B9\u5F0F"},null,8,["modelValue"])]),_:1}),t(n,{label:"\u7701",rules:[{required:!0,message:"\u4E0D\u53EF\u4E3A\u7A7A",trigger:"blur"}],prop:"province"},{default:o(()=>[t(f,{modelValue:l.province,"onUpdate:modelValue":a[7]||(a[7]=e=>l.province=e),placeholder:"\u8BF7\u9009\u62E9\u7701",clearable:"",onChange:W,style:{width:"100%"}},{default:o(()=>[(r(!0),p(_,null,g(i.provinceOptions,(e,s)=>(r(),c(m,{key:s,label:e.province_name,value:e.province_code},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(n,{label:"\u5E02",rules:[{required:!0,message:"\u4E0D\u53EF\u4E3A\u7A7A",trigger:"blur"}],prop:"city"},{default:o(()=>[t(f,{modelValue:l.city,"onUpdate:modelValue":a[8]||(a[8]=e=>l.city=e),placeholder:"\u8BF7\u9009\u62E9\u5E02",clearable:"",onChange:X,style:{width:"100%"}},{default:o(()=>[(r(!0),p(_,null,g(i.cityOptions,(e,s)=>(r(),c(m,{key:s,label:e.city_name,value:e.city_code},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(n,{label:"\u533A",rules:[{required:!0,message:"\u4E0D\u53EF\u4E3A\u7A7A",trigger:"blur"}],prop:"area"},{default:o(()=>[t(f,{modelValue:l.area,"onUpdate:modelValue":a[9]||(a[9]=e=>l.area=e),placeholder:"\u8BF7\u9009\u62E9\u533A",clearable:"",onChange:Y,style:{width:"100%"}},{default:o(()=>[(r(!0),p(_,null,g(i.areaOptions,(e,s)=>(r(),c(m,{key:s,label:e.county_name,value:e.county_code},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(n,{label:"\u9547",rules:[{required:!0,message:"\u4E0D\u53EF\u4E3A\u7A7A",trigger:"blur"}],prop:"street"},{default:o(()=>[t(f,{modelValue:l.street,"onUpdate:modelValue":a[10]||(a[10]=e=>l.street=e),placeholder:"\u8BF7\u9009\u62E9\u9547",clearable:"",onChange:Z,style:{width:"100%"}},{default:o(()=>[(r(!0),p(_,null,g(i.streetOptions,(e,s)=>(r(),c(m,{key:s,label:e.town_name,value:e.town_code},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(n,{label:"\u6751",rules:[{required:!0,message:"\u4E0D\u53EF\u4E3A\u7A7A",trigger:"blur"}],prop:"village"},{default:o(()=>[t(f,{modelValue:l.village,"onUpdate:modelValue":a[11]||(a[11]=e=>l.village=e),placeholder:"\u8BF7\u9009\u62E9\u6751",clearable:"",onChange:ee,style:{width:"100%"}},{default:o(()=>[(r(!0),p(_,null,g(i.villageOptions,(e,s)=>(r(),c(m,{key:s,label:e.village_name,value:e.village_code},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(n,{label:"\u961F",rules:[{required:!0,message:"\u4E0D\u53EF\u4E3A\u7A7A",trigger:"blur"}],prop:"bridge"},{default:o(()=>[t(f,{modelValue:l.bridge,"onUpdate:modelValue":a[12]||(a[12]=e=>l.bridge=e),placeholder:"\u8BF7\u9009\u62E9\u961F",clearable:"",style:{width:"100%"}},{default:o(()=>[(r(!0),p(_,null,g(i.brigadeOptions,(e,s)=>(r(),c(m,{key:s,label:e.group_name,value:e.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),t(n,{label:"\u5730\u5740",prop:"address"},{default:o(()=>[t(v,{modelValue:l.address,"onUpdate:modelValue":a[13]||(a[13]=e=>l.address=e),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u5730\u5740"},null,8,["modelValue"])]),_:1}),t(n,{label:"\u56FE\u7247",prop:"pic",class:"avatar-uploader"},{default:o(()=>[t(ue,{accept:T.value,modelValue:l.pic,"onUpdate:modelValue":a[14]||(a[14]=e=>l.pic=e),data:{cid:0},headers:{Token:B(M).token},action:q.value,"show-file-list":!1,"on-success":N},{default:o(()=>[we("div",Ue,[l.pic?(r(),p("img",{key:0,class:"avatar",style:{width:"200px",height:"130px"},src:l.pic},null,8,he)):(r(),c(le,{key:1},{default:o(()=>[t(B(me))]),_:1}))])]),_:1},8,["accept","modelValue","headers","action"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["title"])])}}});const Se=ge(xe,[["__scopeId","data-v-11648278"]]),He=Object.freeze(Object.defineProperty({__proto__:null,default:Se},Symbol.toStringTag,{value:"Module"}));export{Se as E,ze as a,Ge as b,He as e};