|
1 | 1 | <template>
|
2 | 2 | <td>
|
3 |
| - <h3>VDragAndDropCell ({{ attrs }})</h3> |
| 3 | + <h3>VDragAndDropCell ({{ cellType }})</h3> |
4 | 4 | <Draggable
|
5 |
| - v-model="modelItems" |
6 |
| - :class="classNames" |
7 |
| - :group="{ name: 'sharted', pull: true, put: true }" |
8 |
| - ghost-class="pvtPlaceholder" |
9 |
| - @change="onChange" |
10 | 5 | tag="ul"
|
| 6 | + :list="modelItems" |
| 7 | + :group="{ name: 'sharted', pull: true, put: true }" |
| 8 | + ghost-class=".pvtFilterBox" |
11 | 9 | :preventOnfFilter="false"
|
| 10 | + :class="classes" |
| 11 | + @sort="onDrag" |
12 | 12 | >
|
13 |
| - <!-- :modelValue="items" --> |
14 |
| - <!-- @update:modelValue="onChange" --> |
15 |
| - <!-- @sort="onChange"--> |
16 | 13 | <VDraggableAttribute
|
17 | 14 | v-for="item in modelItems"
|
18 | 15 | :key="item"
|
19 |
| - :name="item" |
20 |
| - :sortable="true" |
21 |
| - :draggable="true" |
22 |
| - :attrValues="{}" |
23 |
| - :sorter="getSort(() => { }, item)" |
24 |
| - :menuLimit="500" |
25 |
| - :zIndex="1000" |
26 |
| - :valueFilter="{}" |
27 |
| - :open="false" |
28 |
| - :async="false" |
29 |
| - :unused="false" |
30 |
| - :localeStrings="{}" |
| 16 | + :disabled="disabledFromDragDrop.includes(item)" |
| 17 | + :sortOnly="restrictedFromDragDrop.includes(item)" |
| 18 | + :open="openStatus?.[item]" |
| 19 | + :unSelectedFilterValues="valueFilter?.[item]" |
| 20 | + :attributeName="item" |
| 21 | + :zIndex="zIndices[item]" |
| 22 | + :hideDropDown="hideDropDown" |
| 23 | + @update:zIndexOfFilterBox="$emit('update:zIndexOfFilterBox')" |
| 24 | + @update:unselectedFilterValues="$emit('update:unselectedFilterValues')" |
| 25 | + @update:openStatusOfFilterBox="$emit('update:unselectedFilterValues')" |
31 | 26 | >
|
32 | 27 | <template #pvtAttr="{ attrName }">
|
33 | 28 | {{ attrName }}
|
|
38 | 33 | </template>
|
39 | 34 |
|
40 | 35 | <script setup>
|
41 |
| -import VDraggableAttribute from './VDraggableAttribute.vue' |
| 36 | +import { ref, onMounted, computed } from 'vue' |
42 | 37 | import { VueDraggableNext as Draggable } from 'vue-draggable-next'
|
43 |
| -import { ref, onMounted } from 'vue' |
44 |
| -import { PivotData, getSort, sortAs, aggregators } from '../../helper' |
| 38 | +import VDraggableAttribute from './VDraggableAttribute.vue' |
45 | 39 |
|
46 |
| -const emit = defineEmits(['update:filters']) |
| 40 | +const emit = defineEmits([ |
| 41 | + 'update:draggedAttribute', |
| 42 | + 'update:zIndexOfFilterBox', |
| 43 | + 'update:unselectedFilterValues', |
| 44 | + 'update:openStatusOfFilterBox' |
| 45 | +]) |
47 | 46 |
|
48 | 47 | const props = defineProps({
|
49 |
| - attrs: { |
| 48 | + cellType: { |
| 49 | + type: String, |
| 50 | + required: true |
| 51 | + }, |
| 52 | + // 삭제할 수 있으면 삭제 |
| 53 | + classes: { |
50 | 54 | type: String,
|
51 | 55 | default: ''
|
52 | 56 | },
|
53 |
| - items: { |
| 57 | + attributeNames: { |
| 58 | + type: Array, |
| 59 | + default: () => [] |
| 60 | + }, |
| 61 | + valueFilter: { |
| 62 | + type: Object, |
| 63 | + default: () => ({}) |
| 64 | + }, |
| 65 | + // 같은 셀 내 이동만 가능(정렬) |
| 66 | + restrictedFromDragDrop: { |
54 | 67 | type: Array,
|
55 | 68 | default: () => []
|
56 | 69 | },
|
57 |
| - classNames: { |
| 70 | + // 삭제 보류 |
| 71 | + disabledFromDragDrop: { |
58 | 72 | type: Array,
|
59 | 73 | default: () => []
|
| 74 | + }, |
| 75 | + hideFilterBoxOfUnusedAttributes: { |
| 76 | + type: Boolean, |
| 77 | + default: false |
| 78 | + }, |
| 79 | + zIndices: { |
| 80 | + type: Object, |
| 81 | + default: () => ({}) |
| 82 | + }, |
| 83 | + openStatus: { |
| 84 | + type: Object, |
| 85 | + default: () => ({}) |
60 | 86 | }
|
61 | 87 | })
|
62 | 88 |
|
63 | 89 | const modelItems = ref([])
|
64 | 90 |
|
65 |
| -const onChange = evt => { |
| 91 | +const onDrag = evt => { |
66 | 92 | console.log('event', Object.keys(evt)[0])
|
67 |
| - emit('update:filters', { cellType: props.attrs, filters: modelItems.value }) |
| 93 | + emit('update:draggedAttribute', { |
| 94 | + cellType: props.cellType, |
| 95 | + attributes: modelItems.value |
| 96 | + }) |
68 | 97 | }
|
69 | 98 |
|
70 | 99 | onMounted(() => {
|
71 |
| - modelItems.value = [...props.items] |
| 100 | + modelItems.value = [...props.attributeNames] |
72 | 101 | })
|
73 | 102 |
|
| 103 | +// 이름 변경해야할 것 같음 hideDropDownInUnusedCell |
| 104 | +const hideDropDown = computed(() => { |
| 105 | + return props.cellType === 'unused' && props.hideFilterBoxOfUnusedAttrs |
| 106 | +}) |
74 | 107 | </script>
|
75 | 108 |
|
76 |
| -<style scoped> |
77 |
| -</style> |
| 109 | +<style scoped></style> |
0 commit comments