basic-settings.6ab4938b.js 5.8 KB

1
  1. import{_ as J,d as K,w as E,n as P,m as Q,aL as W,ag as v,Z as X,z as A,y as Y,r as f,aC as $,o as s,c as p,b as y,L as ee,G as g,u as i,H as ae,M as q,C as o,l as n,aM as te,F as D,D as V,aN as le,a as U}from"./index.3f1ca816.js";import{c as k,i as R}from"./configs.8dac211e.js";import{h as ue,a as ne}from"./index.ef4412b8.js";import{B as oe}from"./basic-descriptions.78acbb1a.js";import"./tootip.1805b3e1.js";import"./verification.611d3025.js";const se={class:"settings__content","bg-white":""},ie={"mb-2":"","font-bold":""},de={key:1,"h-100px":""},re={"mt-5":""},ce={flex:"",gap:"1"},_e={flex:"","gap-3":""},me={key:1,flex:"","justify-end":""},pe=K({__name:"basic-settings",props:{title:{type:String,required:!0},detail:{type:null,required:!0},columns:{type:Array,required:!0},backRoute:{type:String,required:!0},name:{type:String,required:!1},canChange:{type:Boolean,required:!1}},setup(c){const x=c,T=E(null),Z={cat_code:"",cat_name:"",inv_good_name:"",tax:"",inv_tag:"",is_discount:"",addTax:""},b=E([]),{push:N}=P(),{query:I}=Q(),H=W(),w=E(null),L=v(()=>I.id),e=X({...Z}),C=v(()=>({isDiscount:e.is_discount==="1",isZeroTaxRate:e.tax==="0%"})),B=v(()=>{const{isDiscount:u,isZeroTaxRate:a}=C.value,l=!e.cat_code;return{tax:l,is_discount:l,addTax:l||!a||!u,inv_tag:l||!a||u&&a}}),j=v(()=>{const{isDiscount:u,isZeroTaxRate:a}=C.value;return{...k,inv_tag:[{...k.inv_tag,required:a}],addTax:[{...k.addTax,required:u&&a}]}}),S=v(()=>{const{isDiscount:u,isZeroTaxRate:a}=C.value;let l=[],d=[];return u&&a&&(d=l=[R[0],R[1]]),a&&!u&&(d=[R[2]]),{addTax:l,invTag:d}});function M(){w.value.validate(async u=>{if(!u)return;const a={spuCode:L.value,...e},{code:l,message:d}=await ne(a);H({code:l,message:d,handler:()=>N(x.backRoute)})})}function z(u){if(!u)return e.tax="",e.cat_name="",b.value=[];const{tax:a,cat_name:l}=u;b.value=[...a,"0%"],e.cat_name=l,e.tax="",e.addTax="",e.inv_tag="",e.is_discount=""}const G=()=>{e.addTax="",e.inv_tag=""},O=()=>{e.is_discount="",e.addTax="",e.inv_tag=""};return A(()=>e.addTax,u=>{if(!u)return;const{isZeroTaxRate:a,isDiscount:l}=C.value;a&&l&&(e.inv_tag=e.addTax)}),A(()=>x.detail,async()=>{if(!x.detail)return;const{inv_good_name:u,inv_cat_code:a,is_discount:l,good_name:d,inv_tax:r,inv_tag:_,addTax:h}=x.detail;if(e.inv_good_name=u||d,e.tax=r?r*100+"%":"",e.is_discount=String(l),e.inv_good_name.length>70&&(e.inv_good_name=e.inv_good_name.slice(0,70)),Y(()=>{e.inv_tag=String(_)!=="0"?String(_):"",e.addTax=h}),a&&T.value){const F={cat_code:a},t=await T.value.initalData(F);if(!t||!Array.isArray(t))return;const{tax:m}=t[0];b.value=m}}),(u,a)=>{const l=f("el-form-item"),d=f("el-input"),r=f("el-option"),_=f("el-select"),h=f("el-button"),F=$("loading");return s(),p("div",se,[y("h1",ie,ee(c.title),1),c.detail?(s(),g(i(oe),{key:0,data:c.detail,columns:c.columns,"label-width":"130px","col-number":2},null,8,["data","columns"])):ae((s(),p("div",de,[q("\u8BE6\u60C5\u52A0\u8F7D\u4E2D...")])),[[F,!0]]),y("div",re,[c.canChange?(s(),g(i(le),{key:0,"label-position":"left",ref_key:"formRef",ref:w,rules:i(j),model:e},{default:o(()=>[y("div",ce,[n(l,{label:"\u5546\u54C1\u7C7B\u76EE\u8BBE\u7F6E",prop:"cat_code","flex-1":""},{default:o(()=>[n(i(te),{ref_key:"remoteSelectRef",ref:T,"w-full":"","is-root":"",api:i(ue),modelValue:e.cat_code,"onUpdate:modelValue":a[0]||(a[0]=t=>e.cat_code=t),placeholder:"\u8BF7\u9009\u62E9\u5546\u54C1\u7C7B\u76EE","response-label-prop":"cat_name","response-val-prop":"cat_code","request-prop":"cat_name","sub-label-prop":"short_name",onItemChange:z,onInital:a[1]||(a[1]=t=>e.cat_code=t)},null,8,["api","modelValue"])]),_:1}),n(l,{label:"\u5F00\u7968\u5546\u54C1\u540D\u79F0",prop:"inv_good_name","flex-1":""},{default:o(()=>[n(d,{"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})]),y("div",_e,[n(l,{label:"\u7A0E\u7387",prop:"tax"},{default:o(()=>[n(_,{"w-180px":"",modelValue:e.tax,"onUpdate:modelValue":a[3]||(a[3]=t=>e.tax=t),disabled:i(B).tax,placeholder:"\u8BF7\u8F93\u5165\u7A0E\u7387",onChange:O},{default:o(()=>[(s(!0),p(D,null,V(b.value,(t,m)=>(s(),g(r,{key:m,label:t,value:t},null,8,["label","value"]))),128))]),_:1},8,["modelValue","disabled"])]),_:1}),n(l,{label:"\u662F\u5426\u6709\u4F18\u60E0\u653F\u7B56",prop:"is_discount"},{default:o(()=>[n(_,{disabled:i(B).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:G},{default:o(()=>[n(r,{label:"\u5426",value:"0"}),n(r,{label:"\u662F",value:"1"})]),_:1},8,["disabled","modelValue"])]),_:1}),n(l,{label:"\u589E\u503C\u7A0E\u7BA1\u7406\u5185\u5BB9",prop:"addTax"},{default:o(()=>[n(_,{disabled:i(B).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(()=>[(s(!0),p(D,null,V(i(S).addTax,(t,m)=>(s(),g(r,{key:m,label:t.label,value:t.value},null,8,["label","value"]))),128))]),_:1},8,["disabled","modelValue"])]),_:1}),n(l,{label:"\u6C47\u7387\u6807\u8BC6",prop:"inv_tag"},{default:o(()=>[n(_,{"w-180px":"",disabled:i(B).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(()=>[(s(!0),p(D,null,V(i(S).invTag,(t,m)=>(s(),g(r,{key:m,label:t.label,value:t.value},null,8,["label","value"]))),128))]),_:1},8,["disabled","modelValue"])]),_:1})])]),_:1},8,["rules","model"])):U("v-if",!0),c.canChange?(s(),p("div",me,[n(h,{type:"primary",onClick:M},{default:o(()=>[q("\u4FDD\u5B58")]),_:1})])):U("v-if",!0)])])}}});var Be=J(pe,[["__scopeId","data-v-a5cd9d58"],["__file","C:/Users/63107/Desktop/projects/accout-vue3-ui/src/views/InvoiceSaleSettings/basic-settings.vue"]]);export{Be as default};