import{u as e,a,r as l,b as r,d as o,e as t,f as d,h as s,w as i,g as m,j as p,k as u,i as n,n as c,E as f,q as b}from"./index.286e9b79.js";import{v as j}from"./loading.c49775a6.js";import{E as g,a as v}from"./form.ad10dcd5.js";import{E as h,a as _}from"./tab-pane.1cc0f769.js";import{E as x}from"./input.31de1b37.js";import"./form-item.9355e6dc.js";import{E as V}from"./cascader-panel.10f8222e.js";/* empty css            */import"./checkbox.f06171a4.js";/* empty css              */import{_ as y}from"./page-header.29890ed0.js";import{g as k,p as q}from"./http.f588794f.js";import"./_initCloneObject.fb8fbaea.js";import"./strings.8c60bfae.js";import"./event.776e7e11.js";import"./index.ed3ed02e.js";import"./index.569c0449.js";import"./isEqual.57d72c4a.js";import"./arrays.6dddb988.js";import"./scroll.a50153b5.js";import"./cloneDeep.15b627aa.js";import"./index.27150c7e.js";import"./debounce.caafe00b.js";import"./divider.948c4b18.js";const w={class:"card"},E={class:"editor-card"},U={class:"editor-card-box"},C={class:"tool"},z={class:"tool-box"},F={__name:"editor",setup(F){const D=e(),L=a().query.id;let M=l(!1),O=l(!1),R=l("0"),S=l(),A=r({data:{name:"",sort:"0",pid:"",id:0}});null!=L&&L>0&&(M.value=!0,k("shop.region/editor",{id:L}).then((e=>{M.value=!1,e.code&&(A.data=e.data)})));const B=r({title:[{required:!0,message:"请输入名称",trigger:"blur"},{min:3,max:30,message:"名称长度请控制在3-30个字符内",trigger:"blur"}],sort:[{required:!0,message:"请输入排序",trigger:"blur"}]}),G={lazy:!0,checkStrictly:!0,lazyLoad(e,a){var l;const{level:r}=e;k("common/get_area",{pid:null!=(l=e.value)?l:0}).then((e=>{const l=e.data.map((e=>{let a=e.has?2:r;return{value:e.id,label:e.name,leaf:r>=a}}));a(l)})).catch((e=>{f.error(e)}))}},H=async()=>{S.value&&await S.value.validate(((e,a)=>{O.value=!1,e?(O.value=!0,q("shop.region/editor",A.data).then((e=>{O.value=!1,e.code?(S.value.resetFields(),D.replace("/shop/region/index"),f.success("编辑成功")):f.error(e.msg)})).catch((e=>{f.error(e)}))):f.error("请完善内容")}))},I=()=>{D.go(-1)};return(e,a)=>{const l=y,r=V,f=g,k=x,q=h,F=_,D=v,L=b,J=j;return o(),t("div",w,[d(l,{title:"编辑地区"}),s("div",E,[i((o(),p(D,{model:m(A).data,rules:m(B),ref_key:"ruleFormRef",ref:S},{default:u((()=>[s("div",U,[d(F,{modelValue:m(R),"onUpdate:modelValue":a[3]||(a[3]=e=>n(R)?R.value=e:R=e)},{default:u((()=>[d(q,{label:"基本信息",name:"0"},{default:u((()=>[d(f,{label:"所属地区",prop:"pid","label-width":"100px"},{default:u((()=>[d(r,{modelValue:m(A).data.pid,"onUpdate:modelValue":a[0]||(a[0]=e=>m(A).data.pid=e),props:G,style:{width:"100%"},placeholder:"选填,不选择则作分顶级地区",clearable:""},null,8,["modelValue"])])),_:1}),d(f,{label:"名称",prop:"name","label-width":"100px"},{default:u((()=>[d(k,{modelValue:m(A).data.name,"onUpdate:modelValue":a[1]||(a[1]=e=>m(A).data.name=e)},null,8,["modelValue"])])),_:1}),d(f,{label:"排序",required:!0,"label-width":"100px"},{default:u((()=>[d(k,{modelValue:m(A).data.sort,"onUpdate:modelValue":a[2]||(a[2]=e=>m(A).data.sort=e),modelModifiers:{number:!0},type:"number"},null,8,["modelValue"])])),_:1})])),_:1})])),_:1},8,["modelValue"])])])),_:1},8,["model","rules"])),[[J,m(M)]])]),s("div",C,[s("div",z,[d(L,{onClick:I},{default:u((()=>[c("取消")])),_:1}),d(L,{type:"primary",loading:m(O),onClick:H},{default:u((()=>[c("保存")])),_:1},8,["loading"])])])])}}};export{F as default};
