|
@@ -11,6 +11,7 @@ import {
|
|
|
uploadToOss,
|
|
uploadToOss,
|
|
|
deleteOssFile
|
|
deleteOssFile
|
|
|
} from "@/api/shopArchive";
|
|
} from "@/api/shopArchive";
|
|
|
|
|
+import { getEnabledShops } from "@/api/shop";
|
|
|
import type {
|
|
import type {
|
|
|
ShopArchiveForm,
|
|
ShopArchiveForm,
|
|
|
FixedAsset,
|
|
FixedAsset,
|
|
@@ -31,10 +32,41 @@ const activeTab = ref("basic");
|
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
|
const saving = ref(false);
|
|
const saving = ref(false);
|
|
|
|
|
|
|
|
|
|
+// 门店下拉选项
|
|
|
|
|
+const shopOptions = ref<Array<{ id: string; name: string; address: string }>>([]);
|
|
|
|
|
+
|
|
|
|
|
+// 加载门店列表(用于下拉选择)
|
|
|
|
|
+async function loadShopOptions() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = await getEnabledShops();
|
|
|
|
|
+ if (res && res.data) {
|
|
|
|
|
+ shopOptions.value = res.data.map((s: any) => ({
|
|
|
|
|
+ id: String(s.id),
|
|
|
|
|
+ name: s.name,
|
|
|
|
|
+ address: s.address || ""
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error("加载门店列表失败:", error);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 选择门店后自动带出地址
|
|
|
|
|
+function handleShopChange(shopId: string) {
|
|
|
|
|
+ const shop = shopOptions.value.find(s => s.id === shopId);
|
|
|
|
|
+ if (shop) {
|
|
|
|
|
+ form.shopName = shop.name;
|
|
|
|
|
+ form.shopAddress = shop.address;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ form.shopName = "";
|
|
|
|
|
+ form.shopAddress = "";
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 页面模式
|
|
// 页面模式
|
|
|
-const isCreate = computed(() => !route.params.id);
|
|
|
|
|
|
|
+const isCreate = computed(() => route.query.mode === "create");
|
|
|
const isView = computed(() => route.query.mode === "view");
|
|
const isView = computed(() => route.query.mode === "view");
|
|
|
-const isEdit = computed(() => !!route.params.id && route.query.mode !== "view");
|
|
|
|
|
|
|
+const isEdit = computed(() => route.query.mode === "edit");
|
|
|
const pageTitle = computed(() => {
|
|
const pageTitle = computed(() => {
|
|
|
if (isCreate.value) return "新增门店档案";
|
|
if (isCreate.value) return "新增门店档案";
|
|
|
if (isView.value) return "查看门店档案";
|
|
if (isView.value) return "查看门店档案";
|
|
@@ -381,8 +413,8 @@ async function handleSave() {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!form.shopName) {
|
|
|
|
|
- ElMessage.warning("请输入门店名称");
|
|
|
|
|
|
|
+ if (!form.shopId) {
|
|
|
|
|
+ ElMessage.warning("请选择门店");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -421,7 +453,8 @@ function goBack() {
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
loadEnumOptions();
|
|
loadEnumOptions();
|
|
|
- if (route.params.id) {
|
|
|
|
|
|
|
+ loadShopOptions();
|
|
|
|
|
+ if (route.params.id && !isCreate.value) {
|
|
|
loadArchiveDetail();
|
|
loadArchiveDetail();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -448,11 +481,22 @@ onMounted(() => {
|
|
|
<el-tab-pane label="门店基础信息" name="basic">
|
|
<el-tab-pane label="门店基础信息" name="basic">
|
|
|
<el-row :gutter="24">
|
|
<el-row :gutter="24">
|
|
|
<el-col :span="8">
|
|
<el-col :span="8">
|
|
|
- <el-form-item label="门店名称" required>
|
|
|
|
|
- <el-input
|
|
|
|
|
- v-model="form.shopName"
|
|
|
|
|
- placeholder="请输入门店名称"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <el-form-item label="选择门店" required>
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="form.shopId"
|
|
|
|
|
+ placeholder="请选择门店"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ filterable
|
|
|
|
|
+ class="w-full"
|
|
|
|
|
+ @change="handleShopChange"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="shop in shopOptions"
|
|
|
|
|
+ :key="shop.id"
|
|
|
|
|
+ :label="shop.name"
|
|
|
|
|
+ :value="shop.id"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-col>
|
|
</el-col>
|
|
|
<el-col :span="8">
|
|
<el-col :span="8">
|