amountStandard_info.js 3.8 KB

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