crud-compoents.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. export default function() {
  2. //props配置
  3. const propsDefault = {
  4. id: 'id',
  5. label: 'label',
  6. value: 'value',
  7. children: 'children',
  8. disabled: 'disabled'
  9. }
  10. return {
  11. data() {
  12. return {
  13. text: undefined,
  14. propsDefault: propsDefault
  15. }
  16. },
  17. props: {
  18. change: Function,
  19. click: Function,
  20. column: {
  21. type: Object,
  22. default: () => {}
  23. },
  24. label: {
  25. type: String,
  26. default: ''
  27. },
  28. readonly: {
  29. type: Boolean,
  30. default: false
  31. },
  32. size: {
  33. type: String,
  34. default: ''
  35. },
  36. tip: {
  37. type: String,
  38. default: ''
  39. },
  40. disabled: {
  41. type: Boolean,
  42. default: false
  43. },
  44. clearable: {
  45. type: Boolean,
  46. default: true
  47. },
  48. type: {
  49. type: String,
  50. default: ''
  51. },
  52. dic: {
  53. type: Array,
  54. default: () => []
  55. },
  56. placeholder: {
  57. type: String,
  58. default: ''
  59. },
  60. min: {
  61. type: Number
  62. },
  63. max: {
  64. type: Number
  65. },
  66. border: {
  67. type: Boolean,
  68. default: false
  69. },
  70. props: {
  71. type: Object,
  72. default: () => propsDefault
  73. }
  74. },
  75. watch: {
  76. value() {
  77. this.text = this.value;
  78. }
  79. },
  80. computed: {
  81. valueKey: function() {
  82. return this.props.value || this.propsDefault.value;
  83. },
  84. labelKey: function() {
  85. return this.props.label || this.propsDefault.label;
  86. },
  87. childrenKey: function() {
  88. return this.props.children || this.propsDefault.children;
  89. },
  90. disabledKey: function() {
  91. return this.props.disabled || this.propsDefault.disabled;
  92. },
  93. idKey: function() {
  94. return this.props.id || this.propsDefault.id;
  95. }
  96. },
  97. created() {
  98. this.text = this.value;
  99. }
  100. };
  101. }