|
@@ -103,6 +103,34 @@ IdentifyConditionInfoDlg.collectData = function () {
|
|
|
this.identifyConditionInfoData['companyIds'] = company_ids;
|
|
|
this.identifyConditionInfoData['bindFileTypes'] = bind_fts_ids;
|
|
|
|
|
|
+ var chks = $("#relationTable input[type=checkbox]:checked");
|
|
|
+ var relation = {};
|
|
|
+ for (var i = 0; i < chks.length; i++) {
|
|
|
+ var companyId = $(chks[i]).data("company-id");
|
|
|
+ if (typeof relation[companyId] == "undefined") {
|
|
|
+ relation[companyId] = $(chks[i]).val();
|
|
|
+ } else {
|
|
|
+ relation[companyId] += "," + $(chks[i]).val();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.identifyConditionInfoData['relation'] = relation;
|
|
|
+}
|
|
|
+
|
|
|
+IdentifyConditionInfoDlg.otherValid = function () {
|
|
|
+ if (this.identifyConditionInfoData.companyIds != '' && this.identifyConditionInfoData.bindFileTypes != '') {
|
|
|
+ var fileTypes = this.identifyConditionInfoData.bindFileTypes.split(",");
|
|
|
+ var total = fileTypes.length;
|
|
|
+ var _goal = 0;
|
|
|
+ for (var i = 0; i < total; i++) {
|
|
|
+ var typeId = fileTypes[i];
|
|
|
+ _goal += $("input[type=checkbox][value='" + typeId + "']:checked").length > 0 ? 1 : 0;
|
|
|
+ }
|
|
|
+ if (_goal != total) {
|
|
|
+ Feng.error("选择了审核单位及审核附件后,每个附件必须与其中一个审核单位关联");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -111,13 +139,10 @@ IdentifyConditionInfoDlg.collectData = function () {
|
|
|
IdentifyConditionInfoDlg.addSubmit = function () {
|
|
|
this.clearData();
|
|
|
this.collectData();
|
|
|
- if (!this.validate()) {
|
|
|
+ if (!this.validate() || !IdentifyConditionInfoDlg.otherValid()) {
|
|
|
return;
|
|
|
}
|
|
|
- // if(this.identifyConditionInfoData.companyIds==null||this.identifyConditionInfoData.companyIds==''){
|
|
|
- // Feng.error("审核单位不能为空");return ;
|
|
|
- // }
|
|
|
- //提交信息
|
|
|
+
|
|
|
var ajax = new $ax("/admin/talent_condition/add", function (data) {
|
|
|
if (data.code == "200") {
|
|
|
Feng.success(data.msg);
|
|
@@ -139,13 +164,9 @@ IdentifyConditionInfoDlg.addSubmit = function () {
|
|
|
IdentifyConditionInfoDlg.editSubmit = function () {
|
|
|
this.clearData();
|
|
|
this.collectData();
|
|
|
- if (!this.validate()) {
|
|
|
+ if (!this.validate() || !IdentifyConditionInfoDlg.otherValid()) {
|
|
|
return;
|
|
|
}
|
|
|
- // if(this.identifyConditionInfoData.companyIds==null||this.identifyConditionInfoData.companyIds==''){
|
|
|
- // Feng.error("审核单位不能为空");return ;
|
|
|
- // }
|
|
|
- //提交信息
|
|
|
var ajax = new $ax(Feng.ctxPath + "/admin/talent_condition/edit", function (data) {
|
|
|
if (data.code == "200") {
|
|
|
Feng.success(data.msg);
|
|
@@ -172,6 +193,83 @@ IdentifyConditionInfoDlg.onTypeChange = function () {
|
|
|
$("#bindFileTypes").trigger("chosen:updated");
|
|
|
}
|
|
|
|
|
|
+IdentifyConditionInfoDlg.onCompanyOrTypeChange = function () {
|
|
|
+ var companyIds = $("#companyIds").val();
|
|
|
+ var bindFileTypes = $("#bindFileTypes").val();
|
|
|
+ IdentifyConditionInfoDlg.buildRelationTable(companyIds, bindFileTypes);
|
|
|
+}
|
|
|
+
|
|
|
+IdentifyConditionInfoDlg.fstLoad = true;
|
|
|
+IdentifyConditionInfoDlg.buildRelationTable = function (companyIds, bindFileTypes) {
|
|
|
+ var companyWithFileType = $("#companyWithFileType").val();
|
|
|
+ var setting = [];
|
|
|
+ if (companyWithFileType) {
|
|
|
+ var companyTmps = companyWithFileType.split(";")
|
|
|
+ for (var i in companyTmps) {
|
|
|
+ var _companyTmp = companyTmps[i].split(":");
|
|
|
+ var _companyId = _companyTmp[0];
|
|
|
+ var _fileTypes = _companyTmp[1].split(",");
|
|
|
+ setting[_companyId] = _fileTypes;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var trs = $("#relationTable tbody").find("tr");
|
|
|
+ trs.each(function (index, tr) {
|
|
|
+ if (!companyIds || companyIds.indexOf($(tr).data("id").toString()) == -1)
|
|
|
+ $(tr).remove();
|
|
|
+ })
|
|
|
+ for (let i in companyIds) {
|
|
|
+ let companyId = companyIds[i];
|
|
|
+ if (companyId == "")
|
|
|
+ continue;
|
|
|
+ var cfg = setting[companyId];
|
|
|
+ if ($("#relationTable tbody").find("tr[data-id='" + companyId + "']").length > 0) {
|
|
|
+ var chks = $("#relationTable tbody").find("tr[data-id='" + companyId + "']").find("input[type=checkbox]");
|
|
|
+ chks.each(function (index, chk) {
|
|
|
+ if (!bindFileTypes || bindFileTypes.indexOf($(chk).val().toString()) == -1)
|
|
|
+ $(chk).parents("li").remove();
|
|
|
+ })
|
|
|
+ for (let n in bindFileTypes) {
|
|
|
+ let fileType = bindFileTypes[n];
|
|
|
+ if ($("#relationTable tbody").find("tr[data-id='" + companyId + "']").find("input[value='" + fileType + "']").length == 0) {
|
|
|
+ let typename = $("#bindFileTypes option[value='" + fileType + "']").text();
|
|
|
+ let disabled = $("input[type=checkbox][value='" + fileType + "']:checked").length > 0 ? "disabled" : "";
|
|
|
+ let li = '<li><label for="relation[' + companyId + ']">' + typename + '</label><input type="checkbox" data-company-id="' + companyId + '" value="' + fileType + '" ' + disabled + ' onchange="IdentifyConditionInfoDlg.onCheckChange(this);"></li>';
|
|
|
+ $("#relationTable tbody").find("tr[data-id='" + companyId + "'] ul").append(li);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let newTr = "";
|
|
|
+ let companyName = $("#companyIds option[value='" + companyId + "']").text();
|
|
|
+ newTr = '<tr data-id="' + companyId + '"><td style="width:10%;">' + companyName + '</td><td style="width:90%"><ul>';
|
|
|
+ for (let n in bindFileTypes) {
|
|
|
+ let fileType = bindFileTypes[n];
|
|
|
+ let typename = $("#bindFileTypes option[value='" + fileType + "']").text();
|
|
|
+
|
|
|
+ var checked = "";
|
|
|
+ if (typeof cfg != "undefined" && cfg.indexOf(fileType) > -1 && $("input[type=checkbox][value='" + fileType + "']:checked").length == 0)
|
|
|
+ checked = "checked";
|
|
|
+ if (IdentifyConditionInfoDlg.fstLoad && checked == "checked") {
|
|
|
+ $("input[type=checkbox][value='" + fileType + "']").prop("disabled", true);
|
|
|
+ }
|
|
|
+ let disabled = $("input[type=checkbox][value='" + fileType + "']:checked").length > 0 ? "disabled" : "";
|
|
|
+ newTr += '<li><label for="relation[' + companyId + ']">' + typename + '</label><input type="checkbox" data-company-id="' + companyId + '" value="' + fileType + '" ' + checked + " " + disabled + ' onchange="IdentifyConditionInfoDlg.onCheckChange(this);"></li>';
|
|
|
+ }
|
|
|
+ newTr += '</ul></td></tr>'
|
|
|
+ $("#relationTable tbody").append(newTr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ IdentifyConditionInfoDlg.fstLoad = false;
|
|
|
+}
|
|
|
+IdentifyConditionInfoDlg.onCheckChange = function (chk) {
|
|
|
+ var typeId = $(chk).val();
|
|
|
+ if ($(chk).is(":checked")) {
|
|
|
+ $("input[type=checkbox][value='" + typeId + "']").prop("disabled", true);
|
|
|
+ $(chk).removeAttr("disabled");
|
|
|
+ } else {
|
|
|
+ $("input[type=checkbox][value='" + typeId + "']").removeAttr("disabled");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* 验证数据是否为空
|
|
|
*/
|
|
@@ -223,4 +321,5 @@ $(function () {
|
|
|
if (Feng.isNotEmptyStr(bindFileTypes)) {
|
|
|
$("#bindFileTypes").val(bindFileTypes.split(",")).trigger("chosen:updated");
|
|
|
}
|
|
|
+ IdentifyConditionInfoDlg.onCompanyOrTypeChange();
|
|
|
});
|