wk-field-label.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="wk-field wk-field-label">
  3. <view v-if="_label" class="wk-field__label">
  4. <view v-if="field.isNull === 1" class="line" />
  5. {{ _label }}
  6. </view>
  7. <view class="wk-field__body">
  8. <view class="wk-field__body-core">
  9. <view
  10. v-for="(item, index) in field.setting"
  11. :key="index"
  12. :class="{active: formValue === item}"
  13. class="label-item"
  14. @click="handleChange(item)">
  15. {{ item }}
  16. </view>
  17. </view>
  18. <text class="wk wk-arrow-right icon-right" />
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import mixins from './mixins'
  24. export default {
  25. name: 'WkFieldLabel',
  26. mixins: [mixins],
  27. data() {
  28. return {
  29. }
  30. },
  31. methods: {
  32. handleChange(item) {
  33. if (this.field.disabled) {
  34. if (this.config && this.config.disabledMsg) {
  35. this.$toast(this.config.disabledMsg)
  36. }
  37. return
  38. }
  39. this.formValue = item
  40. this.$emit('input', this.formValue)
  41. this.$emit('change', {
  42. index: this.index,
  43. field: this.field,
  44. value: this.formValue
  45. })
  46. }
  47. }
  48. }
  49. </script>
  50. <style scoped lang="scss">
  51. @import "./wkField.scss";
  52. .wk-field-label {
  53. align-items: flex-start;
  54. .wk-field__body {
  55. .wk-field__body-core {
  56. flex-wrap: wrap;
  57. @include left;
  58. .label-item {
  59. color: $gray;
  60. font-size: 22rpx;
  61. border: 1rpx solid #ccc;
  62. border-radius: 6rpx;
  63. padding: 5rpx 20rpx;
  64. margin-right: 15rpx;
  65. &:last-child {
  66. margin-right: 0;
  67. }
  68. &.active {
  69. color: $theme-color;
  70. background-color: #E0EAFB;
  71. border-color: $theme-color;
  72. }
  73. }
  74. }
  75. }
  76. }
  77. </style>