mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2026-02-08 18:54:25 +08:00
v3.18.0 【新增】新增消息管理;【新增】完善企业demo;【新增】完善相关数据权限;【新增】菜单管理下级功能
This commit is contained in:
@@ -102,7 +102,7 @@
|
||||
:dataSource="tableData"
|
||||
:columns="columns"
|
||||
rowKey="goodsId"
|
||||
:scroll="{ x: 1000,y: yHeight }"
|
||||
:scroll="{ x: 1000, y: yHeight }"
|
||||
bordered
|
||||
:pagination="false"
|
||||
:showSorterTooltip="false"
|
||||
@@ -110,8 +110,6 @@
|
||||
@change="onChange"
|
||||
@resizeColumn="handleResizeColumn"
|
||||
>
|
||||
<!-- main.js中有全局表格高度配置,也可单独配置 -->
|
||||
<!-- :scroll="{ y: 300 }" -->
|
||||
<template #headerCell="{ column }">
|
||||
<SmartHeaderCell v-model:value="queryForm[column.filterOptions?.key || column.dataIndex]" :column="column" @change="queryData" />
|
||||
</template>
|
||||
@@ -205,7 +203,6 @@
|
||||
import SmartHeaderCell from '/@/components/support/table-header-cell/index.vue';
|
||||
import { DICT_CODE_ENUM } from '/@/constants/support/dict-const.js';
|
||||
import DictLabel from '/@/components/support/dict-label/index.vue';
|
||||
import { onBeforeMount } from 'vue';
|
||||
|
||||
// ---------------------------- 表格列 ----------------------------
|
||||
|
||||
@@ -499,15 +496,31 @@ import { onBeforeMount } from 'vue';
|
||||
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
|
||||
}
|
||||
|
||||
const dueHeight=ref(0)
|
||||
const yHeight=ref(0)
|
||||
// 动态设置表格高度
|
||||
const yHeight = ref(0);
|
||||
onMounted(() => {
|
||||
let doc = document.querySelector('.ant-form');
|
||||
let btn = document.querySelector('.smart-table-btn-block');
|
||||
let tableCell = document.querySelector('.ant-table-cell');
|
||||
let page = document.querySelector('.smart-query-table-page');
|
||||
let box = document.querySelector('.ant-layout-content>div');
|
||||
dueHeight.value = doc.offsetHeight+10+24+btn.offsetHeight+15+tableCell.offsetHeight+page.offsetHeight+20
|
||||
yHeight.value=box.offsetHeight-dueHeight.value
|
||||
resetGetHeight();
|
||||
});
|
||||
function resetGetHeight() {
|
||||
// 搜索部分高度
|
||||
let doc = document.querySelector('.ant-form');
|
||||
// 按钮部分高度
|
||||
let btn = document.querySelector('.smart-table-btn-block');
|
||||
// 表格头高度
|
||||
let tableCell = document.querySelector('.ant-table-cell');
|
||||
// 分页高度
|
||||
let page = document.querySelector('.smart-query-table-page');
|
||||
// 内容区总高度
|
||||
let box = document.querySelector('.admin-content');
|
||||
setTimeout(() => {
|
||||
let dueHeight = doc.offsetHeight + 10 + 24 + btn.offsetHeight + 15 + tableCell.offsetHeight + page.offsetHeight + 20;
|
||||
yHeight.value = box.offsetHeight - dueHeight;
|
||||
}, 100);
|
||||
}
|
||||
window.addEventListener(
|
||||
'resize',
|
||||
_.throttle(() => {
|
||||
resetGetHeight();
|
||||
}, 1000)
|
||||
);
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<a-modal v-model:open="visible" title="推送人" width="1100px" ok-text="确定" cancel-text="取消" @ok="onSubmit" @cancel="onClose" :zIndex="9999">
|
||||
<a-form class="smart-query-form">
|
||||
<a-row class="smart-query-form-row">
|
||||
<a-form-item label="关键词搜索" class="smart-query-form-item">
|
||||
<a-input v-model:value="queryParam.searchWord" :style="{ width: '250px' }" placeholder="请输入姓名" @change="selectSearchWord" />
|
||||
</a-form-item>
|
||||
<a-form-item class="smart-query-form-item">
|
||||
<a-button type="primary" @click="searchQuery">
|
||||
<template #icon>
|
||||
<SearchOutlined />
|
||||
</template>
|
||||
查询
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
<a-form-item class="smart-query-form-item">
|
||||
<a-button @click="searchReset">
|
||||
<template #icon>
|
||||
<ReloadOutlined />
|
||||
</template>
|
||||
重置
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
</a-row>
|
||||
</a-form>
|
||||
<a-table
|
||||
rowKey="employeeId"
|
||||
:loading="tableLoading"
|
||||
:columns="columns"
|
||||
:data-source="tableData"
|
||||
bordered
|
||||
:pagination="false"
|
||||
:row-selection="{
|
||||
selectedRowKeys: selectedRowKeyList,
|
||||
onChange: onSelectChange,
|
||||
}"
|
||||
>
|
||||
</a-table>
|
||||
<div class="smart-query-table-page">
|
||||
<a-pagination
|
||||
showSizeChanger
|
||||
showQuickJumper
|
||||
show-less-items
|
||||
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
||||
:defaultPageSize="queryParam.pageSize"
|
||||
v-model:current="queryParam.pageNum"
|
||||
v-model:pageSize="queryParam.pageSize"
|
||||
:total="total"
|
||||
@change="queryList"
|
||||
@showSizeChange="queryList"
|
||||
:show-total="(total) => `共${total}条`"
|
||||
/>
|
||||
</div>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||
import { smartSentry } from '/src/lib/smart-sentry';
|
||||
import { SmartLoading } from '/src/components/framework/smart-loading';
|
||||
import SmartEnumSelect from '/src/components/framework/smart-enum-select/index.vue';
|
||||
import { employeeApi } from '/@/api/system/employee-api';
|
||||
// ---------------查询条件----------------
|
||||
const queryParamState = {
|
||||
searchWord: null,
|
||||
keyword: null,
|
||||
pageNum: 1,
|
||||
pageSize: PAGE_SIZE,
|
||||
};
|
||||
|
||||
const classId = ref();
|
||||
const queryParam = reactive({ ...queryParamState });
|
||||
const tableData = ref([]);
|
||||
let tableLoading = ref(false);
|
||||
const total = ref(0);
|
||||
|
||||
// 搜索
|
||||
function searchQuery() {
|
||||
queryList();
|
||||
}
|
||||
|
||||
// 弹窗打开
|
||||
const visible = ref(false);
|
||||
// 重置
|
||||
function searchReset() {
|
||||
Object.assign(queryParam, queryParamState);
|
||||
queryList();
|
||||
}
|
||||
function showModal(receiverIdList) {
|
||||
selectedRowKeyList.value = receiverIdList;
|
||||
queryList();
|
||||
visible.value = true;
|
||||
}
|
||||
function selectSearchWord(e) {
|
||||
queryParam.keyword = queryParam.searchWord;
|
||||
}
|
||||
const columns = [
|
||||
{
|
||||
title: '姓名',
|
||||
dataIndex: 'actualName',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
dataIndex: 'phone',
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
// ----------查询------------
|
||||
async function queryList() {
|
||||
try {
|
||||
tableLoading.value = true;
|
||||
let res = await employeeApi.queryEmployee(queryParam);
|
||||
const list = res.data.list;
|
||||
total.value = res.data.total;
|
||||
tableData.value = list;
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
} finally {
|
||||
tableLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 选择成绩表
|
||||
const selectedRowKeyList = ref([]);
|
||||
const selectedRowsList = ref([]);
|
||||
function onSelectChange(keyArray, selectedRows) {
|
||||
selectedRowKeyList.value = keyArray;
|
||||
selectedRowsList.value = selectedRows;
|
||||
}
|
||||
|
||||
// 弹窗管理
|
||||
function onClose() {
|
||||
visible.value = false;
|
||||
let nameList = selectedRowsList.value.map((item) => item.actualName);
|
||||
emit('reloadList', selectedRowKeyList.value, nameList);
|
||||
}
|
||||
const emit = defineEmits(['reloadList']);
|
||||
|
||||
// 提交
|
||||
function onSubmit() {
|
||||
try {
|
||||
onClose();
|
||||
} catch (error) {
|
||||
smartSentry.captureError(error);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
showModal,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less"></style>
|
||||
@@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<a-modal title="添加" :width="700" :open="visibleFlag" @cancel="onClose" :maskClosable="false" :destroyOnClose="true">
|
||||
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
|
||||
<a-form-item label="标题" name="title">
|
||||
<a-input style="width: 100%" v-model:value="form.title" placeholder="标题" />
|
||||
</a-form-item>
|
||||
<a-form-item label="接收人" name="receiverUserIdList">
|
||||
<a-button @click="selectReceiver" type="primary"> 选择接收人 </a-button>
|
||||
<div>{{ nameListString }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="消息类型" name="messageType">
|
||||
<SmartEnumSelect width="100%" v-model:value="form.messageType" placeholder="请选择类型" enum-name="MESSAGE_TYPE_ENUM" />
|
||||
</a-form-item>
|
||||
<a-form-item label="推送内容" name="content">
|
||||
<a-textarea style="width: 100%" v-model:value="form.content" placeholder="推送内容" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="onSubmit">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-modal>
|
||||
<MessageReceiverModal ref="receiverModalRef" @reloadList="addReceiverIdList" />
|
||||
</template>
|
||||
<script setup>
|
||||
import { nextTick, reactive, ref } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { SmartLoading } from '/src/components/framework/smart-loading';
|
||||
import { smartSentry } from '/src/lib/smart-sentry';
|
||||
import SmartEnumSelect from '/src/components/framework/smart-enum-select/index.vue';
|
||||
import MessageReceiverModal from './message-receiver-modal.vue';
|
||||
import { USER_TYPE_ENUM } from '/src/constants/common-const.js';
|
||||
import { messageApi } from '/@/api/support/message-api.js';
|
||||
// ------------------------ 事件 ------------------------
|
||||
|
||||
const emits = defineEmits(['reloadList']);
|
||||
|
||||
// ------------------------ 显示与隐藏 ------------------------
|
||||
// 是否显示
|
||||
const visibleFlag = ref(false);
|
||||
|
||||
function show(rowData) {
|
||||
Object.assign(form, formDefault);
|
||||
nameListString.value = null;
|
||||
visibleFlag.value = true;
|
||||
nextTick(() => {
|
||||
formRef.value.clearValidate();
|
||||
});
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
Object.assign(form, formDefault);
|
||||
visibleFlag.value = false;
|
||||
}
|
||||
|
||||
// ------------------------ 表单 ------------------------
|
||||
|
||||
// 组件ref
|
||||
const formRef = ref();
|
||||
|
||||
const formDefault = {
|
||||
title: undefined,
|
||||
receiverUserIdList: null,
|
||||
content: null,
|
||||
messageType: null,
|
||||
receiverUserType: USER_TYPE_ENUM.ADMIN_EMPLOYEE.value,
|
||||
};
|
||||
|
||||
let form = reactive({ ...formDefault });
|
||||
|
||||
const rules = {
|
||||
title: [{ required: true, message: '标题 必填' }],
|
||||
content: [{ required: true, message: '推送内容 必填' }],
|
||||
receiverUserIdList: [{ required: true, message: '推送人 必填' }],
|
||||
messageType: [{ required: true, message: '消息类型 必填' }],
|
||||
};
|
||||
|
||||
const nameListString = ref();
|
||||
function addReceiverIdList(idList, nameList) {
|
||||
form.receiverUserIdList = idList;
|
||||
nameListString.value = nameList.join(',');
|
||||
}
|
||||
|
||||
const receiverModalRef = ref();
|
||||
function selectReceiver() {
|
||||
receiverModalRef.value.showModal(form.receiverUserIdList);
|
||||
}
|
||||
|
||||
// 点击确定,验证表单
|
||||
async function onSubmit() {
|
||||
try {
|
||||
await formRef.value.validateFields();
|
||||
save();
|
||||
} catch (err) {
|
||||
message.error('参数验证错误,请仔细填写表单数据!');
|
||||
}
|
||||
}
|
||||
|
||||
// 新建、编辑API
|
||||
async function save() {
|
||||
SmartLoading.show();
|
||||
try {
|
||||
let messageList = [];
|
||||
for (const userId of form.receiverUserIdList) {
|
||||
messageList.push({
|
||||
title: form.title,
|
||||
receiverUserId: userId,
|
||||
content: form.content,
|
||||
messageType: form.messageType,
|
||||
receiverUserType: USER_TYPE_ENUM.ADMIN_EMPLOYEE.value,
|
||||
});
|
||||
}
|
||||
await messageApi.sendMessages(messageList);
|
||||
message.success('操作成功');
|
||||
emits('reloadList');
|
||||
onClose();
|
||||
} catch (err) {
|
||||
smartSentry.captureError(err);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
defineExpose({
|
||||
show,
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,236 @@
|
||||
<template>
|
||||
<!---------- 查询表单form begin ----------->
|
||||
<a-form class="smart-query-form">
|
||||
<a-row class="smart-query-form-row">
|
||||
<a-form-item label="关键词" class="smart-query-form-item">
|
||||
<a-input style="width: 150px" v-model:value="queryForm.searchWord" placeholder="关键词" />
|
||||
</a-form-item>
|
||||
<a-form-item label="类型" class="smart-query-form-item">
|
||||
<smart-enum-select style="width: 150px" v-model:value="queryForm.messageType" placeholder="消息类型" enum-name="MESSAGE_TYPE_ENUM" />
|
||||
</a-form-item>
|
||||
<a-form-item label="是否已读" class="smart-query-form-item">
|
||||
<SmartEnumSelect width="120px" enum-name="FLAG_NUMBER_ENUM" v-model:value="queryForm.readFlag" />
|
||||
</a-form-item>
|
||||
<a-form-item label="创建时间" class="smart-query-form-item">
|
||||
<a-range-picker v-model:value="queryForm.createTime" style="width: 200px" @change="onChangeCreateTime" />
|
||||
</a-form-item>
|
||||
<a-form-item class="smart-query-form-item">
|
||||
<a-button type="primary" @click="searchQuery">
|
||||
<template #icon>
|
||||
<SearchOutlined />
|
||||
</template>
|
||||
查询
|
||||
</a-button>
|
||||
<a-button @click="resetQuery" class="smart-margin-left10">
|
||||
<template #icon>
|
||||
<ReloadOutlined />
|
||||
</template>
|
||||
重置
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
</a-row>
|
||||
</a-form>
|
||||
<!---------- 查询表单form end ----------->
|
||||
|
||||
<a-card size="small" :bordered="false" :hoverable="true">
|
||||
<!---------- 表格操作行 begin ----------->
|
||||
<a-row class="smart-table-btn-block">
|
||||
<div class="smart-table-operate-block">
|
||||
<a-button @click="showForm" type="primary">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
发送消息
|
||||
</a-button>
|
||||
</div>
|
||||
<div class="smart-table-setting-block">
|
||||
<TableOperator v-model="columns" :tableId="TABLE_ID_CONST.SUPPORT.MAIL" :refresh="queryData" />
|
||||
</div>
|
||||
</a-row>
|
||||
<!---------- 表格操作行 end ----------->
|
||||
|
||||
<!---------- 表格 begin ----------->
|
||||
<a-table size="small" :dataSource="tableData" :columns="columns" rowKey="telephoneId" bordered :loading="tableLoading" :pagination="false">
|
||||
<template #bodyCell="{ record, column, text }">
|
||||
<template v-if="column.dataIndex === 'readFlag'">
|
||||
{{ text ? '已读' : '未读' }}
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'messageType'">
|
||||
{{ $smartEnumPlugin.getDescByValue('MESSAGE_TYPE_ENUM', text) }}
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<div class="smart-table-operate">
|
||||
<a-button @click="onDelete(record)" danger type="link">删除</a-button>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
<!---------- 表格 end ----------->
|
||||
|
||||
<div class="smart-query-table-page">
|
||||
<a-pagination
|
||||
showSizeChanger
|
||||
showQuickJumper
|
||||
show-less-items
|
||||
:pageSizeOptions="PAGE_SIZE_OPTIONS"
|
||||
:defaultPageSize="queryForm.pageSize"
|
||||
v-model:current="queryForm.pageNum"
|
||||
v-model:pageSize="queryForm.pageSize"
|
||||
:total="total"
|
||||
@change="queryData"
|
||||
@showSizeChange="queryData"
|
||||
:show-total="(total) => `共${total}条`"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<MessageSendForm ref="formRef" @reloadList="queryData" />
|
||||
</a-card>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||
import { messageApi } from '/@/api/support/message-api';
|
||||
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';
|
||||
import TableOperator from '/@/components/support/table-operator/index.vue';
|
||||
import MessageSendForm from './components/message-send-form.vue';
|
||||
import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
|
||||
// ---------------------------- 表格列 ----------------------------
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
title: '消息类型',
|
||||
dataIndex: 'messageType',
|
||||
ellipsis: true,
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '消息标题',
|
||||
dataIndex: 'title',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '消息内容',
|
||||
dataIndex: 'content',
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: '接收人ID',
|
||||
dataIndex: 'receiverUserId',
|
||||
ellipsis: true,
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: '已读',
|
||||
dataIndex: 'readFlag',
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
title: '已读时间',
|
||||
dataIndex: 'readTime',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
fixed: 'right',
|
||||
width: 60,
|
||||
},
|
||||
]);
|
||||
|
||||
// ---------------------------- 查询数据表单和方法 ----------------------------
|
||||
|
||||
const queryFormState = {
|
||||
searchWord: undefined, //关键词
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
createTime: [],
|
||||
readFlag: null,
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
messageType: null,
|
||||
};
|
||||
function onChangeCreateTime(dates, dateStrings) {
|
||||
queryForm.startDate = dateStrings[0];
|
||||
queryForm.endDate = dateStrings[1];
|
||||
}
|
||||
// 查询表单form
|
||||
const queryForm = reactive({ ...queryFormState });
|
||||
// 表格加载loading
|
||||
const tableLoading = ref(false);
|
||||
// 表格数据
|
||||
const tableData = ref([]);
|
||||
// 总数
|
||||
const total = ref(0);
|
||||
|
||||
// 重置查询条件
|
||||
function resetQuery() {
|
||||
let pageSize = queryForm.pageSize;
|
||||
Object.assign(queryForm, queryFormState);
|
||||
queryForm.pageSize = pageSize;
|
||||
queryData();
|
||||
}
|
||||
|
||||
function searchQuery() {
|
||||
queryForm.pageNum = 1;
|
||||
queryData();
|
||||
}
|
||||
|
||||
// 查询数据
|
||||
async function queryData() {
|
||||
tableLoading.value = true;
|
||||
try {
|
||||
let queryResult = await messageApi.queryAdminMessage(queryForm);
|
||||
tableData.value = queryResult.data.list;
|
||||
total.value = queryResult.data.total;
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
} finally {
|
||||
tableLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(queryData);
|
||||
|
||||
// ---------------------------- 添加/修改 ----------------------------
|
||||
const formRef = ref();
|
||||
|
||||
function showForm(data) {
|
||||
formRef.value.show(data);
|
||||
}
|
||||
|
||||
//确认删除
|
||||
function onDelete(data) {
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选吗?',
|
||||
okText: '删除',
|
||||
okType: 'danger',
|
||||
onOk() {
|
||||
requestDelete(data);
|
||||
},
|
||||
cancelText: '取消',
|
||||
onCancel() {},
|
||||
});
|
||||
}
|
||||
|
||||
async function requestDelete(data) {
|
||||
try {
|
||||
SmartLoading.show();
|
||||
await messageApi.deleteMessage(data.messageId);
|
||||
message.success('删除成功');
|
||||
queryData();
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
} finally {
|
||||
SmartLoading.hide();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user