crud-switch.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <div>
  3. <el-switch v-model="text"
  4. @change="handleChange"
  5. @click.native="handleClick"
  6. :active-text="getDic(0)[labelKey]"
  7. :active-value="getDic(0)[valueKey] || ''"
  8. :inactive-value="getDic(1)[valueKey] || ''"
  9. :inactive-text="getDic(1)[labelKey]"
  10. :disabled="disabled"
  11. :readonly="readonly"
  12. :size="size">
  13. </el-switch>
  14. </div>
  15. </template>
  16. <script>
  17. import create from '../../utils/create';
  18. import crudCompoents from '../../mixins/crud-compoents.js';
  19. export default create({
  20. name: 'crud-switch',
  21. mixins: [crudCompoents()],
  22. props: {
  23. value: {
  24. }
  25. },
  26. data () {
  27. return {};
  28. },
  29. watch: {},
  30. created () { },
  31. mounted () { },
  32. methods: {
  33. handleClick () {
  34. if (typeof this.click === 'function') this.click({ value: this.text, column: this.column });
  35. },
  36. handleChange (value) {
  37. if (typeof this.change === 'function') this.change({ value: value, column: this.column });
  38. this.$emit('input', value);
  39. this.$emit('change', value);
  40. },
  41. getDic (index) {
  42. return this.dic[index] ? this.dic[index] : {};
  43. }
  44. }
  45. });
  46. </script>