|
|
@@ -15,20 +15,20 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 门店电话 -->
|
|
|
- <el-form-item label="门店电话" prop="storePhone">
|
|
|
- <el-input v-model="formData.storePhone" placeholder="请输入门店电话" clearable maxlength="20" />
|
|
|
+ <el-form-item label="门店电话" prop="storeTel">
|
|
|
+ <el-input v-model="formData.storeTel" placeholder="请输入门店电话" clearable maxlength="20" />
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 门店面积 -->
|
|
|
<el-form-item label="门店面积" prop="storeArea">
|
|
|
<el-radio-group v-model="formData.storeArea">
|
|
|
- <el-radio value="小于20平米"> 小于20平米 </el-radio>
|
|
|
- <el-radio value="20-50平米"> 20-50平米 </el-radio>
|
|
|
- <el-radio value="50-100平米"> 50-100平米 </el-radio>
|
|
|
- <el-radio value="100-300平米"> 100-300平米 </el-radio>
|
|
|
- <el-radio value="300-500平米"> 300-500平米 </el-radio>
|
|
|
- <el-radio value="500-1000平米"> 500-1000平米 </el-radio>
|
|
|
- <el-radio value="大于1000平米"> 大于1000平米 </el-radio>
|
|
|
+ <el-radio :value="1"> 小于20平米 </el-radio>
|
|
|
+ <el-radio :value="2"> 20-50平米 </el-radio>
|
|
|
+ <el-radio :value="3"> 50-100平米 </el-radio>
|
|
|
+ <el-radio :value="4"> 100-300平米 </el-radio>
|
|
|
+ <el-radio :value="5"> 300-500平米 </el-radio>
|
|
|
+ <el-radio :value="6"> 500-1000平米 </el-radio>
|
|
|
+ <el-radio :value="7"> 大于1000平米 </el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
|
|
|
@@ -36,25 +36,25 @@
|
|
|
<el-form-item label="营业状态" prop="businessStatus">
|
|
|
<el-radio-group v-model="formData.businessStatus">
|
|
|
<div class="radio-item">
|
|
|
- <el-radio value="正常营业">
|
|
|
+ <el-radio :value="0">
|
|
|
<span class="radio-label">正常营业</span>
|
|
|
</el-radio>
|
|
|
<div class="radio-desc">门店正常开放,能够为顾客提供服务</div>
|
|
|
</div>
|
|
|
<div class="radio-item">
|
|
|
- <el-radio value="暂停营业">
|
|
|
+ <el-radio :value="1">
|
|
|
<span class="radio-label">暂停营业</span>
|
|
|
</el-radio>
|
|
|
<div class="radio-desc">门店因节假日、装修等原因,短期内止营业,预计一段时问后可恢复营业</div>
|
|
|
</div>
|
|
|
<div class="radio-item">
|
|
|
- <el-radio value="筹建中">
|
|
|
+ <el-radio :value="2">
|
|
|
<span class="radio-label">筹建中</span>
|
|
|
</el-radio>
|
|
|
<div class="radio-desc">门店正在筹备阶段,暂时不能提供服务,完成准备后可以证实为顾客提供服务</div>
|
|
|
</div>
|
|
|
<div class="radio-item">
|
|
|
- <el-radio value="永久关门">
|
|
|
+ <el-radio :value="99">
|
|
|
<span class="radio-label">永久关门</span>
|
|
|
</el-radio>
|
|
|
<div class="radio-desc">门店已经关门、转让或搬迁,长时间没有回复营业的计划,无法提供服务</div>
|
|
|
@@ -66,7 +66,7 @@
|
|
|
<el-form-item label="所在地区" required>
|
|
|
<div class="region-selector">
|
|
|
<el-select
|
|
|
- v-model="formData.province"
|
|
|
+ v-model="formData.administrativeRegionProvinceAdcode"
|
|
|
placeholder="请选择省"
|
|
|
clearable
|
|
|
style="width: 33.33%"
|
|
|
@@ -80,21 +80,21 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
<el-select
|
|
|
- v-model="formData.city"
|
|
|
+ v-model="formData.administrativeRegionCityAdcode"
|
|
|
placeholder="请选择市"
|
|
|
clearable
|
|
|
style="width: 33.33%"
|
|
|
- :disabled="!formData.province"
|
|
|
+ :disabled="!formData.administrativeRegionProvinceAdcode"
|
|
|
@change="handleCityChange"
|
|
|
>
|
|
|
<el-option v-for="city in cityOptions" :key="city.adcode" :label="city.name" :value="city.adcode" />
|
|
|
</el-select>
|
|
|
<el-select
|
|
|
- v-model="formData.district"
|
|
|
+ v-model="formData.administrativeRegionDistrictAdcode"
|
|
|
placeholder="请选择区"
|
|
|
clearable
|
|
|
style="width: 33.33%"
|
|
|
- :disabled="!formData.city"
|
|
|
+ :disabled="!formData.administrativeRegionCityAdcode"
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="district in districtOptions"
|
|
|
@@ -134,8 +134,8 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 经纬度查询 -->
|
|
|
- <el-form-item label="经纬度查询" prop="locationQuery">
|
|
|
- <el-input v-model="formData.locationQuery" placeholder="请输入地址进行查询" clearable @blur="handleLocationQuery">
|
|
|
+ <el-form-item label="经纬度查询" prop="queryAddress">
|
|
|
+ <el-input v-model="formData.queryAddress" placeholder="请输入地址进行查询" clearable @blur="handleLocationQuery">
|
|
|
<template #append>
|
|
|
<el-button :icon="Search" @click="handleLocationQuery"> 查询 </el-button>
|
|
|
</template>
|
|
|
@@ -143,22 +143,22 @@
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 经营板块 -->
|
|
|
- <el-form-item label="经营板块" prop="businessSection">
|
|
|
- <el-radio-group v-model="formData.businessSection">
|
|
|
- <div v-for="section in businessSectionList" :key="section.id || section.value" class="businessSection-item">
|
|
|
- <el-radio :value="section.id || section.value" :label="section.name || section.label">
|
|
|
- {{ section.name || section.label }}
|
|
|
+ <el-form-item label="经营板块" prop="">
|
|
|
+ <el-radio-group v-model="formData.businessSection" disabled>
|
|
|
+ <div v-for="section in businessSectionList" :key="section.dictId || section.value" class="businessSection-item">
|
|
|
+ <el-radio :value="String(section.dictId)" :label="section.dictDetail">
|
|
|
+ {{ section.dictDetail }}
|
|
|
</el-radio>
|
|
|
</div>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- 经营种类 -->
|
|
|
- <el-form-item label="经营种类" prop="businessTypes">
|
|
|
- <el-checkbox-group v-model="formData.businessTypes" style="display: flex; flex-wrap: wrap; width: 100%">
|
|
|
+ <el-form-item label="经营种类" prop="">
|
|
|
+ <el-checkbox-group v-model="formData.businessTypes" disabled style="display: flex; flex-wrap: wrap; width: 100%">
|
|
|
<div class="businessSection-item" v-for="type in businessTypeList" :key="type.id || type.value">
|
|
|
- <el-checkbox :value="type.id || type.value" :label="type.name || type.label">
|
|
|
- {{ type.name || type.label }}
|
|
|
+ <el-checkbox :value="type.id || type.value" :label="type.dictDetail">
|
|
|
+ {{ type.dictDetail }}
|
|
|
</el-checkbox>
|
|
|
</div>
|
|
|
</el-checkbox-group>
|
|
|
@@ -195,65 +195,68 @@
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
-
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, reactive, onMounted, watch } from "vue";
|
|
|
+import { ref, reactive, onMounted, watch, nextTick } from "vue";
|
|
|
import { ElMessage, ElNotification } from "element-plus";
|
|
|
import type { FormInstance, FormRules } from "element-plus";
|
|
|
import { Search, Lock } from "@element-plus/icons-vue";
|
|
|
import {
|
|
|
getBusinessSection,
|
|
|
getBusinessSectionTypes,
|
|
|
- getInputPrompt,
|
|
|
getDistrict,
|
|
|
+ getStoreDetail,
|
|
|
saveStoreInfo,
|
|
|
- editStoreInfo,
|
|
|
- getStoreDetail
|
|
|
+ editStoreInfo
|
|
|
} from "@/api/modules/storeDecoration";
|
|
|
+import { getInputPrompt } from "@/api/modules/newLoginApi";
|
|
|
import { useRoute } from "vue-router";
|
|
|
+import { localGet } from "@/utils";
|
|
|
|
|
|
const route = useRoute();
|
|
|
const formRef = ref<FormInstance>();
|
|
|
const loading = ref(false);
|
|
|
+// 标记是否正在加载详情数据,用于防止触发 watch
|
|
|
+const isLoadingDetail = ref(false);
|
|
|
|
|
|
// 表单数据
|
|
|
const formData = reactive({
|
|
|
id: "",
|
|
|
- storeName: "重庆老火锅",
|
|
|
- storeCapacity: 200,
|
|
|
- storePhone: "13000010002",
|
|
|
- storeArea: "50-100平米",
|
|
|
- businessStatus: "正常营业",
|
|
|
- province: "",
|
|
|
- city: "",
|
|
|
- district: "",
|
|
|
- storeAddress: "中信丰悦大厦",
|
|
|
- storeBlurb: "位于港湾广场地铁站直线500米",
|
|
|
- locationQuery: "中信丰悦大厦",
|
|
|
- businessSection: "美食",
|
|
|
- businessTypes: ["小吃快餐", "火锅"] as string[],
|
|
|
- expirationTime: "2025/06/11",
|
|
|
- foodLicenseExpirationTime: "2025/06/11",
|
|
|
- longitude: "",
|
|
|
- latitude: ""
|
|
|
+ storeName: "",
|
|
|
+ storeCapacity: 0 as number,
|
|
|
+ storeTel: "",
|
|
|
+ storeArea: "",
|
|
|
+ businessStatus: "",
|
|
|
+ administrativeRegionProvinceAdcode: "",
|
|
|
+ administrativeRegionCityAdcode: "",
|
|
|
+ administrativeRegionDistrictAdcode: "",
|
|
|
+ storeAddress: "",
|
|
|
+ storeBlurb: "",
|
|
|
+ queryAddress: "",
|
|
|
+ businessSection: "",
|
|
|
+ businessTypes: [] as string[],
|
|
|
+ expirationTime: "",
|
|
|
+ foodLicenseExpirationTime: "",
|
|
|
+ storePositionLongitude: "",
|
|
|
+ storePositionLatitude: "",
|
|
|
+ isChain: 0
|
|
|
});
|
|
|
|
|
|
// 表单验证规则
|
|
|
const rules = reactive<FormRules>({
|
|
|
storeName: [{ required: true, message: "请输入店铺名称", trigger: "blur" }],
|
|
|
storeCapacity: [{ required: true, message: "请输入容纳人数", trigger: "blur" }],
|
|
|
- storePhone: [
|
|
|
+ storeTel: [
|
|
|
{ required: true, message: "请输入门店电话", trigger: "blur" },
|
|
|
{ pattern: /^1[3-9]\d{9}$/, message: "请输入正确的手机号码", trigger: "blur" }
|
|
|
],
|
|
|
storeArea: [{ required: true, message: "请选择门店面积", trigger: "change" }],
|
|
|
businessStatus: [{ required: true, message: "请选择营业状态", trigger: "change" }],
|
|
|
- province: [{ required: true, message: "请选择省", trigger: "change" }],
|
|
|
- city: [{ required: true, message: "请选择市", trigger: "change" }],
|
|
|
- district: [{ required: true, message: "请选择区", trigger: "change" }],
|
|
|
+ administrativeRegionProvinceAdcode: [{ required: true, message: "请选择省", trigger: "change" }],
|
|
|
+ administrativeRegionCityAdcode: [{ required: true, message: "请选择市", trigger: "change" }],
|
|
|
+ administrativeRegionDistrictAdcode: [{ required: true, message: "请选择区", trigger: "change" }],
|
|
|
storeAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
|
|
|
storeBlurb: [{ required: true, message: "请输入门店简介", trigger: "blur" }],
|
|
|
- locationQuery: [{ required: true, message: "请输入地址进行经纬度查询", trigger: "blur" }],
|
|
|
+ queryAddress: [{ required: true, message: "请输入地址进行经纬度查询", trigger: "blur" }],
|
|
|
businessSection: [{ required: true, message: "请选择经营板块", trigger: "change" }],
|
|
|
businessTypes: [{ required: true, message: "请选择经营种类", trigger: "change", type: "array" }]
|
|
|
});
|
|
|
@@ -320,8 +323,8 @@ const getProvinceData = async () => {
|
|
|
|
|
|
// 省份变化时获取城市数据
|
|
|
const handleProvinceChange = async (provinceCode: string) => {
|
|
|
- formData.city = "";
|
|
|
- formData.district = "";
|
|
|
+ formData.administrativeRegionCityAdcode = "";
|
|
|
+ formData.administrativeRegionDistrictAdcode = "";
|
|
|
cityOptions.value = [];
|
|
|
districtOptions.value = [];
|
|
|
|
|
|
@@ -346,7 +349,7 @@ const handleProvinceChange = async (provinceCode: string) => {
|
|
|
|
|
|
// 城市变化时获取区县数据
|
|
|
const handleCityChange = async (cityCode: string) => {
|
|
|
- formData.district = "";
|
|
|
+ formData.administrativeRegionDistrictAdcode = "";
|
|
|
districtOptions.value = [];
|
|
|
|
|
|
if (!cityCode) return;
|
|
|
@@ -367,12 +370,52 @@ const handleCityChange = async (cityCode: string) => {
|
|
|
console.error("获取区县数据失败:", error);
|
|
|
}
|
|
|
};
|
|
|
+const businessMap = new Map();
|
|
|
+
|
|
|
+// 门店面积映射:字符串 -> 数字
|
|
|
+const storeAreaMap: Record<string, number> = {
|
|
|
+ 小于20平米: 1,
|
|
|
+ "20-50平米": 2,
|
|
|
+ "50-100平米": 3,
|
|
|
+ "100-300平米": 4,
|
|
|
+ "300-500平米": 5,
|
|
|
+ "500-1000平米": 6,
|
|
|
+ 大于1000平米: 7
|
|
|
+};
|
|
|
+
|
|
|
+// 门店面积反向映射:数字 -> 字符串
|
|
|
+const storeAreaReverseMap: Record<number, string> = {
|
|
|
+ 1: "小于20平米",
|
|
|
+ 2: "20-50平米",
|
|
|
+ 3: "50-100平米",
|
|
|
+ 4: "100-300平米",
|
|
|
+ 5: "300-500平米",
|
|
|
+ 6: "500-1000平米",
|
|
|
+ 7: "大于1000平米"
|
|
|
+};
|
|
|
+
|
|
|
+// 营业状态映射:字符串 -> 数字
|
|
|
+const businessStatusMap: Record<string, number> = {
|
|
|
+ 正常营业: 0,
|
|
|
+ 暂停营业: 1,
|
|
|
+ 筹建中: 2,
|
|
|
+ 永久关门: 3
|
|
|
+};
|
|
|
+
|
|
|
+// 营业状态反向映射:数字 -> 字符串
|
|
|
+const businessStatusReverseMap: Record<number, string> = {
|
|
|
+ 0: "正常营业",
|
|
|
+ 1: "暂停营业",
|
|
|
+ 2: "筹建中",
|
|
|
+ 3: "永久关门"
|
|
|
+};
|
|
|
|
|
|
// 获取经营板块列表(使用静态数据,也可以从API获取后合并)
|
|
|
const getBusinessSectionData = async () => {
|
|
|
try {
|
|
|
// 如果API有数据,可以合并或替换静态数据
|
|
|
const { data } = await getBusinessSection();
|
|
|
+ console.log(data, "---data--");
|
|
|
if (data) {
|
|
|
const dataAny = data as any;
|
|
|
let apiData: any[] = [];
|
|
|
@@ -386,7 +429,10 @@ const getBusinessSectionData = async () => {
|
|
|
}
|
|
|
// 如果API返回了数据,可以选择使用API数据或合并
|
|
|
// 这里保持使用静态数据,确保UI图的数据显示
|
|
|
- // businessSectionList.value = apiData.length > 0 ? apiData : businessSectionList.value;
|
|
|
+ businessSectionList.value = apiData.length > 0 ? apiData : businessSectionList.value;
|
|
|
+ businessSectionList.value.forEach(item => {
|
|
|
+ businessMap.set(item.id, item);
|
|
|
+ });
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error("获取经营板块失败:", error);
|
|
|
@@ -401,26 +447,19 @@ const handleBusinessSectionChange = async (sectionId: string) => {
|
|
|
formData.businessTypes = [];
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- // 优先使用静态数据
|
|
|
- if (businessTypeMap[sectionId] && businessTypeMap[sectionId].length > 0) {
|
|
|
- businessTypeList.value = businessTypeMap[sectionId];
|
|
|
- formData.businessTypes = [];
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 如果静态数据中没有,尝试从API获取
|
|
|
try {
|
|
|
- const { data } = await getBusinessSectionTypes({ parentId: sectionId });
|
|
|
- if (data) {
|
|
|
- const dataAny = data as any;
|
|
|
+ const res = await getBusinessSectionTypes({ parentId: sectionId });
|
|
|
+ console.log(res, "--data--datax");
|
|
|
+
|
|
|
+ if (res && res.data) {
|
|
|
+ const dataAny = res.data as any;
|
|
|
// 处理不同的返回格式
|
|
|
- if (dataAny.list && Array.isArray(dataAny.list)) {
|
|
|
- businessTypeList.value = dataAny.list;
|
|
|
- } else if (Array.isArray(dataAny)) {
|
|
|
+ if (Array.isArray(dataAny)) {
|
|
|
businessTypeList.value = dataAny;
|
|
|
} else if (dataAny.data && Array.isArray(dataAny.data)) {
|
|
|
businessTypeList.value = dataAny.data;
|
|
|
+ } else if (dataAny.list && Array.isArray(dataAny.list)) {
|
|
|
+ businessTypeList.value = dataAny.list;
|
|
|
} else {
|
|
|
businessTypeList.value = [];
|
|
|
}
|
|
|
@@ -429,38 +468,53 @@ const handleBusinessSectionChange = async (sectionId: string) => {
|
|
|
}
|
|
|
// 清空已选择的经营种类
|
|
|
formData.businessTypes = [];
|
|
|
- } catch (error) {
|
|
|
+ } catch (error: any) {
|
|
|
+ // 忽略请求取消错误(这是正常的,当有重复请求时会被取消)
|
|
|
+ if (error?.code === "ERR_CANCELED" || error?.name === "CanceledError") {
|
|
|
+ console.log("请求被取消(可能是重复请求)");
|
|
|
+ return;
|
|
|
+ }
|
|
|
console.error("获取经营种类失败:", error);
|
|
|
businessTypeList.value = [];
|
|
|
+ formData.businessTypes = [];
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-// 经纬度查询
|
|
|
-const handleLocationQuery = async () => {
|
|
|
- if (!formData.locationQuery) {
|
|
|
- ElMessage.warning("请输入地址进行查询");
|
|
|
- return;
|
|
|
+// 经纬度查询(返回是否成功)
|
|
|
+const queryLocation = async (address?: string): Promise<boolean> => {
|
|
|
+ const queryAddr = address || formData.queryAddress;
|
|
|
+ if (!queryAddr) {
|
|
|
+ return false;
|
|
|
}
|
|
|
try {
|
|
|
- const { data } = await getInputPrompt({ keywords: formData.locationQuery } as any);
|
|
|
- const dataArray = Array.isArray(data) ? data : data ? [data] : [];
|
|
|
- if (dataArray.length > 0) {
|
|
|
- const location = dataArray[0];
|
|
|
- if (location.location) {
|
|
|
- const coords = location.location.split(",");
|
|
|
- formData.longitude = coords[0] || "";
|
|
|
- formData.latitude = coords[1] || "";
|
|
|
- }
|
|
|
- if (location.name) {
|
|
|
- formData.storeAddress = location.name;
|
|
|
+ const { data }: any = await getInputPrompt({ addressName: queryAddr } as any);
|
|
|
+ if (data.tips && data.tips.length > 0) {
|
|
|
+ if (!data.tips[0].location) {
|
|
|
+ return false;
|
|
|
}
|
|
|
- ElMessage.success("查询成功");
|
|
|
- } else {
|
|
|
- ElMessage.warning("未找到相关地址信息");
|
|
|
+ let latlng = data.tips[0].location.split(",");
|
|
|
+ formData.storePositionLongitude = latlng[0];
|
|
|
+ formData.storePositionLatitude = latlng[1];
|
|
|
+ return true;
|
|
|
}
|
|
|
+ return false;
|
|
|
} catch (error) {
|
|
|
console.error("经纬度查询失败:", error);
|
|
|
- ElMessage.error("查询失败,请稍后重试");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 经纬度查询(用户手动触发)
|
|
|
+const handleLocationQuery = async () => {
|
|
|
+ if (!formData.queryAddress) {
|
|
|
+ ElMessage.warning("请输入地址进行查询");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const success = await queryLocation();
|
|
|
+ if (success) {
|
|
|
+ ElMessage.success("查询成功");
|
|
|
+ } else {
|
|
|
+ ElMessage.warning("未找到相关地址信息,请检查地址是否正确");
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -476,22 +530,34 @@ const handleSubmit = async () => {
|
|
|
|
|
|
loading.value = true;
|
|
|
try {
|
|
|
+ // 保存前先调用经纬度查询接口
|
|
|
+ if (formData.queryAddress) {
|
|
|
+ const locationQuerySuccess = await queryLocation();
|
|
|
+ if (!locationQuerySuccess) {
|
|
|
+ ElMessage.warning("经纬度查询失败,请检查地址是否正确,将继续保存其他信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 映射门店面积为数字
|
|
|
+ const storeAreaNum = storeAreaMap[formData.storeArea] || 0;
|
|
|
+ // 映射营业状态为数字
|
|
|
+ const businessStatusNum = businessStatusMap[formData.businessStatus] ?? 0;
|
|
|
+
|
|
|
const submitData = {
|
|
|
- id: formData.id,
|
|
|
+ id: formData.id ? Number(formData.id) : undefined,
|
|
|
+ isChain: formData.isChain,
|
|
|
storeName: formData.storeName,
|
|
|
- storeCapacity: formData.storeCapacity,
|
|
|
- storePhone: formData.storePhone,
|
|
|
- storeArea: formData.storeArea,
|
|
|
- businessStatus: formData.businessStatus,
|
|
|
- province: formData.province || "",
|
|
|
- city: formData.city || "",
|
|
|
- district: formData.district || "",
|
|
|
+ storeCapacity: String(formData.storeCapacity || ""),
|
|
|
+ storeTel: formData.storeTel,
|
|
|
storeAddress: formData.storeAddress,
|
|
|
- storeBlurb: formData.storeBlurb,
|
|
|
- businessSection: formData.businessSection,
|
|
|
- businessTypes: formData.businessTypes,
|
|
|
- longitude: formData.longitude,
|
|
|
- latitude: formData.latitude
|
|
|
+ storeArea: formData.storeArea,
|
|
|
+ queryAddress: formData.queryAddress,
|
|
|
+ administrativeRegionProvinceAdcode: formData.administrativeRegionProvinceAdcode || "",
|
|
|
+ administrativeRegionCityAdcode: formData.administrativeRegionCityAdcode || "",
|
|
|
+ administrativeRegionDistrictAdcode: formData.administrativeRegionDistrictAdcode || "",
|
|
|
+ storePositionLongitude: formData.storePositionLongitude,
|
|
|
+ storePositionLatitude: formData.storePositionLatitude,
|
|
|
+ businessStatus: formData.businessStatus
|
|
|
};
|
|
|
|
|
|
let result;
|
|
|
@@ -525,45 +591,56 @@ const handleSubmit = async () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+const userInfo = localGet("geeker-user")?.userInfo || {};
|
|
|
// 获取店铺详情(编辑时使用)
|
|
|
const getStoreDetailData = async () => {
|
|
|
- const id = route.query.id as string;
|
|
|
- if (!id) return;
|
|
|
-
|
|
|
+ isLoadingDetail.value = true; // 标记开始加载详情
|
|
|
try {
|
|
|
- const { data } = await getStoreDetail({ id } as any);
|
|
|
+ const { data } = await getStoreDetail({ id: userInfo.id } as any);
|
|
|
if (data) {
|
|
|
const storeData = data as any;
|
|
|
formData.id = storeData.id || "";
|
|
|
formData.storeName = storeData.storeName || "";
|
|
|
- formData.storeCapacity = storeData.storeCapacity || 0;
|
|
|
- formData.storePhone = storeData.storePhone || "";
|
|
|
+ formData.storeCapacity = Number(storeData.storeCapacity) || 0;
|
|
|
+ formData.storeTel = storeData.storeTel || "";
|
|
|
+ // 将数字映射回字符串
|
|
|
formData.storeArea = storeData.storeArea || "";
|
|
|
+ // 将数字映射回字符串
|
|
|
formData.businessStatus = storeData.businessStatus || "";
|
|
|
formData.storeAddress = storeData.storeAddress || "";
|
|
|
formData.storeBlurb = storeData.storeBlurb || "";
|
|
|
formData.expirationTime = storeData.expirationTime || "";
|
|
|
formData.foodLicenseExpirationTime = storeData.foodLicenseExpirationTime || "";
|
|
|
- formData.longitude = storeData.longitude || storeData.storePositionLongitude || "";
|
|
|
- formData.latitude = storeData.latitude || storeData.storePositionLatitude || "";
|
|
|
+ formData.storePositionLongitude = storeData.storePositionLongitude || "";
|
|
|
+ formData.storePositionLatitude = storeData.storePositionLatitude || "";
|
|
|
+ formData.isChain = storeData.isChain ?? 0;
|
|
|
+ formData.queryAddress = storeData.queryAddress;
|
|
|
|
|
|
// 设置地区
|
|
|
- if (storeData.province) {
|
|
|
- formData.province = storeData.province;
|
|
|
- await handleProvinceChange(storeData.province);
|
|
|
- if (storeData.city) {
|
|
|
- formData.city = storeData.city;
|
|
|
- await handleCityChange(storeData.city);
|
|
|
- if (storeData.district) {
|
|
|
- formData.district = storeData.district;
|
|
|
+ const provinceCode = storeData.administrativeRegionProvinceAdcode || "";
|
|
|
+ const cityCode = storeData.administrativeRegionCityAdcode || "";
|
|
|
+ const districtCode = storeData.administrativeRegionDistrictAdcode || "";
|
|
|
+
|
|
|
+ if (provinceCode) {
|
|
|
+ formData.administrativeRegionProvinceAdcode = provinceCode;
|
|
|
+ await handleProvinceChange(provinceCode);
|
|
|
+ if (cityCode) {
|
|
|
+ formData.administrativeRegionCityAdcode = cityCode;
|
|
|
+ await handleCityChange(cityCode);
|
|
|
+ if (districtCode) {
|
|
|
+ formData.administrativeRegionDistrictAdcode = districtCode;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 设置经营板块和种类
|
|
|
if (storeData.businessSection) {
|
|
|
- formData.businessSection = storeData.businessSection;
|
|
|
- await handleBusinessSectionChange(storeData.businessSection);
|
|
|
+ const sectionId = String(storeData.businessSection);
|
|
|
+ // 直接调用 handleBusinessSectionChange,因为 isLoadingDetail 会阻止 watch 触发
|
|
|
+ await handleBusinessSectionChange(sectionId);
|
|
|
+ // 设置 businessSection(此时 watch 不会触发,因为 isLoadingDetail 为 true)
|
|
|
+ formData.businessSection = sectionId;
|
|
|
+ // 设置已选择的经营种类
|
|
|
if (storeData.businessTypes) {
|
|
|
formData.businessTypes = Array.isArray(storeData.businessTypes) ? storeData.businessTypes : [storeData.businessTypes];
|
|
|
}
|
|
|
@@ -571,6 +648,8 @@ const getStoreDetailData = async () => {
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error("获取店铺详情失败:", error);
|
|
|
+ } finally {
|
|
|
+ isLoadingDetail.value = false; // 标记加载完成
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -578,7 +657,12 @@ const getStoreDetailData = async () => {
|
|
|
watch(
|
|
|
() => formData.businessSection,
|
|
|
newValue => {
|
|
|
+ // 如果正在加载详情数据,不触发 watch(避免重复请求)
|
|
|
+ if (isLoadingDetail.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (newValue) {
|
|
|
+ console.log(newValue, "--newValue");
|
|
|
handleBusinessSectionChange(newValue);
|
|
|
}
|
|
|
}
|