/**
* 初始化人才认定申报详情对话框
*/
var TalentInfoInfoDlg = {
talentInfoInfoData: {},
};
/**
* 初始化表格的列
*/
TalentInfoInfoDlg.initFileTypeColumn = function () {
return [
{field: 'selectItem', checkbox: false, visible: false},
{title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle', width: "70%", 'class': 'uitd_showTip',
formatter: function (value, row, index) {
let str = '
';
let highlights_by_api = ["crz"];
let description = row.description;
if (highlights_by_api.indexOf(row.api) > -1) {
value = '' + value + '';
description = '' + description + '';
}
if (row.must == 1) {
return ' * ' + value;
}
if (row.must == 2) {
return '' + value;
}
str = str + '
' + description + '
'
return str;
}
},
{title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "10%",
formatter: function (value, row, index) {
if (value == null || value == '' || value == 'null') {
return '无';
}
return "";
}
},
{title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "20%",
formatter: function (value, row, index) {
return "";
}
}
]
};
TalentInfoInfoDlg.initFileTable = function () {
var ajax = new $ax("/common/api/findCommonFileType", function (data) {
if (data == null || data.length == 0) {
return;
}
var datas = new Array();
for (var i = 0; i < $(".fileTable").length; i++) {
datas.push([]);//创建空的多维数组,等下用来存每个附件表的各自的列
}
var enterpriseTag = $("#enterprise_tag").val();
for (var k in data["rows"]) {
if (data["rows"][k].enterprise_tag != "" && data["rows"][k].enterprise_tag != null && data["rows"][k].enterprise_tag.indexOf(enterpriseTag) == -1) {
continue;
}
var rel = data["rows"][k].rel;
if ($("#" + rel).length > 0) {
var tableIndex = 0;
if ($("#" + rel).parents(".table").length > 0) {
tableIndex = $("#" + rel).parents(".table").find("table.fileTable").index(".fileTable");
} else {
tableIndex = $("#" + rel).parents(".row").next(".row").find("table.fileTable").index(".fileTable");
}
data["rows"][k].tableIndex = tableIndex;
data["rows"][k].trIndex = datas[tableIndex].length;
datas[tableIndex].push(data["rows"][k]);
if (data["rows"][k].option) {
//指定了选项
if (rel == "birthday") {
let age = 0;
if ($("#" + rel).val()) {
let birthDate = new Date($("#" + rel).val());//生日日期
let birthYear = birthDate.getFullYear();
let birthMonth = birthDate.getMonth() + 1;
let currentDate = new Date();//当前日期
let currentYear = currentDate.getFullYear();
let currentMonth = currentDate.getMonth() + 1;
age = (currentYear * 12 + currentMonth - birthYear * 12 - birthMonth) / 12;
}
if (age < data["rows"][k].option)
data["rows"][k].hidden = true;
} else {
let selectVal = $("#" + rel).data("value").toString();
let options = data["rows"][k].option.split(",");
if (options.indexOf(selectVal) == -1) {
data["rows"][k].hidden = true;
}
}
}
} else {
if (data["rows"][k].isConditionFile) {
var tableIndex = 0;
if ($("#talent_condition_rel").parents(".table").length > 0) {
tableIndex = $("#talent_condition_rel").parents(".table").find("table.fileTable").index(".fileTable");
} else {
tableIndex = $("#talent_condition_rel").parents(".row").next(".row").find("table.fileTable").index(".fileTable");
}
data["rows"][k].tableIndex = tableIndex;
data["rows"][k].trIndex = datas[tableIndex].length;
datas[tableIndex].push(data["rows"][k]);//放入人才条件后面的附件表
} else {
var tableIndex = $(".fileTable").length - 2;
data["rows"][k].tableIndex = tableIndex;
data["rows"][k].trIndex = datas[tableIndex].length;
datas[$(".fileTable").length - 2].push(data["rows"][k]);//没有归属,放入最后一个附件表
}
}
}
for (var i = 0; i < $(".fileTable").length; i++) {
var that = $(".fileTable").eq(i);
that.bootstrapTable({
columns: TalentInfoInfoDlg.initFileTypeColumn(),
data: datas[i],
showHeader: false,
rowStyle: function (row, index) {
return {classes: ""};
},
onPostBody: function (data) {
for (var k in data) {
var files = data[k].files;
var html = '';
that.find("tr[data-index='" + k + "']").attr("data-rel", data[k]["rel"]);
that.find("tr[data-index='" + k + "']").attr("data-option", data[k]["option"]);
that.find("tr[data-index='" + k + "']").after('' + html + ' |
');
if (typeof data[k].hidden != "undefined") {
that.find("tr[data-index='" + k + "']").css("display", "none");
that.find("tr[data-index='" + k + "']").next("tr.detail-view").css("display", "none");
}
}
$("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_rcrd;
queryData['type'] = $("#type").val();
queryData["source"] = $("#source").val();
queryData["talent_condition"] = $("#talent_condition").val();
queryData['checkState'] = $("#checkState").val();
ajax.set(queryData);
ajax.start();
}
TalentInfoInfoDlg.downloadFile = function (id, type) {
window.location.href = Feng.ctxPath + "/common/api/downloadFile?id=" + id + "&type=" + type;
}
$(function () {
$(":input").prop("disabled", true);
$("#talent_type option").eq(0).prop("selected", true);
var id = $("#id").val();
var checkState = $("#checkState").val();
TalentInfoInfoDlg.initFileTable();
if (id != null && id != '') {
//select初始化
$("select").each(function () {
$(this).val($(this).attr("value")).trigger("change");
});
Feng.getCheckLog("logTable", {"type": CONFIG.project_rcrd, "mainId": id, "typeFileId": "", "active": 1})
}
/*var source = $("#source").val();
var columns = 3;
if (source == 1 || source == 2) {
columns = 3;
} else if (source == 3 || source == 4) {
columns = 4;
}
$("#source").parents("td").attr("colspan", columns);
$("#talent_arrange").parents("td").attr("colspan", columns);
$("#talent_condition").parents("td").attr("colspan", columns - 1);*/
});