index.vue 2.8 KB

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