优化消息发送
This commit is contained in:
parent
37be5e9b01
commit
0ace34f177
@ -96,18 +96,17 @@
|
||||
</template>
|
||||
</BasicTable>
|
||||
</el-card>
|
||||
<!-- 添加、编辑弹框 -->
|
||||
<editDialog
|
||||
v-if="editVisible"
|
||||
:userId="userId"
|
||||
v-model:visible="editVisible"
|
||||
@success="reloadTable('noRefresh')"
|
||||
/>
|
||||
<!-- 上传文件 -->
|
||||
<userUpload v-if="importVisible" v-model:visible="importVisible" @success="reloadTable()" />
|
||||
<sendMsgDialog
|
||||
v-if="sendMsgVisible"
|
||||
v-model:visible="sendMsgVisible"
|
||||
:receiveId="receiveId"
|
||||
/>
|
||||
<!-- 发送WebSocket消息 -->
|
||||
<sendMsgDialog v-if="sendMsgVisible" v-model:visible="sendMsgVisible" :receiveId="receiveId" />
|
||||
</PageWrapper>
|
||||
</template>
|
||||
|
||||
@ -116,7 +115,6 @@
|
||||
import { ColProps } from 'element-plus';
|
||||
import { TableAction } from '@/components/Table';
|
||||
import { useForm } from '@/components/Form/index';
|
||||
import { initWebSocket,sendWebSocket } from '@/components/Websocket/index';
|
||||
import {
|
||||
getUserList,
|
||||
userDelete,
|
||||
@ -130,8 +128,12 @@
|
||||
import { schemas } from './querySchemas';
|
||||
import { downloadByData } from '@/utils/file/download';
|
||||
import printJS from 'print-js';
|
||||
|
||||
/**
|
||||
* 定义参数
|
||||
*/
|
||||
const userId = ref(0);
|
||||
const receiveId = ref('')
|
||||
const receiveId = ref('');
|
||||
const tableRef = ref();
|
||||
const editVisible = ref(false);
|
||||
const sendMsgVisible = ref(false);
|
||||
@ -141,6 +143,7 @@
|
||||
const editDialog = defineAsyncComponent(() => import('./edit.vue'));
|
||||
const sendMsgDialog = defineAsyncComponent(() => import('./sendMsg.vue'));
|
||||
const userUpload = defineAsyncComponent(() => import('./userUpload.vue'));
|
||||
|
||||
/**
|
||||
* 定义查询参数
|
||||
*/
|
||||
@ -329,19 +332,21 @@
|
||||
exportLoading.value = false;
|
||||
message('导出成功');
|
||||
};
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* 此处写的是Socket消息发送案例,实际业务研发时根据实际需求自行接入模板消息
|
||||
*/
|
||||
const sendMessage=async ()=>{
|
||||
if(selectionData.value.length==0){
|
||||
message('请选择数据','error')
|
||||
return
|
||||
const sendMessage = async () => {
|
||||
if (selectionData.value.length == 0) {
|
||||
message('请选择数据', 'error');
|
||||
return;
|
||||
}
|
||||
let ids = [];
|
||||
ids = selectionData.value.map(({ id }) => id);
|
||||
receiveId.value = ids.join()
|
||||
sendMsgVisible.value = true
|
||||
}
|
||||
receiveId.value = ids.join();
|
||||
sendMsgVisible.value = true;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
@ -7,9 +7,12 @@
|
||||
:before-close="dialogClose"
|
||||
>
|
||||
<el-form :model="formData" label-width="100px" ref="formRef">
|
||||
<el-form-item label="消息内容" prop="message"
|
||||
:rules="{ required: true, message: '请输入消息内容', trigger: 'blur' }">
|
||||
<el-input v-model="formData.message" type="textarea"/>
|
||||
<el-form-item
|
||||
label="消息内容"
|
||||
prop="message"
|
||||
:rules="{ required: true, message: '请输入消息内容', trigger: 'blur' }"
|
||||
>
|
||||
<el-input v-model="formData.message" type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
@ -22,14 +25,20 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'element-plus';
|
||||
import {sendMsg} from '@/api/system/user';
|
||||
import { sendMsg } from '@/api/system/user';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { onMounted, reactive, ref, shallowRef } from 'vue';
|
||||
import { message, buildTree } from '@/utils/auth';
|
||||
import { useLockFn } from '@/utils/useLockFn';
|
||||
|
||||
/**
|
||||
* 定义参数
|
||||
*/
|
||||
const userStore = useUserStore();
|
||||
const userInfo: object = userStore.getUserInfo || {};
|
||||
const emit = defineEmits(['update:visible']);
|
||||
const formRef = shallowRef<FormInstance>();
|
||||
|
||||
/**
|
||||
* 定义接收的参数
|
||||
*/
|
||||
@ -44,14 +53,12 @@
|
||||
default: '',
|
||||
},
|
||||
});
|
||||
const emit = defineEmits(['update:visible']);
|
||||
const formRef = shallowRef<FormInstance>();
|
||||
|
||||
/**
|
||||
* 定义表单参数
|
||||
*/
|
||||
const formData = reactive({
|
||||
message: ''
|
||||
message: '',
|
||||
});
|
||||
|
||||
/**
|
||||
@ -67,14 +74,13 @@
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate();
|
||||
await sendMsg({
|
||||
formId:userInfo.id,
|
||||
receiveId:props.receiveId,
|
||||
message:formData.message
|
||||
})
|
||||
formId: userInfo.id,
|
||||
receiveId: props.receiveId,
|
||||
message: formData.message,
|
||||
});
|
||||
message('发送成功');
|
||||
emit('update:visible', false);
|
||||
};
|
||||
|
||||
const { isLock: subLoading, lockFn: submit } = useLockFn(handleSubmit);
|
||||
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user