@ebiz/designer-components 0.0.18-beta.4 → 0.0.18-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/apiService/mockDataService.js +116 -0
- package/src/apiService/simpleDataService.js +7 -5
- package/src/components/Button.vue +70 -22
- package/src/components/EbizDetailBlock.vue +82 -0
- package/src/components/EbizDialog.vue +249 -0
- package/src/components/EbizPageHeader.vue +96 -0
- package/src/components/EbizRemoteSelect.vue +106 -41
- package/src/components/EbizTable.vue +466 -0
- package/src/components/EbizTableColumn.vue +117 -0
- package/src/components/EbizTableSort.vue +181 -0
- package/src/components/EbizTree.vue +147 -0
- package/src/components/EbizTreeSelector.vue +513 -0
- package/src/components/TdesignCalendar/index.vue +6 -3
- package/src/components/TdesignDialog.vue +226 -0
- package/src/components/TdesignInput.vue +23 -23
- package/src/components/TdesignUpload.vue +66 -97
- package/src/index.js +23 -1
- package/src/main.js +2 -2
- package/src/router/index.js +64 -5
- package/src/views/Button.vue +7 -3
- package/src/views/DialogDemo.vue +126 -0
- package/src/views/EbizDetailBlockDemo.vue +31 -0
- package/src/views/Home.vue +33 -2
- package/src/views/PageHeaderDemo.vue +105 -0
- package/src/views/RemoteSelect.vue +336 -5
- package/src/views/TableDemo.vue +335 -0
- package/src/views/TableSortDemo.vue +144 -0
- package/src/views/TableView.vue +69 -0
- package/src/views/TreeDemo.vue +255 -0
- package/src/views/TreeSelectorDemo.vue +246 -0
@@ -0,0 +1,181 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="ebiz-table-sort">
|
3
|
+
<t-popup :visible="sortVisible" trigger="click" placement="bottom-right" :overlay-style="{ width: '450px' }"
|
4
|
+
@visible-change="handleVisibleChange" :destroy-on-close="false">
|
5
|
+
<template #content>
|
6
|
+
<t-card :title="popupTitle" size="small" :bordered="false">
|
7
|
+
<div class="sort-content">
|
8
|
+
<div class="sort-item" v-for="(item, index) in sortItems" :key="index">
|
9
|
+
<div class="sort-item-content" style="display: flex; margin-bottom: 12px;">
|
10
|
+
<t-select v-model="item.type" :placeholder="fieldPlaceholder" :options="fieldOptions" :clearable="false"
|
11
|
+
:style="{ width: '170px' }" @change="handleSortChange" />
|
12
|
+
<t-select v-model="item.sort" :placeholder="orderPlaceholder" :options="orderOptions" :clearable="false"
|
13
|
+
:style="{ width: '170px', marginLeft: '8px' }" @change="handleSortChange" />
|
14
|
+
<t-button theme="default" variant="text" shape="circle" @click="removeSortItem(index)"
|
15
|
+
v-if="sortItems.length > 1" :style="{ marginLeft: '8px', flexShrink: 0 }">
|
16
|
+
<template #icon>
|
17
|
+
<t-icon name="close" />
|
18
|
+
</template>
|
19
|
+
</t-button>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<div class="sort-footer">
|
23
|
+
<t-button theme="default" variant="outline" @click="addSortItem"
|
24
|
+
v-if="sortItems.length < maxSortItems">
|
25
|
+
<template #icon>
|
26
|
+
<t-icon name="add" />
|
27
|
+
</template>
|
28
|
+
{{ addConditionText }}
|
29
|
+
</t-button>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</t-card>
|
33
|
+
</template>
|
34
|
+
<t-button block variant="outline" :title="title">
|
35
|
+
<template #icon>
|
36
|
+
<t-icon :name="icon" />
|
37
|
+
</template>
|
38
|
+
<div v-if="buttonText">
|
39
|
+
{{ buttonText }}
|
40
|
+
</div>
|
41
|
+
</t-button>
|
42
|
+
</t-popup>
|
43
|
+
</div>
|
44
|
+
</template>
|
45
|
+
|
46
|
+
<script>
|
47
|
+
export default {
|
48
|
+
name: "EbizTableSort"
|
49
|
+
}
|
50
|
+
</script>
|
51
|
+
|
52
|
+
<script setup>
|
53
|
+
import { ref, computed, defineProps, defineEmits, watch } from 'vue';
|
54
|
+
import { Button as TButton, Popup as TPopup, Card as TCard, Select as TSelect, Icon as TIcon } from 'tdesign-vue-next';
|
55
|
+
|
56
|
+
const props = defineProps({
|
57
|
+
// v-model绑定值
|
58
|
+
modelValue: {
|
59
|
+
type: Array,
|
60
|
+
default: () => []
|
61
|
+
},
|
62
|
+
// 按钮图标
|
63
|
+
icon: {
|
64
|
+
type: String,
|
65
|
+
default: 'sort'
|
66
|
+
},
|
67
|
+
// 按钮文本
|
68
|
+
buttonText: {
|
69
|
+
type: String,
|
70
|
+
default: ''
|
71
|
+
},
|
72
|
+
// 按钮标题
|
73
|
+
title: {
|
74
|
+
type: String,
|
75
|
+
default: '排序'
|
76
|
+
},
|
77
|
+
// 弹出层标题
|
78
|
+
popupTitle: {
|
79
|
+
type: String,
|
80
|
+
default: '排序'
|
81
|
+
},
|
82
|
+
// 字段选项
|
83
|
+
fieldOptions: {
|
84
|
+
type: Array,
|
85
|
+
default: () => []
|
86
|
+
},
|
87
|
+
// 字段占位符
|
88
|
+
fieldPlaceholder: {
|
89
|
+
type: String,
|
90
|
+
default: '选择字段'
|
91
|
+
},
|
92
|
+
// 排序选项
|
93
|
+
orderOptions: {
|
94
|
+
type: Array,
|
95
|
+
default: () => [
|
96
|
+
{ value: 'asc', label: '升序 ↑' },
|
97
|
+
{ value: 'desc', label: '降序 ↓' }
|
98
|
+
]
|
99
|
+
},
|
100
|
+
// 排序占位符
|
101
|
+
orderPlaceholder: {
|
102
|
+
type: String,
|
103
|
+
default: '选择排序'
|
104
|
+
},
|
105
|
+
// 最大排序条件数量
|
106
|
+
maxSortItems: {
|
107
|
+
type: Number,
|
108
|
+
default: 5
|
109
|
+
},
|
110
|
+
// 添加条件文本
|
111
|
+
addConditionText: {
|
112
|
+
type: String,
|
113
|
+
default: '添加排序条件'
|
114
|
+
}
|
115
|
+
});
|
116
|
+
|
117
|
+
const emit = defineEmits(['update:modelValue', 'sort', 'visible-change']);
|
118
|
+
|
119
|
+
// 排序弹出层显示状态
|
120
|
+
const sortVisible = ref(false);
|
121
|
+
|
122
|
+
// 排序条件列表
|
123
|
+
const sortItems = ref([]);
|
124
|
+
|
125
|
+
// 监听modelValue变化
|
126
|
+
watch(() => props.modelValue, (newVal) => {
|
127
|
+
if (newVal && newVal.length > 0) {
|
128
|
+
sortItems.value = JSON.parse(JSON.stringify(newVal));
|
129
|
+
} else {
|
130
|
+
// 默认添加一个空的排序条件
|
131
|
+
sortItems.value = [{ type: '', sort: 'desc' }];
|
132
|
+
}
|
133
|
+
}, { immediate: true });
|
134
|
+
|
135
|
+
// 添加排序条件
|
136
|
+
const addSortItem = () => {
|
137
|
+
if (sortItems.value.length < props.maxSortItems) {
|
138
|
+
sortItems.value.push({ type: '', sort: 'desc' });
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
142
|
+
// 移除排序条件
|
143
|
+
const removeSortItem = (index) => {
|
144
|
+
sortItems.value.splice(index, 1);
|
145
|
+
handleSortChange();
|
146
|
+
};
|
147
|
+
|
148
|
+
// 处理排序变更
|
149
|
+
const handleSortChange = () => {
|
150
|
+
// 过滤有效的排序条件(字段和排序方向都不为空)
|
151
|
+
const validSortItems = sortItems.value.filter(item => item.type && item.sort);
|
152
|
+
emit('update:modelValue', validSortItems);
|
153
|
+
emit('sort', validSortItems);
|
154
|
+
};
|
155
|
+
|
156
|
+
// 弹出层可见性变化
|
157
|
+
const handleVisibleChange = (visible) => {
|
158
|
+
sortVisible.value = visible;
|
159
|
+
emit('visible-change', visible);
|
160
|
+
};
|
161
|
+
</script>
|
162
|
+
|
163
|
+
<style lang="less" scoped>
|
164
|
+
.ebiz-table-sort {
|
165
|
+
display: inline-block;
|
166
|
+
|
167
|
+
.sort-content {
|
168
|
+
min-width: 400px;
|
169
|
+
width: 100%;
|
170
|
+
}
|
171
|
+
|
172
|
+
.sort-footer {
|
173
|
+
margin-top: 16px;
|
174
|
+
}
|
175
|
+
|
176
|
+
.sort-actions {
|
177
|
+
display: flex;
|
178
|
+
justify-content: flex-end;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
</style>
|
@@ -0,0 +1,147 @@
|
|
1
|
+
<template>
|
2
|
+
<t-tree
|
3
|
+
v-bind="$attrs"
|
4
|
+
:data="data"
|
5
|
+
:value="modelValue"
|
6
|
+
:expanded="expandedModel"
|
7
|
+
:actived="activedModel"
|
8
|
+
:transition="transition"
|
9
|
+
:disable-check="disableCheck"
|
10
|
+
:keys="keys"
|
11
|
+
@change="handleChange"
|
12
|
+
@expand="handleExpand"
|
13
|
+
@active="handleActive"
|
14
|
+
@select="$emit('select', $event)"
|
15
|
+
@drag-start="$emit('drag-start', $event)"
|
16
|
+
@drag-end="$emit('drag-end', $event)"
|
17
|
+
@drag-over="$emit('drag-over', $event)"
|
18
|
+
@drag-leave="$emit('drag-leave', $event)"
|
19
|
+
@drag-drop="$emit('drag-drop', $event)"
|
20
|
+
@click="$emit('click', $event)"
|
21
|
+
@load="$emit('load', $event)"
|
22
|
+
>
|
23
|
+
<template v-if="$slots.default" #default="slotProps">
|
24
|
+
<slot :node="slotProps.node"></slot>
|
25
|
+
</template>
|
26
|
+
<template v-if="$slots.empty" #empty>
|
27
|
+
<slot name="empty"></slot>
|
28
|
+
</template>
|
29
|
+
<template v-if="$slots.icon" #icon="slotProps">
|
30
|
+
<slot name="icon" :node="slotProps.node"></slot>
|
31
|
+
</template>
|
32
|
+
<template v-if="$slots.label" #label="slotProps">
|
33
|
+
<slot name="label" :node="slotProps.node"></slot>
|
34
|
+
</template>
|
35
|
+
<template v-if="$slots.line" #line="slotProps">
|
36
|
+
<slot name="line" :node="slotProps.node"></slot>
|
37
|
+
</template>
|
38
|
+
<template v-if="$slots.operations" #operations="slotProps">
|
39
|
+
<slot name="operations" :node="slotProps.node"></slot>
|
40
|
+
</template>
|
41
|
+
</t-tree>
|
42
|
+
</template>
|
43
|
+
|
44
|
+
<script setup>
|
45
|
+
import { Tree as TTree } from 'tdesign-vue-next';
|
46
|
+
import { computed } from 'vue';
|
47
|
+
|
48
|
+
// 定义组件属性
|
49
|
+
const props = defineProps({
|
50
|
+
// 选中值
|
51
|
+
modelValue: {
|
52
|
+
type: Array,
|
53
|
+
default: () => []
|
54
|
+
},
|
55
|
+
// 展开节点
|
56
|
+
expanded: {
|
57
|
+
type: Array,
|
58
|
+
default: () => []
|
59
|
+
},
|
60
|
+
// 激活节点
|
61
|
+
actived: {
|
62
|
+
type: Array,
|
63
|
+
default: () => []
|
64
|
+
},
|
65
|
+
// 数据
|
66
|
+
items: {
|
67
|
+
type: Array,
|
68
|
+
default: () => []
|
69
|
+
},
|
70
|
+
// 是否启用过渡动画
|
71
|
+
transition: {
|
72
|
+
type: Boolean,
|
73
|
+
default: false
|
74
|
+
},
|
75
|
+
// 自定义节点禁用状态,返回true表示禁用
|
76
|
+
disableCheck: {
|
77
|
+
type: Function,
|
78
|
+
default: null
|
79
|
+
},
|
80
|
+
// 自定义节点数据中的字段名称
|
81
|
+
keys: {
|
82
|
+
type: Object,
|
83
|
+
default: () => ({
|
84
|
+
label: 'label',
|
85
|
+
value: 'value',
|
86
|
+
children: 'children'
|
87
|
+
})
|
88
|
+
}
|
89
|
+
});
|
90
|
+
|
91
|
+
// 定义组件事件
|
92
|
+
const emit = defineEmits([
|
93
|
+
'update:modelValue',
|
94
|
+
'update:expanded',
|
95
|
+
'update:actived',
|
96
|
+
'change',
|
97
|
+
'expand',
|
98
|
+
'active',
|
99
|
+
'select',
|
100
|
+
'click',
|
101
|
+
'load',
|
102
|
+
'drag-start',
|
103
|
+
'drag-end',
|
104
|
+
'drag-over',
|
105
|
+
'drag-leave',
|
106
|
+
'drag-drop'
|
107
|
+
]);
|
108
|
+
|
109
|
+
// 处理items映射到data
|
110
|
+
const data = computed(() => props.items);
|
111
|
+
|
112
|
+
// 展开事件
|
113
|
+
const expandedModel = computed({
|
114
|
+
get: () => props.expanded,
|
115
|
+
set: (val) => emit('update:expanded', val)
|
116
|
+
});
|
117
|
+
|
118
|
+
// 激活节点
|
119
|
+
const activedModel = computed({
|
120
|
+
get: () => props.actived,
|
121
|
+
set: (val) => emit('update:actived', val)
|
122
|
+
});
|
123
|
+
|
124
|
+
// 值改变事件
|
125
|
+
const handleChange = (val, context) => {
|
126
|
+
emit('update:modelValue', val);
|
127
|
+
emit('change', val, context);
|
128
|
+
};
|
129
|
+
|
130
|
+
// 节点展开事件
|
131
|
+
const handleExpand = (val, context) => {
|
132
|
+
emit('update:expanded', val);
|
133
|
+
emit('expand', val, context);
|
134
|
+
};
|
135
|
+
|
136
|
+
// 节点激活事件
|
137
|
+
const handleActive = (val, context) => {
|
138
|
+
emit('update:actived', val);
|
139
|
+
emit('active', val, context);
|
140
|
+
};
|
141
|
+
</script>
|
142
|
+
|
143
|
+
<style>
|
144
|
+
.t-tree {
|
145
|
+
width: 100%;
|
146
|
+
}
|
147
|
+
</style>
|