import{K as p,r as f,A as K,B as T,c as s,C as U,d as v,e as Z,f as t,h as l,D as h,G as k,m as b,i as a,E as J,k as M,H as Q,I as X,v as Y}from"./index-CeQafXht.js";function ee(o){return p({url:"/djl-role/manufacturer/query/list",method:"get",params:o})}function te(o){return p({url:"/djl-role/manufacturer/check/name",method:"get",params:o})}function D(o){return p({url:"/djl-role/manufacturer/check/occupied",method:"get",params:o})}function ae(o){return p({url:"/djl-role/manufacturer/insert",method:"post",data:o})}function le(o){return p({url:"/djl-role/manufacturer/update",method:"post",data:o})}function ne(o){return p({url:"/djl-role/manufacturer/delete",method:"post",data:o})}const oe={class:"app-container"},re={class:"dialog-footer"},ue=X({name:"Post"}),se=Object.assign(ue,{setup(o){const{proxy:u}=Y(),R=f([]),m=f(!1),C=f(!0);f(!0);const y=f(0),$=f(""),E=K({form:{},queryParams:{page:1,limit:10,name:"",phoneNumber:"",openId:""},rules:{name:[{required:!0,message:"请输入厂商名称",trigger:"blur"},{validator:N,trigger:"blur"}]}});function N(n,e,d){if(e!=""){var V=/^[\u0391-\uFFE5A-Za-z0-9-\s]+$/;V.test(e)||d(new Error("名称中不能含有特殊字符"))}te({name:e,id:i.value.id}).then(x=>{x.data?d():d(new Error("名称重复"))})}const{queryParams:_,form:i,rules:B}=T(E);function g(){C.value=!0,ee(_.value).then(n=>{R.value=n.data,y.value=n.count,C.value=!1})}function F(){i.value={},m.value=!0,$.value="新增",u.$refs.postRef!==void 0&&u.$refs.postRef.resetFields()}function q(){m.value=!1}function S(n){D({id:n.id}).then(e=>{e.data?u.$modal.msgWarning("厂商被引用，无法编辑名称"):(i.value={...n},m.value=!0,$.value="编辑",u.$refs.postRef!==void 0&&u.$refs.postRef.resetFields())})}function A(){u.$refs.postRef.validate(n=>{n&&(i.value.id?le(i.value).then(e=>{u.$modal.msgSuccess(e.code),m.value=!1,g()}):ae(i.value).then(e=>{u.$modal.msgSuccess(e.code),m.value=!1,g()}))})}function I(n){D({id:n.id}).then(e=>{e.data?u.$modal.msgWarning("厂商被引用，无法删除"):u.$modal.confirm('是否确认删除厂商为"'+n.name+'"的数据项？').then(function(){return ne({id:n.id})}).then(()=>{g(),u.$modal.msgSuccess("删除成功")}).catch(()=>{})})}return g(),(n,e)=>{const d=s("el-button"),V=s("el-col"),x=s("el-row"),c=s("el-table-column"),z=s("el-table"),L=s("pagination"),P=s("el-input"),j=s("el-form-item"),O=s("el-form"),W=s("el-dialog"),w=U("hasPermi"),G=U("loading");return v(),Z("div",oe,[t(x,{gutter:10,class:"mb8"},{default:l(()=>[t(V,{span:1.5},{default:l(()=>[h((v(),k(d,{type:"primary",plain:"",icon:"Plus",onClick:F},{default:l(()=>[b("新增")]),_:1})),[[w,["manufacturer:add"]]])]),_:1})]),_:1}),h((v(),k(z,{data:a(R)},{default:l(()=>[t(c,{label:"名称",align:"center",prop:"name"}),t(c,{label:"备注",align:"center",prop:"remark"}),t(c,{label:"创建时间",align:"center",prop:"create_time"}),t(c,{label:"更新时间",align:"center",prop:"update_time"}),t(c,{label:"操作",width:"180",align:"center","class-name":"small-padding fixed-width"},{default:l(({row:r})=>[h((v(),k(d,{link:"",type:"primary",onClick:H=>S(r),icon:"EditPen"},{default:l(()=>[b("编辑")]),_:2},1032,["onClick"])),[[w,["manufacturer:edit"]]]),h((v(),k(d,{link:"",type:"primary",onClick:H=>I(r),icon:"Delete"},{default:l(()=>[b("删除")]),_:2},1032,["onClick"])),[[w,["manufacturer:del"]]])]),_:1})]),_:1},8,["data"])),[[G,a(C)]]),h(t(L,{total:a(y),page:a(_).page,"onUpdate:page":e[0]||(e[0]=r=>a(_).page=r),limit:a(_).limit,"onUpdate:limit":e[1]||(e[1]=r=>a(_).limit=r),onPagination:g},null,8,["total","page","limit"]),[[J,a(y)>0]]),t(W,{title:a($),modelValue:a(m),"onUpdate:modelValue":e[4]||(e[4]=r=>Q(m)?m.value=r:null),width:"500px","append-to-body":""},{footer:l(()=>[M("div",re,[t(d,{type:"primary",onClick:A},{default:l(()=>[b("确 定")]),_:1}),t(d,{onClick:q},{default:l(()=>[b("取 消")]),_:1})])]),default:l(()=>[t(O,{ref:"postRef",model:a(i),rules:a(B),"label-width":"80px"},{default:l(()=>[t(j,{label:"厂商名称",prop:"name"},{default:l(()=>[t(P,{modelValue:a(i).name,"onUpdate:modelValue":e[2]||(e[2]=r=>a(i).name=r),maxlength:"25",placeholder:"请输入厂商名称"},null,8,["modelValue"])]),_:1}),t(j,{label:"备注",prop:"remark"},{default:l(()=>[t(P,{autosize:{minRows:4},modelValue:a(i).remark,"onUpdate:modelValue":e[3]||(e[3]=r=>a(i).remark=r),type:"textarea",autocomplete:"off",maxlength:"200","show-word-limit":""},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["title","modelValue"])])}}});export{se as default};
