/**
* 初始化硕博人才生活补贴申报详情对话框
*/
var LivingAllowanceInfoInfoDlg = {
livingAllowanceInfoInfoData: {},
validateFields: {
enterpriseId: {validators: {notEmpty: {message: '所属企业不能为空'}}},
enterpriseName: {validators: {notEmpty: {message: '所属企业不能为空'}}},
type: {validators: {notEmpty: {message: '人才类别不能为空'}}},
talentType: {validators: {notEmpty: {message: '人才标签不能为空'}}},
name: {validators: {notEmpty: {message: '姓名不能为空'}}},
nation: {validators: {notEmpty: {message: '民族不能为空'}}},
provinceCode: {validators: {notEmpty: {message: '户籍省份不能为空'}}},
cityCode: {validators: {notEmpty: {message: '户籍市不能为空'}}},
address: {validators: {notEmpty: {message: '现居地址不能为空'}}},
highEducation: {validators: {notEmpty: {message: '最高学历不能为空'}}},
graduateSchool: {validators: {notEmpty: {message: '毕业院校不能为空'}}},
major: {validators: {notEmpty: {message: '专业不能为空'}}},
phone: {
validators: {
notEmpty: {
message: '手机号码不能为空'
},
regexp: {
regexp: /0?(13|14|15|17|18|19)[0-9]{9}/,
message: "手机号码格式不正确"
}
}
},
bank: {
validators: {
notEmpty: {
message: '开户银行不能为空'
},
regexp: {
regexp: /^[\u4e00-\u9fa5]*银行$/,
message: "开户银行格式不正确"
}
}
},
bankAccount: {
validators: {
notEmpty: {
message: '银行账号不能为空'
},
regexp: {
regexp: /^\d+$/,
message: "银行账号格式不正确"
}
}
},
entryTime: {validators: {notEmpty: {message: '入职时间不能为空'}}},
endTime: {validators: {notEmpty: {message: '工作合同结束时间不能为空'}}},
type: {validators: {notEmpty: {message: '人才类别不能为空'}}},
cardType: {validators: {notEmpty: {message: '证件类型不能为空'}}},
idCard: {validators: {notEmpty: {message: '证件号码不能为空'}}},
sex: {validators: {notEmpty: {message: '性别不能为空'}}},
nationality: {validators: {notEmpty: {message: '国籍/地区不能为空'}}},
birthday: {validators: {notEmpty: {message: '出生日期不能为空'}}},
politics: {validators: {notEmpty: {message: '政治面貌不能为空'}}},
post: {validators: {notEmpty: {message: '职务不能为空'}}},
email: {
validators: {
notEmpty: {
message: '电子邮箱不能为空'
},
emailAddress: {
message: "电子邮箱格式不正确"
}
}
},
bankNetwork: {
validators: {
notEmpty: {
message: '开户银行网点不能为空'
},
regexp: {
regexp: /^[\u4e00-\u9fa5]*银行[\u4e00-\u9fa5]*省?[\u4e00-\u9fa5]+市[\u4e00-\u9fa5]*$/,
message: "开户银行格式不正确"
}
}
},
bankNumber: {
validators: {
notEmpty: {
message: '银行行号不能为空'
},
regexp: {
regexp: /^\d+$/,
message: "银行行号格式不正确"
}
}
},
introductionMode: {
validators: {
notEmpty: {
message: '引进方式不能为空'
}
}
},
startTime: {validators: {notEmpty: {message: '工作合同开始时间不能为空'}}},
mainHonours: {validators: {notEmpty: {message: '主要业绩及取得的荣誉不能为空'}}},
educationAndResume: {validators: {notEmpty: {message: '教育背景及工作简历不能为空'}}},
firstInJJTime: {validators: {notEmpty: {message: '首次来晋工作时间不能为空'}}},
industryField: {validators: {notEmpty: {message: '行业领域不能为空'}}}
},
tax: null,
socialSecurity: null
};
/**
* 清除数据
*/
LivingAllowanceInfoInfoDlg.clearData = function () {
this.livingAllowanceInfoInfoData = {};
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
LivingAllowanceInfoInfoDlg.set = function (key, val) {
this.livingAllowanceInfoInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
return this;
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
LivingAllowanceInfoInfoDlg.get = function (key) {
return $("#" + key).val();
}
/**
* 关闭此对话框
*/
LivingAllowanceInfoInfoDlg.close = function () {
parent.layer.close(window.parent.LivingAllowanceInfo.layerIndex);
}
/**
* 收集数据
*/
LivingAllowanceInfoInfoDlg.collectData = function () {
this
.set('id')
.set('year')
.set('enterpriseId')
.set('enterpriseName')
.set('type')
.set('talentType')
.set('cardType')
.set('idCard')
.set('name')
.set('photo')
.set('sex')
.set('nation')
.set('nationality')
.set('provinceCode')
.set('cityCode')
.set('countyCode')
.set('birthday')
.set('address')
.set('politics')
.set('highEducation')
.set('graduateSchool')
.set('major')
.set('post')
.set('phone')
.set('email')
.set('bank')
.set('bankNetwork')
.set('bankAccount')
.set('bankNumber')
.set('entryTime')
// .set('quitTime')
.set('startTime')
.set('endTime')
.set('educationAndResume')
.set('mainHonours')
.set('firstInJJTime')
// .set('isIntroduction')
.set('industryField')
.set('title')
.set('professionalQualifications')
.set('studyAbroad')
// .set('studyAbroadCountry')
.set('studyAbroadTime')
.set('introductionMode')
.set('letterTime')
// .set('applyCount')
;
if ($("#provinceCode").val() != null && $("#provinceCode").val() != '') {
this.livingAllowanceInfoInfoData["provinceName"] = $("#provinceCode").find("option:selected").text();
}
if ($("#cityCode").val() != null && $("#cityCode").val() != '') {
this.livingAllowanceInfoInfoData["cityName"] = $("#cityCode").find("option:selected").text();
}
if ($("#countyCode").val() != null && $("#countyCode").val() != '') {
this.livingAllowanceInfoInfoData["countyName"] = $("#countyCode").find("option:selected").text();
}
var personalTaxVal = LivingAllowanceInfoInfoDlg.tax.getValue();
var socialSecurityVal = LivingAllowanceInfoInfoDlg.socialSecurity.getValue();
// if(personalTaxVal == null || personalTaxVal.length <= 0){
// Feng.info("")
// }
var personalTax = personalTaxVal.map(function (item) {
return item.value;
}).join(",");
var socialSecurity = socialSecurityVal.map(function (item) {
return item.value;
}).join(",");
LivingAllowanceInfoInfoDlg.livingAllowanceInfoInfoData["personalTax"] = personalTax;
LivingAllowanceInfoInfoDlg.livingAllowanceInfoInfoData["socialSecurity"] = socialSecurity;
}
/**
* 数据校验
* @returns {*|Window.jQuery}
*/
LivingAllowanceInfoInfoDlg.validate = function () {
$('#talentInfoForm').data("bootstrapValidator").resetForm();
$('#talentInfoForm').bootstrapValidator('validate');
return $("#talentInfoForm").data('bootstrapValidator').isValid();
}
/**
* 提交添加
*/
LivingAllowanceInfoInfoDlg.addSubmit = function () {
this.clearData();
this.collectData();
if (!LivingAllowanceInfoInfoDlg.validate()) {
return;
}
var formData = new FormData();
Object.keys(this.livingAllowanceInfoInfoData).forEach((key) => {
formData.append(key, this.livingAllowanceInfoInfoData[key]);
});
if (Feng.isEmptyStr(LivingAllowanceInfoInfoDlg.livingAllowanceInfoInfoData.id) && Feng.isEmptyStr($("#photo").val())) {
Feng.info("头像不能为空!");
return;
}
formData.append('file', $('#photo')[0].files[0]);
$.ajax({
url: Feng.ctxPath + "/api/livingAllowanceInfo/upsert",
type: "POST",
processData: false,
contentType: false,
data: formData,
success: function (data) {
LivingAllowanceInfoInfoDlg.setNoChangeField();
if (data.code == 200) {
Feng.success(data.msg);
window.parent.LivingAllowanceInfo.table.refresh();
$("#id").val(data.obj.id);
$("#fileLi").removeAttr("style");
$("#checkState").val(data.obj.checkState);
} else {
Feng.info(data.msg);
}
}, error: function (data) {
Feng.error("保存失败!" + data.responseJSON.message + "!");
}
});
}
/**
* 提交审核
*/
LivingAllowanceInfoInfoDlg.submitToCheck = function () {
var id = $("#id").val();
if (Feng.isEmptyStr(id)) {
Feng.info("请先填写基础信息并上传附件");
return;
}
if (!validateIsEdit()) return;
var operation = function () {
var ajax = new $ax(Feng.ctxPath + "/api/livingAllowanceInfo/submitToCheck", function (data) {
if (data.code == 200) {
Feng.success(data.msg);
// $("#checkState").val(data.obj);
window.parent.LivingAllowanceInfo.table.refresh();
LivingAllowanceInfoInfoDlg.close();
} else {
Feng.error(data.msg);
}
}, function (data) {
Feng.error("提交审核失败!" + data.responseJSON.message + "!");
});
ajax.set("id", id);
ajax.start();
}
Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
}
/**
* 设置不可修改的字段
*/
LivingAllowanceInfoInfoDlg.setNoChangeField = function () {
var checkState = $("#checkState").val();
var fields = $("#fields").val();
if (checkState == 10) {
$("input,textarea").each(function () {
$(this).attr("readonly", "readonly");
});
$("select").each(function () {
$(this).attr("disabled", "disabled");
});
if (fields != null && fields != '') {
var arr = fields.split(",");
for (var key in arr) {
var name = $("#" + arr[key]).prop("tagName");
if (name == 'select' || name == 'SELECT') {
$("#" + arr[key]).removeAttr("disabled");
}
if (name == "input" || name == 'textarea' || name == "INPUT" || name == 'TEXTAREA') {
$("#" + arr[key]).removeAttr("readonly");
}
}
}
}
}
/**
* 数据加载
* */
/**
* 加载市
*/
LivingAllowanceInfoInfoDlg.afterSelectProvince = function () {
var province = $("#provinceCode").val();
$("#cityCode").empty();
$("#countyCode").empty();
if (province == null || province == '') {
return;
}
Feng.addAjaxSelect({
"id": "cityCode",
"displayCode": "code",
"displayName": "name",
"type": "GET",
"url": Feng.ctxPath + "/api/commonLocation/findCityByProvinceSelect/" + province
});
}
/**
* 加载县
*/
LivingAllowanceInfoInfoDlg.afterSelectCity = function () {
var city = $("#cityCode").val();
$("#countyCode").empty();
if (city == null || city == '') {
return;
}
Feng.addAjaxSelect({
"id": "countyCode",
"displayCode": "code",
"displayName": "name",
"type": "GET",
"url": Feng.ctxPath + "/api/commonLocation/findCountyByCitySelect/" + city
});
}
//校验是否保存基础信息
LivingAllowanceInfoInfoDlg.validId = function () {
var id = $("#id").val();
if (id != null && id != '') {
$("#fileLi").removeAttr("style");
} else {
$("#fileLi").attr("style", "pointer-events: none");
}
}
LivingAllowanceInfoInfoDlg.initTaxAndSocialSecurity = function () {
var year = $("#year").val().substr(0, 4);
var data = new Array();
for (var i = 1; i <= 12; i++) {
var month = year + "-" + (i < 10 ? "0" + i : i);
data.push({name: month, value: month, selected: false, disabled: false});
}
LivingAllowanceInfoInfoDlg.tax = xmSelect.render({
el: '#personalTax',
data: data
})
LivingAllowanceInfoInfoDlg.socialSecurity = xmSelect.render({
el: '#socialSecurity',
data: data
})
}
function validUploadButton(type, row, fileId) {
var files = $("#files").val();
var checkState = $("#checkState").val();
if ((Feng.isEmptyStr(checkState) || checkState == 0 || (checkState == 2 && files.indexOf(row.id) != -1)) && $("#hand").val() != "select") {
return type == 1 ?
""
:
"" +
"";
} else {
return type == 1 ? "" : "";
}
}
/**
* 校验是否可以操作
*/
function validateIsEdit() {
var checkState = $("#checkState").val();
if (checkState != 0 && checkState != 2) {
Feng.error("您的申报正在审核中或已审核完成,无法操作");
return false;
}
return true;
}
$(function () {
Feng.initValidatorTip("talentInfoForm", LivingAllowanceInfoInfoDlg.validateFields);
var hand = $("#hand").val();
var id = $("#id").val();
var checkState = $("#checkState").val();
//批量加载字典表数据
var arr = [
{"name": "nation", "code": "un_nation"},
{"name": "nationality", "code": "un_nationality"},
{"name": "politics", "code": "un_political"},
{"name": "highEducation", "code": "un_master_education"},
{"name": "introductionMode", "code": "un_introduction_mode"},
{"name": "industryField", "code": "un_industryField"},
{"name": "address", "code": "un_street"}];
if (hand == "select") arr.push({"name": "talentType", "code": "un_jbt_talentType"});
if (hand == "update" && checkState != 0 && checkState != 2) arr.push({
"name": "talentType",
"code": "un_jbt_talentType"
});
Feng.findChildDictBatch(JSON.stringify(arr))
//加载省份
Feng.addAjaxSelect({
"id": "provinceCode",
"displayCode": "code",
"displayName": "name",
"type": "GET",
"url": Feng.ctxPath + "/api/commonLocation/getProvinceSelect"
});
if (hand == 'add' || (hand == 'update' && (checkState == 0 || checkState == 2))) {
//加载人才标签
Feng.addAjaxSelect({
"id": "talentType",
"displayCode": "code",
"displayName": "name",
"type": "GET",
"url": Feng.ctxPath + "/api/talentInfo/findTalentTypeByEnterprise"
});
}
LivingAllowanceInfoInfoDlg.setNoChangeField();
LivingAllowanceInfoInfoDlg.initTaxAndSocialSecurity();
//批量加载时间控件
$(".date").each(function () {
laydate.render({
elem: this
, type: 'date'
, trigger: 'click'
});
});
if (id != null && id != '') {
//select初始化
$("select").each(function () {
$(this).val($(this).attr("value")).trigger("change");
});
if (Feng.isNotEmptyStr($("#personalTax").attr("value"))) {
LivingAllowanceInfoInfoDlg.tax.setValue($("#personalTax").attr("value").split(","));
}
if (Feng.isNotEmptyStr($("#socialSecurity").attr("value"))) {
LivingAllowanceInfoInfoDlg.socialSecurity.setValue($("#socialSecurity").attr("value").split(","));
}
Feng.getCheckLog("logTable", {
"type": CONFIG.project_master_living_allowance,
"mainId": id,
"typeFileId": "",
"active": 1
})
}
$("#address").val($("#address").attr("value"));
$("#industryField").val($("#industryField").attr("value"));
$("#provinceCode").val($("#provinceCode").attr("value"));
LivingAllowanceInfoInfoDlg.afterSelectProvince();
$("#cityCode").val($("#cityCode").attr("value"));
LivingAllowanceInfoInfoDlg.afterSelectCity();
$("#countyCode").val($("#countyCode").attr("value"));
LivingAllowanceInfoInfoDlg.validId();
$("#photo").change(function (e) {
var tag = e.target;
var file = tag.files[0];
var imgSrc;
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
imgSrc = this.result;
$("#photoImg").attr("src", imgSrc);
};
});
});