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