@yidun/antd-super-table 0.1.6 → 0.1.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/index.js +595 -589
- package/example/index.vue +66 -2
- package/package.json +4 -3
package/example/index.vue
CHANGED
|
@@ -11,8 +11,8 @@ import { createTableColumns } from './tableColumns'
|
|
|
11
11
|
import { createFormItems } from './formItems'
|
|
12
12
|
|
|
13
13
|
const tableRef = ref<InstanceType<typeof SuperTable>>()
|
|
14
|
-
// 查询条件配置
|
|
15
|
-
const formItems
|
|
14
|
+
// 查询条件配置 - 改为响应式
|
|
15
|
+
const formItems = ref<any[]>(createFormItems())
|
|
16
16
|
|
|
17
17
|
// 表头配置
|
|
18
18
|
const tableColumns: any = createTableColumns({
|
|
@@ -179,6 +179,54 @@ const handleClearCache = () => {
|
|
|
179
179
|
})
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
// 新增查询项计数器
|
|
183
|
+
let newItemCounter = 0
|
|
184
|
+
|
|
185
|
+
// 新增查询项
|
|
186
|
+
const handleAddFormItem = () => {
|
|
187
|
+
newItemCounter++
|
|
188
|
+
const newItem = {
|
|
189
|
+
key: `dynamicInput${newItemCounter}`,
|
|
190
|
+
type: 'input',
|
|
191
|
+
label: `动态输入框${newItemCounter}`,
|
|
192
|
+
name: `dynamicInput${newItemCounter}`,
|
|
193
|
+
value: '',
|
|
194
|
+
}
|
|
195
|
+
formItems.value = [...formItems.value, newItem]
|
|
196
|
+
console.log('✅ 新增查询项:', newItem.name, '当前总数:', formItems.value.length)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// 删除最后一个非 fixed 的查询项
|
|
200
|
+
const handleRemoveFormItem = () => {
|
|
201
|
+
// 从后往前找第一个非 fixed 的项
|
|
202
|
+
const indexToRemove = formItems.value.findLastIndex((item: any) => !item.fixed)
|
|
203
|
+
|
|
204
|
+
if (indexToRemove === -1) {
|
|
205
|
+
Modal.warning({
|
|
206
|
+
title: '提示',
|
|
207
|
+
content: '没有可删除的查询项(fixed 的项不可删除)',
|
|
208
|
+
})
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const removedItem = formItems.value[indexToRemove]
|
|
213
|
+
formItems.value = formItems.value.filter((_: any, index: number) => index !== indexToRemove)
|
|
214
|
+
console.log('❌ 删除查询项:', removedItem.name, '当前总数:', formItems.value.length)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 重置所有查询项
|
|
218
|
+
const handleResetFormItems = () => {
|
|
219
|
+
Modal.confirm({
|
|
220
|
+
title: '提示',
|
|
221
|
+
content: '确定要重置所有查询项吗?这将清除所有动态添加的查询项。',
|
|
222
|
+
onOk: () => {
|
|
223
|
+
formItems.value = createFormItems()
|
|
224
|
+
newItemCounter = 0
|
|
225
|
+
console.log('🔄 重置查询项完成,当前总数:', formItems.value.length)
|
|
226
|
+
},
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
|
|
182
230
|
onMounted(() => {
|
|
183
231
|
handleUpdateSelectOptions()
|
|
184
232
|
|
|
@@ -287,6 +335,19 @@ onMounted(() => {
|
|
|
287
335
|
<a-radio :value="12">12</a-radio>
|
|
288
336
|
</a-radio-group>
|
|
289
337
|
</a-form-item>
|
|
338
|
+
<a-form-item>
|
|
339
|
+
<a-space>
|
|
340
|
+
<a-button @click="handleAddFormItem">
|
|
341
|
+
➕ 新增查询项
|
|
342
|
+
</a-button>
|
|
343
|
+
<a-button @click="handleRemoveFormItem">
|
|
344
|
+
➖ 删除查询项
|
|
345
|
+
</a-button>
|
|
346
|
+
<a-button @click="handleResetFormItems">
|
|
347
|
+
🔄 重置查询项
|
|
348
|
+
</a-button>
|
|
349
|
+
</a-space>
|
|
350
|
+
</a-form-item>
|
|
290
351
|
<a-form-item>
|
|
291
352
|
<a-button
|
|
292
353
|
type="primary"
|
|
@@ -296,6 +357,9 @@ onMounted(() => {
|
|
|
296
357
|
清空缓存
|
|
297
358
|
</a-button>
|
|
298
359
|
</a-form-item>
|
|
360
|
+
<a-form-item label="查询项总数">
|
|
361
|
+
<a-tag color="blue">{{ formItems.length }} 项</a-tag>
|
|
362
|
+
</a-form-item>
|
|
299
363
|
</a-form>
|
|
300
364
|
<super-table
|
|
301
365
|
ref="tableRef"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yidun/antd-super-table",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"@ant-design/icons-vue": "^7.0.1",
|
|
27
27
|
"@vueuse/core": "^13.1.0",
|
|
28
28
|
"ant-design-vue": "^4.2.6",
|
|
29
|
+
"async-validator": "^4.2.5",
|
|
29
30
|
"dayjs": "^1.11.13",
|
|
30
31
|
"lodash-es": "^4.17.21",
|
|
31
32
|
"sortablejs": "^1.15.6",
|
|
32
33
|
"uuid": "^11.1.0",
|
|
33
34
|
"vue": "^3.5.13",
|
|
34
|
-
"vuedraggable": "^4.0.1"
|
|
35
|
-
"async-validator": "^4.2.5"
|
|
35
|
+
"vuedraggable": "^4.0.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@tsconfig/node22": "^22.0.1",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"vite": "^6.2.4",
|
|
58
58
|
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
59
59
|
"vite-plugin-vue-devtools": "^7.7.2",
|
|
60
|
+
"vite-plugin-vue-mcp": "^0.3.2",
|
|
60
61
|
"vue-tsc": "^2.2.8"
|
|
61
62
|
}
|
|
62
63
|
}
|