detailPrincipalDynamicList.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /**
  2. * 分配人员明细动态list.js(负责人)
  3. */
  4. shr.defineClass("shr.custom.DetailPrincipalDynamicList", shr.custom.CustomDynamicList, {
  5. //可编辑列 数组(不区分大小写)
  6. editColumns: [],
  7. isSum: false,
  8. initalizeDOM: function () {
  9. //新增编辑列
  10. this.editColumns.push("person.name");
  11. this.editColumns.push("bdpapd.functioncoefficient");
  12. this.editColumns.push("bdpapd.energyinputcoeff");
  13. this.editColumns.push("bdpapd.performancegradeq1");
  14. this.editColumns.push("bdpapd.performancegradeq2");
  15. this.editColumns.push("bdpapd.performancecoeffq1");
  16. this.editColumns.push("bdpapd.performancecoeffq2");
  17. this.editColumns.push("bdpapd.bonusduedate");
  18. this.editColumns.push("bdpapd.bonusstartingdate");
  19. this.editColumns.push("bdpapd.initialproportion");
  20. shr.custom.DetailPrincipalDynamicList.superClass.initalizeDOM.call(this);
  21. var self = this;
  22. $('#busDep').shrPromptBox("option", {
  23. //确定按钮设置值,之后执行方法
  24. afterOK: function (datas, e) {
  25. //查询表格数据
  26. self.queryGrid();
  27. },
  28. //open方法里调用
  29. verifyBeforeOpenCallback: function (e, value) {
  30. var parentId = shr.getUrlParam('parentId');
  31. var options = {
  32. action: 'getBusDepIdStrByParentId',
  33. uipk: this.uipk,
  34. type: 'POST',
  35. async: false,
  36. param: {
  37. parentId: parentId
  38. },
  39. success: function (res) {
  40. $("#busDep").shrPromptBox("setFilter", "id in ( " + res + ")");
  41. },
  42. };
  43. shr.remoteCall(options);
  44. }
  45. });
  46. },
  47. // 根据动态列表配置 取业务主键
  48. getBillIdFieldName: function () {
  49. return 'bDPAPD.id';
  50. },
  51. /**
  52. * 描述: 导入action
  53. */
  54. importAction: function () {
  55. //自定义参数
  56. var parentId = shr.getUrlParam('parentId');
  57. var customParam = { "parentId": parentId }
  58. this.doImportData('import', customParam);
  59. },
  60. /**
  61. * 获得自定义过滤条件,供子类覆写使用
  62. */
  63. getCustomFilterItems: function () {
  64. var parentId = shr.getUrlParam('parentId');
  65. var busDepIds = $("#busDep_el").val();
  66. var filter = "bonusCycle.id = '" + parentId + "' and bDPAPD.id is not null";
  67. if (busDepIds) {
  68. busDepIds = busDepIds.replace(/,/g, "','");
  69. return filter += " and busDep.id in ('" + busDepIds + "')";
  70. }
  71. return filter;
  72. },
  73. /**
  74. * 组装保存时传至服务端的数据
  75. */
  76. assembleSaveData: function (action) {
  77. var _self = this;
  78. //组装需要修改的数据
  79. var data = [];
  80. var meta;
  81. var id, column, value, cur, element, personCode, datatype;
  82. var tds = $("#grid td[class*='dirty-cell']");
  83. var $table = $("#grid")[0];
  84. for (var i = 0; i < tds.length; i++) {
  85. //获取父节点,以获取对应id
  86. meta = {};
  87. var cur = $(tds[i]);
  88. //获取输入的内容,而不是转以后的字符实体,同时对单引号处理
  89. fid = cur.parent().attr('id');
  90. element = cur.attr('aria-describedby').replace('grid_', '');
  91. value = $($table).getCell(fid, element);
  92. //value = cur.text().replace(/\'/g, "''").trim();
  93. fid = cur.parent().attr('id');
  94. element = cur.attr('aria-describedby').replace('grid_', '');
  95. datatype = _self.getColumnType(element);
  96. if ("promptbox" == datatype) {
  97. column = element.split('.')[0];
  98. value = value["id"];
  99. } else {
  100. column = element.split('.')[1];
  101. }
  102. //列表需要显示id列
  103. id = $("#" + _self.getEscapeChars(fid) + " td[aria-describedby='grid_bdp\\.id']").attr('title');
  104. // //校验输入内容
  105. if (!_self.checkNumValid(value, datatype)) {
  106. $(tds[i]).focus();
  107. $(tds[i]).css({
  108. "border": "solid 2px red"
  109. });
  110. throw new Error("请输入正确的格式");
  111. }
  112. meta.fid = id;
  113. meta.column = column;
  114. meta.value = value;
  115. meta.type = datatype;
  116. data.push(meta);
  117. }
  118. return data;
  119. },
  120. /**
  121. * 默认的action处理方法
  122. */
  123. defaultBatchActionHandle: function (option) {
  124. var selectedIds = this.getSelectedIds();
  125. if (!selectedIds) {
  126. shr.showWarning({ message: "请先选中数据!", hideAfter: 3 })
  127. return;
  128. }
  129. shr.custom.DetailPrincipalDynamicList.superClass.defaultBatchActionHandle.call(this, option);
  130. },
  131. });