点击图片按钮,选择本地图片进行发送
From.vue
<template>
<a-spin :spinning="confirmLoading">
<a-row>
<a-col :span="18" :style="'height:750px;'">
<a-card type="inner" title="工单服务" :style="'background: RGB(247,247,247);height:100%;'">
<chat ref="chat"></chat>
<div class="hover-pr" style="text-align: right; margin-bottom: 5px; float: right;" @click="complaint">
<a-icon type="dislike" /> 我要投诉
</div>
<div @click="uploadImg">
<img style="width: 20px;height: 20px;" src="@/assets/picture.png"/>
</div>
<a-textarea rows="4" placeholder="输入内容" v-model="reply.replyContent" contenteditable @keyup.enter.exact="submit" @keydown.enter.exact="handleKeydown"/>
<a-button type="primary" :style="'float: right;margin-top:5px;'" @click="sendReplyContent" :disabled="model.issueState === '1'">发送</a-button>
</a-card>
</a-col>
</a-row>
</a-spin>
</template>
<script>
import chat from '@/components/chat/chat'
export default {
components: {
chat
},
data () {
return {
url: {
sendContent: "/aa/bb/add",
addPicture: "/aa/bb/addPicture",
isComplaint: "/aa/bb/isComplaint"
}
}
},
mounted() {
this.$refs.chat.getReplyList(this.model.id)
},
methods: {
//输入框按下回车发送
handleKeydown(event) {
if (event.shiftKey && event.keyCode === 13) {
document.execCommand('insertLineBreak'); // 换行
} else if (event.keyCode === 13) { // 回车键
console.log("回车发送");
this.sendReplyContent();
return false;
}
},
//上传图片
uploadImg:function (){
let that=this;
let input = document.createElement("input");
input.type = "file";
input.accept = "image/gif,image/jpe