up.
This commit is contained in:
parent
91c1ce6af4
commit
f4cf916c73
101
z_ele/src/api/xm/platform/index.ts
Normal file
101
z_ele/src/api/xm/platform/index.ts
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import type { ApiResult, PageResult } from '@/api';
|
||||||
|
import type { Platform, PlatformParam } from './model';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询会员
|
||||||
|
*/
|
||||||
|
export async function pagePlatforms(params: PlatformParam) {
|
||||||
|
const res = await request.get<ApiResult<PageResult<Platform>>>(
|
||||||
|
'/xm/platform/page',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户列表
|
||||||
|
*/
|
||||||
|
export async function listUsers(params?: PlatformParam) {
|
||||||
|
const res = await request.get<ApiResult<Platform[]>>('/system/user', {
|
||||||
|
params
|
||||||
|
});
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询用户
|
||||||
|
*/
|
||||||
|
export async function getUser(id: number) {
|
||||||
|
const res = await request.get<ApiResult<Platform>>('/system/user/' + id);
|
||||||
|
if (res.data.code === 0 && res.data.data) {
|
||||||
|
return res.data.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加用户
|
||||||
|
*/
|
||||||
|
export async function addUser(data: Platform) {
|
||||||
|
const res = await request.post<ApiResult<unknown>>('/system/user', data);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
*/
|
||||||
|
export async function updateUser(data: Platform) {
|
||||||
|
const res = await request.put<ApiResult<unknown>>('/system/user', data);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除用户
|
||||||
|
*/
|
||||||
|
export async function removeUser(id?: number) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>('/system/user/' + id);
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除用户
|
||||||
|
*/
|
||||||
|
export async function removeUsers(data: (number | undefined)[]) {
|
||||||
|
const res = await request.delete<ApiResult<unknown>>('/system/user/batch', {
|
||||||
|
data
|
||||||
|
});
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户状态
|
||||||
|
*/
|
||||||
|
export async function updateUserStatus(userId?: number, status?: number) {
|
||||||
|
const res = await request.put<ApiResult<unknown>>('/system/user/status', {
|
||||||
|
userId,
|
||||||
|
status
|
||||||
|
});
|
||||||
|
if (res.data.code === 0) {
|
||||||
|
return res.data.message;
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error(res.data.message));
|
||||||
|
}
|
||||||
13
z_ele/src/api/xm/platform/model/index.ts
Normal file
13
z_ele/src/api/xm/platform/model/index.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import type { PageParam } from '@/api';
|
||||||
|
/**
|
||||||
|
* 会员
|
||||||
|
*/
|
||||||
|
export interface Platform {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员搜索条件
|
||||||
|
*/
|
||||||
|
export interface PlatformParam extends PageParam {
|
||||||
|
name?: string;
|
||||||
|
keyword?: string;
|
||||||
|
}
|
||||||
147
z_ele/src/views/xm/platform/components/platform-edit.vue
Normal file
147
z_ele/src/views/xm/platform/components/platform-edit.vue
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
<!-- 角色编辑弹窗 -->
|
||||||
|
<template>
|
||||||
|
<ele-modal
|
||||||
|
form
|
||||||
|
destroy-on-close
|
||||||
|
:width="460"
|
||||||
|
v-model="visible"
|
||||||
|
:title="isUpdate ? '修改角色' : '添加角色'"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
label-width="80px"
|
||||||
|
@submit.prevent=""
|
||||||
|
>
|
||||||
|
<el-form-item label="角色名称" prop="roleName">
|
||||||
|
<el-input
|
||||||
|
clearable
|
||||||
|
:maxlength="20"
|
||||||
|
v-model="form.roleName"
|
||||||
|
placeholder="请输入角色名称"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="角色标识" prop="roleCode">
|
||||||
|
<el-input
|
||||||
|
clearable
|
||||||
|
:maxlength="20"
|
||||||
|
v-model="form.roleCode"
|
||||||
|
placeholder="请输入角色标识"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注">
|
||||||
|
<el-input
|
||||||
|
:rows="4"
|
||||||
|
type="textarea"
|
||||||
|
v-model="form.comments"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="handleCancel">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="loading" @click="save">
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</ele-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, reactive, watch } from 'vue';
|
||||||
|
import type { FormInstance, FormRules } from 'element-plus';
|
||||||
|
import { EleMessage } from 'ele-admin-plus';
|
||||||
|
import { useFormData } from '@/utils/use-form-data';
|
||||||
|
import { addRole, updateRole } from '@/api/system/role';
|
||||||
|
import type { Role } from '@/api/system/role/model';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
/** 修改回显的数据 */
|
||||||
|
data?: Role | null;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'done'): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
/** 弹窗是否打开 */
|
||||||
|
const visible = defineModel({ type: Boolean });
|
||||||
|
|
||||||
|
/** 是否是修改 */
|
||||||
|
const isUpdate = ref(false);
|
||||||
|
|
||||||
|
/** 提交状态 */
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
/** 表单实例 */
|
||||||
|
const formRef = ref<FormInstance | null>(null);
|
||||||
|
|
||||||
|
/** 表单数据 */
|
||||||
|
const [form, resetFields, assignFields] = useFormData<Role>({
|
||||||
|
roleId: void 0,
|
||||||
|
roleName: '',
|
||||||
|
roleCode: '',
|
||||||
|
comments: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 表单验证规则 */
|
||||||
|
const rules = reactive<FormRules>({
|
||||||
|
roleName: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入角色名称',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
roleCode: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入角色标识',
|
||||||
|
type: 'string',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 关闭弹窗 */
|
||||||
|
const handleCancel = () => {
|
||||||
|
visible.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 保存编辑 */
|
||||||
|
const save = () => {
|
||||||
|
formRef.value?.validate?.((valid) => {
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loading.value = true;
|
||||||
|
const saveOrUpdate = isUpdate.value ? updateRole : addRole;
|
||||||
|
saveOrUpdate(form)
|
||||||
|
.then((msg) => {
|
||||||
|
loading.value = false;
|
||||||
|
EleMessage.success({ message: msg, plain: true });
|
||||||
|
handleCancel();
|
||||||
|
emit('done');
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
loading.value = false;
|
||||||
|
EleMessage.error({ message: e.message, plain: true });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 监听弹窗打开 */
|
||||||
|
watch(visible, () => {
|
||||||
|
if (visible.value) {
|
||||||
|
if (props.data) {
|
||||||
|
assignFields(props.data);
|
||||||
|
isUpdate.value = true;
|
||||||
|
} else {
|
||||||
|
resetFields();
|
||||||
|
isUpdate.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
54
z_ele/src/views/xm/platform/components/platform-search.vue
Normal file
54
z_ele/src/views/xm/platform/components/platform-search.vue
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<!-- 搜索表单 -->
|
||||||
|
<template>
|
||||||
|
<ele-card :body-style="{ paddingBottom: '2px' }">
|
||||||
|
<el-form
|
||||||
|
label-width="82px"
|
||||||
|
@keyup.enter.prevent="search"
|
||||||
|
@submit.prevent=""
|
||||||
|
>
|
||||||
|
<el-row :gutter="8">
|
||||||
|
<el-col :lg="4" :md="8" :sm="12" :xs="24">
|
||||||
|
<el-form-item label="关键字查询">
|
||||||
|
<el-input
|
||||||
|
clearable
|
||||||
|
v-model.trim="form.keyword"
|
||||||
|
placeholder="请输入关键字(平台名称/标识/备注)检索"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="12" :md="8" :sm="24" :xs="24">
|
||||||
|
<el-form-item label-width="16px">
|
||||||
|
<el-button type="primary" @click="search">查询</el-button>
|
||||||
|
<el-button @click="reset">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</ele-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useFormData } from '@/utils/use-form-data';
|
||||||
|
import type { PlatformParam } from '@/api/xm/platform/model';
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'search', where?: PlatformParam): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
/** 表单数据 */
|
||||||
|
const [form, resetFields] = useFormData<PlatformParam>({
|
||||||
|
name: '',
|
||||||
|
keyword: ''
|
||||||
|
});
|
||||||
|
/** 搜索 */
|
||||||
|
const search = () => {
|
||||||
|
let where: any = { ...form };
|
||||||
|
emit('search', where);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 重置 */
|
||||||
|
const reset = () => {
|
||||||
|
resetFields();
|
||||||
|
search();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
158
z_ele/src/views/xm/platform/index.vue
Normal file
158
z_ele/src/views/xm/platform/index.vue
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<template>
|
||||||
|
<ele-page>
|
||||||
|
<!-- 搜索表单 -->
|
||||||
|
<platform-search @search="reload" />
|
||||||
|
<ele-card :body-style="{ paddingTop: '8px' }">
|
||||||
|
<!-- 表格 -->
|
||||||
|
<ele-pro-table
|
||||||
|
ref="tableRef"
|
||||||
|
row-key="roleId"
|
||||||
|
:columns="columns"
|
||||||
|
:datasource="datasource"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
v-model:selections="selections"
|
||||||
|
:highlight-current-row="true"
|
||||||
|
cache-key="systemRoleTable"
|
||||||
|
>
|
||||||
|
<template #toolbar> </template>
|
||||||
|
<template #action="{ row }">
|
||||||
|
<el-link type="primary" underline="never" @click="openEdit(row)">
|
||||||
|
编辑
|
||||||
|
</el-link>
|
||||||
|
<el-divider direction="vertical" />
|
||||||
|
<el-link type="danger" underline="never" @click="remove(row)">
|
||||||
|
删除
|
||||||
|
</el-link>
|
||||||
|
</template>
|
||||||
|
</ele-pro-table>
|
||||||
|
</ele-card>
|
||||||
|
<!-- 编辑弹窗 -->
|
||||||
|
<platform-edit v-model="showEdit" :data="current" @done="reload" />
|
||||||
|
</ele-page>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { ElMessageBox } from 'element-plus';
|
||||||
|
import { EleMessage } from 'ele-admin-plus';
|
||||||
|
import type { EleProTable } from 'ele-admin-plus';
|
||||||
|
import type {
|
||||||
|
DatasourceFunction,
|
||||||
|
Columns
|
||||||
|
} from 'ele-admin-plus/es/ele-pro-table/types';
|
||||||
|
import PlatformSearch from './components/platform-search.vue';
|
||||||
|
import PlatformEdit from './components/platform-edit.vue';
|
||||||
|
import { removeRoles } from '@/api/system/role';
|
||||||
|
import type { Platform, PlatformParam } from '@/api/xm/platform/model';
|
||||||
|
import { pagePlatforms } from '@/api/xm/platform';
|
||||||
|
|
||||||
|
defineOptions({ name: 'SystemRole' });
|
||||||
|
|
||||||
|
/** 表格实例 */
|
||||||
|
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||||
|
|
||||||
|
/** 表格列配置 */
|
||||||
|
const columns = ref<Columns>([
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
columnKey: 'selection',
|
||||||
|
width: 50,
|
||||||
|
align: 'center' /* ,
|
||||||
|
fixed: 'left' */
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'index',
|
||||||
|
columnKey: 'index',
|
||||||
|
width: 50,
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'PlatformId',
|
||||||
|
label: '渠道ID',
|
||||||
|
width: 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'code',
|
||||||
|
label: '渠道代码',
|
||||||
|
width: 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'name',
|
||||||
|
label: '渠道名称',
|
||||||
|
minWidth: 120
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'createTime',
|
||||||
|
label: '创建时间',
|
||||||
|
width: 170,
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
columnKey: 'action',
|
||||||
|
label: '操作',
|
||||||
|
width: 200,
|
||||||
|
align: 'center' /* ,
|
||||||
|
fixed: 'right' */,
|
||||||
|
slot: 'action',
|
||||||
|
hideInPrint: true,
|
||||||
|
hideInExport: true
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** 表格选中数据 */
|
||||||
|
const selections = ref<Platform[]>([]);
|
||||||
|
|
||||||
|
/** 当前编辑数据 */
|
||||||
|
const current = ref<Platform | null>(null);
|
||||||
|
|
||||||
|
/** 是否显示编辑弹窗 */
|
||||||
|
const showEdit = ref(false);
|
||||||
|
|
||||||
|
/** 表格数据源 */
|
||||||
|
const datasource: DatasourceFunction = ({ pages, where, orders }) => {
|
||||||
|
return pagePlatforms({ ...where, ...orders, ...pages });
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 搜索 */
|
||||||
|
const reload = (where?: PlatformParam) => {
|
||||||
|
selections.value = [];
|
||||||
|
tableRef.value?.reload?.({ page: 1, where });
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 打开编辑弹窗 */
|
||||||
|
const openEdit = (row?: Platform) => {
|
||||||
|
current.value = row ?? null;
|
||||||
|
showEdit.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 删除单个 */
|
||||||
|
const remove = (row?: Platform) => {
|
||||||
|
const rows = row == null ? selections.value : [row];
|
||||||
|
if (!rows.length) {
|
||||||
|
EleMessage.error({ message: '请至少选择一条数据', plain: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ElMessageBox.confirm(
|
||||||
|
'确定要删除“' + rows.map((d) => d.roleName).join(', ') + '”吗?',
|
||||||
|
'系统提示',
|
||||||
|
{ type: 'warning', draggable: true }
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
const loading = EleMessage.loading({
|
||||||
|
message: '请求中..',
|
||||||
|
plain: true
|
||||||
|
});
|
||||||
|
removeRoles(rows.map((d) => d.roleId))
|
||||||
|
.then((msg) => {
|
||||||
|
loading.close();
|
||||||
|
EleMessage.success({ message: msg, plain: true });
|
||||||
|
reload();
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
loading.close();
|
||||||
|
EleMessage.error({ message: e.message, plain: true });
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user