/** * 初始化人才认定申报详情对话框 */ var locked = false; var IntegralInfoDlg = { integralInfoData: {}, validateFields: { name: {validators: {notEmpty: {message: '姓名不能为空'}}}, card_type: {validators: {notEmpty: {message: '证件类型不能为空'}}}, card_number: { validators: { notEmpty: {message: '证件号码不能为空'}, regexp: { regexp: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: "身份证号码格式不正确" } } }, phone: { validators: { notEmpty: { message: '手机号码不能为空' }, regexp: { regexp: /0?(13|14|15|17|18|19)[0-9]{9}/, message: "手机号码格式不正确" } } }, email: { validators: { notEmpty: { message: '电子邮箱不能为空' }, emailAddress: { message: "电子邮箱格式不正确" } } } } }; /** * 清除数据 */ IntegralInfoDlg.clearData = function () { this.integralInfoData = {}; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ IntegralInfoDlg.set = function (key, val) { var dis = $("#" + key).attr("disabled"); if (dis == "disabled") { $("#" + key).removeAttr("disabled"); } this.integralInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val; if (dis == "disabled") { $("#" + key).prop("disabled", true); } return this; } /** * 设置对话框中的数据 * * @param key 数据的名称 * @param val 数据的具体值 */ IntegralInfoDlg.get = function (key) { return $("#" + key).val(); } /** * 关闭此对话框 */ IntegralInfoDlg.close = function () { parent.layer.close(window.parent.TalentInfo.layerIndex); } /** * 收集数据 */ IntegralInfoDlg.collectData = function () { this .set('id') .set('type') .set('name') .set('card_type') .set('card_number') .set('phone') .set('email'); } /** * 验证数据 */ IntegralInfoDlg.validate = function () { $('#integralInfoForm').data("bootstrapValidator").resetForm(); $('#integralInfoForm').bootstrapValidator('validate'); return $("#integralInfoForm").data('bootstrapValidator').isValid(); } /** * 初始化表格的列 */ IntegralInfoDlg.initFileTypeColumn = function () { return [ {field: 'selectItem', checkbox: false, visible: false}, {title: '名称', field: 'name', visible: true, align: 'left', valign: 'middle', width: "82%", 'class': 'uitd_showTip', formatter: function (value, row, index) { let str = '
'; if (row.must == 1) { str = str + ' * ' + value; } if (row.must == 2) { str = str + '' + value; } str = str + '
' + row.description + '
' return str; } }, {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "8%", formatter: function (value, row, index) { if (value == null || value == '' || value == 'null') { return '无'; } return ""; } }, {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%", formatter: function (value, row, index) { return IntegralInfoDlg.validUploadButton(1, value, ''); } } ] }; IntegralInfoDlg.addItem = function () { var html = '' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + '
' + '
' + ' ' + ' ' + '
' + '
' + ' ' + ' ' + '
' + '
' + '
' + ' ' + ' ' + '
' + '
' + '
' + ' ' + ' ' + '
' + '
' + '
' + ' ' + ' ' + '
' + '
'; /* * ' ' + ' ' + '
' + ' ' + ' ' + * */ $("#toolbar").before(html); } IntegralInfoDlg.changeAndLoadFile = function () { var table = $(".fileTable"); var items = $("select[name='item_id[]']"); var item_id = []; for (var i = 0; i < items.length; i++) { let _id = items.eq(i).val(); if (_id) { item_id.push(_id); } } if (item_id.length == 0) { table.bootstrapTable("destroy"); return; } var ajax = new $ax("/common/api/findCommonFileType", function (data) { if (data == null || data.length == 0) { return; } table.bootstrapTable("destroy"); table.bootstrapTable({ columns: IntegralInfoDlg.initFileTypeColumn(), data: data.rows, showHeader: true, rowStyle: function (row, index) { return {classes: ""}; }, onPostBody: function (data) { for (var k in data) { var files = data[k].files; var html = ''; table.find("tr[data-index='" + k + "']").after('' + html + ''); } $("td.uitd_showTip").bind("mouseover", function () { var htm = $(this).html(); $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show'); }); }, }); }, function (data) { Feng.error("查询失败!" + data.responseJSON.message + "!"); }); var queryData = {}; queryData["mainId"] = $("#id").val(); queryData['project'] = CONFIG.project_integral_apply; queryData['type'] = $("#type").val(); queryData["itemId"] = item_id; queryData['checkState'] = $("#checkState").val(); ajax.set(queryData); ajax.start(); } IntegralInfoDlg.deleteItem = function () { var len = $("input[name='chk[]']:checked").length; if (len == 0) { Feng.info("请选择要移除的项目"); } for (var i = 0; i < len; i++) { $("input[name='chk[]']:checked").eq(0).parents("table").remove(); } IntegralInfoDlg.changeAndLoadFile(); } IntegralInfoDlg.onProjectTypeChange = function (obj) { var projectType = $(obj).val(); var projectObj = $(obj).parents("table").find("select[name='projectId[]']") Feng.addAjaxSelect({ "obj": projectObj, "displayCode": "id", "displayName": "name", "type": "GET", "url": "/common/api/getIntegralProjectsByType/projectType/" + projectType }); } IntegralInfoDlg.onProjectChange = function (obj) { var projectId = $(obj).val(); var itemObj = $(obj).parents("table").find("select[name='item_id[]']") Feng.addAjaxSelect({ "obj": itemObj, "displayCode": "id", "displayName": "name", "bindData": "unit", "type": "GET", "url": "/common/api/getIntegralItemsByProject/projectId/" + projectId }); } IntegralInfoDlg.onItemChange = function (obj) { var unit = $(obj).find("option:selected").data("unit"); var parent = $(obj).parents("table"); if (typeof unit != "undefined" && unit) { parent.find(".unit").html("(" + unit + ")"); } else { parent.find(".unit").html(""); } IntegralInfoDlg.changeAndLoadFile(); } /** * 提交添加 */ IntegralInfoDlg.addSubmit = function () { this.clearData(); this.collectData(); if (!IntegralInfoDlg.validate()) { return; } var id = $('#id').val(); if (id != null && id != '') { if (!IntegralInfoDlg.validateIsEdit()) return; } $("select").each(function () { $(this).removeAttr("disabled"); }); if (locked) { //return; } locked = true; $("#integralInfoForm").attr("action", "/enterprise/integral/apply"); $("#integralInfoForm")[0].submit(); } //回调 IntegralInfoDlg.infoCallback = function (data) { console.log(data) locked = false; IntegralInfoDlg.setNoChangeField(); Feng.info(data.msg); if (data.code == 200) { window.parent.Integral.table.refresh(); $("#id").val(data.obj.id); $("#fileLi").removeAttr("style"); $("#checkState").val(data.obj.checkState); } return; } //校验是否保存基础信息 IntegralInfoDlg.validId = function () { var id = $("#id").val(); if (id != null && id != '') { $("#fileLi").removeAttr("style"); } else { $("#fileLi").attr("style", "pointer-events: none"); } } var currentTable = null; var currentTr = null; //选择附件并显示附件名 IntegralInfoDlg.checkFile = function (content, fileTypeId, fileId) { currentTable = $(content).parents(".fileTable"); currentTr = $(content).parents("tr").data("index"); if (!IntegralInfoDlg.validateIsEdit()) return; $("#upload_file").unbind("change"); $("#upload_file").change(function () { if (!Feng.chkFileInvalid(this.files[0], 5, 10)) return; IntegralInfoDlg.upload(fileTypeId, fileId); }); $('#upload_file').val(""); $('#upload_file').click(); } //上传附件 IntegralInfoDlg.upload = function (fileTypeId, fileId) { var id = $("#id").val(); if (!IntegralInfoDlg.validateIsEdit()) return; if (fileId != null && fileId != 'null') { $("#fileId").val(fileId) } else { $("#fileId").val(""); } $("#mainId").val(id); $("#fileTypeId").val(fileTypeId); var index = layer.load(0, {shade: false, time: 0}); $("#index").val(index); $("#uploadForm").submit(); } //删除附件 IntegralInfoDlg.deleteFile = function (id, state) { if (!IntegralInfoDlg.validateIsEdit()) return; var operation = function () { var ajax = new $ax(Feng.ctxPath + "/common/api/deleteFile", function (data) { if (data.code = 200) { Feng.success(data.msg); $("input[name='uploadFiles[]'][value='" + id + "']").parents("li").remove(); //$("#fileTable").bootstrapTable("refresh", {}); } else { Feng.error(data.msg); } }, function (data) { Feng.error("删除失败!" + data.responseJSON.message + "!"); }); ajax.set("id", id); ajax.set("type", 1); ajax.start(); } Feng.confirm("删除后无法恢复,确认删除吗?", operation); } /** * 提交审核 */ IntegralInfoDlg.submitToCheck = function () { /*if (!IntegralInfoDlg.validate()) { return; }*/ var id = $("#id").val(); /*if (id == null || id == "") { Feng.info("请先填写基础信息并上传附件"); return; }*/ if (!IntegralInfoDlg.validateIsEdit()) return; var operation = function () { IntegralInfoDlg.clearData(); IntegralInfoDlg.collectData(); /*if (!IntegralInfoDlg.validate()) { return; }*/ var id = $('#id').val(); if (id != null && id != '') { if (!IntegralInfoDlg.validateIsEdit()) return; } $("select").each(function () { $(this).removeAttr("disabled"); }); if (locked) { return; } locked = true; $("#integralInfoForm").attr("action", "/enterprise/integral/submitToCheck"); $("#integralInfoForm")[0].submit(); } Feng.confirm("请确认积分申报内容已核对无误,相应附件已上传,一旦提交,无法修改", operation); } //回调 IntegralInfoDlg.submitCallback = function (data) { locked = false; IntegralInfoDlg.setNoChangeField(); if (data.code == 200) { Feng.success(data.msg); // $("#checkState").val(data.obj); window.parent.TalentInfo.table.refresh(); IntegralInfoDlg.close(); } else { Feng.error(data.msg); } } /** * 校验是否可以修改/提交审核 */ IntegralInfoDlg.validateIsEdit = function () { var checkState = $("#checkState").val(); if (checkState != 0 && checkState != 1) { if (checkState == 5 || checkState == 8) { Feng.error("您的申报审核不通过,无法再修改"); return false; } else if (checkState == 28) { Feng.error("申报已完成"); return false; } else if (checkState == 6) { Feng.error("您的申报已审核通过,无法再修改"); return false; } else if (checkState == 22 || checkState == 25 || checkState == 27) { Feng.error("该申报已终止"); return false; } else { Feng.error("您的申报正在审核中,请耐心等待"); return false; } } return true; } /** * 校验是否显示按钮 * @param type 类型 1-上传按钮,2-修改删除按钮 * @param row * @returns {string} */ IntegralInfoDlg.validUploadButton = function (type, fileTypeId, fileId) { var files = $("#files").val(); files = files.split(","); var checkState = $("#checkState").val(); var realState = $("#realState").val(); //console.log(checkState, realState); if (Feng.isEmptyStr(checkState) || checkState == 0 || (checkState == 1 && realState == 1) || (checkState == 11 && realState != 14) || (realState == 11 && files.indexOf(fileTypeId.toString()) != -1)) { if (type == 1) { //上传 return ""; } else { return "" + ""; } } else { return ""; } } //回调 IntegralInfoDlg.callBack = function (data) { layer.close(data.obj); Feng.info(data.msg); if (data.code == 200) { var sn = data.info.lastIndexOf("."); var suffix = data.ext; //data.info.substring(sn + 1, data.info.length); var imgStr = ""; if (suffix == "pdf" || suffix == "PDF") { imgStr = ""; } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS' || suffix == 'docx' || suffix == 'doc' || suffix == 'DOCX' || suffix == 'DOC') { imgStr = ""; } else { imgStr = ''; } var li = $("input[name='uploadFiles[]'][value='" + data.id + "'").parents("li"); if (li.length > 0) { li.find("div").eq(1).html(data.orignName); li.find("div").eq(2).html(imgStr); } else { var html = '
  • \n\
    \n\
    ' + data.orignName + '
    \n\
    ' + imgStr + '
    \n\
    \n\ \n\ \n\
  • '; $(currentTable).find("tr[data-index='" + currentTr + "']").next("tr.detail-view").find(".imgs").append(html); } } } IntegralInfoDlg.downloadFile = function (id, type) { window.location.href = Feng.ctxPath + "/api/common/downloadFile?id=" + id + "&type=" + type; } //设置不可修改的字段 IntegralInfoDlg.setNoChangeField = function () { var checkState = $("#checkState").val(); var fields = $("#fields").val(); var allowedModifyItem = $("#files").val() == "1" ? true : false; var realState = $("#realState").val(); if (realState == 4 || checkState == 2) { $("input,textarea").each(function () { $(this).attr("readonly", "readonly"); }); $("select,input[type=radio]").each(function () { $(this).attr("disabled", "disabled"); }); if (fields != null && fields != '') { var arr = fields.split(","); for (var key in arr) { if (arr[key] != "") { var name = $("#" + arr[key]).prop("tagName"); if (name == 'select' || name == 'SELECT') { $("#" + arr[key]).removeAttr("disabled"); } else if (name == "input" || name == 'textarea' || name == "INPUT" || name == 'TEXTAREA') { $("#" + arr[key]).removeAttr("readonly"); } else { if (typeof name == "undefined") { $("input[name=" + arr[key] + "]").removeAttr("disabled").removeAttr("readonly"); } } } } } if (!allowedModifyItem) { $("#toolbar").css("display", "none"); } else { $("#itemList :input").removeAttr("readonly"); $("#itemList :input").removeAttr("disabled"); } } } $(function () { IntegralInfoDlg.setNoChangeField(); $('#integralInfoForm').bootstrapValidator({ feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, container: 'tooltip', group: '.rowGroup', fields: IntegralInfoDlg.validateFields, live: 'enabled', message: '该字段不能为空' }).on('error.field.bv', function (e, data) { // Get the tooltip var $parent = data.element.parents('#integralInfoForm'), $icon = $parent.find('.form-control-feedback[data-bv-icon-for="' + data.field + '"]'), title = $icon.data('bs.tooltip').getTitle(); $icon.tooltip('show').tooltip({ html: true, placement: 'right', title: title, container: 'body' }); }); var id = $("#id").val(); var checkState = $("#checkState").val(); if (id != null && id != '') { //select初始化 $("select").each(function () { $(this).val($(this).attr("value")).trigger("change"); }); Feng.getCheckLog("logTable", {"type": CONFIG.project_integral_apply, "mainId": id, "typeFileId": "", "active": 1}) } $("#card_type").val($("#card_type").attr("value")); IntegralInfoDlg.validId(); //IntegralInfoDlg.changeAndLoadFile(); });