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