WebSocketImage.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <div>
  3. <WebSocketCapture ref="webSocketCapture" :multiple="multiple" />
  4. <div style="height:5px" />
  5. <button class="btn btn-success" type="button" style="width:100%" @click="imageUpload">
  6. {{ $t('lang.webSocketImage.uploadImage') }}
  7. </button>
  8. </div>
  9. </template>
  10. <script>
  11. import Common from '../common/Common.js';
  12. import WebSocketCapture from '../widget/WebSocketCapture.vue';
  13. import { Notify, Uuid } from 'pc-component-v3';
  14. export default {
  15. components: {
  16. WebSocketCapture,
  17. },
  18. props: {
  19. /**
  20. * 可以抓拍多张图片
  21. */
  22. 'multiple' : {
  23. type: Boolean,
  24. default: null,
  25. },
  26. }
  27. ,
  28. data: function () {
  29. return {
  30. };
  31. },
  32. methods: {
  33. /**
  34. * 上传图片
  35. */
  36. imageUpload: function () {
  37. var _self = this;
  38. var imageSrcs = _self.$refs.webSocketCapture.imageSrcs;
  39. if (imageSrcs && imageSrcs.length == 0) {
  40. Notify.error('提示', '没有图片',false);
  41. return;
  42. }
  43. if(_self.multiple == true){
  44. _self.$emit('uploadImage', imageSrcs);
  45. }else{
  46. var imageSrc = imageSrcs[0];
  47. _self.$emit('uploadImage', imageSrc);
  48. }
  49. },
  50. },
  51. };
  52. </script>
  53. <style scoped>
  54. </style>