- shops、shop_products 新增 subsidiary_id,店铺商品货主跟随店铺并按店铺回填历史数据 - 店铺列表/详情/新增/编辑/删除按货主范围隔离:货主权限仅可见/可维护自己所属公司的店铺, 新增必须选货主,货主下拉仅自己所属公司;集团改店铺货主时店铺商品同步跟随 - 外部打单平台导入的店铺(type=2)在货主权限下只读:仅保留拉取订单、同步商品,不可编辑/删除 - 打单平台相关接口(平台资料、账号、商家、快递接口、外部发货)加集团权限门禁;添加店铺必须指定货主 - 货主权限菜单隐藏「外部打单平台」;店铺商品列表/绑定按货主范围隔离 - 店铺与店铺商品导出新增货主列并按范围收窄 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
745 lines
26 KiB
Vue
745 lines
26 KiB
Vue
<script setup lang="ts">
|
||
import { computed, onMounted, reactive, ref } from 'vue'
|
||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||
import {
|
||
getShops,
|
||
getShop,
|
||
createShop,
|
||
updateShop,
|
||
deleteShop,
|
||
type ShopItem,
|
||
type ShopDetail,
|
||
} from '@/api/shop'
|
||
import { syncExternalPrintShopProducts, syncExternalPrintShopOrders } from '@/api/externalPrintAccount'
|
||
import { getPrincipalSubsidiaryOptions, type PrincipalSubsidiaryOption } from '@/api/principalSubsidiary'
|
||
import { getAccessContext } from '@/api/access'
|
||
import SplitLayout from '@/components/SplitLayout.vue'
|
||
import ExportButton from '@/components/ExportButton.vue'
|
||
import DataTable from '@/components/DataTable.vue'
|
||
import ListPager from '@/components/ListPager.vue'
|
||
import { DEFAULT_PAGE_SIZE, useListPage } from '@/composables/useListPage'
|
||
import { formatDateTime } from '@/utils/datetime'
|
||
|
||
const PLATFORMS = [
|
||
{ label: '淘宝/天猫', value: 'taobao' },
|
||
{ label: '拼多多', value: 'pdd' },
|
||
{ label: '抖音', value: 'douyin' },
|
||
{ label: '京东', value: 'jd' },
|
||
{ label: '其他', value: 'other' },
|
||
]
|
||
|
||
const STATUS_LABELS: Record<number, string> = { 1: '启用', 0: '禁用' }
|
||
|
||
/** 店铺类型:1 平台店铺 2 外部打单平台商家 3 数据库模式(预留) */
|
||
const TYPE_LABELS: Record<number, string> = { 1: '平台店铺', 2: '外部打单平台', 3: '数据库模式' }
|
||
|
||
function platformLabel(value?: string | null) {
|
||
return PLATFORMS.find((p) => p.value === value)?.label || value || '-'
|
||
}
|
||
|
||
const query = reactive({
|
||
page: 1,
|
||
pageSize: DEFAULT_PAGE_SIZE,
|
||
keyword: '',
|
||
platform: '',
|
||
subsidiary_id: '' as string | number,
|
||
status: '' as string | number,
|
||
})
|
||
|
||
/** 权限范围:所在公司权限只能管理自己所属公司的店铺,且打单平台店铺只读 */
|
||
const isCompanyScope = ref(false)
|
||
/** 货主下拉(所在公司权限仅自己所属公司) */
|
||
const subsidiaryOptions = ref<PrincipalSubsidiaryOption[]>([])
|
||
|
||
async function loadAccessInfo() {
|
||
try {
|
||
const [access, options] = await Promise.all([
|
||
getAccessContext(),
|
||
getPrincipalSubsidiaryOptions({ mine: 1 }),
|
||
])
|
||
isCompanyScope.value = !access.is_group
|
||
subsidiaryOptions.value = options
|
||
} catch {
|
||
isCompanyScope.value = false
|
||
subsidiaryOptions.value = []
|
||
}
|
||
}
|
||
|
||
const { loading, list, total, elapsed, fetchList, search, handlePageChange, handleSizeChange } = useListPage({
|
||
query,
|
||
fetcher: () => {
|
||
const params: Record<string, unknown> = { ...query }
|
||
if (!params.keyword) delete params.keyword
|
||
if (!params.platform) delete params.platform
|
||
if (params.subsidiary_id === '') delete params.subsidiary_id
|
||
if (params.status === '') delete params.status
|
||
return getShops(params)
|
||
},
|
||
})
|
||
|
||
function reset() {
|
||
query.keyword = ''
|
||
query.platform = ''
|
||
query.subsidiary_id = ''
|
||
query.status = ''
|
||
search()
|
||
}
|
||
|
||
/** 导出筛选条件(与列表筛选同源) */
|
||
const exportFilters = computed(() => ({
|
||
keyword: query.keyword.trim(),
|
||
platform: query.platform,
|
||
subsidiary_id: query.subsidiary_id,
|
||
status: query.status,
|
||
}))
|
||
|
||
/* -------------------- 详情 -------------------- */
|
||
const activeDetailTab = ref('detail')
|
||
const detailLoading = ref(false)
|
||
const currentShop = ref<ShopDetail | null>(null)
|
||
|
||
/** 拉取店铺详情(点击列表行触发,展示在下方明细标签页) */
|
||
async function fetchDetail(id: number) {
|
||
detailLoading.value = true
|
||
try {
|
||
currentShop.value = await getShop(id)
|
||
} catch {
|
||
// 拦截器已提示
|
||
} finally {
|
||
detailLoading.value = false
|
||
}
|
||
}
|
||
|
||
function handleRowClick(row: ShopItem) {
|
||
fetchDetail(row.id)
|
||
}
|
||
|
||
/* -------------------- 新增 / 编辑 -------------------- */
|
||
const dialogVisible = ref(false)
|
||
const submitting = ref(false)
|
||
const formRef = ref<FormInstance>()
|
||
const editId = ref<number | null>(null)
|
||
const form = reactive({
|
||
code: '',
|
||
subsidiary_id: null as number | null,
|
||
name: '',
|
||
platform: '',
|
||
contact_name: '',
|
||
contact_phone: '',
|
||
status: 1,
|
||
auto_fetch_order: 0,
|
||
auto_fetch_interval: 3,
|
||
remark: '',
|
||
})
|
||
// 新增时无需填编码(由后端生成 OMS 前缀编码),故 code 不做必填校验
|
||
const rules: FormRules = {
|
||
subsidiary_id: [{ required: true, message: '请选择所属货主', trigger: 'change' }],
|
||
name: [{ required: true, message: '请输入店铺名称', trigger: 'blur' }],
|
||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||
auto_fetch_interval: [
|
||
{
|
||
validator: (_rule: unknown, value: unknown, callback: (e?: string | Error) => void) => {
|
||
const interval = Number(value)
|
||
if (!Number.isInteger(interval) || interval < 3) {
|
||
callback(new Error('拉取间隔必须是不小于 3 的整数(分钟)'))
|
||
} else {
|
||
callback()
|
||
}
|
||
},
|
||
trigger: 'change',
|
||
},
|
||
],
|
||
}
|
||
|
||
function openCreate() {
|
||
editId.value = null
|
||
form.code = ''
|
||
form.subsidiary_id = isCompanyScope.value && subsidiaryOptions.value.length === 1
|
||
? subsidiaryOptions.value[0].id
|
||
: null
|
||
form.name = ''
|
||
form.platform = ''
|
||
form.contact_name = ''
|
||
form.contact_phone = ''
|
||
form.status = 1
|
||
form.auto_fetch_order = 0
|
||
form.auto_fetch_interval = 3
|
||
form.remark = ''
|
||
dialogVisible.value = true
|
||
}
|
||
|
||
function openEdit(row: ShopItem) {
|
||
editId.value = row.id
|
||
form.code = row.code
|
||
form.subsidiary_id = row.subsidiary_id ?? null
|
||
form.name = row.name
|
||
form.platform = row.platform || ''
|
||
form.contact_name = row.contact_name || ''
|
||
form.contact_phone = row.contact_phone || ''
|
||
form.status = row.status
|
||
form.auto_fetch_order = Number(row.auto_fetch_order) === 1 ? 1 : 0
|
||
form.auto_fetch_interval = Number(row.auto_fetch_interval) || 3
|
||
form.remark = row.remark || ''
|
||
dialogVisible.value = true
|
||
}
|
||
|
||
async function submitForm() {
|
||
if (!formRef.value) return
|
||
await formRef.value.validate(async (valid) => {
|
||
if (!valid) return
|
||
submitting.value = true
|
||
try {
|
||
const payload = {
|
||
...form,
|
||
subsidiary_id: form.subsidiary_id == null ? null : Number(form.subsidiary_id),
|
||
}
|
||
if (editId.value == null) {
|
||
const { code } = await createShop(payload)
|
||
ElMessage.success(`新增成功,店铺编码:${code}`)
|
||
} else {
|
||
await updateShop(editId.value, payload)
|
||
ElMessage.success('保存成功')
|
||
// 详情面板正展示该店铺时同步刷新
|
||
if (currentShop.value && currentShop.value.id === editId.value) {
|
||
await fetchDetail(editId.value)
|
||
}
|
||
}
|
||
dialogVisible.value = false
|
||
await fetchList()
|
||
} catch {
|
||
// 拦截器已提示
|
||
} finally {
|
||
submitting.value = false
|
||
}
|
||
})
|
||
}
|
||
|
||
/** 正在拉取订单的店铺ID(防止重复点击) */
|
||
const fetchingOrderId = ref<number | null>(null)
|
||
/** 拉取订单弹窗 */
|
||
const fetchOrderVisible = ref(false)
|
||
const fetchOrderSubmitting = ref(false)
|
||
const fetchOrderShop = ref<ShopItem | null>(null)
|
||
const fetchOrderForm = reactive({ days: 7 })
|
||
|
||
const FETCH_ORDER_DAYS = [
|
||
{ label: '最近 1 天', value: 1 },
|
||
{ label: '最近 3 天', value: 3 },
|
||
{ label: '最近 7 天', value: 7 },
|
||
{ label: '最近 30 天', value: 30 },
|
||
{ label: '最近 90 天', value: 90 },
|
||
{ label: '全部待处理(不限下单时间)', value: 0 },
|
||
]
|
||
|
||
/** 打开手动拉单弹窗(外部打单平台店铺) */
|
||
function openFetchOrder(row: ShopItem) {
|
||
if (!row.external_print_account_id) {
|
||
ElMessage.warning('该店铺未关联外部打单账号,无法拉取订单')
|
||
return
|
||
}
|
||
fetchOrderShop.value = row
|
||
fetchOrderForm.days = 7
|
||
fetchOrderVisible.value = true
|
||
}
|
||
/** 手动拉取订单:后端按店铺所属商家逐平台分区拉取并写入订单/明细 */
|
||
async function submitFetchOrder() {
|
||
const shop = fetchOrderShop.value
|
||
if (!shop || !shop.external_print_account_id) return
|
||
fetchOrderSubmitting.value = true
|
||
fetchingOrderId.value = shop.id
|
||
try {
|
||
const res = await syncExternalPrintShopOrders(shop.external_print_account_id, shop.id, {
|
||
days: fetchOrderForm.days,
|
||
})
|
||
const scope = fetchOrderForm.days === 0
|
||
? '全部待处理'
|
||
: `${formatDateTime(res.start_time)} ~ ${formatDateTime(res.end_time)}`
|
||
if (res.orders || res.skipped || res.voided) {
|
||
ElMessage.success(
|
||
`拉取完成(${scope}):未发货 ${res.orders} 单(新增 ${res.created},更新 ${res.updated}),明细 ${res.items} 条` +
|
||
`${res.skipped ? `;跳过平台已发货 ${res.skipped} 单` : ''}${res.voided ? `;自动作废 ${res.voided} 单` : ''}`,
|
||
)
|
||
} else {
|
||
ElMessage.warning(`该范围(${scope})内没有平台未发货的订单`)
|
||
}
|
||
fetchOrderVisible.value = false
|
||
await fetchList()
|
||
if (currentShop.value && currentShop.value.id === shop.id) await fetchDetail(shop.id)
|
||
} catch {
|
||
// 拦截器已提示
|
||
} finally {
|
||
fetchOrderSubmitting.value = false
|
||
fetchingOrderId.value = null
|
||
}
|
||
}
|
||
|
||
/** 正在同步商品的店铺ID(防止重复点击) */
|
||
const syncingId = ref<number | null>(null)
|
||
|
||
/** 同步外部打单平台商家的店铺商品(后端按商家分区逐域名拉取全量快照) */
|
||
async function handleSyncProducts(row: ShopItem) {
|
||
const accountId = row.external_print_account_id
|
||
if (!accountId) {
|
||
ElMessage.warning('该店铺未关联外部打单账号,无法同步商品')
|
||
return
|
||
}
|
||
syncingId.value = row.id
|
||
try {
|
||
const res = await syncExternalPrintShopProducts(accountId, row.id)
|
||
const parts = [ `新增 ${res.created}`, `更新 ${res.updated}` ]
|
||
if (res.removed) parts.push(`移除 ${res.removed}`)
|
||
if (res.offline) parts.push(`下架 ${res.offline}(已绑定或被订单引用,已保留)`)
|
||
const suffix = res.verified ? '' : '(平台数据在拉取过程中有变动,本次未处理下架,建议重试)'
|
||
ElMessage.success(`同步完成:${parts.join(',')},共 ${res.unique} 条${suffix}`)
|
||
if (currentShop.value && currentShop.value.id === row.id) await fetchDetail(row.id)
|
||
} catch {
|
||
// 拦截器已提示
|
||
} finally {
|
||
syncingId.value = null
|
||
}
|
||
}
|
||
|
||
async function handleDelete(row: ShopItem) {
|
||
try {
|
||
await ElMessageBox.confirm(`确认删除店铺「${row.name}」?`, '删除确认', {
|
||
type: 'warning',
|
||
confirmButtonText: '删除',
|
||
cancelButtonText: '取消',
|
||
})
|
||
} catch {
|
||
return
|
||
}
|
||
try {
|
||
await deleteShop(row.id)
|
||
ElMessage.success('已删除')
|
||
if (currentShop.value && currentShop.value.id === row.id) currentShop.value = null
|
||
await fetchList()
|
||
} catch {
|
||
// 拦截器已提示
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
fetchList()
|
||
loadAccessInfo()
|
||
})
|
||
</script>
|
||
|
||
<template>
|
||
<el-card class="shop-card">
|
||
<template #header>
|
||
<div class="page-header">
|
||
<span>店铺</span>
|
||
<div class="header-actions">
|
||
<el-button type="primary" @click="openCreate">新增店铺</el-button>
|
||
<ExportButton type="shop" :filters="exportFilters" />
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<SplitLayout :first-size="420" storage-key="shop-split" :show-second="!!currentShop">
|
||
<template #first>
|
||
<el-form :inline="true" class="search-bar">
|
||
<el-form-item label="关键词">
|
||
<el-input
|
||
v-model="query.keyword"
|
||
placeholder="店铺名称或编码"
|
||
clearable
|
||
@keyup.enter="search"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="平台">
|
||
<el-select v-model="query.platform" placeholder="全部" clearable style="width: 140px">
|
||
<el-option v-for="p in PLATFORMS" :key="p.value" :label="p.label" :value="p.value" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="货主">
|
||
<el-select
|
||
v-model="query.subsidiary_id"
|
||
placeholder="全部"
|
||
clearable
|
||
filterable
|
||
style="width: 150px"
|
||
@change="search"
|
||
>
|
||
<el-option v-for="s in subsidiaryOptions" :key="s.id" :label="s.name" :value="s.id" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="状态">
|
||
<el-select v-model="query.status" placeholder="全部" clearable style="width: 120px">
|
||
<el-option label="启用" :value="1" />
|
||
<el-option label="禁用" :value="0" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item>
|
||
<el-button type="primary" @click="search">查询</el-button>
|
||
<el-button @click="reset">重置</el-button>
|
||
</el-form-item>
|
||
</el-form>
|
||
|
||
<div class="top-table-wrap">
|
||
<DataTable
|
||
:loading="loading"
|
||
:data="list"
|
||
highlight-current-row
|
||
height="100%"
|
||
@row-click="handleRowClick"
|
||
>
|
||
<el-table-column prop="code" label="店铺编码" width="180" />
|
||
<el-table-column prop="name" label="店铺名称" min-width="150" />
|
||
<el-table-column label="货主" width="140" show-overflow-tooltip>
|
||
<template #default="{ row }">{{ row.subsidiary_name || '-' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="平台" width="110">
|
||
<template #default="{ row }">{{ platformLabel(row.platform) }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="类型" width="110">
|
||
<template #default="{ row }">{{ TYPE_LABELS[row.type] || '-' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="自动拉取" width="150">
|
||
<template #default="{ row }">
|
||
<el-tag v-if="row.auto_fetch_order === 1" type="success">
|
||
每 {{ row.auto_fetch_interval }} 分钟
|
||
</el-tag>
|
||
<el-tag v-else type="info">关闭</el-tag>
|
||
<el-tooltip
|
||
v-if="row.last_order_sync_at"
|
||
:content="`${formatDateTime(row.last_order_sync_at)} ${row.last_order_sync_msg || ''}`"
|
||
placement="top"
|
||
>
|
||
<div class="last-sync">最近拉单</div>
|
||
</el-tooltip>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="contact_name" label="联系人" width="100" />
|
||
<el-table-column prop="contact_phone" label="联系电话" width="130" />
|
||
<el-table-column label="状态" width="80">
|
||
<template #default="{ row }">
|
||
<el-tag :type="row.status === 1 ? 'success' : 'info'">
|
||
{{ STATUS_LABELS[row.status] || row.status }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="操作" width="290" fixed="right">
|
||
<template #default="{ row }">
|
||
<el-button
|
||
v-if="!(isCompanyScope && row.type === 2)"
|
||
link
|
||
type="primary"
|
||
@click.stop="openEdit(row)"
|
||
>编辑</el-button>
|
||
<el-button
|
||
v-if="row.type === 2"
|
||
link
|
||
type="primary"
|
||
:loading="fetchingOrderId === row.id"
|
||
@click.stop="openFetchOrder(row)"
|
||
>
|
||
拉取订单
|
||
</el-button>
|
||
<el-button
|
||
v-if="row.type === 2"
|
||
link
|
||
type="primary"
|
||
:loading="syncingId === row.id"
|
||
@click.stop="handleSyncProducts(row)"
|
||
>
|
||
同步商品
|
||
</el-button>
|
||
<el-button
|
||
v-if="!(isCompanyScope && row.type === 2)"
|
||
link
|
||
type="danger"
|
||
@click.stop="handleDelete(row)"
|
||
>删除</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</DataTable>
|
||
</div>
|
||
|
||
<ListPager
|
||
:total="total"
|
||
:elapsed="elapsed"
|
||
:page="query.page"
|
||
:page-size="query.pageSize"
|
||
@page-change="handlePageChange"
|
||
@size-change="handleSizeChange"
|
||
/>
|
||
</template>
|
||
|
||
<template #second>
|
||
<el-tabs v-model="activeDetailTab" type="border-card" class="detail-tabs">
|
||
<el-tab-pane label="明细" name="detail">
|
||
<div v-loading="detailLoading" class="detail-body">
|
||
<template v-if="currentShop">
|
||
<div class="detail-toolbar">
|
||
<span class="detail-title">店铺详情 · {{ currentShop.name }}</span>
|
||
<el-tag :type="currentShop.status === 1 ? 'success' : 'info'">
|
||
{{ STATUS_LABELS[currentShop.status] || currentShop.status }}
|
||
</el-tag>
|
||
<el-button size="small" class="detail-edit" @click="openEdit(currentShop)">
|
||
编辑
|
||
</el-button>
|
||
<el-button
|
||
v-if="currentShop.type === 2"
|
||
size="small"
|
||
:loading="fetchingOrderId === currentShop.id"
|
||
@click="openFetchOrder(currentShop)"
|
||
>
|
||
拉取订单
|
||
</el-button>
|
||
<el-button
|
||
v-if="currentShop.type === 2"
|
||
size="small"
|
||
:loading="syncingId === currentShop.id"
|
||
@click="handleSyncProducts(currentShop)"
|
||
>
|
||
同步商品
|
||
</el-button>
|
||
</div>
|
||
|
||
<el-descriptions :column="3" border size="small" title="基本信息">
|
||
<el-descriptions-item label="店铺编码">{{ currentShop.code }}</el-descriptions-item>
|
||
<el-descriptions-item label="店铺名称">{{ currentShop.name }}</el-descriptions-item>
|
||
<el-descriptions-item label="所属平台">
|
||
{{ platformLabel(currentShop.platform) }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="自动拉取订单">
|
||
{{ currentShop.auto_fetch_order === 1 ? `是(每 ${currentShop.auto_fetch_interval} 分钟)` : '否' }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="最近拉单">
|
||
<span v-if="currentShop.last_order_sync_at">
|
||
{{ formatDateTime(currentShop.last_order_sync_at) }}
|
||
<span class="sync-msg">{{ currentShop.last_order_sync_msg || '' }}</span>
|
||
</span>
|
||
<span v-else>-</span>
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="联系人">
|
||
{{ currentShop.contact_name || '-' }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="联系电话">
|
||
{{ currentShop.contact_phone || '-' }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="创建时间">
|
||
{{ formatDateTime(currentShop.created_at) }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="更新时间">
|
||
{{ formatDateTime(currentShop.updated_at) }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="备注" :span="3">
|
||
{{ currentShop.remark || '-' }}
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
|
||
<el-descriptions :column="3" border size="small" title="关联统计" class="stat-block">
|
||
<el-descriptions-item label="店铺商品数">
|
||
{{ currentShop.stats?.shop_product_count ?? 0 }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="已绑定商品">
|
||
{{ currentShop.stats?.shop_product_bound_count ?? 0 }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="订单数">
|
||
{{ currentShop.stats?.order_count ?? 0 }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="订单金额合计">
|
||
{{ currentShop.stats?.order_amount ?? 0 }}
|
||
</el-descriptions-item>
|
||
<el-descriptions-item label="最近订单时间" :span="2">
|
||
{{ currentShop.stats?.latest_order_at ? formatDateTime(currentShop.stats.latest_order_at) : '暂无订单' }}
|
||
</el-descriptions-item>
|
||
</el-descriptions>
|
||
</template>
|
||
<el-empty v-else description="请点击上方店铺查看详情" />
|
||
</div>
|
||
</el-tab-pane>
|
||
</el-tabs>
|
||
</template>
|
||
</SplitLayout>
|
||
|
||
<el-dialog v-model="dialogVisible" :title="editId == null ? '新增店铺' : '编辑店铺'" width="560px">
|
||
<el-form ref="formRef" :model="form" :rules="rules" label-width="96px">
|
||
<el-alert
|
||
v-if="editId == null"
|
||
class="code-tip"
|
||
type="info"
|
||
show-icon
|
||
:closable="false"
|
||
title="店铺编码无需填写,保存后由系统自动生成(前缀 OMS,表示在 OMS 中创建)"
|
||
/>
|
||
<el-form-item label="店铺编码" prop="code">
|
||
<el-input
|
||
v-model="form.code"
|
||
:disabled="editId == null"
|
||
:placeholder="editId == null ? '保存后自动生成(前缀 OMS)' : '同一主体下唯一,留空表示不修改'"
|
||
/>
|
||
</el-form-item>
|
||
<el-form-item label="所属货主" prop="subsidiary_id">
|
||
<el-select
|
||
v-model="form.subsidiary_id"
|
||
placeholder="请选择所属货主(下属公司)"
|
||
filterable
|
||
:disabled="editId != null && isCompanyScope"
|
||
style="width: 100%"
|
||
>
|
||
<el-option v-for="s in subsidiaryOptions" :key="s.id" :label="s.name" :value="s.id" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="店铺名称" prop="name">
|
||
<el-input v-model="form.name" placeholder="请输入店铺名称" />
|
||
</el-form-item>
|
||
<el-form-item label="平台" prop="platform">
|
||
<el-select v-model="form.platform" placeholder="选填" clearable style="width: 100%">
|
||
<el-option v-for="p in PLATFORMS" :key="p.value" :label="p.label" :value="p.value" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="联系人" prop="contact_name">
|
||
<el-input v-model="form.contact_name" placeholder="选填" />
|
||
</el-form-item>
|
||
<el-form-item label="联系电话" prop="contact_phone">
|
||
<el-input v-model="form.contact_phone" placeholder="选填" />
|
||
</el-form-item>
|
||
<el-form-item label="状态" prop="status">
|
||
<el-select v-model="form.status" style="width: 100%">
|
||
<el-option label="启用" :value="1" />
|
||
<el-option label="禁用" :value="0" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="自动拉取订单" prop="auto_fetch_order">
|
||
<el-switch v-model="form.auto_fetch_order" :active-value="1" :inactive-value="0" />
|
||
<span class="form-tip">开启后按间隔自动拉取该店铺订单</span>
|
||
</el-form-item>
|
||
<el-form-item label="拉取间隔" prop="auto_fetch_interval">
|
||
<el-input-number
|
||
v-model="form.auto_fetch_interval"
|
||
:min="3"
|
||
:step="1"
|
||
:precision="0"
|
||
/>
|
||
<span class="form-tip">分钟(不小于 3 分钟,开启自动拉取后生效)</span>
|
||
</el-form-item>
|
||
<el-form-item label="备注" prop="remark">
|
||
<el-input v-model="form.remark" type="textarea" :rows="2" placeholder="选填" />
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="dialogVisible = false">取消</el-button>
|
||
<el-button type="primary" :loading="submitting" @click="submitForm">保存</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
|
||
<el-dialog v-model="fetchOrderVisible" title="拉取订单" width="480px">
|
||
<el-alert
|
||
type="info"
|
||
:closable="false"
|
||
show-icon
|
||
title="按店铺所属商家逐平台分区拉取;时间窗按「此刻往前 N×24 小时」计算。只拉取平台侧未发货的订单(已发货/已完成/已关闭的订单会跳过)。下拉时间越长耗时越久。开启「自动拉取订单」后系统会按间隔定时拉取"
|
||
class="fetch-order-tip"
|
||
/>
|
||
<el-form :model="fetchOrderForm" label-width="96px">
|
||
<el-form-item label="店铺">
|
||
<span>{{ fetchOrderShop?.name || '-' }}</span>
|
||
</el-form-item>
|
||
<el-form-item label="拉取范围">
|
||
<el-select v-model="fetchOrderForm.days" style="width: 100%">
|
||
<el-option v-for="item in FETCH_ORDER_DAYS" :key="item.value" :label="item.label" :value="item.value" />
|
||
</el-select>
|
||
</el-form-item>
|
||
</el-form>
|
||
<template #footer>
|
||
<el-button @click="fetchOrderVisible = false">取消</el-button>
|
||
<el-button type="primary" :loading="fetchOrderSubmitting" @click="submitFetchOrder">开始拉取</el-button>
|
||
</template>
|
||
</el-dialog>
|
||
</el-card>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.shop-card {
|
||
flex: 1;
|
||
min-height: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
.shop-card :deep(.el-card__body) {
|
||
flex: 1;
|
||
min-height: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow: hidden;
|
||
padding: 10px 12px;
|
||
}
|
||
.page-header {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
font-weight: 600;
|
||
}
|
||
.last-sync {
|
||
margin-top: 2px;
|
||
font-size: 11px;
|
||
color: var(--el-text-color-secondary);
|
||
cursor: default;
|
||
}
|
||
.fetch-order-tip {
|
||
margin-bottom: 14px;
|
||
}
|
||
.sync-msg {
|
||
margin-left: 6px;
|
||
color: var(--el-text-color-secondary);
|
||
}
|
||
.search-bar {
|
||
margin-bottom: 12px;
|
||
}
|
||
.top-table-wrap {
|
||
flex: 1;
|
||
min-height: 0;
|
||
overflow: hidden;
|
||
}
|
||
.code-tip {
|
||
margin-bottom: 14px;
|
||
}
|
||
.form-tip {
|
||
margin-left: 8px;
|
||
font-size: 12px;
|
||
color: var(--el-text-color-secondary);
|
||
}
|
||
.detail-tabs {
|
||
flex: 1;
|
||
min-height: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
.detail-tabs :deep(.el-tabs__content) {
|
||
flex: 1;
|
||
min-height: 0;
|
||
overflow: hidden;
|
||
}
|
||
.detail-tabs :deep(.el-tab-pane) {
|
||
height: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
min-height: 0;
|
||
}
|
||
.detail-body {
|
||
flex: 1;
|
||
min-height: 0;
|
||
overflow: auto;
|
||
padding-right: 4px;
|
||
}
|
||
.detail-toolbar {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
margin-bottom: 12px;
|
||
}
|
||
.detail-title {
|
||
font-weight: 600;
|
||
}
|
||
.detail-edit {
|
||
margin-left: auto;
|
||
}
|
||
.stat-block {
|
||
margin-top: 16px;
|
||
}
|
||
</style>
|