identifyCondition_info.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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 talentTypes = $("#talentTypes").val();
  81. var ids = "",talentTypeArr = "";
  82. for(var key in companys){
  83. if(Feng.isNotEmptyStr(companys[key])){
  84. ids = ids + companys[key]+",";
  85. }
  86. }
  87. if(Feng.isNotEmptyStr(ids)){
  88. ids = ids.substring(0,ids.length-1);
  89. }
  90. for(var key in talentTypes){
  91. if(Feng.isNotEmptyStr(talentTypes[key])){
  92. talentTypeArr = talentTypeArr + talentTypes[key]+",";
  93. }
  94. }
  95. if(Feng.isNotEmptyStr(talentTypeArr)){
  96. talentTypeArr = talentTypeArr.substring(0,talentTypeArr.length-1);
  97. }
  98. this.identifyConditionInfoData['companyIds'] = ids;
  99. this.identifyConditionInfoData['talentTypes'] = talentTypeArr;
  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. /**
  156. * 验证数据是否为空
  157. */
  158. IdentifyConditionInfoDlg.validate = function () {
  159. $('#identifyConditionInfoForm').data("bootstrapValidator").resetForm();
  160. $('#identifyConditionInfoForm').bootstrapValidator('validate');
  161. return $("#identifyConditionInfoForm").data('bootstrapValidator').isValid();
  162. }
  163. $(function() {
  164. Feng.initValidator("identifyConditionInfoForm", IdentifyConditionInfoDlg.validateFields);
  165. //下拉框数据动态加载
  166. // Feng.addAjaxSelect({
  167. // "id": "talentLevel",
  168. // "displayCode": "code",
  169. // "displayName": "name",
  170. // "type": "GET",
  171. // "url": Feng.ctxPath + "/dict/findChildDictByCode?code=un_talentLevel"
  172. // });
  173. var arr = [{
  174. "name": "talentLevel",
  175. "code": "talent_arrange"
  176. }];
  177. Feng.findChildDictBatch(JSON.stringify(arr));
  178. Feng.addAjaxSelect({
  179. "id": "companyIds",
  180. "displayCode": "id",
  181. "displayName": "name",
  182. "type": "GET",
  183. "url": Feng.ctxPath + "/common/api/getCompanyKvs"
  184. });
  185. $('#companyIds').chosen({
  186. // search_contains:false,
  187. // enable_split_word_search: true
  188. });
  189. $('#talentTypes').chosen({
  190. search_contains:true,    //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
  191. disable_search: false,
  192. width:"100%",
  193. enable_split_word_search: true
  194. });
  195. //下拉框数据回显
  196. $("select").each(function () {
  197. $(this).val($(this).attr("selectVal"));
  198. });
  199. var companyIds = $("#companyIds").attr("selectVal");
  200. var talentTypes = $("#talentTypes").attr("selectVal");
  201. if(Feng.isNotEmptyStr(companyIds)){
  202. $("#companyIds").val(companyIds.split(",")).trigger("chosen:updated");
  203. }
  204. if(Feng.isNotEmptyStr(talentTypes)){
  205. $("#talentTypes").val(talentTypes.split(",")).trigger("chosen:updated");
  206. }
  207. });