123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- ////员工自助--多人请假单(编辑)
- var personType = "";
- shr.defineClass("shr.ats.AtsLeaveBillBatchEditForPerExt", shr.ats.AtsLeaveBillBatchEditForPer, {
- initalizeDOM: function () {
-
- var that = this;
- shr.ats.AtsLeaveBillBatchEditForPerExt.superClass.initalizeDOM.call(this);
- $("#dowFile").hide();
- shr.callHandler({
- handler : "com.kingdee.shr.ats.web.handler.AtsLeaveBillEditHandlerEx",
- action : 'customerCheckParam',
- async : false,
- type : "POST",
- param : { "policyId" : "","personId" : $("#personId").val() },
- success:function(data){
- personType = data.personType;
- }
- });
- var entries_cont = waf("#entries");
- $("#entries_cont").css("margin-left","0");
- entries_cont.jqGrid("option", {
- beforeSaveCell: function (rowid, cellname, value, iRow, iCol) { // F7触发
- if (cellname == "policy") {
- action = "save";
- }
- }
- , afterSaveCell: function (rowid, cellname, value, iRow, iCol) { // F7 触发
-
- if(value["adminOrgUnit.id"]){
- $("#entries").jqGrid('setCell',rowid,"adminOrgUnit.id",value["adminOrgUnit.id"]);
- }
- if(cellname == "realLeaveLength"){
- if( "GTIIT_SAS" == personType || "GTIIT_PSS" == personType || "GTIIT_GAS" == personType){
- var rowData = $("#entries").jqGrid("getRowData");
- var flag = false;
- for(var i = 0; i < rowData.length; i++){
- var leaveLength = rowData[i].realLeaveLength;
- if(leaveLength >= 7){
- flag = true;
- }
- }
- if(flag){
- that.getField("remark").shrTextarea('option', 'required', true);
- $("#remark").parent().parent().parent().parent().find(".field-label").text("Request for leave:During my applied leave,the emergency contact will be :");
- }else{
- $("#remark").parent().parent().parent().parent().find(".field-label").text("Request for leave:");
- that.getField("remark").shrTextarea('option', 'required', false);
- }
- }
- }
- _self.afterSaveCellTrigger(rowid, cellname, value, iRow, iCol);
- }
- , beforeEditCell: function (rowid, cellname, value, iRow, iCol) { // 切换成文本的时候触发
- if(cellname == "isElasticCalLen"){
- var $entries_isElasticCalLen="#entries tr[id='" + rowid + "'] td[aria-describedby='entries_isElasticCalLen'] input";
- $($entries_isElasticCalLen).unbind("change");
- $($entries_isElasticCalLen).change(function(){
- that.countLeaveLength(rowid);
- });
- }
- if (cellname == "policy") {
- lastRowRemark = $("#entries tr[id='" + rowid + "'] td[aria-describedby='entries_policy']").attr('title');
- idROW = rowid;
- policyKey = $("#entries").jqGrid('getCell', rowid, "policy");
- action = "EDIT";
- }
- if (cellname == "leaveLength") {
- var personId = $("#entries").jqGrid('getCell', rowid, "person").id;
- if (typeof personId === 'undefined') {
- return;
- }
- var hrOrgUnitId = $("#hrOrgUnit_el").val();
- if (hrOrgUnitId == null || hrOrgUnitId == "") {
- shr.showWarning({ message: jsBizMultLan.atsManager_atsLeaveBillBatchEdit_i18n_22 });
- return;
- }
- that.remoteCall({
- type: "post",
- method: "isLeaveLengthEdit",
- param: { personId: personId, hrOrgUnitId: hrOrgUnitId },
- async: false,
- success: function (res) {
- var info = res;
- if (info.errorString) {
- shr.showWarning({ message: info.errorString });
- } else {
- if (info.editable == 'true') {
- $("#" + rowid).find("td").eq(iCol).removeClass("disabled");
- } else {
- $("#entries").jqGrid('setCell', rowid, "leaveLength", "", "disabled");
- setTimeout(function () {
- $("#entries").jqGrid('restoreCell', iRow, iCol);
- }, 1);
- }
- }
- }
- });
- }
- }
- , afterEditCell: function (rowid, cellname, value, iRow, iCol) {
- if(cellname=="person"){
- var hrOrgUnitId=$("#hrOrgUnit_el").val();
- $("#"+rowid+"_person").shrPromptBox().attr("data-params",hrOrgUnitId);
- $("#"+rowid+"_person").shrPromptBox("option", {
- onchange: function (e, value) {
- var id = $(this).attr("id");
- var index = id.substring(0,id.indexOf("_person"));
- $("#entries").jqGrid('setCell', index, "person.number", value.current["person.number"]);
- }
- });
- }
- _self.saveEditCellValue(rowid, cellname, value, iRow, iCol);
- }
- , afterRestoreCell: function (rowid, value, iRow, iCol) {
- if (iCol == 3 && action != "save") { // 将说明 重新复制
- $("#entries tr[id='" + rowid + "'] td[aria-describedby='entries_policy']").attr('title', lastRowRemark);
- }
- }
- });
- },
-
- verify: function () {
- var that = this;
- //如果是查看页面提交工作流,不需要再次校验了
- if (that.getOperateState().toUpperCase() == 'ViEW') {
- return;
- }
- var obj = $("#entries").jqGrid("getRowData");
- if (obj.length == 0) {
- shr.showWarning({ message: jsBizMultLan.atsManager_atsLeaveBillBatchEdit_i18n_15 });
- return false;
- }
- if (!that.checkRowIsOver()) {
- return false;
- }
- if (!that.checkBilltime(obj)) {
- shr.showWarning({message: jsBizMultLan.atsManager_atsLeaveBillBatchEdit_i18n_NX_5});
- return false;
- }
- _rowMap = {} ;
- var errorString = "";
- var errorFlag = 0;
- jQuery(obj).each(function(n){
- errorString = that.checkEveryRowee(n + 1 , this);
- if(errorString){
- that.showErrors( n + 1 ,this.person.name + " " + errorString);
- errorFlag = 1 ;
- }
-
- });
- if(errorString && errorString != ""){
- shr.showWarning({message: errorString});
- return false;
- }
- jQuery(obj).each(function (n) {
- var rowid = $("#entries tr:eq(" + (n + 1) + ")").attr('id')
- errorString = that.checkIsNullEveryRow(this);
- if (errorString == "") {
- errorString = that.checkEveryRow(this);
- }
- if (errorString == "" || errorString == undefined) { // 检测请假时长是不是大于计算时长
- errorString = that.checkCalLength(this);
- }
- if (errorString == undefined || errorString == null || errorString == "") {
- } else {
-
- that.preShowError(rowid, this.person.name + " " + this.policy.name + " " + errorString);
- errorFlag = 1;
- }
- });
- //校验是否为同一个假期类型
- if( "GTIIT_SAS" == personType || "GTIIT_PSS" == personType || "GTIIT_GAS" == personType){
- for(var i = 0 ; i < obj.length ; i++){
- var realLeaveLength = obj[i].realLeaveLength;
- if(realLeaveLength >= 7 && (obj[i].reason == null || obj[i].reason == "")){
- shr.showWarning({message: "If the duration of leave is more than 7 days, the reason for leave cannot be empty !"});
- return false;
- }
- }
- }
- if (errorFlag == 0) {
- return true;
- } else {
- return false;
- }
- },
- countLeaveLength: function (rowid, action) {
- var that = this;
- if ($("#entries").jqGrid('getCell', rowid, "person") == undefined
- || $("#entries").jqGrid('getCell', rowid, "person") == null) {
- return;
- } else {
- personId = $("#entries").jqGrid('getCell', rowid, "person").id;
- }
- if ($("#entries").jqGrid('getCell', rowid, "policy") == undefined
- || $("#entries").jqGrid('getCell', rowid, "policy") == null) {
- return;
- } else {
- holidayTypeId = $("#entries").jqGrid('getCell', rowid, "policy").id;
- }
- var personId = $("#entries").jqGrid('getCell', rowid, "person").id;
- var beginTime = $("#entries").jqGrid('getCell', rowid, "beginTime");
- var endTime = $("#entries").jqGrid('getCell', rowid, "endTime");
- var hrOrgUnitId = $("#hrOrgUnit_el").val();
- var isElasticCalLen = $("#entries").jqGrid('getCell', rowid, "isElasticCalLen")=="1";
- if (!strDateTime(beginTime) || !strDateTime(endTime)) {
- return;
- }
- var holidayTypeId = $("#entries").jqGrid('getCell', rowid, "policy").id;
- if (personId == undefined || personId == null
- || holidayTypeId == undefined || holidayTypeId == null
- || beginTime == undefined || beginTime == null
- || endTime == undefined || endTime == null) {
- return;
- }
- that.remoteCall({
- type: "post",
- async: false,
- method: "getRealLeaveLengthInfo",
- param: { personId: personId,
- beginTime: beginTime,
- endTime: endTime,
- holidayTypeId: holidayTypeId,
- action: action,
- hrOrgUnitId: hrOrgUnitId,
- isElasticCalLen:isElasticCalLen},
- success: function (res) {
- info = res;
- if (info.errorString) {
- that.preShowError(rowid, info.errorString);
- // shr.showError({message: info.errorString});
- } else {
- var day = parseFloat(info.leaveBillDays + info.segRest);
- var leaveLengDay = parseFloat(info.leaveBillDays);
- if (action != "EDIT") { // 第一次进入的时候重现计算先请假时长
- $("#entries").jqGrid('setCell', rowid, "leaveLength", leaveLengDay);
- $("#entries").jqGrid('setCell', rowid, "realLeaveLength", leaveLengDay);
- }
- // 每次触发之前都会记住这个 计算的时长
- $("#entries").jqGrid('setCell', rowid, "caleaveLength", day);
- }
- }
- });
- if( "GTIIT_SAS" == personType || "GTIIT_PSS" == personType || "GTIIT_GAS" == personType){
- var rowData = $("#entries").jqGrid("getRowData");
- var flag = false;
- for(var i = 0; i < rowData.length; i++){
- var leaveLength = rowData[i].realLeaveLength;
- if(leaveLength >= 7){
- flag = true;
- }
- }
- if(flag){
- that.getField("remark").shrTextarea('option', 'required', true);
- $("#remark").parent().parent().parent().parent().find(".field-label").text("Request for leave:During my applied leave,the emergency contact will be :");
- }else{
- $("#remark").parent().parent().parent().parent().find(".field-label").text("Request for leave:");
- that.getField("remark").shrTextarea('option', 'required', false);
- }
-
- }
- },
-
- dowFileAction:function(){
- shr.callHandler({
- handler : "com.kingdee.customer.util.handler.ConfigurationHandler",
- action : 'getCustomerConfig',
- async : false,
- param : { "fnumber" : "1001" },
- success:function(data){
- if(data){
- // 创建一个虚拟的链接元素
- var downloadLink = document.createElement('a');
- downloadLink.download = data.name;
- downloadLink.href = data.ip+"/leaveTemplate/"+data.name;
- document.body.appendChild(downloadLink);
- downloadLink.click();
- document.body.removeChild(downloadLink);
- }else{
- shr.showInfo({message: "No teacher fake template is configured !"});
- }
- }
- });
- },
- });
|