CheckNatureCom.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="check-nature-box">
  3. <view class="title" :style="textStyle">检验性质:</view>
  4. <wd-picker
  5. class="nature-picker"
  6. v-model="selectCode"
  7. :columns="columns"
  8. @confirm="onConfirm"
  9. >
  10. <view class="nature-input">
  11. <text :class="['nature-text', { 'nature-text--placeholder': !displayLabel }]">
  12. {{ displayLabel || '请选择' }}
  13. </text>
  14. </view>
  15. </wd-picker>
  16. </view>
  17. </template>
  18. <script lang="ts" setup>
  19. import { ref, computed } from 'vue'
  20. interface Props {
  21. type: string
  22. textStyle?: any
  23. }
  24. const props = defineProps<Props>()
  25. const emit = defineEmits<{
  26. change: [text: number, type: string]
  27. }>()
  28. const selectCode = ref<number | undefined>(undefined)
  29. const columns = [
  30. { label: '定期检验', value: 100 },
  31. { label: '年度检查', value: 200 },
  32. // { label: '超年限检验', value: 300 },
  33. ]
  34. const displayLabel = computed(() => {
  35. if (selectCode.value == null) return ''
  36. const item = columns.find((c) => c.value === selectCode.value)
  37. return item ? item.label : ''
  38. })
  39. const onConfirm = ({ value }: { value: number }) => {
  40. if (value) {
  41. emit('change', value, props.type)
  42. }
  43. }
  44. defineExpose({
  45. reset: () => {
  46. selectCode.value = undefined
  47. },
  48. inputContent: computed(() => selectCode.value || undefined),
  49. })
  50. </script>
  51. <style lang="scss" scoped>
  52. .check-nature-box {
  53. display: flex;
  54. flex-direction: row;
  55. align-items: center;
  56. margin-bottom: 10px;
  57. }
  58. .title {
  59. flex-shrink: 0;
  60. width: 60px;
  61. font-size: 12px;
  62. color: rgb(51, 51, 51);
  63. text-align: right;
  64. }
  65. .nature-picker {
  66. flex: 1;
  67. min-width: 0;
  68. }
  69. .nature-input {
  70. box-sizing: border-box;
  71. display: flex;
  72. flex: 1;
  73. flex-direction: row;
  74. align-items: center;
  75. min-width: 0;
  76. height: 30px;
  77. min-height: 30px;
  78. padding: 0 5px;
  79. border: 1px solid #ccc;
  80. border-radius: 6px;
  81. }
  82. .nature-text {
  83. font-size: 12px;
  84. color: rgb(51, 51, 51);
  85. &--placeholder {
  86. color: rgba(136, 136, 136, 1);
  87. }
  88. }
  89. </style>