ProgressPage.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div v-show="visible" class="main">
  3. <div class="center">
  4. <!--el-progress type="circle" :width="100" :stroke-width="6" color="#0F9900" :percentage="percentage"></el-progress-->
  5. <q-circular-progress
  6. show-value
  7. instant-feedback
  8. font-size="14px"
  9. :value="percentage"
  10. size="100px"
  11. :thickness="0.12"
  12. color="green-7"
  13. track-color="grey-4"
  14. class="q-ma-md"
  15. >
  16. {{ percentage }}%
  17. </q-circular-progress>
  18. <p class="text">{{ text }}</p>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. //-----------------------------------------------------------------------------
  24. import Vue from 'vue';
  25. import Component from 'vue-class-component';
  26. const ruMessage = {
  27. 'start': ' ',
  28. 'finish': ' ',
  29. 'error': ' ',
  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.$el.style.width = this.$parent.$el.offsetWidth + 'px';
  47. this.$el.style.height = this.$parent.$el.offsetHeight + 'px';
  48. this.text = '';
  49. this.totalSteps = 1;
  50. this.step = 1;
  51. this.progress = 0;
  52. this.visible = true;
  53. }
  54. hide() {
  55. this.visible = false;
  56. }
  57. setState(state) {
  58. if (state.state)
  59. this.text = (ruMessage[state.state] ? ruMessage[state.state] : state.state);
  60. this.step = (state.step ? state.step : this.step);
  61. this.totalSteps = (state.totalSteps > this.totalSteps ? state.totalSteps : this.totalSteps);
  62. this.progress = state.progress || 0;
  63. }
  64. get percentage() {
  65. let circle = document.querySelector('path[class="el-progress-circle__path"]');
  66. if (circle)
  67. circle.style.transition = '';
  68. return Math.round(((this.step - 1)/this.totalSteps + this.progress/(100*this.totalSteps))*100);
  69. }
  70. }
  71. //-----------------------------------------------------------------------------
  72. </script>
  73. <style scoped>
  74. .main {
  75. display: flex;
  76. flex-direction: column;
  77. justify-content: center;
  78. align-items: center;
  79. z-index: 100;
  80. background-color: rgba(0, 0, 0, 0.8);
  81. position: absolute;
  82. }
  83. .center {
  84. display: flex;
  85. flex-direction: column;
  86. justify-content: flex-start;
  87. align-items: center;
  88. color: white;
  89. height: 250px;
  90. }
  91. .text {
  92. color: yellow;
  93. }
  94. </style>
  95. <style>
  96. .el-progress__text {
  97. color: lightgreen !important;
  98. }
  99. </style>