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.

66 lines
1.4 KiB

2 years ago
  1. <template>
  2. <div class="tw-flex tw-flex-col">
  3. <label class="tw-mb-[10px]" :for="select.id"><span>{{ select.label
  4. }}<span v-if="select.required" class="required">*</span></span></label>
  5. <select :class="['tw-pr-[40px]',validation ? '' : 'tw-bg-white tw-rounded-[10px]']" :name="select.id"
  6. v-model="value" @change="inputVal">
  7. <option value="0">{{ defaultOptionMsg }}</option>
  8. <option v-for="{ id, name } in selectList" :key="id" :value="id">
  9. {{ name }}
  10. </option>
  11. </select>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: "ElementSelect",
  17. props: {
  18. select: {
  19. type: Object,
  20. },
  21. selectList: {
  22. type: Array,
  23. },
  24. default: {
  25. type: Number,
  26. },
  27. validation: {
  28. type: Boolean,
  29. },
  30. defaultOptionMsg: {
  31. type: String,
  32. },
  33. },
  34. data() {
  35. return {
  36. value: this.default ?? null,
  37. };
  38. },
  39. mounted() { },
  40. watch: {
  41. default: {
  42. handler: function () {
  43. this.value = this.default;
  44. },
  45. },
  46. },
  47. methods: {
  48. inputVal() {
  49. this.$emit("change", this.value);
  50. },
  51. },
  52. };
  53. </script>
  54. <style lang="scss" scoped>
  55. select {
  56. -moz-appearance: none;
  57. /* Firefox */
  58. -webkit-appearance: none;
  59. /* Safari and Chrome */
  60. appearance: none;
  61. background-image: url("~/assets/svg/down-arrow.svg");
  62. background-size: 9px 6px;
  63. background-position: right 20px center;
  64. background-repeat: no-repeat;
  65. }
  66. </style>