EnumSelectWidgetInfo.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <div>
  3. <!-- <label :for="'enum-select-widget-' + field.fieldName" class="m-form-group-label">{{ field.name }}</label> -->
  4. <select :id="'enum-select-widget-' + field.fieldName" v-model="selectedValue" class="form-control form-control-complex form-input">
  5. <option value="" />
  6. <option v-for="keyValue in field.keyValues" :key="keyValue.keyStr" :value="keyValue.keyStr">{{ keyValue.value }}</option>
  7. </select>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. props: {
  13. 'field': {
  14. type: Object,
  15. default: null,
  16. },
  17. 'fieldValue': {
  18. type: Object,
  19. default: null,
  20. },
  21. },
  22. emits: ['valueChanged'],
  23. data: function(){
  24. return {
  25. selectedValue: ((this.fieldValue == undefined || this.fieldValue.displayValue == undefined) ? '' : this.fieldValue.displayValue[0]),
  26. };
  27. },
  28. watch: {
  29. selectedValue: function(curVal,oldVal){
  30. if(curVal != oldVal){
  31. var newFieldValue = {
  32. displayValue: [curVal],
  33. fieldType: 'String',
  34. };
  35. this.$emit('valueChanged', newFieldValue);
  36. }
  37. },
  38. },
  39. };
  40. </script>
  41. <style scoped>
  42. @media (min-width: 768px){
  43. .m-form-group-label{
  44. width: 80px;
  45. text-align: right;
  46. padding-right: 10px;
  47. }
  48. }
  49. .form-control-complex{
  50. width: 200px !important;
  51. float: none !important;
  52. }
  53. .form-input{
  54. border-radius: 4px !important;
  55. }
  56. </style>