billModule.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div class="bill-module-box">
  3. <div class="bill-module-form" v-if="searchConfig" v-show="!hideSearch">
  4. <by-form :propConfig="searchConfig" ref="search" />
  5. <div class="search-btn">
  6. <el-button type="primary" size="mini" icon="el-icon-search" @click="search">搜索</el-button>
  7. <el-button size="mini" icon="el-icon-refresh" @click="resert">重置</el-button>
  8. </div>
  9. </div>
  10. <div class="bill-tool" v-if="toolConfig">
  11. <by-tool :propConfig="toolConfig" ref="tool" @clickHandle="clickHandle" />
  12. </div>
  13. <div class="table" v-if="tableConfig">
  14. <by-table :propConfig="tableConfig" ref="table" v-on="$listeners" />
  15. </div>
  16. </div>
  17. </template>
  18. <script lang="ts">
  19. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  20. @Component
  21. export default class BillModule extends Vue {
  22. config : any = {}
  23. hideSearch = false
  24. @Prop()
  25. propConfig : any
  26. get searchConfig() {
  27. return this.config?.search ? this.config.search : null
  28. }
  29. get toolConfig() {
  30. return this.config?.tool ? this.config.tool : null
  31. }
  32. get tableConfig() {
  33. return this.config?.table ? this.config.table : null
  34. }
  35. created() {
  36. if (this.propConfig) {
  37. this.setConfig(this.propConfig)
  38. }
  39. }
  40. setConfig(c : any) {
  41. this.config = c ? c : {}
  42. }
  43. getConfig() {
  44. return (this as any).$lodash.cloneDeep(this.config)
  45. }
  46. //工具栏按钮点击操作
  47. clickHandle(n : string) {
  48. if (n == 'toggleSearch') {
  49. this.hideSearch = !this.hideSearch
  50. } else {
  51. this.$emit('clickHandle', n)
  52. }
  53. }
  54. //获取搜索值
  55. getSearchValue() {
  56. let value : any = {}
  57. if (this.$refs.search) {
  58. value = (this.$refs.search as any).getValue()
  59. }
  60. return value
  61. }
  62. //获取表格数据
  63. getTableValue() {
  64. let data : Array<any> = [];
  65. if (this.$refs.table) {
  66. data = (this.$refs.table as any).getValue();
  67. }
  68. return data;
  69. }
  70. //获取已选中表格数据
  71. getSelectTable() {
  72. let data : Array<any> = [];
  73. if (this.$refs.table) {
  74. data = (this.$refs.table as any).getSelectData();
  75. }
  76. return data;
  77. }
  78. //清除搜索条件
  79. clearSearch() {
  80. (this.$refs.search as any).clearValue();
  81. }
  82. search() {
  83. this.$emit('search', this.getSearchValue());
  84. }
  85. resert() {
  86. if (this.$refs.search) {
  87. (this.$refs.search as any).setValue({})
  88. }
  89. this.$emit('resert');
  90. }
  91. //设置表格数据
  92. setTableValue(data : Array<any>) {
  93. if (this.$refs.table) {
  94. (this.$refs.table as any).setValue(data)
  95. }
  96. }
  97. setPage(page : any) {
  98. if (this.$refs.table) {
  99. (this.$refs.table as any).setPage(page)
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .bill-module-box {
  106. width: 100%;
  107. .bill-tool {
  108. width: 100%;
  109. padding-bottom: 16px;
  110. }
  111. .bill-module-form {
  112. padding-bottom: 8px;
  113. .search-btn {
  114. width: 100%;
  115. display: flex;
  116. justify-content: flex-end;
  117. }
  118. }
  119. }
  120. </style>