index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="app-container">
  3. <SearchBoxVue :data="searchData" :objects="objects" :departments="departments" @search="handleSearch" @reset="handleReset" />
  4. <TableBoxVue :loading="loading" :data="tableData" :objects="objects" :departments="departments" @refresh="handleRefresh" />
  5. <pagination
  6. :auto-scroll="false"
  7. :total="paginationData.total"
  8. :page="paginationData.page"
  9. :limit="paginationData.limit"
  10. @pagination="handlePagination"
  11. />
  12. </div>
  13. </template>
  14. <script>
  15. import SearchBoxVue from './components/SearchBox.vue'
  16. import TableBoxVue from './components/TableBox.vue'
  17. import { get_select_object, get_select_department, get_rule_list } from '@/api/rule/config'
  18. export default {
  19. components: {
  20. SearchBoxVue,
  21. TableBoxVue
  22. },
  23. data() {
  24. return {
  25. loading: false,
  26. searchData: {
  27. changjing: [],
  28. department: [],
  29. object: '',
  30. type: '',
  31. is_not: '',
  32. description: '',
  33. score: undefined,
  34. error_level: '',
  35. status: ''
  36. },
  37. tableData: [],
  38. paginationData: {
  39. total: 0,
  40. page: 1,
  41. limit: 10
  42. },
  43. objects: [],
  44. departments: []
  45. }
  46. },
  47. created() {
  48. this.getObjectData()
  49. this.getDepartmentData()
  50. this.getList()
  51. },
  52. methods: {
  53. // 质控项目
  54. getObjectData() {
  55. get_select_object().then(res => {
  56. const { p } = res
  57. this.objects = Array.isArray(p) ? p : []
  58. console.log(this.objects)
  59. })
  60. },
  61. // 质控科室
  62. getDepartmentData() {
  63. get_select_department().then(res => {
  64. const { p } = res
  65. this.departments = Array.isArray(p) ? p : []
  66. })
  67. },
  68. handleRefresh() {
  69. this.getList()
  70. },
  71. async getList() {
  72. const { page, limit } = this.paginationData
  73. const params = {
  74. ...this.searchData,
  75. page,
  76. page_size: limit
  77. }
  78. this.loading = true
  79. get_rule_list(params).then(res => {
  80. const { p } = res
  81. this.paginationData.total = p.count
  82. this.tableData = p.list
  83. }).catch(error => {
  84. console.log(error)
  85. }).finally(() => {
  86. this.loading = false
  87. })
  88. },
  89. handlePagination(param) {
  90. this.paginationData.page = param.page
  91. this.paginationData.limit = param.limit
  92. this.getList()
  93. },
  94. handleSearch() {
  95. this.paginationData.page = 1
  96. this.getList()
  97. },
  98. handleReset() {
  99. this.searchData = {
  100. changjing: [],
  101. department: [],
  102. object: '',
  103. type: '',
  104. is_not: '',
  105. description: '',
  106. score: undefined,
  107. error_level: '',
  108. status: ''
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. </style>