|
|
@@ -1,11 +1,12 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { addServiceReportData, pageServiceReportData } from '@/api/reportService'
|
|
|
-import { addReportServiceDataReq, ReportServiceRes } from '@/api/reportService/types'
|
|
|
+import type { 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 { showNotify } from 'vant'
|
|
|
+import { ensureBusinessAuthByVisitorProfile } from '@/utils/businessAuth/ensure'
|
|
|
|
|
|
const active = ref(0)
|
|
|
|
|
|
@@ -20,6 +21,15 @@ const rules = ref({
|
|
|
})
|
|
|
// 服务类型
|
|
|
const range = ref<{ text: string; value: string }[]>([])
|
|
|
+let businessAuthPromise: Promise<boolean> | null = null
|
|
|
+const ensureBusinessAuthReady = () => {
|
|
|
+ if (!businessAuthPromise) {
|
|
|
+ businessAuthPromise = ensureBusinessAuthByVisitorProfile().finally(() => {
|
|
|
+ businessAuthPromise = null
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return businessAuthPromise
|
|
|
+}
|
|
|
|
|
|
const submit = async () => {
|
|
|
if (!formData.value.serviceType) {
|
|
|
@@ -49,15 +59,9 @@ const submit = async () => {
|
|
|
|
|
|
|
|
|
|
|
|
+ await ensureBusinessAuthReady()
|
|
|
const { data } = await addServiceReportData({
|
|
|
...formData.value,
|
|
|
- streetCode: addressList.value.selectedOptions[1] ? addressList.value.selectedOptions[1].areaCode : '',
|
|
|
- streetName: addressList.value.selectedOptions[1] ? addressList.value.selectedOptions[1].areaName : '',
|
|
|
- communityCode: addressList.value.selectedOptions[2] ? addressList.value.selectedOptions[2].areaCode : '',
|
|
|
- communityName: addressList.value.selectedOptions[2] ? addressList.value.selectedOptions[2].areaName : '',
|
|
|
- grid: addressList.value.selectedOptions[3] ? addressList.value.selectedOptions[3].areaCode : '',
|
|
|
- gridName: addressList.value.selectedOptions[3] ? addressList.value.selectedOptions[3].areaName : '',
|
|
|
- createUser:'admin'
|
|
|
})
|
|
|
if (data) {
|
|
|
uni.showToast({
|
|
|
@@ -81,6 +85,7 @@ const pageInfo = ref({
|
|
|
})
|
|
|
const reportServiceList = async () => {
|
|
|
loading.value = true
|
|
|
+ await ensureBusinessAuthReady()
|
|
|
const { data } = await pageServiceReportData({
|
|
|
pageNumber: pageInfo.value.pageNumber,
|
|
|
pageSize: pageInfo.value.pageSize,
|
|
|
@@ -102,11 +107,21 @@ const handleGoDetail = (item: ReportServiceRes) => {
|
|
|
}
|
|
|
|
|
|
/** 选择地区 */
|
|
|
-const addressList = ref([])
|
|
|
+interface AddressOption {
|
|
|
+ areaName: string
|
|
|
+ areaCode: string
|
|
|
+}
|
|
|
+
|
|
|
+interface AddressSelection {
|
|
|
+ value: string
|
|
|
+ tabIndex: number
|
|
|
+ selectedOptions: AddressOption[]
|
|
|
+}
|
|
|
+
|
|
|
+const addressList = ref<AddressSelection | null>(null)
|
|
|
const areaShow = ref(false)
|
|
|
-const handleAddressFinish = (value) => {
|
|
|
- console.log("啊哈哈",value)
|
|
|
- formData.value.area = value.selectedOptions[value.tabIndex].areaName
|
|
|
+const handleAddressFinish = (value: AddressSelection) => {
|
|
|
+ formData.value.area = value.selectedOptions[value.tabIndex]?.areaName || ''
|
|
|
addressList.value = value
|
|
|
}
|
|
|
const hanleSelectArea = () => {
|
|
|
@@ -114,6 +129,11 @@ const hanleSelectArea = () => {
|
|
|
}
|
|
|
|
|
|
onMounted(async () => {
|
|
|
+ try {
|
|
|
+ await ensureBusinessAuthReady()
|
|
|
+ } catch (e) {
|
|
|
+ console.error('业务认证初始化失败:', e)
|
|
|
+ }
|
|
|
const { data } = await getQuestionTypeList({
|
|
|
page: 1,
|
|
|
limit: 9999,
|