mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-12-15 14:50:29 +08:00
refactor: system pages (#399)
* refactor: system pages * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export function useColumns() {
|
||||
const columns: TableColumnList = [
|
||||
{
|
||||
type: "selection",
|
||||
width: 55,
|
||||
align: "left",
|
||||
hide: ({ checkList }) => !checkList.includes("勾选列")
|
||||
},
|
||||
{
|
||||
label: "序号",
|
||||
type: "index",
|
||||
width: 60,
|
||||
hide: ({ checkList }) => !checkList.includes("序号列")
|
||||
},
|
||||
{
|
||||
label: "部门名称",
|
||||
prop: "name",
|
||||
width: 180,
|
||||
align: "left"
|
||||
},
|
||||
{
|
||||
label: "排序",
|
||||
prop: "sort",
|
||||
width: 60
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
width: 80,
|
||||
cellRenderer: ({ row, props }) => (
|
||||
<el-tag
|
||||
size={props.size}
|
||||
type={row.status === 1 ? "danger" : "success"}
|
||||
effect="plain"
|
||||
>
|
||||
{row.status === 0 ? "关闭" : "开启"}
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
width: 180,
|
||||
prop: "createTime",
|
||||
formatter: ({ createTime }) =>
|
||||
dayjs(createTime).format("YYYY-MM-DD HH:mm:ss")
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: "remark"
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
fixed: "right",
|
||||
width: 140,
|
||||
slot: "operation"
|
||||
}
|
||||
];
|
||||
|
||||
return {
|
||||
columns
|
||||
};
|
||||
}
|
||||
114
src/views/system/dept/hook.tsx
Normal file
114
src/views/system/dept/hook.tsx
Normal file
@@ -0,0 +1,114 @@
|
||||
import dayjs from "dayjs";
|
||||
import { handleTree } from "@/utils/tree";
|
||||
import { getDeptList } from "@/api/system";
|
||||
import { reactive, ref, onMounted } from "vue";
|
||||
|
||||
export function useDept() {
|
||||
const form = reactive({
|
||||
user: "",
|
||||
status: ""
|
||||
});
|
||||
const dataList = ref([]);
|
||||
const loading = ref(true);
|
||||
|
||||
const columns: TableColumnList = [
|
||||
{
|
||||
type: "selection",
|
||||
width: 55,
|
||||
align: "left",
|
||||
hide: ({ checkList }) => !checkList.includes("勾选列")
|
||||
},
|
||||
{
|
||||
label: "序号",
|
||||
type: "index",
|
||||
minWidth: 70,
|
||||
hide: ({ checkList }) => !checkList.includes("序号列")
|
||||
},
|
||||
{
|
||||
label: "部门名称",
|
||||
prop: "name",
|
||||
width: 180,
|
||||
align: "left"
|
||||
},
|
||||
{
|
||||
label: "排序",
|
||||
prop: "sort",
|
||||
minWidth: 70
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
minWidth: 100,
|
||||
cellRenderer: ({ row, props }) => (
|
||||
<el-tag
|
||||
size={props.size}
|
||||
type={row.status === 1 ? "danger" : "success"}
|
||||
effect="plain"
|
||||
>
|
||||
{row.status === 0 ? "关闭" : "开启"}
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
label: "创建时间",
|
||||
minWidth: 200,
|
||||
prop: "createTime",
|
||||
formatter: ({ createTime }) =>
|
||||
dayjs(createTime).format("YYYY-MM-DD HH:mm:ss")
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: "remark",
|
||||
minWidth: 200
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
fixed: "right",
|
||||
width: 160,
|
||||
slot: "operation"
|
||||
}
|
||||
];
|
||||
|
||||
function handleUpdate(row) {
|
||||
console.log(row);
|
||||
}
|
||||
|
||||
function handleDelete(row) {
|
||||
console.log(row);
|
||||
}
|
||||
|
||||
function handleSelectionChange(val) {
|
||||
console.log("handleSelectionChange", val);
|
||||
}
|
||||
|
||||
function resetForm(formEl) {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
onSearch();
|
||||
}
|
||||
|
||||
async function onSearch() {
|
||||
loading.value = true;
|
||||
const { data } = await getDeptList();
|
||||
dataList.value = handleTree(data);
|
||||
setTimeout(() => {
|
||||
loading.value = false;
|
||||
}, 500);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
onSearch();
|
||||
});
|
||||
|
||||
return {
|
||||
form,
|
||||
loading,
|
||||
columns,
|
||||
dataList,
|
||||
onSearch,
|
||||
resetForm,
|
||||
handleUpdate,
|
||||
handleDelete,
|
||||
handleSelectionChange
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import { useColumns } from "./columns";
|
||||
import { handleTree } from "@/utils/tree";
|
||||
import { getDeptList } from "@/api/system";
|
||||
import { FormInstance } from "element-plus";
|
||||
import { reactive, ref, onMounted } from "vue";
|
||||
import { TableProBar } from "@/components/ReTable";
|
||||
import { ref } from "vue";
|
||||
import { useDept } from "./hook";
|
||||
import { PureTableBar } from "@/components/RePureTableBar";
|
||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||
|
||||
import Delete from "@iconify-icons/ep/delete";
|
||||
import EditPen from "@iconify-icons/ep/edit-pen";
|
||||
import Search from "@iconify-icons/ep/search";
|
||||
@@ -16,47 +14,19 @@ defineOptions({
|
||||
name: "Dept"
|
||||
});
|
||||
|
||||
const form = reactive({
|
||||
user: "",
|
||||
status: ""
|
||||
});
|
||||
const dataList = ref([]);
|
||||
const loading = ref(true);
|
||||
const { columns } = useColumns();
|
||||
|
||||
const formRef = ref<FormInstance>();
|
||||
const formRef = ref();
|
||||
const tableRef = ref();
|
||||
|
||||
function handleUpdate(row) {
|
||||
console.log(row);
|
||||
}
|
||||
|
||||
function handleDelete(row) {
|
||||
console.log(row);
|
||||
}
|
||||
|
||||
function handleSelectionChange(val) {
|
||||
console.log("handleSelectionChange", val);
|
||||
}
|
||||
|
||||
async function onSearch() {
|
||||
loading.value = true;
|
||||
const { data } = await getDeptList();
|
||||
dataList.value = handleTree(data as any);
|
||||
setTimeout(() => {
|
||||
loading.value = false;
|
||||
}, 500);
|
||||
}
|
||||
|
||||
const resetForm = (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
onSearch();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
onSearch();
|
||||
});
|
||||
const {
|
||||
form,
|
||||
loading,
|
||||
columns,
|
||||
dataList,
|
||||
onSearch,
|
||||
resetForm,
|
||||
handleUpdate,
|
||||
handleDelete,
|
||||
handleSelectionChange
|
||||
} = useDept();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -68,10 +38,20 @@ onMounted(() => {
|
||||
class="bg-bg_color w-[99/100] pl-8 pt-4"
|
||||
>
|
||||
<el-form-item label="部门名称:" prop="user">
|
||||
<el-input v-model="form.user" placeholder="请输入部门名称" clearable />
|
||||
<el-input
|
||||
v-model="form.user"
|
||||
placeholder="请输入部门名称"
|
||||
clearable
|
||||
class="!w-[200px]"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态:" prop="status">
|
||||
<el-select v-model="form.status" placeholder="请选择状态" clearable>
|
||||
<el-select
|
||||
v-model="form.status"
|
||||
placeholder="请选择状态"
|
||||
clearable
|
||||
class="!w-[180px]"
|
||||
>
|
||||
<el-option label="开启" value="1" />
|
||||
<el-option label="关闭" value="0" />
|
||||
</el-select>
|
||||
@@ -91,11 +71,9 @@ onMounted(() => {
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<TableProBar
|
||||
<PureTableBar
|
||||
title="部门列表"
|
||||
:loading="loading"
|
||||
:tableRef="tableRef?.getTableRef()"
|
||||
:dataList="dataList"
|
||||
@refresh="onSearch"
|
||||
>
|
||||
<template #buttons>
|
||||
@@ -112,6 +90,7 @@ onMounted(() => {
|
||||
showOverflowTooltip
|
||||
table-layout="auto"
|
||||
default-expand-all
|
||||
:loading="loading"
|
||||
:size="size"
|
||||
:data="dataList"
|
||||
:columns="columns"
|
||||
@@ -150,6 +129,6 @@ onMounted(() => {
|
||||
</template>
|
||||
</pure-table>
|
||||
</template>
|
||||
</TableProBar>
|
||||
</PureTableBar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user