el-plus 0.0.87 → 0.0.89
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/CHANGELOG.md +12 -0
- package/dist/index.full.js +61 -45
- package/dist/index.full.min.js +4 -4
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +4 -4
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +57 -43
- package/docs/components/buttons.md +66 -19
- package/docs/components/form.md +24 -5
- package/docs/components/header.md +23 -0
- package/docs/components/search-list-page.md +11 -1
- package/docs/components/table.md +2 -1
- package/docs/components/use-form-dialog.md +4 -5
- package/docs/hooks/use-navigation.md +131 -0
- package/docs/hooks/use-utils.md +144 -0
- package/docs/index.md +11 -11
- package/docs/overview.md +99 -0
- package/docs/pages/detail.md +1 -1
- package/docs/pages/list.md +1 -1
- package/docs/pages/router.md +151 -0
- package/es/components/uni-vue/index.d.ts +7 -17
- package/es/components/uni-vue/src/uni-vue.vue.d.ts +3 -7
- package/es/components/uni-vue/src/uni-vue.vue2.mjs +1 -3
- package/es/components/uni-vue/src/uni-vue.vue2.mjs.map +1 -1
- package/es/components/uni-vue/src/use-uni-vue.d.ts +1 -1
- package/es/components/uni-vue/src/use-uni-vue.mjs +54 -38
- package/es/components/uni-vue/src/use-uni-vue.mjs.map +1 -1
- package/es/package.json.mjs +1 -1
- package/lib/components/uni-vue/index.d.ts +7 -17
- package/lib/components/uni-vue/src/uni-vue.vue.d.ts +3 -7
- package/lib/components/uni-vue/src/uni-vue.vue2.js +1 -3
- package/lib/components/uni-vue/src/uni-vue.vue2.js.map +1 -1
- package/lib/components/uni-vue/src/use-uni-vue.d.ts +1 -1
- package/lib/components/uni-vue/src/use-uni-vue.js +54 -38
- package/lib/components/uni-vue/src/use-uni-vue.js.map +1 -1
- package/lib/package.json.js +1 -1
- package/package.json +4 -2
- package/docs/components/index.md +0 -23
package/dist/index.full.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! ElPlus v0.0.
|
|
1
|
+
/*! ElPlus v0.0.89 */
|
|
2
2
|
|
|
3
3
|
import { useAttrs, getCurrentInstance, inject, provide, ref, nextTick, defineComponent, computed, createVNode, Fragment, withDirectives, resolveComponent, mergeProps, resolveDirective, useTemplateRef, reactive, onBeforeUpdate, createTextVNode, h, mergeModels, useModel, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, createCommentVNode, withCtx, renderSlot, renderList, createBlock, vShow, toDisplayString, useSlots, watch, onMounted, createSlots, normalizeProps, guardReactiveProps, markRaw, Transition, shallowReactive, isVNode, render, createElementVNode, toRaw } from 'vue';
|
|
4
4
|
import { buttonProps, useLocale as useLocale$1, ElLoading, ElMessage, ElMessageBox, formProps as formProps$1, formEmits as formEmits$1, ElTooltip, formItemProps as formItemProps$1, ElFormItem, ElForm, ElRow, ElCol, inputProps as inputProps$1, inputEmits as inputEmits$1, configProviderContextKey, ElConfigProvider, ElDialog, ElButton, ElTable, ElIcon, selectProps as selectProps$1, selectEmits as selectEmits$1, ElPageHeader, datePickerProps, linkProps as linkProps$1, ElSkeleton } from 'element-plus';
|
|
@@ -14,8 +14,6 @@ import { merge, cloneDeep } from 'lodash-unified';
|
|
|
14
14
|
import { useToggle } from '@vueuse/core';
|
|
15
15
|
import { useRouter, useRoute } from 'vue-router';
|
|
16
16
|
import { encode } from 'js-base64';
|
|
17
|
-
import Vue2 from 'vue2';
|
|
18
|
-
import VueRouter3 from 'vue-router3';
|
|
19
17
|
import dayjs from 'dayjs';
|
|
20
18
|
|
|
21
19
|
const apiProps = {
|
|
@@ -4084,7 +4082,19 @@ const uniVueProps = {
|
|
|
4084
4082
|
// 组件类型 bpm、 address
|
|
4085
4083
|
};
|
|
4086
4084
|
|
|
4087
|
-
|
|
4085
|
+
let Vue2 = null;
|
|
4086
|
+
let VueRouter3 = null;
|
|
4087
|
+
const loadModules = async () => {
|
|
4088
|
+
if (!Vue2) {
|
|
4089
|
+
const vue2Module = await import('vue2');
|
|
4090
|
+
Vue2 = vue2Module.default;
|
|
4091
|
+
}
|
|
4092
|
+
if (!VueRouter3) {
|
|
4093
|
+
const routerModule = await import('vue-router3');
|
|
4094
|
+
VueRouter3 = routerModule.default;
|
|
4095
|
+
}
|
|
4096
|
+
};
|
|
4097
|
+
const useUniVue = (props, _emit) => {
|
|
4088
4098
|
const uniVue = useTemplateRef("uniVue");
|
|
4089
4099
|
const { type } = props;
|
|
4090
4100
|
const loading = ref(true);
|
|
@@ -4109,7 +4119,6 @@ const useUniVue = (props, emit) => {
|
|
|
4109
4119
|
}
|
|
4110
4120
|
}
|
|
4111
4121
|
};
|
|
4112
|
-
setupWindow();
|
|
4113
4122
|
const prepareVueAttributes = () => {
|
|
4114
4123
|
const events = {};
|
|
4115
4124
|
const _props = {};
|
|
@@ -4195,7 +4204,7 @@ const useUniVue = (props, emit) => {
|
|
|
4195
4204
|
const cssPromises = [];
|
|
4196
4205
|
if (!isBpm) {
|
|
4197
4206
|
cssPromises.push(
|
|
4198
|
-
http.request("/
|
|
4207
|
+
http.request("/index.css", {
|
|
4199
4208
|
responseReturn: "raw",
|
|
4200
4209
|
baseURL: ""
|
|
4201
4210
|
}).then((res) => res.data)
|
|
@@ -4217,6 +4226,8 @@ const useUniVue = (props, emit) => {
|
|
|
4217
4226
|
if (instance) {
|
|
4218
4227
|
return;
|
|
4219
4228
|
}
|
|
4229
|
+
await loadModules();
|
|
4230
|
+
setupWindow();
|
|
4220
4231
|
const el = uniVue.value;
|
|
4221
4232
|
const shadowRoot = el.attachShadow({ mode: "open" });
|
|
4222
4233
|
const container = document.createElement("div");
|
|
@@ -4230,6 +4241,12 @@ const useUniVue = (props, emit) => {
|
|
|
4230
4241
|
const style = document.createElement("style");
|
|
4231
4242
|
style.textContent = css;
|
|
4232
4243
|
shadowRoot.appendChild(style);
|
|
4244
|
+
if (isAddress && !document.querySelector("style[data-hx-address-style]")) {
|
|
4245
|
+
const headStyle = document.createElement("style");
|
|
4246
|
+
headStyle.textContent = css;
|
|
4247
|
+
headStyle.setAttribute("data-hx-address-style", "true");
|
|
4248
|
+
document.head.appendChild(headStyle);
|
|
4249
|
+
}
|
|
4233
4250
|
} catch (error) {
|
|
4234
4251
|
console.log(error);
|
|
4235
4252
|
} finally {
|
|
@@ -4237,55 +4254,54 @@ const useUniVue = (props, emit) => {
|
|
|
4237
4254
|
}
|
|
4238
4255
|
}
|
|
4239
4256
|
shadowRoot.appendChild(container);
|
|
4240
|
-
console.log(prepareVueAttributes());
|
|
4241
|
-
const baseEvents = {
|
|
4242
|
-
...prepareVueAttributes().on,
|
|
4243
|
-
"input": (newVal) => {
|
|
4244
|
-
console.log(newVal, "input", props.name);
|
|
4245
|
-
emit("update:modelValue", newVal);
|
|
4246
|
-
},
|
|
4247
|
-
"update:dialogFormData": (newVal) => {
|
|
4248
|
-
console.log(newVal, "update:dialogFormData");
|
|
4249
|
-
emit("update:dialogFormData", newVal);
|
|
4250
|
-
},
|
|
4251
|
-
"update:visible": (newVal) => {
|
|
4252
|
-
console.log(newVal, "update:visible");
|
|
4253
|
-
emit("update:visible", newVal);
|
|
4254
|
-
}
|
|
4255
|
-
};
|
|
4256
4257
|
instance = new Vue2({
|
|
4257
4258
|
el: container,
|
|
4258
|
-
// @ts-expect-error 缺少类型定义
|
|
4259
4259
|
router: new VueRouter3(),
|
|
4260
|
-
render: (h) =>
|
|
4261
|
-
props:
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4260
|
+
render: (h) => {
|
|
4261
|
+
const { on: vue2Events, props: vue2Props } = prepareVueAttributes();
|
|
4262
|
+
return h(props.name, {
|
|
4263
|
+
props: vue2Props,
|
|
4264
|
+
on: vue2Events
|
|
4265
|
+
});
|
|
4266
|
+
}
|
|
4266
4267
|
});
|
|
4267
4268
|
};
|
|
4269
|
+
const updateVue2Instance = () => {
|
|
4270
|
+
if (!instance) return;
|
|
4271
|
+
const child = instance.$children[0];
|
|
4272
|
+
if (child) {
|
|
4273
|
+
const { props: vue2Props } = prepareVueAttributes();
|
|
4274
|
+
Object.assign(child.$options.propsData, vue2Props);
|
|
4275
|
+
if (child._props) {
|
|
4276
|
+
Object.keys(vue2Props).forEach((key) => {
|
|
4277
|
+
const newValue = vue2Props[key];
|
|
4278
|
+
const oldValue = child._props[key];
|
|
4279
|
+
if (newValue === oldValue && typeof newValue === "object" && newValue !== null) {
|
|
4280
|
+
const temp = {};
|
|
4281
|
+
child._props[key] = temp;
|
|
4282
|
+
}
|
|
4283
|
+
child._props[key] = newValue;
|
|
4284
|
+
});
|
|
4285
|
+
}
|
|
4286
|
+
child.$forceUpdate();
|
|
4287
|
+
}
|
|
4288
|
+
instance.$forceUpdate();
|
|
4289
|
+
};
|
|
4268
4290
|
Object.keys(attrs).forEach((key) => {
|
|
4269
|
-
console.log(key, 8);
|
|
4270
4291
|
if (!key.startsWith("on")) {
|
|
4271
4292
|
watch(
|
|
4272
4293
|
() => attrs[key],
|
|
4273
|
-
(
|
|
4294
|
+
() => {
|
|
4295
|
+
console.log(key, "key");
|
|
4274
4296
|
nextTick(() => {
|
|
4275
4297
|
try {
|
|
4276
|
-
|
|
4277
|
-
let vue2Prop = key;
|
|
4278
|
-
if (key === "modelValue") {
|
|
4279
|
-
vue2Prop = "value";
|
|
4280
|
-
}
|
|
4281
|
-
instance.$children[0][vue2Prop] = newVal;
|
|
4298
|
+
updateVue2Instance();
|
|
4282
4299
|
} catch (e) {
|
|
4283
4300
|
}
|
|
4284
4301
|
});
|
|
4285
4302
|
},
|
|
4286
4303
|
{
|
|
4287
|
-
deep: true
|
|
4288
|
-
immediate: true
|
|
4304
|
+
deep: true
|
|
4289
4305
|
}
|
|
4290
4306
|
);
|
|
4291
4307
|
}
|
|
@@ -4305,12 +4321,10 @@ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
4305
4321
|
},
|
|
4306
4322
|
__name: "uni-vue",
|
|
4307
4323
|
props: uniVueProps,
|
|
4308
|
-
emits: ["update:modelValue", "update:dialogFormData", "update:visible"],
|
|
4309
4324
|
setup(__props, { emit: __emit }) {
|
|
4310
4325
|
const bem = createNameSpace("uni-vue");
|
|
4311
4326
|
const props = __props;
|
|
4312
|
-
const
|
|
4313
|
-
const { loading } = useUniVue(props, emit);
|
|
4327
|
+
const { loading } = useUniVue(props);
|
|
4314
4328
|
return (_ctx, _cache) => {
|
|
4315
4329
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
4316
4330
|
createVNode(unref(ElSkeleton), {
|
|
@@ -4461,7 +4475,7 @@ var components = [
|
|
|
4461
4475
|
EpFooterInfo
|
|
4462
4476
|
];
|
|
4463
4477
|
|
|
4464
|
-
var version = "0.0.
|
|
4478
|
+
var version = "0.0.89";
|
|
4465
4479
|
|
|
4466
4480
|
var globalProperties = {
|
|
4467
4481
|
install(app) {
|
|
@@ -14,19 +14,55 @@ const buttons = [
|
|
|
14
14
|
{
|
|
15
15
|
name: '新增',
|
|
16
16
|
prop: 'add',
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
onClick: () => {
|
|
18
|
+
// 新增逻辑
|
|
19
|
+
},
|
|
19
20
|
},
|
|
20
21
|
{
|
|
21
22
|
name: '删除',
|
|
22
23
|
prop: 'delete',
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
onClick: () => {
|
|
25
|
+
// 删除逻辑
|
|
26
|
+
},
|
|
25
27
|
},
|
|
26
28
|
]
|
|
27
29
|
</script>
|
|
28
30
|
```
|
|
29
31
|
|
|
32
|
+
## 在 Form 中使用
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
const formItemList = ref<FormProps['formItemList']>([
|
|
36
|
+
{
|
|
37
|
+
col: 24,
|
|
38
|
+
type: 'EpButtons',
|
|
39
|
+
props: {
|
|
40
|
+
list: [
|
|
41
|
+
{
|
|
42
|
+
name: '提交审批',
|
|
43
|
+
type: 'primary',
|
|
44
|
+
onClick: () => {
|
|
45
|
+
// 提交审批逻辑
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: '取消审批',
|
|
50
|
+
onClick: () => {
|
|
51
|
+
// 取消审批逻辑
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: '作废',
|
|
56
|
+
onClick: () => {
|
|
57
|
+
// 作废逻辑
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
])
|
|
64
|
+
```
|
|
65
|
+
|
|
30
66
|
## Props
|
|
31
67
|
|
|
32
68
|
| 属性 | 说明 | 类型 | 默认值 |
|
|
@@ -38,18 +74,19 @@ const buttons = [
|
|
|
38
74
|
|
|
39
75
|
## ButtonProps 配置
|
|
40
76
|
|
|
41
|
-
| 属性 | 说明 | 类型 |
|
|
42
|
-
|
|
43
|
-
| name | 按钮文本 | `string` |
|
|
44
|
-
| prop | 唯一标识 | `string` |
|
|
45
|
-
| type | 按钮类型 | `'primary' \| 'success' \| 'warning' \| 'danger' \| 'info'` |
|
|
46
|
-
| plain | 朴素按钮 | `boolean` |
|
|
47
|
-
| disabled | 是否禁用 | `boolean \| () => boolean` |
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
77
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
78
|
+
|------|------|------|--------|
|
|
79
|
+
| name | 按钮文本 | `string` | - |
|
|
80
|
+
| prop | 唯一标识 | `string` | - |
|
|
81
|
+
| type | 按钮类型 | `'primary' \| 'success' \| 'warning' \| 'danger' \| 'info'` | - |
|
|
82
|
+
| plain | 朴素按钮 | `boolean` | `false` |
|
|
83
|
+
| disabled | 是否禁用 | `boolean \| () => boolean` | `false` |
|
|
84
|
+
| show | 是否显示(支持函数) | `boolean \| () => boolean` | `true` |
|
|
85
|
+
| hide | 是否隐藏(支持函数) | `boolean \| () => boolean` | `false` |
|
|
86
|
+
| permission | 权限标识 | `string` | - |
|
|
87
|
+
| confirm | 是否需要确认 | `boolean` | `false` |
|
|
88
|
+
| confirmText | 确认提示文本 | `string` | `'确定要${name}吗?'` |
|
|
89
|
+
| onClick | 点击回调 | `(e: MouseEvent \| TableScope) => void` | - |
|
|
53
90
|
|
|
54
91
|
## 带确认弹窗
|
|
55
92
|
|
|
@@ -58,9 +95,7 @@ const buttons = [
|
|
|
58
95
|
{
|
|
59
96
|
name: '删除',
|
|
60
97
|
prop: 'delete',
|
|
61
|
-
type: 'danger',
|
|
62
98
|
confirm: true,
|
|
63
|
-
confirmText: '确定要删除吗?',
|
|
64
99
|
onClick: () => {
|
|
65
100
|
// 删除逻辑
|
|
66
101
|
},
|
|
@@ -68,6 +103,18 @@ const buttons = [
|
|
|
68
103
|
]
|
|
69
104
|
```
|
|
70
105
|
|
|
106
|
+
> **⚠️ 注意:需要确认弹窗时,必须使用 `confirm: true` 属性,禁止手动编写 `ElMessageBox.confirm`**
|
|
107
|
+
>
|
|
108
|
+
> **正确做法**:
|
|
109
|
+
> ```tsx
|
|
110
|
+
> { name: '取消审批', confirm: true, onClick: () => { ElMessage.success('成功') } }
|
|
111
|
+
> ```
|
|
112
|
+
>
|
|
113
|
+
> **错误做法**:
|
|
114
|
+
> ```tsx
|
|
115
|
+
> { name: '取消审批', onClick: () => { ElMessageBox.confirm(...).then(...) } }
|
|
116
|
+
> ```
|
|
117
|
+
|
|
71
118
|
## 权限控制
|
|
72
119
|
|
|
73
120
|
```tsx
|
|
@@ -101,7 +148,7 @@ const buttons = [
|
|
|
101
148
|
{
|
|
102
149
|
name: '审核',
|
|
103
150
|
prop: 'audit',
|
|
104
|
-
|
|
151
|
+
show: () => formData.status === 'pending',
|
|
105
152
|
onClick: () => {},
|
|
106
153
|
},
|
|
107
154
|
]
|
package/docs/components/form.md
CHANGED
|
@@ -42,10 +42,28 @@ const formItemList = ref<FormProps['formItemList']>([
|
|
|
42
42
|
```
|
|
43
43
|
## 表单数据
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
**不需要预定义表单字段**,`reactive({})` 即可,组件会自动管理字段值。
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// ✅ 正确:无需预定义字段
|
|
49
|
+
const formData = reactive({})
|
|
50
|
+
|
|
51
|
+
// ❌ 错误:不需要提前声明所有字段
|
|
52
|
+
const formData = reactive({
|
|
53
|
+
name: '',
|
|
54
|
+
status: '',
|
|
55
|
+
applicant: '',
|
|
56
|
+
// ...
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**仅需预定义以下特殊字段:**
|
|
61
|
+
|
|
62
|
+
| 场景 | 需预定义的字段 | 示例 |
|
|
63
|
+
|------|---------------|------|
|
|
64
|
+
| 日期范围 | 开始和结束两个独立字段 | `orderDateStart: ''`, `orderDateEnd: ''` |
|
|
65
|
+
| 表格数组 | 空数组 | `detailList: []` |
|
|
66
|
+
| 附件数组 | 空数组 | `fileList: []` |
|
|
49
67
|
|
|
50
68
|
## Props
|
|
51
69
|
|
|
@@ -72,7 +90,8 @@ const formItemList = ref<FormProps['formItemList']>([
|
|
|
72
90
|
| label | 标签文本 | `string` | - |
|
|
73
91
|
| col | 占用列数 | `number` | - |
|
|
74
92
|
| disabled | 是否禁用 | `boolean` | `false` |
|
|
75
|
-
|
|
|
93
|
+
| show | 是否显示(支持函数) | `boolean \| () => boolean` | `true` |
|
|
94
|
+
| hide | 是否隐藏(支持函数) | `boolean \| () => boolean` | `false` |
|
|
76
95
|
| required | 是否必填 | `boolean` | `false` |
|
|
77
96
|
| rules | 校验规则 | `FormItemRule[]` | - |
|
|
78
97
|
| props | 传递给组件的属性 | `object` | - |
|
|
@@ -92,3 +92,26 @@ const attachmentProps: HeaderProps['attachmentProps'] = {
|
|
|
92
92
|
}
|
|
93
93
|
</script>
|
|
94
94
|
```
|
|
95
|
+
|
|
96
|
+
## 在 Form 中使用
|
|
97
|
+
|
|
98
|
+
EpHeader 也可以作为表单项放入 EpForm 中,作为表单的一部分:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
const formItemList = ref<FormProps['formItemList']>([
|
|
102
|
+
{
|
|
103
|
+
col: 24,
|
|
104
|
+
type: 'EpHeader',
|
|
105
|
+
props: {
|
|
106
|
+
buttons: [
|
|
107
|
+
{ name: '提交审批', type: 'primary', onClick: () => {} },
|
|
108
|
+
{ name: '取消审批', onClick: () => {} },
|
|
109
|
+
{ name: '作废', onClick: () => {} },
|
|
110
|
+
],
|
|
111
|
+
isShowAttachmentButton: true,
|
|
112
|
+
fileList: formData.fileList,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
// 其他表单项...
|
|
116
|
+
])
|
|
117
|
+
```
|
|
@@ -57,7 +57,7 @@ const handleAdd = () => {}
|
|
|
57
57
|
| reqParams | URL 参数 | `object` | `{}` |
|
|
58
58
|
| reqBefore | 请求前处理 | `(reqData) => reqData` | - |
|
|
59
59
|
| reqAfter | 响应后处理 | `(res) => data` | - |
|
|
60
|
-
| formData |
|
|
60
|
+
| formData | 表单数据,参考 [EpForm 表单数据说明](./form.md#表单数据) | `object` | `{}` |
|
|
61
61
|
| formItemList | 搜索表单配置 | [`FormItemProps[]`](./form.md#formitemprops-配置) | `[]` |
|
|
62
62
|
| columns | 表格列配置(有customColumnModule就不需要定义列) | [`TableColumn[]`](./table.md#tablecolumn-配置) | `[]` |
|
|
63
63
|
| leftButtons | 左侧按钮 | [`ButtonProps[]`](./buttons.md#buttonprops-配置) | `[]` |
|
|
@@ -77,5 +77,15 @@ const handleAdd = () => {}
|
|
|
77
77
|
| buttonsProps | 按钮组额外属性 | `object` | - |
|
|
78
78
|
| name | 权限前缀 | `string` | - |
|
|
79
79
|
| customColumnModule | 自定义列模块 | `string \| number` | - |
|
|
80
|
+
|
|
81
|
+
::: warning 互斥关系
|
|
82
|
+
`customColumnModule` 和以下配置是**互斥**的:
|
|
83
|
+
- `columns`:设置了 `customColumnModule` 后会忽略 `columns`
|
|
84
|
+
- `leftButtons` 中的"自定义列设置"按钮:组件会自动内置该按钮
|
|
85
|
+
|
|
86
|
+
**正确用法**:
|
|
87
|
+
- 启用自定义列:`customColumnModule: "moduleName"`(无需配 columns 和自定义列按钮)
|
|
88
|
+
- 固定列模式:不设置 `customColumnModule`,使用 `columns` 配置
|
|
89
|
+
:::
|
|
80
90
|
| customColumnApi | 自定义列接口 | `string` | - |
|
|
81
91
|
| customColumnSaveApi | 自定义列保存接口 | `string` | - |
|
package/docs/components/table.md
CHANGED
|
@@ -78,7 +78,8 @@ const actionButtons = [
|
|
|
78
78
|
| headerRender | 自定义表头渲染 | `() => VNode` |
|
|
79
79
|
| required | 是否必填 | `boolean \| () => boolean` |
|
|
80
80
|
| disabled | 是否禁用 | `boolean \| (scope) => boolean` |
|
|
81
|
-
|
|
|
81
|
+
| show | 是否显示(支持函数) | `boolean \| () => boolean` |
|
|
82
|
+
| hide | 是否隐藏(支持函数) | `boolean \| () => boolean` |
|
|
82
83
|
| filter | 显示筛选 | `boolean` |
|
|
83
84
|
| editable | 可批量编辑 | `boolean` |
|
|
84
85
|
|
|
@@ -13,14 +13,13 @@
|
|
|
13
13
|
<script setup lang="tsx">
|
|
14
14
|
import { useFormDialog } from 'el-plus'
|
|
15
15
|
|
|
16
|
-
const formItemList = [
|
|
17
|
-
{ prop: 'name', label: '姓名', required: true },
|
|
18
|
-
{ prop: 'age', label: '年龄' },
|
|
19
|
-
]
|
|
20
16
|
|
|
21
17
|
const FormDialog = useFormDialog({
|
|
22
18
|
title: '用户信息',
|
|
23
|
-
formItemList
|
|
19
|
+
formItemList:[
|
|
20
|
+
{ prop: 'name', label: '姓名', required: true },
|
|
21
|
+
{ prop: 'age', label: '年龄' },
|
|
22
|
+
],
|
|
24
23
|
dialogProps: {
|
|
25
24
|
destroyOnClose: true, // 关闭时销毁对话框内容
|
|
26
25
|
},
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# useNavigation 导航
|
|
2
|
+
|
|
3
|
+
提供路由导航、标签页管理和页面模式控制等功能。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<div>
|
|
10
|
+
<el-button @click="handleEdit">编辑</el-button>
|
|
11
|
+
<el-button @click="handleGoto">跳转新页面</el-button>
|
|
12
|
+
<el-button @click="handleClose">关闭当前页</el-button>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { useNavigation } from 'el-plus'
|
|
18
|
+
|
|
19
|
+
const { $goto, $closeTag, mode, setMode, isBrowse, isEdit, isAdd } = useNavigation({
|
|
20
|
+
onModeChange: (newMode) => {
|
|
21
|
+
console.log('模式变化:', newMode)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// 编辑模式
|
|
26
|
+
const handleEdit = () => {
|
|
27
|
+
setMode('edit')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 跳转到新页面
|
|
31
|
+
const handleGoto = () => {
|
|
32
|
+
$goto({
|
|
33
|
+
name: 'detail',
|
|
34
|
+
query: { id: '123' }
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 关闭当前标签页
|
|
39
|
+
const handleClose = () => {
|
|
40
|
+
$closeTag()
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 参数
|
|
46
|
+
|
|
47
|
+
### Config 配置
|
|
48
|
+
|
|
49
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
50
|
+
|------|------|------|--------|
|
|
51
|
+
| onModeChange | 模式变化时的回调函数 | `(mode: PageMode) => void` | - |
|
|
52
|
+
|
|
53
|
+
## 返回值
|
|
54
|
+
|
|
55
|
+
| 属性 | 说明 | 类型 |
|
|
56
|
+
|------|------|------|
|
|
57
|
+
| $goto | 打开新窗口或跳转路由 | `(config: NavigationConfig) => void` |
|
|
58
|
+
| $closeTag | 关闭当前标签页 | `() => void` |
|
|
59
|
+
| mode | 当前页面模式 | `ComputedRef<PageMode>` |
|
|
60
|
+
| isBrowse | 是否为浏览模式 | `ComputedRef<boolean>` |
|
|
61
|
+
| isEdit | 是否为编辑模式 | `ComputedRef<boolean>` |
|
|
62
|
+
| isAdd | 是否为新增模式 | `ComputedRef<boolean>` |
|
|
63
|
+
| setMode | 设置页面模式 | `(mode: PageMode, callback?: (mode: PageMode) => void) => void` |
|
|
64
|
+
|
|
65
|
+
## 类型定义
|
|
66
|
+
|
|
67
|
+
### PageMode
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
type PageMode = 'add' | 'edit' | 'browse'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### NavigationConfig
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
interface NavigationConfig {
|
|
77
|
+
id?: number | string // 菜单id
|
|
78
|
+
name?: string // 路由模块name,适用于内部跳转
|
|
79
|
+
title?: string // 菜单名称,适用于传外部url跳转
|
|
80
|
+
url?: string // 菜单url
|
|
81
|
+
query?: Record<string, any> // url参数
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 功能说明
|
|
86
|
+
|
|
87
|
+
### $goto 路由跳转
|
|
88
|
+
|
|
89
|
+
支持两种跳转方式:
|
|
90
|
+
|
|
91
|
+
**内部路由跳转**
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
$goto({
|
|
95
|
+
name: 'userDetail',
|
|
96
|
+
query: { id: '123', mode: 'browse' }
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**外部URL跳转**
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
$goto({
|
|
104
|
+
url: 'https://example.com',
|
|
105
|
+
title: '外部链接'
|
|
106
|
+
})
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### setMode 模式切换
|
|
110
|
+
|
|
111
|
+
用于详情页的模式切换,自动更新URL参数并触发回调。
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
// 切换到编辑模式
|
|
115
|
+
setMode('edit')
|
|
116
|
+
|
|
117
|
+
// 切换并执行回调
|
|
118
|
+
setMode('edit', (mode) => {
|
|
119
|
+
console.log('已切换到编辑模式')
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### $closeTag 关闭标签页
|
|
124
|
+
|
|
125
|
+
关闭当前标签页并自动切换到前一个标签页,需要在支持标签页管理的环境中使用。
|
|
126
|
+
|
|
127
|
+
## 注意事项
|
|
128
|
+
|
|
129
|
+
- 该 hook 依赖 `vue-router`,必须在路由环境中使用
|
|
130
|
+
- `$closeTag` 方法依赖父窗口的标签页管理功能
|
|
131
|
+
- `setMode` 会修改URL的query参数,刷新页面后模式会保持
|