demand-modify-modal.29d6899a.js 4.4 KB

1
  1. import{_ as A,d as $,cl as Y,m as f,r as m,o as P,A as O,x as s,h as l,u as g,ct as Q,d4 as H,H as T,G as C,b as z,ce as _,S as k}from"./index.56449854.js";import{o as G}from"./index.96b4109c.js";import{c as D}from"./createRequset.56e9fc42.js";import{b as x}from"./calc.f00124e1.js";const F="admin/tips/";var h={list:D(`${F}list`),create:D(`${F}create`),update:D(`${F}update`)};const J={class:"w-full flex justify-end"},K=$({__name:"demand-modify-modal",props:{isBusiness:{type:Boolean,required:!1}},emits:["refresh"],setup(W,{expose:w,emit:I}){const c=Y(!1),v=Y(!1),M=f(null),r=f("create"),b=()=>({date:"",companyNo:"",totalTip1:"",totalTip2:""}),t=f(b()),B=f(null),U={date:[{required:!0,message:"\u8BF7\u9009\u62E9\u6570\u636E\u65F6\u95F4",trigger:"change"}],companyNo:[{required:!0,message:"\u8BF7\u9009\u62E9\u4E1A\u52A1\u516C\u53F8",trigger:"change"}],totalTip1:[{required:!0,message:"\u8BF7\u8F93\u5165\u8425\u6536\u76EE\u6807",trigger:"change"}],totalTip2:[{required:!0,message:"\u8BF7\u8F93\u5165\u6BDB\u5229\u76EE\u6807",trigger:"change"}]};function N(o,e){Number(o)>=1e8?t.value[e]=9999999999e-2:t.value[e]=G(o)}async function S(o,e){var n;try{await((n=B.value)==null?void 0:n.validate());const{companyNo:u,date:i,totalTip1:p,totalTip2:d,id:a}=t.value;if(Number(d)>Number(p)){_.warning("\u6BDB\u5229\u76EE\u6807\u4E0D\u80FD\u529F\u5927\u4E8E\u5E94\u6536\u76EE\u6807");return}v.value=!0;const[R,j]=i.split("-"),V={id:a,total_tips:p,cost_tips:d,companyNo:u,month:j,year:R},y=r.value==="update";y||delete V.id;const E=await(y?h.update:h.create)(V);E.code==0||E.code==1?(_.success((y?"\u4FEE\u6539":"\u6DFB\u52A0")+"\u6210\u529F"),c.value=!1,I("refresh")):_.warning(E.message),v.value=!1}catch{}}function q(o){const e=k(new Date).format("YYYY"),n=k(o).format("YYYY"),u=new Date(2023,0,1);return n-e>=2||o.getTime()<u.getTime()}return w({onDisplay:o=>{if(c.value=!0,o.id){r.value="update";const{id:e,year:n,month:u,cost_tips:i,total_tips:p,companyNo:d}=o;t.value={id:e,companyNo:d,date:`${n}-${String(u).length===1?"0"+u:u}`,totalTip1:p,totalTip2:i},setTimeout(()=>t.value.companyNo=o.companyNo,500)}else r.value="create",t.value={date:"",companyNo:o.companyNo,totalTip1:"",totalTip2:""},setTimeout(()=>t.value.companyNo=o.companyNo,500)}}),(o,e)=>{const n=m("ElDatePicker"),u=m("ElFormItem"),i=m("ElInput"),p=m("ElButton"),d=m("el-dialog");return P(),O(d,{modelValue:c.value,"onUpdate:modelValue":e[6]||(e[6]=a=>c.value=a),title:(r.value==="update"?"\u4FEE\u6539":"\u6DFB\u52A0")+"\u516C\u53F8\u6307\u6807",center:"",onClose:e[7]||(e[7]=()=>t.value=b()),"close-on-click-modal":!1,"close-on-press-escape":!1},{default:s(()=>[l(g(Q),{"label-width":"90px",rules:U,model:t.value,ref_key:"formRef",ref:B},{default:s(()=>[l(u,{label:"\u6307\u6807\u6708\u4EFD",prop:"date"},{default:s(()=>[l(n,{modelValue:t.value.date,"onUpdate:modelValue":e[0]||(e[0]=a=>t.value.date=a),type:"month",style:{width:"100%"},placeholder:"\u6307\u6807\u6708\u4EFD","value-format":"YYYY-MM",disabled:r.value==="update",disabledDate:q},null,8,["modelValue","disabled"])]),_:1}),l(u,{label:"\u6307\u6807\u516C\u53F8",prop:"companyNo"},{default:s(()=>[l(H,{ref_key:"businessQueryRef",ref:M,disabled:r.value==="update",modelValue:t.value.companyNo,"onUpdate:modelValue":e[1]||(e[1]=a=>t.value.companyNo=a),placeholder:"\u6307\u6807\u516C\u53F8"},null,8,["disabled","modelValue"])]),_:1}),l(u,{label:"\u8425\u6536\u76EE\u6807",prop:"totalTip1"},{default:s(()=>[l(i,{placeholder:"\u8425\u6536\u76EE\u6807",modelValue:t.value.totalTip1,"onUpdate:modelValue":e[2]||(e[2]=a=>t.value.totalTip1=a),onInput:e[3]||(e[3]=a=>N(a,"totalTip1"))},{append:s(()=>[T(C(g(x)(t.value.totalTip1)),1)]),_:1},8,["modelValue"])]),_:1}),l(u,{label:"\u6BDB\u5229\u76EE\u6807",prop:"totalTip2"},{default:s(()=>[l(i,{placeholder:"\u6BDB\u5229\u76EE\u6807",modelValue:t.value.totalTip2,"onUpdate:modelValue":e[4]||(e[4]=a=>t.value.totalTip2=a),onInput:e[5]||(e[5]=a=>N(a,"totalTip2"))},{append:s(()=>[T(C(g(x)(t.value.totalTip2)),1)]),_:1},8,["modelValue"])]),_:1}),l(u,null,{default:s(()=>[z("div",J,[l(p,{class:"float-right",loading:v.value,onClick:S,type:"primary"},{default:s(()=>[T(" \u4FDD\u5B58 ")]),_:1},8,["loading"])])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue","title"])}}});var L=A(K,[["__file","C:/Users/89793/Desktop/projects/report-v3/src/views/tipsSetting/companyTotalTips/components/demand-modify-modal.vue"]]),ue=Object.freeze(Object.defineProperty({__proto__:null,default:L},Symbol.toStringTag,{value:"Module"}));export{L as D,h as a,ue as d};