crud-compoents.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. //httpProps配置
  11. const propsHttpDefault = {
  12. name: 'name',
  13. url: 'url',
  14. }
  15. return {
  16. data() {
  17. return {
  18. text: undefined,
  19. propsHttpDefault: propsHttpDefault,
  20. propsDefault: propsDefault
  21. }
  22. },
  23. props: {
  24. change: Function,
  25. click: Function,
  26. column: {
  27. type: Object,
  28. default: () => {}
  29. },
  30. label: {
  31. type: String,
  32. default: ''
  33. },
  34. readonly: {
  35. type: Boolean,
  36. default: false
  37. },
  38. size: {
  39. type: String,
  40. default: ''
  41. },
  42. tip: {
  43. type: String,
  44. default: ''
  45. },
  46. disabled: {
  47. type: Boolean,
  48. default: false
  49. },
  50. dataType: {
  51. type: String
  52. },
  53. clearable: {
  54. type: Boolean,
  55. default: true
  56. },
  57. type: {
  58. type: String,
  59. default: ''
  60. },
  61. dic: {
  62. type: Array,
  63. default: () => []
  64. },
  65. placeholder: {
  66. type: String,
  67. default: ''
  68. },
  69. min: {
  70. type: Number
  71. },
  72. max: {
  73. type: Number
  74. },
  75. border: {
  76. type: Boolean,
  77. default: false
  78. },
  79. propsHttp: {
  80. type: Object,
  81. default: () => propsHttpDefault
  82. },
  83. props: {
  84. type: Object,
  85. default: () => propsDefault
  86. }
  87. },
  88. watch: {
  89. value() {
  90. this.text = this.value;
  91. }
  92. },
  93. computed: {
  94. nameKey: function() {
  95. return this.propsHttp.name || this.propsHttpDefault.name;
  96. },
  97. urlKey: function() {
  98. return this.propsHttp.url || this.propsHttpDefault.url;
  99. },
  100. valueKey: function() {
  101. return this.props.value || this.propsDefault.value;
  102. },
  103. labelKey: function() {
  104. return this.props.label || this.propsDefault.label;
  105. },
  106. childrenKey: function() {
  107. return this.props.children || this.propsDefault.children;
  108. },
  109. disabledKey: function() {
  110. return this.props.disabled || this.propsDefault.disabled;
  111. },
  112. idKey: function() {
  113. return this.props.id || this.propsDefault.id;
  114. }
  115. },
  116. created() {
  117. this.text = this.value;
  118. }
  119. };
  120. }