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.

91 lines
2.1 KiB

  1. <template>
  2. <div :class="[`tw-grid tw-grid-cols-1 md:tw-grid-cols-[${label_width}px_auto] xl:tw-grid-cols-[${label_width}px_auto] tw-gap-[10px]`]">
  3. <label v-if="label_width!=0" class="tw-mb-[10px] tw-font-normal" :for="select.id"><span>{{ $t(select.label)
  4. }}<span v-if="select.required" class="required">*</span></span></label>
  5. <select :class="[`tw-pr-[40px] tw-min-w-[${select_width}px]`,validation ? '' : 'tw-border-error-default']" :name="select.id" v-model="value"
  6. @change="inputVal">
  7. <option :value="0">{{ $t("Select option") }}</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: "ElementSelectNew",
  17. props: {
  18. select: {
  19. type: Object,
  20. },
  21. selectList: {
  22. type: Array,
  23. },
  24. default: {
  25. type: String,
  26. },
  27. validation: {
  28. type: Boolean,
  29. },
  30. isRow: {
  31. type: Boolean,
  32. default: () => false,
  33. },
  34. itemsCenter: {
  35. type: Boolean,
  36. default: () => false,
  37. },
  38. labelWidth:{
  39. type: Number,
  40. default: () => 90,
  41. },
  42. selectWidth:{
  43. type: Number,
  44. default: () => 200,
  45. }
  46. },
  47. data() {
  48. return {
  49. value: this.default ?? null,
  50. label_width: this.labelWidth,
  51. select_width: this.selectWidth
  52. };
  53. },
  54. mounted() { },
  55. watch: {
  56. default: {
  57. handler: function () {
  58. this.value = this.default;
  59. },
  60. },
  61. labelWidth:{
  62. handler: function () {
  63. this.label_width = this.labelWidth;
  64. },
  65. },
  66. selectWidth:{
  67. handler: function () {
  68. this.select_width = this.selectWidth;
  69. },
  70. }
  71. },
  72. methods: {
  73. inputVal() {
  74. this.$emit("change", this.value);
  75. },
  76. },
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. select {
  81. -moz-appearance: none;
  82. /* Firefox */
  83. -webkit-appearance: none;
  84. /* Safari and Chrome */
  85. appearance: none;
  86. background-image: url("~/assets/svg/down-arrow.svg");
  87. background-size: 9px 6px;
  88. background-position: right 20px center;
  89. background-repeat: no-repeat;
  90. }
  91. </style>