ParamRow.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="param-row">
  3. <u-button
  4. :type="labelType"
  5. size="mini"
  6. class="param-label"
  7. >
  8. {{ label }}
  9. </u-button>
  10. <!-- 输入框 -->
  11. <u-input
  12. v-if="inputType === 'text'"
  13. v-model="inputValue"
  14. :placeholder="placeholder"
  15. :type="inputType"
  16. class="param-input"
  17. @input="handleInput"
  18. ></u-input>
  19. <!-- 选择器 -->
  20. <u-select
  21. v-else-if="inputType === 'select'"
  22. v-model="inputValue"
  23. :list="options"
  24. :placeholder="placeholder"
  25. class="param-select"
  26. @change="handleSelect"
  27. ></u-select>
  28. <!-- 复选框 -->
  29. <u-checkbox
  30. v-if="showCheckbox"
  31. v-model="checkboxValue"
  32. class="checkbox"
  33. @change="handleCheckbox"
  34. >
  35. {{ checkboxLabel }}
  36. </u-checkbox>
  37. <!-- 操作按钮 -->
  38. <u-button
  39. v-if="actionButton"
  40. :type="buttonType"
  41. size="mini"
  42. class="action-btn"
  43. :disabled="buttonDisabled"
  44. @click="handleAction"
  45. >
  46. {{ actionButton }}
  47. </u-button>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. name: 'ParamRow',
  53. props: {
  54. label: {
  55. type: String,
  56. required: true
  57. },
  58. labelType: {
  59. type: String,
  60. default: 'primary'
  61. },
  62. inputType: {
  63. type: String,
  64. default: 'text'
  65. },
  66. placeholder: {
  67. type: String,
  68. default: '请输入'
  69. },
  70. value: {
  71. type: [String, Number],
  72. default: ''
  73. },
  74. options: {
  75. type: Array,
  76. default: () => []
  77. },
  78. showCheckbox: {
  79. type: Boolean,
  80. default: false
  81. },
  82. checkboxLabel: {
  83. type: String,
  84. default: ''
  85. },
  86. checkboxValue: {
  87. type: Boolean,
  88. default: false
  89. },
  90. actionButton: {
  91. type: String,
  92. default: ''
  93. },
  94. buttonType: {
  95. type: String,
  96. default: 'info'
  97. },
  98. buttonDisabled: {
  99. type: Boolean,
  100. default: false
  101. }
  102. },
  103. data() {
  104. return {
  105. inputValue: this.value
  106. }
  107. },
  108. watch: {
  109. value(newVal) {
  110. this.inputValue = newVal
  111. }
  112. },
  113. methods: {
  114. handleInput(value) {
  115. this.$emit('input', value)
  116. },
  117. handleSelect(value) {
  118. this.$emit('change', value)
  119. },
  120. handleCheckbox(value) {
  121. this.$emit('checkbox-change', value)
  122. },
  123. handleAction() {
  124. this.$emit('action')
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. @import '@/static/scss/custom-theme.scss';
  131. .param-row {
  132. @include flex-start;
  133. margin-bottom: $custom-spacing-md;
  134. gap: $custom-spacing-sm;
  135. flex-wrap: wrap;
  136. .param-label {
  137. min-width: 80px;
  138. @include button-style('primary');
  139. }
  140. .param-input, .param-select {
  141. flex: 1;
  142. min-width: 120px;
  143. @include input-style;
  144. }
  145. .checkbox {
  146. margin-left: $custom-spacing-sm;
  147. }
  148. .action-btn {
  149. @include button-style('info');
  150. background-color: $custom-bg-secondary;
  151. color: $custom-text-secondary;
  152. border: 1px solid $custom-border-secondary;
  153. &:disabled {
  154. background-color: $custom-bg-disabled;
  155. color: $custom-text-disabled;
  156. border-color: $custom-border-disabled;
  157. }
  158. }
  159. }
  160. // 响应式设计
  161. @include responsive(md) {
  162. .param-row {
  163. .param-input, .param-select {
  164. min-width: 150px;
  165. }
  166. }
  167. }
  168. @include responsive(lg) {
  169. .param-row {
  170. .param-input, .param-select {
  171. min-width: 200px;
  172. }
  173. }
  174. }
  175. </style>