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.

285 lines
8.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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. props:{
  107. uploadBookingID:{
  108. type: String,
  109. }
  110. },
  111. methods: {
  112. handleUploadEvent() {
  113. window.addEventListener("focus", () => {}, { once: true });
  114. this.$refs.uploader.click();
  115. },
  116. UploadEvent(e) {
  117. this.choose = true;
  118. this.upload = true;
  119. this.uploaded = new FormData();
  120. this.uploaded.append("file", e.target.files[0]);
  121. this.size = Math.ceil(e.target.files[0].size / 1000);
  122. this.$axios
  123. .post(
  124. `/trending/api/BookingOnline/UploadRemittance?BookingID=${this.uploadBookingID}`, this.uploaded)
  125. .then((response) => {
  126. //console.log(JSON.stringify(response))
  127. if(response && response.data){
  128. this.upload = false;
  129. this.success = true;
  130. this.$emit('reload-BookingContent');
  131. }
  132. })
  133. .catch((error) => {
  134. console.log(error);
  135. });
  136. // this.$axios
  137. // .post("/s3/upload", this.uploaded, {
  138. // onUploadProgress: function (progressEvent) {
  139. // this.uploadPercentage = parseInt(
  140. // Math.round((progressEvent.loaded / progressEvent.total) * 100)
  141. // );
  142. // }.bind(this),
  143. // })
  144. // .then((response) => {
  145. // console.log(response.status);
  146. // if (response.status == 200) {
  147. // this.upload = false;
  148. // this.success = true;
  149. // }
  150. // })
  151. // .catch((error) => console.log(error));
  152. },
  153. hideUploadRemittanceSlip() {
  154. this.$modal.hide("UploadRemittanceSlip");
  155. this.success = false;
  156. this.choose = false;
  157. this.upload = false;
  158. },
  159. cancelUpload() {},
  160. },
  161. };
  162. </script>
  163. <style lang="scss" scoped>
  164. .close {
  165. position: absolute;
  166. right: 25px;
  167. top: 25px;
  168. background-image: url("~/assets/svg/close.svg");
  169. background-position: center;
  170. background-repeat: no-repeat;
  171. background-size: cover;
  172. width: 14px;
  173. height: 14px;
  174. @media (min-width: 1366px) {
  175. position: relative;
  176. right: initial;
  177. top: initial;
  178. }
  179. }
  180. progress[value] {
  181. -webkit-appearance: none;
  182. appearance: none;
  183. // width: 290px;
  184. // height: 40px;
  185. }
  186. progress[value]::-webkit-progress-bar {
  187. background-color: #f8f8f8;
  188. border-radius: 16px;
  189. }
  190. progress[value]::-webkit-progress-value {
  191. background-color: #f48800;
  192. border-radius: 16px;
  193. background-size: 35px 20px, 100% 100%, 100% 100%;
  194. }
  195. @-webkit-keyframes animate-stripes {
  196. 100% {
  197. background-position: -100px 0px;
  198. -webkit-animation: animate-stripes 5s linear infinite;
  199. animation: animate-stripes 5s linear infinite;
  200. }
  201. }
  202. @keyframes animate-stripes {
  203. 100% {
  204. background-position: -100px 0px;
  205. -webkit-animation: animate-stripes 5s linear infinite;
  206. animation: animate-stripes 5s linear infinite;
  207. }
  208. }
  209. :deep() {
  210. .v--modal {
  211. background-color: white !important;
  212. text-align: left;
  213. border-radius: 16px;
  214. box-shadow: 0 20px 60px -2px rgb(27 33 58 / 40%);
  215. padding: 20px;
  216. max-width: 100%;
  217. top: 0 !important;
  218. left: 0 !important;
  219. right: 0 !important;
  220. margin: 0 auto;
  221. height: auto !important;
  222. vertical-align: middle;
  223. @media screen and (min-width: 768px) {
  224. padding: 20px;
  225. }
  226. @media screen and (min-width: 1024px) {
  227. padding: 40px;
  228. }
  229. }
  230. .v--modal-overlay {
  231. position: fixed;
  232. box-sizing: border-box;
  233. left: 0;
  234. top: 0;
  235. width: max-content;
  236. height: auto;
  237. background: rgba(0, 0, 0, 0.2);
  238. z-index: 999;
  239. opacity: 1;
  240. }
  241. .v--modal-top-right {
  242. display: block;
  243. position: fixed;
  244. right: 0;
  245. top: 0;
  246. }
  247. .v--modal-background-click {
  248. display: flex;
  249. justify-content: center;
  250. align-items: center;
  251. }
  252. .v--modal-box {
  253. margin-left: 30px;
  254. margin-right: 30px;
  255. @media (min-width: 768px) {
  256. margin-left: 67px;
  257. margin-right: 67px;
  258. }
  259. }
  260. }
  261. </style>