瀏覽代碼

fix(address): 优化级联选择器的选项计算逻辑

优化了gridAddress组件中的选项计算逻辑,确保级联选择器的options正确更新。此更改解决了由于计算逻辑错误导致的级联选择器未按预期显示的问题。

fix(report): 更新问题和区域标签状态文本

更新了报告问题和区域标签的状态文本,从'未解答'更改为'待解答',以清晰区分问题状态。此更改适用于报告问题和报告区域功能的用户界面。

refactor(forms): 增强表单验证和标签显示

重构了表单验证逻辑,并增强了标签显示。现在问题类型、标题和内容的表单字段都经过适当验证,并且标签在显示上更加一致。此外,优化了问题类型和状态标签的显示方式,使之更加用户友好。

refactor(address): 改进地址选择的实现

改进了地址选择的实现方式,通过使用正确的属性和方法名称,确保地址选择功能在报告问题功能中按预期工作。此更改修正了之前地址选择不工作的问题。
梦辉 3 周之前
父節點
當前提交
7f4128dac5

+ 10 - 9
src/components/address/gridAddress/index.vue

@@ -1,5 +1,5 @@
 <script lang="ts" setup>
-import { defineProps, defineEmits, ref, onMounted, watch } from 'vue'
+import { defineProps, defineEmits, ref, onMounted, watch, computed } from 'vue'
 import { CascaderOption } from 'vant'
 import { getGridAddress } from '@/api/system'
 
@@ -10,17 +10,18 @@ const props = defineProps<{
 
 const emit = defineEmits(['update:modelValue','finish'])
 
-const localShow = ref(props.modelValue) // 本地控制的显示状态
 const cascaderValue = ref<string>() // 用于存储级联选择的值
 const options = ref<CascaderOption[]>([]) // 用于存储级联选择的选项
 
-// 监听 props 的变化,更新本地状态
-watch(
-  () => props.modelValue,
-  (newVal) => {
-    localShow.value = newVal
-  }
-)
+// 本地控制的显示状态
+const localShow = computed({
+  get() {
+    return props.modelValue
+  },
+  set(value) {
+    emit('update:modelValue', value)
+  },
+})
 
 // 当弹窗关闭时触发事件,更新父组件的 areaShow
 const onClose = () => {

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

@@ -21,7 +21,7 @@ onLoad(async (option) => {
       <view class="label">问题类型:</view>
       <view class="flex value">
         <view class="value">{{ questDetail?.questionType }}</view>
-        <van-tag v-if="questDetail?.status === 0" color="red">解答</van-tag>
+        <van-tag v-if="questDetail?.status === 0" color="red">解答</van-tag>
         <van-tag v-if="questDetail?.status === 1" color="green">已解答</van-tag>
       </view>
     </view>

+ 32 - 16
src/subPages/pages/reportProblems/index.vue

@@ -3,17 +3,17 @@ import { addQuestionReportData, getQuestionTypeList, pageQuestionReportData } fr
 import { AddQuestionReportDataReq, QuestionListRes, QuestionType, QuestionTypeListRes } from '@/api/questionReqort/types'
 import { onMounted, ref } from 'vue'
 import GridAddress from '@/components/address/gridAddress/index.vue'
-import { showNotify } from 'vant';
+import { showNotify } from 'vant'
 
 const active = ref(0)
 
 const formData = ref<AddQuestionReportDataReq & { location?: string }>({})
-const range = ref<{text: string, value: string}[]>([])
+const range = ref<{ text: string; value: string }[]>([])
 const rules = ref({
-  type: [{ required: true, message: '请选择问题类型' }],
-  title: [{ required: true, message: '请输入问题标题' }],
-  content: [{ required: true, message: '请输入问题内容' }],
-  location: [{ required: true, message: '请输入问题所在地' }],
+  questionType: [{ required: true, message: '请选择问题类型' }],
+  questionTitle: [{ required: true, message: '请输入问题标题' }],
+  questionContent: [{ required: true, message: '请输入问题内容' }],
+  addrName: [{ required: true, message: '请输入问题所在地' }],
 })
 
 /** 上报问题 */
@@ -23,6 +23,18 @@ const handleAddressFinish = (value) => {
   addressList.value = value
 }
 const submit = async () => {
+  if (!formData.value.questionType) {
+    showNotify('请选择问题类型')
+    return
+  }
+  if (!formData.value.questionTitle) {
+    showNotify('请输入问题标题')
+    return
+  }
+  if (!formData.value.questionContent) {
+    showNotify('请输入问题内容')
+    return
+  }
   if (!addressList.value || addressList.value.length === 0) {
     showNotify('请选择问题所在地')
     return
@@ -82,24 +94,21 @@ const hanleSelectArea = () => {
   areaShow.value = true
 }
 
-
-
 onMounted(async () => {
-  const {data} = await getQuestionTypeList({
+  const { data } = await getQuestionTypeList({
     page: 1,
     limit: 9999,
-    category:QuestionType.QUESTION
-    
+    category: QuestionType.QUESTION,
   })
   if (data.records) {
-    range.value = data.records.map(item => {
+    range.value = data.records.map((item) => {
       return {
         text: item.typeName,
-        value: item.typeName
+        value: item.typeName,
       }
     })
   } else {
-     range.value = []
+    range.value = []
   }
 })
 </script>
@@ -108,7 +117,7 @@ onMounted(async () => {
   <van-tabs v-model:active="active" type="card" class="top-tabs">
     <van-tab title="上报问题">
       <view class="tab-container">
-        <uni-forms :modelValue="formData" :rules="rules" label-align="right" label-width="80">
+        <uni-forms ref="questionReportFormRef" :modelValue="formData" :rules="rules" label-align="right" label-width="80">
           <uni-forms-item label="问题类型" required name="questionType">
             <uni-data-select v-model="formData.questionType" :localdata="range"></uni-data-select>
           </uni-forms-item>
@@ -140,7 +149,14 @@ onMounted(async () => {
             <view>定位:{{ item.addrName }}</view>
             <view class="flex gap-3">
               <view class="type">问题类型</view>
-              <van-tag color="#CFFECE" text-color="black">{{ item.questionType }}</van-tag>
+              <van-tag
+                class="max-w-[100px] text-ellipsis overflow-hidden text-nowrap !block !leading-[25px]"
+                color="#CFFECE"
+                text-color="black"
+                >{{ item.questionType }}</van-tag
+              >
+              <van-tag v-if="item?.status === 0" color="red">未解答</van-tag>
+              <van-tag v-if="item?.status === 1" color="green">已解答</van-tag>
             </view>
           </view>
         </van-list>

+ 1 - 1
src/subPages/pages/reportServer/detail.vue

@@ -22,7 +22,7 @@ onLoad(async (option) => {
       <view class="label">问题类型:</view>
       <view class="flex value">
         <view class="value">{{ reportServiceDetail?.serviceType }}</view>
-        <van-tag v-if="reportServiceDetail?.status === 0" color="red">解答</van-tag>
+        <van-tag v-if="reportServiceDetail?.status === 0" color="red">解答</van-tag>
         <van-tag v-if="reportServiceDetail?.status === 1" color="green">已解答</van-tag>
       </view>
     </view>

+ 44 - 12
src/subPages/pages/reportServer/index.vue

@@ -3,9 +3,9 @@ import { addServiceReportData, pageServiceReportData } from '@/api/reportService
 import { addReportServiceDataReq, ReportServiceRes } from '@/api/reportService/types'
 import { onMounted, ref } from 'vue'
 import GridAddress from '@/components/address/gridAddress/index.vue'
-import { getQuestionTypeList } from '@/api/questionReqort';
-import { QuestionType } from '@/api/questionReqort/types';
-
+import { getQuestionTypeList } from '@/api/questionReqort'
+import { QuestionType } from '@/api/questionReqort/types'
+import { showNotify } from 'vant'
 
 const active = ref(0)
 
@@ -19,9 +19,36 @@ const rules = ref({
   area: [{ required: true, message: '请选择服务区域' }],
 })
 // 服务类型
-const range = ref<{text: string, value: string}[]>([])
+const range = ref<{ text: string; value: string }[]>([])
 
 const submit = async () => {
+  if (!formData.value.serviceType) {
+    showNotify('请选择服务类型')
+    return
+  }
+  if (!formData.value.serviceTitle) {
+    showNotify('请输入服务标题')
+    return
+  }
+  if (!formData.value.serviceContent) {
+    showNotify('请输入服务内容')
+    return
+  }
+  if (!formData.value.area) {
+    showNotify('所在区域')
+    return
+  }
+  if (!formData.value.contactPerson) {
+    showNotify('请输入联系人姓名')
+    return
+  }
+  if (!formData.value.contactPhone) {
+    showNotify('请输入联系人电话')
+    return
+  }
+
+
+
   const { data } = await addServiceReportData({
     ...formData.value,
     streetCode: addressList.value.selectedOptions[1] ? addressList.value.selectedOptions[1].areaCode : '',
@@ -84,23 +111,21 @@ const hanleSelectArea = () => {
   areaShow.value = true
 }
 
-
 onMounted(async () => {
-  const {data} = await getQuestionTypeList({
+  const { data } = await getQuestionTypeList({
     page: 1,
     limit: 9999,
-    category:QuestionType.SERVICE
-    
+    category: QuestionType.SERVICE,
   })
   if (data.records) {
-    range.value = data.records.map(item => {
+    range.value = data.records.map((item) => {
       return {
         text: item.typeName,
-        value: item.typeName
+        value: item.typeName,
       }
     })
   } else {
-     range.value = []
+    range.value = []
   }
 })
 </script>
@@ -149,7 +174,14 @@ onMounted(async () => {
             <view>定位:{{ item.area }}</view>
             <view class="flex gap-3">
               <view class="type">问题类型</view>
-              <van-tag color="#CFFECE" text-color="black">{{ item.serviceType }}</van-tag>
+              <van-tag
+                class="max-w-[100px] text-ellipsis overflow-hidden text-nowrap !block !leading-[25px]"
+                color="#CFFECE"
+                text-color="black"
+                >{{ item.serviceType }}</van-tag
+              >
+              <van-tag v-if="item?.status === 0" color="red">待解答</van-tag>
+              <van-tag v-if="item?.status === 1" color="green">已解答</van-tag>
             </view>
           </view>
         </van-list>