NewProduct.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div style="height: 100vh; width: 100vw">
  3. <span>{{ texts.new_instruction }}</span>
  4. <div ref="webcam_placeholder" style="height: 50vh">
  5. <webcam :maxres="maxres" @ready="webcam_ready=false" ref="webcam" :height="webcam_height" style=""/>
  6. </div>
  7. <div class="row" style="height: 10vh">
  8. <q-btn :loading="webcam_ready" @click="capture">{{ texts.new_snap}}</q-btn>
  9. <q-btn :disabled="imgs.length==0" @click="save()">{{ texts.new_done }}</q-btn>
  10. </div>
  11. <div class="row" style="flex-wrap:nowrap; overflow-y: auto; width:90vw; max-height: 15vh">
  12. <q-item round v-for="img in imgs"style="display: inline-flex">
  13. <q-btn @click="delete_image(img)"><q-icon style="position: absolute" mat="clear"/></q-btn>
  14. <img :src="img" style="max-height:10vh"/>
  15. </q-item>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import Webcam from '../components/webcam'
  21. var api = require('../api.js')
  22. var utils = require('../utils.js')
  23. import {
  24. QCard,
  25. QLayout,
  26. QToolbar,
  27. QToolbarTitle,
  28. QBtn,
  29. QIcon,
  30. QList,
  31. QListHeader,
  32. QItem,
  33. QItemSide,
  34. QItemMain
  35. } from 'quasar'
  36. export default {
  37. name: 'index',
  38. components: {
  39. QCard,
  40. QLayout,
  41. QToolbar,
  42. QToolbarTitle,
  43. QBtn,
  44. QIcon,
  45. QList,
  46. QListHeader,
  47. QItem,
  48. QItemSide,
  49. Webcam,
  50. QItemMain
  51. },
  52. data () {
  53. return {
  54. products: [
  55. {name: 'hello'}
  56. ],
  57. api: api,
  58. imgs: [],
  59. texts: '',
  60. webcam_height: 0,
  61. webcam_ready: true,
  62. maxres: 25600
  63. }
  64. },
  65. methods: {
  66. capture: function () {
  67. this.imgs.push(this.$refs.webcam.capture())
  68. },
  69. delete_image: function (img) {
  70. this.imgs.pop(img)
  71. },
  72. save: function () {
  73. var self = this
  74. window.images = self.imgs
  75. this.$refs.webcam.stop()
  76. self.$router.push('save')
  77. }
  78. },
  79. mounted () {
  80. window.p = this
  81. utils.setTexts(this)
  82. this.webcam_height = this.$refs.webcam_placeholder.clientHeight - 50
  83. },
  84. beforeDestroy () {
  85. }
  86. }
  87. </script>
  88. <style lang="stylus" scoped>
  89. div
  90. display: flex
  91. flex-direction: column
  92. align-items: center
  93. .row
  94. flex-direction: row
  95. </style>