TaskLocation.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <view class="task-location">
  3. <wd-cell
  4. title-width="200rpx"
  5. :placeholder="'请选择' + taskFieldConfig.taskFiledValue"
  6. :title="taskFieldConfig.taskFiledValue"
  7. :required="taskFieldConfig.isMustfill === '1'"
  8. :value="cellValue"
  9. :is-link="!props.disabled"
  10. @click="taskLocationClick"
  11. />
  12. </view>
  13. </template>
  14. <script setup lang="ts">
  15. import { computed } from 'vue'
  16. import type { TaskFieldConfigItem } from '@/services/modules/task/taskFrom/type'
  17. interface Props {
  18. taskFieldConfig: TaskFieldConfigItem
  19. disabled?: boolean
  20. }
  21. type FieldValue = string
  22. const props = withDefaults(defineProps<Props>(), {
  23. disabled: false,
  24. })
  25. const value = defineModel<FieldValue>('value', { default: '' })
  26. const label = defineModel<FieldValue>('label', { default: '' })
  27. const cellValue = computed(() => label.value || value.value || '')
  28. const taskLocationClick = () => {
  29. if (props.disabled) return
  30. uni.navigateTo({
  31. url: `/pages-common/location-select/index?type=${props.taskFieldConfig.taskFiledType}`,
  32. events: {
  33. locationSelect: (location: string) => {
  34. label.value = location
  35. value.value = location
  36. },
  37. },
  38. })
  39. }
  40. </script>