IssueBatchForm.BsWyG-AW.js 10 KB

1
  1. import{a1 as e,a2 as t,A as a,t as i,F as s,G as l,a3 as o,as as n,ap as r,ad as d,a as u,g as p,k as _,m,z as f,I as c,r as g,q as h}from"./element-plus.B27SxRGv.js";import{p as v,I as y,E as j}from"./index.DYWCVKSk.js";import{M as b,aS as w,aD as V,aL as I,u as D,I as S,bJ as Y,H as x,v as E,s as q,bb as U,t as M,F as k,aU as C}from"./@vue.DbmRtknU.js";import"./lodash-es.DaM9m3L-.js";import"./async-validator.j0i5Y79Y.js";import"./@popperjs.DxtSUbXb.js";import"./@ctrl.BEgk5vdO.js";import"./dayjs.DCWbrgJ0.js";import"./memoize-one.BAtLgO95.js";import"./normalize-wheel-es.TzhA1irr.js";import"./@floating-ui.8vigAAFV.js";import"./pinia.BlfmsheH.js";import"./@vueuse.Dnsd2JKX.js";import"./vue-i18n.DXLOBfKS.js";import"./@intlify.DPMNdUn_.js";import"./nprogress.BTjJXJ-u.js";import"./codemirror.CYSLATvI.js";import"./diff-match-patch.DkK4wJpa.js";import"./vue-web-terminal.D-rog7dz.js";import"./vue.MGxsMDTR.js";/* empty css */import"./vue-router.yxIMtaxH.js";import"./axios.Da-QW0H8.js";import"./qs.BQjOrGHM.js";import"./side-channel.4q28KFJj.js";import"./es-errors.DTEWvbA_.js";import"./object-inspect.DvQZIv3_.js";import"./side-channel-list.Do0-XmF5.js";import"./side-channel-map.DNHQ53lO.js";import"./get-intrinsic.Bbe5x-9b.js";import"./es-object-atoms.CyiuHMUS.js";import"./math-intrinsics.pM-JTNwN.js";import"./gopd.BudZp56J.js";import"./es-define-property.F0aoeP8o.js";import"./has-symbols.BcO-SUVM.js";import"./get-proto.Cb_fpw-j.js";import"./dunder-proto.WEH3rgQR.js";import"./call-bind-apply-helpers.DJjIjCF_.js";import"./function-bind.DrnB-baK.js";import"./hasown.BXcyoiLU.js";import"./call-bound.22gFUC2Q.js";import"./side-channel-weakmap.DpSeWE6i.js";import"./pinia-plugin-persistedstate.COWkwNh5.js";const H={style:{"margin-top":"12px","text-align":"right"}},P=b({__name:"IssueBatchForm",props:{enterpriseId:{},institutionId:{}},emits:["success"],setup(b,{expose:P,emit:z}){const O={EMPLOYEE:"支付宝ID",PHONE:"手机号",ENTERPRISE_PAY_UID:"企业码ID"},F=b,A=C(),N=C(),R=C(!1),T=C([]),L=C([]),B=w({}),G=w({issue_name:"",quota_type:"COUPON",effective_start_date:"",effective_end_date:"",institution_id:F.institutionId||"",batch_no:"",share_mode:"0",issue_desc:"",issue_target_info_list:[]});function J(){const e=new Date;return e.getFullYear().toString()+String(e.getMonth()+1).padStart(2,"0")+String(e.getDate()).padStart(2,"0")+String(e.getHours()).padStart(2,"0")+String(e.getMinutes()).padStart(2,"0")+String(e.getSeconds()).padStart(2,"0")+String(e.getMilliseconds()).padStart(3,"0")}function K(e){L.value=e.map(e=>e.employee_id)}function $(){const e=[];for(const t of T.value){if(!L.value.includes(t.employee_id))continue;const a=B[t.employee_id];!a||a<=0||e.push({issue_quota:String(a),owner_type:"ENTERPRISE_PAY_UID",owner_id:t.employee_id,owner_open_id:t.identity_open_id||void 0,user_name:t.employee_name||""})}0!==e.length?(G.issue_target_info_list=e,R.value=!1):h.warning("请至少选择一个员工并填写有效额度")}V(()=>{G.batch_no=J(),async function(){var e,t,a,i,s,l,o;try{let n=F.enterpriseId;if(!n){n=null==(e=v().getCurrentEnterprise)?void 0:e.enterprise_id}if(!n)return;const r=F.institutionId||G.institution_id;let d="all",u=[];if(r)try{const e=await y.detailInstitution(r,n);if(d=(null==(a=null==(t=null==e?void 0:e.data)?void 0:t.data)?void 0:a.applicable_scope)||"all","employee"===d){const e=await y.listScope(r,{enterprise_id:n,page_size:500});u=((null==(s=null==(i=null==e?void 0:e.data)?void 0:i.data)?void 0:s.scope_info_list)||[]).flatMap(e=>e.owner_id_list||[])}}catch{}const p=await j.listEmployee({enterprise_id:n,page_no:1,page_size:500});let _=((null==(o=null==(l=null==p?void 0:p.data)?void 0:l.data)?void 0:o.items)||[]).filter(e=>"EMPLOYEE_ACTIVATED"===e.status);if("employee"===d&&u.length>0){const e=new Set(u);_=_.filter(t=>e.has(t.employee_id))}else"none"===d&&(_=[]);T.value=_}catch(n){}}()});const Q=w({issue_name:[{required:!0,message:"请输入发放名称",trigger:"blur"}],institution_id:[{required:!0,message:"请输入制度ID",trigger:"blur"}],effective_start_date:[{required:!0,message:"请选择有效起始时间",trigger:"change"}],effective_end_date:[{required:!0,message:"请选择有效结束时间",trigger:"change"}]});return P({submitForm:async function(){var e;return!!(await(null==(e=A.value)?void 0:e.validate().catch(()=>!1)))&&(0!==G.issue_target_info_list.length||(h.warning("请至少选择一个员工并填写额度"),!1))},resetForm:function(){G.issue_name="",G.quota_type="COUPON",G.effective_start_date="",G.effective_end_date="",G.institution_id=F.institutionId||"",G.batch_no=J(),G.share_mode="0",G.issue_desc="",G.issue_target_info_list=[]},getFormData:function(){var e;return{enterprise_id:F.enterpriseId||(null==(e=v().getCurrentEnterprise)?void 0:e.enterprise_id),issue_name:G.issue_name,quota_type:G.quota_type,effective_start_date:G.effective_start_date,effective_end_date:G.effective_end_date,institution_id:G.institution_id,batch_no:G.batch_no,share_mode:G.share_mode,issue_desc:G.issue_desc||void 0,issue_target_info_list:G.issue_target_info_list.length>0?G.issue_target_info_list:void 0}}}),(h,v)=>{const y=i,j=a,b=t,w=e,V=l,C=s,P=n,z=o,J=r,W=d,X=u,Z=p,ee=m,te=_,ae=f,ie=c,se=g;return I(),D(k,null,[S(ae,{ref_key:"formRef",ref:A,model:G,rules:Q,"label-width":"140px","label-suffix":":"},{default:Y(()=>[S(w,{gutter:20},{default:Y(()=>[S(b,{span:12},{default:Y(()=>[S(j,{label:"发放名称",prop:"issue_name"},{default:Y(()=>[S(y,{modelValue:G.issue_name,"onUpdate:modelValue":v[0]||(v[0]=e=>G.issue_name=e),placeholder:"最多20字",maxlength:20},null,8,["modelValue"])]),_:1})]),_:1}),S(b,{span:12},{default:Y(()=>[S(j,{label:"制度ID",prop:"institution_id"},{default:Y(()=>[S(y,{modelValue:G.institution_id,"onUpdate:modelValue":v[1]||(v[1]=e=>G.institution_id=e),placeholder:"制度ID",disabled:!!F.institutionId},null,8,["modelValue","disabled"])]),_:1})]),_:1})]),_:1}),S(w,{gutter:20},{default:Y(()=>[S(b,{span:12},{default:Y(()=>[S(j,{label:"额度类型",prop:"quota_type"},{default:Y(()=>[S(C,{modelValue:G.quota_type,"onUpdate:modelValue":v[2]||(v[2]=e=>G.quota_type=e),disabled:"",style:{width:"100%"}},{default:Y(()=>[S(V,{label:"点券",value:"COUPON"})]),_:1},8,["modelValue"])]),_:1})]),_:1}),S(b,{span:12},{default:Y(()=>[S(j,{label:"是否可转赠",prop:"share_mode"},{default:Y(()=>[S(z,{modelValue:G.share_mode,"onUpdate:modelValue":v[3]||(v[3]=e=>G.share_mode=e)},{default:Y(()=>[S(P,{value:"0"},{default:Y(()=>[...v[9]||(v[9]=[x("不可转赠",-1)])]),_:1}),S(P,{value:"1"},{default:Y(()=>[...v[10]||(v[10]=[x("可转赠",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1}),S(w,{gutter:20},{default:Y(()=>[S(b,{span:12},{default:Y(()=>[S(j,{label:"有效起始时间",prop:"effective_start_date"},{default:Y(()=>[S(J,{modelValue:G.effective_start_date,"onUpdate:modelValue":v[4]||(v[4]=e=>G.effective_start_date=e),type:"datetime",placeholder:"选择日期时间",format:"YYYY-MM-DD HH:mm:ss","value-format":"YYYY-MM-DD HH:mm:ss",style:{width:"100%"}},null,8,["modelValue"])]),_:1})]),_:1}),S(b,{span:12},{default:Y(()=>[S(j,{label:"有效结束时间",prop:"effective_end_date"},{default:Y(()=>[S(J,{modelValue:G.effective_end_date,"onUpdate:modelValue":v[5]||(v[5]=e=>G.effective_end_date=e),type:"datetime",placeholder:"选择日期时间",format:"YYYY-MM-DD HH:mm:ss","value-format":"YYYY-MM-DD HH:mm:ss",style:{width:"100%"}},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),S(w,{gutter:20},{default:Y(()=>[S(b,{span:24},{default:Y(()=>[S(j,{label:"发放说明",prop:"issue_desc"},{default:Y(()=>[S(y,{modelValue:G.issue_desc,"onUpdate:modelValue":v[6]||(v[6]=e=>G.issue_desc=e),type:"textarea",rows:2,placeholder:"可选,最多200字",maxlength:200},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),S(W,{"content-position":"left"},{default:Y(()=>[...v[11]||(v[11]=[x("发放员工列表",-1)])]),_:1}),S(w,{gutter:20},{default:Y(()=>[S(b,{span:24},{default:Y(()=>[S(j,{label:"员工选择",prop:"issue_target_info_list"},{default:Y(()=>[E("div",null,[S(X,{type:"primary",plain:"",onClick:v[7]||(v[7]=e=>R.value=!0)},{default:Y(()=>[...v[12]||(v[12]=[x(" 选择员工并设置额度 ",-1)])]),_:1}),G.issue_target_info_list.length>0?(I(),q(Z,{key:0,type:"info",style:{"margin-left":"8px"}},{default:Y(()=>[x(" 已选 "+U(G.issue_target_info_list.length)+" 人 ",1)]),_:1})):M("",!0)])]),_:1})]),_:1})]),_:1}),G.issue_target_info_list.length>0?(I(),q(w,{key:0,gutter:20},{default:Y(()=>[S(b,{span:24},{default:Y(()=>[S(te,{data:G.issue_target_info_list,border:"","max-height":"300",size:"small"},{default:Y(()=>[S(ee,{type:"index",label:"序号",width:"60"}),S(ee,{prop:"user_name",label:"员工姓名","min-width":"120"}),S(ee,{prop:"owner_type",label:"识别方式","min-width":"120"},{default:Y(e=>[x(U(O[e.row.owner_type]||e.row.owner_type),1)]),_:1}),S(ee,{prop:"owner_id",label:"识别ID","min-width":"160","show-overflow-tooltip":""}),S(ee,{prop:"issue_quota",label:"发放额度(元)","min-width":"120",align:"right"}),S(ee,{label:"操作",width:"80",align:"center"},{default:Y(e=>[S(X,{type:"danger",size:"small",link:"",onClick:t=>{return a=e.$index,void G.issue_target_info_list.splice(a,1);var a}},{default:Y(()=>[...v[13]||(v[13]=[x("移除",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])]),_:1})]),_:1})):M("",!0)]),_:1},8,["model","rules"]),S(se,{modelValue:R.value,"onUpdate:modelValue":v[8]||(v[8]=e=>R.value=e),title:"选择发放员工",width:"700px","destroy-on-close":""},{default:Y(()=>[E("div",null,[S(te,{ref_key:"employeeTableRef",ref:N,data:T.value,border:"","max-height":"400",onSelectionChange:K},{default:Y(()=>[S(ee,{type:"selection",width:"55"}),S(ee,{prop:"employee_name",label:"员工姓名","min-width":"120"}),S(ee,{prop:"employee_id",label:"员工ID","min-width":"160","show-overflow-tooltip":""}),S(ee,{prop:"department_name",label:"部门","min-width":"120"}),S(ee,{label:"发放额度(元)",width:"160"},{default:Y(e=>[S(ie,{modelValue:B[e.row.employee_id],"onUpdate:modelValue":t=>B[e.row.employee_id]=t,min:.01,precision:2,size:"small","controls-position":"right",style:{width:"130px"}},null,8,["modelValue","onUpdate:modelValue"])]),_:1})]),_:1},8,["data"]),E("div",H,[S(X,{type:"primary",onClick:$},{default:Y(()=>[x(" 确认选择 (已选 "+U(L.value.length)+" 人) ",1)]),_:1})])])]),_:1},8,["modelValue"])],64)}}});export{P as default};