mirror of
https://github.com/certd/certd.git
synced 2026-05-17 13:57:31 +08:00
🔱: [client] sync upgrade with 21 commits [trident-sync]
Update README.md
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { requestForMock } from "/src/api/service";
|
||||
const request = requestForMock;
|
||||
const apiPrefix = "/mock/formLayout";
|
||||
export function GetList(query) {
|
||||
return request({
|
||||
url: apiPrefix + "/page",
|
||||
method: "get",
|
||||
data: query
|
||||
});
|
||||
}
|
||||
|
||||
export function AddObj(obj) {
|
||||
return request({
|
||||
url: apiPrefix + "/add",
|
||||
method: "post",
|
||||
data: obj
|
||||
});
|
||||
}
|
||||
|
||||
export function UpdateObj(obj) {
|
||||
return request({
|
||||
url: apiPrefix + "/update",
|
||||
method: "post",
|
||||
data: obj
|
||||
});
|
||||
}
|
||||
|
||||
export function DelObj(id) {
|
||||
return request({
|
||||
url: apiPrefix + "/delete",
|
||||
method: "post",
|
||||
params: { id }
|
||||
});
|
||||
}
|
||||
|
||||
export function GetObj(id) {
|
||||
return request({
|
||||
url: apiPrefix + "/info",
|
||||
method: "get",
|
||||
params: { id }
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import * as api from "./api";
|
||||
import { dict, compute } from "@fast-crud/fast-crud";
|
||||
export default function ({ expose }) {
|
||||
const pageRequest = async (query) => {
|
||||
return await api.GetList(query);
|
||||
};
|
||||
const editRequest = async ({ form, row }) => {
|
||||
form.id = row.id;
|
||||
return await api.UpdateObj(form);
|
||||
};
|
||||
const delRequest = async ({ row }) => {
|
||||
return await api.DelObj(row.id);
|
||||
};
|
||||
|
||||
const addRequest = async ({ form }) => {
|
||||
return await api.AddObj(form);
|
||||
};
|
||||
|
||||
const { getFormData, getFormWrapperRef } = expose;
|
||||
return {
|
||||
crudOptions: {
|
||||
request: {
|
||||
pageRequest,
|
||||
addRequest,
|
||||
editRequest,
|
||||
delRequest
|
||||
},
|
||||
form: {
|
||||
/**
|
||||
* flex模式,通过
|
||||
* grid模式
|
||||
*/
|
||||
display: "flex",
|
||||
wrapper: {
|
||||
customClass: "page-layout",
|
||||
onOpened(context) {
|
||||
getFormWrapperRef().formOptions.display = context.options.initial?.display;
|
||||
console.log("form opened", context, getFormData());
|
||||
}
|
||||
}
|
||||
},
|
||||
columns: {
|
||||
display: {
|
||||
title: "布局",
|
||||
type: "dict-radio",
|
||||
dict: dict({
|
||||
data: [
|
||||
{ value: "flex", label: "flex", color: "blue" },
|
||||
{ value: "grid", label: "grid", color: "green" }
|
||||
]
|
||||
}),
|
||||
search: { show: true, valueChange: null },
|
||||
form: {
|
||||
valueChange(context) {
|
||||
const { value } = context;
|
||||
getFormWrapperRef().formOptions.display = value;
|
||||
console.log("valueChange", value, context);
|
||||
}
|
||||
}
|
||||
},
|
||||
name: {
|
||||
title: "姓名",
|
||||
type: "text",
|
||||
search: { show: true }
|
||||
},
|
||||
zip: {
|
||||
title: "邮编",
|
||||
type: "text"
|
||||
},
|
||||
blank: {
|
||||
title: "表单占位栏",
|
||||
type: "text",
|
||||
form: {
|
||||
blank: true
|
||||
}
|
||||
},
|
||||
gridSpan: {
|
||||
title: "grid跨列",
|
||||
type: "textarea",
|
||||
form: {
|
||||
col: {
|
||||
style: { gridColumn: "span 2" } // grid 模式
|
||||
}
|
||||
}
|
||||
},
|
||||
flexSpan: {
|
||||
title: "flex跨列",
|
||||
type: "textarea",
|
||||
search: { show: false },
|
||||
form: {
|
||||
show: compute((context) => {
|
||||
// grid跨列模式下使用flex模式的设置会显示异常,为了演示效果,在grid模式下隐藏
|
||||
return context.form.display !== "grid";
|
||||
}),
|
||||
col: { span: 24 } // flex模式跨列配置
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<fs-page>
|
||||
<template #header>
|
||||
<div class="title">表单布局</div>
|
||||
</template>
|
||||
<fs-crud ref="crudRef" custom-class="page-layout" v-bind="crudBinding"> </fs-crud>
|
||||
</fs-page>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent, ref, onMounted } from "vue";
|
||||
import { useCrud } from "@fast-crud/fast-crud";
|
||||
import createCrudOptions from "./crud";
|
||||
import { useExpose } from "@fast-crud/fast-crud";
|
||||
export default defineComponent({
|
||||
name: "FormLayout",
|
||||
setup() {
|
||||
// crud组件的ref
|
||||
const crudRef = ref();
|
||||
// crud 配置的ref
|
||||
const crudBinding = ref();
|
||||
// 暴露的方法
|
||||
const { expose } = useExpose({ crudRef, crudBinding });
|
||||
// 你的crud配置
|
||||
const { crudOptions } = createCrudOptions({ expose });
|
||||
// 初始化crud配置
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
|
||||
const { resetCrudOptions } = useCrud({ expose, crudOptions });
|
||||
// 你可以调用此方法,重新初始化crud配置
|
||||
// resetCrudOptions(options)
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
expose.doRefresh();
|
||||
});
|
||||
|
||||
return {
|
||||
crudBinding,
|
||||
crudRef
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="less">
|
||||
.page-layout {
|
||||
.ant-form-item-label {
|
||||
width: 110px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,41 @@
|
||||
import mockUtil from "/src/mock/base";
|
||||
const options = {
|
||||
name: "formLayout",
|
||||
idGenerator: 0
|
||||
};
|
||||
const list = [
|
||||
{
|
||||
display: "flex",
|
||||
name: "aa",
|
||||
date: "2016-05-02",
|
||||
status: "0",
|
||||
province: "1",
|
||||
avatar: "https://alicdn.antdv.com/vue.png",
|
||||
show: true,
|
||||
city: "sz",
|
||||
address: "123123",
|
||||
zip: "518000"
|
||||
},
|
||||
{
|
||||
display: "grid",
|
||||
name: "bb",
|
||||
date: "2016-05-04",
|
||||
status: "1",
|
||||
province: "2"
|
||||
},
|
||||
{
|
||||
name: "cc",
|
||||
date: 2232433534511,
|
||||
status: "1",
|
||||
province: "0"
|
||||
},
|
||||
{
|
||||
name: "dd",
|
||||
date: "2016-05-03",
|
||||
status: "2",
|
||||
province: "wh,gz"
|
||||
}
|
||||
];
|
||||
options.list = list;
|
||||
const mock = mockUtil.buildMock(options);
|
||||
export default mock;
|
||||
Reference in New Issue
Block a user