1 |
- import{_ as ee,d as ae,w as le,x as f,Z as S,ai as oe,aX as ue,A as te,r as p,aD as ne,H as re,o as k,G as V,D as r,l as n,h as M,m as se,M as D,a as T,aZ as x,z as ie}from"./index.js";import{h as de,a as ce}from"./index.95768c8f.js";import me from"./company-modal.30c47e.js";import"./index.f604950f.js";const pe={class:"w-full flex justify-center"},fe={class:"w-full flex justify-between items-center"},ve=M("div",null,"\u64CD\u4F5C",-1),ye=ae({__name:"addEdit",props:{itemId:{type:String,default:""},showModel:{type:Boolean,default:!1},isDetails:{type:String,default:"add"},sitem:{type:Object}},emits:["cancel","refresh"],setup(q,{emit:U}){const N=q,{logout:O}=le(),Z=f("default"),E=f(),s=f([]);let v="";const _=f(!1),G=f(""),d=f("add"),R={id:"",nickname:"",mobile:"",companyArr:[]},H=f(null),o=S({...R}),j=f(null),{isSuperUser:X}=oe();let h=[];const J=S({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")):ue(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()}}]}),K=async a=>{if(!!a){if(!v){x.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),y=h.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=h.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})=>!y.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=[...y,...A,...w],e.companyArr.forEach(t=>{t.companyCode===v&&(t.is_main="1")}),F.value=!0;const{code:g,message:B}=d.value==="add"?await de(e):await ce(e);F.value=!1,g===0?(x.success(b.value+"\u6210\u529F\uFF01"),_.value=!1,U("refresh")):g>100&&g<140?(_.value=!1,O()):x.error(B)}})}},L=async(a,l)=>{var u;a&&(a.clearValidate(),a.resetFields()),await ie(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]}),h=((u=l.company_relaton)==null?void 0:u.map(e=>({...e})))||[],d.value==="add"&&(o.companyArr=[],h=[])},z=()=>{_.value=!1,s.value=[],o.companyArr=[],v="",U("cancel")},F=f(!0),b=f("");async function I(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"}L(E.value,a),F.value=!1}function P(a){if(o.companyArr.splice(a,1),s.value[a]&&(v=""),s.value.splice(a,1),o.companyArr.length>=1){if(s.value[a]=!0,o.companyArr[a]){v=o.companyArr[a].companyCode,s.value[a]=!0;return}v=o.companyArr[a-1].companyCode,s.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:y}=e;o.companyArr.push({companyCode:i,companyName:y})}}),s.value=o.companyArr.map(()=>!1);const u=o.companyArr.findIndex(({companyCode:e})=>e===v);u>=0&&(s.value[u]=!0)}te(()=>N.showModel,()=>{const{showModel:a,itemId:l,isDetails:u,sitem:e}=N;if(_.value=a,_.value&&(G.value=l,d.value=u,I(u!=="add"?e:R)),d.value==="edit"||d.value==="view"){const i=e.company_relaton.findIndex(({is_main:y})=>String(y)==="1");i>=0&&(s.value=e.company_relaton.map(()=>!1),v=e.company_relaton[i].companyCode,s.value[i]=!0)}});function W(a){s.value.forEach((l,u)=>{s.value[u]=!1}),v=o.companyArr[a].companyCode,s.value[a]=!0}return(a,l)=>{const u=p("el-input"),e=p("el-form-item"),i=p("el-col"),y=p("el-checkbox"),A=p("el-table-column"),w=p("ElButton"),g=p("el-table"),B=p("el-row"),t=p("el-button"),m=p("el-form"),C=p("el-dialog"),Y=ne("loading");return re((k(),V(C,{"close-on-press-escape":!1,"close-on-click-modal":!1,modelValue:_.value,"onUpdate:modelValue":l[4]||(l[4]=c=>_.value=c),"append-to-body":"",width:"900px",center:"",title:b.value,onClose:z},{default:r(()=>[n(m,{class:"demo-ruleForm",ref_key:"ruleFormRef",ref:E,model:o,rules:J,"label-width":"90px",size:Z.value,"status-icon":""},{default:r(()=>[n(B,null,{default:r(()=>[n(i,{span:24},{default:r(()=>[n(e,{label:"\u771F\u5B9E\u59D3\u540D",prop:"nickname"},{default:r(()=>[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:r(()=>[n(e,{label:"\u624B\u673A\u53F7",prop:"mobile"},{default:r(()=>[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:r(()=>[n(e,{label:"\u4E1A\u52A1\u516C\u53F8",prop:"companyArr"},{default:r(()=>[n(g,{data:o.companyArr,border:"",size:"small","row-key":"companyCode","reserve-selection":"",ref_key:"tableRef",ref:H},{default:r(()=>[n(A,{label:"\u9ED8\u8BA4\u516C\u53F8",width:"80px"},{default:r(({$index:c})=>[M("div",pe,[n(y,{disabled:d.value==="view",modelValue:s.value[c],"onUpdate:modelValue":$=>s.value[c]=$,onChange:()=>W(c)},null,8,["disabled","modelValue","onUpdate:modelValue","onChange"])])]),_:1}),n(A,{label:"\u516C\u53F8\u7F16\u7801",prop:"companyCode"}),n(A,{label:"\u516C\u53F8\u540D\u79F0",prop:"companyName"}),d.value!=="view"&&se(X)?(k(),V(A,{key:0,width:"100px",label:"\u64CD\u4F5C"},{header:r(()=>[M("div",fe,[ve,n(w,{text:"",type:"primary",onClick:l[2]||(l[2]=()=>j.value.onDisplay())},{default:r(()=>[D("\u6DFB\u52A0")]),_:1})])]),default:r(({$index:c})=>[n(w,{text:"",type:"danger",onClick:()=>P(c)},{default:r(()=>[D("\u5220\u9664")]),_:2},1032,["onClick"])]),_:1})):T("v-if",!0)]),_:1},8,["data"])]),_:1})]),_:1})]),_:1}),n(i,{span:24,class:"clear"},{default:r(()=>[d.value==="add"||d.value==="edit"?(k(),V(t,{key:0,type:"primary",class:"fr",style:{margin:"0 0 0 16px"},onClick:l[3]||(l[3]=c=>K(E.value)),loading:F.value},{default:r(()=>[D("\u4FDD\u5B58")]),_:1},8,["loading"])):T("v-if",!0),n(t,{class:"fr",style:{margin:"0 0 0 16px"},onClick:z},{default:r(()=>[D("\u5173\u95ED")]),_:1})]),_:1})]),_:1},8,["model","rules","size"]),n(me,{ref_key:"companyModalRef",ref:j,onChoose:Q},null,512)]),_:1},8,["modelValue","title"])),[[Y,F.value]])}}});var be=ee(ye,[["__file","C:/Users/89793/Desktop/projects/settle-vue3/src/views/interest/companyAccount-origin/addEdit.vue"]]);export{be as default};
|