suyuan-breed/public/admin/assets/edit.8d4a1af2.js

2 lines
8.2 KiB
JavaScript

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