123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- /**
- * 初始化人才认定申报详情对话框
- */
- var TalentInfoInfoDlg = {
- talentInfoInfoData: {},
- };
- /**
- * 初始化表格的列
- */
- TalentInfoInfoDlg.initFileTypeColumn = function () {
- return [
- {field: 'selectItem', checkbox: false, visible: false},
- {title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle', width: "30%", 'class': 'uitd_showTip',
- formatter: function (value, row, index) {
- if (row.must == 1) {
- return '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + value;
- }
- if (row.must == 2) {
- return '<i class="fa fa-paste"></i>' + value;
- }
- }
- },
- {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "8%",
- formatter: function (value, row, index) {
- if (value == null || value == '' || value == 'null') {
- return '无';
- }
- return "<button type='button' onclick=\"TalentInfoInfoDlg.downloadFile('" + row.id + "',3)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
- "<i class=\"fa fa-download\"></i>下载" +
- "</button>";
- }
- },
- {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle', width: "52%", 'class': 'uitd_showTip'},
- {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%",
- 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 birthday = parseInt($("#" + rel).val().substring(0, 4));
- let currentYear = parseInt(new Date().getFullYear());
- let age = currentYear - (isNaN(birthday) ? 0 : birthday);
- if (isNaN(birthday) || (!isNaN(birthday) && 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").parents(".table").length > 0) {
- tableIndex = $("#talent_condition").parents(".table").find("table.fileTable").index(".fileTable");
- } else {
- tableIndex = $("#talent_condition").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 - 1;
- data["rows"][k].tableIndex = tableIndex;
- data["rows"][k].trIndex = datas[tableIndex].length;
- datas[$(".fileTable").length - 1].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 = '<ul class="imgs"><li style="width: 80%;font-weight: bold;padding-top: 5px;">附件原名</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">预览</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">操作</li>';
- for (var key in files) {
- var sn = files[key].url.lastIndexOf(".");
- var suffix = files[key].ext;//files[key].url.substring(sn + 1, files[key].url.length);
- var imgStr = "";
- if (suffix == "pdf" || suffix == "PDF") {
- imgStr = "<button type='button' onclick=\"Feng.showPdf('" + files[key].url + "','" + files[key].id + "','" + files[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-pdf-o\" aria-hidden=\"true\"></i></button>";
- } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS') {
- imgStr = "<button type='button' onclick=\"Feng.showExcel('" + files[key].url + "','" + files[key].id + "','" + files[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-excel-o\" aria-hidden=\"true\"></i></button>";
- } else {
- imgStr = '<img class=\"imgUrl\" onclick="Feng.showImg(this)" src=\"' + files[key].url + '\" style=\"width:25px;height:25px;\">';
- }
- html += '<li data-id="' + files[key].id + '">\n\
- <div><input type="hidden" name="uploadFiles[]" value="' + files[key].id + '"></div>\n' +
- '<div style="width: 80%;">' + files[key].orignName + '</div>\n' +
- '<div style="width: 10%;">' + imgStr + '</div>\n' +
- '<div style="width: 10%;"></div>\n\
- </li>';
- }
- html = html + '</ul>';
- 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('<tr class="detail-view"><td colspan="5">' + html + '</td></tr>');
- 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 + "/api/common/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})
- }
- });
|