table-page.hbs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div>
  3. <div class="app-container account-container" v-loading="viewLoading">
  4. <div class="toolbar-container">
  5. <AccToolBar
  6. ref="toolbar"
  7. direction="left"
  8. :default-show-buttons="['Refresh']"
  9. @refreshEvent="refreshEvent"
  10. />
  11. </div>
  12. <div class="scroll-box-container">
  13. <div class="body-container">
  14. <vxe-grid
  15. border
  16. resizable
  17. auto-resize
  18. show-footer
  19. highlight-hover-row
  20. highlight-current-row
  21. show-overflow="tooltip"
  22. ref="xGrid"
  23. max-height="800"
  24. row-id="id"
  25. align="left"
  26. size="medium"
  27. :loading="tableLoading"
  28. :columns="tableColumn"
  29. :form-config="tableForm"
  30. :pager-config="tablePage"
  31. :proxy-config="tableProxy"
  32. :cell-class-name="cellClassName"
  33. >
  34. <!-- template插槽 -->
  35. </vxe-grid>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import AccToolBar from '@/components/AccToolBar'
  43. export default {
  44. name: '{{ properCase name }}',
  45. components: {
  46. AccToolBar
  47. },
  48. data() {
  49. return {
  50. viewLoading: false,
  51. tableLoading: false,
  52. tableForm: {
  53. data: {
  54. name: ''
  55. },
  56. items: [
  57. {
  58. visible: true,
  59. sapn: 4,
  60. field: 'name',
  61. title: '',
  62. itemRender: {
  63. name: '$input'
  64. }
  65. }
  66. ],
  67. display: 'outline'
  68. },
  69. tableColumn: [
  70. { type: 'seq', width: 50 },
  71. {
  72. visible: true,
  73. align: 'center',
  74. title: this.$t('table.body.status'),
  75. field: 'status',
  76. slots: {
  77. default: 'status_default'
  78. }
  79. },
  80. {
  81. visible: true,
  82. title: this.$t('basic.table.body.operate'),
  83. align: 'center',
  84. field: 'operate',
  85. slots: {
  86. default: 'operate_default'
  87. }
  88. }
  89. ],
  90. tableProxy: {
  91. autoLoad: true, // 是否自动加载查询数据
  92. seq: true, // 启用动态序号代理
  93. sort: true, // 启用排序代理
  94. filter: true, // 启用筛选代理
  95. form: true, // 启用表单代理
  96. props: {
  97. result: 'results',
  98. total: 'count'
  99. },
  100. ajax: {
  101. query: ({ page, sort, filters, form }) => {
  102. const pageParams = {
  103. page: page.currentPage,
  104. page_size: page.pageSize
  105. }
  106. const data = Object.assign(pageParams, this.tableForm.data)
  107. console.log(data)
  108. }
  109. }
  110. },
  111. tablePage: {
  112. pageSize: 20,
  113. pageSizes: [10, 20, 50, 100, 200, 500, 1000]
  114. }
  115. }
  116. },
  117. watch: {
  118. },
  119. created() {
  120. },
  121. mounted() {
  122. },
  123. methods: {
  124. // 数字为负数的,显示为红色
  125. cellClassName({ row, rowIndex, column, columnIndex }) {
  126. const field = column.property
  127. const cellValue = row[field]
  128. if (typeof cellValue === 'number' && cellValue < 0) {
  129. return 'col-red'
  130. }
  131. },
  132. refreshEvent() {
  133. this.$refs.xGrid.commitProxy('query')
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. </style>