|
|
@@ -6,13 +6,16 @@ import Refresh from "~icons/ep/refresh";
|
|
|
import Link from "~icons/ep/link";
|
|
|
import Remove from "~icons/ep/remove";
|
|
|
import Search from "~icons/ep/search";
|
|
|
+import CircleCheck from "~icons/ep/circle-check";
|
|
|
+import CircleClose from "~icons/ep/circle-close";
|
|
|
import {
|
|
|
syncErpShops,
|
|
|
getErpShopList,
|
|
|
bindErpShop,
|
|
|
unbindErpShop,
|
|
|
autoBindErpShop,
|
|
|
- unbindAllErpShop
|
|
|
+ unbindAllErpShop,
|
|
|
+ batchUpdateBindEnabled
|
|
|
} from "@/api/erpShop";
|
|
|
import { getDeviceList } from "@/api/device";
|
|
|
|
|
|
@@ -24,6 +27,7 @@ const loading = ref(false);
|
|
|
const syncing = ref(false);
|
|
|
const autoBinding = ref(false);
|
|
|
const unbindingAll = ref(false);
|
|
|
+const batchUpdating = ref(false);
|
|
|
|
|
|
const form = reactive({
|
|
|
keyword: "",
|
|
|
@@ -38,6 +42,11 @@ const bindDialogVisible = ref(false);
|
|
|
const currentErpShop = ref<any>(null);
|
|
|
const selectedDeviceId = ref<number | null>(null);
|
|
|
const bindLoading = ref(false);
|
|
|
+const selectedRows = ref<any[]>([]);
|
|
|
+
|
|
|
+function handleSelectionChange(rows: any[]) {
|
|
|
+ selectedRows.value = rows;
|
|
|
+}
|
|
|
|
|
|
async function fetchList() {
|
|
|
loading.value = true;
|
|
|
@@ -154,6 +163,37 @@ async function handleUnbindAll() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+async function handleBatchBindEnabled(bindEnabled: number) {
|
|
|
+ if (selectedRows.value.length === 0) {
|
|
|
+ ElMessage.warning("请先勾选要操作的店铺");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const label = bindEnabled === 1 ? "允许绑定" : "禁止绑定";
|
|
|
+ try {
|
|
|
+ await ElMessageBox.confirm(
|
|
|
+ `确认将 ${selectedRows.value.length} 个店铺设为「${label}」?`,
|
|
|
+ "批量修改",
|
|
|
+ { type: "warning" }
|
|
|
+ );
|
|
|
+ } catch { return; }
|
|
|
+
|
|
|
+ batchUpdating.value = true;
|
|
|
+ try {
|
|
|
+ const ids = selectedRows.value.map((r: any) => r.erpShopId);
|
|
|
+ const res = await batchUpdateBindEnabled(ids, bindEnabled);
|
|
|
+ if (res.code === 200) {
|
|
|
+ ElMessage.success(`已更新 ${res.data} 个店铺`);
|
|
|
+ await fetchList();
|
|
|
+ } else {
|
|
|
+ ElMessage.error(res.message || "操作失败");
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ ElMessage.error("操作请求失败");
|
|
|
+ } finally {
|
|
|
+ batchUpdating.value = false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function openBindDialog(row: any) {
|
|
|
currentErpShop.value = row;
|
|
|
selectedDeviceId.value = row._boundDevice?.id || null;
|
|
|
@@ -205,6 +245,11 @@ async function handleUnbind(row: any) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function getBindEnabledTag(bindEnabled: number | null) {
|
|
|
+ if (bindEnabled === 0) return { label: "不允许", type: "danger" as const };
|
|
|
+ return { label: "允许", type: "success" as const };
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
fetchList();
|
|
|
});
|
|
|
@@ -254,7 +299,7 @@ onMounted(() => {
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
|
|
|
- <!-- 操作按钮 + 表格 -->
|
|
|
+ <!-- 标题 + 操作按钮 + 表格 -->
|
|
|
<div class="px-6 pt-4">
|
|
|
<div class="flex items-center justify-between mb-4">
|
|
|
<h2 class="text-lg font-semibold">ERP 店铺管理</h2>
|
|
|
@@ -281,6 +326,25 @@ onMounted(() => {
|
|
|
>
|
|
|
一键解绑
|
|
|
</el-button>
|
|
|
+ <el-divider direction="vertical" />
|
|
|
+ <el-button
|
|
|
+ type="success"
|
|
|
+ :icon="useRenderIcon(CircleCheck)"
|
|
|
+ :loading="batchUpdating"
|
|
|
+ plain
|
|
|
+ @click="handleBatchBindEnabled(1)"
|
|
|
+ >
|
|
|
+ 批量允许绑定
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ :icon="useRenderIcon(CircleClose)"
|
|
|
+ :loading="batchUpdating"
|
|
|
+ plain
|
|
|
+ @click="handleBatchBindEnabled(0)"
|
|
|
+ >
|
|
|
+ 批量禁止绑定
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -292,11 +356,23 @@ onMounted(() => {
|
|
|
style="width: 100%"
|
|
|
empty-text="暂无数据,请先同步ERP店铺"
|
|
|
:row-style="{ height: '64px' }"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
>
|
|
|
+ <el-table-column type="selection" width="50" fixed="left" />
|
|
|
<el-table-column prop="erpShopId" label="ERP店铺ID" width="160" align="center" />
|
|
|
<el-table-column prop="shopName" label="店铺名称" min-width="180" show-overflow-tooltip />
|
|
|
<el-table-column prop="nickName" label="卖家账号" min-width="160" show-overflow-tooltip />
|
|
|
<el-table-column prop="shopCode" label="设备ID(shopCode)" width="180" align="center" show-overflow-tooltip />
|
|
|
+ <el-table-column label="允许绑定" width="100" align="center">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-tag
|
|
|
+ :type="getBindEnabledTag(row.bindEnabled).type"
|
|
|
+ size="small"
|
|
|
+ >
|
|
|
+ {{ getBindEnabledTag(row.bindEnabled).label }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column label="绑定设备" min-width="180">
|
|
|
<template #default="{ row }">
|
|
|
<el-popover
|