|
@@ -1,4 +1,5 @@
|
|
-<script setup lang="ts">/**
|
|
|
|
|
|
+<script lang="ts" setup>
|
|
|
|
+/**
|
|
* @Name: InfoCard.vue
|
|
* @Name: InfoCard.vue
|
|
* @Description:
|
|
* @Description:
|
|
* @Author: xinyan
|
|
* @Author: xinyan
|
|
@@ -7,135 +8,156 @@ import { useRouter } from 'vue-router';
|
|
import { ref } from 'vue';
|
|
import { ref } from 'vue';
|
|
import { usePagination } from '/@/utils/usePagination';
|
|
import { usePagination } from '/@/utils/usePagination';
|
|
import { useTableData } from '/@/utils/useTableData';
|
|
import { useTableData } from '/@/utils/useTableData';
|
|
-import { Delete, EditPen, Picture as IconPicture, Search } from '@element-plus/icons-vue';
|
|
|
|
|
|
+import { Delete, EditPen, Picture as IconPicture, Plus, Search } from '@element-plus/icons-vue';
|
|
import * as api from '/@/views/employee-information/api';
|
|
import * as api from '/@/views/employee-information/api';
|
|
import { useResponse } from '/@/utils/useResponse';
|
|
import { useResponse } from '/@/utils/useResponse';
|
|
import EditEmployeeInfo from '/@/views/employee-information/components/EditEmployeeInfo.vue';
|
|
import EditEmployeeInfo from '/@/views/employee-information/components/EditEmployeeInfo.vue';
|
|
|
|
+import CreateEmployee from '/@/views/employee-information/components/CreateEmployee.vue';
|
|
|
|
+import { ElCol } from 'element-plus';
|
|
|
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
const loading = ref();
|
|
const loading = ref();
|
|
|
|
+// 创建弹窗
|
|
|
|
+const showDialog = ref(false);
|
|
const isDrawerVisible = ref(false);
|
|
const isDrawerVisible = ref(false);
|
|
|
|
+
|
|
const employeeInfo = ref([]);
|
|
const employeeInfo = ref([]);
|
|
const { tableOptions, handlePageChange } = usePagination(fetchCardData);
|
|
const { tableOptions, handlePageChange } = usePagination(fetchCardData);
|
|
tableOptions.value.limit = 12;
|
|
tableOptions.value.limit = 12;
|
|
|
|
|
|
async function fetchCardData() {
|
|
async function fetchCardData() {
|
|
- const query = {
|
|
|
|
- page: tableOptions.value.page,
|
|
|
|
- limit: tableOptions.value.limit,
|
|
|
|
- };
|
|
|
|
- await useTableData(api.getCardData, query, tableOptions);
|
|
|
|
|
|
+ const query = {
|
|
|
|
+ page: tableOptions.value.page,
|
|
|
|
+ limit: tableOptions.value.limit,
|
|
|
|
+ };
|
|
|
|
+ await useTableData(api.getCardData, query, tableOptions);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+async function addEmployee() {
|
|
|
|
+ showDialog.value = true;
|
|
}
|
|
}
|
|
|
|
|
|
const checkItem = (item) => {
|
|
const checkItem = (item) => {
|
|
- router.push({
|
|
|
|
- path: '/employee/detail',
|
|
|
|
- query: {
|
|
|
|
- id: item.id,
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
|
|
+ router.push({
|
|
|
|
+ path: '/employee/detail',
|
|
|
|
+ query: {
|
|
|
|
+ id: item.id,
|
|
|
|
+ },
|
|
|
|
+ });
|
|
};
|
|
};
|
|
|
|
|
|
-async function editItem (item) {
|
|
|
|
- const res = await useResponse(item.id, api.getEmployeeDetailOverview);
|
|
|
|
- employeeInfo.value = res.data;
|
|
|
|
- if (employeeInfo.value){
|
|
|
|
- isDrawerVisible.value = true; // 显示 Drawer
|
|
|
|
- console.log("=>(InfoCard.vue:44) isDrawerVisible.value", isDrawerVisible.value);
|
|
|
|
- }
|
|
|
|
|
|
+async function editItem(item) {
|
|
|
|
+ const res = await useResponse(item.id, api.getEmployeeDetailOverview);
|
|
|
|
+ employeeInfo.value = res.data;
|
|
|
|
+ if (employeeInfo.value) {
|
|
|
|
+ isDrawerVisible.value = true; // 显示 Drawer
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
const getImageUrl = (images) => {
|
|
const getImageUrl = (images) => {
|
|
- // 如果有图片,返回第一个图片的 image_url,否则返回占位图
|
|
|
|
- return images.length > 0 ? images[0].image_url : '';
|
|
|
|
|
|
+ // 如果有图片,返回第一个图片的 image_url,否则返回占位图
|
|
|
|
+ return images.length > 0 ? images[0].image_url : '';
|
|
};
|
|
};
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
- fetchCardData();
|
|
|
|
|
|
+ fetchCardData();
|
|
});
|
|
});
|
|
-
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
- <el-card shadow="never" style="border: none; min-height: 820px; position: relative;">
|
|
|
|
- <div class="card-container">
|
|
|
|
- <el-row :gutter="20">
|
|
|
|
- <el-col v-for="(item, index) in tableOptions.data" :key="index" :span="4" class="my-2.5">
|
|
|
|
- <el-card class="item-card" shadow="hover">
|
|
|
|
- <el-image :src="getImageUrl(item.images)" alt="电脑图片" class="card-image">
|
|
|
|
- <template #error>
|
|
|
|
- <el-icon class="card-image" style="font-size: 4rem">
|
|
|
|
- <icon-picture />
|
|
|
|
- </el-icon>
|
|
|
|
- </template>
|
|
|
|
- </el-image>
|
|
|
|
- <div class="card-content">
|
|
|
|
- <div>
|
|
|
|
- <span style="color: #808d97;font-weight: 500">姓名: </span>
|
|
|
|
- <span style="font-weight: 500">{{ item.name }}</span>
|
|
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- <span style="color: #808d97;font-weight: 500">部门: </span>
|
|
|
|
- <span style="font-weight: 500">{{ item.department }}</span>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- <div class="card-footer">
|
|
|
|
- <el-button :icon="Search" circle text bg type="primary" @click="checkItem(item)" />
|
|
|
|
- <el-button :icon="EditPen" circle text bg type="warning" @click="editItem(item)" />
|
|
|
|
- <el-button :icon="Delete" circle text bg type="danger" @click="deleteItem(item)" />
|
|
|
|
- </div>
|
|
|
|
- </el-card>
|
|
|
|
- </el-col>
|
|
|
|
- </el-row>
|
|
|
|
- </div>
|
|
|
|
- <div class="pagination-container" style="position: absolute; right: 32px; bottom: 32px;">
|
|
|
|
|
|
+ <!-- 标题区域 -->
|
|
|
|
+ <el-card class="mb-5" style="border: none">
|
|
|
|
+ <div class="flex justify-between items-baseline">
|
|
|
|
+ <div>
|
|
|
|
+ <span class="font-bold text-xl">人员信息概览</span>
|
|
|
|
+ <el-divider class="text-3xl" direction="vertical" />
|
|
|
|
+ </div>
|
|
|
|
+ <span>
|
|
|
|
+ <el-button :icon="Plus" bg text type="primary" @click="addEmployee">添 加</el-button>
|
|
|
|
+ </span>
|
|
|
|
+ </div>
|
|
|
|
+ </el-card>
|
|
|
|
+ <!-- 卡片展示区域 -->
|
|
|
|
+ <el-card class="mb-5" style="border: none; min-height: 83vh">
|
|
|
|
+ <el-card v-loading="loading" class="card-container" shadow="never" style="border: none">
|
|
|
|
+ <el-row :gutter="20">
|
|
|
|
+ <el-col v-for="(item, index) in tableOptions.data" :key="index" :lg="6" :md="8" :sm="8" :xl="4" :xs="12" class="my-2.5">
|
|
|
|
+ <el-card class="item-card" shadow="hover">
|
|
|
|
+ <el-image :src="getImageUrl(item.images)" alt="电脑图片" class="card-image">
|
|
|
|
+ <template #error>
|
|
|
|
+ <el-icon class="card-image" style="font-size: 4rem">
|
|
|
|
+ <icon-picture />
|
|
|
|
+ </el-icon>
|
|
|
|
+ </template>
|
|
|
|
+ </el-image>
|
|
|
|
+ <div class="card-content">
|
|
|
|
+ <div>
|
|
|
|
+ <span style="color: #808d97; font-weight: 500">姓名: </span>
|
|
|
|
+ <span style="font-weight: 500">{{ item.name }}</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div>
|
|
|
|
+ <span style="color: #808d97; font-weight: 500">部门: </span>
|
|
|
|
+ <span style="font-weight: 500">{{ item.department }}</span>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="card-footer">
|
|
|
|
+ <el-button :icon="Search" bg circle text type="primary" @click="checkItem(item)" />
|
|
|
|
+ <el-button :icon="EditPen" bg circle text type="warning" @click="editItem(item)" />
|
|
|
|
+ <!--<el-button :icon="Delete" bg circle text type="danger" @click="deleteItem(item)" />-->
|
|
|
|
+ </div>
|
|
|
|
+ </el-card>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+ </el-card>
|
|
|
|
+ <div class="pagination-container" style="position: absolute; right: 40px; bottom: 50px">
|
|
<el-pagination
|
|
<el-pagination
|
|
v-model:current-page="tableOptions.page"
|
|
v-model:current-page="tableOptions.page"
|
|
v-model:page-size="tableOptions.limit"
|
|
v-model:page-size="tableOptions.limit"
|
|
- :page-sizes="[6, 12, 24,36,48,60]"
|
|
|
|
|
|
+ :page-sizes="[6, 12, 24, 36, 48, 60]"
|
|
:total="tableOptions.total"
|
|
:total="tableOptions.total"
|
|
background
|
|
background
|
|
layout="sizes, prev, pager, next, total"
|
|
layout="sizes, prev, pager, next, total"
|
|
@change="handlePageChange"
|
|
@change="handlePageChange"
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
- <!-- 编辑 Drawer -->
|
|
|
|
- <EditEmployeeInfo v-if="isDrawerVisible" v-model="isDrawerVisible" :name="employeeInfo.name" :employeeInfo/>
|
|
|
|
- </el-card>
|
|
|
|
-
|
|
|
|
|
|
+ </el-card>
|
|
|
|
+ <!-- 新增 Dialog -->
|
|
|
|
+ <CreateEmployee v-model="showDialog" @refresh="fetchCardData" />
|
|
|
|
+ <!-- 编辑 Drawer -->
|
|
|
|
+ <EditEmployeeInfo v-if="isDrawerVisible" @refresh="fetchCardData" v-model="isDrawerVisible" :employeeInfo :name="employeeInfo.name" />
|
|
</template>
|
|
</template>
|
|
|
|
|
|
-<style scoped lang="scss">
|
|
|
|
|
|
+<style lang="scss" scoped>
|
|
.card-container {
|
|
.card-container {
|
|
- margin-bottom: 20px;
|
|
|
|
|
|
+ margin-bottom: 30px;
|
|
}
|
|
}
|
|
|
|
|
|
.item-card {
|
|
.item-card {
|
|
- border-radius: 10px;
|
|
|
|
- overflow: hidden;
|
|
|
|
- position: relative;
|
|
|
|
|
|
+ border-radius: 10px;
|
|
|
|
+ overflow: hidden;
|
|
|
|
+ position: relative;
|
|
}
|
|
}
|
|
|
|
|
|
.card-image {
|
|
.card-image {
|
|
- width: 100%;
|
|
|
|
- height: 150px;
|
|
|
|
- object-fit: cover;
|
|
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 150px;
|
|
|
|
+ object-fit: cover;
|
|
}
|
|
}
|
|
|
|
|
|
.card-content {
|
|
.card-content {
|
|
- padding: 10px;
|
|
|
|
- font-size: 14px;
|
|
|
|
|
|
+ padding: 10px;
|
|
|
|
+ font-size: 14px;
|
|
}
|
|
}
|
|
|
|
|
|
.card-footer {
|
|
.card-footer {
|
|
- display: flex;
|
|
|
|
- justify-content: flex-end;
|
|
|
|
- // padding: 10px;
|
|
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: flex-end;
|
|
|
|
+ // padding: 10px;
|
|
}
|
|
}
|
|
|
|
|
|
.pagination-container {
|
|
.pagination-container {
|
|
- display: flex;
|
|
|
|
- justify-content: flex-end;
|
|
|
|
- // margin-bottom: 20px;
|
|
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: flex-end;
|
|
|
|
+ // margin-bottom: 20px;
|
|
}
|
|
}
|
|
-</style>
|
|
|
|
|
|
+</style>
|