mirror of https://github.com/certd/certd
🔱: [client] sync upgrade with 4 commits [trident-sync]
perf: DynamicallyCrudOptions 动态CrudOptions refactor: doc cover refactor: doc coverpull/14/head
parent
263b0fa455
commit
f344c58f26
|
@ -1,22 +1,20 @@
|
|||
import * as api from "./api";
|
||||
import { requestForMock } from "/src/api/service";
|
||||
import { useCompute } from "@fast-crud/fast-crud";
|
||||
import { message } from "ant-design-vue";
|
||||
import { ref, computed } from "vue";
|
||||
const { asyncCompute, compute } = useCompute();
|
||||
export default function ({ expose }) {
|
||||
const pageRequest = async (query) => {
|
||||
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
return await api.GetList(query);
|
||||
};
|
||||
const editRequest = async ({ form, row }) => {
|
||||
const editRequest = async ({ form, row }: EditReq) => {
|
||||
form.id = row.id;
|
||||
return await api.UpdateObj(form);
|
||||
};
|
||||
const delRequest = async ({ row }) => {
|
||||
const delRequest = async ({ row }: DelReq) => {
|
||||
return await api.DelObj(row.id);
|
||||
};
|
||||
|
||||
const addRequest = async ({ form }) => {
|
||||
const addRequest = async ({ form }: AddReq) => {
|
||||
return await api.AddObj(form);
|
||||
};
|
||||
|
||||
|
@ -48,7 +46,7 @@ export default function ({ expose }) {
|
|||
},
|
||||
rowHandle: {
|
||||
fixed: "right",
|
||||
align:'center',
|
||||
align: "center"
|
||||
},
|
||||
columns: {
|
||||
id: {
|
|
@ -10,30 +10,19 @@
|
|||
</fs-page>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent, ref, onMounted } from "vue";
|
||||
import { useCrud, useExpose } from "@fast-crud/fast-crud";
|
||||
<script lang="ts">
|
||||
import { defineComponent, onMounted } from "vue";
|
||||
import { useFs } from "@fast-crud/fast-crud";
|
||||
import createCrudOptions from "./crud";
|
||||
|
||||
export default defineComponent({
|
||||
name: "BasisComputeMore",
|
||||
setup() {
|
||||
// crud组件的ref
|
||||
const crudRef = ref();
|
||||
// crud 配置的ref
|
||||
const crudBinding = ref();
|
||||
// 暴露的方法
|
||||
const { expose } = useExpose({ crudRef, crudBinding });
|
||||
// 你的crud配置
|
||||
const { crudOptions, output } = createCrudOptions({ expose });
|
||||
// 初始化crud配置
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-unused-vars
|
||||
const { resetCrudOptions } = useCrud({ expose, crudOptions });
|
||||
// 你可以调用此方法,重新初始化crud配置
|
||||
// resetCrudOptions(options)
|
||||
const { crudBinding, crudRef, crudExpose, output } = useFs({ createCrudOptions });
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
expose.doRefresh();
|
||||
crudExpose.doRefresh();
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as api from "./api";
|
||||
import { requestForMock } from "/src/api/service";
|
||||
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq, useCompute, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
import { AddReq, ButtonProps, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq, RowHandleProps, useCompute, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
import { message } from "ant-design-vue";
|
||||
import { ref, computed } from "vue";
|
||||
const { asyncCompute, compute } = useCompute();
|
||||
|
@ -58,9 +58,12 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
|||
},
|
||||
rowHandle: {
|
||||
fixed: "right",
|
||||
show: computed(() => {
|
||||
return false;
|
||||
}),
|
||||
buttons: {
|
||||
edit: {
|
||||
show: compute(({ row }) => {
|
||||
show: compute<boolean>(({ row }) => {
|
||||
return row.editable;
|
||||
})
|
||||
},
|
||||
|
@ -68,7 +71,13 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
|||
show: compute(({ row }) => {
|
||||
return row.editable;
|
||||
})
|
||||
}
|
||||
},
|
||||
custom: compute(({ row }) => {
|
||||
return {
|
||||
text: "动态按钮:" + row.id,
|
||||
show: true
|
||||
};
|
||||
})
|
||||
}
|
||||
},
|
||||
columns: {
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import {defineComponent, onMounted} from "vue";
|
||||
import {useFs} from "@fast-crud/fast-crud";
|
||||
import { defineComponent, onMounted } from "vue";
|
||||
import { useFs } from "@fast-crud/fast-crud";
|
||||
import createCrudOptions from "./crud";
|
||||
|
||||
export default defineComponent({
|
||||
|
|
|
@ -33,7 +33,7 @@ export function DelObj(id: any) {
|
|||
});
|
||||
}
|
||||
|
||||
export function GetObj(id) {
|
||||
export function GetObj(id: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/info",
|
||||
method: "get",
|
||||
|
|
Loading…
Reference in New Issue