cd-vue-filter 2.2.5 → 2.2.7
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/dist/cd-vue-filter.js +7811 -0
- package/dist/cd-vue-filter.umd.cjs +3 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/style.css +1 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/province.d.ts +3 -0
- package/dist/utils/province.d.ts.map +1 -0
- package/package.json +23 -12
- package/src/components/FilterComponent.vue +0 -359
- package/src/components/SavePlanDialog.vue +0 -239
- package/src/components/cd-filter-bar.vue +0 -412
- package/src/components/cd-filter.vue +0 -1002
- package/src/components/filterDialog.vue +0 -345
- package/src/index.ts +0 -43
- package/src/types/index.ts +0 -65
- package/src/utils/province.ts +0 -5502
- /package/{src → dist}/vue-shim.d.ts +0 -0
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<t-dialog header="筛选条件设置" placement="center" :visible="visible" @update:visible="$emit('update:visible', $event)"
|
|
3
|
-
width="700px" :z-index="999" :footer="true" @close="closeDialog" id="leader-line-clip-container">
|
|
4
|
-
<template #body>
|
|
5
|
-
<div class="filter-dialog-content">
|
|
6
|
-
<div class="leader-line-container">
|
|
7
|
-
<div class="filter-scroll-wrapper" id="filter-scroll-wrapper">
|
|
8
|
-
<div class="filter-dialog-left" v-if="filterCards.length > 1">
|
|
9
|
-
<!-- 单选框列表 -->
|
|
10
|
-
<div class="connectors-container" >
|
|
11
|
-
<t-radio-group size="small" class="connector-selector" v-model="type1" style="margin-right: 20px;">
|
|
12
|
-
<t-radio-button value="and">且</t-radio-button>
|
|
13
|
-
<t-radio-button value="or">或</t-radio-button>
|
|
14
|
-
</t-radio-group>
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
<!-- 左侧筛选内容 -->
|
|
18
|
-
<div class="filter-dialog-middle" id="filter-dialog-middle">
|
|
19
|
-
<!-- 筛选卡片区域 -->
|
|
20
|
-
<div class="filter-cards">
|
|
21
|
-
<!-- 筛选卡片 -->
|
|
22
|
-
<div v-for="(card, cardIndex) in filterCards" :key="card.id" class="filter-card-item">
|
|
23
|
-
<!-- 卡片标题和删除按钮 -->
|
|
24
|
-
<div class="filter-card-header">
|
|
25
|
-
<div style="
|
|
26
|
-
display: flex;
|
|
27
|
-
align-items: center;
|
|
28
|
-
flex-direction: row;
|
|
29
|
-
">
|
|
30
|
-
<span class="filter-card-title">筛选卡片 {{ cardIndex + 1 }}</span>
|
|
31
|
-
<t-radio-group size="small" v-model="card.connector" class="connector-selector">
|
|
32
|
-
<t-radio-button value="and">且</t-radio-button>
|
|
33
|
-
<t-radio-button value="or">或</t-radio-button>
|
|
34
|
-
</t-radio-group>
|
|
35
|
-
</div>
|
|
36
|
-
<t-button theme="default" variant="text" size="small" @click="removeFilterCard(cardIndex)"
|
|
37
|
-
:disabled="filterCards.length === 1">
|
|
38
|
-
<template #icon>
|
|
39
|
-
<t-icon name="close" />
|
|
40
|
-
</template>
|
|
41
|
-
</t-button>
|
|
42
|
-
</div>
|
|
43
|
-
<!-- 卡片内容:筛选条件组合 -->
|
|
44
|
-
<div class="filter-card-content">
|
|
45
|
-
<div v-for="(condition, condIndex) in card.conditions" :key="condIndex" class="filter-combination">
|
|
46
|
-
<!-- 筛选组件 -->
|
|
47
|
-
<FilterComponent :field-options="fieldOptions" :filter-condition="card.conditions[condIndex]"
|
|
48
|
-
:index="condIndex" :select-options="[]" :size="size"/>
|
|
49
|
-
<!-- 删除条件按钮 -->
|
|
50
|
-
<t-button theme="default" variant="text" size="small"
|
|
51
|
-
@click="removeConditionFromCard(cardIndex, condIndex)" :disabled="card.conditions.length === 1">
|
|
52
|
-
<template #icon>
|
|
53
|
-
<t-icon name="minus" />
|
|
54
|
-
</template>
|
|
55
|
-
</t-button>
|
|
56
|
-
</div>
|
|
57
|
-
<!-- 添加条件按钮 -->
|
|
58
|
-
<div class="filter-card-actions">
|
|
59
|
-
<t-button theme="default" size="small" @click="addConditionToCard(cardIndex)">
|
|
60
|
-
<template #icon>
|
|
61
|
-
<t-icon name="add" />
|
|
62
|
-
</template>
|
|
63
|
-
添加条件
|
|
64
|
-
</t-button>
|
|
65
|
-
</div>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
<!-- 增加筛选卡片按钮 -->
|
|
69
|
-
<div class="add-filter-card" @click="addFilterCard">
|
|
70
|
-
<div class="add-card-content">
|
|
71
|
-
<t-icon name="add" />
|
|
72
|
-
<span>增加筛选卡片</span>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
</template>
|
|
81
|
-
<template #footer>
|
|
82
|
-
<div class="filter-dialog-footer1">
|
|
83
|
-
<div class="filter-dialog-footer2"></div>
|
|
84
|
-
<div class="filter-dialog-footer">
|
|
85
|
-
<t-button theme="default" @click="closeDialog">取消</t-button>
|
|
86
|
-
<t-button theme="primary" @click="submitFilter">确定</t-button>
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
</template>
|
|
90
|
-
</t-dialog>
|
|
91
|
-
</template>
|
|
92
|
-
<script setup>
|
|
93
|
-
import { ref, watch } from 'vue'
|
|
94
|
-
import { MessagePlugin } from 'tdesign-vue-next'
|
|
95
|
-
import FilterComponent from "./FilterComponent.vue"
|
|
96
|
-
// Props
|
|
97
|
-
const props = defineProps({
|
|
98
|
-
visible: {
|
|
99
|
-
type: Boolean,
|
|
100
|
-
default: false
|
|
101
|
-
},
|
|
102
|
-
fieldOptions: {
|
|
103
|
-
type: Array,
|
|
104
|
-
default: () => []
|
|
105
|
-
},
|
|
106
|
-
initialFilterCards: {
|
|
107
|
-
type: Array,
|
|
108
|
-
default: () => []
|
|
109
|
-
},
|
|
110
|
-
initialType1: {
|
|
111
|
-
type: String,
|
|
112
|
-
default: 'and'
|
|
113
|
-
},
|
|
114
|
-
size: {
|
|
115
|
-
type: String,
|
|
116
|
-
default: "medium"
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
// Emits
|
|
120
|
-
const emit = defineEmits([
|
|
121
|
-
'update:visible',
|
|
122
|
-
'submit',
|
|
123
|
-
'close'
|
|
124
|
-
])
|
|
125
|
-
// 筛选卡片列表
|
|
126
|
-
const filterCards = ref([
|
|
127
|
-
{
|
|
128
|
-
id: 1,
|
|
129
|
-
connector: "and",
|
|
130
|
-
conditions: [
|
|
131
|
-
{ field: "", operator: "eq", value: "" },
|
|
132
|
-
],
|
|
133
|
-
},
|
|
134
|
-
])
|
|
135
|
-
const type1 = ref("and")
|
|
136
|
-
let nextCardId = 3
|
|
137
|
-
// 监听props变化,同步数据
|
|
138
|
-
watch(() => props.initialFilterCards, (newVal) => {
|
|
139
|
-
if (newVal && newVal.length > 0) {
|
|
140
|
-
filterCards.value = newVal
|
|
141
|
-
}
|
|
142
|
-
}, { immediate: true, deep: true })
|
|
143
|
-
watch(() => props.initialType1, (newVal) => {
|
|
144
|
-
if (newVal) {
|
|
145
|
-
type1.value = newVal
|
|
146
|
-
}
|
|
147
|
-
}, { immediate: true })
|
|
148
|
-
// 添加筛选卡片
|
|
149
|
-
const addFilterCard = () => {
|
|
150
|
-
filterCards.value.push({
|
|
151
|
-
id: nextCardId++,
|
|
152
|
-
connector: "and",
|
|
153
|
-
conditions: [{ field: "", operator: "eq", value: "" }],
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
// 向指定卡片添加筛选条件
|
|
157
|
-
const addConditionToCard = (cardIndex) => {
|
|
158
|
-
if (cardIndex >= 0 && cardIndex < filterCards.value.length) {
|
|
159
|
-
filterCards.value[cardIndex].conditions.push({
|
|
160
|
-
field: "",
|
|
161
|
-
operator: "eq",
|
|
162
|
-
value: "",
|
|
163
|
-
})
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
// 从指定卡片中删除筛选条件
|
|
167
|
-
const removeConditionFromCard = (cardIndex, condIndex) => {
|
|
168
|
-
if (cardIndex >= 0 && cardIndex < filterCards.value.length) {
|
|
169
|
-
const card = filterCards.value[cardIndex]
|
|
170
|
-
if (
|
|
171
|
-
card.conditions.length > 1 &&
|
|
172
|
-
condIndex >= 0 &&
|
|
173
|
-
condIndex < card.conditions.length
|
|
174
|
-
) {
|
|
175
|
-
card.conditions.splice(condIndex, 1)
|
|
176
|
-
} else if (card.conditions.length <= 1) {
|
|
177
|
-
MessagePlugin.warning("每个卡片至少需要一个筛选条件")
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
// 删除筛选卡片
|
|
182
|
-
const removeFilterCard = (cardIndex) => {
|
|
183
|
-
if (filterCards.value.length > 1) {
|
|
184
|
-
filterCards.value.splice(cardIndex, 1)
|
|
185
|
-
} else {
|
|
186
|
-
MessagePlugin.warning("至少需要保留一个筛选卡片")
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// 提交筛选
|
|
190
|
-
const submitFilter = () => {
|
|
191
|
-
emit('submit', {
|
|
192
|
-
filterCards: filterCards.value,
|
|
193
|
-
type1: type1.value
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
// 关闭对话框
|
|
197
|
-
const closeDialog = () => {
|
|
198
|
-
emit('close')
|
|
199
|
-
emit('update:visible', false)
|
|
200
|
-
}
|
|
201
|
-
</script>
|
|
202
|
-
<style scoped>
|
|
203
|
-
.filter-dialog-content {
|
|
204
|
-
min-height: 400px;
|
|
205
|
-
}
|
|
206
|
-
.leader-line-container {
|
|
207
|
-
position: relative;
|
|
208
|
-
width: 100%;
|
|
209
|
-
height: 100%;
|
|
210
|
-
}
|
|
211
|
-
.filter-scroll-wrapper {
|
|
212
|
-
display: flex;
|
|
213
|
-
flex-direction: row;
|
|
214
|
-
height: 100%;
|
|
215
|
-
margin-left: auto;
|
|
216
|
-
z-index: 2 !important;
|
|
217
|
-
}
|
|
218
|
-
.filter-dialog-left {
|
|
219
|
-
display: flex;
|
|
220
|
-
justify-content: flex-start;
|
|
221
|
-
align-items: flex-start;
|
|
222
|
-
margin-bottom: 16px;
|
|
223
|
-
width: 25%;
|
|
224
|
-
padding-top: 80px;
|
|
225
|
-
position: relative;
|
|
226
|
-
z-index: 0;
|
|
227
|
-
}
|
|
228
|
-
.connectors-container {
|
|
229
|
-
display: flex;
|
|
230
|
-
align-items: center;
|
|
231
|
-
}
|
|
232
|
-
.connectors-container::before {
|
|
233
|
-
content: "";
|
|
234
|
-
position: absolute;
|
|
235
|
-
width: 100px;
|
|
236
|
-
left: 75px;
|
|
237
|
-
border: 1px solid blue;
|
|
238
|
-
border-right-color: transparent;
|
|
239
|
-
top: 50px;
|
|
240
|
-
bottom: 50px;
|
|
241
|
-
z-index: -1;
|
|
242
|
-
}
|
|
243
|
-
.connector-selector {
|
|
244
|
-
margin-right: 20px;
|
|
245
|
-
}
|
|
246
|
-
.filter-dialog-middle {
|
|
247
|
-
flex: 1;
|
|
248
|
-
}
|
|
249
|
-
.filter-cards {
|
|
250
|
-
display: flex;
|
|
251
|
-
flex-direction: column;
|
|
252
|
-
gap: 16px;
|
|
253
|
-
}
|
|
254
|
-
.filter-card-item {
|
|
255
|
-
border: 1px solid var(--td-component-stroke);
|
|
256
|
-
border-radius: 6px;
|
|
257
|
-
padding: 16px;
|
|
258
|
-
background-color: var(--td-bg-color-container);
|
|
259
|
-
}
|
|
260
|
-
.filter-card-header {
|
|
261
|
-
display: flex;
|
|
262
|
-
justify-content: space-between;
|
|
263
|
-
align-items: center;
|
|
264
|
-
margin-bottom: 12px;
|
|
265
|
-
padding-bottom: 8px;
|
|
266
|
-
border-bottom: 1px solid var(--td-component-stroke);
|
|
267
|
-
}
|
|
268
|
-
.filter-card-title {
|
|
269
|
-
font-weight: 500;
|
|
270
|
-
color: var(--td-text-color-primary);
|
|
271
|
-
margin-right: 12px;
|
|
272
|
-
}
|
|
273
|
-
.filter-card-content {
|
|
274
|
-
display: flex;
|
|
275
|
-
flex-direction: column;
|
|
276
|
-
gap: 12px;
|
|
277
|
-
}
|
|
278
|
-
.filter-combination {
|
|
279
|
-
display: flex;
|
|
280
|
-
align-items: center;
|
|
281
|
-
gap: 12px;
|
|
282
|
-
}
|
|
283
|
-
.filter-card-actions {
|
|
284
|
-
display: flex;
|
|
285
|
-
justify-content: flex-start;
|
|
286
|
-
padding-top: 8px;
|
|
287
|
-
border-top: 1px dashed var(--td-component-stroke);
|
|
288
|
-
}
|
|
289
|
-
.add-filter-card {
|
|
290
|
-
border: 2px dashed var(--td-component-stroke);
|
|
291
|
-
border-radius: 6px;
|
|
292
|
-
padding: 24px;
|
|
293
|
-
display: flex;
|
|
294
|
-
justify-content: center;
|
|
295
|
-
align-items: center;
|
|
296
|
-
cursor: pointer;
|
|
297
|
-
transition: all 0.3s ease;
|
|
298
|
-
background-color: var(--td-bg-color-container-hover);
|
|
299
|
-
}
|
|
300
|
-
.add-filter-card:hover {
|
|
301
|
-
border-color: var(--td-brand-color);
|
|
302
|
-
background-color: var(--td-brand-color-light);
|
|
303
|
-
}
|
|
304
|
-
.add-card-content {
|
|
305
|
-
display: flex;
|
|
306
|
-
flex-direction: column;
|
|
307
|
-
align-items: center;
|
|
308
|
-
gap: 8px;
|
|
309
|
-
color: var(--td-text-color-secondary);
|
|
310
|
-
}
|
|
311
|
-
.add-card-content span {
|
|
312
|
-
font-size: 14px;
|
|
313
|
-
}
|
|
314
|
-
.filter-dialog-footer1 {
|
|
315
|
-
display: flex;
|
|
316
|
-
flex-direction: column;
|
|
317
|
-
}
|
|
318
|
-
.filter-dialog-footer2 {
|
|
319
|
-
flex: 1;
|
|
320
|
-
}
|
|
321
|
-
.filter-dialog-footer {
|
|
322
|
-
display: flex;
|
|
323
|
-
justify-content: flex-end;
|
|
324
|
-
gap: 12px;
|
|
325
|
-
padding-top: 16px;
|
|
326
|
-
border-top: 1px solid var(--td-component-stroke);
|
|
327
|
-
}
|
|
328
|
-
/* 连接器选择器样式 - 为"且"和"或"添加背景区分 */
|
|
329
|
-
.connector-selector :deep(.t-radio-button.t-is-checked) {
|
|
330
|
-
background-color: #e8f4ff;
|
|
331
|
-
border-color: #0052d9;
|
|
332
|
-
}
|
|
333
|
-
.connector-selector :deep(.t-radio-button.t-is-checked .t-radio-button__label) {
|
|
334
|
-
color: #0052d9;
|
|
335
|
-
font-weight: 500;
|
|
336
|
-
}
|
|
337
|
-
.connector-selector :deep(.t-radio-button:last-child.t-is-checked) {
|
|
338
|
-
background-color: #fff3e8;
|
|
339
|
-
border-color: #ff8800;
|
|
340
|
-
}
|
|
341
|
-
.connector-selector :deep(.t-radio-button:last-child.t-is-checked .t-radio-button__label) {
|
|
342
|
-
color: #ff8800;
|
|
343
|
-
font-weight: 500;
|
|
344
|
-
}
|
|
345
|
-
</style>
|
package/src/index.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// 直接从项目源文件导入组件
|
|
2
|
-
import FilterDialog from './components/filterDialog.vue';
|
|
3
|
-
import FilterComponent from './components/filterDialog.vue';
|
|
4
|
-
import CdFilterBar from './components/cd-filter-bar.vue';
|
|
5
|
-
import type {
|
|
6
|
-
FilterComponentProps,
|
|
7
|
-
FilterDialogProps,
|
|
8
|
-
FilterCard,
|
|
9
|
-
FilterCondition,
|
|
10
|
-
FieldOption,
|
|
11
|
-
FieldType,
|
|
12
|
-
OperatorOption,
|
|
13
|
-
CascaderOption,
|
|
14
|
-
ProvinceData,
|
|
15
|
-
CityData
|
|
16
|
-
} from './types/index';
|
|
17
|
-
|
|
18
|
-
// 导出组件
|
|
19
|
-
export { FilterDialog, FilterComponent, CdFilterBar };
|
|
20
|
-
|
|
21
|
-
// 导出类型
|
|
22
|
-
export type {
|
|
23
|
-
FilterComponentProps,
|
|
24
|
-
FilterDialogProps,
|
|
25
|
-
FilterCard,
|
|
26
|
-
FilterCondition,
|
|
27
|
-
FieldOption,
|
|
28
|
-
FieldType,
|
|
29
|
-
OperatorOption,
|
|
30
|
-
CascaderOption,
|
|
31
|
-
ProvinceData,
|
|
32
|
-
CityData
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// Vue 插件安装函数
|
|
36
|
-
export const install = (app: any) => {
|
|
37
|
-
app.component('FilterDialog', FilterDialog);
|
|
38
|
-
app.component('FilterComponent', FilterComponent);
|
|
39
|
-
app.component('CdFilterBar', CdFilterBar);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// 默认导出 FilterDialog
|
|
43
|
-
export default FilterDialog;
|
package/src/types/index.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// 字段类型定义
|
|
2
|
-
export type FieldType = 'number' | 'money' | 'text' | 'date' | 'time' | 'select' | 'selectProvince' | 'basedata' | 'billdata';
|
|
3
|
-
|
|
4
|
-
// 字段选项接口
|
|
5
|
-
export interface FieldOption {
|
|
6
|
-
key: string;
|
|
7
|
-
label: string;
|
|
8
|
-
value: string;
|
|
9
|
-
type: FieldType;
|
|
10
|
-
options?: { key: string; label: string; value: string }[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// 过滤条件接口
|
|
14
|
-
export interface FilterCondition {
|
|
15
|
-
field: string;
|
|
16
|
-
operator: string;
|
|
17
|
-
value: any;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// FilterComponent 组件属性接口
|
|
21
|
-
export interface FilterComponentProps {
|
|
22
|
-
fieldOptions: FieldOption[];
|
|
23
|
-
filterCondition: FilterCondition;
|
|
24
|
-
selectOptions?: Record<string, any[]>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// FilterDialog 组件属性接口
|
|
28
|
-
export interface FilterDialogProps {
|
|
29
|
-
visible: boolean;
|
|
30
|
-
fieldOptions: FieldOption[];
|
|
31
|
-
initialFilterCards?: FilterCard[];
|
|
32
|
-
initialType1?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 筛选卡片接口
|
|
36
|
-
export interface FilterCard {
|
|
37
|
-
id: number;
|
|
38
|
-
connector: 'and' | 'or';
|
|
39
|
-
conditions: FilterCondition[];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// 操作符选项接口
|
|
43
|
-
export interface OperatorOption {
|
|
44
|
-
key: string;
|
|
45
|
-
label: string;
|
|
46
|
-
value: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// 级联选择器选项接口
|
|
50
|
-
export interface CascaderOption {
|
|
51
|
-
label: string;
|
|
52
|
-
value: string;
|
|
53
|
-
children?: CascaderOption[];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// 省份数据接口
|
|
57
|
-
export interface ProvinceData {
|
|
58
|
-
name: string;
|
|
59
|
-
city: CityData[];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface CityData {
|
|
63
|
-
name: string;
|
|
64
|
-
area: string[];
|
|
65
|
-
}
|