🔱: [client] sync upgrade with 21 commits [trident-sync]

Update README.md
This commit is contained in:
xiaojunnuo
2023-01-29 15:26:45 +08:00
parent 62e3945d30
commit d10e80bf83
567 changed files with 36438 additions and 2 deletions
@@ -0,0 +1,50 @@
import { requestForMock } from "/src/api/service";
const request = requestForMock;
const apiPrefix = "/mock/FeatureEditableRow";
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 }
});
}
export function BatchDelete(ids) {
return request({
url: apiPrefix + "/batchDelete",
method: "post",
data: { ids }
});
}
@@ -0,0 +1,88 @@
import * as api from "./api";
import { dict } 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 }) => {
const id = await api.AddObj(form);
return { id };
};
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
actionbar: { buttons: { add: { show: false }, addRow: { show: true } } },
table: {
editable: {
enabled: true,
mode: "row",
activeTrigger: false
}
},
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"
})
},
name: {
title: "姓名",
type: "text"
},
province: {
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,40 @@
<template>
<fs-page>
<fs-crud ref="crudRef" v-bind="crudBinding" />
</fs-page>
</template>
<script>
import { defineComponent, ref, onMounted } from "vue";
import createCrudOptions from "./crud";
import { useExpose, useCrud } from "@fast-crud/fast-crud";
export default defineComponent({
name: "FeatureEditableRow",
setup() {
// crud组件的ref
const crudRef = ref();
// crud 配置的ref
const crudBinding = ref();
// 暴露的方法
const { expose } = useExpose({ crudRef, crudBinding });
// 你的crud配置
const { crudOptions, selectedIds } = 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();
expose.editable.enable();
});
return {
crudBinding,
crudRef
};
}
});
</script>
@@ -0,0 +1,19 @@
import mockUtil from "/src/mock/base";
const options = {
name: "FeatureEditableRow",
idGenerator: 0
};
const list = [
{
radio: "1"
},
{
radio: "2"
},
{
radio: "0"
}
];
options.list = list;
const mock = mockUtil.buildMock(options);
export default mock;