talentcheckproperties_info.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /**
  2. * 初始化主管部门审核配置详情对话框
  3. */
  4. var TalentcheckpropertiesInfoDlg = {
  5. talentcheckpropertiesInfoData : {},
  6. validateFields: {
  7. code:{
  8. validators: {
  9. notEmpty: {
  10. message: '人才标签不能为空'
  11. }
  12. }
  13. },
  14. companyId: {
  15. validators: {
  16. notEmpty: {
  17. message: '审核单位不能为空'
  18. }
  19. }
  20. },
  21. enterpriseId: {
  22. validators: {
  23. notEmpty: {
  24. message: '企业不能为空'
  25. }
  26. }
  27. }
  28. }
  29. };
  30. /**
  31. * 清除数据
  32. */
  33. TalentcheckpropertiesInfoDlg.clearData = function() {
  34. this.talentcheckpropertiesInfoData = {};
  35. }
  36. /**
  37. * 设置对话框中的数据
  38. *
  39. * @param key 数据的名称
  40. * @param val 数据的具体值
  41. */
  42. TalentcheckpropertiesInfoDlg.set = function(key, val) {
  43. this.talentcheckpropertiesInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  44. return this;
  45. }
  46. /**
  47. * 设置对话框中的数据
  48. *
  49. * @param key 数据的名称
  50. * @param val 数据的具体值
  51. */
  52. TalentcheckpropertiesInfoDlg.get = function(key) {
  53. return $("#" + key).val();
  54. }
  55. /**
  56. * 关闭此对话框
  57. */
  58. TalentcheckpropertiesInfoDlg.close = function() {
  59. parent.layer.close(window.parent.Talentcheckproperties.layerIndex);
  60. }
  61. /**
  62. * 收集数据
  63. */
  64. TalentcheckpropertiesInfoDlg.collectData = function() {
  65. this
  66. .set('id')
  67. .set('code')
  68. .set('enterpriseId')
  69. .set('companyId')
  70. .set('description');
  71. }
  72. /**
  73. * 提交添加
  74. */
  75. TalentcheckpropertiesInfoDlg.addSubmit = function() {
  76. this.clearData();
  77. this.collectData();
  78. if (!this.validate()) {
  79. return;
  80. }
  81. //提交信息
  82. var ajax = new $ax(Feng.ctxPath + "/talentcheckproperties/add", function(data){
  83. if(data.code==200){
  84. Feng.success(data.msg);
  85. window.parent.Talentcheckproperties.table.refresh();
  86. TalentcheckpropertiesInfoDlg.close();
  87. }else{
  88. Feng.error(data.msg);
  89. }
  90. },function(data){
  91. Feng.error("添加失败!" + data.responseJSON.message + "!");
  92. });
  93. ajax.set(this.talentcheckpropertiesInfoData);
  94. ajax.start();
  95. }
  96. /**
  97. * 提交修改
  98. */
  99. TalentcheckpropertiesInfoDlg.editSubmit = function() {
  100. this.clearData();
  101. this.collectData();
  102. if (!this.validate()) {
  103. return;
  104. }
  105. //提交信息
  106. var ajax = new $ax(Feng.ctxPath + "/talentcheckproperties/update", function(data){
  107. if(data.code==200){
  108. Feng.success(data.msg);
  109. window.parent.Talentcheckproperties.table.refresh();
  110. TalentcheckpropertiesInfoDlg.close();
  111. }else{
  112. Feng.error(data.msg);
  113. }
  114. },function(data){
  115. Feng.error("修改失败!" + data.responseJSON.message + "!");
  116. });
  117. ajax.set(this.talentcheckpropertiesInfoData);
  118. ajax.start();
  119. }
  120. /**
  121. * 验证数据是否为空
  122. */
  123. TalentcheckpropertiesInfoDlg.validate = function () {
  124. $('#talentcheckpropertiesForm').data("bootstrapValidator").resetForm();
  125. $('#talentcheckpropertiesForm').bootstrapValidator('validate');
  126. return $("#talentcheckpropertiesForm").data('bootstrapValidator').isValid();
  127. }
  128. $(function() {
  129. Feng.initValidator("talentcheckpropertiesForm", TalentcheckpropertiesInfoDlg.validateFields);
  130. //下拉框数据动态加载
  131. Feng.addAjaxSelect({
  132. "id": "code",
  133. "displayCode": "code",
  134. "displayName": "name",
  135. "type": "GET",
  136. "url": Feng.ctxPath + "/dict/findChildDictByCode?code=un_jbt_talentType"
  137. });
  138. //提交信息
  139. var ajax = new $ax(Feng.ctxPath + "/talentcheckproperties/init", function(data){
  140. var enterprise = data.enterprises;
  141. var company = data.companys;
  142. var eHtml,cHtml = "<option value=''>请选择</option>";
  143. for(var key in enterprise){
  144. eHtml = eHtml + "<option value='"+enterprise[key].id+"'>"+enterprise[key].name+"</option>"
  145. }
  146. for(var key in company){
  147. cHtml = cHtml + "<option value='"+company[key].id+"'>"+company[key].name+"</option>"
  148. }
  149. $("#companyId").empty().append(cHtml);
  150. $("#enterpriseId").empty().append(eHtml);
  151. },function(data){
  152. Feng.error("初始失败!" + data.responseJSON.message + "!");
  153. });
  154. ajax.start();
  155. //下拉框数据回显
  156. $("select").each(function () {
  157. $(this).val($(this).attr("selectVal"));
  158. });
  159. });