import{_ as W,d as J,x as S,n as K,aO as X,ah as x,Z as Y,aP as $,A as U,z as ee,r as g,o as p,c as B,l as u,D as d,h as F,a as ae,m as c,F as h,E as R,G as A,aQ as te,M as ne}from"./index.js";import{c as w,i as k}from"./configs.f31ce718.js";import{h as le}from"./index.ab253282.js";import ue from"./query-category.748471.js";import"./verification.611d3025.js";const oe={flex:"",gap:"1"},de={flex:"","gap-3":""},ie={flex:"","justify-end":""},se=J({__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:I}){const b=N,_=S(null),L={cat_code:"",cat_name:"",inv_good_name:"",tax:"",inv_tag:"",is_discount:"",addTax:""},v=S([]),{query:j}=K(),H=X(),q=S(null),M=x(()=>j.id),e=Y({...L}),Z=$(!1),T=x(()=>({isDiscount:e.is_discount==="1",isZeroTaxRate:e.tax==="0%"})),C=x(()=>{const l=!e.cat_code,{isDiscount:a,isZeroTaxRate:n}=T.value;return{tax:l,is_discount:l,addTax:l||!n||!a,inv_tag:l||!n||a&&n}}),O=x(()=>{const{isDiscount:l,isZeroTaxRate:a}=T.value;return{...w,inv_tag:[{...w.inv_tag,required:a}],addTax:[{...w.addTax,required:l&&a}]}}),E=x(()=>{const{isDiscount:l,isZeroTaxRate:a}=T.value;let n=[],o=[];return l&&a&&(o=n=[k[0],k[1]]),a&&!l&&(o=[k[2]]),{addTax:n,invTag:o}});function Q(){q.value.validate(async l=>{if(!l)return;const{addTax:a,is_discount:n,inv_tag:o,cat_code:i,inv_good_name:s,tax:f}=e,t=[{addTax:a,is_discount:n,inv_tag:o||"0",cat_code:i,inv_good_name:s,tax:f,spuCode:M.value}];Z.value=!0;const{code:r,message:y}=await le({list:t,status:"2",isZx:b.isZx?"1":"0"});Z.value=!1,H({code:r,message:y,handler:()=>I("refresh")})})}function z(l,a){if(!l)return e.tax="",e.cat_name="",v.value=[];const{tax:n,cat_name:o}=l;e.cat_name=o,v.value=[...n,"0%","1%","3%"],a||(e.tax="",e.addTax="",e.inv_tag="",e.is_discount="")}const G=()=>{e.addTax="",e.inv_tag=""},P=()=>{e.is_discount="",e.addTax="",e.inv_tag=""};return U(()=>e.addTax,l=>{if(!l)return;const{isZeroTaxRate:a,isDiscount:n}=T.value;if(a&&n){const o=E.value.addTax;let i=o.findIndex(s=>s.label===e.addTax);e.inv_tag=o[i].value}},{immediate:!0}),U(()=>[b.detail,_.value],async()=>{if(!b.detail||!_.value)return;const{cgd_inv_good_name:l,cgd_inv_cat_code:a,inv_cat_code:n,is_discount:o,good_name:i,cgd_inv_tax:s,inv_tax:f,inv_tag:t,addTax:r,status:y}=b.detail;if(e.inv_good_name=l||i,e.tax=s||"",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=r}),Number(y)===1&&a&&_.value){const V={cat_code:a},m=await _.value.initalData(V);if(!m||!Array.isArray(m))return;const{tax:D}=m[0];v.value=[...D,"0%","1%","3%"]}if(Number(y)===2&&_.value){const V={cat_code:n},m=await _.value.initalData(V);if(!m||!Array.isArray(m))return;const{tax:D}=m[0];v.value=[...D,"0%","1%","3%"],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=g("el-form-item"),o=g("el-input"),i=g("el-option"),s=g("el-select"),f=g("el-button");return p(),B(h,null,[u(c(te),{"label-position":"left",ref_key:"formRef",ref:q,rules:c(O),model:e},{default:d(()=>[F("div",oe,[u(n,{label:"\u5546\u54C1\u7C7B\u76EE\u8BBE\u7F6E",prop:"cat_code","flex-1":""},{default:d(()=>[ae(` <RemoteSelect\r
          ref="remoteSelectRef"\r
          w-full\r
          :api="httpCatlist"\r
          v-model="formData.cat_code"\r
          :getLabel="handleLabel"\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
          loadMore\r
          @inital="code => (formData.cat_code = code)"\r
        /> `),u(ue,{ref_key:"remoteSelectRef",ref:_,modelValue:e.cat_code,"onUpdate:modelValue":a[0]||(a[0]=t=>e.cat_code=t),onChange:z,classWrapper:"finance-item"},null,8,["modelValue"])]),_:1})]),F("div",null,[u(n,{label:"\u5F00\u7968\u5546\u54C1\u540D\u79F0",prop:"inv_good_name","flex-1":""},{default:d(()=>[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})]),F("div",de,[u(n,{label:"\u7A0E\u7387",prop:"tax"},{default:d(()=>[u(s,{"w-180px":"",modelValue:e.tax,"onUpdate:modelValue":a[2]||(a[2]=t=>e.tax=t),disabled:c(C).tax,placeholder:"\u8BF7\u8F93\u5165\u7A0E\u7387",onChange:P},{default:d(()=>[(p(!0),B(h,null,R(v.value,(t,r)=>(p(),A(i,{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:d(()=>[u(s,{disabled:c(C).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:d(()=>[u(i,{label:"\u5426",value:"0"}),u(i,{label:"\u662F",value:"1"})]),_:1},8,["disabled","modelValue"])]),_:1}),u(n,{label:"\u589E\u503C\u7A0E\u7BA1\u7406\u5185\u5BB9",prop:"addTax"},{default:d(()=>[u(s,{disabled:c(C).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:d(()=>[(p(!0),B(h,null,R(c(E).addTax,(t,r)=>(p(),A(i,{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:d(()=>[u(s,{"w-180px":"",disabled:c(C).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:d(()=>[(p(!0),B(h,null,R(c(E).invTag,(t,r)=>(p(),A(i,{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:Q},{default:d(()=>[ne("\u4FDD\u5B58")]),_:1})])],64)}}});var ve=W(se,[["__scopeId","data-v-5313553e"],["__file","C:/Users/89793/Desktop/projects/settle-vue3/src/views/InvoiceSaleSettings/_component/finance-setting.vue"]]);export{ve as default};
