index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div class="print-count">
  3. <module-view :propConfig="config" ref="view" v-loading="load" @pagination="pagination" @onRefresh="getList" @resert="queryList" @search="queryList"/>
  4. </div>
  5. </template>
  6. <script lang="ts">
  7. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  8. import { query} from '@/api/printCount'
  9. @Component({components:{}})
  10. export default class PrintCount extends Vue {
  11. load=false;
  12. isSearch=false
  13. timeNum = 0;
  14. config:any={
  15. attr:{
  16. calculateH:true
  17. },
  18. search:{
  19. attr:{
  20. size:'small'
  21. },
  22. columns:[
  23. [{
  24. span:8,
  25. label:'模板名称',
  26. prop:'templateName',
  27. component:'by-input',
  28. compConfig:{
  29. attr:{
  30. clearable:true
  31. }
  32. }
  33. },{
  34. span:8,
  35. label:'外部用户标识',
  36. prop:'userName',
  37. component:'user-modal'
  38. }]
  39. ]
  40. },
  41. tool:{
  42. tools:{
  43. search:true,
  44. refresh:true
  45. }
  46. },
  47. table:{
  48. attr:{
  49. size:'mini',
  50. seq:true,
  51. checkbox:true
  52. },
  53. columns:[{
  54. title:'外部用户标识',
  55. field:'userName',
  56. width:130
  57. },{
  58. title:'模板名称',
  59. field:'templateName'
  60. },{
  61. title:'打印次数',
  62. field:'printCount',
  63. width:130
  64. },{
  65. title:'最后一次打印时间',
  66. field:'lastTime',
  67. width:160
  68. }]
  69. }
  70. }
  71. mounted(){
  72. this.getList();
  73. }
  74. //分页
  75. pagination(){
  76. if(this.isSearch){
  77. this.queryList();
  78. }else{
  79. this.getList()
  80. }
  81. }
  82. //列表请求(只有分页,不包含搜素条件)
  83. getList(){
  84. if(!this.$refs.view){
  85. if(this.timeNum > 5){
  86. return
  87. }
  88. setTimeout(()=>{
  89. this.getList()
  90. },500)
  91. this.timeNum ++;
  92. return
  93. }
  94. this.isSearch = false;
  95. let data = (this.$refs.view as any).getPage();
  96. delete data.total;
  97. this.requestList(data);
  98. }
  99. //列表请求(包含分页和搜素条件)
  100. queryList(){
  101. this.isSearch = true;
  102. let data = (this.$refs.view as any).getQuery();
  103. delete data.total;
  104. this.requestList(data);
  105. }
  106. requestList(data:any){
  107. this.load = true;
  108. query(data).then((res:any) => {
  109. this.load = false;
  110. (this.$refs.view as any).setTableValue(res.data.records);
  111. let page = {
  112. pageNo: res.data.current, //当前页
  113. pageSize: res.data.size, //每页条数
  114. total: res.data.total //总条数
  115. };
  116. (this.$refs.view as any).setPage(page)
  117. }).catch(()=>{
  118. this.load = false;
  119. })
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .print-count{
  125. width: 100%;
  126. height: 100%;
  127. overflow-y: hidden;
  128. }
  129. </style>