1 |
- import{_ as K,d as W,w as D,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 o,b as F,u as d,aQ as te,F as B,D as R,G as S,aR as ne,M as le}from"./index.42bf163d.js";import{c as w,i as A}from"./configs.1568820f.js";import{h as ue,a as oe}from"./index.a3e78a40.js";import"./tootip.bb80052f.js";import"./verification.611d3025.js";const se={flex:"",gap:"1"},ie={flex:"","gap-3":""},de={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=D(null),L={cat_code:"",cat_name:"",inv_good_name:"",tax:"",inv_tag:"",is_discount:"",addTax:""},v=D([]),{query:j}=X(),H=Y(),k=D(null),O=g(()=>j.id),e=$({...L}),q=ee(!1),b=g(()=>({isDiscount:e.is_discount==="1",isZeroTaxRate:e.tax==="0%"})),T=g(()=>{const n=!e.cat_code,{isDiscount:a,isZeroTaxRate:l}=b.value;return{tax:n,is_discount:n,addTax:n||!l||!a,inv_tag:n||!l||a&&l}}),z=g(()=>{const{isDiscount:n,isZeroTaxRate:a}=b.value;return{...w,inv_tag:[{...w.inv_tag,required:a}],addTax:[{...w.addTax,required:n&&a}]}}),U=g(()=>{const{isDiscount:n,isZeroTaxRate:a}=b.value;let l=[],s=[];return n&&a&&(s=l=[A[0],A[1]]),a&&!n&&(s=[A[2]]),{addTax:l,invTag:s}});function G(){k.value.validate(async n=>{if(!n)return;const{addTax:a,is_discount:l,inv_tag:s,cat_code:r,inv_good_name:_,tax:f}=e,t=[{addTax:a,is_discount:l,inv_tag:s||"0",cat_code:r,inv_good_name:_,tax:f,spuCode:O.value}];q.value=!0;const{code:i,message:E}=await oe({list:t,status:"2"});q.value=!1,H({code:i,message:E,handler:()=>N("refresh")})})}function M(n){if(!n)return e.tax="",e.cat_name="",v.value=[];const{tax:a,cat_name:l}=n;e.cat_name=l,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(n){return n.merge_code+" / "+n.cat_name+"-"+n.short_name}return Z(()=>e.addTax,n=>{if(!n)return;const{isZeroTaxRate:a,isDiscount:l}=b.value;a&&l&&(e.inv_tag=e.addTax)},{immediate:!0}),Z(()=>[y.detail,c.value],async()=>{if(!y.detail||!c.value)return;const{cgd_inv_good_name:n,cgd_inv_cat_code:a,inv_cat_code:l,is_discount:s,good_name:r,cgd_inv_tax:_,inv_tax:f,inv_tag:t,addTax:i,status:E}=y.detail;if(e.inv_good_name=n||r,e.tax=_||"",e.is_discount=String(s),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=i}),a&&c.value){const V={cat_code:a},m=await c.value.initalData(V);if(!m||!Array.isArray(m))return;const{tax:h}=m[0];v.value=h}if(Number(E)===2&&c.value){const V={cat_code:l},m=await c.value.initalData(V);if(!m||!Array.isArray(m))return;const{tax:h}=m[0];v.value=h,e.tax=f,e.is_discount=String(s),e.inv_tag=String(t)!=="0"?String(t):"",e.addTax=i}},{immediate:!0}),(n,a)=>{const l=x("el-form-item"),s=x("el-input"),r=x("el-option"),_=x("el-select"),f=x("el-button");return p(),C(B,null,[u(d(ne),{"label-position":"left",ref_key:"formRef",ref:k,rules:d(z),model:e},{default:o(()=>[F("div",se,[u(l,{label:"\u5546\u54C1\u7C7B\u76EE\u8BBE\u7F6E",prop:"cat_code","flex-1":""},{default:o(()=>[u(d(te),{ref_key:"remoteSelectRef",ref:c,"w-full":"","is-root":"",api:d(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(l,{label:"\u5F00\u7968\u5546\u54C1\u540D\u79F0",prop:"inv_good_name","flex-1":""},{default:o(()=>[u(s,{"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",ie,[u(l,{label:"\u7A0E\u7387",prop:"tax"},{default:o(()=>[u(_,{"w-180px":"",modelValue:e.tax,"onUpdate:modelValue":a[3]||(a[3]=t=>e.tax=t),disabled:d(T).tax,placeholder:"\u8BF7\u8F93\u5165\u7A0E\u7387",onChange:Q},{default:o(()=>[(p(!0),C(B,null,R(v.value,(t,i)=>(p(),S(r,{key:i,label:t,value:t},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1}),u(l,{label:"\u662F\u5426\u6709\u4F18\u60E0\u653F\u7B56",prop:"is_discount"},{default:o(()=>[u(_,{disabled:d(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:o(()=>[u(r,{label:"\u5426",value:"0"}),u(r,{label:"\u662F",value:"1"})]),_:1},8,["disabled","modelValue"])]),_:1}),u(l,{label:"\u589E\u503C\u7A0E\u7BA1\u7406\u5185\u5BB9",prop:"addTax"},{default:o(()=>[u(_,{disabled:d(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:o(()=>[(p(!0),C(B,null,R(d(U).addTax,(t,i)=>(p(),S(r,{key:i,label:t.label,value:t.value},null,8,["label","value"]))),128))]),_:1},8,["disabled","modelValue"])]),_:1}),u(l,{label:"\u6C47\u7387\u6807\u8BC6",prop:"inv_tag"},{default:o(()=>[u(_,{"w-180px":"",disabled:d(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:o(()=>[(p(!0),C(B,null,R(d(U).invTag,(t,i)=>(p(),S(r,{key:i,label:t.label,value:t.value},null,8,["label","value"]))),128))]),_:1},8,["disabled","modelValue"])]),_:1})])]),_:1},8,["rules","model"]),F("div",de,[u(f,{type:"primary",onClick:G},{default:o(()=>[le("\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};
|