You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Notice.js 4.6 KiB

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. (function () {
  2. var begin = '';
  3. var end = '';
  4. var multipleData = null;
  5. var parentparam = '';
  6. var page = {
  7. grid: null,
  8. init: function ($page, param) {
  9. begin = '';
  10. end = '';
  11. parentparam = param;
  12. multipleData = null;
  13. page.grid = $page.find('#lr_EducationalAdministrationNews_list').lrpagination({
  14. lclass: page.lclass,
  15. rows: 10, // 每页行数
  16. getData: function (param, callback) {// 获取数据 param 分页参数,callback 异步回调
  17. param.multipleData = multipleData;
  18. param.parentparam = parentparam;
  19. page.loadData(param, callback, $page);
  20. },
  21. renderData: function (_index, _item, _$item) {// 渲染数据模板
  22. return page.rowRender(_index, _item, _$item, $page);
  23. },
  24. click: function (item, $item, $et) {// 列表行点击事件
  25. if ($et.hasClass('lr-btn-danger')) {
  26. page.btnClick(item, $item, $page);
  27. }
  28. else {
  29. page.rowClick(item, $item, $page);
  30. }
  31. },
  32. btns: page.rowBtns
  33. });
  34. $page.find('#lr_EducationalAdministrationNews_btn').on('tap', function () {
  35. learun.nav.go({ path: 'EducationalAdministration/News/form', title: '新增', type: 'right' });
  36. });
  37. },
  38. lclass: 'lr-list',
  39. loadData: function (param, callback, $page) {// 列表加载后台数据
  40. var _postParam = {
  41. pagination: {
  42. rows: param.rows,
  43. page: param.page,
  44. sidx: 'F_NewsId',
  45. sord: 'DESC'
  46. },
  47. queryJson: '{}'
  48. };
  49. if (param.multipleData) {
  50. _postParam.queryJson = JSON.stringify(multipleData);
  51. }
  52. if (param.begin && param.end) {
  53. _postParam.queryJson = JSON.stringify({ StartTime: param.begin, EndTime: param.end });
  54. }
  55. if (param.parentparam) {
  56. _postParam.queryJson = JSON.stringify({ F_CategoryId:param.parentparam});
  57. }
  58. learun.httpget(config.webapi + '/learun/news/list?F_CategoryId=' + param.parentparam, _postParam, (data) => {
  59. $page.find('.lr-badge').text('0');
  60. console.log(data);
  61. if (data) {
  62. $page.find('.lr-badge').text(data.records);
  63. callback(data.rows, parseInt(data.records));
  64. }
  65. else {
  66. callback([], 0);
  67. }
  68. });
  69. },
  70. rowRender: function (_index, _item, _$item, $page) {// 渲染列表行数据
  71. _$item.addClass('lr-list-item lr-list-item-multi');
  72. _$item.append($('<p class="lr-ellipsis"><span>公告标题:</span></p>').dataFormatter({ value: _item.F_FullHead }));
  73. _$item.append($('<p class="lr-ellipsis"><span>所属类别:</span></p>').dataFormatter({ value: _item.F_Category }));
  74. _$item.append($('<p class="lr-ellipsis"><span>发布时间:</span></p>').dataFormatter({
  75. value: _item.F_ReleaseTime,
  76. type: 'datetime',
  77. dateformat: 'yyyy-MM-dd'
  78. }));
  79. _$item.append($('<p class="lr-ellipsis"><span>信息来源:</span></p>').dataFormatter({ value: _item.F_SourceName }));
  80. return '';
  81. },
  82. rowClick: function (item, $item, $page) {// 列表行点击触发方法
  83. learun.nav.go({ path: 'workspace/listdetaile', title: '详情', param: item, type: 'right' });
  84. },
  85. btnClick: function (item, $item, $page) {// 左滑按钮点击事件
  86. learun.layer.confirm('确定要删除该笔数据吗?', function (_index) {
  87. if (_index === '1') {
  88. learun.layer.loading(true, '正在删除该笔数据');
  89. learun.httppost(config.webapi + 'learun/EducationalAdministration/News/delete', item.F_NewsId, (data) => {
  90. if (data) {// 删除数据成功
  91. page.grid.reload();
  92. }
  93. learun.layer.loading(false);
  94. });
  95. }
  96. }, '智慧校园提示', ['取消', '确定']);
  97. },
  98. rowBtns: ['<a class="lr-btn-danger">删除</a>'] // 列表行左滑按钮
  99. };
  100. return page;
  101. })();