demand-modify-modal.bf1d74b7.js 4.8 KB

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