1. <template>
    2. <div :class="['page-table-wrapper', tabVue.rootClass]">
    3. <div class="table-wrapper__search" v-if="hasSearchSlot()">
    4. <table-search
    5. @handleConfirmSearch="tabVue.confirmSearch()"
    6. @handleClearSearch="tabVue.clearSearch()">
    7. <slot name="search"></slot>
    8. </table-search>
    9. </div>
    10. <div class="table-wrapper__content">
    11. <div class="table-wrapper__content--toolbar">
    12. <table-operation :parent="tabVue" :config="tabVue.OperationController">
    13. <slot name="operationLeft" slot="left" v-if="!noOperationLeftsSlots"></slot>
    14. <slot name="operationRight" slot="right" v-if="!noOperationRightsSlots"></slot>
    15. </table-operation>
    16. </div>
    17. <basic-table :parent="tabVue">
    18. <template slot="tableColumn" slot-scope="scope">
    19. <slot name="tableColumn" :row="scope.row" :columnItem="scope.columnItem"></slot>
    20. </template>
    21. <template slot="tableRowDetail" slot-scope="scope">
    22. <slot name="tableRowDetail" :row="props.row"></slot>
    23. </template>
    24. </basic-table>
    25. </div>
    26. </div>
    27. </template>
    28. <script>
    29. import { tableSearch } from '@/components/table-search';
    30. import basicTable from './basic-table';
    31. import { tableOperation } from '@/components/table-operation';
    32. import _ from 'lodash';
    33. export default {
    34. components: { tableSearch, basicTable, tableOperation },
    35. props: {
    36. parent: { /* 指定父组件的this */
    37. type: Object
    38. }
    39. },
    40. data() {
    41. return {
    42. tabVue: this.parent || this.$parent
    43. }
    44. },
    45. computed() {
    46. noOperationLeftsSlots() {
    47. return _.isEmpty(this.$slots.operationLeft);
    48. },
    49. noOperationRightsSlots() {
    50. return _.isEmpty(this.$slots.operationRight);
    51. }
    52. },
    53. methods: {
    54. /* 判断是否有搜索插槽 */
    55. hasSearchSlot() {
    56. return this.$slots.search;
    57. }
    58. }
    59. }
    60. </script>