chat.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. import { mapActions, mapState, mapMutations } from 'vuex'
  2. import { scrollMsgIntoView, lazyloadImage, getMeechatType } from '@/util/util.js'
  3. import { emojiList } from '@/util/emoji'
  4. import { Message } from 'element-ui'
  5. import WsManager from '@/util/wsManager.js'
  6. import ImageMin from '@/util/imageMin.js'
  7. import { getMiniWsUrl } from '@/util/contract.js'
  8. import PostMessager from '@/util/postMessager.js'
  9. // 聊天mixin 用于chatRoom组件
  10. export const chatMixin = {
  11. watch: {
  12. '$route' () {
  13. this.bdHiden = true
  14. // 切换房间
  15. this.groupSet = false
  16. this.lockMore = false
  17. this.lockEnd = false
  18. this.enableScroll = false
  19. if (this.meechatType == 'mini') this.initMiniRoom()
  20. else this.initRoom()
  21. },
  22. chatList (val) {
  23. let lastVal = val[val.length - 1]
  24. if ((lastVal && lastVal.msg_type == 4) || this.isBottom) {
  25. // 自己发的红包自动滚动到底部
  26. this.$nextTick(this.resizeToBottom)
  27. }
  28. },
  29. isJoinGroup (val) {
  30. if (val == 1) setTimeout(this.resizeToBottom.bind(this), 100)
  31. }
  32. },
  33. data () {
  34. return {
  35. isLoadingRoom: true,
  36. groupSet: false,
  37. lockMore: false,
  38. lockEnd: false,
  39. enableScroll: false, // 记录滚动条是否激活的状态
  40. isBottom: true,
  41. scrollHeight: 100, // 滚动条高度
  42. isScrollToView: false,
  43. isShowGroudMgr: false, // 是否显示群管理
  44. chatImageArrSel: null, // 图片组
  45. meechatType: getMeechatType()
  46. }
  47. },
  48. computed: {
  49. ...mapState(['curSession', 'group', 'chat', 'userId', 'userInfo']),
  50. ...mapState({
  51. creator: state => state.group.creator,
  52. isJoin: state => state.group.isJoin,
  53. pinMsg: state => state.group.pinMsg,
  54. atList: state => state.group.atList,
  55. unreadNums: state => state.group.unreadNums,
  56. chatList: state => state.group.chatList,
  57. members: state => state.group.members,
  58. sessionId: state => state.curSession,
  59. sessionInfo: state => state.group.sessionInfo
  60. }),
  61. isExist () {
  62. // 是否存在在会话列表中
  63. let sessionList = this.chat.sessionList
  64. if (sessionList && sessionList.length) {
  65. return sessionList.some(e => {
  66. return e.session_id == this.sessionId
  67. })
  68. } else {
  69. return true
  70. }
  71. },
  72. isAdmin () {
  73. return (this.group.adminList && this.group.adminList.some(id => id == this.userId)) || this.group.creator == this.userId
  74. },
  75. isPrivate () {
  76. return this.$store.getters.isPrivate
  77. },
  78. isCreator () {
  79. return this.userId == this.creator
  80. },
  81. isJoinGroup () {
  82. if (this.group && this.group.groupId) {
  83. return this.isJoin ? 1 : 0
  84. } else {
  85. return 1
  86. }
  87. },
  88. linkToCreator () {
  89. let { creator, userId } = this.group
  90. let sessionId = creator > userId ? `${userId}-${creator}` : `${creator}-${userId}`
  91. return `${location.origin}/#/pm/${sessionId}`
  92. }
  93. },
  94. mounted () {
  95. if (this.meechatType == 'mini') this.initMiniRoom()
  96. else this.initRoom()
  97. document.getElementById('app').addEventListener('contextmenu', e => e.preventDefault())
  98. this.chatImageArrSel = this.$refs.scrollWrap.getElementsByTagName('img')
  99. // this.$nextTick(() => {
  100. // this.$refs.msgWrap.style.height = 'auto'
  101. // })
  102. },
  103. methods: {
  104. ...mapMutations([
  105. 'initGroup',
  106. 'setUserId',
  107. 'setToken',
  108. 'resetUnreadNums',
  109. 'addChatItem',
  110. 'deleteChatItem',
  111. 'initState',
  112. 'clearAtList',
  113. 'clearHash',
  114. 'setSessionItemUnread',
  115. 'clearChatList',
  116. 'changeSessionId',
  117. 'addPinChatItem'
  118. ]),
  119. ...mapActions([
  120. 'setAccount',
  121. 'getGroupInfo',
  122. 'getUserInfo',
  123. 'getNewMsgFromDb',
  124. 'getNewMsg',
  125. 'getHistoryMsg',
  126. 'doSendMsg',
  127. 'getPrivateNewMsgFromDb',
  128. 'getPrivateNewMsg',
  129. 'getPrivateHistoryMsg',
  130. 'doSendPrivateMsg'
  131. ]),
  132. /**
  133. * 内嵌房间初始化
  134. */
  135. async initMiniRoom () {
  136. // 初始化postMessage消息管理器
  137. let callback = (event) => {
  138. if (event.action === 'meechat:setShow') {
  139. this.handleToggleChat(event.show)
  140. } else if (event.action === 'meechat:logout') {
  141. this.handleLogout2()
  142. }
  143. }
  144. this.postMessager = new PostMessager('*', { callback })
  145. window.postMessager = this.postMessager
  146. // 设置groupId
  147. this.initGroup({
  148. userId: this.userId,
  149. groupId: this.groupId,
  150. useCache: false
  151. })
  152. // 检查登录态
  153. let userId = localStorage.getItem('user_id')
  154. let token = localStorage.getItem('token')
  155. let account = localStorage.getItem('account')
  156. if (userId && token && account) {
  157. this.setUserId(userId)
  158. this.setToken(token)
  159. this.setAccount(JSON.parse(account))
  160. this.showLoginBtn = false
  161. if (self === top) {
  162. await this.scatterConnect()
  163. }
  164. await this.getUserInfo()
  165. }
  166. this.$nextTick(this.initChat)
  167. this.$nextTick(this.initMiniSocket)
  168. },
  169. async initRoom () {
  170. if (!this.userInfo) {
  171. await this.getUserInfo()
  172. }
  173. if (!this.userInfo) return
  174. this.changeSessionId(this.$route.params.id)
  175. this.clearHash()
  176. this.clearChatList()
  177. this.initState()
  178. if (this.isExist) {
  179. // 把会话列表的消息数设置为0
  180. this.$store.commit('setSessionItemUnread', {
  181. session_id: this.curSession,
  182. unread: 0,
  183. curSession: this.curSession
  184. })
  185. }
  186. if (this.isPrivate) await this.initPersonChat()
  187. else await this.initGroupChat()
  188. },
  189. /**
  190. * @des 私聊初始化处理
  191. */
  192. async initPersonChat () {
  193. let flag = await this.getPrivateNewMsgFromDb()
  194. if (!flag) {
  195. // 如果indexDB没数据时,才需要loading
  196. this.showLoadingRoom(true)
  197. }
  198. let data = await this.getPrivateNewMsg()
  199. this.showLoadingRoom(false)
  200. this.$nextTick(() => {
  201. this.resizeToBottom()
  202. this.bdHiden = false
  203. })
  204. setTimeout(() => {
  205. // 不存在会话,则添加会话
  206. if (!this.isExist) {
  207. // 获取对方信息
  208. let otherInfo = null
  209. for (let key in data.data.userMap) {
  210. if (key != this.userId) {
  211. otherInfo = data.data.userMap[key]
  212. }
  213. }
  214. if (otherInfo) {
  215. let obj = {
  216. cover_photo: otherInfo.cover_photo,
  217. is_group: '0',
  218. name: otherInfo.nick_name,
  219. session_id: this.sessionId
  220. }
  221. this.$store.commit('addSessionItem', obj)
  222. }
  223. }
  224. }, 1000)
  225. return data
  226. },
  227. /**
  228. * @des 聊天群初始化处理
  229. */
  230. async initGroupChat () {
  231. this.initGroup({
  232. userId: this.userId,
  233. groupId: this.sessionId,
  234. useCache: false
  235. })
  236. this.isShowGroudMgr = false
  237. this.getGroupInfo()
  238. let flag = await this.getNewMsgFromDb()
  239. if (!flag) {
  240. // 如果indexDB没数据时,才需要loading
  241. this.showLoadingRoom(true)
  242. }
  243. await this.getNewMsg()
  244. this.showLoadingRoom(false)
  245. this.$nextTick(() => {
  246. this.resizeToBottom()
  247. this.bdHiden = false
  248. lazyloadImage({
  249. wrap: this.$refs.scrollWrap,
  250. imageArr: this.chatImageArrSel,
  251. derection: 'up'
  252. })
  253. })
  254. setTimeout(() => {
  255. // 不存在会话,则添加会话
  256. if (!this.isExist) {
  257. // 获取对方信息
  258. if (this.group) {
  259. let obj = {
  260. cover_photo: this.group.coverPhoto,
  261. is_group: '1',
  262. name: this.group.groupName,
  263. session_id: this.sessionId
  264. }
  265. this.$store.commit('addSessionItem', obj)
  266. }
  267. }
  268. }, 1000)
  269. },
  270. // Mini链接socket
  271. initMiniSocket () {
  272. if (!window.WebSocket) {
  273. console.log('Error: WebSocket is not supported .')
  274. return
  275. }
  276. let host = getMiniWsUrl() + `?group_id=${this.groupId}`
  277. if (this.socket) {
  278. this.socket.destroy()
  279. this.socket = null
  280. }
  281. this.socket = new WsManager(host, {
  282. autoConnect: true, // 自动连接
  283. reconnection: true, // 断开自动重连
  284. reconnectionDelay: 2000 // 重连间隔时间,单位秒
  285. })
  286. this.socket.on('open', res => {})
  287. this.socket.on('message', (data) => {
  288. data = JSON.parse(data)
  289. if (data.channel.match('chat:group')) {
  290. if (data.data.type === 'msg') {
  291. this.getNewMsg({ newMsg: true })
  292. if (data.data.from != this.userId) {
  293. // 未读消息数+1
  294. if (!this.showChat) {
  295. if (this.unreadCounts === 0) {
  296. this.postResize(130, 50)
  297. }
  298. this.unreadCounts++
  299. } else {
  300. this.addUnreadNums()
  301. }
  302. }
  303. }
  304. if (data.data.type === 'repeal') {
  305. this.repealChatItem(data.data)
  306. }
  307. if (data.data.type === 'block') {
  308. this.updateGroupBlockList({
  309. type: 'add',
  310. id: data.data.to
  311. })
  312. }
  313. if (data.data.type === 'unblock') {
  314. this.updateGroupBlockList({
  315. type: 'delete',
  316. id: data.data.to
  317. })
  318. }
  319. if (data.data.type === 'join') {
  320. this.updateMembers(data.data.user_info)
  321. }
  322. if (data.data.type === 'pin_msg') {
  323. this.updateGroupPinMsg(data.data.pinMsg)
  324. }
  325. if (data.data.type === 'unpin_msg') {
  326. this.updateGroupPinMsg(null)
  327. }
  328. if (data.data.type === 'new_redpack') {
  329. this.addPacketItem(data.data)
  330. if (data.data.from == this.userId) {
  331. this.$nextTick(this.resizeToBottom)
  332. }
  333. }
  334. if (data.data.type === 'grab_redpack') {
  335. if (data.data.from == this.userId || data.data.to == this.userId) {
  336. this.addPacketTip(data.data)
  337. }
  338. }
  339. }
  340. })
  341. },
  342. /**
  343. * @des 滚动事件监听
  344. */
  345. initScrollEvent () {},
  346. /**
  347. * @des 聊天窗体滚动事件处理集
  348. */
  349. async handleScroll (e) {
  350. // 防止切换房间时触发滚动处理
  351. if (!this.group.chatList.length) {
  352. return
  353. }
  354. // 防止滚动到置顶消息触发滚动
  355. // if (this.isScrollToView) {
  356. // return
  357. // }
  358. // 激活滚动条
  359. this.enableScroll = true
  360. let totalHeight = this.$refs.msgWrap.offsetHeight - 16
  361. let scrollTop = e.target.scrollTop
  362. // 差不多滚动到顶部
  363. if (scrollTop == 0 && !this.lockMore) {
  364. if (this.group.endHash !== null) {
  365. this.lockMore = true
  366. let res
  367. if (this.isPrivate) {
  368. res = await this.getPrivateHistoryMsg()
  369. } else {
  370. res = await this.getHistoryMsg()
  371. }
  372. if (res === 'end') {
  373. this.lockEnd = true
  374. } else {
  375. let scrollBottom = totalHeight - scrollTop
  376. this.$nextTick(() => {
  377. e.target.scrollTop =
  378. this.$refs.msgWrap.offsetHeight - scrollBottom
  379. setTimeout(() => {
  380. this.lockMore = false
  381. }, 800)
  382. })
  383. }
  384. }
  385. }
  386. // 滚动到底部清空未读消息状态
  387. if (scrollTop + e.target.offsetHeight > totalHeight) {
  388. this.isBottom = true
  389. if (this.group.unreadNums) {
  390. this.resetUnreadNums()
  391. }
  392. } else {
  393. this.isBottom = false
  394. }
  395. lazyloadImage({
  396. wrap: this.$refs.scrollWrap,
  397. imageArr: this.chatImageArrSel,
  398. derection: 'up'
  399. })
  400. },
  401. /**
  402. * @des 聊天窗体滚动到底部
  403. */
  404. resizeToBottom () {
  405. if (!this.$refs.msgWrap) return
  406. this.$refs.msgWrap.style.height = 'auto'
  407. this.$refs.scrollWrap.scrollTop = this.$refs.msgWrap.offsetHeight
  408. this.resetUnreadNums()
  409. lazyloadImage({
  410. wrap: this.$refs.scrollWrap,
  411. imageArr: this.chatImageArrSel,
  412. derection: 'up'
  413. }, 200)
  414. },
  415. /**
  416. * @des 点击,查看未读消息
  417. * 直接滚动到聊天列表底部
  418. */
  419. doSetRead () {
  420. this.resizeToBottom()
  421. },
  422. /**
  423. * @des 引用某条消息
  424. */
  425. quoteMsg (msg) {
  426. this.$refs.inputArea.inputMsg = msg
  427. },
  428. /**
  429. * @des 某条消息被删除
  430. */
  431. deleteMsg (hash) {
  432. this.deleteChatItem(hash)
  433. },
  434. pinMsgClose () {
  435. this.pinMsg.visible = false
  436. },
  437. scrollToView () {
  438. if (!this.pinMsg) return
  439. let hash = this.pinMsg.hash
  440. let index = this.group.chatList.findIndex(item => item.hash === hash)
  441. if (index < 0) {
  442. this.addPinChatItem(this.pinMsg)
  443. index = 0
  444. }
  445. let node = this.$refs.msgWrap.getElementsByClassName('msg-item')[index]
  446. let toOffsetTop = index >= 0 ? node.offsetTop : node.offsetTop
  447. let lazy = function () {
  448. lazyloadImage({
  449. wrap: this.$refs.scrollWrap,
  450. imageArr: this.chatImageArrSel,
  451. derection: 'up'
  452. })
  453. }
  454. scrollMsgIntoView(
  455. this.$refs.scrollWrap, toOffsetTop, node, lazy.bind(this)
  456. )
  457. // 防止加载更多
  458. this.isScrollToView = true
  459. setTimeout(() => {
  460. this.isScrollToView = false
  461. }, 2000)
  462. },
  463. scrollToMsg (index) {
  464. let hash = this.atList[index].hash
  465. let eleIndex = this.group.chatList.findIndex(item => item.hash === hash)
  466. if (eleIndex >= 0) {
  467. let node = this.$refs.msgWrap.getElementsByClassName('msg-item').item(eleIndex)
  468. scrollMsgIntoView(
  469. this.$refs.scrollWrap,
  470. node.offsetTop - (this.pinMsg ? 40 : 10),
  471. node
  472. )
  473. }
  474. this.clearAtList()
  475. },
  476. async joinGroup () {
  477. this.showLoadingRoom(true)
  478. await this.$store.dispatch('joinGroup')
  479. this.showLoadingRoom(false)
  480. },
  481. // 群管理
  482. showGroudMgr (flag) {
  483. this.isShowGroudMgr = flag == 1
  484. },
  485. // 关闭表情,文件栏
  486. initEmojiAndTool () {
  487. this.emojiShow = false
  488. this.toolShow = false
  489. },
  490. showLoadingRoom (flag) {
  491. this.isLoadingRoom = flag
  492. }
  493. },
  494. beforeDestroy () {
  495. document.body.removeEventListener('click', this.initEmojiAndTool)
  496. }
  497. }
  498. // 聊天输入框mixin
  499. export const inputMixin = {
  500. computed: {
  501. ...mapState(['group', 'userId']),
  502. ...mapState({
  503. chatInputFocus: state => state.group.chatInputFocus,
  504. blockList: state => state.group.blockList
  505. }),
  506. isPrivate () {
  507. return this.$store.getters.isPrivate
  508. },
  509. emojiMap () {
  510. var emojiMap = {}
  511. for (let i in emojiList) {
  512. let arr = emojiList[i]
  513. arr.forEach(v => {
  514. let names = JSON.stringify(v.names)
  515. let emoji = v.surrogates
  516. emojiMap[names] = emoji
  517. })
  518. }
  519. return emojiMap
  520. }
  521. },
  522. data () {
  523. return {
  524. filePreviewShow: false, // 是否显示文件预览
  525. emojiShow: false, // 是否显示emoji
  526. fileInfo: null, // 当前上传文件
  527. inputMsg: '',
  528. atInd: 0,
  529. meechatType: getMeechatType()
  530. }
  531. },
  532. mounted () {
  533. },
  534. methods: {
  535. ...mapMutations(['updateChatInputFocus', 'addChatItem']),
  536. ...mapActions(['doSendMsg', 'doSendFile', 'doSendPrivateMsg']),
  537. addEmoji (val) {
  538. this.inputMsg += val
  539. this.emojiShow = false
  540. this.$refs.chatInput.focus()
  541. },
  542. closeFilePreview () {
  543. this.fileInfo = null
  544. this.filePreviewShow = false
  545. this.emptyFileForm()
  546. },
  547. showFilePreview (fileInfo) {
  548. if (!fileInfo) return
  549. this.fileInfo = fileInfo
  550. this.filePreviewShow = true
  551. },
  552. /**
  553. * @des 处理消息发送
  554. */
  555. handleInput () {
  556. this.inputMsg = this.inputMsg.substring(0, 5000)
  557. },
  558. /**
  559. * @des 处理消息发送
  560. */
  561. async handleSend (e) {
  562. // 判断是否被禁言
  563. if (this.blockList.some(id => id == this.userId)) {
  564. Message({
  565. message: '您已被禁言',
  566. type: 'error'
  567. })
  568. return
  569. }
  570. // 替换emoji字符串
  571. let _inputMsg = this.inputMsg
  572. let parts = _inputMsg.match(/\["[a-z0-9A-Z_]+"\]/g)
  573. for (let k in parts) {
  574. let emoji = this.emojiMap[parts[k]]
  575. if (emoji) {
  576. _inputMsg = _inputMsg.replace(parts[k], emoji)
  577. }
  578. }
  579. let text = _inputMsg.trim().substring(0, 5000)
  580. if (text.length === 0) {
  581. Message({
  582. message: '聊天内容不能为空',
  583. type: 'warning'
  584. })
  585. return
  586. }
  587. let opt = {
  588. type: 0,
  589. msg: text
  590. }
  591. // 用户不是第一次发言
  592. if (this.group.members[this.userId]) {
  593. let createTime = Date.now()
  594. this.addChatItem({
  595. from: this.userId,
  596. content: text,
  597. hash: `${createTime}`,
  598. timestamp: createTime,
  599. createTime,
  600. msg_type: '0',
  601. loading: true
  602. })
  603. opt.createTime = createTime
  604. }
  605. this.inputMsg = ''
  606. let data = this.isPrivate ? await this.doSendPrivateMsg(opt) : await this.doSendMsg(opt)
  607. // // 发送成功后,才加
  608. this.$store.commit('setSessionItemUnread', {
  609. session_id: this.curSession,
  610. unread: 0,
  611. curSession: this.curSession,
  612. cont: text,
  613. timestamp: data.timestamp
  614. })
  615. // 滚到底部
  616. this.$nextTick(function () {
  617. this.resizeToBottom ? this.resizeToBottom() : this.$emit('toBottom')
  618. lazyloadImage({
  619. wrap: this.$refs.scrollWrap,
  620. imageArr: this.chatImageArrSel,
  621. derection: 'up'
  622. })
  623. })
  624. e.preventDefault()
  625. return false
  626. },
  627. /**
  628. * 文件预处理
  629. * @return {Object} data 预处理文件信息
  630. * @param {Number} data.type
  631. * @param {File} data.res
  632. */
  633. async preHandleFile (file) {
  634. let type = file.type
  635. let size = file.size
  636. if (type.match('video')) {
  637. return size > 3 * 1024 * 1024
  638. ? Promise.reject(new Error(file))
  639. : Promise.resolve({
  640. type: 2,
  641. res: file,
  642. preview: window.webkitURL.createObjectURL(file)
  643. })
  644. } else if (type.match('audio')) {
  645. return size > 2 * 1024 * 1024
  646. ? Promise.reject(new Error(file))
  647. : Promise.resolve({
  648. type: 3,
  649. res: file,
  650. preview: window.webkitURL.createObjectURL(file)
  651. })
  652. } else if (type.match('image')) {
  653. let image = await new ImageMin({
  654. file: file,
  655. maxSize: 1024 * 1024
  656. })
  657. return {
  658. type: 1,
  659. preview: image.base64,
  660. res: image.res
  661. }
  662. }
  663. },
  664. /**
  665. * @des 处理文件发送
  666. */
  667. async handleFile (e) {
  668. let inputfile
  669. if (e.constructor === File) {
  670. inputfile = e
  671. } else {
  672. inputfile = e.target.files[0]
  673. }
  674. try {
  675. let fileInfo = await this.preHandleFile(inputfile)
  676. if (this.meechatType == 'pc') this.showFilePreview(fileInfo)
  677. else this.handleFileSend(fileInfo)
  678. } catch (error) {
  679. Message({
  680. message: '上传文件大小限制:音频2M以内,视频3M以内',
  681. type: 'warning'
  682. })
  683. }
  684. },
  685. // 发送文件消息
  686. handleFileSend (fileInfo) {
  687. this.filePreviewShow = false
  688. let opt = { res: fileInfo.res }
  689. let createTime = Date.now()
  690. this.addChatItem({
  691. content: fileInfo.preview || '',
  692. from: this.userId,
  693. hash: `${createTime}`,
  694. msg_type: fileInfo.type,
  695. timestamp: createTime,
  696. res: fileInfo.res,
  697. loading: true,
  698. createTime
  699. })
  700. opt.createTime = createTime
  701. this.doSendFile(opt)
  702. setTimeout(() => {
  703. this.emptyFileForm()
  704. this.$refs.toolbar && this.$refs.toolbar.resetInput()
  705. this.resizeToBottom ? this.resizeToBottom() : this.$emit('toBottom')
  706. }, 100)
  707. },
  708. // 初始文件表单
  709. emptyFileForm () {
  710. if (this.$refs.inputFile) {
  711. this.$refs.inputFile.value = null
  712. }
  713. if (this.$refs.inputFile1) {
  714. this.$refs.inputFile1.value = null
  715. }
  716. if (this.$refs.inputFile2) {
  717. this.$refs.inputFile2.value = null
  718. }
  719. if (this.$refs.inputFile3) {
  720. this.$refs.inputFile3.value = null
  721. }
  722. }
  723. }
  724. }