Skip to content

Commit

Permalink
增加canvas版t-table组件
Browse files Browse the repository at this point in the history
  • Loading branch information
栾华亮 committed Dec 9, 2020
1 parent 12540e5 commit 1f012bf
Show file tree
Hide file tree
Showing 35 changed files with 1,952 additions and 535 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"deploy": "gh-pages -d dist"
},
"dependencies": {
"axios": "^0.21.0",
"core-js": "^3.6.4",
"element-ui": "^2.4.5",
"loadsh": "^0.0.4",
"vue": "^2.6.11"
},
"devDependencies": {
Expand Down
12 changes: 12 additions & 0 deletions src/components/Icon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Vue from 'vue';
import Icon from './index.vue';

Vue.component('Icon', Icon);

// 导入所有的svg(参照webpack文档: http://webpack.github.io/docs/context.html#dynamic-requires )
// ~function (requireContext) {
// return requireContext.keys().map(requireContext)
// }(require.context('./svg', false, /\.svg$/))
const requireAll = requireContext => requireContext.keys().map(requireContext);
const req = require.context('./svg', false, /\.svg$/)
requireAll(req);
47 changes: 47 additions & 0 deletions src/components/Icon/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<template>
<svg :style="iconSty"
aria-hidden="true">
<use :xlink:href="iconName"/>
</svg>
</template>
<script>
export default {
name: 'Icon',
props: {
type: {
default: 'sad'
},
size: {
type: [Number, String],
default: 16
},
color: {
type: String
}
},
computed: {
iconName() {
return '#' + this.type
},
iconSty() {
return {
'font-size': this.size + 'px',
'color': this.color
}
}
}
}
</script>

<style scoped>
svg {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
user-select: none;
}
</style>
1 change: 1 addition & 0 deletions src/components/Icon/svg/arrow-back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/Icon/svg/arrow-forward.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/Icon/svg/asce.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/Icon/svg/desc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/Icon/svg/reset.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/components/Icon/svg/rotate-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/Icon/svg/rotate-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 27 additions & 10 deletions src/components/data-table/column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export default {
name: 'DTableGridColumn',
props: {
type: String,
business_type: String,
showTooltip: Boolean, // 内容超出显示tooltip
align: [Boolean, String], // 对齐方式
fixed: [Boolean, String], // 固定列
Expand All @@ -15,7 +15,9 @@ export default {
return []
}
},
renderColumn: Function
renderColumn: Function,
linkAction: Function,
cardRender: Function
},
provide() {
return {
Expand All @@ -41,14 +43,29 @@ export default {
getColumnAction() {
let links = []
let dropdown = []
this.actions.forEach(item => {
if (item.type === 'link') {
links.push(item)
if (this.business_type === 'link') {
links = {
handler: ({ row, rowIndex }) => {
typeof this.linkAction === 'function' && this.linkAction({ row, rowIndex })
},
cardRender: (pos, { row, rowIndex }) => {
if (typeof this.cardRender === 'function') {
const vnode = this.cardRender(this.$createElement, { row, rowIndex })
this.dTable.updatePoptip(pos, vnode)
}
}
}
if (item.type === 'dropdown') {
dropdown = item.list
}
})
} else if (this.business_type === 'action'){
this.actions.forEach(item => {
if (item.type === 'link') {
links.push(item)
}
if (item.type === 'dropdown') {
dropdown = item.list
}
})
}
return {
links,
dropdown
Expand All @@ -59,7 +76,7 @@ export default {
const self = this
const { links, dropdown } = this.getColumnAction()
this.column = {
type: this.type,
business_type: this.business_type,
property: this.property,
label: this.label,
showTooltip: this.showTooltip,
Expand Down
Loading

0 comments on commit 1f012bf

Please sign in to comment.