UiSelect.vue 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <el-row class="form-group">
  3. <el-col :span="3" style="min-height:50px;padding-top:10px;">
  4. <label style="margin-left:10px;vertical-align: middle;" class="control-label">{{label ? label : 'Select'}}</label>
  5. </el-col>
  6. <el-col :span="14">
  7. <el-select
  8. :id="select_ui_id"
  9. v-model="value"
  10. :multiple="multiple ? true : false"
  11. :disabled="disabled ? true : false"
  12. :size="size ? size : 'large'"
  13. :clearable="clearable ? true : false"
  14. :multiple-limit="multipleLimit ? multiple-limit : 0"
  15. :placeholder="placeholder ? placeholder : '请选择'"
  16. @change="selectChange">
  17. <el-option
  18. v-for="item in options.attr"
  19. :key="item.value"
  20. :label="item.label"
  21. :value="item.value+''"
  22. :disabled="disabled ? true : false">
  23. <span v-if="freez" style="float: left">{{item.label}}</span>
  24. <span v-if="freez" style="float: right; color: #8492a6; font-size: 13px">{{item.notice?item.notice:item.value}}</span>
  25. </el-option>
  26. </el-select>
  27. <input type='text' :name="name?name:'select'" :id="name" class="ui-input-select-el-col-select" :value="value" style="width:0;height:0.5px;border: 0 solid rgba(255,255,255,0)">
  28. </el-col>
  29. <el-col :span="7">
  30. <div class="classJs">
  31. <div v-if="tips">
  32. <span class="red">*</span>&ensp;{{tips}}
  33. </div>
  34. </div>
  35. </el-col>
  36. </el-row>
  37. </template>
  38. <script>
  39. export default {
  40. props: ['label','multiple','disabled','size','clearable','multipleLimit','name','placeholder','free','tips','options'],
  41. data() {
  42. return {
  43. freez: this._props.free ? true : false,
  44. value: this._props.options.checked ? this._props.options.checked : '',
  45. select_ui_id: this._props.name ? 'select-ui-'+this._props.name : 'select-ui-id'
  46. };
  47. },
  48. mounted() {
  49. if( this._props.multiple ){
  50. $(document).find('#select-ui-'+this._props.name+' input.el-input__inner').css({color:'rgba(255,255,255,0)'});
  51. if( this._props.options.checked ){
  52. this.setData(this._props.options.checked);
  53. }
  54. }
  55. },
  56. methods: {
  57. selectChange(value) {
  58. this.setData(value);
  59. this.$emit('set-keys',value);
  60. },
  61. setData(value) {
  62. if( this._props.multiple ){
  63. var str = value.join(';');
  64. $(document).find('input#'+this._props.name).val(str);
  65. }else{
  66. $(document).find('input#'+this._props.name).val(value);
  67. $(document).find('input#'+this._props.name).trigger("change");
  68. }
  69. }
  70. }
  71. }
  72. </script>
  73. <style scoped>
  74. .classJs {
  75. margin-left: 10px;
  76. vertical-align: middle;
  77. height:42px;
  78. line-height:42px;
  79. }
  80. .red{
  81. color: red;
  82. }
  83. </style>