123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- /**
- * 初始化认定条件管理详情对话框
- */
- var IdentifyConditionInfoDlg = {
- identifyConditionInfoData: {},
- validateFields: {
- talentLevel: {
- validators: {
- notEmpty: {
- message: '人才层次不能为空'
- }
- }
- },
- type: {
- validators: {
- notEmpty: {
- message: '人才类别不能为空'
- }
- }
- },
- name: {
- validators: {
- notEmpty: {
- message: '名称不能为空'
- }
- }
- },
- active: {
- validators: {
- notEmpty: {
- message: '启用状态不能为空'
- }
- }
- }
- }
- };
- /**
- * 清除数据
- */
- IdentifyConditionInfoDlg.clearData = function () {
- this.identifyConditionInfoData = {};
- }
- /**
- * 设置对话框中的数据
- *
- * @param key 数据的名称
- * @param val 数据的具体值
- */
- IdentifyConditionInfoDlg.set = function (key, val) {
- this.identifyConditionInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
- return this;
- }
- /**
- * 设置对话框中的数据
- *
- * @param key 数据的名称
- * @param val 数据的具体值
- */
- IdentifyConditionInfoDlg.get = function (key) {
- return $("#" + key).val();
- }
- /**
- * 关闭此对话框
- */
- IdentifyConditionInfoDlg.close = function () {
- parent.layer.close(window.parent.IdentifyCondition.layerIndex);
- }
- /**
- * 收集数据
- */
- IdentifyConditionInfoDlg.collectData = function () {
- this
- .set('id')
- .set('type')
- .set('talentLevel')
- .set('name')
- .set('active')
- .set('description');
- var companys = $("#companyIds").val();
- var bindFileTypes = $("#bindFileTypes").val();
- var company_ids = "", bind_fts_ids = "";
- for (var key in companys) {
- if (Feng.isNotEmptyStr(companys[key])) {
- company_ids = company_ids + companys[key] + ",";
- }
- }
- if (Feng.isNotEmptyStr(company_ids)) {
- company_ids = company_ids.substring(0, company_ids.length - 1);
- }
- for (var key in bindFileTypes) {
- if (Feng.isNotEmptyStr(bindFileTypes[key])) {
- bind_fts_ids = bind_fts_ids + bindFileTypes[key] + ",";
- }
- }
- if (Feng.isNotEmptyStr(bind_fts_ids)) {
- bind_fts_ids = bind_fts_ids.substring(0, bind_fts_ids.length - 1);
- }
- this.identifyConditionInfoData['companyIds'] = company_ids;
- this.identifyConditionInfoData['bindFileTypes'] = bind_fts_ids;
- }
- /**
- * 提交添加
- */
- IdentifyConditionInfoDlg.addSubmit = function () {
- this.clearData();
- this.collectData();
- if (!this.validate()) {
- 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);
- window.parent.IdentifyCondition.table.refresh();
- IdentifyConditionInfoDlg.close();
- } else {
- Feng.error(data.msg);
- }
- }, function (data) {
- Feng.error("添加失败!" + data.responseJSON.message + "!");
- });
- ajax.set(this.identifyConditionInfoData);
- ajax.start();
- }
- /**
- * 提交修改
- */
- IdentifyConditionInfoDlg.editSubmit = function () {
- this.clearData();
- this.collectData();
- if (!this.validate()) {
- 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);
- window.parent.IdentifyCondition.table.refresh();
- IdentifyConditionInfoDlg.close();
- } else {
- Feng.error(data.msg);
- }
- }, function (data) {
- Feng.error("修改失败!" + data.responseJSON.message + "!");
- });
- ajax.set(this.identifyConditionInfoData);
- ajax.start();
- }
- IdentifyConditionInfoDlg.onTypeChange = function () {
- var type = $("#type").val();
- Feng.addAjaxSelect({
- "id": "bindFileTypes",
- "displayCode": "id",
- "displayName": "name",
- "type": "GET",
- "url": Feng.ctxPath + "/common/api/getConditionFileTypesByType/type/" + type
- });
- $("#bindFileTypes").trigger("chosen:updated");
- }
- /**
- * 验证数据是否为空
- */
- IdentifyConditionInfoDlg.validate = function () {
- $('#identifyConditionInfoForm').data("bootstrapValidator").resetForm();
- $('#identifyConditionInfoForm').bootstrapValidator('validate');
- return $("#identifyConditionInfoForm").data('bootstrapValidator').isValid();
- }
- $(function () {
- Feng.initValidator("identifyConditionInfoForm", IdentifyConditionInfoDlg.validateFields);
- var arr = [{
- "name": "talentLevel",
- "code": "talent_arrange"
- }];
- Feng.findChildDictBatch(JSON.stringify(arr));
- Feng.addAjaxSelect({
- "id": "companyIds",
- "displayCode": "id",
- "displayName": "name",
- "type": "GET",
- "url": Feng.ctxPath + "/common/api/getCompanyKvs"
- });
- $('#companyIds').chosen({
- search_contains: true,
- disable_search: false,
- width: "100%",
- enable_split_word_search: true
- });
- $('#bindFileTypes').chosen({
- search_contains: true,
- disable_search: false,
- width: "100%",
- enable_split_word_search: true
- });
- //下拉框数据回显
- $("select").each(function () {
- $(this).val($(this).attr("selectVal"));
- });
- var companyIds = $("#companyIds").attr("selectVal");
- if (Feng.isNotEmptyStr(companyIds)) {
- $("#companyIds").val(companyIds.split(",")).trigger("chosen:updated");
- }
- var type = $("#type").val();
- if (type > 0) {
- IdentifyConditionInfoDlg.onTypeChange();
- }
- var bindFileTypes = $("#bindFileTypes").attr("selectVal");
- if (Feng.isNotEmptyStr(bindFileTypes)) {
- $("#bindFileTypes").val(bindFileTypes.split(",")).trigger("chosen:updated");
- }
- });
|