| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <script setup lang="ts">
- import { ref } from "vue";
- import tree from "./tree.vue";
- import { useUser } from "./utils/hook";
- import { PureTableBar } from "@/components/RePureTableBar";
- import { useRenderIcon } from "@/components/ReIcon/src/hooks";
- import Upload from "~icons/ri/upload-line";
- import Role from "~icons/ri/admin-line";
- import Password from "~icons/ri/lock-password-line";
- import More from "~icons/ep/more-filled";
- import Delete from "~icons/ep/delete";
- import EditPen from "~icons/ep/edit-pen";
- import Refresh from "~icons/ep/refresh";
- import AddFill from "~icons/ri/add-circle-line";
- defineOptions({
- name: "SystemUser"
- });
- const treeRef = ref();
- const formRef = ref();
- const tableRef = ref();
- const {
- form,
- loading,
- columns,
- dataList,
- selectedNum,
- pagination,
- buttonClass,
- deviceDetection,
- onSearch,
- resetForm,
- onbatchDel,
- openDialog,
- handleUpdate,
- handleDelete,
- handleReset,
- handleSizeChange,
- onSelectionCancel,
- handleCurrentChange,
- handleSelectionChange
- } = useUser(tableRef, treeRef);
- </script>
- <template>
- <div :class="['flex', 'justify-between', deviceDetection() && 'flex-wrap']">
- <!-- <tree
- ref="treeRef"
- :class="['mr-2', deviceDetection() ? 'w-full' : 'min-w-[200px]']"
- :treeData="treeData"
- :treeLoading="treeLoading"
- @tree-select="onTreeSelect"
- /> -->
- <div :class="[deviceDetection() ? ['w-full', 'mt-2'] : 'width-calc']">
- <!-- <el-form
- ref="formRef"
- :inline="true"
- :model="form"
- class="search-form bg-bg_color w-full pl-8 pt-[12px] overflow-auto"
- >
- <el-form-item label="用户名称:" prop="username">
- <el-input
- v-model="form.username"
- placeholder="请输入用户名称"
- clearable
- class="w-[180px]!"
- />
- </el-form-item>
- <el-form-item label="手机号码:" prop="phone">
- <el-input
- v-model="form.phone"
- placeholder="请输入手机号码"
- clearable
- class="w-[180px]!"
- />
- </el-form-item>
- <el-form-item label="状态:" prop="status">
- <el-select
- v-model="form.status"
- placeholder="请选择"
- clearable
- class="w-[180px]!"
- >
- <el-option label="已开启" value="1" />
- <el-option label="已关闭" value="0" />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button
- type="primary"
- :icon="useRenderIcon('ri/search-line')"
- :loading="loading"
- @click="onSearch"
- >
- 搜索
- </el-button>
- <el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">
- 重置
- </el-button>
- </el-form-item>
- </el-form> -->
- <PureTableBar title="用户列表" :columns="columns" @refresh="onSearch">
- <template #buttons>
- <el-button
- type="primary"
- :icon="useRenderIcon(AddFill)"
- @click="openDialog()"
- >
- 新增用户
- </el-button>
- </template>
- <template v-slot="{ size, dynamicColumns }">
- <div
- v-if="selectedNum > 0"
- v-motion-fade
- class="bg-[var(--el-fill-color-light)] w-full h-[46px] mb-2 pl-4 flex items-center"
- >
- <div class="flex-auto">
- <span
- style="font-size: var(--el-font-size-base)"
- class="text-[rgba(42,46,54,0.5)] dark:text-[rgba(220,220,242,0.5)]"
- >
- 已选 {{ selectedNum }} 项
- </span>
- <el-button type="primary" text @click="onSelectionCancel">
- 取消选择
- </el-button>
- </div>
- <el-popconfirm title="是否确认删除?" @confirm="onbatchDel">
- <template #reference>
- <el-button type="danger" text class="mr-1!">
- 批量删除
- </el-button>
- </template>
- </el-popconfirm>
- </div>
- <pure-table
- ref="tableRef"
- row-key="id"
- adaptive
- :adaptiveConfig="{ offsetBottom: 108 }"
- align-whole="center"
- table-layout="auto"
- :loading="loading"
- :size="size"
- :data="dataList"
- :columns="dynamicColumns"
- :pagination="{ ...pagination, size }"
- :header-cell-style="{
- background: 'var(--el-fill-color-light)',
- color: 'var(--el-text-color-primary)'
- }"
- @selection-change="handleSelectionChange"
- @page-size-change="handleSizeChange"
- @page-current-change="handleCurrentChange"
- >
- <template #operation="{ row }">
- <el-button
- class="reset-margin"
- link
- type="primary"
- :size="size"
- :icon="useRenderIcon(EditPen)"
- @click="openDialog('修改', row)"
- >
- 修改
- </el-button>
- <el-popconfirm
- :title="`是否确认删除用户名为${row.username}的这条数据`"
- @confirm="handleDelete(row)"
- >
- <template #reference>
- <el-button
- class="reset-margin"
- link
- type="primary"
- :size="size"
- :icon="useRenderIcon(Delete)"
- >
- 删除
- </el-button>
- </template>
- </el-popconfirm>
- <el-dropdown>
- <el-button
- class="ml-3! mt-[2px]!"
- link
- type="primary"
- :size="size"
- :icon="useRenderIcon(More)"
- @click="handleUpdate(row)"
- />
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item>
- <el-button
- :class="buttonClass"
- link
- type="primary"
- :size="size"
- :icon="useRenderIcon(Password)"
- @click="handleReset(row)"
- >
- 重置密码
- </el-button>
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </template>
- </pure-table>
- </template>
- </PureTableBar>
- </div>
- </div>
- </template>
- <style lang="scss" scoped>
- :deep(.el-dropdown-menu__item i) {
- margin: 0;
- }
- :deep(.el-button:focus-visible) {
- outline: none;
- }
- .main-content {
- margin: 24px 24px 0 !important;
- }
- .search-form {
- :deep(.el-form-item) {
- margin-bottom: 12px;
- }
- }
- // 修复Flex布局工具类定义,确保在所有浏览器中一致
- .flex {
- display: flex;
- }
- .justify-between {
- justify-content: space-between;
- }
- /* Tailwind flex-wrap 对应的传统 CSS */
- .flex-wrap {
- flex-wrap: wrap;
- }
- /* Tailwind w-full 对应的传统 CSS(宽度100%) */
- .w-full {
- width: 100%;
- }
- /* Tailwind mt-2 对应的传统 CSS(默认 0.5rem,即 8px,根据设计稿可调整) */
- .mt-2 {
- margin-top: 0.5rem; /* 或 8px,1rem = 16px 时等价 */
- }
- /* Tailwind w-[calc(100%)] 对应的传统 CSS(直接转换 calc 表达式) */
- .width-calc {
- width: calc(100%);
- }
- </style>
|