🔱: [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,42 @@
import { requestForMock } from "/src/api/service";
const request = requestForMock;
const apiPrefix = "/mock/FormNewPage";
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 + "/get",
method: "get",
params: { id }
});
}
@@ -0,0 +1,96 @@
import * as api from "./api";
import { useRouter } from "vue-router";
export default function ({ expose }) {
const router = useRouter();
const { getFormRef, getFormData } = expose;
const pageRequest = async (query) => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }) => {
if (row.id) {
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);
};
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
actionbar: {
buttons: {
add: {
click() {
router.push("/crud/form/new-page/edit");
}
}
}
},
rowHandle: {
buttons: {
edit: {
click(context) {
router.push("/crud/form/new-page/edit?id=" + context.row.id);
}
}
}
},
columns: {
title: {
title: "商品标题",
type: "text"
},
code: {
title: "商品代码",
search: { show: true },
type: "text"
},
images: {
title: "图片",
type: "image-uploader"
},
price: {
title: "价格",
sortable: true
},
store: {
title: "库存",
type: "number"
},
intro: {
title: "简介",
type: "textarea",
column: {
ellipsis: true
}
},
content: {
title: "详情",
type: ["editor-wang", "colspan"],
form: {
itemProps: { labelWidth: "0px" }
}
},
product: {
title: "未分组字段",
type: ["text", "colspan"],
form: {
helper: "未分组的字段会显示在这里,一般来说你应该把所有字段都编入分组内"
}
}
}
}
};
}
@@ -0,0 +1,81 @@
<template>
<fs-page>
<template #header>
<div class="title">新页面编辑</div>
</template>
<div class="p-5">
<fs-form ref="formRef" v-bind="formOptions" />
<div style="margin-top: 10px">
<a-button v-if="formRef" @click="formRef.submit">保存</a-button>
</div>
</div>
</fs-page>
</template>
<script>
import { useRoute } from "vue-router";
import { defineComponent, ref, onMounted } from "vue";
import { useCrud, useExpose, useColumns } from "@fast-crud/fast-crud";
import createCrudOptions from "./crud";
import * as api from "./api";
import _ from "lodash-es";
import { message } from "ant-design-vue";
import { usePageStore } from "/@/store/modules/page";
export default defineComponent({
name: "FormNewPageEdit",
setup(props, ctx) {
// crud组件的ref
const crudRef = ref();
// crud 配置的ref
const crudBinding = ref();
// 暴露的方法
const { expose } = useExpose({ crudRef, crudBinding });
// 你的crud配置
const { crudOptions } = createCrudOptions({ expose });
// 初始化crud配置
const { resetCrudOptions } = useCrud({ expose, crudOptions });
const formRef = ref();
const formOptions = ref();
const route = useRoute();
const id = route.query.id;
if (id) {
//编辑表单
formOptions.value = crudBinding.value.editForm;
} else {
formOptions.value = crudBinding.value.addForm;
}
const doSubmit = formOptions.value.doSubmit;
const pageStore = usePageStore();
formOptions.value.doSubmit = (context) => {
console.log("submit", context);
doSubmit(context);
//提交成功后,关闭本页面
message.success("保存成功");
pageStore.close({ tagName: route.fullPath });
};
const getDetail = async (id) => {
return await api.GetObj(id);
};
onMounted(async () => {
if (id) {
//远程获取记录详情
const detail = await getDetail(id);
formRef.value.setFormData(detail);
}
});
return {
crudBinding,
crudRef,
formRef,
formOptions
};
}
});
</script>
@@ -0,0 +1,43 @@
<template>
<fs-page>
<fs-crud ref="crudRef" v-bind="crudBinding">
<template #actionbar-right> </template>
</fs-crud>
</fs-page>
</template>
<script>
import { defineComponent, ref, onMounted } from "vue";
import { useCrud, useExpose, useColumns } from "@fast-crud/fast-crud";
import createCrudOptions from "./crud";
import _ from "lodash-es";
import { message } from "ant-design-vue";
export default defineComponent({
name: "FormNewPage",
setup(props, ctx) {
// 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>
@@ -0,0 +1,22 @@
import mockUtil from "/src/mock/base";
const options = {
name: "FormNewPage",
idGenerator: 0
};
const list = [
{
title: "无线充电宝",
code: "100001",
images: "https://img0.bdstatic.com/static/searchdetail/img/logo-2X_0c4ef02.png",
price: 100,
stock: 99,
intro: "30000毫安超大容量移动电源充电宝官方原装正品专用便携",
content: ""
}
];
options.list = list;
options.copyTimes = 1000;
const mock = mockUtil.buildMock(options);
export default mock;