index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="workSpace">
  3. <searchForm ref='searchForm' :keys="['userName']" @on-search='onSearch'> </searchForm>
  4. <VaCard tag="b" class="table">
  5. <div class="va-table-responsive">
  6. <VaDataTable :items="users" :columns="columns" :loading="loading">
  7. <template #cell(clockTime)="{ value }">
  8. {{getTime(value)}}
  9. </template>
  10. <template #cell(clockStatusName)="{ rowData }">
  11. <VaBadge
  12. v-if='rowData.clockStatus ==1'
  13. :text="rowData.clockStatusName"
  14. color="success"
  15. class="mr-2"
  16. />
  17. <VaBadge
  18. v-else
  19. :text="rowData.clockStatusName"
  20. color="danger"
  21. class="mr-2"
  22. />
  23. </template>
  24. </VaDataTable>
  25. </div>
  26. <div class="pagination">
  27. <VaPagination
  28. @click="update"
  29. v-model="pageInfo.pageNum"
  30. :total="pageInfo.total"
  31. :page-size="pageInfo.pageSize"
  32. :visible-pages="4"
  33. class="justify-center sm:justify-start"
  34. />
  35. </div>
  36. </VaCard>
  37. </div>
  38. </template>
  39. <script>
  40. import searchForm from '../module/searchForm.vue'
  41. import dict from '../../../common/dict'
  42. import moment from 'moment'
  43. export default {
  44. name: 'index',
  45. components: {
  46. searchForm,
  47. },
  48. mounted() {
  49. this.getList()
  50. },
  51. methods:{
  52. onSearch(){
  53. this.pageInfo.pageNum = 1
  54. this.getList()
  55. },
  56. update(){
  57. this.getList()
  58. },
  59. getTime(time){
  60. return moment(new Date(parseInt(time))).format('yyyy-MM-DD HH:mm:ss')
  61. },
  62. getList(){
  63. let params = {
  64. pageNum: Math.ceil(this.pageInfo.pageNum / this.pageInfo.pageSize),
  65. pageSize: this.pageInfo.pageSize,
  66. userName: this.$refs.searchForm.form.userName,
  67. }
  68. if( this.$refs.searchForm.form.clockTime!=null){
  69. params.clockTime = this.$refs.searchForm.form.clockTime.getTime()
  70. }
  71. this.$api.getWorkClockList(params).then(res=>{
  72. this.users = res.result.records
  73. this.pageInfo.total = res.result.total
  74. })
  75. },
  76. },
  77. data() {
  78. return {
  79. pageInfo:{
  80. ...dict.pageInfo
  81. },
  82. users:[],
  83. columns:[
  84. { key: 'name', label: '员工姓名' },
  85. { key: 'clockAddr', label: '打卡地址' },
  86. { key: 'clockTime', label: '打卡时间' },
  87. { key: 'clockTypeName', label: '打卡类型' },
  88. { key: 'clockStatusName', label: '打卡状态' },
  89. ],
  90. loading:false
  91. }
  92. },
  93. }
  94. </script>
  95. <style scoped lang="less">
  96. .workSpace {
  97. width: 100%;
  98. flex: 1;
  99. }
  100. .table {
  101. margin-top: 20px;
  102. width: 100%;
  103. }
  104. .va-table-responsive {
  105. width: 100%;
  106. }
  107. .va-table {
  108. width: 100%;
  109. }
  110. .pagination {
  111. display: flex;
  112. justify-content: center;
  113. margin-top: 30px;
  114. margin-bottom: 10px;
  115. }
  116. </style>