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.

186 lines
5.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="group tw-mb-[20px]">
  3. <div class="element tw-grid tw-grid-cols-1 md:tw-grid-cols-[166px_auto_auto] xl:tw-grid-cols-[166px_auto_auto] tw-gap-[10px]">
  4. <div class="tw-flex tw-items-center">
  5. <label class="tw-mb-[10px] tw-font-normal t14 md:t16">
  6. <span>{{ $t("Select an extension")}}</span>
  7. </label>
  8. </div>
  9. <elementSelectNew
  10. :select="{
  11. id: 'SelectYear',
  12. label: '',
  13. required: true,
  14. }"
  15. :isRow="true"
  16. :itemsCenter="true"
  17. :labelWidth="0"
  18. :selectWidth="200"
  19. :selectList="selectYearList"
  20. :default="formData.select_year"
  21. :validation="validation.select_year"
  22. @change="selectYear($event)"
  23. ></elementSelectNew>
  24. <elementSelectNew
  25. :select="{
  26. id: 'selectMonth',
  27. label: '',
  28. required: false,
  29. }"
  30. :isRow="true"
  31. :itemsCenter="true"
  32. :labelWidth="0"
  33. :selectWidth="200"
  34. :selectList="selectMonthList"
  35. :default="formData.select_month"
  36. :validation="validation.select_month"
  37. @change="selectMonth($event)"
  38. ></elementSelectNew>
  39. </div>
  40. <div class="element tw-mt-[20px] tw-grid tw-grid-cols-1 md:tw-grid-cols-[166px_auto] xl:tw-grid-cols-[166px_auto] tw-gap-[10px]">
  41. <div class="tw-flex tw-items-center">
  42. <label class="tw-mb-[10px] tw-font-normal t14 md:t16">
  43. <span>{{ $t("Exhibition Name")}}</span><span class="required t12 md:t14">*</span>
  44. </label>
  45. </div>
  46. <elementSelectNew
  47. :select="{
  48. id: 'ExhibitionName',
  49. label: 'Exhibition Name',
  50. required: true,
  51. }"
  52. :isRow="true"
  53. :itemsCenter="true"
  54. :labelWidth="0"
  55. :selectWidth="200"
  56. :selectList="selectExhibitionList"
  57. :default="formData.exhibition_name"
  58. :validation="validation.exhibition_name"
  59. @change="selectExhibition($event)"
  60. ></elementSelectNew>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import elementSelectNew from "@/components/newComponent/form/ElementSelectNew";
  66. import is from "is_js";
  67. export default {
  68. name: 'selectExhibition',
  69. components: {
  70. elementSelectNew,
  71. },
  72. props: {
  73. selectYearList: {
  74. type: Array,
  75. },
  76. selectMonthList: {
  77. type: Array,
  78. },
  79. },
  80. data() {
  81. return {
  82. selectExhibitionList: [],
  83. formData: {
  84. select_year: "0",
  85. select_month: "0",
  86. exhibition_name: "0",
  87. exhibition: {id:'0',name: ''},
  88. },
  89. validation: {
  90. select_year: true,
  91. select_month: true,
  92. exhibition_name: true,
  93. },
  94. errors: null,
  95. };
  96. },
  97. methods: {
  98. reset() {
  99. this.formData = {
  100. select_year: "0",
  101. select_month: "0",
  102. exhibition_name: "0",
  103. exhibition: {id:'0',name: ''},
  104. };
  105. },
  106. validators() {
  107. // if (is.empty(this.formData.select_year) || this.formData.select_year =="0") {
  108. // this.validation.select_year = false;
  109. // } else {
  110. // this.validation.select_year = true;
  111. // }
  112. // if (is.empty(this.formData.select_month) || this.formData.select_month =="0") {
  113. // this.validation.select_month = false;
  114. // } else {
  115. // this.validation.select_month = true;
  116. // }
  117. if (is.empty(this.formData.exhibition_name) || this.formData.exhibition_name =="0") {
  118. this.validation.exhibition_name = false;
  119. } else {
  120. this.validation.exhibition_name = true;
  121. }
  122. this.errors = Object.entries(this.validation).filter(
  123. (e) => e[1] == false
  124. );
  125. if (this.errors.length > 0) {
  126. return false;
  127. } else {
  128. return true;
  129. }
  130. },
  131. selectYear(value){
  132. this.formData.select_year = value;
  133. this.getExhibitions();
  134. },
  135. selectMonth(value){
  136. this.formData.select_month = value;
  137. this.getExhibitions();
  138. },
  139. selectExhibition(value){
  140. if(this.selectExhibitionList.length>0){
  141. for(let i=0;i<this.selectExhibitionList.length;i++){
  142. if(this.selectExhibitionList[i].id == value){
  143. this.formData.selectPackape = this.selectExhibitionList[i];
  144. break;
  145. }
  146. }
  147. }
  148. this.formData.exhibition_name = value;
  149. },
  150. getExhibitions(){
  151. this.selectExhibitionList = [];
  152. if((this.formData.select_year && this.formData.select_year!="0") && (this.formData.select_month && this.formData.select_month !="0")){
  153. this.$axios.get(`/trending/api/Onsite/Exhibitions?Lang=${this.$i18n.localeProperties["langQuery"]}&ServiceID=${this.$route.params.id}&Year=${this.formData.select_year}&Month=${this.formData.select_month}`)
  154. .then((response) => {
  155. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  156. let data = response.data.DATA.rel
  157. if(data.length>0){
  158. this.selectExhibitionList = data.map((item) => {
  159. return {
  160. id: item.ArgumentID,
  161. name: item.ArgumentValue,
  162. };
  163. });
  164. }
  165. }
  166. })
  167. .catch((error) => console.log(error));
  168. }
  169. }
  170. },
  171. };
  172. </script>
  173. <style lang="scss" scoped>
  174. select {
  175. -moz-appearance: none;
  176. /* Firefox */
  177. -webkit-appearance: none;
  178. /* Safari and Chrome */
  179. appearance: none;
  180. background-image: url("~/assets/svg/down-arrow.svg");
  181. background-size: 9px 6px;
  182. background-position: right 20px center;
  183. background-repeat: no-repeat;
  184. }
  185. </style>