taskManage.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. $(function () {
  2. /*任务状态*/
  3. $.ajax({
  4. type: "POST",
  5. url: baseURL + "sys/dict/infoList/task_status",
  6. contentType: "application/json",
  7. async: false,
  8. success: function(r){
  9. if(r.code == 0){
  10. vm.dict = r.dictList;
  11. }else{
  12. layer.alert("读取字典项失败");
  13. }
  14. }
  15. });
  16. /*任务类型*/
  17. $.ajax({
  18. type: "POST",
  19. url: baseURL + "sys/dict/infoList/task_type",
  20. contentType: "application/json",
  21. async: false,
  22. success: function(r){
  23. if(r.code == 0){
  24. vm.type = r.dictList;
  25. }else{
  26. layer.alert("读取字典项失败");
  27. }
  28. }
  29. });
  30. $("#jqGrid").jqGrid({
  31. url: baseURL + 'qmjz/taskManage/page',
  32. datatype: "json",
  33. colModel: [
  34. { label: 'id', name: 'id', index: 'id', width: 50, key: true ,hidden: true},
  35. { label: '任务名称', name: 'taskName', index: 'taskName', width: 70 },
  36. { label: '任务类型', name: 'taskType', index: 'taskType', width: 60, sortable: false,formatter: function (cellvalue, options, rowdata) {
  37. for (const item of vm.type) {
  38. if(cellvalue == item.value) {
  39. return item.code
  40. }
  41. }
  42. }},
  43. { label: '任务积分', name: 'taskScore', index: 'taskScore', width: 60 },
  44. { label: '任务状态', name: 'taskStatus', index: 'taskStatus', width: 80, sortable: false,formatter: function (cellvalue, options, rowdata) {
  45. for (const item of vm.dict) {
  46. if(cellvalue == item.value) {
  47. return item.code
  48. }
  49. }
  50. }},
  51. ],
  52. viewrecords: true,
  53. height: 385,
  54. rowNum: 10,
  55. rowList : [10,30,50],
  56. rownumbers: true,
  57. rownumWidth: 25,
  58. autowidth:true,
  59. multiselect: true,
  60. pager: "#jqGridPager",
  61. jsonReader : {
  62. root: "list",
  63. page: "currPage",
  64. total: "totalPage",
  65. records: "totalCount"
  66. },
  67. prmNames : {
  68. page:"pageNum",
  69. rows:"pageSize"
  70. // order: "order"
  71. },
  72. gridComplete:function(){
  73. //隐藏grid底部滚动条
  74. $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
  75. }
  76. });
  77. upload(1,'images','images/*');
  78. });
  79. var vm = new Vue({
  80. el:'#rrapp',
  81. data:{
  82. q:{
  83. taskName: '',
  84. taskScore:'',
  85. taskStatus:''
  86. },
  87. dict: [],
  88. type: [],
  89. work: {},
  90. showList: true,
  91. },
  92. watch: {
  93. colleges: function() {
  94. this.$nextTick(function(){
  95. $('#college').selectpicker('refresh');
  96. })
  97. },
  98. qstaffguids:function () {
  99. this.$nextTick(function(){
  100. $('#qstaffguid').selectpicker('refresh');
  101. })
  102. }
  103. },
  104. methods: {
  105. init:function () {
  106. vm.q.work= {};
  107. },
  108. refresh: function () {
  109. vm.init();
  110. location.reload();
  111. },
  112. query: function () {
  113. vm.reload(1);
  114. },
  115. update: function (event) {
  116. var id = getSelectedRow();
  117. if(id == null){
  118. return ;
  119. }
  120. vm.showList = false;
  121. vm.getInfo(id)
  122. },
  123. getInfo: function(id){
  124. $.get(baseURL + "qmjz/taskManage/info/"+id, function(r){
  125. vm.work = r.data;
  126. });
  127. },
  128. reload: function (event) {
  129. vm.showList = true;
  130. var page;
  131. if (event == 1){
  132. page = 1;
  133. }else {
  134. page = $("#jqGrid").jqGrid('getGridParam','page');
  135. }
  136. $("#jqGrid").jqGrid('setGridParam',{
  137. postData:{'taskName': vm.q.taskName,'taskScore':vm.q.taskScore,'taskStatus': vm.q.taskStatus},
  138. page:page
  139. }).trigger("reloadGrid");
  140. },
  141. point() {
  142. var width = ($(window).width() * 0.6);
  143. var height = ($(window).height() - 50);
  144. layui.use(['layer', 'form'], function () {
  145. var $ = layui.jquery, layer = layui.layer;
  146. layer.open({
  147. type: 2,
  148. area: [width + 'px', height + 'px'],
  149. fix: false, //不固定
  150. maxmin: true,
  151. shadeClose: true,
  152. resize: false,
  153. full: true,
  154. shade: 0.4,
  155. title: '积分抵扣',
  156. anim: 3,
  157. content: '../qyh/point.html',
  158. end: function () {
  159. // vm.reload();
  160. // console.log(11)
  161. }
  162. });
  163. })
  164. },
  165. }
  166. });
  167. layui.use([ 'layer', 'form'],function() {
  168. var $ = layui.jquery, layer = layui.layer, form = layui.form;
  169. form.on('submit(go)', function(data){
  170. $.ajax({
  171. type: "POST",
  172. url: baseURL + 'qmjz/taskManage/update',
  173. contentType: "application/json",
  174. data: JSON.stringify(vm.work),
  175. success: function(r){
  176. if(r.code === 0){
  177. layer.msg("操作成功", {icon: 1});
  178. vm.reload();
  179. }else{
  180. layer.alert(r.msg);
  181. }
  182. }
  183. });
  184. return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
  185. });
  186. });