identifyCondition_info.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /**
  2. * 初始化认定条件管理详情对话框
  3. */
  4. var IdentifyConditionInfoDlg = {
  5. identifyConditionInfoData: {},
  6. validateFields: {
  7. talentLevel: {
  8. validators: {
  9. notEmpty: {
  10. message: '人才层次不能为空'
  11. }
  12. }
  13. },
  14. type: {
  15. validators: {
  16. notEmpty: {
  17. message: '人才类别不能为空'
  18. }
  19. }
  20. },
  21. name: {
  22. validators: {
  23. notEmpty: {
  24. message: '名称不能为空'
  25. }
  26. }
  27. },
  28. active: {
  29. validators: {
  30. notEmpty: {
  31. message: '启用状态不能为空'
  32. }
  33. }
  34. }
  35. }
  36. };
  37. /**
  38. * 清除数据
  39. */
  40. IdentifyConditionInfoDlg.clearData = function () {
  41. this.identifyConditionInfoData = {};
  42. }
  43. /**
  44. * 设置对话框中的数据
  45. *
  46. * @param key 数据的名称
  47. * @param val 数据的具体值
  48. */
  49. IdentifyConditionInfoDlg.set = function (key, val) {
  50. this.identifyConditionInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  51. return this;
  52. }
  53. /**
  54. * 设置对话框中的数据
  55. *
  56. * @param key 数据的名称
  57. * @param val 数据的具体值
  58. */
  59. IdentifyConditionInfoDlg.get = function (key) {
  60. return $("#" + key).val();
  61. }
  62. /**
  63. * 关闭此对话框
  64. */
  65. IdentifyConditionInfoDlg.close = function () {
  66. parent.layer.close(window.parent.IdentifyCondition.layerIndex);
  67. }
  68. /**
  69. * 收集数据
  70. */
  71. IdentifyConditionInfoDlg.collectData = function () {
  72. this
  73. .set('id')
  74. .set('type')
  75. .set('talentLevel')
  76. .set('name')
  77. .set('active')
  78. .set('description');
  79. var companys = $("#companyIds").val();
  80. var bindFileTypes = $("#bindFileTypes").val();
  81. var company_ids = "", bind_fts_ids = "";
  82. for (var key in companys) {
  83. if (Feng.isNotEmptyStr(companys[key])) {
  84. company_ids = company_ids + companys[key] + ",";
  85. }
  86. }
  87. if (Feng.isNotEmptyStr(company_ids)) {
  88. company_ids = company_ids.substring(0, company_ids.length - 1);
  89. }
  90. for (var key in bindFileTypes) {
  91. if (Feng.isNotEmptyStr(bindFileTypes[key])) {
  92. bind_fts_ids = bind_fts_ids + bindFileTypes[key] + ",";
  93. }
  94. }
  95. if (Feng.isNotEmptyStr(bind_fts_ids)) {
  96. bind_fts_ids = bind_fts_ids.substring(0, bind_fts_ids.length - 1);
  97. }
  98. this.identifyConditionInfoData['companyIds'] = company_ids;
  99. this.identifyConditionInfoData['bindFileTypes'] = bind_fts_ids;
  100. }
  101. /**
  102. * 提交添加
  103. */
  104. IdentifyConditionInfoDlg.addSubmit = function () {
  105. this.clearData();
  106. this.collectData();
  107. if (!this.validate()) {
  108. return;
  109. }
  110. // if(this.identifyConditionInfoData.companyIds==null||this.identifyConditionInfoData.companyIds==''){
  111. // Feng.error("审核单位不能为空");return ;
  112. // }
  113. //提交信息
  114. var ajax = new $ax("/admin/talent_condition/add", function (data) {
  115. if (data.code == "200") {
  116. Feng.success(data.msg);
  117. window.parent.IdentifyCondition.table.refresh();
  118. IdentifyConditionInfoDlg.close();
  119. } else {
  120. Feng.error(data.msg);
  121. }
  122. }, function (data) {
  123. Feng.error("添加失败!" + data.responseJSON.message + "!");
  124. });
  125. ajax.set(this.identifyConditionInfoData);
  126. ajax.start();
  127. }
  128. /**
  129. * 提交修改
  130. */
  131. IdentifyConditionInfoDlg.editSubmit = function () {
  132. this.clearData();
  133. this.collectData();
  134. if (!this.validate()) {
  135. return;
  136. }
  137. // if(this.identifyConditionInfoData.companyIds==null||this.identifyConditionInfoData.companyIds==''){
  138. // Feng.error("审核单位不能为空");return ;
  139. // }
  140. //提交信息
  141. var ajax = new $ax(Feng.ctxPath + "/admin/talent_condition/edit", function (data) {
  142. if (data.code == "200") {
  143. Feng.success(data.msg);
  144. window.parent.IdentifyCondition.table.refresh();
  145. IdentifyConditionInfoDlg.close();
  146. } else {
  147. Feng.error(data.msg);
  148. }
  149. }, function (data) {
  150. Feng.error("修改失败!" + data.responseJSON.message + "!");
  151. });
  152. ajax.set(this.identifyConditionInfoData);
  153. ajax.start();
  154. }
  155. IdentifyConditionInfoDlg.onTypeChange = function () {
  156. var type = $("#type").val();
  157. Feng.addAjaxSelect({
  158. "id": "bindFileTypes",
  159. "displayCode": "id",
  160. "displayName": "name",
  161. "type": "GET",
  162. "url": Feng.ctxPath + "/common/api/getConditionFileTypesByType/type/" + type
  163. });
  164. $("#bindFileTypes").trigger("chosen:updated");
  165. }
  166. /**
  167. * 验证数据是否为空
  168. */
  169. IdentifyConditionInfoDlg.validate = function () {
  170. $('#identifyConditionInfoForm').data("bootstrapValidator").resetForm();
  171. $('#identifyConditionInfoForm').bootstrapValidator('validate');
  172. return $("#identifyConditionInfoForm").data('bootstrapValidator').isValid();
  173. }
  174. $(function () {
  175. Feng.initValidator("identifyConditionInfoForm", IdentifyConditionInfoDlg.validateFields);
  176. var arr = [{
  177. "name": "talentLevel",
  178. "code": "talent_arrange"
  179. }];
  180. Feng.findChildDictBatch(JSON.stringify(arr));
  181. Feng.addAjaxSelect({
  182. "id": "companyIds",
  183. "displayCode": "id",
  184. "displayName": "name",
  185. "type": "GET",
  186. "url": Feng.ctxPath + "/common/api/getCompanyKvs"
  187. });
  188. $('#companyIds').chosen({
  189. search_contains: true,
  190. disable_search: false,
  191. width: "100%",
  192. enable_split_word_search: true
  193. });
  194. $('#bindFileTypes').chosen({
  195. search_contains: true,
  196. disable_search: false,
  197. width: "100%",
  198. enable_split_word_search: true
  199. });
  200. //下拉框数据回显
  201. $("select").each(function () {
  202. $(this).val($(this).attr("selectVal"));
  203. });
  204. var companyIds = $("#companyIds").attr("selectVal");
  205. if (Feng.isNotEmptyStr(companyIds)) {
  206. $("#companyIds").val(companyIds.split(",")).trigger("chosen:updated");
  207. }
  208. var type = $("#type").val();
  209. if (type > 0) {
  210. IdentifyConditionInfoDlg.onTypeChange();
  211. }
  212. var bindFileTypes = $("#bindFileTypes").attr("selectVal");
  213. if (Feng.isNotEmptyStr(bindFileTypes)) {
  214. $("#bindFileTypes").val(bindFileTypes.split(",")).trigger("chosen:updated");
  215. }
  216. });