|
@@ -29,12 +29,16 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="flex-1 p-base overflow-hidden">
|
|
|
- <div class="full-h radius-base scroll-y-auto message-info-content">
|
|
|
- <content-edit-able v-model="messageContent" class="full-h" @click="onContentClick"></content-edit-able>
|
|
|
+ <div class="full-h radius-base p-base scroll-y-auto message-info-content">
|
|
|
+ <content-edit-able
|
|
|
+ v-model="messageContent"
|
|
|
+ class="full content-edit-able"
|
|
|
+ @click="onContentClick"
|
|
|
+ ></content-edit-able>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="p-base flex items-center justify-end">
|
|
|
- <el-button size="small" plain @click="sendCurrentPaper">发送当前试卷</el-button>
|
|
|
+ <el-button v-show="showSendPaper" size="small" plain @click="sendCurrentPaper">发送当前试卷</el-button>
|
|
|
<el-button size="small" type="primary" :disabled="!allowSend" :loading="loading" @click="onSendMessage">
|
|
|
发送
|
|
|
</el-button>
|
|
@@ -42,11 +46,11 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <image-preview v-model="previewModalVisible" :url="previewPath"></image-preview>
|
|
|
+ <image-preview v-model="previewModalVisible" :url="props.paperPath || ''"></image-preview>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="tsx" name="MessageSend">
|
|
|
-import { ref, computed, watch, nextTick, defineComponent, createApp } from 'vue'
|
|
|
+import { ref, computed, watch, nextTick } from 'vue'
|
|
|
import { ElInput, ElButton, ElTree, ElIcon, ElMessage } from 'element-plus'
|
|
|
import { Close } from '@element-plus/icons-vue'
|
|
|
import ContentEditAble from '@/components/common/ContentEditAble.vue'
|
|
@@ -60,26 +64,39 @@ type MarkerItem = ExtractArrayValue<ExtractApiResponse<'getUserGroup'>['chiffGro
|
|
|
type TreeNode = ExtractArrayValue<ExtractApiResponse<'getUserGroup'>['markerGroup']> & { label: string }
|
|
|
|
|
|
const props = defineProps<{
|
|
|
- replyUserId: number
|
|
|
+ replyUserId?: number | null
|
|
|
+ paperPath?: string | null
|
|
|
}>()
|
|
|
|
|
|
-const emit = defineEmits(['close'])
|
|
|
+/** cleat warning */
|
|
|
+const emit = defineEmits(['close', 'change-type', 'reply'])
|
|
|
|
|
|
+/** 默认的收件人ID */
|
|
|
const replyUserId = useVModel(props, 'replyUserId')
|
|
|
|
|
|
/** 图片预览 */
|
|
|
const previewModalVisible = ref<boolean>(false)
|
|
|
|
|
|
-const previewPath = ref<string>()
|
|
|
-
|
|
|
+/** 显示收件人tree */
|
|
|
const showCheckUser = ref<boolean>(true)
|
|
|
|
|
|
+/** 消息内容 */
|
|
|
const messageContent = ref<string>('')
|
|
|
|
|
|
+/** 选中的收件人 */
|
|
|
const checkedUsers = ref<MarkerItem[]>([])
|
|
|
|
|
|
+/** 收件人tree 筛选关键字 */
|
|
|
const filterText = ref<string>('')
|
|
|
|
|
|
+/** 是否已发送试卷 */
|
|
|
+const sendedPaper = ref<boolean>(false)
|
|
|
+
|
|
|
+/** 显示发送试卷按钮 */
|
|
|
+const showSendPaper = computed<boolean>(() => {
|
|
|
+ return !!props.paperPath && !sendedPaper.value
|
|
|
+})
|
|
|
+
|
|
|
const allowSend = computed<boolean>(() => {
|
|
|
return !!(messageContent.value && checkedUsers.value.length)
|
|
|
})
|
|
@@ -145,36 +162,26 @@ const onCheckChange = () => {
|
|
|
checkedUsers.value = (treeRef?.value?.getCheckedNodes(true) as MarkerItem[]) || []
|
|
|
}
|
|
|
|
|
|
+watch(messageContent, () => {
|
|
|
+ nextTick(() => {
|
|
|
+ const paperButton = document.querySelector(`.content-edit-able [data-path="${props.paperPath}"]`)
|
|
|
+ sendedPaper.value = !!paperButton
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
const onContentClick = (e: Event) => {
|
|
|
const target = e.target as HTMLButtonElement
|
|
|
- console.log([target])
|
|
|
- const data = target.getAttribute('data')
|
|
|
- console.log(data)
|
|
|
const path = target.getAttribute('data-path')
|
|
|
if (path) {
|
|
|
- console.log(path)
|
|
|
+ previewModalVisible.value = true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/** 发送当前试卷 */
|
|
|
const sendCurrentPaper = () => {
|
|
|
- const ImgLink = defineComponent({
|
|
|
- render() {
|
|
|
- return (
|
|
|
- <ElButton
|
|
|
- style={{ textAlign: 'left' }}
|
|
|
- class="pointer inline-block full-w"
|
|
|
- contenteditable={false}
|
|
|
- type="primary"
|
|
|
- data={'xxxxx'}
|
|
|
- link
|
|
|
- >
|
|
|
- 当前试卷
|
|
|
- </ElButton>
|
|
|
- )
|
|
|
- },
|
|
|
- })
|
|
|
- messageContent.value += createApp(ImgLink).mount(document.createElement('div')).$el.outerHTML
|
|
|
+ if (props.paperPath) {
|
|
|
+ messageContent.value += ` <span class="pointer inline link-button" contenteditable="false" data-path="${props.paperPath}">当前试卷</span>`
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const { fetch: sendMessage, loading } = useFetch('sendMessage')
|
|
@@ -182,6 +189,9 @@ const { fetch: sendMessage, loading } = useFetch('sendMessage')
|
|
|
/** 发送消息 */
|
|
|
const onSendMessage = async () => {
|
|
|
try {
|
|
|
+ if (messageContent.value.length > 2000) {
|
|
|
+ return ElMessage.error('输入内容过长')
|
|
|
+ }
|
|
|
await sendMessage({
|
|
|
content: messageContent.value,
|
|
|
receiveUserIds: checkedUsers.value.map((u) => u.id),
|
|
@@ -244,7 +254,7 @@ getUserGroup()
|
|
|
}
|
|
|
}
|
|
|
.message-info-content {
|
|
|
- // border: $OnePixelLine;
|
|
|
+ border: 1px solid $color--primary;
|
|
|
font-size: $SmallFont;
|
|
|
::v-deep(textarea.el-textarea__inner) {
|
|
|
height: 100%;
|