增加管理员小程序用户界面

This commit is contained in:
zy 2026-05-07 15:19:37 +08:00
parent 8207396329
commit a115f118d3
8 changed files with 792 additions and 26 deletions

View File

@ -4,11 +4,11 @@ import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils'; import { render } from '/@/utils/common/renderUtils';
//列表数据 //列表数据
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ // {
title: '小程序应用', // title: '小程序应用',
align: "center", // align: "center",
dataIndex: 'appName' // dataIndex: 'appName'
}, // },
// { // {
// title: '手机号码', // title: '手机号码',
// align: "center", // align: "center",

View File

@ -11,7 +11,7 @@
<BasicTable @register="registerTable" :rowSelection="rowSelection"> <BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题--> <!--插槽:table标题-->
<template #tableTitle> <template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <!-- <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>-->
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-dropdown v-if="selectedRowKeys.length > 0">
@ -150,9 +150,9 @@
function getTableAction(record) { function getTableAction(record) {
return [ return [
{ {
label: '编辑', label: '详情',
onClick: handleEdit.bind(null, record), onClick: handleDetail.bind(null, record),
}, }
]; ];
} }
@ -162,9 +162,6 @@
function getDropDownAction(record) { function getDropDownAction(record) {
return [ return [
{ {
label: '详情',
onClick: handleDetail.bind(null, record),
} ,{
label: '初始化用户密码', label: '初始化用户密码',
onClick: handleInitPass.bind(null, record), onClick: handleInitPass.bind(null, record),
}, { }, {

View File

@ -8,20 +8,20 @@
<a-input v-model:value="formData.appType" placeholder="请输入来源应用MA小程序H5普通H5H5-WX微信H5APPappH5-PCPC端H5" :disabled="disabled"></a-input> <a-input v-model:value="formData.appType" placeholder="请输入来源应用MA小程序H5普通H5H5-WX微信H5APPappH5-PCPC端H5" :disabled="disabled"></a-input>
</a-form-item> </a-form-item>
</a-col> --> </a-col> -->
<a-col :span="24"> <!-- <a-col :span="24">-->
<a-form-item label="小程序应用" v-bind="validateInfos.appId"> <!-- <a-form-item label="小程序应用" v-bind="validateInfos.appId">-->
<ApiSelect <!-- <ApiSelect-->
:api="getAppList" <!-- :api="getAppList"-->
showSearch <!-- showSearch-->
v-model:value="formData.appId" <!-- v-model:value="formData.appId"-->
optionFilterProp="label" <!-- optionFilterProp="label"-->
resultField="list" <!-- resultField="list"-->
labelField="name" <!-- labelField="name"-->
valueField="id" <!-- valueField="id"-->
placeholder="请选择" <!-- placeholder="请选择"-->
/> <!-- />-->
</a-form-item> <!-- </a-form-item>-->
</a-col> <!-- </a-col>-->
<a-col :span="24"> <a-col :span="24">
<a-form-item label="账号" v-bind="validateInfos.userName"> <a-form-item label="账号" v-bind="validateInfos.userName">
<a-input v-model:value="formData.userName" placeholder="请输入账号" :disabled="disabled"></a-input> <a-input v-model:value="formData.userName" placeholder="请输入账号" :disabled="disabled"></a-input>

View File

@ -0,0 +1,93 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/appmana/userInfo/list',
save='/appmana/userInfo/add',
edit='/appmana/userInfo/edit',
deleteOne = '/appmana/userInfo/delete',
deleteBatch = '/appmana/userInfo/deleteBatch',
importExcel = '/appmana/userInfo/importExcel',
exportXls = '/appmana/userInfo/exportXls',
initPassword='/appmana/userInfo/initPassword',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const list = (params) => defHttp.get({ url: Api.list, params });
/**
*
* @param params
* @param handleSuccess
*/
export const deleteOne = (params,handleSuccess) => {
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
/**
*
* @param params
* @param handleSuccess
*/
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
});
}
/**
*
* @param params
* @param isUpdate
*/
export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params }, { isTransformResponse: false });
}
/**
*
* @param params
*/
export const initPassword= (params,handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认初始化',
content: '是否初始化用户密码',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.post({url: Api.initPassword,params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
});
}

View File

@ -0,0 +1,167 @@
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
{
title: '小程序应用',
align: "center",
dataIndex: 'appName'
},
// {
// title: '手机号码',
// align: "center",
// dataIndex: 'phone'
// },
{
title: '用户名',
align: "center",
dataIndex: 'userName'
},
{
title: '昵称',
align: "center",
dataIndex: 'nickName'
},
{
title: '性别',
align: "center",
dataIndex: 'sex',
customRender: ({ text }) => {
if (!text || text == '0') {
return '男';
} else if (text == '2') {
return '女';
} else{
return '未知';
}
}
},
{
title: '头像',
align: "center",
dataIndex: 'avatar',
customRender: render.renderAvatar,
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '逻辑删除标记0显示1隐藏',
field: 'delFlag',
component: 'Input',
dynamicRules: ({model,schema}) => {
return [
{ required: true, message: '请输入逻辑删除标记0显示1隐藏!'},
];
},
},
{
label: '用户编码',
field: 'userCode',
component: 'InputNumber',
dynamicRules: ({model,schema}) => {
return [
{ required: true, message: '请输入用户编码!'},
];
},
},
{
label: '来源应用MA小程序H5普通H5H5-WX微信H5APPappH5-PCPC端H5',
field: 'appType',
component: 'Input',
dynamicRules: ({model,schema}) => {
return [
{ required: true, message: '请输入来源应用MA小程序H5普通H5H5-WX微信H5APPappH5-PCPC端H5!'},
];
},
},
{
label: '来源应用id',
field: 'appId',
component: 'Input',
},
{
label: '手机号码',
field: 'phone',
component: 'Input',
},
{
label: '密码',
field: 'password',
component: 'Input',
},
{
label: '用户等级0普通用户1普通会员',
field: 'userGrade',
component: 'InputNumber',
},
{
label: '当前积分',
field: 'pointsCurrent',
component: 'InputNumber',
},
{
label: '昵称',
field: 'nickName',
component: 'Input',
},
{
label: '性别120未知',
field: 'sex',
component: 'Input',
},
{
label: '头像',
field: 'headimgUrl',
component: 'Input',
},
{
label: '所在城市',
field: 'city',
component: 'Input',
},
{
label: '所在国家',
field: 'country',
component: 'Input',
},
{
label: '所在省份',
field: 'province',
component: 'Input',
},
{
label: '上级ID',
field: 'parentId',
component: 'Input',
},
{
label: '用户浏览量',
field: 'userViews',
component: 'InputNumber',
},
{
label: '个性签名',
field: 'userSignature',
component: 'Input',
},
{
label: '版本号',
field: 'version',
component: 'InputNumber',
},
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false,
},
];

View File

@ -0,0 +1,225 @@
<template>
<div>
<!--查询区域-->
<div class="jeecg-basic-table-form-container">
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row :gutter="24">
</a-row>
</a-form>
</div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
</template>
<!--字段回显插槽-->
<template #htmlSlot="{text}">
<div v-html="text"></div>
</template>
<!--省市区字段回显插槽-->
<template #pcaSlot="{text}">
{{ getAreaTextByCode(text) }}
</template>
<template #fileSlot="{text}">
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button>
</template>
</BasicTable>
<!-- 表单区域 -->
<UserInfoModal ref="registerModal" @success="handleSuccess"></UserInfoModal>
</div>
</template>
<script lang="ts" name="appmana-userInfo" setup>
import { ref, reactive } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns } from './UserInfo.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl,initPassword } from './UserInfo.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import UserInfoModal from './components/UserInfoModal.vue'
const formRef = ref();
const queryParam = reactive<any>({});
const toggleSearchStatus = ref<boolean>(false);
const registerModal = ref();
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: 'user_info',
api: list,
columns,
canResize:false,
useSearchForm: false,
actionColumn: {
width: 120,
fixed: 'right',
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
},
exportConfig: {
name: "user_info",
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
const labelCol = reactive({
xs: { span: 24 },
sm: { span: 7 },
});
const wrapperCol = reactive({
xs: { span: 24 },
sm: { span: 16 },
});
/**
* 新增事件
*/
function handleAdd() {
registerModal.value.disableSubmit = false;
registerModal.value.add();
}
/**
* 编辑事件
*/
function handleEdit(record: Recordable) {
registerModal.value.disableSubmit = false;
registerModal.value.edit(record);
}
/**
* 详情
*/
function handleDetail(record: Recordable) {
registerModal.value.disableSubmit = true;
registerModal.value.edit(record);
}
/**
* 删除事件
*/
async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess);
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record) {
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
];
}
/**
* 下拉操作栏
*/
function getDropDownAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
} ,{
label: '初始化用户密码',
onClick: handleInitPass.bind(null, record),
}, {
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
}
}
]
}
/**
* 查询
*/
function searchQuery() {
reload();
}
/**
* 重置
*/
function searchReset() {
formRef.value.resetFields();
selectedRowKeys.value = [];
//
reload();
}
/**
* 初始化用户密码
*/
async function handleInitPass(record) {
await initPassword({ userId: record.id }, handleSuccess);
}
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust{
width: calc(50% - 15px);
min-width: 100px !important;
}
.query-group-split-cust{
width: 30px;
display: inline-block;
text-align: center
}
}
</style>

View File

@ -0,0 +1,209 @@
<template>
<a-spin :spinning="confirmLoading">
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row>
<!-- <a-col :span="24">
<a-form-item label="来源应用MA小程序H5普通H5H5-WX微信H5APPappH5-PCPC端H5" v-bind="validateInfos.appType">
<a-input v-model:value="formData.appType" placeholder="请输入来源应用MA小程序H5普通H5H5-WX微信H5APPappH5-PCPC端H5" :disabled="disabled"></a-input>
</a-form-item>
</a-col> -->
<a-col :span="24">
<a-form-item label="小程序应用" v-bind="validateInfos.appId">
<ApiSelect
:api="getAppList"
showSearch
v-model:value="formData.appId"
optionFilterProp="label"
resultField="list"
labelField="name"
valueField="id"
placeholder="请选择"
/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="账号" v-bind="validateInfos.userName">
<a-input v-model:value="formData.userName" placeholder="请输入账号" :disabled="disabled"></a-input>
<div style=" font-size: 10px; color: red;">初始密码为hjjc2023</div>
</a-form-item>
</a-col>
<!-- <a-col :span="24">
<a-form-item label="手机号码" v-bind="validateInfos.phone">
<a-input v-model:value="formData.phone" placeholder="请输入手机号码" :disabled="disabled"></a-input>
</a-form-item>
</a-col> -->
<!-- <a-col :span="24">
<a-form-item label="密码" v-bind="validateInfos.password">
<a-input v-model:value="formData.password" placeholder="请输入密码" :disabled="disabled"></a-input>
</a-form-item>
</a-col> -->
<!--
<a-col :span="24">
<a-form-item label="性别120未知" v-bind="validateInfos.sex">
<a-input v-model:value="formData.sex" placeholder="请输入性别120未知" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="头像" v-bind="validateInfos.headimgUrl">
<a-input v-model:value="formData.headimgUrl" placeholder="请输入头像" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="所在城市" v-bind="validateInfos.city">
<a-input v-model:value="formData.city" placeholder="请输入所在城市" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="所在国家" v-bind="validateInfos.country">
<a-input v-model:value="formData.country" placeholder="请输入所在国家" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="所在省份" v-bind="validateInfos.province">
<a-input v-model:value="formData.province" placeholder="请输入所在省份" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="上级ID" v-bind="validateInfos.parentId">
<a-input v-model:value="formData.parentId" placeholder="请输入上级ID" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="个性签名" v-bind="validateInfos.userSignature">
<a-input v-model:value="formData.userSignature" placeholder="请输入个性签名" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
-->
</a-row>
</a-form>
</a-spin>
</template>
<script lang="ts" setup>
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { getValueType } from '/@/utils';
import { saveOrUpdate } from '../UserInfo.api';
import { Form } from 'ant-design-vue';
import { getAppList } from '../../wxapp/WxApp.api';
import { ApiSelect} from '/@/components/Form/index';
const props = defineProps({
formDisabled: { type: Boolean, default: false },
formData: { type: Object, default: ()=>{} },
formBpm: { type: Boolean, default: true }
});
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
id: '',
delFlag: '',
userCode: undefined,
appType: 'MA',
appId: '',
phone: '',
userName: '',
password: '',
userGrade: undefined,
pointsCurrent: undefined,
nickName: '',
sex: '',
headimgUrl: '',
city: '',
country: '',
province: '',
parentId: '',
userViews: undefined,
userSignature: '',
version: undefined,
});
const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const confirmLoading = ref<boolean>(false);
//
const validatorRules = {
// phone: [{ required: true, message: ''},],
appId: [{ required: true, message: '请选择小程序应用'},],
userName: [{ required: true, message: '请输入用户名'},],
};
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
//
const disabled = computed(()=>{
if(props.formBpm === true){
if(props.formData.disabled === false){
return false;
}else{
return true;
}
}
return props.formDisabled;
});
/**
* 新增
*/
function add() {
edit({});
}
/**
* 编辑
*/
function edit(record) {
nextTick(() => {
resetFields();
//
Object.assign(formData, record);
});
}
/**
* 提交数据
*/
async function submitForm() {
//
await validate();
confirmLoading.value = true;
const isUpdate = ref<boolean>(false);
//
let model = formData;
if (model.id) {
isUpdate.value = true;
}
await saveOrUpdate(model, isUpdate.value)
.then((res) => {
if (res.success) {
createMessage.success(res.message);
emit('ok');
} else {
createMessage.warning(res.message);
}
})
.finally(() => {
confirmLoading.value = false;
});
}
defineExpose({
add,
edit,
submitForm,
});
</script>
<style lang="less" scoped>
.antd-modal-form {
min-height: 500px !important;
overflow-y: auto;
padding: 24px 24px 24px 24px;
}
</style>

View File

@ -0,0 +1,75 @@
<template>
<a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
<UserInfoForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></UserInfoForm>
</a-modal>
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import UserInfoForm from './UserInfoForm.vue'
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
const disableSubmit = ref<boolean>(false);
const registerForm = ref();
const emit = defineEmits(['register', 'success']);
/**
* 新增
*/
function add() {
title.value = '新增';
visible.value = true;
nextTick(() => {
registerForm.value.add();
});
}
/**
* 编辑
* @param record
*/
function edit(record) {
title.value = disableSubmit.value ? '详情' : '编辑';
visible.value = true;
nextTick(() => {
registerForm.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
function handleOk() {
registerForm.value.submitForm();
}
/**
* form保存回调事件
*/
function submitCallback() {
handleCancel();
emit('success');
}
/**
* 取消按钮回调事件
*/
function handleCancel() {
visible.value = false;
}
defineExpose({
add,
edit,
disableSubmit,
});
</script>
<style>
/**隐藏样式-modal确定按钮 */
.jee-hidden {
display: none !important;
}
</style>