mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 19:09:19 +08:00
feat: 发货仓与快递报价主数据及按仓选价算运费
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import type { ExpressQuoteDTO, ExpressQuoteVO } from './types';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export async function getExpressQuotePageApi(
|
||||
params: PageQueryDTO<ExpressQuoteDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ExpressQuoteVO.Info>>(
|
||||
'/ec/express-quote/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getEnabledExpressQuotesApi() {
|
||||
return requestClient.get<ExpressQuoteVO.Info[]>('/ec/express-quote/enabled');
|
||||
}
|
||||
|
||||
export async function getExpressQuoteDetailApi(id: number) {
|
||||
return requestClient.get<ExpressQuoteVO.Info>(
|
||||
`/ec/express-quote/detail/${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function createExpressQuoteApi(data: ExpressQuoteDTO.Create) {
|
||||
return requestClient.post<ExpressQuoteVO.Info>(
|
||||
'/ec/express-quote/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateExpressQuoteApi(
|
||||
id: number,
|
||||
data: ExpressQuoteDTO.Update,
|
||||
) {
|
||||
return requestClient.put<ExpressQuoteVO.Info>(
|
||||
`/ec/express-quote/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function deleteExpressQuoteApi(id: number) {
|
||||
return requestClient.delete(`/ec/express-quote/delete/${id}`);
|
||||
}
|
||||
|
||||
export async function upsertExpressQuoteVersionApi(
|
||||
quoteId: number,
|
||||
data: ExpressQuoteDTO.VersionUpsert,
|
||||
) {
|
||||
return requestClient.post<ExpressQuoteVO.Version>(
|
||||
`/ec/express-quote/${quoteId}/version`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function deleteExpressQuoteVersionApi(versionId: number) {
|
||||
return requestClient.delete(`/ec/express-quote/version/${versionId}`);
|
||||
}
|
||||
|
||||
export async function getExpressCarriersApi() {
|
||||
return requestClient.get<ExpressQuoteVO.CarrierOption[]>(
|
||||
'/ec/express-quote/meta/carriers',
|
||||
);
|
||||
}
|
||||
|
||||
export async function getExpressProvincesApi() {
|
||||
return requestClient.get<ExpressQuoteVO.ProvinceOption[]>(
|
||||
'/ec/express-quote/meta/provinces',
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -0,0 +1,48 @@
|
||||
export namespace ExpressQuoteDTO {
|
||||
export interface Create {
|
||||
code: string;
|
||||
name: string;
|
||||
carrierCode: string;
|
||||
billingMode: string;
|
||||
status?: number;
|
||||
remark?: string;
|
||||
initialVersion?: VersionUpsert;
|
||||
}
|
||||
|
||||
export interface Update {
|
||||
name: string;
|
||||
carrierCode: string;
|
||||
status?: number;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface Filters {
|
||||
keywords?: string;
|
||||
carrierCode?: string;
|
||||
billingMode?: string;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
export interface VersionUpsert {
|
||||
effectiveFrom: string;
|
||||
flatAmount?: number;
|
||||
unitScope?: string;
|
||||
pricePerKg?: number;
|
||||
minAmount?: number;
|
||||
volumeDivisor?: number;
|
||||
useVolumetric?: number;
|
||||
remark?: string;
|
||||
regions?: RegionUpsert[];
|
||||
}
|
||||
|
||||
export interface RegionUpsert {
|
||||
regionName: string;
|
||||
provinces?: string[];
|
||||
isDefault?: number;
|
||||
sortOrder?: number;
|
||||
firstWeightG?: number;
|
||||
firstAmount?: number;
|
||||
additionalWeightG?: number;
|
||||
additionalAmount?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
export namespace ExpressQuoteVO {
|
||||
export interface Info {
|
||||
id: number;
|
||||
companyId: number;
|
||||
code: string;
|
||||
name: string;
|
||||
carrierCode: string;
|
||||
billingMode: string;
|
||||
status: number;
|
||||
remark?: string;
|
||||
createTime?: string;
|
||||
currentVersion?: Version;
|
||||
versions?: Version[];
|
||||
}
|
||||
|
||||
export interface Version {
|
||||
id: number;
|
||||
quoteId: number;
|
||||
effectiveFrom: string;
|
||||
flatAmount?: number;
|
||||
unitScope?: string;
|
||||
pricePerKg?: number;
|
||||
minAmount?: number;
|
||||
volumeDivisor?: number;
|
||||
useVolumetric?: number;
|
||||
remark?: string;
|
||||
regions?: Region[];
|
||||
}
|
||||
|
||||
export interface Region {
|
||||
id?: number;
|
||||
regionName: string;
|
||||
provinces?: string[];
|
||||
isDefault?: number;
|
||||
sortOrder?: number;
|
||||
firstWeightG?: number;
|
||||
firstAmount?: number;
|
||||
additionalWeightG?: number;
|
||||
additionalAmount?: number;
|
||||
}
|
||||
|
||||
export interface CarrierOption {
|
||||
code: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ProvinceOption {
|
||||
code: string;
|
||||
name: string;
|
||||
normalized: string;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,11 @@ export namespace ProductSkuVO {
|
||||
skuCode?: string;
|
||||
/** 单件实重(克);空=未填 */
|
||||
weightG?: number | null;
|
||||
lengthMm?: number | null;
|
||||
widthMm?: number | null;
|
||||
heightMm?: number | null;
|
||||
warehouseId?: number | null;
|
||||
warehouseName?: string;
|
||||
/** 规格组合键;空=未结构化 */
|
||||
specCombinationKey?: string;
|
||||
/** 已绑规格值 */
|
||||
|
||||
@@ -60,6 +60,10 @@ export namespace ProductDTO {
|
||||
skuCode?: string;
|
||||
/** 单件实重(克);空=未填;界面按 kg 录入后换算 */
|
||||
weightG?: number | null;
|
||||
lengthMm?: number | null;
|
||||
widthMm?: number | null;
|
||||
heightMm?: number | null;
|
||||
warehouseId?: number | null;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -82,6 +86,10 @@ export namespace ProductDTO {
|
||||
skuCode?: string;
|
||||
/** 单件实重(克);空=未填 */
|
||||
weightG?: number | null;
|
||||
lengthMm?: number | null;
|
||||
widthMm?: number | null;
|
||||
heightMm?: number | null;
|
||||
warehouseId?: number | null;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
@@ -104,6 +112,10 @@ export namespace ProductDTO {
|
||||
skuCode?: string;
|
||||
/** 单件实重(克);空=未填 */
|
||||
weightG?: number | null;
|
||||
lengthMm?: number | null;
|
||||
widthMm?: number | null;
|
||||
heightMm?: number | null;
|
||||
warehouseId?: number | null;
|
||||
/** 商品成本 */
|
||||
productCost: number;
|
||||
/** 运费成本 */
|
||||
|
||||
@@ -84,6 +84,11 @@ export namespace ProductVO {
|
||||
skuCode?: string;
|
||||
/** 单件实重(克);空=未填 */
|
||||
weightG?: number | null;
|
||||
lengthMm?: number | null;
|
||||
widthMm?: number | null;
|
||||
heightMm?: number | null;
|
||||
warehouseId?: number | null;
|
||||
warehouseName?: string;
|
||||
/** 规格组合键;空=未结构化 */
|
||||
specCombinationKey?: string;
|
||||
/** 已绑规格值 */
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { WarehouseDTO, WarehouseVO } from './types';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export async function getWarehousePageApi(
|
||||
params: PageQueryDTO<WarehouseDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<WarehouseVO.Info>>(
|
||||
'/ec/warehouse/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getEnabledWarehousesApi() {
|
||||
return requestClient.get<WarehouseVO.Info[]>('/ec/warehouse/enabled');
|
||||
}
|
||||
|
||||
export async function getWarehouseDetailApi(id: number) {
|
||||
return requestClient.get<WarehouseVO.Info>(`/ec/warehouse/detail/${id}`);
|
||||
}
|
||||
|
||||
export async function createWarehouseApi(data: WarehouseDTO.Create) {
|
||||
return requestClient.post<WarehouseVO.Info>('/ec/warehouse/create', data);
|
||||
}
|
||||
|
||||
export async function updateWarehouseApi(
|
||||
id: number,
|
||||
data: WarehouseDTO.Update,
|
||||
) {
|
||||
return requestClient.put<WarehouseVO.Info>(`/ec/warehouse/update/${id}`, data);
|
||||
}
|
||||
|
||||
export async function deleteWarehouseApi(id: number) {
|
||||
return requestClient.delete(`/ec/warehouse/delete/${id}`);
|
||||
}
|
||||
|
||||
export async function getWarehouseBindsApi(warehouseId: number) {
|
||||
return requestClient.get<WarehouseVO.Bind[]>(
|
||||
`/ec/warehouse/${warehouseId}/binds`,
|
||||
);
|
||||
}
|
||||
|
||||
export async function addWarehouseBindApi(data: WarehouseDTO.BindCreate) {
|
||||
return requestClient.post<WarehouseVO.Bind>('/ec/warehouse/bind', data);
|
||||
}
|
||||
|
||||
export async function updateWarehouseBindApi(
|
||||
bindId: number,
|
||||
data: WarehouseDTO.BindUpdate,
|
||||
) {
|
||||
return requestClient.put<WarehouseVO.Bind>(
|
||||
`/ec/warehouse/bind/${bindId}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function removeWarehouseBindApi(bindId: number) {
|
||||
return requestClient.delete(`/ec/warehouse/bind/${bindId}`);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
@@ -0,0 +1,37 @@
|
||||
export namespace WarehouseDTO {
|
||||
export interface Create {
|
||||
code: string;
|
||||
name: string;
|
||||
province?: string;
|
||||
city?: string;
|
||||
address?: string;
|
||||
status?: number;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface Update {
|
||||
name: string;
|
||||
province?: string;
|
||||
city?: string;
|
||||
address?: string;
|
||||
status?: number;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface Filters {
|
||||
keywords?: string;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
export interface BindCreate {
|
||||
warehouseId: number;
|
||||
quoteId: number;
|
||||
priority?: number;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
export interface BindUpdate {
|
||||
priority?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
export namespace WarehouseVO {
|
||||
export interface Info {
|
||||
id: number;
|
||||
companyId: number;
|
||||
code: string;
|
||||
name: string;
|
||||
province?: string;
|
||||
city?: string;
|
||||
address?: string;
|
||||
status: number;
|
||||
remark?: string;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
bindCount?: number;
|
||||
binds?: Bind[];
|
||||
}
|
||||
|
||||
export interface Bind {
|
||||
id: number;
|
||||
warehouseId: number;
|
||||
quoteId: number;
|
||||
quoteName?: string;
|
||||
quoteCode?: string;
|
||||
carrierCode?: string;
|
||||
billingMode?: string;
|
||||
priority: number;
|
||||
status: number;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
TreeSelect,
|
||||
@@ -22,6 +23,8 @@ import {
|
||||
import { getCategoryTreeApi } from '#/api/ec/product/category';
|
||||
import { createProductApi, updateProductApi } from '#/api/ec/product';
|
||||
import { getProductSkuPageApi } from '#/api/ec/product/sku';
|
||||
import { getEnabledWarehousesApi } from '#/api/ec/warehouse';
|
||||
import type { WarehouseVO } from '#/api/ec/warehouse';
|
||||
import { FileCategory } from '#/constants/file-category';
|
||||
import { uploadFile } from '#/utils/upload-file';
|
||||
import CategoryFormModal from '#/views/ec/product/category/components/CategoryFormModal.vue';
|
||||
@@ -250,6 +253,10 @@ function mapSkuFields(spec: ProductVO.SkuInfo): ProductDTO.Sku & {
|
||||
skuCode: spec.skuCode || '',
|
||||
weightG: spec.weightG ?? null,
|
||||
weightKg: gramsToKg(spec.weightG),
|
||||
lengthMm: spec.lengthMm ?? null,
|
||||
widthMm: spec.widthMm ?? null,
|
||||
heightMm: spec.heightMm ?? null,
|
||||
warehouseId: spec.warehouseId ?? null,
|
||||
productCost: spec.productCost ?? 0,
|
||||
shippingCost: spec.shippingCost ?? 0,
|
||||
otherCost: spec.otherCost ?? 0,
|
||||
@@ -261,6 +268,20 @@ function mapSkuFields(spec: ProductVO.SkuInfo): ProductDTO.Sku & {
|
||||
};
|
||||
}
|
||||
|
||||
const warehouseOptions = ref<{ label: string; value: number }[]>([]);
|
||||
|
||||
async function loadWarehouses() {
|
||||
try {
|
||||
const list = await getEnabledWarehousesApi();
|
||||
warehouseOptions.value = (list ?? []).map((w: WarehouseVO.Info) => ({
|
||||
label: `${w.name} (${w.code})`,
|
||||
value: w.id,
|
||||
}));
|
||||
} catch {
|
||||
warehouseOptions.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
// 规格数据 - 支持创建和更新
|
||||
const skus = ref<SkuFormRow[]>([]);
|
||||
const showSkus = ref(false);
|
||||
@@ -488,7 +509,7 @@ async function open(
|
||||
resetForm(); // 先重置表单
|
||||
initFormData(); // 再初始化数据
|
||||
|
||||
await reloadCategoryTree();
|
||||
await Promise.all([reloadCategoryTree(), loadWarehouses()]);
|
||||
|
||||
modalApi.open();
|
||||
}
|
||||
@@ -550,6 +571,10 @@ const defaultSku = (): SkuFormRow => ({
|
||||
skuCode: '',
|
||||
weightG: null,
|
||||
weightKg: null,
|
||||
lengthMm: null,
|
||||
widthMm: null,
|
||||
heightMm: null,
|
||||
warehouseId: null,
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
@@ -623,6 +648,10 @@ function toSkuUpdatePayload(row: SkuFormRow): ProductDTO.UpdateSku {
|
||||
name: row.name,
|
||||
skuCode: row.skuCode ?? '',
|
||||
weightG: kgToGrams(row.weightKg),
|
||||
lengthMm: row.lengthMm ?? null,
|
||||
widthMm: row.widthMm ?? null,
|
||||
heightMm: row.heightMm ?? null,
|
||||
warehouseId: row.warehouseId ?? null,
|
||||
productCost: row.productCost ?? 0,
|
||||
shippingCost: row.shippingCost ?? 0,
|
||||
otherCost: row.otherCost ?? 0,
|
||||
@@ -924,6 +953,24 @@ const skuColumns = [
|
||||
},
|
||||
} as any),
|
||||
},
|
||||
{
|
||||
title: '发货仓',
|
||||
dataIndex: 'warehouseId',
|
||||
key: 'warehouseId',
|
||||
width: 140,
|
||||
customRender: ({ record }: { record: SkuFormRow }) =>
|
||||
h(Select, {
|
||||
value: record.warehouseId ?? undefined,
|
||||
allowClear: true,
|
||||
placeholder: '默认仓',
|
||||
options: warehouseOptions.value,
|
||||
style: { width: '100%' },
|
||||
'onUpdate:value': (value: null | number) => {
|
||||
record.warehouseId = value ?? null;
|
||||
touchSkuRows();
|
||||
},
|
||||
} as any),
|
||||
},
|
||||
{
|
||||
title: '规格',
|
||||
key: 'specValues',
|
||||
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ExpressQuoteDTO, ExpressQuoteVO } from '#/api/ec/express-quote';
|
||||
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
Form,
|
||||
FormItem,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Select,
|
||||
Switch,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
createExpressQuoteApi,
|
||||
getExpressCarriersApi,
|
||||
getExpressProvincesApi,
|
||||
updateExpressQuoteApi,
|
||||
upsertExpressQuoteVersionApi,
|
||||
} from '#/api/ec/express-quote';
|
||||
|
||||
const emit = defineEmits<{ success: [] }>();
|
||||
|
||||
const isEdit = ref(false);
|
||||
const editingId = ref<number>();
|
||||
const carriers = ref<ExpressQuoteVO.CarrierOption[]>([]);
|
||||
const provinces = ref<ExpressQuoteVO.ProvinceOption[]>([]);
|
||||
const mode = ref('FLAT');
|
||||
|
||||
const form = reactive({
|
||||
code: '',
|
||||
name: '',
|
||||
carrierCode: 'ZTO',
|
||||
billingMode: 'FLAT',
|
||||
status: 1,
|
||||
remark: '',
|
||||
effectiveFrom: dayjs().format('YYYY-MM-DD'),
|
||||
flatAmount: 0,
|
||||
unitScope: 'ORDER',
|
||||
pricePerKg: 0,
|
||||
minAmount: undefined as number | undefined,
|
||||
volumeDivisor: 6000,
|
||||
useVolumetric: false,
|
||||
regionName: '默认区',
|
||||
regionProvinces: [] as string[],
|
||||
firstWeightG: 1000,
|
||||
firstAmount: 0,
|
||||
additionalWeightG: 1000,
|
||||
additionalAmount: 0,
|
||||
});
|
||||
|
||||
const isRegion = computed(() => form.billingMode === 'REGION_WEIGHT');
|
||||
const isFlat = computed(() => form.billingMode === 'FLAT');
|
||||
const isPerKg = computed(() => form.billingMode === 'PER_KG');
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
onConfirm: handleSubmit,
|
||||
onOpenChange: (open) => {
|
||||
if (!open) reset();
|
||||
},
|
||||
});
|
||||
|
||||
function reset() {
|
||||
Object.assign(form, {
|
||||
code: '',
|
||||
name: '',
|
||||
carrierCode: 'ZTO',
|
||||
billingMode: 'FLAT',
|
||||
status: 1,
|
||||
remark: '',
|
||||
effectiveFrom: dayjs().format('YYYY-MM-DD'),
|
||||
flatAmount: 0,
|
||||
unitScope: 'ORDER',
|
||||
pricePerKg: 0,
|
||||
minAmount: undefined,
|
||||
volumeDivisor: 6000,
|
||||
useVolumetric: false,
|
||||
regionName: '默认区',
|
||||
regionProvinces: [],
|
||||
firstWeightG: 1000,
|
||||
firstAmount: 0,
|
||||
additionalWeightG: 1000,
|
||||
additionalAmount: 0,
|
||||
});
|
||||
isEdit.value = false;
|
||||
editingId.value = undefined;
|
||||
}
|
||||
|
||||
async function ensureMeta() {
|
||||
if (!carriers.value.length) {
|
||||
carriers.value = await getExpressCarriersApi();
|
||||
}
|
||||
if (!provinces.value.length) {
|
||||
provinces.value = await getExpressProvincesApi();
|
||||
}
|
||||
}
|
||||
|
||||
async function open(edit: boolean, row?: ExpressQuoteVO.Info) {
|
||||
await ensureMeta();
|
||||
isEdit.value = edit;
|
||||
if (edit && row) {
|
||||
editingId.value = row.id;
|
||||
form.code = row.code;
|
||||
form.name = row.name;
|
||||
form.carrierCode = row.carrierCode;
|
||||
form.billingMode = row.billingMode;
|
||||
form.status = row.status;
|
||||
form.remark = row.remark || '';
|
||||
mode.value = row.billingMode;
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
modalApi.setState({
|
||||
title: edit ? '编辑报价单' : '新建报价单',
|
||||
class: 'w-[640px]',
|
||||
});
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
function buildVersion(): ExpressQuoteDTO.VersionUpsert {
|
||||
const version: ExpressQuoteDTO.VersionUpsert = {
|
||||
effectiveFrom: form.effectiveFrom,
|
||||
volumeDivisor: form.volumeDivisor,
|
||||
useVolumetric: form.useVolumetric ? 1 : 0,
|
||||
};
|
||||
if (form.billingMode === 'FLAT') {
|
||||
version.flatAmount = form.flatAmount;
|
||||
version.unitScope = form.unitScope;
|
||||
} else if (form.billingMode === 'PER_KG') {
|
||||
version.pricePerKg = form.pricePerKg;
|
||||
version.minAmount = form.minAmount;
|
||||
} else {
|
||||
version.regions = [
|
||||
{
|
||||
regionName: form.regionName || '默认区',
|
||||
provinces: form.regionProvinces,
|
||||
isDefault: 1,
|
||||
firstWeightG: form.firstWeightG,
|
||||
firstAmount: form.firstAmount,
|
||||
additionalWeightG: form.additionalWeightG,
|
||||
additionalAmount: form.additionalAmount,
|
||||
},
|
||||
];
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!form.name.trim() || (!isEdit.value && !form.code.trim())) {
|
||||
message.warning('请填写编码与名称');
|
||||
return;
|
||||
}
|
||||
modalApi.setState({ confirming: true });
|
||||
try {
|
||||
if (isEdit.value && editingId.value) {
|
||||
await updateExpressQuoteApi(editingId.value, {
|
||||
name: form.name.trim(),
|
||||
carrierCode: form.carrierCode,
|
||||
status: form.status,
|
||||
remark: form.remark || undefined,
|
||||
});
|
||||
// 编辑时可追加版本
|
||||
if (form.effectiveFrom) {
|
||||
await upsertExpressQuoteVersionApi(editingId.value, buildVersion());
|
||||
}
|
||||
message.success('已更新');
|
||||
} else {
|
||||
await createExpressQuoteApi({
|
||||
code: form.code.trim(),
|
||||
name: form.name.trim(),
|
||||
carrierCode: form.carrierCode,
|
||||
billingMode: form.billingMode,
|
||||
status: form.status,
|
||||
remark: form.remark || undefined,
|
||||
initialVersion: buildVersion(),
|
||||
});
|
||||
message.success('创建成功');
|
||||
}
|
||||
modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.setState({ confirming: false });
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal>
|
||||
<Form layout="vertical" class="max-h-[70vh] overflow-y-auto px-1">
|
||||
<FormItem v-if="!isEdit" label="报价编码" required>
|
||||
<Input v-model:value="form.code" />
|
||||
</FormItem>
|
||||
<FormItem label="名称" required>
|
||||
<Input v-model:value="form.name" />
|
||||
</FormItem>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<FormItem label="承运商" required>
|
||||
<Select
|
||||
v-model:value="form.carrierCode"
|
||||
:options="carriers.map((c) => ({ value: c.code, label: c.name }))"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="计费模式" required>
|
||||
<Select
|
||||
v-model:value="form.billingMode"
|
||||
:disabled="isEdit"
|
||||
:options="[
|
||||
{ value: 'FLAT', label: '一口价 FLAT' },
|
||||
{ value: 'PER_KG', label: '按千克 PER_KG' },
|
||||
{ value: 'REGION_WEIGHT', label: '分区首重续重' },
|
||||
]"
|
||||
/>
|
||||
</FormItem>
|
||||
</div>
|
||||
<FormItem label="状态">
|
||||
<Select
|
||||
v-model:value="form.status"
|
||||
:options="[
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
]"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="生效日(版本)" required>
|
||||
<Input v-model:value="form.effectiveFrom" placeholder="yyyy-MM-dd" />
|
||||
</FormItem>
|
||||
<template v-if="isFlat">
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<FormItem label="一口价(元)">
|
||||
<InputNumber v-model:value="form.flatAmount" :min="0" class="w-full" />
|
||||
</FormItem>
|
||||
<FormItem label="计费单位">
|
||||
<Select
|
||||
v-model:value="form.unitScope"
|
||||
:options="[
|
||||
{ value: 'ORDER', label: '每单' },
|
||||
{ value: 'PIECE', label: '每件' },
|
||||
]"
|
||||
/>
|
||||
</FormItem>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="isPerKg">
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<FormItem label="元/kg">
|
||||
<InputNumber v-model:value="form.pricePerKg" :min="0" class="w-full" />
|
||||
</FormItem>
|
||||
<FormItem label="最低消费">
|
||||
<InputNumber v-model:value="form.minAmount" :min="0" class="w-full" />
|
||||
</FormItem>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="isRegion">
|
||||
<FormItem label="分区名">
|
||||
<Input v-model:value="form.regionName" />
|
||||
</FormItem>
|
||||
<FormItem label="覆盖省份">
|
||||
<Select
|
||||
v-model:value="form.regionProvinces"
|
||||
mode="multiple"
|
||||
allow-clear
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
:options="provinces.map((p) => ({ value: p.code, label: p.name }))"
|
||||
placeholder="可多选;设为默认分区"
|
||||
/>
|
||||
</FormItem>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<FormItem label="首重(克)">
|
||||
<InputNumber v-model:value="form.firstWeightG" :min="1" class="w-full" />
|
||||
</FormItem>
|
||||
<FormItem label="首重价">
|
||||
<InputNumber v-model:value="form.firstAmount" :min="0" class="w-full" />
|
||||
</FormItem>
|
||||
<FormItem label="续重步进(克)">
|
||||
<InputNumber v-model:value="form.additionalWeightG" :min="1" class="w-full" />
|
||||
</FormItem>
|
||||
<FormItem label="续重价">
|
||||
<InputNumber v-model:value="form.additionalAmount" :min="0" class="w-full" />
|
||||
</FormItem>
|
||||
</div>
|
||||
</template>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<FormItem label="启用体积重">
|
||||
<Switch v-model:checked="form.useVolumetric" />
|
||||
</FormItem>
|
||||
<FormItem label="体积重除数">
|
||||
<InputNumber v-model:value="form.volumeDivisor" :min="1" class="w-full" />
|
||||
</FormItem>
|
||||
</div>
|
||||
<FormItem label="备注">
|
||||
<Input.TextArea v-model:value="form.remark" :rows="2" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,212 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { ExpressQuoteDTO, ExpressQuoteVO } from '#/api/ec/express-quote';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteExpressQuoteApi,
|
||||
getExpressQuotePageApi,
|
||||
} from '#/api/ec/express-quote';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
|
||||
import ExpressQuoteFormModal from './components/ExpressQuoteFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'ExpressQuoteManagement' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const loading = ref(false);
|
||||
const formModalRef = ref<InstanceType<typeof ExpressQuoteFormModal> | null>(
|
||||
null,
|
||||
);
|
||||
const searchForm = ref({
|
||||
keywords: '',
|
||||
billingMode: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
});
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const actionCodes = [
|
||||
'ec:express-quote:create',
|
||||
'ec:express-quote:update',
|
||||
'ec:express-quote:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(actionCodes);
|
||||
|
||||
const tableBaseColumns: VxeGridProps<ExpressQuoteVO.Info>['columns'] = [
|
||||
{ type: 'seq' as const, minWidth: 'auto', title: '序号' },
|
||||
{ field: 'code', title: '编码', minWidth: 120 },
|
||||
{ field: 'name', title: '名称', minWidth: 160 },
|
||||
{ field: 'carrierCode', title: '承运商', minWidth: 90 },
|
||||
{ field: 'billingMode', title: '计费模式', minWidth: 130 },
|
||||
{
|
||||
title: '当前生效',
|
||||
minWidth: 120,
|
||||
slots: { default: 'effective' },
|
||||
},
|
||||
{ title: '状态', minWidth: 80, slots: { default: 'status' } },
|
||||
];
|
||||
|
||||
const actionColumn: NonNullable<
|
||||
VxeGridProps<ExpressQuoteVO.Info>['columns']
|
||||
>[number] = {
|
||||
title: '操作',
|
||||
minWidth: 160,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const tableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(tableBaseColumns ?? []), actionColumn]
|
||||
: (tableBaseColumns ?? []),
|
||||
);
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '名称/编码',
|
||||
allowClear: true,
|
||||
onChange: (e: Event) => {
|
||||
searchForm.value.keywords = (e.target as HTMLInputElement).value;
|
||||
},
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'keywords',
|
||||
label: '关键字',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '计费模式',
|
||||
allowClear: true,
|
||||
options: [
|
||||
{ label: 'FLAT', value: 'FLAT' },
|
||||
{ label: 'PER_KG', value: 'PER_KG' },
|
||||
{ label: 'REGION_WEIGHT', value: 'REGION_WEIGHT' },
|
||||
],
|
||||
onChange: (val: string | undefined) => {
|
||||
searchForm.value.billingMode = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'billingMode',
|
||||
label: '模式',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
handleSubmit: async () => gridReloadRef.value?.(),
|
||||
handleReset: async () => {
|
||||
searchForm.value = {
|
||||
keywords: '',
|
||||
billingMode: undefined,
|
||||
status: undefined,
|
||||
};
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
}));
|
||||
|
||||
const gridOptions: VxeGridProps<ExpressQuoteVO.Info> = {
|
||||
columns: tableColumns.value,
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ExpressQuoteDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
keywords: searchForm.value.keywords || undefined,
|
||||
billingMode: searchForm.value.billingMode,
|
||||
status: searchForm.value.status,
|
||||
},
|
||||
};
|
||||
const data = await getExpressQuotePageApi(params);
|
||||
return { items: data.records, total: data.total };
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '快递报价',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
syncVxeGridColumns(gridApi, tableColumns);
|
||||
|
||||
async function handleDelete(row: ExpressQuoteVO.Info) {
|
||||
await deleteExpressQuoteApi(row.id);
|
||||
message.success('删除成功');
|
||||
gridApi.reload();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="快递报价" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
公司级报价单(可多仓共用);支持一口价 / 按 kg / 分区首重续重;版本按生效日 as-of
|
||||
</div>
|
||||
</template>
|
||||
<Grid :loading="loading">
|
||||
<template #toolbar-tools>
|
||||
<PermissionGate code="ec:express-quote:create">
|
||||
<Button type="primary" @click="formModalRef?.open(false)">
|
||||
<PlusIcon />
|
||||
新建报价
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</template>
|
||||
<template #effective="{ row }: { row: ExpressQuoteVO.Info }">
|
||||
{{ row.currentVersion?.effectiveFrom || '—' }}
|
||||
</template>
|
||||
<template #status="{ row }: { row: ExpressQuoteVO.Info }">
|
||||
<Tag :color="row.status === 1 ? 'green' : 'red'">
|
||||
{{ row.status === 1 ? '启用' : '停用' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template
|
||||
v-if="showActionColumn"
|
||||
#action="{ row }: { row: ExpressQuoteVO.Info }"
|
||||
>
|
||||
<Space>
|
||||
<PermissionGate code="ec:express-quote:update">
|
||||
<Button size="small" @click="formModalRef?.open(true, row)">
|
||||
编辑/调价
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="ec:express-quote:delete">
|
||||
<Popconfirm title="确定删除?" @confirm="handleDelete(row)">
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
<ExpressQuoteFormModal ref="formModalRef" @success="gridApi.reload()" />
|
||||
</Page>
|
||||
</template>
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
<script lang="ts" setup>
|
||||
import type { WarehouseVO } from '#/api/ec/warehouse';
|
||||
import type { ExpressQuoteVO } from '#/api/ec/express-quote';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Drawer,
|
||||
Form,
|
||||
FormItem,
|
||||
InputNumber,
|
||||
message,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
addWarehouseBindApi,
|
||||
getWarehouseBindsApi,
|
||||
removeWarehouseBindApi,
|
||||
updateWarehouseBindApi,
|
||||
} from '#/api/ec/warehouse';
|
||||
import { getEnabledExpressQuotesApi } from '#/api/ec/express-quote';
|
||||
|
||||
const openFlag = ref(false);
|
||||
const warehouse = ref<WarehouseVO.Info | null>(null);
|
||||
const binds = ref<WarehouseVO.Bind[]>([]);
|
||||
const quotes = ref<ExpressQuoteVO.Info[]>([]);
|
||||
const loading = ref(false);
|
||||
const quoteId = ref<number>();
|
||||
const priority = ref(100);
|
||||
|
||||
async function open(row: WarehouseVO.Info) {
|
||||
warehouse.value = row;
|
||||
openFlag.value = true;
|
||||
await reload();
|
||||
quotes.value = await getEnabledExpressQuotesApi();
|
||||
}
|
||||
|
||||
async function reload() {
|
||||
if (!warehouse.value) return;
|
||||
loading.value = true;
|
||||
try {
|
||||
binds.value = await getWarehouseBindsApi(warehouse.value.id);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function addBind() {
|
||||
if (!warehouse.value || !quoteId.value) {
|
||||
message.warning('请选择报价单');
|
||||
return;
|
||||
}
|
||||
await addWarehouseBindApi({
|
||||
warehouseId: warehouse.value.id,
|
||||
quoteId: quoteId.value,
|
||||
priority: priority.value,
|
||||
});
|
||||
message.success('绑定成功');
|
||||
quoteId.value = undefined;
|
||||
await reload();
|
||||
}
|
||||
|
||||
async function changePriority(row: WarehouseVO.Bind, val: number) {
|
||||
await updateWarehouseBindApi(row.id, { priority: val });
|
||||
message.success('已更新优先级');
|
||||
await reload();
|
||||
}
|
||||
|
||||
async function remove(row: WarehouseVO.Bind) {
|
||||
await removeWarehouseBindApi(row.id);
|
||||
message.success('已解绑');
|
||||
await reload();
|
||||
}
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer
|
||||
v-model:open="openFlag"
|
||||
:title="`合作快递 — ${warehouse?.name || ''}`"
|
||||
width="640"
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="mb-4 flex flex-wrap items-end gap-2">
|
||||
<Form layout="inline">
|
||||
<FormItem label="报价单">
|
||||
<Select
|
||||
v-model:value="quoteId"
|
||||
allow-clear
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
style="width: 220px"
|
||||
:options="
|
||||
quotes.map((q) => ({
|
||||
value: q.id,
|
||||
label: `${q.name} (${q.carrierCode}/${q.billingMode})`,
|
||||
}))
|
||||
"
|
||||
placeholder="选择报价"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="优先级">
|
||||
<InputNumber v-model:value="priority" :min="1" style="width: 90px" />
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Button type="primary" @click="addBind">绑定</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</div>
|
||||
<p class="mb-2 text-xs text-slate-500">
|
||||
数字越小越优先;未发货订单按此顺序选价,已发货优先匹配承运商。
|
||||
</p>
|
||||
<Table
|
||||
:loading="loading"
|
||||
:data-source="binds"
|
||||
row-key="id"
|
||||
size="small"
|
||||
:pagination="false"
|
||||
:columns="[
|
||||
{ title: '报价', dataIndex: 'quoteName', key: 'quoteName' },
|
||||
{ title: '承运商', dataIndex: 'carrierCode', key: 'carrierCode', width: 90 },
|
||||
{ title: '模式', dataIndex: 'billingMode', key: 'billingMode', width: 120 },
|
||||
{ title: '优先级', key: 'priority', width: 110 },
|
||||
{ title: '状态', key: 'status', width: 80 },
|
||||
{ title: '操作', key: 'action', width: 80 },
|
||||
]"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'priority'">
|
||||
<InputNumber
|
||||
:value="(record as WarehouseVO.Bind).priority"
|
||||
:min="1"
|
||||
size="small"
|
||||
@change="(v) => changePriority(record as WarehouseVO.Bind, Number(v))"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'status'">
|
||||
<Tag :color="(record as WarehouseVO.Bind).status === 1 ? 'green' : 'red'">
|
||||
{{ (record as WarehouseVO.Bind).status === 1 ? '启用' : '停用' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<Popconfirm title="确定解绑?" @confirm="remove(record as WarehouseVO.Bind)">
|
||||
<Button type="link" danger size="small">解绑</Button>
|
||||
</Popconfirm>
|
||||
</template>
|
||||
</template>
|
||||
</Table>
|
||||
</Drawer>
|
||||
</template>
|
||||
@@ -0,0 +1,141 @@
|
||||
<script lang="ts" setup>
|
||||
import type { WarehouseDTO, WarehouseVO } from '#/api/ec/warehouse';
|
||||
|
||||
import { reactive, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, FormItem, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createWarehouseApi,
|
||||
updateWarehouseApi,
|
||||
} from '#/api/ec/warehouse';
|
||||
|
||||
const emit = defineEmits<{ success: [] }>();
|
||||
|
||||
const isEdit = ref(false);
|
||||
const editingId = ref<number>();
|
||||
const form = reactive({
|
||||
code: '',
|
||||
name: '',
|
||||
province: '',
|
||||
city: '',
|
||||
address: '',
|
||||
status: 1 as number,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
onConfirm: handleSubmit,
|
||||
onOpenChange: (open) => {
|
||||
if (!open) reset();
|
||||
},
|
||||
});
|
||||
|
||||
function reset() {
|
||||
form.code = '';
|
||||
form.name = '';
|
||||
form.province = '';
|
||||
form.city = '';
|
||||
form.address = '';
|
||||
form.status = 1;
|
||||
form.remark = '';
|
||||
editingId.value = undefined;
|
||||
isEdit.value = false;
|
||||
}
|
||||
|
||||
function open(edit: boolean, row?: WarehouseVO.Info) {
|
||||
isEdit.value = edit;
|
||||
if (edit && row) {
|
||||
editingId.value = row.id;
|
||||
form.code = row.code;
|
||||
form.name = row.name;
|
||||
form.province = row.province || '';
|
||||
form.city = row.city || '';
|
||||
form.address = row.address || '';
|
||||
form.status = row.status ?? 1;
|
||||
form.remark = row.remark || '';
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
modalApi.setState({ title: edit ? '编辑仓库' : '新建仓库' });
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!form.name.trim() || (!isEdit.value && !form.code.trim())) {
|
||||
message.warning('请填写编码与名称');
|
||||
return;
|
||||
}
|
||||
modalApi.setState({ confirming: true });
|
||||
try {
|
||||
if (isEdit.value && editingId.value) {
|
||||
const data: WarehouseDTO.Update = {
|
||||
name: form.name.trim(),
|
||||
province: form.province || undefined,
|
||||
city: form.city || undefined,
|
||||
address: form.address || undefined,
|
||||
status: form.status,
|
||||
remark: form.remark || undefined,
|
||||
};
|
||||
await updateWarehouseApi(editingId.value, data);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
const data: WarehouseDTO.Create = {
|
||||
code: form.code.trim(),
|
||||
name: form.name.trim(),
|
||||
province: form.province || undefined,
|
||||
city: form.city || undefined,
|
||||
address: form.address || undefined,
|
||||
status: form.status,
|
||||
remark: form.remark || undefined,
|
||||
};
|
||||
await createWarehouseApi(data);
|
||||
message.success('创建成功');
|
||||
}
|
||||
modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.setState({ confirming: false });
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-[520px]">
|
||||
<Form layout="vertical" class="px-1">
|
||||
<FormItem v-if="!isEdit" label="仓库编码" required>
|
||||
<Input v-model:value="form.code" placeholder="公司内唯一" />
|
||||
</FormItem>
|
||||
<FormItem label="仓库名称" required>
|
||||
<Input v-model:value="form.name" placeholder="如:华东仓" />
|
||||
</FormItem>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<FormItem label="省">
|
||||
<Input v-model:value="form.province" />
|
||||
</FormItem>
|
||||
<FormItem label="市">
|
||||
<Input v-model:value="form.city" />
|
||||
</FormItem>
|
||||
</div>
|
||||
<FormItem label="地址">
|
||||
<Input v-model:value="form.address" />
|
||||
</FormItem>
|
||||
<FormItem label="状态">
|
||||
<Select
|
||||
v-model:value="form.status"
|
||||
:options="[
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
]"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem label="备注">
|
||||
<Input.TextArea v-model:value="form.remark" :rows="2" />
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,192 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { WarehouseDTO, WarehouseVO } from '#/api/ec/warehouse';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteWarehouseApi, getWarehousePageApi } from '#/api/ec/warehouse';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
|
||||
import WarehouseBindDrawer from './components/WarehouseBindDrawer.vue';
|
||||
import WarehouseFormModal from './components/WarehouseFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'WarehouseManagement' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const loading = ref(false);
|
||||
const formModalRef = ref<InstanceType<typeof WarehouseFormModal> | null>(null);
|
||||
const bindDrawerRef = ref<InstanceType<typeof WarehouseBindDrawer> | null>(null);
|
||||
const searchForm = ref({ keywords: '', status: undefined as number | undefined });
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const actionCodes = [
|
||||
'ec:warehouse:create',
|
||||
'ec:warehouse:update',
|
||||
'ec:warehouse:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(actionCodes);
|
||||
|
||||
const tableBaseColumns: VxeGridProps<WarehouseVO.Info>['columns'] = [
|
||||
{ type: 'seq' as const, minWidth: 'auto', title: '序号' },
|
||||
{ field: 'code', title: '编码', minWidth: 120 },
|
||||
{ field: 'name', title: '名称', minWidth: 140 },
|
||||
{ field: 'province', title: '省', minWidth: 90 },
|
||||
{ field: 'city', title: '市', minWidth: 90 },
|
||||
{ field: 'bindCount', title: '报价绑定', minWidth: 90 },
|
||||
{ title: '状态', minWidth: 80, slots: { default: 'status' } },
|
||||
{ field: 'createTime', title: '创建时间', minWidth: 170 },
|
||||
];
|
||||
|
||||
const actionColumn: NonNullable<VxeGridProps<WarehouseVO.Info>['columns']>[number] =
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 220,
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const tableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(tableBaseColumns ?? []), actionColumn]
|
||||
: (tableBaseColumns ?? []),
|
||||
);
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '名称/编码',
|
||||
allowClear: true,
|
||||
onChange: (e: Event) => {
|
||||
searchForm.value.keywords = (e.target as HTMLInputElement).value;
|
||||
},
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'keywords',
|
||||
label: '关键字',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '状态',
|
||||
allowClear: true,
|
||||
options: [
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
],
|
||||
onChange: (val: number | undefined) => {
|
||||
searchForm.value.status = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
handleSubmit: async () => gridReloadRef.value?.(),
|
||||
handleReset: async () => {
|
||||
searchForm.value = { keywords: '', status: undefined };
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
}));
|
||||
|
||||
const gridOptions: VxeGridProps<WarehouseVO.Info> = {
|
||||
columns: tableColumns.value,
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<WarehouseDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
keywords: searchForm.value.keywords || undefined,
|
||||
status: searchForm.value.status,
|
||||
},
|
||||
};
|
||||
const data = await getWarehousePageApi(params);
|
||||
return { items: data.records, total: data.total };
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '发货仓库',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
syncVxeGridColumns(gridApi, tableColumns);
|
||||
|
||||
async function handleDelete(row: WarehouseVO.Info) {
|
||||
await deleteWarehouseApi(row.id);
|
||||
message.success('删除成功');
|
||||
gridApi.reload();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="发货仓库" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
配置发货仓与快递报价绑定(无库存);SKU 可指定默认仓用于运费估算
|
||||
</div>
|
||||
</template>
|
||||
<Grid :loading="loading">
|
||||
<template #toolbar-tools>
|
||||
<PermissionGate code="ec:warehouse:create">
|
||||
<Button type="primary" @click="formModalRef?.open(false)">
|
||||
<PlusIcon />
|
||||
新建仓库
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</template>
|
||||
<template #status="{ row }: { row: WarehouseVO.Info }">
|
||||
<Tag :color="row.status === 1 ? 'green' : 'red'">
|
||||
{{ row.status === 1 ? '启用' : '停用' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template v-if="showActionColumn" #action="{ row }: { row: WarehouseVO.Info }">
|
||||
<Space>
|
||||
<PermissionGate code="ec:warehouse:update">
|
||||
<Button size="small" @click="bindDrawerRef?.open(row)">快递</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="ec:warehouse:update">
|
||||
<Button size="small" @click="formModalRef?.open(true, row)">编辑</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="ec:warehouse:delete">
|
||||
<Popconfirm title="确定删除该仓库?" @confirm="handleDelete(row)">
|
||||
<Button size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
<WarehouseFormModal ref="formModalRef" @success="gridApi.reload()" />
|
||||
<WarehouseBindDrawer ref="bindDrawerRef" />
|
||||
</Page>
|
||||
</template>
|
||||
Reference in New Issue
Block a user