Nav apraksta

index.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * Created by TT on 2017/5/8.
  3. */
  4. ;
  5. spa_define(function () {
  6. return $.use(["spa", "pagedatagrid", "util"], function (spa, pdgf, util) {
  7. return {
  8. main: function () {
  9. var root = spa.findInMain(".sys_demand_index");
  10. var pdg = pdgf.build(root);
  11. pdg.code.shell("showDay", function (env) {
  12. if (env.cd && env.cd[this.k]) {
  13. var day = env.cd[this.k];
  14. return day.substring(0, 4) + "-" + day.substring(4, 6) + "-" + day.substring(6, 8);
  15. }
  16. return "";
  17. });
  18. pdg.code.shell("status", function (env) {
  19. var v = env.cd[this.k];
  20. return v === "1" ? "关闭需求" : (v === "0" ? "打开需求" : "");
  21. });
  22. pdg.code.shell("status2", function (env) {
  23. var v = env.cd[this.k];
  24. return v === "1" ? "发布中" : (v === "0" ? "已关闭" : "");
  25. });
  26. pdg.code.listen($.dict.doTransfer);
  27. root.find(".opt-query").on("click", function () {
  28. pdg.load();
  29. });
  30. pdg.load();
  31. root.on("click", ".icon-eye-open", function () {
  32. var $this = $(this);
  33. var demandId = $this.parent().attr("demandId");
  34. util.get("../ajax/demand/id/" + demandId, null, function (rd) {
  35. if (rd) {
  36. spa.showModal("sys_demand_edit", {
  37. data: rd,
  38. hand: function () {
  39. pdg.load()
  40. }
  41. })
  42. } else {
  43. util.alert("客户选择有误", function () {
  44. pdg.load();
  45. });
  46. }
  47. }, {});
  48. });
  49. root.on("click", ".opt-auth", function () {
  50. var demandId = $(this).parent().attr("demandId");
  51. var demandStatus = $(this).parent().attr("demandStatus");
  52. if (demandId) {
  53. if (demandStatus == "1") {
  54. util.boxMsg({
  55. title: "确认关闭",
  56. content: "您是否要关闭选中的需求!!!!!!!!!!!!!!!!!!",
  57. btns: [{
  58. caption: "关闭", hand: function () {
  59. util.post("../ajax/demand/close", {
  60. demandId: demandId,
  61. demandStatus: demandStatus
  62. }, function () {
  63. pdg.load();
  64. });
  65. }
  66. },
  67. {caption: "取消"}
  68. ]
  69. });
  70. }if (demandStatus == "0"){
  71. util.boxMsg({
  72. title: "确认打开",
  73. content: "您是否要打开选中的需求",
  74. btns: [{
  75. caption: "打开", hand: function () {
  76. util.post("../ajax/demand/close", {
  77. demandId: demandId,
  78. demandStatus: demandStatus
  79. }, function () {
  80. pdg.load();
  81. });
  82. }
  83. },
  84. {caption: "取消"}
  85. ]
  86. });
  87. }
  88. }
  89. });
  90. }
  91. };
  92. });
  93. });