You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

291 lines
8.9 KiB

2 years ago
2 years ago
2 years ago
  1. <template>
  2. <modal name="UploadRemittanceSlip" :clickToClose="false">
  3. <div class="tw-text-base-primary">
  4. <div v-if="choose == false">
  5. <div>
  6. <div class="modal-header tw-flex tw-w-full tw-mb-[10px]">
  7. <div class="t18 tw-font-bold tw-mt-[15px] tw-flex tw-w-full justify-center lg:t28 lg:tw-font-bold">
  8. {{ $t('Upload your file') }}
  9. </div>
  10. <button class="close tw-transition tw-btn-md" @click="$modal.hide('UploadRemittanceSlip')"></button>
  11. </div>
  12. <div class="t14 tw-flex tw-justify-center tw-text-base-tertiary tw-mb-[20px] lg:tw-body-2 lg:tw-mb-[40px]">
  13. {{ $t('JPG, PNG, PDF are allowed') }}
  14. </div>
  15. <div class="modal-content">
  16. <button
  17. class="tw-flex tw-flex-col tw-items-center tw-bg-neutrals-0 tw-border tw-border-dashed tw-border-neutrals-800 tw-rounded-[16px] tw-w-full"
  18. @click="handleUploadEvent">
  19. <img src="~/assets/svg/uploadImg.svg" class="tw-mb-[15px] tw-mt-[23px] mb:tw-mb-[23px] mb:tw-mb-[35px]"
  20. alt="" />
  21. <div class="t14 tw-text-base-tertiary tw-whitespace-nowrap tw-mb-[10px] tw-mx-[10px] lg:tw-body-2">
  22. {{ $t('Drag and drop or browse to choose a file') }}
  23. </div>
  24. <div class="tw-body-5 tw-text-base-tertiary tw-mb-[20px] lg:tw-body-3 lg:tw-mb-[40px]">
  25. {{ $t('"Upload up to 1 file"') }}
  26. </div>
  27. <input type="file" class="d-none" ref="uploader" @change="UploadEvent" />
  28. </button>
  29. </div>
  30. </div>
  31. </div>
  32. <div v-if="success == true">
  33. <div class="modal-header tw-flex tw-mb-[20px]">
  34. <div class="tw-mt-[15px] tw-flex tw-w-full tw-flex-col tw-items-center">
  35. <img src="~/assets/svg/White.svg" class="tw-mb-[10px] tw-h-[36px] tw-w-[36px]" />
  36. <div class="t18 tw-font-bold lg:t28">{{ $t('Upload Successfully') }}</div>
  37. </div>
  38. <button class="close tw-transition tw-btn-md" @click="hideUploadRemittanceSlip"></button>
  39. </div>
  40. <div class="modal-content t12 tw-text-neutrals-800">
  41. <div class="tw-flex tw-mb-[10px] tw-w-full tw-justify-between lg:tw-body-2">
  42. <div>{{ $t('1 of 1 uploaded') }}</div>
  43. <button @click="cancelUpload">{{ $t('Cancel') }}</button>
  44. </div>
  45. <div class="tw-flex tw-bg-neutrals-0 tw-rounded-[10px]">
  46. <div
  47. class="t12 tw-flex tw-justify-between tw-items-center tw-break-words tw-text-neutrals-800 tw-w-full lg:t16">
  48. <div class="tw-mr-[66px] tw-relative tw-z-[2] tw-pl-[20px] tw-py-[4px]">
  49. <div class="tw-max-w-[170px] tw-whitespace-normal">
  50. {{ $t(this.filename) }}
  51. </div>
  52. <div>{{ $t(this.size) }} KB</div>
  53. </div>
  54. <div class="tw-z-[2] tw-mr-[10px]">
  55. <img src="~/assets/svg/UploadSuccessful.svg" />
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div v-if="upload == true">
  62. <div class="modal-header tw-flex tw-w-full tw-mb-[10px]">
  63. <div
  64. class="t18 tw-font-bold tw-mt-[15px] tw-mb-[20px] tw-flex tw-w-full justify-center lg:t28 lg:tw-font-bold">
  65. {{ $t('Uploading ...') }}
  66. </div>
  67. <button class="close tw-transition tw-btn-md" @click="$modal.hide('UploadRemittanceSlip')"></button>
  68. </div>
  69. <div class="modal-content t12 tw-text-neutrals-800">
  70. <div class="tw-flex tw-mb-[10px] tw-w-full tw-justify-between lg:tw-body-2">
  71. <div>{{ $t('1 of 1 uploaded') }}</div>
  72. <button>{{ $t('Cancel') }}</button>
  73. </div>
  74. <div class="t12 tw-flex tw-relative tw-justify-between tw-items-center tw-break-words tw-text-white lg:t16">
  75. <div class="tw-mr-[66px] tw-relative tw-z-[2] tw-pl-[20px] tw-py-[4px]">
  76. <div class="tw-max-w-[170px] tw-whitespace-normal">
  77. {{ $t(this.filename) }}
  78. </div>
  79. <div>{{ $t(this.size) }} KB</div>
  80. </div>
  81. <div class="tw-z-[2] tw-mr-[10px]">
  82. <img src="~/assets/svg/Cancel.svg" />
  83. </div>
  84. <progress max="100" :value.prop="uploadPercentage"
  85. class="tw-absolute tw-left-0 tw-top-0 tw-w-full tw-z-[1] tw-h-full"></progress>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </modal>
  91. </template>
  92. <script>
  93. export default {
  94. name: "UploadRemittanceSlip",
  95. data() {
  96. return {
  97. uploaded: null,
  98. choose: false,
  99. success: false,
  100. upload: false,
  101. uploadPercentage: 0,
  102. filename: "",
  103. size: "",
  104. };
  105. },
  106. methods: {
  107. handleUploadEvent() {
  108. window.addEventListener("focus", () => {}, { once: true });
  109. this.$refs.uploader.click();
  110. },
  111. UploadEvent(e) {
  112. this.choose = true;
  113. this.upload = true;
  114. this.uploaded = new FormData();
  115. this.uploaded.append("file", e.target.files[0]);
  116. console.log(e.target.files[0]);
  117. this.uploaded.append("bucket", "media-showeasy-com");
  118. this.uploaded.append("bucket_path", "users");
  119. this.filename = e.target.files[0].name;
  120. this.size = Math.ceil(e.target.files[0].size / 1000);
  121. console.log(this.filename);
  122. console.log(this.size);
  123. this.$axios
  124. .post(
  125. `/trending/api/BookingOnline/UploadRemittance?BookingID=${this.BookingID}`, this.uploaded ,{
  126. onUploadProgress: function (progressEvent) {
  127. this.uploadPercentage = parseInt(
  128. Math.round((progressEvent.loaded / progressEvent.total) * 100)
  129. );
  130. }.bind(this),
  131. })
  132. .then((response) => {
  133. console.log(JSON.stringify(response))
  134. if(response && response.data){
  135. this.upload = false;
  136. this.success = true;
  137. }
  138. })
  139. .catch((error) => {
  140. console.log(error);
  141. });
  142. // this.$axios
  143. // .post("/s3/upload", this.uploaded, {
  144. // onUploadProgress: function (progressEvent) {
  145. // this.uploadPercentage = parseInt(
  146. // Math.round((progressEvent.loaded / progressEvent.total) * 100)
  147. // );
  148. // }.bind(this),
  149. // })
  150. // .then((response) => {
  151. // console.log(response.status);
  152. // if (response.status == 200) {
  153. // this.upload = false;
  154. // this.success = true;
  155. // }
  156. // })
  157. // .catch((error) => console.log(error));
  158. },
  159. hideUploadRemittanceSlip() {
  160. this.$modal.hide("UploadRemittanceSlip");
  161. this.success = false;
  162. this.choose = false;
  163. this.upload = false;
  164. },
  165. cancelUpload() {},
  166. },
  167. };
  168. </script>
  169. <style lang="scss" scoped>
  170. .close {
  171. position: absolute;
  172. right: 25px;
  173. top: 25px;
  174. background-image: url("~/assets/svg/close.svg");
  175. background-position: center;
  176. background-repeat: no-repeat;
  177. background-size: cover;
  178. width: 14px;
  179. height: 14px;
  180. @media (min-width: 1366px) {
  181. position: relative;
  182. right: initial;
  183. top: initial;
  184. }
  185. }
  186. progress[value] {
  187. -webkit-appearance: none;
  188. appearance: none;
  189. // width: 290px;
  190. // height: 40px;
  191. }
  192. progress[value]::-webkit-progress-bar {
  193. background-color: #f8f8f8;
  194. border-radius: 16px;
  195. }
  196. progress[value]::-webkit-progress-value {
  197. background-color: #f48800;
  198. border-radius: 16px;
  199. background-size: 35px 20px, 100% 100%, 100% 100%;
  200. }
  201. @-webkit-keyframes animate-stripes {
  202. 100% {
  203. background-position: -100px 0px;
  204. -webkit-animation: animate-stripes 5s linear infinite;
  205. animation: animate-stripes 5s linear infinite;
  206. }
  207. }
  208. @keyframes animate-stripes {
  209. 100% {
  210. background-position: -100px 0px;
  211. -webkit-animation: animate-stripes 5s linear infinite;
  212. animation: animate-stripes 5s linear infinite;
  213. }
  214. }
  215. :deep() {
  216. .v--modal {
  217. background-color: white !important;
  218. text-align: left;
  219. border-radius: 16px;
  220. box-shadow: 0 20px 60px -2px rgb(27 33 58 / 40%);
  221. padding: 20px;
  222. max-width: 100%;
  223. top: 0 !important;
  224. left: 0 !important;
  225. right: 0 !important;
  226. margin: 0 auto;
  227. height: auto !important;
  228. vertical-align: middle;
  229. @media screen and (min-width: 768px) {
  230. padding: 20px;
  231. }
  232. @media screen and (min-width: 1024px) {
  233. padding: 40px;
  234. }
  235. }
  236. .v--modal-overlay {
  237. position: fixed;
  238. box-sizing: border-box;
  239. left: 0;
  240. top: 0;
  241. width: max-content;
  242. height: auto;
  243. background: rgba(0, 0, 0, 0.2);
  244. z-index: 999;
  245. opacity: 1;
  246. }
  247. .v--modal-top-right {
  248. display: block;
  249. position: fixed;
  250. right: 0;
  251. top: 0;
  252. }
  253. .v--modal-background-click {
  254. display: flex;
  255. justify-content: center;
  256. align-items: center;
  257. }
  258. .v--modal-box {
  259. margin-left: 30px;
  260. margin-right: 30px;
  261. @media (min-width: 768px) {
  262. margin-left: 67px;
  263. margin-right: 67px;
  264. }
  265. }
  266. }
  267. </style>