user.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form','echarts'], function ($, undefined, Backend, Table, Form,Echarts) {
  2. var Controller = {
  3. index: async function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'user/user/index',
  8. add_url: 'user/user/add',
  9. edit_url: 'user/user/edit',
  10. del_url: 'user/user/del',
  11. multi_url: 'user/user/multi',
  12. table: 'user',
  13. }
  14. });
  15. var table = $("#table");
  16. table.on('load-success.bs.table', function (e, data) {
  17. $("#right_per").text(`${data.right_per}%`);
  18. });
  19. let levels = await $.getJSON('user/user/levels')
  20. // 初始化表格
  21. table.bootstrapTable({
  22. url: $.fn.bootstrapTable.defaults.extend.index_url,
  23. pk: 'id',
  24. sortName: 'user.id',
  25. searchFormVisible:true,
  26. columns: [
  27. [
  28. //{checkbox: true},
  29. {field: 'id', title: __('Id'), sortable: true},
  30. //{field: 'group.name', title: __('Group')},
  31. {field: 'username', title: __('Username'), operate: 'LIKE'},
  32. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  33. {field: 'mobile', title: __('手机号'), operate: 'LIKE'},
  34. {
  35. field: 'avatar',
  36. title: __('头像'),
  37. events: Table.api.events.image,
  38. formatter: Table.api.formatter.image,
  39. operate: false
  40. },
  41. {
  42. field: 'gender',
  43. title: __('性别'),
  44. searchList: {1: __('男'), 2: __('Female')},
  45. formatter: Table.api.formatter.label
  46. },
  47. {
  48. field: 'age',
  49. title: __('年龄'),
  50. operate: "BETWEEN"
  51. },
  52. /*{
  53. field: 'city_name',
  54. title: __('地区'),
  55. searchList: function (column) {
  56. return Template('sourcetpl', {})
  57. }
  58. },*/
  59. {
  60. field: 'jointime',
  61. title: __('Jointime'),
  62. formatter: Table.api.formatter.datetime,
  63. operate: 'RANGE',
  64. addclass: 'datetimerange',
  65. sortable: true
  66. },
  67. //{field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
  68. {
  69. field: 'status',
  70. title: __('Status'),
  71. formatter: Table.api.formatter.status,
  72. searchList: {normal: __('Normal'), hidden: __('Hidden')}
  73. },
  74. {
  75. field: 'operate',
  76. title: __('Operate'),
  77. table: table,
  78. events: Table.api.events.operate,
  79. formatter: Table.api.formatter.operate,
  80. buttons:[
  81. ]
  82. }
  83. ]
  84. ],
  85. onLoadSuccess(){
  86. $(".btn-editone").data("area", ["800px","90%"]);
  87. }
  88. });
  89. // 为表格绑定事件
  90. Table.api.bindevent(table);
  91. },
  92. add: function () {
  93. Controller.api.bindevent();
  94. },
  95. edit: function () {
  96. Controller.api.bindevent();
  97. },
  98. rate(){
  99. Controller.api.bindevent()
  100. let e=Echarts.init(document.getElementById('charts'))
  101. let option = {
  102. tooltip: {
  103. trigger: 'axis',
  104. formatter:(p)=>{
  105. let a=p[0]
  106. return `日期:${a.name}<br>正确率:${a.value}%`
  107. }
  108. },
  109. xAxis: {
  110. type: 'category',
  111. data: x
  112. },
  113. yAxis: {
  114. type: 'value'
  115. },
  116. series: [
  117. {
  118. data: value,
  119. type: 'line',
  120. label: {
  121. formatter:(a)=>{
  122. return `日期:${a.name}<br>正确率:${a.value}%`
  123. }
  124. }
  125. }
  126. ]
  127. };
  128. e.setOption(option)
  129. $(window).resize(function () {
  130. e.resize();
  131. });
  132. $("#search").on('click',function (){
  133. let time=$('.form-time').val()
  134. if(!time){
  135. layer.msg('请选择时间')
  136. return
  137. }
  138. location.href=`${location.origin}${location.pathname}?time=${time}`
  139. })
  140. },
  141. api: {
  142. bindevent: function () {
  143. Form.api.bindevent($("form[role=form]"));
  144. }
  145. }
  146. };
  147. return Controller;
  148. });