refactor: ♻️ 支持CURD演示示例切换
This commit is contained in:
@@ -5,7 +5,9 @@ const contentConfig: IContentConfig = {
|
|||||||
table: {
|
table: {
|
||||||
showOverflowTooltip: true,
|
showOverflowTooltip: true,
|
||||||
},
|
},
|
||||||
|
toolbar: [],
|
||||||
indexAction: function (params) {
|
indexAction: function (params) {
|
||||||
|
// 模拟发起网络请求获取列表数据
|
||||||
// console.log("indexAction:", params);
|
// console.log("indexAction:", params);
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
total: 2,
|
total: 2,
|
||||||
@@ -44,11 +46,13 @@ const contentConfig: IContentConfig = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
modifyAction(data) {
|
modifyAction(data) {
|
||||||
console.log("modifyAction:", data);
|
// 模拟发起网络请求修改字段
|
||||||
|
// console.log("modifyAction:", data);
|
||||||
|
ElMessage.success(JSON.stringify(data));
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
},
|
},
|
||||||
cols: [
|
cols: [
|
||||||
{ type: "selection", width: 50, align: "center" },
|
{ type: "index", width: 50, align: "center" },
|
||||||
{ label: "ID", align: "center", prop: "id", show: false },
|
{ label: "ID", align: "center", prop: "id", show: false },
|
||||||
{ label: "用户名", align: "center", prop: "username" },
|
{ label: "用户名", align: "center", prop: "username" },
|
||||||
{ label: "图片", align: "center", prop: "avatar", templet: "image" },
|
{ label: "图片", align: "center", prop: "avatar", templet: "image" },
|
||||||
@@ -106,14 +110,6 @@ const contentConfig: IContentConfig = {
|
|||||||
templet: "date",
|
templet: "date",
|
||||||
dateFormat: "YYYY/MM/DD HH:mm:ss",
|
dateFormat: "YYYY/MM/DD HH:mm:ss",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
label: "操作",
|
|
||||||
align: "center",
|
|
||||||
fixed: "right",
|
|
||||||
width: 150,
|
|
||||||
templet: "tool",
|
|
||||||
operat: ["edit", "delete"],
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +1,78 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-link
|
<div class="flex-x-between mb-10">
|
||||||
href="https://gitee.com/youlaiorg/vue3-element-admin/blob/master/src/views/demo/curd/index.vue"
|
<el-link
|
||||||
type="primary"
|
href="https://gitee.com/youlaiorg/vue3-element-admin/blob/master/src/views/demo/curd/index.vue"
|
||||||
target="_blank"
|
type="primary"
|
||||||
class="mb-10"
|
target="_blank"
|
||||||
>
|
>
|
||||||
示例源码 请点击>>>>
|
示例源码 请点击>>>>
|
||||||
</el-link>
|
</el-link>
|
||||||
|
<el-button type="primary" plain round size="small" @click="isA = !isA">
|
||||||
<!-- 搜索 -->
|
切换示例
|
||||||
<page-search
|
</el-button>
|
||||||
ref="searchRef"
|
</div>
|
||||||
:search-config="searchConfig"
|
|
||||||
@query-click="handleQueryClick"
|
|
||||||
@reset-click="handleResetClick"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<page-content
|
<template v-if="isA">
|
||||||
ref="contentRef"
|
<!-- 搜索 -->
|
||||||
:content-config="contentConfig"
|
<page-search
|
||||||
@add-click="handleAddClick"
|
ref="searchRef"
|
||||||
@edit-click="handleEditClick"
|
:search-config="searchConfig"
|
||||||
@export-click="handleExportClick"
|
@query-click="handleQueryClick"
|
||||||
@search-click="handleSearchClick"
|
@reset-click="handleResetClick"
|
||||||
@toolbar-click="handleToolbarClick"
|
/>
|
||||||
@operat-click="handleOperatClick"
|
|
||||||
@filter-change="handleFilterChange"
|
|
||||||
>
|
|
||||||
<template #status="scope">
|
|
||||||
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
|
||||||
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</page-content>
|
|
||||||
|
|
||||||
<!-- 新增 -->
|
<!-- 列表 -->
|
||||||
<page-modal
|
<page-content
|
||||||
ref="addModalRef"
|
ref="contentRef"
|
||||||
:modal-config="addModalConfig"
|
:content-config="contentConfig"
|
||||||
@submit-click="handleSubmitClick"
|
@add-click="handleAddClick"
|
||||||
>
|
@edit-click="handleEditClick"
|
||||||
<template #gender="scope">
|
@export-click="handleExportClick"
|
||||||
<dictionary v-model="scope.formData[scope.prop]" type-code="gender" />
|
@search-click="handleSearchClick"
|
||||||
</template>
|
@toolbar-click="handleToolbarClick"
|
||||||
</page-modal>
|
@operat-click="handleOperatClick"
|
||||||
|
@filter-change="handleFilterChange"
|
||||||
|
>
|
||||||
|
<template #status="scope">
|
||||||
|
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
||||||
|
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</page-content>
|
||||||
|
|
||||||
<!-- 编辑 -->
|
<!-- 新增 -->
|
||||||
<page-modal
|
<page-modal
|
||||||
ref="editModalRef"
|
ref="addModalRef"
|
||||||
:modal-config="editModalConfig"
|
:modal-config="addModalConfig"
|
||||||
@submit-click="handleSubmitClick"
|
@submit-click="handleSubmitClick"
|
||||||
>
|
>
|
||||||
<template #gender="scope">
|
<template #gender="scope">
|
||||||
<dictionary v-model="scope.formData[scope.prop]" type-code="gender" />
|
<dictionary v-model="scope.formData[scope.prop]" type-code="gender" />
|
||||||
</template>
|
</template>
|
||||||
</page-modal>
|
</page-modal>
|
||||||
|
|
||||||
|
<!-- 编辑 -->
|
||||||
|
<page-modal
|
||||||
|
ref="editModalRef"
|
||||||
|
:modal-config="editModalConfig"
|
||||||
|
@submit-click="handleSubmitClick"
|
||||||
|
>
|
||||||
|
<template #gender="scope">
|
||||||
|
<dictionary v-model="scope.formData[scope.prop]" type-code="gender" />
|
||||||
|
</template>
|
||||||
|
</page-modal>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<page-content ref="contentRef" :content-config="contentConfig2">
|
||||||
|
<template #status="scope">
|
||||||
|
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
||||||
|
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</page-content>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -66,7 +82,7 @@ import type { IObject, IOperatData } from "@/components/CURD/types";
|
|||||||
import usePage from "@/components/CURD/usePage";
|
import usePage from "@/components/CURD/usePage";
|
||||||
import addModalConfig from "./config/add";
|
import addModalConfig from "./config/add";
|
||||||
import contentConfig from "./config/content";
|
import contentConfig from "./config/content";
|
||||||
// import contentConfig from "./config/content2";
|
import contentConfig2 from "./config/content2";
|
||||||
import editModalConfig from "./config/edit";
|
import editModalConfig from "./config/edit";
|
||||||
import searchConfig from "./config/search";
|
import searchConfig from "./config/search";
|
||||||
|
|
||||||
@@ -120,4 +136,7 @@ function handleOperatClick(data: IOperatData) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 切换示例
|
||||||
|
const isA = ref(true);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user