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