mirror of
https://github.com/certd/certd.git
synced 2026-05-18 14:27:36 +08:00
🔱: [client] sync upgrade with 8 commits [trident-sync]
build: publish success chore: chore: chore: chore: build: publish success chore:
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { requestForMock } from "/src/api/service";
|
||||
const request = requestForMock;
|
||||
const apiPrefix = "/mock/EditableRow";
|
||||
export function GetList(query: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/page",
|
||||
method: "get",
|
||||
data: query
|
||||
});
|
||||
}
|
||||
|
||||
export function AddObj(obj: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/add",
|
||||
method: "post",
|
||||
data: obj
|
||||
});
|
||||
}
|
||||
|
||||
export function UpdateObj(obj: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/update",
|
||||
method: "post",
|
||||
data: obj
|
||||
});
|
||||
}
|
||||
|
||||
export function DelObj(id: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/delete",
|
||||
method: "post",
|
||||
params: { id }
|
||||
});
|
||||
}
|
||||
|
||||
export function GetObj(id: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/get",
|
||||
method: "get",
|
||||
params: { id }
|
||||
});
|
||||
}
|
||||
|
||||
export function BatchDelete(ids: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/batchDelete",
|
||||
method: "post",
|
||||
data: { ids }
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
import * as api from "./api";
|
||||
import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
return await api.GetList(query);
|
||||
};
|
||||
const editRequest = async ({ form, row }: EditReq) => {
|
||||
form.id = row.id;
|
||||
return await api.UpdateObj(form);
|
||||
};
|
||||
const delRequest = async ({ row }: DelReq) => {
|
||||
return await api.DelObj(row.id);
|
||||
};
|
||||
|
||||
const addRequest = async ({ form }: AddReq) => {
|
||||
const id = await api.AddObj(form);
|
||||
return { id };
|
||||
};
|
||||
|
||||
return {
|
||||
crudOptions: {
|
||||
request: {
|
||||
pageRequest,
|
||||
addRequest,
|
||||
editRequest,
|
||||
delRequest
|
||||
},
|
||||
//将 addRow 按钮启用
|
||||
actionbar: { buttons: { add: { show: false }, addRow: { show: true } } },
|
||||
table: {
|
||||
editable: {
|
||||
enabled: true,
|
||||
mode: "row"
|
||||
}
|
||||
},
|
||||
columns: {
|
||||
id: {
|
||||
title: "ID",
|
||||
type: "number",
|
||||
form: {
|
||||
show: false
|
||||
},
|
||||
column: { width: 80, align: "center" }
|
||||
},
|
||||
disable: {
|
||||
title: "禁止编辑",
|
||||
type: "text",
|
||||
column: {
|
||||
editable: {
|
||||
disabled: true //也可以配置为方法,根据条件禁用或启用编辑
|
||||
// disabled: ({ column, index, row }) => {
|
||||
// return index % 2 === 0;
|
||||
// }
|
||||
}
|
||||
}
|
||||
},
|
||||
radio: {
|
||||
title: "状态",
|
||||
search: { show: true },
|
||||
type: "dict-radio",
|
||||
dict: dict({
|
||||
url: "/mock/dicts/OpenStatusEnum?single"
|
||||
}),
|
||||
column: {
|
||||
width: 300
|
||||
},
|
||||
form: {
|
||||
rules: {
|
||||
async asyncValidator(context) {
|
||||
console.log("context", context);
|
||||
return true;
|
||||
},
|
||||
message: "远程校验测试"
|
||||
}
|
||||
}
|
||||
},
|
||||
target: {
|
||||
title: "根据状态动态显隐",
|
||||
search: { show: true },
|
||||
type: "text",
|
||||
form: {
|
||||
conditionalRender: {
|
||||
match: ({ form }) => {
|
||||
return form.radio === "2";
|
||||
},
|
||||
render: ({ form }) => {
|
||||
return <div>已停止</div>;
|
||||
}
|
||||
},
|
||||
show: compute(({ form }) => {
|
||||
return form.radio !== "0";
|
||||
})
|
||||
}
|
||||
},
|
||||
"user.name": {
|
||||
title: "姓名",
|
||||
type: "text",
|
||||
form: {
|
||||
key: ["user", "name"],
|
||||
rules: [
|
||||
{ required: true, message: "请输入姓名" },
|
||||
{
|
||||
type: "string",
|
||||
min: 2,
|
||||
max: 10,
|
||||
message: "长度在 2 到 10 个字符"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
address: {
|
||||
title: "地址",
|
||||
children: {
|
||||
province: {
|
||||
title: "省份",
|
||||
search: { show: true },
|
||||
type: "text",
|
||||
form: {
|
||||
rules: [{ required: true, message: "请输入省份" }]
|
||||
}
|
||||
},
|
||||
city: {
|
||||
title: "城市",
|
||||
search: { show: true },
|
||||
type: "dict-select",
|
||||
dict: dict({
|
||||
value: "id",
|
||||
label: "text",
|
||||
data: [
|
||||
{ id: "sz", text: "深圳", color: "success" },
|
||||
{ id: "gz", text: "广州", color: "primary" },
|
||||
{ id: "bj", text: "北京" },
|
||||
{ id: "wh", text: "武汉" },
|
||||
{ id: "sh", text: "上海" }
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<fs-page>
|
||||
<template #header>
|
||||
<div class="title">
|
||||
行编辑模式
|
||||
<span class="sub">在表格内编辑每行数据</span>
|
||||
</div>
|
||||
<div class="more"><a target="_blank" href="http://fast-crud.docmirror.cn/api/expose.html">文档</a></div>
|
||||
</template>
|
||||
<fs-crud ref="crudRef" v-bind="crudBinding">
|
||||
<template #actionbar-right>
|
||||
<fs-button class="ml-5" @click="log">log</fs-button>
|
||||
</template>
|
||||
</fs-crud>
|
||||
</fs-page>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, onMounted } from "vue";
|
||||
import createCrudOptions from "./crud";
|
||||
import { useFs } from "@fast-crud/fast-crud";
|
||||
|
||||
export default defineComponent({
|
||||
name: "EditableRow",
|
||||
setup() {
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions });
|
||||
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
crudExpose.doRefresh();
|
||||
crudExpose.editable.enable();
|
||||
});
|
||||
|
||||
return {
|
||||
crudBinding,
|
||||
crudRef,
|
||||
log() {
|
||||
console.log("table data:", crudBinding.value.data, crudExpose.getTableData());
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,24 @@
|
||||
import mockUtil from "/src/mock/base";
|
||||
const options: any = {
|
||||
name: "EditableRow",
|
||||
idGenerator: 0
|
||||
};
|
||||
const list = [
|
||||
{
|
||||
radio: "1",
|
||||
children: [
|
||||
{
|
||||
radio: "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
radio: "2"
|
||||
},
|
||||
{
|
||||
radio: "0"
|
||||
}
|
||||
];
|
||||
options.list = list;
|
||||
const mock = mockUtil.buildMock(options);
|
||||
export default mock;
|
||||
Reference in New Issue
Block a user