¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div class="hxlh-table"> |
| | | <vxe-grid |
| | | ref="vxeTable" |
| | | :show-header-overflow="true" |
| | | :show-overflow="showOverflow" |
| | | :stripe="true" |
| | | :border="true" |
| | | :show-footer="showfooter" |
| | | header-align="center" |
| | | highlight-hover-column |
| | | highlight-hover-row |
| | | resizable |
| | | :loading="loading" |
| | | :pager-config="tablePage" |
| | | :form-config="tableForm" |
| | | :columns="columns" |
| | | :data.sync="data" |
| | | :checkbox-config="checkboxConfig" |
| | | :height="height" |
| | | :max-height="maxHeight" |
| | | :toolbar="toolbar" |
| | | :reload-data="reloadData" |
| | | :footer-method="footerMethod" |
| | | :footer-cell-class-name="footerCellClassName" |
| | | :scroll-x="{enabled: true}" |
| | | :scroll-y="{enabled: true}" |
| | | @sort-change="sortChange" |
| | | @page-change="pagerChange" |
| | | @form-submit="findList" |
| | | @checkbox-change="checkChange" |
| | | @checkbox-all="checkChangeall" |
| | | > |
| | | <template v-slot:buttons> |
| | | <slot /> |
| | | </template> |
| | | </vxe-grid> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | |
| | | // è·å Vuex åå¨å®ä¾ |
| | | // const useStore = useStore(); |
| | | |
| | | const props = defineProps({ |
| | | /* table åæ°*/ |
| | | showOverflow: { |
| | | type: Boolean, |
| | | default: () => { |
| | | return true |
| | | } |
| | | }, |
| | | columns: { |
| | | type: Array, |
| | | default: () => { |
| | | return [] |
| | | } |
| | | }, |
| | | showfooter: { |
| | | type: Boolean, |
| | | default: () => { |
| | | return false |
| | | } |
| | | }, |
| | | toolbar: { |
| | | type: Object, |
| | | default: () => { |
| | | return { |
| | | id: 'khjgz', |
| | | zoom: true, |
| | | resizable: { |
| | | storage: true |
| | | }, |
| | | custom: { |
| | | storage: true |
| | | }, |
| | | slots: { |
| | | buttons: 'buttons' |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | data: { |
| | | type: Array, |
| | | default: () => { |
| | | return [] |
| | | } |
| | | }, |
| | | loading: { |
| | | type: Boolean, |
| | | default: false |
| | | }, |
| | | page: { |
| | | type: Object, |
| | | default: function() { |
| | | return null |
| | | } |
| | | }, |
| | | checkboxConfig: { |
| | | type: Object, |
| | | default: () => { |
| | | return {} |
| | | } |
| | | }, |
| | | maxHeight: { |
| | | type: String, |
| | | default: () => { |
| | | return '' |
| | | } |
| | | }, |
| | | height: { |
| | | type: String, |
| | | default: () => { |
| | | return '' |
| | | } |
| | | }, |
| | | reloadData: { |
| | | type: Function, |
| | | default: () => { |
| | | return {} |
| | | } |
| | | }, |
| | | footerCellClassName: { |
| | | type: Function, |
| | | default: () => { |
| | | return {} |
| | | } |
| | | }, |
| | | mxTableFootData: { |
| | | type: Array, |
| | | default: () => { |
| | | return [] |
| | | } |
| | | } |
| | | }) |
| | | |
| | | const tableForm = ref([]); |
| | | |
| | | const height = ref(document.documentElement.clientHeight - 94.5 + "px;") |
| | | // const url = computed(() => props.src) |
| | | const emit = defineEmits(); |
| | | |
| | | function pagerChange({ type, currentPage, pageSize }) { |
| | | if (type == 'current') { |
| | | emit("changePageNo", currentPage); |
| | | } else if (type == 'size') { |
| | | emit('changePageSize', pageSize) |
| | | } |
| | | } |
| | | function findList() {} |
| | | |
| | | function sortChange({ column, property, order }) { |
| | | emit('sortTable', property, order) |
| | | } |
| | | |
| | | function checkChange(info) { |
| | | const { records, checked, row, rowIndex } = info |
| | | emit('on-checkbox', { records, rowIndex, checked }) |
| | | } |
| | | |
| | | function checkChangeall(info) { |
| | | const { records, checked, row } = info |
| | | emit('on-checkbox', { records, rowIndex: null, checked }) |
| | | } |
| | | |
| | | // å®ä¹ footerMethod 彿° |
| | | function footerMethod({ columns, data }) { |
| | | // 触å footerMethod äºä»¶ |
| | | emit('footerMethod', { columns, data }); |
| | | // è¿å Vuex ä¸ç hxlhTableFootData ç¶æ |
| | | // return useStore.state.hxlhTableFootData; |
| | | }; |
| | | |
| | | function handleSum(list, field) { |
| | | var total = 0 |
| | | for (var index = 0; index < list.length; index++) { |
| | | total += Number(list[index][field] || 0) |
| | | } |
| | | return total |
| | | } |
| | | const vxeTable = ref(null); |
| | | |
| | | // å¨å¼åçæ¹åæ¶æ´æ°è¡¨å°¾å计 |
| | | function updateFooter(params) { |
| | | const xTable = vxeTable.value |
| | | xTable.updateFooter() |
| | | } |
| | | |
| | | // åæ¶å¤éæ¡éæ© |
| | | function clearCheckboxRow() { |
| | | const xTable = vxeTable.value |
| | | xTable.clearCheckboxRow() |
| | | } |
| | | |
| | | // å®ä¹ tablePage 计ç®å±æ§ |
| | | const tablePage = computed(() => { |
| | | if (!props.page) { |
| | | return; |
| | | } |
| | | console.log(props.page); |
| | | return { |
| | | total: props.page.total, |
| | | currentPage: props.page.current, |
| | | pageSize: props.page.size, |
| | | align: 'left', |
| | | pageSizes: [10, 20, 50, 100, 500], |
| | | layouts: ['PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total'], |
| | | perfect: true |
| | | }; |
| | | }); |
| | | |
| | | console.log(tablePage); |
| | | |
| | | // å®ä¹ footData 计ç®å±æ§ |
| | | const footData = computed(() => props.mxTableFootData); |
| | | |
| | | </script> |
| | | |
| | | <style lang="less"> |
| | | .hxlh-table .vxe-toolbar .vxe-tools--operate { |
| | | margin-top: -23px; |
| | | } |
| | | |
| | | .hxlh-table .vxe-toolbar { |
| | | min-height: 52px; |
| | | height: auto; |
| | | } |
| | | |
| | | .vxe-table .vxe-footer--column.col-red { |
| | | color: red; |
| | | } |
| | | |
| | | </style> |
| | |
| | | import ImagePreview from "@/components/ImagePreview" |
| | | // åå
¸æ ç¾ç»ä»¶ |
| | | import DictTag from '@/components/DictTag' |
| | | // vxe-table |
| | | import 'xe-utils'; |
| | | import VXETable from 'vxe-table' |
| | | import 'vxe-table/lib/index.css' |
| | | |
| | | |
| | | const app = createApp(App) |
| | | |
| | |
| | | // æ¯æ largeãdefaultãsmall |
| | | size: Cookies.get('size') || 'default' |
| | | }) |
| | | app.use(VXETable) |
| | | |
| | | app.mount('#app') |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div id="view"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <div slot="header" class="clearfix"> |
| | | <span><b>è¡¨æ ¼å±ç¤º</b></span> |
| | | </div> |
| | | <div style="width: 100%;display: flex;flex-direction: column;align-items: center;"> |
| | | |
| | | <!--æ¥è¯¢æ¡ä»¶--> |
| | | <!-- <el-form ref="queryForm" style="width: 100%" inline> |
| | | <el-form-item label="æ¥å£å" style="float: left" class="form_btn "> |
| | | <el-input v-model="selectItem.name" autocomplete="off"></el-input> |
| | | </el-form-item> |
| | | <el-form-item style="float: right" class="form_btn "> |
| | | <el-button icon="el-icon-search" @click="alert('ææ¶æ æ³æç´¢')">æç´¢</el-button> |
| | | </el-form-item> |
| | | </el-form> --> |
| | | |
| | | <HxlhTable |
| | | style="width: 100%" |
| | | :columns="columns" |
| | | :data="tableData" |
| | | :loading="loading" |
| | | :page="page" |
| | | > |
| | | </HxlhTable> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | |
| | | import { ref, reactive, onMounted } from 'vue'; |
| | | import HxlhTable from '@/components/HxlhTable' |
| | | |
| | | // æç´¢ä½¿ç¨ç»ä»¶ |
| | | const selectItem = reactive({ |
| | | name: '' |
| | | }); |
| | | |
| | | // è¡¨æ ¼ - é¡¹ç®æææ°æ® |
| | | const tableData = ref([ |
| | | { code: '111', name: 'å¼ ä¸', sex: 'ç·' }, |
| | | { code: '222', name: 'æå', sex: 'ç·' }, |
| | | { code: '333', name: 'çäº', sex: 'ç·' }, |
| | | { code: '444', name: 'èµµå
', sex: '女' } |
| | | ]); |
| | | |
| | | for (let i = 0; i < 1000; i++) { |
| | | tableData.value.push({ |
| | | code: `new${i + 1}`, |
| | | name: `æ°äºº${i + 1}`, |
| | | sex: 'æªç¥' |
| | | }); |
| | | } |
| | | |
| | | // è¡¨æ ¼é
ç½® |
| | | const columns = ref([ |
| | | { type: 'seq', title: 'åºå·', width: 60 }, |
| | | { |
| | | title: 'ç¼å·', |
| | | field: 'code' |
| | | }, |
| | | { |
| | | title: 'åç§°', |
| | | field: 'name' |
| | | }, |
| | | { |
| | | title: 'æ§å«', |
| | | field: 'sex' |
| | | } |
| | | ]); |
| | | |
| | | // è¡¨æ ¼ç¼å² |
| | | const loading = ref(false); |
| | | |
| | | // å页屿§ |
| | | const page = reactive({ |
| | | total: 1004, |
| | | current: 1, |
| | | size: 10 |
| | | }); |
| | | |
| | | // çå½å¨æé©åï¼æ¿ä»£ mounted |
| | | onMounted(() => { |
| | | // è¿éå¯ä»¥æ¾ç½®åæ¥ mounted é©åä¸ç代ç |
| | | }); |
| | | |
| | | </script> |
| | | |
| | | <style scoped="scoped"> |
| | | #view { |
| | | width: 100%; |
| | | height: 100%; |
| | | padding: 0px; |
| | | margin: 0px; |
| | | } |
| | | |
| | | .box-card { |
| | | width: 480px; |
| | | } |
| | | </style> |
| | | |
| | | |