1 |
- import{aN as z,aO as le,_ as oe,d as ue,D as te,E as f,a7 as q,ai as ne,aT as se,H as re,x as p,aA as ie,O as de,o as V,N as x,K as s,y as n,b as N,u as ce,a as j,W as D,aS as M,G as me}from"./index.743f0c80.js";import pe from"./company-modal.9e19c0cb.js";import"./index.e2a9809e.js";const{VITE_PROXY_DOMAIN_REAL:ke,VITE_PROXY_USER_REAL:fe}=le(),L=fe+"/admin/",_e=h=>z.request("post",`${L}useradd`,{data:h}),ve=h=>z.request("post",`${L}usersave`,{data:h}),ye={class:"w-full flex justify-center"},Fe={class:"w-full flex justify-between items-center"},Ae=N("div",null,"\u64CD\u4F5C",-1),Ce=D("\u6DFB\u52A0"),be=D("\u5220\u9664"),he=D("\u4FDD\u5B58"),Ee=D("\u5173\u95ED"),ge=ue({__name:"addEdit",props:{itemId:{type:String,default:""},showModel:{type:Boolean,default:!1},isDetails:{type:String,default:"add"},sitem:{type:Object}},emits:["cancel","refresh"],setup(h,{emit:R}){const U=h,{logout:P}=te(),X=f("default"),B=f(),r=f([]);let _="";const y=f(!1),Y=f(""),d=f("add"),I={id:"",nickname:"",mobile:"",companyArr:[]},G=f(null),o=q({...I}),T=f(null),{isSuperUser:H}=ne();let g=[];const K=q({nickname:[{required:!0,message:"\u8BF7\u8F93\u5165\u771F\u5B9E\u59D3\u540D",trigger:"blur"},{min:2,max:12,message:"\u957F\u5EA6\u5728 2 \u5230 12 \u4E2A\u5B57\u7B26",trigger:"blur"}],mobile:[{required:!0,validator:(a,l,u)=>{l===""?u(new Error("\u624B\u673A\u53F7\u4E0D\u80FD\u4E3A\u7A7A\uFF01")):se(l)?u():u(new Error("\u624B\u673A\u53F7\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01"))},trigger:"blur"}],companyArr:[{required:!0,validator:(a,l,u)=>{l.length===0?u(new Error("\u8BF7\u9009\u62E9\u4E1A\u52A1\u516C\u53F8")):u()}}]}),W=async a=>{if(!!a){if(!_){M.warning("\u8BF7\u9009\u62E9\u9ED8\u8BA4\u516C\u53F8");return}await a.validate(async(l,u)=>{if(l){if(F.value===!0)return;const e=Object.assign({},o);d.value==="add"&&delete e.id;const i=e.companyArr.map(({companyCode:t})=>t),v=g.filter(({companyCode:t})=>!i.includes(t)).map(({companyCode:t,companyName:m,id:C})=>({id:C,companyCode:t,companyName:m,is_del:1,is_main:"0"})),A=g.filter(({companyCode:t})=>i.includes(t)).map(({companyCode:t,companyName:m,id:C})=>({id:C,companyCode:t,companyName:m,is_del:0,is_main:"0"})),w=e.companyArr.filter(({companyCode:t})=>!v.find(({companyCode:m})=>m===t)&&!A.find(({companyCode:m})=>m===t)).map(({companyCode:t,companyName:m,id:C})=>({id:C,companyCode:t,companyName:m,is_main:"0",is_del:0}));e.companyArr=[...v,...A,...w],e.companyArr.forEach(t=>{t.companyCode===_&&(t.is_main="1")}),F.value=!0;const{code:E,message:k}=d.value==="add"?await _e(e):await ve(e);F.value=!1,E===0?(M.success(b.value+"\u6210\u529F\uFF01"),y.value=!1,R("refresh")):E>100&&E<140?(y.value=!1,P()):M.error(k)}})}},$=async(a,l)=>{var u;a&&(a.clearValidate(),a.resetFields()),await me(async()=>{for(let e in o)e==="companyArr"&&l.company_relaton?d.value!=="add"?l.company_relaton.forEach(i=>{o.companyArr.push({...i})}):o.companyArr=[]:o[e]=l[e]}),g=((u=l.company_relaton)==null?void 0:u.map(e=>({...e})))||[],d.value==="add"&&(o.companyArr=[],g=[])},O=()=>{y.value=!1,r.value=[],o.companyArr=[],_="",R("cancel")},F=f(!0),b=f("");async function S(a){switch(F.value=!0,d.value){case"add":b.value="\u65B0\u5EFA\u8D26\u53F7";break;case"edit":b.value="\u7F16\u8F91\u8D26\u53F7";break;case"view":b.value="\u8D26\u53F7\u8BE6\u60C5";break;default:b.value="\u65B0\u5EFA\u8D26\u53F7"}$(B.value,a),F.value=!1}function J(a){if(o.companyArr.splice(a,1),r.value[a]&&(_=""),r.value.splice(a,1),o.companyArr.length>=1){if(r.value[a]=!0,o.companyArr[a]){_=o.companyArr[a].companyCode,r.value[a]=!0;return}_=o.companyArr[a-1].companyCode,r.value[a-1]=!0}}function Q(a){const l=o.companyArr.map(({companyCode:e})=>e);a.forEach(e=>{if(!l.includes(e.code)){const{code:i,name:v}=e;o.companyArr.push({companyCode:i,companyName:v})}}),r.value=o.companyArr.map(()=>!1);const u=o.companyArr.findIndex(({companyCode:e})=>e===_);u>=0&&(r.value[u]=!0)}re(()=>U.showModel,()=>{const{showModel:a,itemId:l,isDetails:u,sitem:e}=U;if(y.value=a,y.value&&(Y.value=l,d.value=u,S(u!=="add"?e:I)),d.value==="edit"||d.value==="view"){const i=e.company_relaton.findIndex(({is_main:v})=>String(v)==="1");i>=0&&(r.value=e.company_relaton.map(()=>!1),_=e.company_relaton[i].companyCode,r.value[i]=!0)}});function Z(a){r.value.forEach((l,u)=>{r.value[u]=!1}),_=o.companyArr[a].companyCode,r.value[a]=!0}return(a,l)=>{const u=p("el-input"),e=p("el-form-item"),i=p("el-col"),v=p("el-checkbox"),A=p("el-table-column"),w=p("ElButton"),E=p("el-table"),k=p("el-row"),t=p("el-button"),m=p("el-form"),C=p("el-dialog"),ee=ie("loading");return de((V(),x(C,{"close-on-press-escape":!1,modelValue:y.value,"onUpdate:modelValue":l[4]||(l[4]=c=>y.value=c),"append-to-body":"",width:"900px",center:"",title:b.value,onClose:O},{default:s(()=>[n(m,{class:"demo-ruleForm",ref_key:"ruleFormRef",ref:B,model:o,rules:K,"label-width":"90px",size:X.value,"status-icon":""},{default:s(()=>[n(k,null,{default:s(()=>[n(i,{span:24},{default:s(()=>[n(e,{label:"\u771F\u5B9E\u59D3\u540D",prop:"nickname"},{default:s(()=>[n(u,{modelValue:o.nickname,"onUpdate:modelValue":l[0]||(l[0]=c=>o.nickname=c),disabled:d.value==="view",placeholder:"\u771F\u5B9E\u59D3\u540D"},null,8,["modelValue","disabled"])]),_:1})]),_:1}),n(i,{span:24},{default:s(()=>[n(e,{label:"\u624B\u673A\u53F7",prop:"mobile"},{default:s(()=>[n(u,{modelValue:o.mobile,"onUpdate:modelValue":l[1]||(l[1]=c=>o.mobile=c),disabled:d.value==="view",maxlength:11,placeholder:"\u624B\u673A\u53F7"},null,8,["modelValue","disabled"])]),_:1})]),_:1}),n(i,{span:24},{default:s(()=>[n(e,{label:"\u4E1A\u52A1\u516C\u53F8",prop:"companyArr"},{default:s(()=>[n(E,{data:o.companyArr,border:"",size:"small","row-key":"companyCode","reserve-selection":"",ref_key:"tableRef",ref:G},{default:s(()=>[n(A,{label:"\u9ED8\u8BA4\u516C\u53F8",width:"80px"},{default:s(({$index:c})=>[N("div",ye,[n(v,{disabled:d.value==="view",modelValue:r.value[c],"onUpdate:modelValue":ae=>r.value[c]=ae,onChange:()=>Z(c)},null,8,["disabled","modelValue","onUpdate:modelValue","onChange"])])]),_:1}),n(A,{label:"\u516C\u53F8\u7F16\u53F7",prop:"companyCode"}),n(A,{label:"\u516C\u53F8\u540D\u79F0",prop:"companyName"}),d.value!=="view"&&ce(H)?(V(),x(A,{key:0,width:"100px",label:"\u64CD\u4F5C"},{header:s(()=>[N("div",Fe,[Ae,n(w,{text:"",type:"primary",onClick:l[2]||(l[2]=()=>T.value.onDisplay())},{default:s(()=>[Ce]),_:1})])]),default:s(({$index:c})=>[n(w,{text:"",type:"danger",onClick:()=>J(c)},{default:s(()=>[be]),_:2},1032,["onClick"])]),_:1})):j("v-if",!0)]),_:1},8,["data"])]),_:1})]),_:1})]),_:1}),n(i,{span:24,class:"clear"},{default:s(()=>[d.value==="add"||d.value==="edit"?(V(),x(t,{key:0,type:"primary",class:"fr",style:{margin:"0 0 0 16px"},onClick:l[3]||(l[3]=c=>W(B.value)),loading:F.value},{default:s(()=>[he]),_:1},8,["loading"])):j("v-if",!0),n(t,{class:"fr",style:{margin:"0 0 0 16px"},onClick:O},{default:s(()=>[Ee]),_:1})]),_:1})]),_:1},8,["model","rules","size"]),n(pe,{ref_key:"companyModalRef",ref:T,onChoose:Q},null,512)]),_:1},8,["modelValue","title"])),[[ee,F.value]])}}});var Ve=oe(ge,[["__file","D:/work/accout-vue3-ui/src/views/interest/companyAccount/addEdit.vue"]]);export{Ve as default};
|