hongluan-business-ui
Version:
Hongluan Business Component Library for Vue 3
1 lines • 10.6 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/simple-table-list/src/index.vue"],"sourcesContent":["<template>\n <div v-loading=\"loading\" :class=\"prefix + '-simple-table-list'\" :style=\"[padding ? `--table-list-padding: ${padding}` : '']\">\n <slot v-if=\"searchbar.show\" name=\"searchbar\">\n <hb-table-searchbar ref=\"searchbarRef\" gap=\"var(--sm)\" v-bind=\"searchbar\" @change=\"onSearchbarChanged\">\n <template v-for=\"name in selectorSlots\" #[name]=\"colData\">\n <slot :name=\"name\" v-bind=\"colData\"> </slot>\n </template>\n <template #prefix>\n <slot name=\"searchbar-prefix\"></slot>\n </template>\n <template #suffix>\n <slot name=\"searchbar-suffix\"></slot>\n </template>\n </hb-table-searchbar>\n </slot>\n <slot name=\"toolbar\">\n <hb-table-toolbar ref=\"toolbarRef\" v-bind=\"tableToolbar\">\n <template #extra-after>\n <slot name=\"toolbar-extra-after\"></slot>\n </template>\n <template #extra-before>\n <slot name=\"toolbar-extra-before\"></slot>\n </template>\n <template #action-icon=\"{ item }\">\n <slot name=\"toolbar-action-icon\" :item=\"item\"></slot>\n </template>\n </hb-table-toolbar>\n </slot>\n <hl-scrollbar v-bind=\"scrollbarProps\">\n <hl-simple-table\n ref=\"simpleTableRef\"\n v-bind=\"tableProps\"\n :cols=\"cols\"\n :data=\"tableData\"\n @row-click=\"(...args) => $emit('row-click', ...args)\"\n @cell-click=\"(...args) => $emit('cell-click', ...args)\"\n @expand=\"(...args) => $emit('expand', ...args)\"\n @sort-change=\"(...args) => $emit('sort-change', ...args)\"\n >\n <template v-for=\"col in slotCols\" #[col.slotName]=\"colData\">\n <slot :name=\"col.slotName\" v-bind=\"colData\"> </slot>\n </template>\n <template v-for=\"col in headerSlotCols\" #[col.headerSlotName]=\"colData\">\n <slot :name=\"col.headerSlotName\" v-bind=\"colData\"> </slot>\n </template>\n <template v-for=\"col in filterSlotCols\" #[col.filter.slotName]=\"colData\">\n <slot :name=\"col.filter.slotName\" v-bind=\"colData\"> </slot>\n </template>\n <template v-for=\"col in expandSlotCols\" #[col.expand.slotName]=\"colData\">\n <slot :name=\"col.expand.slotName\" v-bind=\"colData\"> </slot>\n </template>\n <template #empty>\n <slot name=\"empty\">\n <span>{{ t('hl.table.emptyText') }}</span>\n </slot>\n </template>\n <template #unknown>\n <slot name=\"unknown\">\n </slot>\n </template>\n </hl-simple-table>\n </hl-scrollbar>\n <slot v-if=\"pagination.show\" name=\"pagination\">\n <hl-pagination\n v-if=\"tableData?.length > 0\"\n ref=\"paginationRef\"\n :page-size=\"pagination.pageSize\"\n :current-page=\"pagination.currentPage\"\n :total=\"pagination.total\"\n layout=\"sizes, slot, prev, pager, next, jumper\"\n justify=\"between\"\n @current-change=\"handleCurrentChange\"\n @size-change=\"handleSizeChange\"\n >\n <div style=\"width: 100%\"></div>\n </hl-pagination>\n </slot>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, ref } from 'vue'\nimport { HlPagination, HlSimpleTable, HlLoading, HlScrollbar, useLocale } from 'hongluan-ui'\nimport HbTableToolbar from '@hongluan-business-ui/components/table-toolbar'\nimport HbTableSearchbar from '@hongluan-business-ui/components/table-searchbar'\nimport { usePrefix } from '@hongluan-business-ui/utils/util'\n\nimport type { PropType } from 'vue'\nimport type { TableToolbar } from '@hongluan-business-ui/components/table-list/src/table-list'\n\nexport default defineComponent({\n name: 'SimpleTableList',\n components: {\n HbTableToolbar,\n HbTableSearchbar,\n HlSimpleTable,\n HlPagination,\n HlScrollbar,\n },\n directives: {\n loading: HlLoading.directive,\n },\n props: {\n loading: {\n type: Boolean,\n default: false,\n },\n tableProps: {\n type: Object,\n default: () => ({\n size: '',\n }),\n },\n scrollbarProps: {\n type: Object,\n default: () => ({}),\n },\n tableData: {\n type: Array as PropType<unknown[]>,\n default: () => [],\n },\n cols: {\n type: Array as PropType<unknown[]>,\n default: () => [],\n },\n searchbar: {\n type: Object,\n default: () => ({\n show: true,\n searcher: {\n show: true,\n placeholder: '请输入搜索条件',\n },\n }),\n },\n toolbar: {\n type: Object as PropType<TableToolbar>,\n default: () => ({}),\n },\n pagination: {\n type: Object,\n default: () => ({\n show: true,\n total: 0,\n pageSize: 10,\n currentPage: 1,\n }),\n },\n padding: {\n type: String,\n default: '',\n },\n },\n emits: ['cell-click', 'current-change', 'searchbar-change', 'size-change', 'row-click', 'expand', 'sort-change'],\n setup(props, { emit }) {\n const { t } = useLocale()\n const { prefix } = usePrefix()\n const searchbarRef = ref()\n const toolbarRef = ref()\n const simpleTableRef = ref()\n const paginationRef = ref()\n\n const getSlotCols = (cols: any, filter: (col: any) => boolean, result: any[]) => {\n cols.forEach(col => {\n if (filter(col) && shouldShowCol(col)) {\n result.push(col)\n }\n if (col.children && Array.isArray(col.children)) {\n getSlotCols(col.children, filter, result)\n }\n })\n }\n\n const slotCols = computed(() => {\n const result = []\n getSlotCols(props.cols, col => col.slotName, result)\n return result\n })\n const headerSlotCols = computed(() => {\n const result = []\n getSlotCols(props.cols, col => col.headerSlotName, result)\n return result\n })\n const filterSlotCols = computed(() => {\n const result = []\n getSlotCols(props.cols, col => col.filter?.slotName, result)\n return result\n })\n const expandSlotCols = computed(() => {\n const result = []\n getSlotCols(props.cols, col => col.expand?.slotName, result)\n return result\n })\n const selectorSlots = computed(() => {\n return props.searchbar.selector?.items?.map(s => s.slotName) ?? []\n })\n const tableToolbar = computed(() => {\n return {\n selection: {\n show: props.toolbar.showSelectionText,\n count: props.toolbar.selectionCount,\n total: props.pagination.total,\n },\n action: props.toolbar.action,\n extra: {\n showColConfig: 'showColConfig' in props.toolbar ? props.toolbar.showColConfig : true,\n colConfig: {\n cols: props.cols,\n colLabelField: 'title',\n },\n },\n }\n })\n\n const shouldShowCol = (col: { $show$: boolean; }) => {\n return !('$show$' in col) || col.$show$\n }\n const onSearchbarChanged = (urlParams: string, mapParams: Record<string, unknown>, originalParams: Record<string, unknown>) => {\n emit('searchbar-change', urlParams, mapParams, originalParams)\n }\n const handleCurrentChange = currentPage => {\n emit('current-change', currentPage)\n }\n const handleSizeChange = size => {\n emit('size-change', size)\n }\n\n return {\n t,\n prefix,\n searchbarRef,\n toolbarRef,\n simpleTableRef,\n paginationRef,\n slotCols,\n headerSlotCols,\n filterSlotCols,\n expandSlotCols,\n selectorSlots,\n tableToolbar,\n onSearchbarChanged,\n handleCurrentChange,\n handleSizeChange,\n }\n },\n})\n</script>\n"],"names":["_withCtx","_createSlots"],"mappings":";;;;;;;AA0FA,MAAK,YAAa,gBAAa;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAEF,YAAY;AAAA,IACV,SAAS,UAAU;AAAA;AAAA,EAErB,OAAO;AAAA,IACL,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA;AAAA,IAEX,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAO,QACd,MAAM;AAAA;AAAA;AAAA,IAGV,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,SAAS;AAAO;AAAA,IAElB,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS,MAAM;AAAA;AAAA,IAEjB,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS,MAAM;AAAA;AAAA,IAEjB,WAAW;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAO,QACd,MAAM;AAAA,QACN,UAAU;AAAA,UACR,MAAM;AAAA,UACN,aAAa;AAAA;AAAA;AAAA;AAAA,IAInB,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAO;AAAA,IAElB,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAO,QACd,MAAM;AAAA,QACN,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa;AAAA;AAAA;AAAA,IAGjB,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA;AAAA;A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