GetColumnComponent.js
48 lines
| 1 | import * as ChooseColumn from '../components/TableColumns/choose'; |
| 2 | import * as LinkTypeColumn from '../components/TableColumns/link-type'; |
| 3 | import * as IconStatusColumn from '../components/TableColumns/icon-status'; |
| 4 | import * as InputControlColumn from '../components/TableColumns/input-control'; |
| 5 | import * as TextareaControlColumn from '../components/TableColumns/textarea-control'; |
| 6 | import SelectControlColumn from '../components/TableColumns/select-control'; |
| 7 | import ColumnPre from '../components/TableColumns/pre'; |
| 8 | |
| 9 | |
| 10 | export default { |
| 11 | props: { |
| 12 | columnsComponents: { |
| 13 | type: Array, |
| 14 | required: false, |
| 15 | default() { |
| 16 | return []; |
| 17 | }, |
| 18 | }, |
| 19 | }, |
| 20 | data() { |
| 21 | return { |
| 22 | componentsCols: [], |
| 23 | }; |
| 24 | }, |
| 25 | created() { |
| 26 | this.componentsCols = [ |
| 27 | ...this.columnsComponents, |
| 28 | ChooseColumn, |
| 29 | LinkTypeColumn, |
| 30 | IconStatusColumn, |
| 31 | InputControlColumn, |
| 32 | TextareaControlColumn, |
| 33 | ColumnPre, |
| 34 | SelectControlColumn, |
| 35 | ]; |
| 36 | }, |
| 37 | methods: { |
| 38 | getColumnComponentByPrefix( column, prefix ) { |
| 39 | const index = this.componentsCols.findIndex( comp => comp[ prefix ]?.name === ( |
| 40 | column + '--' + prefix |
| 41 | ) ); |
| 42 | |
| 43 | return ( |
| 44 | - 1 === index |
| 45 | ) ? false : this.componentsCols[ index ][ prefix ]; |
| 46 | }, |
| 47 | }, |
| 48 | }; |