소스 검색

- 优化级联选择器组件排放事件和选项数据加载逻辑
- 增强表单组件输入限制并优化区域选择功能

梦辉 2 주 전
부모
커밋
8e7f6088f0
3개의 변경된 파일16개의 추가작업 그리고 7개의 파일을 삭제
  1. 8 4
      src/components/address/gridAddress/index.vue
  2. 1 1
      src/subPages/pages/reportProblems/index.vue
  3. 7 2
      src/subPages/pages/reportServer/index.vue

+ 8 - 4
src/components/address/gridAddress/index.vue

@@ -8,7 +8,7 @@ const props = defineProps<{
   modelValue: boolean
 }>()
 
-const emit = defineEmits(['update:modelValue','finish'])
+const emit = defineEmits(['update:modelValue', 'finish'])
 
 const cascaderValue = ref<string>() // 用于存储级联选择的值
 const options = ref<CascaderOption[]>([]) // 用于存储级联选择的选项
@@ -25,14 +25,18 @@ const localShow = computed({
 
 // 当弹窗关闭时触发事件,更新父组件的 areaShow
 const onClose = () => {
+  cascaderValue.value = ''
   emit('update:modelValue', false)
 }
-
+const onClickOverlay = () => {
+  cascaderValue.value = ''
+}
 
 // 当级联选择完成时
 const onFinish = (value: any) => {
   emit('update:modelValue', false)
-  emit('finish',value)
+  emit('finish', value)
+  cascaderValue.value = ''
 }
 
 // 异步加载选项数据
@@ -60,7 +64,7 @@ onMounted(async () => {
 </script>
 
 <template>
-  <van-popup v-model:show="localShow" round position="bottom">
+  <van-popup v-model:show="localShow" @click-overlay="onClickOverlay" round position="bottom">
     <van-cascader
       v-model="cascaderValue"
       title="请选择所在地区"

+ 1 - 1
src/subPages/pages/reportProblems/index.vue

@@ -127,7 +127,7 @@ onMounted(async () => {
           </uni-forms-item>
           <!-- 问题内容 -->
           <uni-forms-item label="问题内容" required name="questionContent">
-            <uni-easyinput v-model="formData.questionContent" type="textarea" placeholder="请输入问题内容"></uni-easyinput>
+            <uni-easyinput v-model="formData.questionContent" :maxlength="-1" type="textarea" placeholder="请输入问题内容"></uni-easyinput>
           </uni-forms-item>
           <!-- 问题所在地 -->
           <uni-forms-item label="问题所在地" required name="addrName">

+ 7 - 2
src/subPages/pages/reportServer/index.vue

@@ -104,6 +104,7 @@ const handleGoDetail = (item: ReportServiceRes) => {
 const addressList = ref([])
 const areaShow = ref(false)
 const handleAddressFinish = (value) => {
+  console.log("啊哈哈",value)
   formData.value.area = value.selectedOptions[value.tabIndex].areaName
   addressList.value = value
 }
@@ -144,11 +145,15 @@ onMounted(async () => {
           </uni-forms-item>
           <!-- 问题内容 -->
           <uni-forms-item label="所需服务内容" required name="serviceContent">
-            <uni-easyinput v-model="formData.serviceContent" type="textarea" placeholder="所需服务内容"></uni-easyinput>
+            <uni-easyinput v-model="formData.serviceContent"
+            :maxlength="-1"
+             type="textarea" placeholder="所需服务内容"></uni-easyinput>
           </uni-forms-item>
           <!-- 问题所在地 -->
           <uni-forms-item label="所在区域" required name="area">
-            <uni-easyinput :value="formData.area" placeholder="所在区域" @focus="hanleSelectArea"></uni-easyinput>
+            <uni-easyinput v-model="formData.area"
+             placeholder="所在区域"
+             @focus="hanleSelectArea"></uni-easyinput>
             <GridAddress v-model="areaShow" @finish="handleAddressFinish"></GridAddress>
           </uni-forms-item>
           <!-- 联系人姓名 -->