ProgressPage.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div v-show="visible" class="fit column justify-center items-center z-max" style="background-color: rgba(0, 0, 0, 0.8)">
  3. <div class="column justify-start items-center" style="height: 250px">
  4. <q-circular-progress
  5. show-value
  6. instant-feedback
  7. font-size="13px"
  8. :value="percentage"
  9. size="100px"
  10. :thickness="0.11"
  11. color="green-7"
  12. track-color="grey-4"
  13. class="q-ma-md"
  14. >
  15. <span class="text-yellow">{{ percentage }}%</span>
  16. </q-circular-progress>
  17. <p class="text-yellow">{{ text }}</p>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. //-----------------------------------------------------------------------------
  23. import Vue from 'vue';
  24. import Component from 'vue-class-component';
  25. const ruMessage = {
  26. 'start': ' ',
  27. 'finish': ' ',
  28. 'error': ' ',
  29. 'queue': 'очередь',
  30. 'download': 'скачивание',
  31. 'decompress': 'распаковка',
  32. 'convert': 'конвертирование',
  33. 'loading': 'загрузка',
  34. 'parse': 'обработка',
  35. 'upload': 'отправка',
  36. };
  37. export default @Component({
  38. })
  39. class ProgressPage extends Vue {
  40. text = '';
  41. totalSteps = 1;
  42. step = 1;
  43. progress = 0;
  44. visible = false;
  45. show() {
  46. this.text = '';
  47. this.totalSteps = 1;
  48. this.step = 1;
  49. this.progress = 0;
  50. this.visible = true;
  51. }
  52. hide() {
  53. this.visible = false;
  54. this.text = '';
  55. }
  56. setState(state) {
  57. if (state.state) {
  58. if (state.state == 'queue') {
  59. this.text = (state.place ? 'Номер в очереди: ' + state.place : '');
  60. } else {
  61. this.text = (ruMessage[state.state] ? ruMessage[state.state] : state.state);
  62. }
  63. }
  64. this.step = (state.step ? state.step : this.step);
  65. this.totalSteps = (state.totalSteps > this.totalSteps ? state.totalSteps : this.totalSteps);
  66. this.progress = state.progress || 0;
  67. }
  68. get percentage() {
  69. return Math.round(((this.step - 1)/this.totalSteps + this.progress/(100*this.totalSteps))*100);
  70. }
  71. }
  72. //-----------------------------------------------------------------------------
  73. </script>