import{_ as J,d as K,n as D,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 B,a as ae,F,z as S,A as R,i as te,cd as ne,H as le}from"./index.js";import{c as w,i as A}from"./configs.daaaa261.js";import{h as ue}from"./index.49bb9470.js";import oe from"./query-category.dcce26.js";import"./verification.611d3025.js";const ie={flex:"",gap:"1"},de={flex:"","gap-3":""},se={flex:"","justify-end":""},re=K({__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=D(null),j=U,x=N,H={cat_code:"",cat_name:"",inv_good_name:"",tax:"",inv_tag:"",is_discount:"",addTax:""},v=D([]),{query:I}=P(),L=X(),k=D(null),Q=f(()=>I.id),e=Y({...H}),q=$(!1),b=f(()=>({isDiscount:e.is_discount==="1",isZeroTaxRate:e.tax==="0%"})),T=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}}),z=f(()=>{const{isDiscount:l,isZeroTaxRate:a}=b.value;return{...w,inv_tag:[{...w.inv_tag,required:a}],addTax:[{...w.addTax,required:l&&a}]}}),V=f(()=>{const{isDiscount:l,isZeroTaxRate:a}=b.value;let n=[],o=[];return l&&a&&(o=n=[A[0],A[1]]),a&&!l&&(o=[A[2]]),{addTax:n,invTag:o}});function M(){k.value.validate(async l=>{if(!l)return;const{addTax:a,is_discount:n,inv_tag:o,cat_code:d,inv_good_name:s,tax:p}=e,t=[{addTax:a,is_discount:n,inv_tag:o||"0",cat_code:d,inv_good_name:s,tax:p,spuCode:Q.value}];q.value=!0;const{code:r,message:y}=await ue({list:t,status:"2",isZx:x.isZx?"1":"0"});q.value=!1,L({code:r,message:y,handler:()=>j("refresh")})})}function O(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 W=()=>{e.addTax="",e.inv_tag=""},G=()=>{e.is_discount="",e.addTax="",e.inv_tag=""};return Z(()=>e.addTax,l=>{if(!l)return;const{isZeroTaxRate:a,isDiscount:n}=b.value;if(a&&n){const o=V.value.addTax;let d=o.findIndex(s=>s.label===e.addTax);e.inv_tag=o[d].value}},{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:s,inv_tax:p,inv_tag:t,addTax:r,status:y}=x.detail;if(e.inv_good_name=l||d,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&&c.value){const h={cat_code:a},_=await c.value.initalData(h);if(!_||!Array.isArray(_))return;const{tax:E}=_[0];v.value=[...E,"0%","1%","3%"]}if(Number(y)===2&&c.value){const h={cat_code:n},_=await c.value.initalData(h);if(!_||!Array.isArray(_))return;const{tax:E}=_[0];v.value=[...E,"0%","1%","3%"],e.tax=p,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"),d=g("el-option"),s=g("el-select"),p=g("el-button");return m(),C(F,null,[u(te(ne),{"label-position":"left",ref_key:"formRef",ref:k,rules:z.value,model:e},{default:i(()=>[B("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
          :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(oe,{ref_key:"remoteSelectRef",ref:c,modelValue:e.cat_code,"onUpdate:modelValue":a[0]||(a[0]=t=>e.cat_code=t),onChange:O,classWrapper:"finance-item"},null,8,["modelValue"])]),_:1})]),B("div",null,[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})]),B("div",de,[u(n,{label:"\u7A0E\u7387",prop:"tax"},{default:i(()=>[u(s,{"w-180px":"",modelValue:e.tax,"onUpdate:modelValue":a[2]||(a[2]=t=>e.tax=t),disabled:T.value.tax,placeholder:"\u8BF7\u8F93\u5165\u7A0E\u7387",onChange:G},{default:i(()=>[(m(!0),C(F,null,S(v.value,(t,r)=>(m(),R(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:i(()=>[u(s,{disabled:T.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:W},{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(s,{disabled:T.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(F,null,S(V.value.addTax,(t,r)=>(m(),R(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:i(()=>[u(s,{"w-180px":"",disabled:T.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(F,null,S(V.value.invTag,(t,r)=>(m(),R(d,{key:r,label:t.label,value:t.value},null,8,["label","value"]))),128))]),_:1},8,["disabled","modelValue"])]),_:1})])]),_:1},8,["rules","model"]),B("div",se,[u(p,{type:"primary",onClick:M},{default:i(()=>a[6]||(a[6]=[le("\u4FDD\u5B58")])),_:1})])],64)}}});var fe=J(re,[["__scopeId","data-v-5313553e"],["__file","D:/work/jiesuan/settle-vue3/src/views/InvoiceSaleSettings/_component/finance-setting.vue"]]);export{fe as default};
