@agile-team/wl-skills-kit 2.11.0 → 2.11.2
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 +47 -9
- package/README.md +41 -23
- package/bin/wl-skills.js +133 -39
- package/docs/agent-pipeline-runbook.md +3 -3
- package/docs//345/205/250/347/233/230/345/210/206/346/236/220/344/270/216/346/231/272/350/203/275/344/275/223/346/220/255/345/273/272/346/214/207/345/215/227.md +4 -4
- package/files/.wl-skills/copilot-instructions-full.md +233 -233
- package/files/.wl-skills/docs/jh-pagination.md +505 -505
- package/files/.wl-skills/docs/page-spec-schema.md +109 -0
- package/files/.wl-skills/docs/request.md +940 -940
- package/files/.wl-skills/guides/architecture.md +1 -1
- package/files/.wl-skills/skills/core/convention-audit/SKILL.md +3 -3
- package/files/.wl-skills/skills/core/page-codegen/SKILL.md +10 -4
- package/files/.wl-skills/skills/core/spec-doc-parse/SKILL.md +332 -332
- package/files/.wl-skills/skills/core/spec-doc-parse/USAGE.md +97 -97
- package/files/.wl-skills/skills/sync/permission-sync/USAGE.md +107 -107
- package/files/.wl-skills/src/components/global/C_ParentView/index.vue +3 -3
- package/files/.wl-skills/src/components/global/C_RightToolbar/index.vue +157 -157
- package/files/.wl-skills/src/components/global/C_SvgIcon/index.vue +31 -31
- package/files/.wl-skills/src/components/global/C_SvgIcon/svgicon.js +10 -10
- package/files/.wl-skills/src/components/global/C_TagStatus/README.md +264 -264
- package/files/.wl-skills/src/components/global/C_TagStatus/config.ts +192 -192
- package/files/.wl-skills/src/components/global/C_TagStatus/index.vue +106 -106
- package/files/.wl-skills/src/components/global/C_TagStatus/types.ts +64 -64
- package/files/.wl-skills/src/components/global/C_Tree/README.md +153 -153
- package/files/.wl-skills/src/components/global/C_Tree/index.scss +42 -42
- package/files/.wl-skills/src/components/global/C_Tree/index.vue +78 -78
- package/files/.wl-skills/src/components/global/C_Tree/types.ts +59 -59
- package/files/.wl-skills/src/components/local/c_formModal/README.md +235 -235
- package/files/.wl-skills/src/components/local/c_formModal/data.ts +95 -95
- package/files/.wl-skills/src/components/local/c_formModal/index.scss +8 -8
- package/files/.wl-skills/src/components/local/c_formModal/index.vue +107 -107
- package/files/.wl-skills/src/components/local/c_formSections/data.ts +175 -175
- package/files/.wl-skills/src/components/local/c_formSections/index.scss +280 -280
- package/files/.wl-skills/src/components/local/c_formSections/index.vue +429 -429
- package/files/.wl-skills/src/components/local/c_listModal/data.ts +41 -41
- package/files/.wl-skills/src/components/local/c_listModal/index.vue +136 -136
- package/files/.wl-skills/src/components/local/c_spliterTitle/index.scss +25 -25
- package/files/.wl-skills/src/components/local/c_spliterTitle/index.vue +21 -21
- package/files/.wl-skills/src/components/remote/AGGrid/README.md +530 -530
- package/files/.wl-skills/src/components/remote/BaseForm/README.md +508 -508
- package/files/.wl-skills/src/components/remote/BaseQuery/README.md +865 -865
- package/files/.wl-skills/src/components/remote/BaseTable/README.md +941 -941
- package/files/.wl-skills/src/components/remote/BaseToolbar/README.md +496 -496
- package/files/.wl-skills/src/types/page.ts +24 -24
- package/files/.wl-skills/standards/04-coding-basics.md +39 -1
- package/files/.wl-skills/standards/09-typescript.md +26 -3
- package/files/.wl-skills/standards/14-layout-containers.md +6 -6
- package/files/.wl-skills/standards/index.md +2 -2
- package/files/.wl-skills/templates/README.md +44 -44
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-add/api.md +54 -54
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-add/data.ts +346 -346
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-add/index.scss +1 -1
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-add/index.vue +28 -28
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-add-form/data.ts +115 -115
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-add-form/index.scss +44 -44
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-add-form/index.vue +43 -43
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-change/data.ts +338 -338
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-change/index.scss +1 -1
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-change/index.vue +28 -28
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-change-form/data.ts +115 -115
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-change-form/index.scss +44 -44
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-apply-change-form/index.vue +43 -43
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-archive/api.md +88 -88
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-archive/data.ts +601 -601
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-archive/index.scss +1 -1
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-archive/index.vue +64 -64
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-detail/api.md +67 -67
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-detail/data.ts +286 -286
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-detail/index.scss +139 -139
- package/files/.wl-skills/templates/produce/aiflow/mmwr-customer-detail/index.vue +318 -318
- package/files/.wl-skills/templates/produce/aiflow/mmwr-temp-customer-archive/api.md +98 -98
- package/files/.wl-skills/templates/produce/aiflow/mmwr-temp-customer-archive/data.ts +543 -543
- package/files/.wl-skills/templates/produce/aiflow/mmwr-temp-customer-archive/index.scss +1 -1
- package/files/.wl-skills/templates/produce/aiflow/mmwr-temp-customer-archive/index.vue +52 -52
- package/files/.wl-skills/templates/sale/demo/add-demo/data.ts +518 -518
- package/files/.wl-skills/templates/sale/demo/billet-flame-cut-plan/data.ts +524 -524
- package/files/.wl-skills/templates/sale/demo/billet-flame-cut-plan/index.scss +154 -154
- package/files/.wl-skills/templates/sale/demo/billet-flame-cut-plan/index.vue +117 -117
- package/files/.wl-skills/templates/sale/demo/domestic-trade-order/data.ts +308 -308
- package/files/.wl-skills/templates/sale/demo/domestic-trade-order/index.scss +99 -99
- package/files/.wl-skills/templates/sale/demo/domestic-trade-order/index.vue +77 -77
- package/files/.wl-skills/templates/sale/demo/heat-batch-return/data.ts +367 -367
- package/files/.wl-skills/templates/sale/demo/heat-batch-return/index.scss +100 -100
- package/files/.wl-skills/templates/sale/demo/heat-batch-return/index.vue +170 -170
- package/files/.wl-skills/templates/sale/demo/heat-batch-return/meltDialog.vue +320 -320
- package/files/.wl-skills/templates/sale/demo/metallurgical-spec/data.ts +824 -824
- package/lib/ast-rules.js +304 -9
- package/lib/page-spec.js +588 -0
- package/lib/safe-fix.js +115 -0
- package/mcp/config.js +47 -47
- package/mcp/registry.js +6 -1
- package/mcp/tools/projectTools.js +19 -1
- package/package.json +16 -11
- package/files/.wl-skills/src/components/global/C_Splitter/index.scss +0 -61
- package/files/.wl-skills/src/components/global/C_Splitter/index.vue +0 -149
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: ChenYu ycyplus@gmail.com
|
|
3
|
-
* @Date: 2026-01-01 13:30:00
|
|
4
|
-
* @LastEditors: ChenYu ycyplus@gmail.com
|
|
5
|
-
* @LastEditTime: 2026-01-04 08:18:10
|
|
6
|
-
* @FilePath: \cx-ui-sale\src\components\local\c_formModal\data.ts
|
|
7
|
-
* @Description: 表单弹窗组件 - 数据逻辑层
|
|
8
|
-
* Copyright (c) 2026 by CHENY, All Rights Reserved 😎.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import type { Ref } from "vue";
|
|
12
|
-
import { AbstractFormHook } from "@jhlc/common-core/src/page-hooks/form-hook";
|
|
13
|
-
import type { BaseFormItemDesc } from "@jhlc/common-core/src/components/form/common/type";
|
|
14
|
-
import request from "@jhlc/common-core/src/util/request";
|
|
15
|
-
|
|
16
|
-
export interface ModalApi {
|
|
17
|
-
getById: string;
|
|
18
|
-
save: string;
|
|
19
|
-
update: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export type ModalMode = "add" | "edit" | "view";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 创建表单弹窗 Hook
|
|
26
|
-
* @param props - 组件 Props
|
|
27
|
-
* @param mode - 当前模式
|
|
28
|
-
* @param emit - 事件触发器
|
|
29
|
-
*/
|
|
30
|
-
export function createFormModal(
|
|
31
|
-
props: {
|
|
32
|
-
formItems: BaseFormItemDesc<any>[];
|
|
33
|
-
api: ModalApi;
|
|
34
|
-
titlePrefix?: string;
|
|
35
|
-
},
|
|
36
|
-
mode: Ref<ModalMode>,
|
|
37
|
-
emit: (event: "ok") => void
|
|
38
|
-
) {
|
|
39
|
-
const Page = new (class extends AbstractFormHook {
|
|
40
|
-
constructor() {
|
|
41
|
-
super({});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
formItemsDefine(): BaseFormItemDesc<any>[] {
|
|
45
|
-
return props.formItems;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async save() {
|
|
49
|
-
// 表单验证
|
|
50
|
-
const valid = await new Promise<boolean>((resolve) => {
|
|
51
|
-
this.validate((isValid) => resolve(isValid));
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (!valid) return;
|
|
55
|
-
|
|
56
|
-
// 根据模式调用不同 API
|
|
57
|
-
const res = await request({
|
|
58
|
-
url: mode.value === "add" ? props.api.save : props.api.update,
|
|
59
|
-
method: mode.value === "add" ? "post" : "put",
|
|
60
|
-
data: this.form.value
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// 成功提示并关闭
|
|
64
|
-
this.msgSuccess(res.message || "操作成功");
|
|
65
|
-
this.visible.value = false;
|
|
66
|
-
emit("ok");
|
|
67
|
-
|
|
68
|
-
return res;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async getById(id: string) {
|
|
72
|
-
const data = await request({
|
|
73
|
-
url: props.api.getById,
|
|
74
|
-
method: "get",
|
|
75
|
-
params: { id }
|
|
76
|
-
});
|
|
77
|
-
this.form.value = data.data;
|
|
78
|
-
return data;
|
|
79
|
-
}
|
|
80
|
-
})();
|
|
81
|
-
|
|
82
|
-
return Page.create();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 计算弹窗标题
|
|
87
|
-
*/
|
|
88
|
-
export function computeTitle(mode: ModalMode, titlePrefix: string): string {
|
|
89
|
-
const prefixMap = {
|
|
90
|
-
add: "新增",
|
|
91
|
-
edit: "编辑",
|
|
92
|
-
view: "查看"
|
|
93
|
-
};
|
|
94
|
-
return `${prefixMap[mode]}${titlePrefix}`;
|
|
95
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* @Author: ChenYu ycyplus@gmail.com
|
|
3
|
+
* @Date: 2026-01-01 13:30:00
|
|
4
|
+
* @LastEditors: ChenYu ycyplus@gmail.com
|
|
5
|
+
* @LastEditTime: 2026-01-04 08:18:10
|
|
6
|
+
* @FilePath: \cx-ui-sale\src\components\local\c_formModal\data.ts
|
|
7
|
+
* @Description: 表单弹窗组件 - 数据逻辑层
|
|
8
|
+
* Copyright (c) 2026 by CHENY, All Rights Reserved 😎.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { Ref } from "vue";
|
|
12
|
+
import { AbstractFormHook } from "@jhlc/common-core/src/page-hooks/form-hook";
|
|
13
|
+
import type { BaseFormItemDesc } from "@jhlc/common-core/src/components/form/common/type";
|
|
14
|
+
import request from "@jhlc/common-core/src/util/request";
|
|
15
|
+
|
|
16
|
+
export interface ModalApi {
|
|
17
|
+
getById: string;
|
|
18
|
+
save: string;
|
|
19
|
+
update: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type ModalMode = "add" | "edit" | "view";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 创建表单弹窗 Hook
|
|
26
|
+
* @param props - 组件 Props
|
|
27
|
+
* @param mode - 当前模式
|
|
28
|
+
* @param emit - 事件触发器
|
|
29
|
+
*/
|
|
30
|
+
export function createFormModal(
|
|
31
|
+
props: {
|
|
32
|
+
formItems: BaseFormItemDesc<any>[];
|
|
33
|
+
api: ModalApi;
|
|
34
|
+
titlePrefix?: string;
|
|
35
|
+
},
|
|
36
|
+
mode: Ref<ModalMode>,
|
|
37
|
+
emit: (event: "ok") => void
|
|
38
|
+
) {
|
|
39
|
+
const Page = new (class extends AbstractFormHook {
|
|
40
|
+
constructor() {
|
|
41
|
+
super({});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
formItemsDefine(): BaseFormItemDesc<any>[] {
|
|
45
|
+
return props.formItems;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async save() {
|
|
49
|
+
// 表单验证
|
|
50
|
+
const valid = await new Promise<boolean>((resolve) => {
|
|
51
|
+
this.validate((isValid) => resolve(isValid));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (!valid) return;
|
|
55
|
+
|
|
56
|
+
// 根据模式调用不同 API
|
|
57
|
+
const res = await request({
|
|
58
|
+
url: mode.value === "add" ? props.api.save : props.api.update,
|
|
59
|
+
method: mode.value === "add" ? "post" : "put",
|
|
60
|
+
data: this.form.value
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// 成功提示并关闭
|
|
64
|
+
this.msgSuccess(res.message || "操作成功");
|
|
65
|
+
this.visible.value = false;
|
|
66
|
+
emit("ok");
|
|
67
|
+
|
|
68
|
+
return res;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async getById(id: string) {
|
|
72
|
+
const data = await request({
|
|
73
|
+
url: props.api.getById,
|
|
74
|
+
method: "get",
|
|
75
|
+
params: { id }
|
|
76
|
+
});
|
|
77
|
+
this.form.value = data.data;
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
80
|
+
})();
|
|
81
|
+
|
|
82
|
+
return Page.create();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 计算弹窗标题
|
|
87
|
+
*/
|
|
88
|
+
export function computeTitle(mode: ModalMode, titlePrefix: string): string {
|
|
89
|
+
const prefixMap = {
|
|
90
|
+
add: "新增",
|
|
91
|
+
edit: "编辑",
|
|
92
|
+
view: "查看"
|
|
93
|
+
};
|
|
94
|
+
return `${prefixMap[mode]}${titlePrefix}`;
|
|
95
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Description: c_formModal 样式
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
.dialog-footer {
|
|
6
|
-
display: flex;
|
|
7
|
-
justify-content: flex-end;
|
|
8
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @Description: c_formModal 样式
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
.dialog-footer {
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: flex-end;
|
|
8
|
+
}
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
* @Author: ChenYu ycyplus@gmail.com
|
|
3
|
-
* @Date: 2026-01-01 13:30:00
|
|
4
|
-
* @LastEditors: ChenYu ycyplus@gmail.com
|
|
5
|
-
* @LastEditTime: 2026-01-04 09:17:43
|
|
6
|
-
* @FilePath: \cx-ui-sale\src\components\local\c_formModal\index.vue
|
|
7
|
-
* @Description: 表单弹窗组件 (新增、编辑、详情)
|
|
8
|
-
* Copyright (c) 2026 by CHENY, All Rights Reserved 😎.
|
|
9
|
-
-->
|
|
10
|
-
<template>
|
|
11
|
-
<jh-dialog v-model="visible" :width="width" :title="currentTitle">
|
|
12
|
-
<BaseForm
|
|
13
|
-
ref="formRef"
|
|
14
|
-
:form="form"
|
|
15
|
-
:items="formItems"
|
|
16
|
-
:columns="columns"
|
|
17
|
-
:label-width="labelWidth"
|
|
18
|
-
:disabled="mode === 'view'"
|
|
19
|
-
/>
|
|
20
|
-
<template #footer>
|
|
21
|
-
<div class="dialog-footer">
|
|
22
|
-
<BaseToolbar
|
|
23
|
-
v-if="mode !== 'view'"
|
|
24
|
-
:items="cancelConfirmButtons(() => (visible = false), save)"
|
|
25
|
-
/>
|
|
26
|
-
<BaseToolbar
|
|
27
|
-
v-else
|
|
28
|
-
:items="[{ label: '关闭', onClick: () => (visible = false) }]"
|
|
29
|
-
/>
|
|
30
|
-
</div>
|
|
31
|
-
</template>
|
|
32
|
-
</jh-dialog>
|
|
33
|
-
</template>
|
|
34
|
-
|
|
35
|
-
<script setup lang="ts">
|
|
36
|
-
import type { BaseFormItemDesc } from "@jhlc/common-core/src/components/form/common/type";
|
|
37
|
-
import { cancelConfirmButtons } from "@jhlc/common-core/src/components/toolbar/toolbar-data";
|
|
38
|
-
import {
|
|
39
|
-
createFormModal,
|
|
40
|
-
computeTitle,
|
|
41
|
-
type ModalApi,
|
|
42
|
-
type ModalMode
|
|
43
|
-
} from "./data";
|
|
44
|
-
|
|
45
|
-
interface Props {
|
|
46
|
-
formItems: BaseFormItemDesc<any>[];
|
|
47
|
-
api: ModalApi;
|
|
48
|
-
width?: string;
|
|
49
|
-
columns?: number;
|
|
50
|
-
labelWidth?: string;
|
|
51
|
-
titlePrefix?: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
55
|
-
width: "850px",
|
|
56
|
-
columns: 2,
|
|
57
|
-
labelWidth: "110px",
|
|
58
|
-
titlePrefix: "数据"
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const emit = defineEmits(["ok"]);
|
|
62
|
-
|
|
63
|
-
// 当前模式
|
|
64
|
-
const mode = ref<ModalMode>("add");
|
|
65
|
-
|
|
66
|
-
// 创建页面Hook实例
|
|
67
|
-
const Page = createFormModal(props, mode, emit);
|
|
68
|
-
|
|
69
|
-
// 解构使用
|
|
70
|
-
const { visible, formRef, form, formItems, save, reset } = Page;
|
|
71
|
-
|
|
72
|
-
// 计算标题
|
|
73
|
-
const currentTitle = computed(() =>
|
|
74
|
-
computeTitle(mode.value, props.titlePrefix)
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
defineExpose({
|
|
78
|
-
/** 打开新增弹窗 */
|
|
79
|
-
open(formData?: Record<string, any>) {
|
|
80
|
-
console.log("🚀 ~ file: index.vue:80 ~ open ~ formData:", formData);
|
|
81
|
-
mode.value = "add";
|
|
82
|
-
reset();
|
|
83
|
-
if (formData) {
|
|
84
|
-
form.value = {
|
|
85
|
-
...formData
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
visible.value = true;
|
|
89
|
-
},
|
|
90
|
-
/** 打开编辑弹窗 */
|
|
91
|
-
async edit(id: string) {
|
|
92
|
-
mode.value = "edit";
|
|
93
|
-
visible.value = true;
|
|
94
|
-
await Page.getById(id);
|
|
95
|
-
},
|
|
96
|
-
/** 打开详情弹窗(只读) */
|
|
97
|
-
async view(id: string) {
|
|
98
|
-
mode.value = "view";
|
|
99
|
-
visible.value = true;
|
|
100
|
-
await Page.getById(id);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
</script>
|
|
104
|
-
|
|
105
|
-
<style scoped lang="scss">
|
|
106
|
-
@import "./index.scss";
|
|
107
|
-
</style>
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenYu ycyplus@gmail.com
|
|
3
|
+
* @Date: 2026-01-01 13:30:00
|
|
4
|
+
* @LastEditors: ChenYu ycyplus@gmail.com
|
|
5
|
+
* @LastEditTime: 2026-01-04 09:17:43
|
|
6
|
+
* @FilePath: \cx-ui-sale\src\components\local\c_formModal\index.vue
|
|
7
|
+
* @Description: 表单弹窗组件 (新增、编辑、详情)
|
|
8
|
+
* Copyright (c) 2026 by CHENY, All Rights Reserved 😎.
|
|
9
|
+
-->
|
|
10
|
+
<template>
|
|
11
|
+
<jh-dialog v-model="visible" :width="width" :title="currentTitle">
|
|
12
|
+
<BaseForm
|
|
13
|
+
ref="formRef"
|
|
14
|
+
:form="form"
|
|
15
|
+
:items="formItems"
|
|
16
|
+
:columns="columns"
|
|
17
|
+
:label-width="labelWidth"
|
|
18
|
+
:disabled="mode === 'view'"
|
|
19
|
+
/>
|
|
20
|
+
<template #footer>
|
|
21
|
+
<div class="dialog-footer">
|
|
22
|
+
<BaseToolbar
|
|
23
|
+
v-if="mode !== 'view'"
|
|
24
|
+
:items="cancelConfirmButtons(() => (visible = false), save)"
|
|
25
|
+
/>
|
|
26
|
+
<BaseToolbar
|
|
27
|
+
v-else
|
|
28
|
+
:items="[{ label: '关闭', onClick: () => (visible = false) }]"
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
</jh-dialog>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import type { BaseFormItemDesc } from "@jhlc/common-core/src/components/form/common/type";
|
|
37
|
+
import { cancelConfirmButtons } from "@jhlc/common-core/src/components/toolbar/toolbar-data";
|
|
38
|
+
import {
|
|
39
|
+
createFormModal,
|
|
40
|
+
computeTitle,
|
|
41
|
+
type ModalApi,
|
|
42
|
+
type ModalMode
|
|
43
|
+
} from "./data";
|
|
44
|
+
|
|
45
|
+
interface Props {
|
|
46
|
+
formItems: BaseFormItemDesc<any>[];
|
|
47
|
+
api: ModalApi;
|
|
48
|
+
width?: string;
|
|
49
|
+
columns?: number;
|
|
50
|
+
labelWidth?: string;
|
|
51
|
+
titlePrefix?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
55
|
+
width: "850px",
|
|
56
|
+
columns: 2,
|
|
57
|
+
labelWidth: "110px",
|
|
58
|
+
titlePrefix: "数据"
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const emit = defineEmits(["ok"]);
|
|
62
|
+
|
|
63
|
+
// 当前模式
|
|
64
|
+
const mode = ref<ModalMode>("add");
|
|
65
|
+
|
|
66
|
+
// 创建页面Hook实例
|
|
67
|
+
const Page = createFormModal(props, mode, emit);
|
|
68
|
+
|
|
69
|
+
// 解构使用
|
|
70
|
+
const { visible, formRef, form, formItems, save, reset } = Page;
|
|
71
|
+
|
|
72
|
+
// 计算标题
|
|
73
|
+
const currentTitle = computed(() =>
|
|
74
|
+
computeTitle(mode.value, props.titlePrefix)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
defineExpose({
|
|
78
|
+
/** 打开新增弹窗 */
|
|
79
|
+
open(formData?: Record<string, any>) {
|
|
80
|
+
console.log("🚀 ~ file: index.vue:80 ~ open ~ formData:", formData);
|
|
81
|
+
mode.value = "add";
|
|
82
|
+
reset();
|
|
83
|
+
if (formData) {
|
|
84
|
+
form.value = {
|
|
85
|
+
...formData
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
visible.value = true;
|
|
89
|
+
},
|
|
90
|
+
/** 打开编辑弹窗 */
|
|
91
|
+
async edit(id: string) {
|
|
92
|
+
mode.value = "edit";
|
|
93
|
+
visible.value = true;
|
|
94
|
+
await Page.getById(id);
|
|
95
|
+
},
|
|
96
|
+
/** 打开详情弹窗(只读) */
|
|
97
|
+
async view(id: string) {
|
|
98
|
+
mode.value = "view";
|
|
99
|
+
visible.value = true;
|
|
100
|
+
await Page.getById(id);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<style scoped lang="scss">
|
|
106
|
+
@import "./index.scss";
|
|
107
|
+
</style>
|