|
@@ -0,0 +1,312 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import { useRequest } from '@/hooks/useRequest.ts'
|
|
|
+import { useTableStore } from '@/stores/useTable.ts'
|
|
|
+
|
|
|
+import type { ReqConfig } from '@/types/dataAnalysis.ts'
|
|
|
+import {
|
|
|
+ FilterType,
|
|
|
+ type QueryInfo,
|
|
|
+ type TableFieldInfo,
|
|
|
+ type TablePaginationSetting,
|
|
|
+ type TableToolsConfig
|
|
|
+} from '@/types/table.ts'
|
|
|
+import { FieldSpecialEffectType, TextType } from '@/types/tableText.ts'
|
|
|
+import axiosInstance from '@/utils/axios/axiosInstance.ts'
|
|
|
+import { onMounted, ref } from 'vue'
|
|
|
+import { ElMessageBox, ElMessage } from 'element-plus'
|
|
|
+
|
|
|
+// 定义表格配置接口
|
|
|
+interface TableConfig {
|
|
|
+ requestConfig: ReqConfig
|
|
|
+ pagingConfig: TablePaginationSetting
|
|
|
+ tableFieldsInfo: Array<TableFieldInfo>
|
|
|
+ queryInfo: Array<QueryInfo>
|
|
|
+ tableToolsConfig: TableToolsConfig
|
|
|
+}
|
|
|
+
|
|
|
+const { AllApi } = useRequest()
|
|
|
+const { allGameInfo } = useTableStore()
|
|
|
+
|
|
|
+// 控制模态框的显示与隐藏
|
|
|
+const dialogVisible = ref(false)
|
|
|
+// 模态框的标题
|
|
|
+const dialogTitle = ref('')
|
|
|
+// 成员表单数据
|
|
|
+const memberForm = ref({
|
|
|
+ id: '',
|
|
|
+ account: '',
|
|
|
+ name: '',
|
|
|
+ password: '',
|
|
|
+ createdAt: '',
|
|
|
+ updatedAt: '',
|
|
|
+ permission: ''
|
|
|
+})
|
|
|
+
|
|
|
+// 表格配置
|
|
|
+const tableConfig = ref<TableConfig>({
|
|
|
+ requestConfig: {
|
|
|
+ url: AllApi.memberList, // 假设这是获取成员列表的接口,可替换为实际路径
|
|
|
+ otherOptions: {}
|
|
|
+ },
|
|
|
+ pagingConfig: {
|
|
|
+ limit: 20,
|
|
|
+ currentPage: 1,
|
|
|
+ total: 0,
|
|
|
+ pageSizeList: [20, 30]
|
|
|
+ },
|
|
|
+ tableFieldsInfo: [
|
|
|
+ {
|
|
|
+ name: 'id',
|
|
|
+ cnName: 'ID',
|
|
|
+ isShow: false,
|
|
|
+ needSort: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'account',
|
|
|
+ cnName: '账号',
|
|
|
+ isShow: true,
|
|
|
+ needSort: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'name',
|
|
|
+ cnName: '姓名',
|
|
|
+ isShow: true,
|
|
|
+ needSort: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'password',
|
|
|
+ cnName: '密码',
|
|
|
+ isShow: false, // 默认不展示密码字段,防止泄露
|
|
|
+ needSort: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'createdAt',
|
|
|
+ cnName: '创建时间',
|
|
|
+ isShow: true,
|
|
|
+ needSort: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'updatedAt',
|
|
|
+ cnName: '更新时间',
|
|
|
+ isShow: true,
|
|
|
+ needSort: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'permission',
|
|
|
+ cnName: '权限',
|
|
|
+ isShow: true,
|
|
|
+ needSort: false
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ queryInfo: [
|
|
|
+ {
|
|
|
+ name: 'search',
|
|
|
+ label: '搜索账号',
|
|
|
+ type: FilterType.INPUT,
|
|
|
+ placeholder: '请输入账号',
|
|
|
+ default: ''
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ tableToolsConfig: {
|
|
|
+ add: true,
|
|
|
+ filterFields: true,
|
|
|
+ refresh: true,
|
|
|
+ download: false
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+/**
|
|
|
+ * 新增成员
|
|
|
+ */
|
|
|
+const addNewMember = () => {
|
|
|
+ dialogTitle.value = '新增成员'
|
|
|
+ memberForm.value = {
|
|
|
+ id: '',
|
|
|
+ account: '',
|
|
|
+ name: '',
|
|
|
+ password: '',
|
|
|
+ createdAt: '',
|
|
|
+ updatedAt: '',
|
|
|
+ permission: ''
|
|
|
+ }
|
|
|
+ dialogVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 编辑成员
|
|
|
+ * @param row 成员数据
|
|
|
+ */
|
|
|
+const editMember = (row: any) => {
|
|
|
+ dialogTitle.value = '修改成员'
|
|
|
+ memberForm.value = { ...row }
|
|
|
+ dialogVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 保存成员信息
|
|
|
+ */
|
|
|
+const saveMember = async () => {
|
|
|
+ try {
|
|
|
+ let url = AllApi.updateMember
|
|
|
+ if (memberForm.value.id) {
|
|
|
+ // 编辑成员
|
|
|
+ // await AllApi.updateMember(memberForm.value)
|
|
|
+ ElMessage.success('修改成功')
|
|
|
+ } else {
|
|
|
+ // 新增成员
|
|
|
+ url = AllApi.addMember
|
|
|
+ ElMessage.success('新增成功')
|
|
|
+ }
|
|
|
+ axiosInstance.post(url, memberForm.value)
|
|
|
+ dialogVisible.value = false
|
|
|
+ } catch (error) {
|
|
|
+ ElMessage.error('操作失败')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 删除成员
|
|
|
+ * @param row 成员数据
|
|
|
+ */
|
|
|
+const delMember = (row: any) => {
|
|
|
+ ElMessageBox.confirm('确定要删除该成员吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ // 这里可以添加删除成员的逻辑
|
|
|
+ console.log('删除成员', row)
|
|
|
+ ElMessage.success('删除成功')
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ ElMessage.info('已取消删除')
|
|
|
+ })
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="memberTableContainer">
|
|
|
+ <div class="memberTable">
|
|
|
+ <CustomTable
|
|
|
+ ref="memberTable"
|
|
|
+ :request-config="tableConfig.requestConfig"
|
|
|
+ :open-page-query="true"
|
|
|
+ :pagination-config="tableConfig.pagingConfig"
|
|
|
+ :table-fields-info="tableConfig.tableFieldsInfo"
|
|
|
+ :query-info="tableConfig.queryInfo"
|
|
|
+ :tools="tableConfig.tableToolsConfig"
|
|
|
+ :open-filter-query="true"
|
|
|
+ :open-remote-query="true"
|
|
|
+ @add-new-item="addNewMember"
|
|
|
+ >
|
|
|
+ <template #tableOperation>
|
|
|
+ <el-table-column label="操作" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-text class="operationBtn" type="primary" @click="editMember(scope.row)"
|
|
|
+ >修改</el-text
|
|
|
+ >
|
|
|
+ <el-text class="operationBtn" type="danger" @click="delMember(scope.row)"
|
|
|
+ >删除</el-text
|
|
|
+ >
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
+ </CustomTable>
|
|
|
+ </div>
|
|
|
+ <!-- 模态框组件 -->
|
|
|
+ <el-dialog v-model="dialogVisible" :title="dialogTitle" width="400px">
|
|
|
+ <el-form :model="memberForm" label-width="100px">
|
|
|
+ <el-form-item label="账号">
|
|
|
+ <el-input v-model="memberForm.account" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="姓名">
|
|
|
+ <el-input v-model="memberForm.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="权限">
|
|
|
+ <el-select
|
|
|
+ v-model="memberForm.permission"
|
|
|
+ placeholder="请选择权限"
|
|
|
+ multiple
|
|
|
+ collapse-tags
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in allGameInfo"
|
|
|
+ :key="item.gid"
|
|
|
+ :label="item.gameName"
|
|
|
+ :value="item.gid"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button class="dialogFooterBtn" type="primary" @click="saveMember">确定</el-button>
|
|
|
+ <el-button class="dialogFooterBtn" @click="dialogVisible = false">取消</el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.memberTableContainer {
|
|
|
+ width: 98%;
|
|
|
+ margin: 1% auto;
|
|
|
+ background-color: white;
|
|
|
+ box-sizing: border-box;
|
|
|
+ position: relative; /* Keep relative positioning for the absolute positioned handleFileActions */
|
|
|
+}
|
|
|
+.functionalContainer {
|
|
|
+ width: 100%;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 0 24px 24px;
|
|
|
+}
|
|
|
+
|
|
|
+.toolBtn {
|
|
|
+ min-width: 80px;
|
|
|
+ height: 28px;
|
|
|
+ margin-right: 16px;
|
|
|
+ border-radius: 3px;
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: 500;
|
|
|
+ font-family:
|
|
|
+ PingFang SC,
|
|
|
+ Microsoft YaHei UI,
|
|
|
+ Microsoft YaHei,
|
|
|
+ Helvetica Neue,
|
|
|
+ Helvetica,
|
|
|
+ Hiragino Sans GB,
|
|
|
+ Arial,
|
|
|
+ sans-serif;
|
|
|
+}
|
|
|
+
|
|
|
+.operationBtn,
|
|
|
+.dialogFooterBtn {
|
|
|
+ margin-right: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+/* 模态框样式优化 */
|
|
|
+.el-dialog {
|
|
|
+ border-radius: 10px;
|
|
|
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
|
+}
|
|
|
+
|
|
|
+.el-dialog__header {
|
|
|
+ background-color: #f0f2f5;
|
|
|
+ border-bottom: 1px solid #ebeef5;
|
|
|
+ padding: 15px 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.el-dialog__body {
|
|
|
+ padding: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.el-dialog__footer {
|
|
|
+ background-color: #f0f2f5;
|
|
|
+ border-top: 1px solid #ebeef5;
|
|
|
+ padding: 15px 20px;
|
|
|
+ text-align: right;
|
|
|
+}
|
|
|
+</style>
|