identifyCondition_info.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. notWorkYear: {
  36. validators: {
  37. notEmpty: {
  38. message: '常年工作判定条件不能为空'
  39. }
  40. }
  41. },
  42. activeYear:{
  43. validators: {
  44. notEmpty: {
  45. message: '有效期不能为空'
  46. },
  47. regexp :{
  48. regexp: /^\d+$/,
  49. message:"只能输入数字"
  50. }
  51. }
  52. }
  53. }
  54. };
  55. /**
  56. * 清除数据
  57. */
  58. IdentifyConditionInfoDlg.clearData = function() {
  59. this.identifyConditionInfoData = {};
  60. }
  61. /**
  62. * 设置对话框中的数据
  63. *
  64. * @param key 数据的名称
  65. * @param val 数据的具体值
  66. */
  67. IdentifyConditionInfoDlg.set = function(key, val) {
  68. this.identifyConditionInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  69. return this;
  70. }
  71. /**
  72. * 设置对话框中的数据
  73. *
  74. * @param key 数据的名称
  75. * @param val 数据的具体值
  76. */
  77. IdentifyConditionInfoDlg.get = function(key) {
  78. return $("#" + key).val();
  79. }
  80. /**
  81. * 关闭此对话框
  82. */
  83. IdentifyConditionInfoDlg.close = function() {
  84. parent.layer.close(window.parent.IdentifyCondition.layerIndex);
  85. }
  86. /**
  87. * 收集数据
  88. */
  89. IdentifyConditionInfoDlg.collectData = function() {
  90. this
  91. .set('id')
  92. .set('source')
  93. .set('type')
  94. .set('talentLevel')
  95. .set('name')
  96. .set('activeYear')
  97. .set('notWorkYear')
  98. .set('active')
  99. .set('description');
  100. var companys = $("#companyIds").val();
  101. var talentTypes = $("#talentTypes").val();
  102. var ids = "",talentTypeArr = "";
  103. for(var key in companys){
  104. if(Feng.isNotEmptyStr(companys[key])){
  105. ids = ids + companys[key]+",";
  106. }
  107. }
  108. if(Feng.isNotEmptyStr(ids)){
  109. ids = ids.substring(0,ids.length-1);
  110. }
  111. for(var key in talentTypes){
  112. if(Feng.isNotEmptyStr(talentTypes[key])){
  113. talentTypeArr = talentTypeArr + talentTypes[key]+",";
  114. }
  115. }
  116. if(Feng.isNotEmptyStr(talentTypeArr)){
  117. talentTypeArr = talentTypeArr.substring(0,talentTypeArr.length-1);
  118. }
  119. this.identifyConditionInfoData['companyIds'] = ids;
  120. this.identifyConditionInfoData['talentTypes'] = talentTypeArr;
  121. }
  122. /**
  123. * 提交添加
  124. */
  125. IdentifyConditionInfoDlg.addSubmit = function() {
  126. this.clearData();
  127. this.collectData();
  128. if (!this.validate()) {
  129. return;
  130. }
  131. // if(this.identifyConditionInfoData.companyIds==null||this.identifyConditionInfoData.companyIds==''){
  132. // Feng.error("审核单位不能为空");return ;
  133. // }
  134. //提交信息
  135. var ajax = new $ax(Feng.ctxPath + "/identifyCondition/add", function(data){
  136. if(data.code=="200"){
  137. Feng.success(data.msg);
  138. window.parent.IdentifyCondition.table.refresh();
  139. IdentifyConditionInfoDlg.close();
  140. }else{
  141. Feng.error(data.msg);
  142. }
  143. },function(data){
  144. Feng.error("添加失败!" + data.responseJSON.message + "!");
  145. });
  146. ajax.set(this.identifyConditionInfoData);
  147. ajax.start();
  148. }
  149. /**
  150. * 提交修改
  151. */
  152. IdentifyConditionInfoDlg.editSubmit = function() {
  153. this.clearData();
  154. this.collectData();
  155. if (!this.validate()) {
  156. return;
  157. }
  158. // if(this.identifyConditionInfoData.companyIds==null||this.identifyConditionInfoData.companyIds==''){
  159. // Feng.error("审核单位不能为空");return ;
  160. // }
  161. //提交信息
  162. var ajax = new $ax(Feng.ctxPath + "/identifyCondition/update", function(data){
  163. if(data.code=="200"){
  164. Feng.success(data.msg);
  165. window.parent.IdentifyCondition.table.refresh();
  166. IdentifyConditionInfoDlg.close();
  167. }else{
  168. Feng.error(data.msg);
  169. }
  170. },function(data){
  171. Feng.error("修改失败!" + data.responseJSON.message + "!");
  172. });
  173. ajax.set(this.identifyConditionInfoData);
  174. ajax.start();
  175. }
  176. /**
  177. * 验证数据是否为空
  178. */
  179. IdentifyConditionInfoDlg.validate = function () {
  180. $('#identifyConditionInfoForm').data("bootstrapValidator").resetForm();
  181. $('#identifyConditionInfoForm').bootstrapValidator('validate');
  182. return $("#identifyConditionInfoForm").data('bootstrapValidator').isValid();
  183. }
  184. $(function() {
  185. Feng.initValidator("identifyConditionInfoForm", IdentifyConditionInfoDlg.validateFields);
  186. //下拉框数据动态加载
  187. // Feng.addAjaxSelect({
  188. // "id": "talentLevel",
  189. // "displayCode": "code",
  190. // "displayName": "name",
  191. // "type": "GET",
  192. // "url": Feng.ctxPath + "/dict/findChildDictByCode?code=un_talentLevel"
  193. // });
  194. var arr = [{
  195. "name": "talentLevel",
  196. "code": "un_talentLevel"
  197. }, {
  198. "name": "talentTypes",
  199. "code": "un_jbt_talentType"
  200. }];
  201. Feng.findChildDictBatch(JSON.stringify(arr));
  202. Feng.addAjaxSelect({
  203. "id": "companyIds",
  204. "displayCode": "id",
  205. "displayName": "name",
  206. "type": "GET",
  207. "url": Feng.ctxPath + "/company/selectAll"
  208. });
  209. $('#companyIds').chosen({
  210. // search_contains:false,
  211. // enable_split_word_search: true
  212. });
  213. $('#talentTypes').chosen({
  214. search_contains:true,    //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
  215. disable_search: false,
  216. width:"100%",
  217. enable_split_word_search: true
  218. });
  219. //下拉框数据回显
  220. $("select").each(function () {
  221. $(this).val($(this).attr("selectVal"));
  222. });
  223. var companyIds = $("#companyIds").attr("selectVal");
  224. var talentTypes = $("#talentTypes").attr("selectVal");
  225. if(Feng.isNotEmptyStr(companyIds)){
  226. $("#companyIds").val(companyIds.split(",")).trigger("chosen:updated");
  227. }
  228. if(Feng.isNotEmptyStr(talentTypes)){
  229. $("#talentTypes").val(talentTypes.split(",")).trigger("chosen:updated");
  230. }
  231. });