1 |
- import{d as N,r as p,o as _,A as E,y as r,h as e,H as x,G as q,a as b,_ as z,Q as O,aa as P,di as S,w as V,aw as Z,B as $,i as k,c as G,e as w,f3 as H,fd as Q}from"./index.js";const U=N({__name:"data-table",props:{data:{type:null,required:!0},isSelection:{type:Boolean,required:!0},colorRow:{type:Boolean,required:!0},cat_code:{type:String,required:!0}},emits:["relation"],setup(D,{emit:g}){const f=D,C=g;function v(d){return d===f.cat_code}function l({row:d}){if(f.colorRow)return"success-row"}return(d,m)=>{const s=p("ElTableColumn"),B=p("ElTag"),F=p("ElButton"),A=p("ElPopconfirm"),R=p("ElTable");return _(),E(R,{size:"small",border:"",data:d.data,style:{width:"100%"},"row-class-name":l,"row-key":"id","default-expand-all":""},{default:r(()=>[e(s,{label:"\u660E\u7EC6ID",prop:"id","min-width":"60px","show-overflow-tooltip":""}),e(s,{label:"\u53D1\u7968\u660E\u7EC6\u7C7B\u76EE\u7F16\u53F7",prop:"cat_code","min-width":"140px","show-overflow-tooltip":""}),e(s,{label:"\u8D27\u7269\u6216\u5E94\u7A0E\u52B3\u52A1\u3001\u670D\u52A1\u540D\u79F0",prop:"good_name","min-width":"180px","show-overflow-tooltip":""}),d.isSelection?(_(),E(s,{key:0,label:"\u662F\u5426\u53EF\u5173\u8054"},{default:r(({row:n})=>[e(B,{size:"small",type:v(n.cat_code)?"success":"warning"},{default:r(()=>[x(q(v(n.cat_code)?"\u53EF\u5173\u8054":"\u4E0D\u53EF\u5173\u8054"),1)]),_:2},1032,["type"])]),_:1})):b("v-if",!0),e(s,{label:"\u6570\u91CF",prop:"num",width:"80px","show-overflow-tooltip":""}),e(s,{label:"\u5355\u4EF7",prop:"unit_price",width:"120px","show-overflow-tooltip":""}),e(s,{label:"\u91D1\u989D",prop:"amount",width:"80px","show-overflow-tooltip":""}),e(s,{label:"\u7A0E\u7387",prop:"tax",width:"80px","show-overflow-tooltip":""}),e(s,{label:"\u7A0E\u989D",prop:"tax_amount",width:"80px","show-overflow-tooltip":""}),e(s,{label:"\u7A0E\u540E\u603B\u989D",prop:"total_amount",width:"120px","show-overflow-tooltip":""}),d.isSelection?(_(),E(s,{key:1,fixed:"right",label:"\u64CD\u4F5C",width:"48px"},{default:r(({row:n,$index:a})=>[v(n.cat_code)?(_(),E(A,{key:0,title:"\u662F\u5426\u786E\u8BA4\u5173\u8054",onConfirm:o=>C("relation",n,a)},{reference:r(()=>[e(F,{link:"",size:"small",type:"primary"},{default:r(()=>m[0]||(m[0]=[x("\u5173\u8054")])),_:1})]),_:2},1032,["onConfirm"])):b("v-if",!0)]),_:1})):b("v-if",!0)]),_:1},8,["data"])}}});var I=z(U,[["__file","D:/work/jiesuan/settle-vue3/src/components/ZeroRelation/src/data-table.vue"]]);const J={class:"flex flex-col border border-[#ebeef5]"},K={class:"flex border-b-1 border-[#ebeef5]"},L={class:"flex-1 border-r-1 border-[#ebeef5] p-[5px] overflow-hidden"},M={class:"flex-1 p-[5px] overflow-hidden"},W={class:"flex"},X=N({__name:"index",props:{code:{type:String,required:!0}},emits:["refresh"],setup(D,{emit:g}){const f=D,C=g,v=[{value:"0",label:"\u5F85\u5173\u8054"},{value:"1",label:"\u6B63\u5728\u5173\u8054"},{value:"2",label:"\u5DF2\u5173\u8054"}],l=O({positive:{ok:[],no:[]},negative:{no:[]},result:[],notRelation:[],selection:[]}),d=P(()=>l.negative.no.find(({relationStatus:n})=>n=="1")||{}),m=S({success(){C("refresh")}}),s=S({initialData:[],success(n=[]){let a=[];const o=[];n=n.map(u=>({...u,relationStatus:"0"})),n.forEach(u=>{Number(u.total_amount)<0?o.push(u):a.push(u)});const c=o.map(({cat_code:u})=>u);let t=[],i=[];a.forEach(u=>{c.includes(u.cat_code)?t.push(u):i.push(u)}),o[0].relationStatus="1",l.positive.no=t,l.negative.no=o,l.notRelation=i}}),B=()=>s.run(H({code:f.code}));function F(n){const a=l.negative.no.findIndex(({relationStatus:t})=>t==="1");l.negative.no[a]={...l.negative.no[a],...Object.keys(n).reduce((t,i)=>({...t,["n_"+i]:n[i]}),{}),relationStatus:"2"};const o=l.positive.no.findIndex(t=>t.id===n.id);if(l.positive.no.splice(o,1),l.negative.no.filter(({relationStatus:t})=>t=="0"||t=="1").map((t,i)=>i).length===0){const t=l.negative.no.map(({id:i,n_id:u})=>({main_id:u,voice_id:i}));m.run(Q({data:t}))}else{const t=l.negative.no.findIndex(i=>i.relationStatus=="0");l.negative.no[t].relationStatus="1"}}function A(n){const a=l.negative.no.findIndex(({relationStatus:t})=>t==="1");l.negative.no[a].relationStatus="0";const o={},c={};Object.keys(l.negative.no[n]).forEach(t=>{if(t.indexOf("n_")!==-1){const[i,u]=t.split("n_");c[u]=l.negative.no[n][t]}else o[t]=l.negative.no[n][t]}),l.negative.no[n]={...o,relationStatus:"1"},l.positive.no.push({...c}),l.positive.no.sort((t,i)=>t.id-i.id)}V(()=>f.code,()=>{!f.code||B()},{immediate:!0});function R({row:n}){if(n.relationStatus=="1")return"success-row"}return(n,a)=>{const o=p("ElTableColumn"),c=p("ElTag"),t=p("ElButton"),i=p("ElPopconfirm"),u=p("ElTable"),j=Z("loading");return $((_(),G("div",J,[w("div",K,[w("div",L,[a[0]||(a[0]=w("h3",{class:"font-bold"},"\u65E0\u9700\u5173\u8054",-1)),e(I,{data:l.notRelation},null,8,["data"])]),w("div",M,[a[1]||(a[1]=w("h3",{class:"font-bold"},"\u53EF\u5173\u8054\u660E\u7EC6",-1)),e(I,{cat_code:d.value.cat_code,data:l.positive.no,onRelation:F,isSelection:"",colorRow:""},null,8,["cat_code","data"])])]),w("div",W,[e(u,{class:"mt-[10px] custom-detail-table",border:"",size:"small",data:l.negative.no,"row-class-name":R},{default:r(()=>[e(o,{label:"\u8D1F\u6570\u660E\u7EC6"},{default:r(()=>[e(o,{label:"\u660E\u7EC6ID",prop:"id","min-width":"60px","show-overflow-tooltip":""}),e(o,{label:"\u53D1\u7968\u660E\u7EC6\u7C7B\u76EE\u7F16\u53F7",prop:"cat_code","min-width":"140px","show-overflow-tooltip":""}),e(o,{label:"\u8D27\u7269\u6216\u5E94\u7A0E\u52B3\u52A1\u3001\u670D\u52A1\u540D\u79F0",prop:"good_name","min-width":"180px","show-overflow-tooltip":""}),e(o,{label:"\u91D1\u989D",prop:"amount",width:"80px","show-overflow-tooltip":""}),e(o,{label:"\u7A0E\u7387",prop:"tax",width:"80px","show-overflow-tooltip":""}),e(o,{label:"\u7A0E\u989D",prop:"tax_amount",width:"80px","show-overflow-tooltip":""}),e(o,{label:"\u7A0E\u540E\u603B\u989D",prop:"total_amount",width:"120px","show-overflow-tooltip":""})]),_:1}),e(o,{label:"\u72B6\u6001",width:"90px"},{default:r(({row:y})=>[e(c,null,{default:r(()=>{var h;return[x(q(((h=v.find(T=>T.value===y.relationStatus))==null?void 0:h.label)||"--"),1)]}),_:2},1024)]),_:1}),e(o,{label:"\u6B63\u6570\u660E\u7EC6"},{default:r(()=>[e(o,{label:"\u660E\u7EC6ID",prop:"n_id","min-width":"60px","show-overflow-tooltip":""}),e(o,{label:"\u53D1\u7968\u660E\u7EC6\u7C7B\u76EE\u7F16\u53F7",prop:"n_cat_code","min-width":"140px","show-overflow-tooltip":""}),e(o,{label:"\u8D27\u7269\u6216\u5E94\u7A0E\u52B3\u52A1\u3001\u670D\u52A1\u540D\u79F0",prop:"n_good_name","min-width":"180px","show-overflow-tooltip":""}),e(o,{label:"\u6570\u91CF",prop:"n_num",width:"80px","show-overflow-tooltip":""}),e(o,{label:"\u5355\u4EF7",prop:"n_unit_price",width:"120px","show-overflow-tooltip":""}),e(o,{label:"\u91D1\u989D",prop:"n_amount",width:"80px","show-overflow-tooltip":""}),e(o,{label:"\u7A0E\u7387",prop:"n_tax",width:"80px","show-overflow-tooltip":""}),e(o,{label:"\u7A0E\u989D",prop:"n_tax_amount",width:"80px","show-overflow-tooltip":""}),e(o,{label:"\u7A0E\u540E\u603B\u989D",prop:"n_total_amount",width:"120px","show-overflow-tooltip":""})]),_:1}),e(o,{fixed:"right",label:"\u64CD\u4F5C",width:"75px"},{default:r(({row:y,$index:h})=>[y.relationStatus==="2"?(_(),E(i,{key:0,title:"\u662F\u5426\u786E\u8BA4\u89E3\u9664\u5173\u8054",onConfirm:T=>A(h)},{reference:r(()=>[e(t,{link:"",size:"small",type:"primary"},{default:r(()=>a[2]||(a[2]=[x("\u89E3\u9664\u5173\u8054")])),_:1})]),_:2},1032,["onConfirm"])):b("v-if",!0)]),_:1})]),_:1},8,["data"])])])),[[j,k(s).loading||k(m).loading]])}}});var ee=z(X,[["__file","D:/work/jiesuan/settle-vue3/src/components/ZeroRelation/src/index.vue"]]);export{ee as Z};
|