finance-setting.de74945a.js 5.9 KB

1
  1. import{_ as K,d as W,w as R,m as X,aO as Y,ag as g,Z as $,aP as ee,z as Z,y as ae,r as x,o as p,c as C,l as u,C as s,b as F,u as _,aQ as te,F as B,D as S,G as w,aR as le,M as ne}from"./index.fd765376.js";import{c as A,i as k}from"./configs.b3471459.js";import{h as ue,a as oe}from"./index.a71cd8eb.js";import"./tootip.99c35844.js";import"./verification.611d3025.js";const se={flex:"",gap:"1"},de={flex:"","gap-3":""},ie={flex:"","justify-end":""},re=W({__name:"finance-setting",props:{columns:{type:Array,required:!0},backRoute:{type:String,required:!0},name:{type:String,required:!1},detail:{type:null,required:!0}},emits:["refresh"],setup(I,{emit:N}){const y=I,c=R(null),L={cat_code:"",cat_name:"",inv_good_name:"",tax:"",inv_tag:"",is_discount:"",addTax:""},v=R([]),{query:j}=X(),H=Y(),q=R(null),O=g(()=>j.id),e=$({...L}),U=ee(!1),b=g(()=>({isDiscount:e.is_discount==="1",isZeroTaxRate:e.tax==="0%"})),T=g(()=>{const l=!e.cat_code,{isDiscount:a,isZeroTaxRate:n}=b.value;return{tax:l,is_discount:l,addTax:l||!n||!a,inv_tag:l||!n||a&&n}}),z=g(()=>{const{isDiscount:l,isZeroTaxRate:a}=b.value;return{...A,inv_tag:[{...A.inv_tag,required:a}],addTax:[{...A.addTax,required:l&&a}]}}),E=g(()=>{const{isDiscount:l,isZeroTaxRate:a}=b.value;let n=[],o=[];return l&&a&&(o=n=[k[0],k[1]]),a&&!l&&(o=[k[2]]),{addTax:n,invTag:o}});function G(){q.value.validate(async l=>{if(!l)return;const{addTax:a,is_discount:n,inv_tag:o,cat_code:d,inv_good_name:i,tax:f}=e,t=[{addTax:a,is_discount:n,inv_tag:o||"0",cat_code:d,inv_good_name:i,tax:f,spuCode:O.value}];U.value=!0;const{code:r,message:V}=await oe({list:t,status:"2"});U.value=!1,H({code:r,message:V,handler:()=>N("refresh")})})}function M(l){if(!l)return e.tax="",e.cat_name="",v.value=[];const{tax:a,cat_name:n}=l;e.cat_name=n,v.value=[...a,"0%"],e.tax="",e.addTax="",e.inv_tag="",e.is_discount=""}const P=()=>{e.addTax="",e.inv_tag=""},Q=()=>{e.is_discount="",e.addTax="",e.inv_tag=""};function J(l){return l.merge_code+" / "+l.cat_name+"-"+l.short_name}return Z(()=>e.addTax,l=>{if(!l)return;const{isZeroTaxRate:a,isDiscount:n}=b.value;if(a&&n){const o=E.value.addTax;let d=o.findIndex(i=>i.label===e.addTax);e.inv_tag=o[d].value}},{immediate:!0}),Z(()=>[y.detail,c.value],async()=>{if(!y.detail||!c.value)return;const{cgd_inv_good_name:l,cgd_inv_cat_code:a,inv_cat_code:n,is_discount:o,good_name:d,cgd_inv_tax:i,inv_tax:f,inv_tag:t,addTax:r,status:V}=y.detail;if(e.inv_good_name=l||d,e.tax=i||"",e.is_discount=String(o),e.inv_good_name.length>70&&(e.inv_good_name=e.inv_good_name.slice(0,70)),ae(()=>{e.inv_tag=String(t)!=="0"?String(t):"",e.addTax=r}),a&&c.value){const h={cat_code:a},m=await c.value.initalData(h);if(!m||!Array.isArray(m))return;const{tax:D}=m[0];v.value=D}if(Number(V)===2&&c.value){const h={cat_code:n},m=await c.value.initalData(h);if(!m||!Array.isArray(m))return;const{tax:D}=m[0];v.value=D,e.tax=f,e.is_discount=String(o),e.inv_tag=String(t)!=="0"?String(t):"",e.addTax=r}},{immediate:!0}),(l,a)=>{const n=x("el-form-item"),o=x("el-input"),d=x("el-option"),i=x("el-select"),f=x("el-button");return p(),C(B,null,[u(_(le),{"label-position":"left",ref_key:"formRef",ref:q,rules:_(z),model:e},{default:s(()=>[F("div",se,[u(n,{label:"\u5546\u54C1\u7C7B\u76EE\u8BBE\u7F6E",prop:"cat_code","flex-1":""},{default:s(()=>[u(_(te),{ref_key:"remoteSelectRef",ref:c,"w-full":"","is-root":"",api:_(ue),modelValue:e.cat_code,"onUpdate:modelValue":a[0]||(a[0]=t=>e.cat_code=t),getLabel:J,placeholder:"\u8BF7\u9009\u62E9\u5546\u54C1\u7C7B\u76EE","response-label-prop":"cat_name","response-val-prop":"merge_code","request-prop":"cat_name","sub-label-prop":"short_name",onItemChange:M,onInital:a[1]||(a[1]=t=>e.cat_code=t)},null,8,["api","modelValue"])]),_:1})]),F("div",null,[u(n,{label:"\u5F00\u7968\u5546\u54C1\u540D\u79F0",prop:"inv_good_name","flex-1":""},{default:s(()=>[u(o,{"w-full":"",modelValue:e.inv_good_name,"onUpdate:modelValue":a[2]||(a[2]=t=>e.inv_good_name=t),placeholder:"\u8BF7\u8F93\u5165\u5546\u54C1\u540D\u79F0",maxlength:"70"},null,8,["modelValue"])]),_:1})]),F("div",de,[u(n,{label:"\u7A0E\u7387",prop:"tax"},{default:s(()=>[u(i,{"w-180px":"",modelValue:e.tax,"onUpdate:modelValue":a[3]||(a[3]=t=>e.tax=t),disabled:_(T).tax,placeholder:"\u8BF7\u8F93\u5165\u7A0E\u7387",onChange:Q},{default:s(()=>[(p(!0),C(B,null,S(v.value,(t,r)=>(p(),w(d,{key:r,label:t,value:t},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1}),u(n,{label:"\u662F\u5426\u6709\u4F18\u60E0\u653F\u7B56",prop:"is_discount"},{default:s(()=>[u(i,{disabled:_(T).is_discount,"w-150px":"",modelValue:e.is_discount,"onUpdate:modelValue":a[4]||(a[4]=t=>e.is_discount=t),placeholder:"\u8BF7\u9009\u62E9\u662F\u5426\u5305\u542B\u4F18\u60E0\u653F\u7B56",onChange:P},{default:s(()=>[u(d,{label:"\u5426",value:"0"}),u(d,{label:"\u662F",value:"1"})]),_:1},8,["disabled","modelValue"])]),_:1}),u(n,{label:"\u589E\u503C\u7A0E\u7BA1\u7406\u5185\u5BB9",prop:"addTax"},{default:s(()=>[u(i,{disabled:_(T).addTax,"w-230px":"",modelValue:e.addTax,"onUpdate:modelValue":a[5]||(a[5]=t=>e.addTax=t),placeholder:"\u8BF7\u9009\u62E9\u589E\u503C\u7A0E\u7BA1\u7406\u7A0E\u5185\u5BB9"},{default:s(()=>[(p(!0),C(B,null,S(_(E).addTax,(t,r)=>(p(),w(d,{key:r,label:t.label,value:t.label},null,8,["label","value"]))),128))]),_:1},8,["disabled","modelValue"])]),_:1}),u(n,{label:"\u6C47\u7387\u6807\u8BC6",prop:"inv_tag"},{default:s(()=>[u(i,{"w-180px":"",disabled:_(T).inv_tag,modelValue:e.inv_tag,"onUpdate:modelValue":a[6]||(a[6]=t=>e.inv_tag=t),placeholder:"\u8BF7\u9009\u62E9\u6C47\u7387\u6807\u8BC6"},{default:s(()=>[(p(!0),C(B,null,S(_(E).invTag,(t,r)=>(p(),w(d,{key:r,label:t.label,value:t.value},null,8,["label","value"]))),128))]),_:1},8,["disabled","modelValue"])]),_:1})])]),_:1},8,["rules","model"]),F("div",ie,[u(f,{type:"primary",onClick:G},{default:s(()=>[ne("\u4FDD\u5B58")]),_:1})])],64)}}});var fe=K(re,[["__scopeId","data-v-5313553e"],["__file","C:/Users/63107/Desktop/projects/accout-vue3-ui/src/views/InvoiceSaleSettings/_component/finance-setting.vue"]]);export{fe as default};