topiccategory.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. $(function () {
  2. $("#jqGrid").Grid({
  3. url: '../topiccategory/list',
  4. rownumWidth:60,
  5. colModel: [
  6. {label: 'id', name: 'id', index: 'id', key: true, hidden: true},
  7. {label: '活动类别主题', name: 'title', index: 'title', width: 80},
  8. {
  9. label: '活动类别图片链接', name: 'picUrl', index: 'pic_url', width: 80, formatter: function (value) {
  10. return transImg(value);
  11. }
  12. }]
  13. });
  14. });
  15. var vm = new Vue({
  16. el: '#rrapp',
  17. data: {
  18. showList: true,
  19. title: null,
  20. topicCategory: {picUrl: ''},
  21. ruleValidate: {
  22. title: [
  23. {required: true, message: '活动类别主题不能为空', trigger: 'blur'}
  24. ],
  25. picUrl: [
  26. {required: true, message: '活动类别图片不能为空', trigger: 'blur'}
  27. ]
  28. },
  29. q: {
  30. title: ''
  31. }
  32. },
  33. methods: {
  34. query: function () {
  35. vm.reload();
  36. },
  37. add: function () {
  38. vm.showList = false;
  39. vm.title = "新增";
  40. vm.topicCategory = {picUrl: ''};
  41. },
  42. update: function (event) {
  43. var id = getSelectedRow("#jqGrid");
  44. if (id == null) {
  45. return;
  46. }
  47. vm.showList = false;
  48. vm.title = "修改";
  49. vm.getInfo(id)
  50. },
  51. saveOrUpdate: function (event) {
  52. var url = vm.topicCategory.id == null ? "../topiccategory/save" : "../topiccategory/update";
  53. Ajax.request({
  54. type: "POST",
  55. url: url,
  56. contentType: "application/json",
  57. params: JSON.stringify(vm.topicCategory),
  58. successCallback: function (r) {
  59. alert('操作成功', function (index) {
  60. vm.reload();
  61. });
  62. }
  63. });
  64. },
  65. del: function (event) {
  66. var ids = getSelectedRows("#jqGrid");
  67. if (ids == null) {
  68. return;
  69. }
  70. confirm('确定要删除选中的记录?', function () {
  71. Ajax.request({
  72. type: "POST",
  73. url: "../topiccategory/delete",
  74. contentType: "application/json",
  75. params: JSON.stringify(ids),
  76. successCallback: function (r) {
  77. alert('操作成功', function (index) {
  78. vm.reload();
  79. });
  80. }
  81. });
  82. });
  83. },
  84. getInfo: function (id) {
  85. Ajax.request({
  86. url: "../topiccategory/info/" + id,
  87. async: true,
  88. successCallback: function (r) {
  89. vm.topicCategory = r.topicCategory;
  90. }
  91. });
  92. },
  93. reload: function (event) {
  94. vm.showList = true;
  95. var page = $("#jqGrid").jqGrid('getGridParam', 'page');
  96. $("#jqGrid").jqGrid('setGridParam', {
  97. postData: {'title': vm.q.title},
  98. page: page
  99. }).trigger("reloadGrid");
  100. vm.handleReset('formValidate');
  101. },
  102. handleSuccess: function (res, file) {
  103. vm.topicCategory.picUrl = file.response.url;
  104. },
  105. handleFormatError: function (file) {
  106. this.$Notice.warning({
  107. title: '文件格式不正确',
  108. desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
  109. });
  110. },
  111. handleMaxSize: function (file) {
  112. this.$Notice.warning({
  113. title: '超出文件大小限制',
  114. desc: '文件 ' + file.name + ' 太大,不能超过 2M。'
  115. });
  116. },
  117. eyeImage: function () {
  118. var url = vm.topicCategory.picUrl;
  119. eyeImage(url);
  120. },
  121. handleSubmit: function (name) {
  122. handleSubmitValidate(this, name, function () {
  123. vm.saveOrUpdate()
  124. });
  125. },
  126. handleReset: function (name) {
  127. handleResetForm(this, name);
  128. }
  129. }
  130. });