index.stub 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div class="default-main ba-table-box">
  3. <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
  4. <!-- 表格顶部菜单 -->
  5. <!-- 自定义按钮请使用插槽,甚至公共搜索也可以使用具名插槽渲染,参见文档 -->
  6. <TableHeader
  7. :buttons="['refresh', 'add', 'edit', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
  8. :quick-search-placeholder="t('Quick search placeholder', { fields: t('{%webTranslate%}quick Search Fields') })"
  9. ></TableHeader>
  10. <!-- 表格 -->
  11. <!-- 表格列有多种自定义渲染方式,比如自定义组件、具名插槽等,参见文档 -->
  12. <!-- 要使用 el-table 组件原有的属性,直接加在 Table 标签上即可 -->
  13. <Table ref="tableRef"></Table>
  14. <!-- 表单 -->
  15. <PopupForm />
  16. </div>
  17. </template>
  18. <script setup lang="ts">
  19. import { onMounted, provide, useTemplateRef } from 'vue'
  20. import { useI18n } from 'vue-i18n'
  21. import PopupForm from './popupForm.vue'
  22. import { baTableApi } from '/@/api/common'
  23. import { defaultOptButtons } from '/@/components/table'
  24. import TableHeader from '/@/components/table/header/index.vue'
  25. import Table from '/@/components/table/index.vue'
  26. import baTableClass from '/@/utils/baTable'
  27. defineOptions({
  28. name: '{%componentName%}',
  29. })
  30. const { t } = useI18n()
  31. const tableRef = useTemplateRef('tableRef')
  32. const optButtons: OptButton[] = defaultOptButtons({%optButtons%})
  33. /**
  34. * baTable 内包含了表格的所有数据且数据具备响应性,然后通过 provide 注入给了后代组件
  35. */
  36. const baTable = new baTableClass(
  37. new baTableApi({%controllerUrl%}),
  38. {
  39. pk: '{%tablePk%}',
  40. column: [
  41. {%tableColumn%}
  42. ],
  43. dblClickNotEditColumn: {%dblClickNotEditColumn%},{%defaultOrder%}
  44. },
  45. {
  46. defaultItems: {%defaultItems%},
  47. }
  48. )
  49. provide('baTable', baTable)
  50. onMounted(() => {
  51. baTable.table.ref = tableRef.value
  52. baTable.mount()
  53. baTable.getData()?.then(() => {
  54. baTable.initSort()
  55. baTable.dragSort()
  56. })
  57. })
  58. </script>
  59. <style scoped lang="scss"></style>