mirror of
https://github.com/certd/certd.git
synced 2026-07-20 05:37:32 +08:00
🔱: [client] sync upgrade with 12 commits [trident-sync]
chore: 1.16.11 chore: 1.16.10 chore: chore: chore: build: publish success perf: 组件独立使用示例 https://github.com/fast-crud/fast-crud/issues/226 perf: 导出增加 onlyShow 和 columnFilter配置 https://github.com/fast-crud/fast-crud/issues/229 Merge remote-tracking branch 'origin/main' perf: 表单labelWidth演示 https://github.com/fast-crud/fast-crud/issues/230 perf: 翻页后自动滚动到顶部 https://github.com/fast-crud/fast-crud/issues/232
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import * as api from "./api";
|
||||
import { message } from "ant-design-vue";
|
||||
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq, FormWrapperContext, ScopeContext, UserPageQuery, UserPageRes, utils } from "@fast-crud/fast-crud";
|
||||
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
import { computed } from "vue";
|
||||
|
||||
export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
return await api.GetList(query);
|
||||
};
|
||||
@@ -16,6 +18,7 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
const addRequest = async ({ form }: AddReq) => {
|
||||
return await api.AddObj(form);
|
||||
};
|
||||
|
||||
return {
|
||||
crudOptions: {
|
||||
request: {
|
||||
@@ -25,6 +28,22 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
delRequest
|
||||
},
|
||||
form: {
|
||||
labelCol: {
|
||||
//固定label宽度
|
||||
span: null,
|
||||
style: {
|
||||
width: computed(() => {
|
||||
return context.labelWidthRef.value + "px";
|
||||
})
|
||||
}
|
||||
},
|
||||
afterSubmit(context) {
|
||||
// context.res 是add或update请求返回结果
|
||||
if (context.form.id === 1) {
|
||||
message.error("模拟保存失败,阻止弹窗关闭");
|
||||
throw new Error("模拟失败,阻止弹窗关闭");
|
||||
}
|
||||
},
|
||||
wrapper: {
|
||||
buttons: {
|
||||
ok: {
|
||||
@@ -34,9 +53,16 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
text: "自定义按钮",
|
||||
click: async (context: FormWrapperContext) => {
|
||||
utils.logger.info("btn context", context);
|
||||
message.info({ content: "通过自定义按钮,触发保存" });
|
||||
message.info("通过自定义按钮,触发保存");
|
||||
await context.submit();
|
||||
message.info({ content: "保存成功" });
|
||||
message.info("保存成功");
|
||||
}
|
||||
},
|
||||
customClose: {
|
||||
text: "自定义关闭",
|
||||
color: "red",
|
||||
click: async (context: FormWrapperContext) => {
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,32 @@
|
||||
<template>
|
||||
<fs-page>
|
||||
<template #header>
|
||||
<div class="title">基本表单</div>
|
||||
</template>
|
||||
<fs-crud ref="crudRef" v-bind="crudBinding">
|
||||
<template #actionbar-right>
|
||||
<a-alert class="ml-1" type="info" message="基本表单" />
|
||||
<template #form-body-top>
|
||||
<div style="display: flex">
|
||||
<span>label宽度设置:</span>
|
||||
<a-slider v-model:value="labelWidthRef" style="width: 200px" :min="40" :max="300"></a-slider>
|
||||
</div>
|
||||
</template>
|
||||
</fs-crud>
|
||||
</fs-page>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, onMounted, nextTick } from "vue";
|
||||
import { useFs, UseFsProps } from "@fast-crud/fast-crud";
|
||||
import { defineComponent, onMounted, ref } from "vue";
|
||||
import { useFs } from "@fast-crud/fast-crud";
|
||||
import createCrudOptions from "./crud.jsx";
|
||||
|
||||
export default defineComponent({
|
||||
name: "FormBase",
|
||||
setup() {
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions });
|
||||
const labelWidthRef = ref(100);
|
||||
const context = {
|
||||
labelWidthRef
|
||||
};
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context });
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(async () => {
|
||||
@@ -24,7 +35,8 @@ export default defineComponent({
|
||||
|
||||
return {
|
||||
crudBinding,
|
||||
crudRef
|
||||
crudRef,
|
||||
labelWidthRef
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,7 +10,8 @@ const list = [
|
||||
age: 15,
|
||||
password: "",
|
||||
status: "2",
|
||||
url: "https://baidu.com"
|
||||
url: "https://baidu.com",
|
||||
renderLabel: "第一行编辑演示阻止表单提交"
|
||||
},
|
||||
{
|
||||
name: "张三",
|
||||
|
||||
Reference in New Issue
Block a user