chunk-49f13072.3b4594ae.js 44.6 KB
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-49f13072"],{"0193":function(e,a,t){},5417:function(e,a,t){"use strict";t("0193")},acb8:function(e,a,t){"use strict";t.r(a);var r=function(){var e=this,a=e.$createElement,t=e._self._c||a;return t("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading||e.quotaLoading,expression:"loading || quotaLoading"}],staticClass:"leave-apply-page"},[e.flowBoxMode?e._e():t("div",{staticClass:"page-head"},[t("div",[t("div",{staticClass:"page-title"},[e._v(e._s(e.currentSceneConfig.title))]),t("div",{staticClass:"page-tip"},[e._v(e._s(e.currentSceneConfig.tip))]),e.isPaidScene?t("div",{staticClass:"page-tip-sub"},[e._v("\n        请选择带薪假类型与起始时间;请假天数从列表选择(仅整天,不超过当前类型可用上限)。\n      ")]):e._e()]),t("div",{staticClass:"page-actions"},[t("el-button",{on:{click:e.handleBack}},[e._v("返回")]),t("el-button",{attrs:{type:"warning",loading:e.submitLoading&&"save"===e.submitType},on:{click:function(a){return e.handleSubmit("save")}}},[e._v("保存草稿")]),t("el-button",{attrs:{type:"primary",loading:e.submitLoading&&"submit"===e.submitType},on:{click:function(a){return e.handleSubmit("submit")}}},[e._v("提交申请")])],1)]),e.flowBoxMode||e.dataForm.flowId?e._e():t("el-alert",{staticClass:"head-alert",attrs:{type:"warning",closable:!1,title:"当前页面未携带 flowId,请从流程入口进入,或在地址后追加 ?flowId=流程ID 再提交。","show-icon":""}}),e.showSummaryPanel?t("div",{staticClass:"summary-panel"},[t("div",{staticClass:"summary-head"},[t("div",{staticClass:"summary-title"},[e._v(e._s(e.currentSceneConfig.summaryTitle))]),e.canFillMaxDays?t("el-button",{attrs:{type:"text"},on:{click:e.fillMaxDays}},[e._v("按可用上限填入天数")]):e._e()],1),t("el-row",{attrs:{gutter:16}},e._l(e.summaryCards,(function(a){return t("el-col",{key:a.key,attrs:{xs:24,sm:12,md:6}},[t("div",{staticClass:"summary-card",class:{active:a.active}},[t("div",{staticClass:"summary-label"},[e._v(e._s(a.label))]),t("div",{staticClass:"summary-value"},[e._v(e._s(a.value))]),a.desc?t("div",{staticClass:"summary-desc"},[e._v(e._s(a.desc))]):e._e()])])})),1),e.leaveTypeSummaryText?t("div",{staticClass:"summary-helper"},[e._v(e._s(e.leaveTypeSummaryText))]):e._e()],1):e._e(),t("el-card",{staticClass:"form-card",attrs:{shadow:"never"}},[t("div",{staticClass:"card-head",attrs:{slot:"header"},slot:"header"},[t("span",[e._v("申请信息")]),t("span",{staticClass:"bill-no"},[e._v("单据号:"+e._s(e.dataForm.billNo||"生成中..."))])]),t("el-form",{ref:"dataForm",attrs:{model:e.dataForm,rules:e.dataRule,"label-width":"100px",disabled:e.setting.readonly}},[t("el-row",{attrs:{gutter:16}},[t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"流程标题",prop:"flowTitle"}},[t("el-input",{attrs:{maxlength:"50",placeholder:"请输入流程标题"},model:{value:e.dataForm.flowTitle,callback:function(a){e.$set(e.dataForm,"flowTitle","string"===typeof a?a.trim():a)},expression:"dataForm.flowTitle"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"紧急程度",prop:"flowUrgent"}},[t("el-select",{attrs:{placeholder:"请选择紧急程度"},model:{value:e.dataForm.flowUrgent,callback:function(a){e.$set(e.dataForm,"flowUrgent",a)},expression:"dataForm.flowUrgent"}},e._l(e.flowUrgentOptions,(function(e){return t("el-option",{key:e.value,attrs:{label:e.label,value:e.value}})})),1)],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"申请人员"}},[t("el-input",{attrs:{value:e.dataForm.applyUser||"无",readonly:""}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"申请日期"}},[t("el-date-picker",{attrs:{type:"date","value-format":"timestamp",format:"yyyy-MM-dd",readonly:"",editable:!1},model:{value:e.dataForm.applyDate,callback:function(a){e.$set(e.dataForm,"applyDate",a)},expression:"dataForm.applyDate"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"申请部门"}},[t("el-input",{attrs:{value:e.dataForm.applyDept||"无",readonly:""}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"申请职位"}},[t("el-input",{attrs:{value:e.dataForm.applyPost||"无",readonly:""}})],1)],1),t("el-col",{attrs:{span:24}},[t("el-form-item",{attrs:{label:e.currentSceneConfig.leaveTypeLabel,prop:"leaveType"}},[t("el-radio-group",{on:{change:e.handleLeaveTypeChange},model:{value:e.dataForm.leaveType,callback:function(a){e.$set(e.dataForm,"leaveType",a)},expression:"dataForm.leaveType"}},e._l(e.leaveTypeOptions,(function(a){return t("el-radio",{key:a.value,attrs:{label:a.value}},[e._v(e._s(a.label))])})),1)],1)],1),e.isPaidScene&&"丧假"===e.dataForm.leaveType?t("el-col",{attrs:{span:24}},[t("el-form-item",{attrs:{label:"丧假关系",prop:"funeralRelationType"}},[t("el-radio-group",{model:{value:e.dataForm.funeralRelationType,callback:function(a){e.$set(e.dataForm,"funeralRelationType",a)},expression:"dataForm.funeralRelationType"}},[t("el-radio",{attrs:{label:1}},[e._v("直系亲属")]),t("el-radio",{attrs:{label:2}},[e._v("非直系亲属")])],1)],1)],1):e._e(),e.isPaidScene?e._e():t("el-col",{attrs:{span:24}},[t("el-form-item",{attrs:{label:"请假原因",prop:"leaveReason"}},[t("el-input",{attrs:{type:"textarea",rows:3,maxlength:"300","show-word-limit":"",placeholder:e.currentSceneConfig.reasonPlaceholder},model:{value:e.dataForm.leaveReason,callback:function(a){e.$set(e.dataForm,"leaveReason","string"===typeof a?a.trim():a)},expression:"dataForm.leaveReason"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"起始时间",prop:"leaveStartTime"}},[t("el-date-picker",{attrs:{type:"date","value-format":"timestamp",format:"yyyy-MM-dd",editable:!1,placeholder:"选择日期"},on:{change:e.recomputeLeaveRangeFromNaturalDay},model:{value:e.leaveStartDateTs,callback:function(a){e.leaveStartDateTs=a},expression:"leaveStartDateTs"}})],1)],1),e.needsHalfPeriod?t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"半天为"}},[t("el-radio-group",{on:{change:e.recomputeLeaveRangeFromNaturalDay},model:{value:e.dayHalfPeriod,callback:function(a){e.dayHalfPeriod=a},expression:"dayHalfPeriod"}},[t("el-radio",{attrs:{label:"am"}},[e._v("上午")]),t("el-radio",{attrs:{label:"pm"}},[e._v("下午")])],1)],1)],1):e._e(),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"结束时间"}},[t("el-input",{attrs:{value:e.leaveEndTimeDisplay,readonly:"",placeholder:"根据起始时间与请假天数自动计算"}})],1)],1),t("el-col",{attrs:{span:24}},[e.isPaidScene?t("div",{staticClass:"form-helper"},[e._v("带薪休假仅支持整天;请在下方下拉中选择 1~当前类型可用上限 的天数。")]):e.isRestScene?t("div",{staticClass:"form-helper"},[e._v("应休请先选整数天;若有半天拆分额度,可勾选「再加半天」;含半天时请选择上/下午。")]):e.isPersonalScene?t("div",{staticClass:"form-helper"},[e._v("事假、病假请在下方下拉中选择 1~10 天整数天;1 天按自然日 24 小时计。")]):t("div",{staticClass:"form-helper"},[e._v("1 天按自然日 24 小时计;请假天数支持整数或 0.5,含半天时请选择上/下午。")])]),t("el-col",{attrs:{span:12}},[e.isPaidScene?t("el-form-item",{attrs:{label:"请假天数",prop:"leaveDayCount"}},[t("el-select",{attrs:{placeholder:"请选择请假天数",clearable:"",filterable:""},on:{change:e.recomputeLeaveRangeFromNaturalDay},model:{value:e.dataForm.leaveDayCount,callback:function(a){e.$set(e.dataForm,"leaveDayCount",a)},expression:"dataForm.leaveDayCount"}},e._l(e.paidLeaveDaySelectOptions,(function(e){return t("el-option",{key:e,attrs:{label:e+" 天",value:String(e)}})})),1)],1):e.isRestScene?t("el-form-item",{attrs:{label:"请假天数",prop:"leaveDayCount"}},[t("div",{staticClass:"rest-days-admin"},[t("el-select",{staticClass:"rest-days-admin__full",attrs:{placeholder:"整数天"},on:{change:e.syncRestLeaveDayToForm},model:{value:e.restFullDays,callback:function(a){e.restFullDays=e._n(a)},expression:"restFullDays"}},e._l(e.restFullDaySelectOptions,(function(e){return t("el-option",{key:e,attrs:{label:0===e?"0 天(与半天组合)":e+" 天",value:e}})})),1),e.restCanOfferHalfDay?t("el-checkbox",{staticClass:"rest-days-admin__half",attrs:{disabled:!e.restHalfChoiceEnabled},on:{change:e.syncRestLeaveDayToForm},model:{value:e.restAddHalfDay,callback:function(a){e.restAddHalfDay=a},expression:"restAddHalfDay"}},[e._v("再加半天")]):e._e()],1)]):e.isPersonalScene?t("el-form-item",{attrs:{label:"请假天数",prop:"leaveDayCount"}},[t("el-select",{attrs:{placeholder:"请选择请假天数",clearable:"",filterable:""},on:{change:e.recomputeLeaveRangeFromNaturalDay},model:{value:e.dataForm.leaveDayCount,callback:function(a){e.$set(e.dataForm,"leaveDayCount",a)},expression:"dataForm.leaveDayCount"}},e._l(e.personalLeaveDaySelectOptions,(function(e){return t("el-option",{key:e,attrs:{label:e+" 天",value:String(e)}})})),1)],1):t("el-form-item",{attrs:{label:"请假天数",prop:"leaveDayCount"}},[t("el-input",{attrs:{placeholder:"请输入请假天数"},on:{input:e.recomputeLeaveRangeFromNaturalDay,blur:e.recomputeLeaveRangeFromNaturalDay},model:{value:e.dataForm.leaveDayCount,callback:function(a){e.$set(e.dataForm,"leaveDayCount","string"===typeof a?a.trim():a)},expression:"dataForm.leaveDayCount"}},[t("template",{slot:"append"},[e._v("天")])],2)],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"请假小时",prop:"leaveHour"}},[t("el-input",{attrs:{placeholder:"请输入请假小时"},model:{value:e.dataForm.leaveHour,callback:function(a){e.$set(e.dataForm,"leaveHour","string"===typeof a?a.trim():a)},expression:"dataForm.leaveHour"}},[t("template",{slot:"append"},[e._v("小时")])],2)],1)],1),t("el-col",{attrs:{span:24}},[t("el-form-item",{attrs:{label:"相关附件",prop:"fileJson"}},[t("NCC-UploadFz",{attrs:{type:"workFlow"},model:{value:e.fileList,callback:function(a){e.fileList=a},expression:"fileList"}})],1)],1)],1)],1)],1)],1)},i=[],s=(t("7cdf"),t("a481"),t("7f7f"),t("96cf"),t("3b8d")),n=(t("f576"),t("5df3"),t("1c4c"),t("7514"),t("75fc")),l=(t("ac6a"),t("8615"),t("7618")),o=t("db72"),u=t("bd86"),c=(t("6762"),t("2fdb"),t("c5f6"),t("ee1d"),t("2f62")),m=t("eff6"),d=t("826a");function f(e,a,t){var r=Number(a);if(!e||!r||r<=0)return{leaveStartTime:"",leaveEndTime:"",leaveHour:""};if(2*r!==Math.round(2*r))return{leaveStartTime:"",leaveEndTime:"",leaveHour:""};var i,s,n="pm"===t?"pm":"am",l=Math.round(2*r),o=Math.floor(l/2),u=l%2===1,c=new Date(String(e).replace(/-/g,"/")+" 00:00:00");if(Number.isNaN(c.getTime()))return{leaveStartTime:"",leaveEndTime:"",leaveHour:""};function m(e){var a=e.getFullYear(),t="".concat(e.getMonth()+1).padStart(2,"0"),r="".concat(e.getDate()).padStart(2,"0");return"".concat(a,"-").concat(t,"-").concat(r)}function d(e){return String(e).padStart(2,"0")}function f(e,a){var t=new Date(e.getTime());return t.setDate(t.getDate()+a),t}if(0===o&&u)"pm"===n?(i=new Date(c),i.setHours(12,0,0,0),s=new Date(c),s.setHours(23,59,59,0)):(i=new Date(c),i.setHours(0,0,0,0),s=new Date(c),s.setHours(11,59,59,0));else if(o>0&&u)i=new Date(c),i.setHours(0,0,0,0),s=f(c,o),"am"===n?s.setHours(11,59,59,0):s.setHours(23,59,59,0);else{if(i=new Date(c),i.setHours(0,0,0,0),o<=0)return{leaveStartTime:"",leaveEndTime:"",leaveHour:""};s=f(c,o-1),s.setHours(23,59,59,0)}var v="".concat(m(i)," ").concat(d(i.getHours()),":").concat(d(i.getMinutes()),":").concat(d(i.getSeconds())),h="".concat(m(s)," ").concat(d(s.getHours()),":").concat(d(s.getMinutes()),":").concat(d(s.getSeconds())),y=24*r,p=Number.isInteger(y)?String(y):y.toFixed(1);return{leaveStartTime:v,leaveEndTime:h,leaveHour:p}}function v(e){if(!e||"object"!==Object(l["a"])(e))return null;var a=null!=e.code?e.code:e.Code,t=200===Number(a)||200===a||"200"===a,r=null!=e.data?e.data:e.Data;if("string"===typeof r)try{r=JSON.parse(r)}catch(s){r=null}if(r&&"object"===Object(l["a"])(r)&&void 0===r.paid&&void 0===r.Paid){var i=null!=r.data?r.data:r.Data;!i||"object"!==Object(l["a"])(i)||void 0===i.paid&&void 0===i.Paid&&void 0===i.serverDate&&void 0===i.ServerDate||(r=i)}return t&&void 0!==r&&null!==r?r:void 0!==e.paid||void 0!==e.Paid?e:void 0!==r&&null!==r?r:null}var h="rest",y="personal",p="paid",D=function(){return{id:"",flowId:"",billNo:"",flowTitle:"",flowUrgent:1,applyUser:"",applyDate:"",applyDept:"",applyPost:"",leaveType:"",leaveReason:"",funeralRelationType:1,leaveStartTime:"",leaveEndTime:"",leaveDayCount:"",leaveHour:"",fileJson:""}},b={name:"LeaveApplyPage",props:{scene:{type:String,default:h}},data:function(){var e,a=this,t=function(e,t,r){if(a.flowBoxMode&&a.dataForm.id){var i=a.parseTimeToMs(a.dataForm.leaveStartTime),s=a.parseTimeToMs(a.dataForm.leaveEndTime);if(!Number.isNaN(i)&&!Number.isNaN(s)&&i>0&&s>0)return r()}if(!a.leaveStartDateTs)return r(new Error("请选择起始时间"));var n=Number(a.dataForm.leaveDayCount||0);if(!n||n<=0)return a.isPaidScene?r(new Error("请选择请假天数")):a.isRestScene?r(new Error("请选择请假天数(整数天,必要时勾选再加半天)")):a.isPersonalScene?r(new Error("请选择请假天数")):r(new Error("请输入请假天数"));if(a.isPaidScene){if(Math.floor(n)!==n)return r(new Error("带薪休假仅可选择整天"))}else if(a.isPersonalScene){if(Math.floor(n)!==n||n<1||n>10)return r(new Error("请选择 1~10 天整数天"))}else if(Math.round(2*n)!==2*n)return r(new Error("请假天数必须是整数或 0.5 的倍数"));if(!a.dataForm.leaveStartTime||!a.dataForm.leaveEndTime)return r(new Error("请确认起始时间与请假天数,系统将自动计算起止时刻"));r()},r=function(e,t,r){if(a.isPaidScene&&a.flowBoxMode&&a.dataForm.id){var i=Number(t);if(""!==t&&null!=t&&!Number.isNaN(i)&&i>0)return r()}if(""===t||null===t||void 0===t)return a.isPaidScene?r(new Error("请选择请假天数")):a.isRestScene?r(new Error("请选择请假天数(整数天,必要时勾选再加半天)")):a.isPersonalScene?r(new Error("请选择请假天数")):r(new Error("请输入请假天数"));var s=Number(t);if(!s||s<=0)return r(new Error("请假天数必须大于 0"));if(a.isPaidScene){if(Math.floor(s)!==s)return r(new Error("带薪休假仅可选择整天"));var n=a.paidLeaveMaxInteger;return n<=0?a.flowBoxMode&&a.dataForm.id?r():r(new Error("当前假期类型暂无可选天数")):s>n?r(new Error("最多可选 ".concat(n," 天"))):r()}if(a.isRestScene){if(Math.round(2*s)!==2*s)return r(new Error("请假天数必须是整数或 0.5 天"));var l=a.restMaxAvailableDays;if(s>l)return r(new Error("最多可申请 ".concat(a.formatNumber(l)," 天")));var o=s-Math.floor(s);return o>a.restRemainingHalfSplit+1e-9?r(new Error("半天拆分额度不足")):r()}return a.isPersonalScene?Math.floor(s)!==s?r(new Error("事假、病假须选择整数天")):s<1||s>10?r(new Error("事假、病假可选择 1~10 天")):r():Math.round(2*s)!==2*s?r(new Error("请假天数必须是整数或 0.5 的倍数")):void r()},i=function(e,t,r){if(a.flowBoxMode&&a.dataForm.id){var i=Number(t);if(""!==t&&null!=t&&!Number.isNaN(i)&&i>0)return r()}if(""===t||null===t||void 0===t)return r(new Error(e.message));var s=Number(t);return!s||s<=0?r(new Error("请假小时必须大于 0")):a.isPaidScene||a.isPersonalScene?Math.floor(s)!==s?r(new Error("请假小时须为整数")):r():Math.round(2*s)!==2*s?r(new Error("请假小时必须是整数或 0.5 的倍数")):void r()},s=function(e,t,r){return a.isPaidScene&&"丧假"===a.dataForm.leaveType?[1,2].includes(Number(t))?void r():r(new Error("请选择丧假关系")):r()},n=function(e,t,r){return a.isPaidScene?r():t&&String(t).trim()?void r():r(new Error("请输入请假原因"))};return{loading:!1,quotaLoading:!1,submitLoading:!1,submitType:"",applicantName:"",fileList:[],quotaSummary:null,flowBoxMode:!1,setting:{},leaveStartDateTs:"",dayHalfPeriod:"am",restFullDays:0,restAddHalfDay:!1,_suppressLeaveTypeSideEffects:!1,flowUrgentOptions:[{value:1,label:"普通"},{value:2,label:"重要"},{value:3,label:"紧急"}],sceneConfigMap:(e={},Object(u["a"])(e,h,{title:"休假申请",tip:"当前页用于发起每月应休天数的休假申请。",summaryTitle:"本月休假额度",leaveTypeLabel:"休假类别",reasonPlaceholder:"请输入休假原因",defaultLeaveType:"休假",leaveTypeOptions:[{value:"休假",label:"休假"}]}),Object(u["a"])(e,y,{title:"事假申请",tip:"当前页用于发起事假、病假申请。",summaryTitle:"请假说明",leaveTypeLabel:"请假类别",reasonPlaceholder:"请输入事假/病假原因",defaultLeaveType:"事假",leaveTypeOptions:[{value:"事假",label:"事假"},{value:"病假",label:"病假"}]}),Object(u["a"])(e,p,{title:"带薪休假",tip:"当前页用于发起婚假、丧假、年假、产假、额外假期申请。",summaryTitle:"带薪休假额度",leaveTypeLabel:"带薪休假类别",reasonPlaceholder:"请输入带薪休假原因",defaultLeaveType:"婚假",leaveTypeOptions:[{value:"婚假",label:"婚假"},{value:"丧假",label:"丧假"},{value:"年假",label:"年假"},{value:"产假",label:"产假"}]}),e),dataForm:D(),dataRule:{flowTitle:[{required:!0,message:"请输入流程标题",trigger:"blur"}],flowUrgent:[{required:!0,message:"请选择紧急程度",trigger:"change"}],leaveType:[{required:!0,message:"请选择请假类别",trigger:"change"}],leaveReason:[{validator:n,trigger:"blur"}],funeralRelationType:[{validator:s,trigger:"change"}],leaveStartTime:[{validator:t,trigger:"change"}],leaveDayCount:[{validator:r,trigger:"change"}],leaveHour:[{validator:i,message:"请输入请假小时",trigger:"blur"}]}}},computed:Object(o["a"])(Object(o["a"])({},Object(c["b"])(["userInfo"])),{},{currentSceneConfig:function(){return this.sceneConfigMap[this.scene]||this.sceneConfigMap[h]},isRestScene:function(){return this.scene===h},isPersonalScene:function(){return this.scene===y},isPaidScene:function(){return this.scene===p},showSummaryPanel:function(){return this.isRestScene||this.isPaidScene},restQuota:function(){var e=this.quotaSummary||{},a=e.rest||e.Rest;return a&&"object"===Object(l["a"])(a)?Object(o["a"])(Object(o["a"])({},a),{},{workedDaysThisMonth:null!=a.workedDaysThisMonth?a.workedDaysThisMonth:null!=a.WorkedDaysThisMonth?a.WorkedDaysThisMonth:0,restUnlockCycle:null!=a.restUnlockCycle?a.restUnlockCycle:null!=a.RestUnlockCycle?a.RestUnlockCycle:0,unlockedRestDays:null!=a.unlockedRestDays?a.unlockedRestDays:null!=a.UnlockedRestDays?a.UnlockedRestDays:0,availableRestDays:null!=a.availableRestDays?a.availableRestDays:null!=a.AvailableRestDays?a.AvailableRestDays:0}):{}},paidQuota:function(){var e=this.quotaSummary||{},a=e.paid||e.Paid;if(!a||"object"!==Object(l["a"])(a))return{marriage:{},funeral:{},annual:{},maternity:{},extraLeaves:[]};var t=a.marriage||a.Marriage||{},r=a.funeral||a.Funeral||{},i=a.annual||a.Annual||{},s=a.maternity||a.Maternity||{},n=a.extraLeaves||a.ExtraLeaves,o=[];Array.isArray(n)?o=n:n&&"object"===Object(l["a"])(n)&&(o=Object.values(n));var u=o.map((function(e,a){return{id:e.id||e.Id||"extra-"+a,leaveName:String(e.leaveName||e.LeaveName||"").trim(),grantYear:null!=e.grantYear?e.grantYear:e.GrantYear,extraDays:Number(null!=e.extraDays?e.extraDays:null!=e.ExtraDays?e.ExtraDays:0)}})).filter((function(e){return e.leaveName}));return{marriage:{matched:null!=t.matched?t.matched:t.Matched,maxDays:Number(null!=t.maxDays?t.maxDays:null!=t.MaxDays?t.MaxDays:0)},funeral:{matched:null!=r.matched?r.matched:r.Matched,directRelativeDays:Number(null!=r.directRelativeDays?r.directRelativeDays:null!=r.DirectRelativeDays?r.DirectRelativeDays:0),indirectRelativeDays:Number(null!=r.indirectRelativeDays?r.indirectRelativeDays:null!=r.IndirectRelativeDays?r.IndirectRelativeDays:0)},annual:{matched:null!=i.matched?i.matched:i.Matched,totalDays:Number(null!=i.totalDays?i.totalDays:null!=i.TotalDays?i.TotalDays:0),usedDays:Number(null!=i.usedDays?i.usedDays:null!=i.UsedDays?i.UsedDays:0),remainingDays:Number(null!=i.remainingDays?i.remainingDays:null!=i.RemainingDays?i.RemainingDays:0)},maternity:{matched:null!=s.matched?s.matched:s.Matched,maxDays:Number(null!=s.maxDays?s.maxDays:null!=s.MaxDays?s.MaxDays:0)},extraLeaves:u}},extraLeaveList:function(){return Array.isArray(this.paidQuota.extraLeaves)?this.paidQuota.extraLeaves:[]},leaveTypeOptions:function(){var e=this.currentSceneConfig.leaveTypeOptions||[];if(!this.isPaidScene||!this.extraLeaveList.length)return e;var a=this.extraLeaveList.map((function(e){var a=String(e.leaveName||"").trim(),t=e.grantYear,r=a&&null!=t&&""!==t?"".concat(a,"(").concat(t,"年)"):a;return{value:a,label:r}}));return[].concat(Object(n["a"])(e),Object(n["a"])(a))},summaryCards:function(){if(this.isRestScene){var e=this.restQuota,a=e.restUnlockCycle>0,t=a?e.availableRestDays||0:e.remainingRestDays||0,r=a?"已解锁 ".concat(e.unlockedRestDays||0," 天"):"天",i=[{key:"total",label:"本月应休",value:this.formatNumber(e.monthlyRestDays||0),desc:"天"},{key:"used",label:"已申请",value:this.formatNumber(e.usedRestDays||0),desc:"天"},{key:"remain",label:"剩余可休",value:this.formatNumber(t),desc:r,active:!0},{key:"split",label:"半天额度",value:this.formatNumber(e.remainingHalfDaySplitDays||0),desc:"还能拆 ".concat(e.remainingHalfDaySelections||0," 次半天")}];return a&&i.push({key:"worked",label:"本月已上班",value:"".concat(e.workedDaysThisMonth||0," 天"),desc:"每".concat(e.restUnlockCycle,"天解锁1天")}),i}if(this.isPersonalScene)return[{key:"personal",label:"可申请类型",value:"事假 / 病假",desc:"1~10 天可选",active:!0}];var s=this.extraLeaveList.reduce((function(e,a){return e+Number(a.extraDays||0)}),0),n=String(this.dataForm.leaveType||"").trim(),l=this.extraLeaveList.some((function(e){return String(e.leaveName||"").trim()===n}));return[{key:"marriage",label:"婚假",value:"".concat(this.formatNumber((this.paidQuota.marriage||{}).maxDays||0)," 天"),active:"婚假"===this.dataForm.leaveType},{key:"funeral",label:"丧假",value:"".concat(this.formatNumber((this.paidQuota.funeral||{}).directRelativeDays||0)," / ").concat(this.formatNumber((this.paidQuota.funeral||{}).indirectRelativeDays||0)," 天"),desc:"直系 / 非直系",active:"丧假"===this.dataForm.leaveType},{key:"annual",label:"年假剩余",value:"".concat(this.formatNumber((this.paidQuota.annual||{}).remainingDays||0)," 天"),desc:"总额 ".concat(this.formatNumber((this.paidQuota.annual||{}).totalDays||0)," 天"),active:"年假"===this.dataForm.leaveType},{key:"maternity",label:"产假",value:"".concat(this.formatNumber((this.paidQuota.maternity||{}).maxDays||0)," 天"),desc:"按后台规则",active:"产假"===this.dataForm.leaveType},{key:"extra",label:"额外假期总额",value:"".concat(this.formatNumber(s)," 天"),active:l}]},leaveTypeSummaryText:function(){var e=this;if(this.isRestScene){var a=this.restQuota;if(!a.attendanceGroupBound)return"当前用户还未绑定考勤分组,暂时无法计算本月休假额度。";if(a.restUnlockCycle>0){var t=a.workedDaysThisMonth||0,r=a.restUnlockCycle,i=a.unlockedRestDays||0,s=a.availableRestDays||0,n=t%r,l=0===n?r:r-n,o=i<(a.monthlyRestDays||0),u="本月已上班 ".concat(t," 天,已解锁 ").concat(i," 天应休,当前可申请 ").concat(s," 天。");return o&&l>0&&(u+="再上满 ".concat(l," 天可再解锁 1 天。")),u}return"当前分组【".concat(a.attendanceGroupName||"未命名分组","】本月还可休 ").concat(this.formatNumber(a.remainingRestDays||0)," 天;其中还能拆分半天 ").concat(this.formatNumber(a.remainingHalfDaySplitDays||0)," 天。")}if(this.isPersonalScene)return"事假、病假不限制后台额度;请假天数请在下拉中选择 1~10 天整数天;1 天按自然日 24 小时计。";if("婚假"===this.dataForm.leaveType){var c=Number((this.paidQuota.marriage||{}).maxDays||0);return c>0?"按当前司龄规则,本次婚假最多可请 ".concat(this.formatNumber(c)," 天。"):"当前未匹配到婚假规则,请先联系管理员维护规则。"}if("丧假"===this.dataForm.leaveType){var m=this.paidQuota.funeral||{},d=Number(1===Number(this.dataForm.funeralRelationType)?m.directRelativeDays:m.indirectRelativeDays)||0;return"当前丧假规则:直系亲属 ".concat(this.formatNumber(m.directRelativeDays||0)," 天,非直系亲属 ").concat(this.formatNumber(m.indirectRelativeDays||0)," 天;当前选择最多可请 ").concat(this.formatNumber(d)," 天。")}if("年假"===this.dataForm.leaveType){var f=this.paidQuota.annual||{};return"本年年假总额 ".concat(this.formatNumber(f.totalDays||0)," 天,已申请 ").concat(this.formatNumber(f.usedDays||0)," 天,剩余 ").concat(this.formatNumber(f.remainingDays||0)," 天。")}if("产假"===this.dataForm.leaveType){var v=this.paidQuota.maternity||{};return Number(v.maxDays||0)>0?"按当前司龄规则,本次产假最多可请 ".concat(this.formatNumber(v.maxDays||0)," 天。"):"当前未匹配到产假规则,请先联系管理员维护规则。"}var h=this.extraLeaveList.find((function(a){return String(a.leaveName||"").trim()===String(e.dataForm.leaveType||"").trim()}));return h?"当前额外假期【".concat(h.leaveName,"】最多可请 ").concat(this.formatNumber(h.extraDays||0)," 天。"):""},selectedLeaveMaxDays:function(){var e=this;if(this.isRestScene){var a=this.restQuota;return a.restUnlockCycle>0?Number(a.availableRestDays||0):Number(a.remainingRestDays||0)}if(!this.isPaidScene)return null;if("婚假"===this.dataForm.leaveType)return Number((this.paidQuota.marriage||{}).maxDays||0);if("丧假"===this.dataForm.leaveType)return Number(1===Number(this.dataForm.funeralRelationType)?(this.paidQuota.funeral||{}).directRelativeDays||0:(this.paidQuota.funeral||{}).indirectRelativeDays||0);if("年假"===this.dataForm.leaveType)return Number((this.paidQuota.annual||{}).remainingDays||0);if("产假"===this.dataForm.leaveType)return Number((this.paidQuota.maternity||{}).maxDays||0);var t=this.extraLeaveList.find((function(a){return String(a.leaveName||"").trim()===String(e.dataForm.leaveType||"").trim()}));return t?Number(t.extraDays||0):null},canFillMaxDays:function(){return!this.isPaidScene&&(null!==this.selectedLeaveMaxDays&&this.selectedLeaveMaxDays>0)},paidLeaveMaxInteger:function(){if(!this.isPaidScene)return 0;var e=Number(this.selectedLeaveMaxDays);return null===this.selectedLeaveMaxDays||void 0===this.selectedLeaveMaxDays||Number.isNaN(e)?0:Math.max(0,Math.floor(e))},paidLeaveDaySelectOptions:function(){var e=this.paidLeaveMaxInteger;return!this.isPaidScene||e<=0?[]:Array.from({length:e},(function(e,a){return a+1}))},personalLeaveDaySelectOptions:function(){return this.isPersonalScene?Array.from({length:10},(function(e,a){return a+1})):[]},restMaxAvailableDays:function(){return this.isRestScene?Number(this.selectedLeaveMaxDays||0):0},restRemainingHalfSplit:function(){return this.isRestScene?Number(this.restQuota.remainingHalfDaySplitDays||0):0},restCanOfferHalfDay:function(){return this.isRestScene&&this.restRemainingHalfSplit>=.5},restFullDayMax:function(){return Math.max(0,Math.floor(this.restMaxAvailableDays))},restFullDaySelectOptions:function(){if(!this.isRestScene)return[];var e=this.restFullDayMax;return Array.from({length:e+1},(function(e,a){return a}))},restHalfChoiceEnabled:function(){return!!this.restCanOfferHalfDay&&this.restFullDays+.5<=this.restMaxAvailableDays+1e-9},restAddHalfDayRequired:function(){return this.isRestScene&&this.restMaxAvailableDays>0&&0===this.restFullDays&&this.restHalfChoiceEnabled},needsHalfPeriod:function(){if(this.isPaidScene||this.isPersonalScene)return!1;var e=Number(this.dataForm.leaveDayCount||0);return!(!e||Math.round(2*e)!==2*e)&&Math.round(2*e)%2===1},leaveEndTimeDisplay:function(){var e=this.dataForm.leaveEndTime;if(""===e||null==e)return"";var a=this.parseTimeToMs(e);if(Number.isNaN(a)||!a)return"";var t=new Date(a);if(Number.isNaN(t.getTime()))return"";var r=t.getFullYear(),i="".concat(t.getMonth()+1).padStart(2,"0"),s="".concat(t.getDate()).padStart(2,"0"),n="".concat(t.getHours()).padStart(2,"0"),l="".concat(t.getMinutes()).padStart(2,"0");return"".concat(r,"-").concat(i,"-").concat(s," ").concat(n,":").concat(l)}}),created:function(){this.flowBoxMode||this.initializePage()},watch:{"$route.query":{deep:!0,handler:function(){this.flowBoxMode||this.initializePage()}},"dataForm.leaveType":function(e){var a=this;this._suppressLeaveTypeSideEffects||("丧假"!==e||[1,2].includes(Number(this.dataForm.funeralRelationType))||(this.dataForm.funeralRelationType=1),"丧假"!==e&&(this.dataForm.funeralRelationType=1),(this.isPaidScene||this.isPersonalScene)&&(this.dataForm.leaveDayCount="",this.$nextTick((function(){return a.recomputeLeaveRangeFromNaturalDay()}))),this.refreshFlowTitle())},"dataForm.funeralRelationType":function(){var e=this;this._suppressLeaveTypeSideEffects||this.isPaidScene&&"丧假"===this.dataForm.leaveType&&(this.dataForm.leaveDayCount="",this.$nextTick((function(){return e.recomputeLeaveRangeFromNaturalDay()})))},restCanOfferHalfDay:function(e){!e&&this.isRestScene&&(this.restAddHalfDay=!1,this.syncRestLeaveDayToForm())}},methods:{init:function(e){var a=this;this.flowBoxMode=!0,this.setting=e||{},this.leaveStartDateTs="",this.dayHalfPeriod="am",this.restFullDays=0,this.restAddHalfDay=!1,this.dataForm=D(),this.dataForm.id=e.id||"",this.dataForm.flowId=e.flowId||"",this.dataForm.leaveType=this.currentSceneConfig.defaultLeaveType,this.$nextTick((function(){a.$refs.dataForm&&!e.id&&a.$refs.dataForm.resetFields(),a.fileList=[],a.quotaSummary=null,a.fillApplicantInfo();var t=function(){a.loadQuotaSummary().then((function(){a.isPaidScene?(a.clampPaidLeaveTypeIfNeeded(),a.refreshFlowTitle(),a.clampPaidLeaveDayForScene()):a.isRestScene?a.applyRestUiFromLeaveDayCount():a.isPersonalScene&&a.clampPersonalLeaveDayForScene(),a.recomputeLeaveRangeFromNaturalDay(),a.$emit("setPageLoad")}))};e.id?Object(d["e"])("leaveApply",e.id).then((function(r){if(a._suppressLeaveTypeSideEffects=!0,a.dataForm=Object.assign(D(),r.data||{}),a.normalizeLeaveApplyFieldsFromApi(),!a.dataForm.flowId&&e.flowId&&(a.dataForm.flowId=e.flowId),a.dataForm.fileJson)try{a.fileList=JSON.parse(a.dataForm.fileJson)}catch(i){a.fileList=[]}a.syncLeaveStartDateFromStoredTimes(),a.$nextTick((function(){a._suppressLeaveTypeSideEffects=!1})),t()})).catch((function(){t()})):Object(m["a"])("WF_LeaveApplyNo").then((function(e){a.dataForm.billNo=e&&e.data||"",t()})).catch((function(){t()}))}))},dataFormSubmit:function(e){var a=this;this.$refs.dataForm.validate((function(t){if(t){var r=a.flowBoxMode&&("audit"===e||"reject"===e);if(!r){var i=a.validateBusinessRule();if(i)return void a.$message.error(i)}var s=Object.assign({},a.dataForm,{flowUrgent:Number(a.dataForm.flowUrgent||1),funeralRelationType:"丧假"===a.dataForm.leaveType?Number(a.dataForm.funeralRelationType||0):null,leaveReason:(a.dataForm.leaveReason||"").trim(),fileJson:a.fileList&&a.fileList.length?JSON.stringify(a.fileList):""});a.$emit("eventReciver",s,e)}}))},initializePage:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var a,t,r,i,s,n;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(a=this.$route.query||{},t=a.id,r=void 0===t?"":t,i=a.flowId,s=void 0===i?"":i,n="".concat(this.scene,"_").concat(r,"_").concat(s),this._pageInitKey!==n){e.next=4;break}return e.abrupt("return");case 4:return this._pageInitKey=n,this.loading=!0,this.fileList=[],this.quotaSummary=null,this.leaveStartDateTs="",this.dayHalfPeriod="am",this.restFullDays=0,this.restAddHalfDay=!1,this.dataForm=D(),this.dataForm.flowId=s||"",this.dataForm.leaveType=this.currentSceneConfig.defaultLeaveType,this.fillApplicantInfo(),e.prev=16,e.next=19,this.loadQuotaSummary();case 19:if(!r){e.next=24;break}return e.next=22,this.loadInfo(r);case 22:e.next=26;break;case 24:return e.next=26,this.loadBillNo();case 26:return e.prev=26,this.loading=!1,this.isRestScene?this.applyRestUiFromLeaveDayCount():this.isPersonalScene?this.clampPersonalLeaveDayForScene():this.isPaidScene&&(this.clampPaidLeaveTypeIfNeeded(),this.refreshFlowTitle(),this.clampPaidLeaveDayForScene()),this.recomputeLeaveRangeFromNaturalDay(),e.finish(26);case 31:case"end":return e.stop()}}),e,this,[[16,,26,31]])})));function a(){return e.apply(this,arguments)}return a}(),fillApplicantInfo:function(){var e=this.userInfo.userName||this.userInfo.realName||"当前用户",a=this.userInfo.userAccount||"";this.applicantName=e,this.dataForm.applyUser=a?"".concat(e,"/").concat(a):e,this.dataForm.applyDate=(new Date).getTime(),this.dataForm.applyDept=this.userInfo.organizeName||"",this.dataForm.applyPost=this.getPositionText(),this.refreshFlowTitle()},getPositionText:function(){var e=this.userInfo.positionIds;return Array.isArray(e)&&e.length?e.map((function(e){return e&&e.name})).filter(Boolean).join("、"):this.userInfo.positionName||""},refreshFlowTitle:function(){if(this.applicantName&&!this.dataForm.id){var e=this.dataForm.leaveType||this.currentSceneConfig.title;this.dataForm.flowTitle="".concat(this.applicantName,"的").concat(e,"申请"),this.isPaidScene&&(this.dataForm.leaveReason="".concat(e,"申请"))}},loadBillNo:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var a;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Object(m["a"])("WF_LeaveApplyNo");case 2:a=e.sent,this.dataForm.billNo=a&&a.data||"";case 4:case"end":return e.stop()}}),e,this)})));function a(){return e.apply(this,arguments)}return a}(),loadInfo:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(a){var t,r=this;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return this._suppressLeaveTypeSideEffects=!0,e.prev=1,e.next=4,Object(d["e"])("leaveApply",a);case 4:if(t=e.sent,this.dataForm=Object.assign(D(),t.data||{}),this.normalizeLeaveApplyFieldsFromApi(),!this.dataForm.flowId&&this.$route.query.flowId&&(this.dataForm.flowId=this.$route.query.flowId),this.dataForm.fileJson)try{this.fileList=JSON.parse(this.dataForm.fileJson)}catch(i){this.fileList=[]}this.syncLeaveStartDateFromStoredTimes(),this.isPaidScene?(this.clampPaidLeaveTypeIfNeeded(),this.clampPaidLeaveDayForScene()):this.isPersonalScene&&this.clampPersonalLeaveDayForScene();case 11:return e.prev=11,this.$nextTick((function(){r._suppressLeaveTypeSideEffects=!1})),e.finish(11);case 14:case"end":return e.stop()}}),e,this,[[1,,11,14]])})));function a(a){return e.apply(this,arguments)}return a}(),loadQuotaSummary:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(){var a;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return this.quotaLoading=!0,e.prev=1,e.next=4,Object(d["f"])();case 4:a=e.sent,this.quotaSummary=v(a)||{};case 6:return e.prev=6,this.quotaLoading=!1,e.finish(6);case 9:case"end":return e.stop()}}),e,this,[[1,,6,9]])})));function a(){return e.apply(this,arguments)}return a}(),handleLeaveTypeChange:function(e){var a=this;this.dataForm.leaveType=e,this.$nextTick((function(){a.$refs.dataForm&&a.$refs.dataForm.clearValidate("funeralRelationType")}))},tsToYmd:function(e){if(""===e||null==e)return"";var a=new Date(Number(e));if(Number.isNaN(a.getTime()))return"";var t=a.getFullYear(),r="".concat(a.getMonth()+1).padStart(2,"0"),i="".concat(a.getDate()).padStart(2,"0");return"".concat(t,"-").concat(r,"-").concat(i)},parseLocalYmdHmsToTs:function(e){if(!e)return"";var a=new Date(String(e).replace(/-/g,"/"));return Number.isNaN(a.getTime())?"":a.getTime()},parseTimeToMs:function(e){if(""===e||null==e)return NaN;if("number"===typeof e)return Number.isNaN(e)?NaN:e;var a=Number(e);if(!Number.isNaN(a)&&a>1e12)return a;var t=new Date(e);return Number.isNaN(t.getTime())?NaN:t.getTime()},normalizeLeaveApplyFieldsFromApi:function(){if(null!=this.dataForm.applyDate&&""!==this.dataForm.applyDate){var e=this.parseTimeToMs(this.dataForm.applyDate);Number.isNaN(e)||(this.dataForm.applyDate=e)}if(null!=this.dataForm.leaveStartTime&&""!==this.dataForm.leaveStartTime){var a=this.parseTimeToMs(this.dataForm.leaveStartTime);Number.isNaN(a)||(this.dataForm.leaveStartTime=a)}if(null!=this.dataForm.leaveEndTime&&""!==this.dataForm.leaveEndTime){var t=this.parseTimeToMs(this.dataForm.leaveEndTime);Number.isNaN(t)||(this.dataForm.leaveEndTime=t)}null!=this.dataForm.leaveDayCount&&""!==this.dataForm.leaveDayCount&&(this.dataForm.leaveDayCount=String(this.dataForm.leaveDayCount)),null!=this.dataForm.leaveHour&&""!==this.dataForm.leaveHour&&(this.dataForm.leaveHour=String(this.dataForm.leaveHour))},syncLeaveStartDateFromStoredTimes:function(){if(this.dataForm.leaveStartTime){var e=this.parseTimeToMs(this.dataForm.leaveStartTime);if(e&&!Number.isNaN(e)){var a=new Date(e),t=new Date(a.getFullYear(),a.getMonth(),a.getDate());this.leaveStartDateTs=t.getTime(),this.dayHalfPeriod=this.isPaidScene?"am":a.getHours()>=12?"pm":"am"}else this.leaveStartDateTs=""}else this.leaveStartDateTs=""},clampPaidLeaveTypeIfNeeded:function(){if(this.isPaidScene){var e=this.leaveTypeOptions;if(e&&e.length){var a=String(this.dataForm.leaveType||"").trim(),t=e.some((function(e){return String(e.value)===a}));t||(this.dataForm.leaveType=e[0].value)}}},clampPaidLeaveDayForScene:function(){if(this.isPaidScene){var e=this.paidLeaveMaxInteger;if(e<=0){if(this.flowBoxMode||this.setting.readonly)return;this.dataForm.leaveDayCount=""}else{var a=Number(this.dataForm.leaveDayCount||0);if(a){var t=Math.floor(a);t<1&&(t=1),t>e&&(t=e),(Math.floor(a)!==a||a>e||a<1)&&(this.dataForm.leaveDayCount=String(t))}}}},clampPersonalLeaveDayForScene:function(){if(this.isPersonalScene){var e=Number(this.dataForm.leaveDayCount||0);if(e){var a=Math.floor(e);a<1&&(a=1),a>10&&(a=10),(Math.floor(e)!==e||e>10||e<1)&&(this.dataForm.leaveDayCount=String(a))}}},recomputeLeaveRangeFromNaturalDay:function(){var e=this,a=Number(this.dataForm.leaveDayCount||0),t=!a||a<=0||(this.isPaidScene?Math.floor(a)!==a:this.isPersonalScene?Math.floor(a)!==a||a<1||a>10:Math.round(2*a)!==2*a);if(!this.leaveStartDateTs||t){if(this.flowBoxMode&&this.dataForm.id){var r=this.parseTimeToMs(this.dataForm.leaveStartTime),i=this.parseTimeToMs(this.dataForm.leaveEndTime);if(!Number.isNaN(r)&&!Number.isNaN(i)&&r>0&&i>0)return}return this.dataForm.leaveStartTime="",this.dataForm.leaveEndTime="",void(this.dataForm.leaveHour="")}var s=this.tsToYmd(this.leaveStartDateTs);if(!s)return this.dataForm.leaveStartTime="",this.dataForm.leaveEndTime="",void(this.dataForm.leaveHour="");var n=f(s,a,this.dayHalfPeriod),l=n.leaveStartTime,o=n.leaveEndTime,u=n.leaveHour;this.dataForm.leaveStartTime=this.parseLocalYmdHmsToTs(l),this.dataForm.leaveEndTime=this.parseLocalYmdHmsToTs(o),this.dataForm.leaveHour=u,this.$nextTick((function(){e.$refs.dataForm&&e.$refs.dataForm.validateField("leaveStartTime")}))},formatNumber:function(e){var a=Number(e||0);return Number.isInteger(a)?String(a):a.toFixed(1)},fillMaxDays:function(){var e=this;if(this.isRestScene)this.fillMaxRestDays();else{var a=Number(this.selectedLeaveMaxDays||0);a<=0||(this.dataForm.leaveDayCount=this.formatNumber(a),this.$nextTick((function(){return e.recomputeLeaveRangeFromNaturalDay()})))}},fillMaxRestDays:function(){var e=this.restMaxAvailableDays,a=this.restRemainingHalfSplit,t=this.restFullDaySelectOptions;if(t.length){var r=Math.floor(e),i=t.indexOf(r)>=0?r:t[t.length-1];this.restFullDays=i,this.restAddHalfDay=a>=.5&&i+.5<=e+1e-9,this.restHalfChoiceEnabled||(this.restAddHalfDay=!1),this.syncRestLeaveDayToForm()}},syncRestLeaveDayToForm:function(){var e=this;if(this.isRestScene){this.restFullDays>this.restFullDayMax&&(this.restFullDays=this.restFullDayMax),this.restCanOfferHalfDay||(this.restAddHalfDay=!1),this.restAddHalfDay&&!this.restHalfChoiceEnabled&&(this.restAddHalfDay=!1);var a=this.restFullDays,t=a+(this.restAddHalfDay?.5:0);if(t<=0)return this.dataForm.leaveDayCount="",void this.recomputeLeaveRangeFromNaturalDay();if(t>this.restMaxAvailableDays+1e-9)return this.dataForm.leaveDayCount="",void this.recomputeLeaveRangeFromNaturalDay();var r=t-Math.floor(t);if(r>this.restRemainingHalfSplit+1e-9)return this.dataForm.leaveDayCount="",void this.recomputeLeaveRangeFromNaturalDay();this.dataForm.leaveDayCount=String(t%1===0?t:t.toFixed(1)),this.recomputeLeaveRangeFromNaturalDay(),this.$nextTick((function(){e.$refs.dataForm&&(e.$refs.dataForm.validateField("leaveDayCount"),e.$refs.dataForm.validateField("leaveStartTime"))}))}},applyRestUiFromLeaveDayCount:function(){if(this.isRestScene){var e=Number(this.dataForm.leaveDayCount||0);if(!e||e<=0)return this.restFullDays=0,this.restAddHalfDay=!1,void this.syncRestLeaveDayToForm();var a=this.restFullDayMax,t=Math.min(Math.floor(e),a),r=e-Math.floor(e)>=.5;this.restFullDays=t,this.restCanOfferHalfDay||(r=!1),r&&t+.5>this.restMaxAvailableDays+1e-9&&(r=!1),this.restAddHalfDay=r,this.syncRestLeaveDayToForm()}},getRequestDays:function(){return Number(this.dataForm.leaveDayCount||0)},getHalfDaySplitDays:function(e){var a=Number(e||0);return a-Math.floor(a)},validateRestScene:function(e){if(!this.restFullDaySelectOptions.length)return"当前暂无可选应休天数";if(this.restAddHalfDayRequired&&!this.restAddHalfDay)return"请选择「再加半天」或改选大于 0 的整数天";var a=this.restQuota;if(!a.attendanceGroupBound)return"当前用户未绑定考勤分组,无法提交休假申请";var t=a.restUnlockCycle>0?Number(a.availableRestDays||0):Number(a.remainingRestDays||0);if(e>t)return"当前可申请 ".concat(this.formatNumber(t)," 天");var r=this.getHalfDaySplitDays(e),i=Number(a.remainingHalfDaySplitDays||0);return r>i?"本月可拆分半天额度剩余 ".concat(this.formatNumber(i)," 天"):""},validatePaidScene:function(e){var a=this;if(Math.floor(e)!==e)return"带薪休假仅可选择整天";if("婚假"===this.dataForm.leaveType){var t=Math.floor(Number((this.paidQuota.marriage||{}).maxDays||0));return t<=0?"当前未匹配到婚假规则,暂不能提交婚假申请":e>t?"婚假最多可请 ".concat(this.formatNumber(t)," 天"):""}if("丧假"===this.dataForm.leaveType){var r=this.paidQuota.funeral||{},i=Math.floor(Number(1===Number(this.dataForm.funeralRelationType)?r.directRelativeDays||0:r.indirectRelativeDays||0));return i<=0?"当前未匹配到丧假规则,暂不能提交丧假申请":e>i?"当前选择的丧假最多可请 ".concat(this.formatNumber(i)," 天"):""}if("年假"===this.dataForm.leaveType){var s=Math.floor(Number((this.paidQuota.annual||{}).remainingDays||0));return s<=0?"当前年假剩余天数为 0,暂不能提交年假申请":e>s?"当前年假剩余 ".concat(this.formatNumber(s)," 天"):""}if("产假"===this.dataForm.leaveType){var n=Math.floor(Number((this.paidQuota.maternity||{}).maxDays||0));return n<=0?"当前未匹配到产假规则,暂不能提交产假申请":e>n?"产假最多可请 ".concat(this.formatNumber(n)," 天"):""}var l=this.extraLeaveList.find((function(e){return String(e.leaveName||"").trim()===String(a.dataForm.leaveType||"").trim()}));if(l){var o=Math.floor(Number(l.extraDays||0));return o<=0?"当前额外假期【".concat(l.leaveName,"】可用天数为 0"):e>o?"额外假期【".concat(l.leaveName,"】最多可请 ").concat(this.formatNumber(o)," 天"):""}return"请选择有效的带薪假类型"},validateBusinessRule:function(){if(this.isPaidScene&&!this.dataForm.id){var e=this.dataForm.leaveType||this.currentSceneConfig.title;String(this.dataForm.leaveReason||"").trim()||(this.dataForm.leaveReason="".concat(e,"申请"))}if(!this.dataForm.flowId)return"缺少流程ID,无法提交,请从流程入口进入页面";var a=this.getRequestDays();if(!a||a<=0)return"请假天数必须大于 0";if(this.isPaidScene){if(Math.floor(a)!==a)return"带薪休假仅可选择整天"}else if(this.isPersonalScene){if(Math.floor(a)!==a)return"事假、病假须选择整数天";if(a<1||a>10)return"事假、病假可选择 1~10 天"}else if(Math.round(2*a)!==2*a)return"请假天数必须是整数或 0.5 的倍数";return this.isRestScene?this.validateRestScene(a):this.isPaidScene?this.validatePaidScene(a):""},handleSubmit:function(e){var a=this;this.submitType=e,this.$refs.dataForm.validate((function(t){if(t){var r=a.validateBusinessRule();r?a.$message.error(r):"submit"!==e?a.handleRequest(e):a.$confirm("确认提交当前申请吗?","提示",{type:"warning"}).then((function(){return a.handleRequest(e)})).catch((function(){}))}}))},handleRequest:function(){var e=Object(s["a"])(regeneratorRuntime.mark((function e(a){var t,r,i;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return this.submitLoading=!0,e.prev=1,t=Object.assign({},this.dataForm,{flowUrgent:Number(this.dataForm.flowUrgent||1),funeralRelationType:"丧假"===this.dataForm.leaveType?Number(this.dataForm.funeralRelationType||0):null,leaveReason:(this.dataForm.leaveReason||"").trim(),fileJson:this.fileList&&this.fileList.length?JSON.stringify(this.fileList):"",status:"submit"===a?0:1}),t.id||delete t.id,r=t.id?d["g"]:d["a"],e.next=7,r("leaveApply",t);case 7:i=e.sent,this.$message.success(i&&i.msg||("submit"===a?"提交成功":"保存成功")),this.goAfterSuccess();case 10:return e.prev=10,this.submitLoading=!1,e.finish(10);case 13:case"end":return e.stop()}}),e,this,[[1,,10,13]])})));function a(a){return e.apply(this,arguments)}return a}(),goAfterSuccess:function(){this.$router.push({path:"/workFlow/flowLaunch"})},handleBack:function(){window.history.length>1?this.$router.back():this.$router.push({path:"/workFlow/flowLaunch"})}}},F=b,g=(t("5417"),t("2877")),T=Object(g["a"])(F,r,i,!1,null,"7fbb3f2b",null);a["default"]=T.exports}}]);