feat(mes/wm): 迁移仓库基础到 vben5 antd/ele
parent
ec5b607171
commit
2d1325f11a
|
|
@ -0,0 +1,42 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace MesQcDefectRecordApi {
|
||||||
|
/** MES 质检缺陷记录 */
|
||||||
|
export interface DefectRecord {
|
||||||
|
id?: number; // 编号
|
||||||
|
qcType?: number; // 检验类型
|
||||||
|
qcId?: number; // 检验单 ID
|
||||||
|
lineId?: number; // 检验行 ID
|
||||||
|
name?: string; // 缺陷描述
|
||||||
|
level?: number; // 缺陷等级
|
||||||
|
quantity?: number; // 缺陷数量
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询质检缺陷记录分页 */
|
||||||
|
export function getDefectRecordPage(
|
||||||
|
params: PageParam & { lineId?: number; qcId?: number; qcType?: number; },
|
||||||
|
) {
|
||||||
|
return requestClient.get<PageResult<MesQcDefectRecordApi.DefectRecord>>(
|
||||||
|
'/mes/qc/defect-record/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增质检缺陷记录 */
|
||||||
|
export function createDefectRecord(data: MesQcDefectRecordApi.DefectRecord) {
|
||||||
|
return requestClient.post('/mes/qc/defect-record/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改质检缺陷记录 */
|
||||||
|
export function updateDefectRecord(data: MesQcDefectRecordApi.DefectRecord) {
|
||||||
|
return requestClient.put('/mes/qc/defect-record/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除质检缺陷记录 */
|
||||||
|
export function deleteDefectRecord(id: number) {
|
||||||
|
return requestClient.delete(`/mes/qc/defect-record/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace MesQcIndicatorResultApi {
|
||||||
|
/** MES 检验结果明细 */
|
||||||
|
export interface IndicatorResultDetail {
|
||||||
|
id?: number; // 编号
|
||||||
|
resultId?: number; // 关联检验结果 ID
|
||||||
|
indicatorId?: number; // 检测指标 ID
|
||||||
|
value?: string; // 检测值(统一存为字符串)
|
||||||
|
valueNumber?: number; // UI 数值绑定(提交前转字符串)
|
||||||
|
remark?: string; // 备注
|
||||||
|
// 关联查询字段(来自 indicator)
|
||||||
|
indicatorName?: string; // 检测指标名称
|
||||||
|
valueType?: number; // 质检值类型
|
||||||
|
valueSpecification?: string; // 值属性
|
||||||
|
}
|
||||||
|
|
||||||
|
/** MES 检验结果 */
|
||||||
|
export interface IndicatorResult {
|
||||||
|
id?: number; // 编号
|
||||||
|
code?: string; // 样品编号
|
||||||
|
qcId?: number; // 关联质检单 ID
|
||||||
|
qcType?: number; // 质检类型
|
||||||
|
itemId?: number; // 产品物料 ID
|
||||||
|
sn?: string; // 物资 SN
|
||||||
|
remark?: string; // 备注
|
||||||
|
createTime?: Date; // 创建时间
|
||||||
|
items?: IndicatorResultDetail[]; // 检验结果明细列表
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询检验结果分页 */
|
||||||
|
export function getIndicatorResultPage(
|
||||||
|
params: PageParam & { qcId?: number; qcType?: number },
|
||||||
|
) {
|
||||||
|
return requestClient.get<PageResult<MesQcIndicatorResultApi.IndicatorResult>>(
|
||||||
|
'/mes/qc/indicator-result/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询检验结果明细(含检测项模板):编辑传 id,新增不传 */
|
||||||
|
export function getIndicatorResultDetail(
|
||||||
|
qcId: number,
|
||||||
|
qcType: number,
|
||||||
|
id?: number,
|
||||||
|
) {
|
||||||
|
return requestClient.get<MesQcIndicatorResultApi.IndicatorResult>(
|
||||||
|
'/mes/qc/indicator-result/get-detail',
|
||||||
|
{ params: { id, qcId, qcType } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增检验结果 */
|
||||||
|
export function createIndicatorResult(
|
||||||
|
data: MesQcIndicatorResultApi.IndicatorResult,
|
||||||
|
) {
|
||||||
|
return requestClient.post('/mes/qc/indicator-result/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改检验结果 */
|
||||||
|
export function updateIndicatorResult(
|
||||||
|
data: MesQcIndicatorResultApi.IndicatorResult,
|
||||||
|
) {
|
||||||
|
return requestClient.put('/mes/qc/indicator-result/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除检验结果 */
|
||||||
|
export function deleteIndicatorResult(id: number) {
|
||||||
|
return requestClient.delete(`/mes/qc/indicator-result/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace MesQcIqcApi {
|
||||||
|
/** MES 来料检验单 */
|
||||||
|
export interface Iqc {
|
||||||
|
id?: number; // 编号
|
||||||
|
code?: string; // 检验单编号
|
||||||
|
name?: string; // 检验单名称
|
||||||
|
templateId?: number; // 检验模板 ID
|
||||||
|
sourceDocType?: number; // 来源单据类型
|
||||||
|
sourceDocId?: number; // 来源单据 ID
|
||||||
|
sourceLineId?: number; // 来源单据行 ID
|
||||||
|
sourceDocCode?: string; // 来源单据编号(关联查询)
|
||||||
|
vendorId?: number; // 供应商 ID
|
||||||
|
vendorNickname?: string; // 供应商简称(关联查询)
|
||||||
|
vendorBatch?: string; // 供应商批次号
|
||||||
|
itemId?: number; // 产品物料 ID
|
||||||
|
itemCode?: string; // 产品物料编码(关联查询)
|
||||||
|
itemName?: string; // 产品物料名称(关联查询)
|
||||||
|
itemSpecification?: string; // 规格型号(关联查询)
|
||||||
|
unitName?: string; // 单位名称(关联查询)
|
||||||
|
receivedQuantity?: number; // 本次接收数量
|
||||||
|
checkQuantity?: number; // 本次检测数量
|
||||||
|
qualifiedQuantity?: number; // 合格品数量
|
||||||
|
unqualifiedQuantity?: number; // 不合格品数量
|
||||||
|
criticalRate?: number; // 致命缺陷率(%)
|
||||||
|
majorRate?: number; // 严重缺陷率(%)
|
||||||
|
minorRate?: number; // 轻微缺陷率(%)
|
||||||
|
criticalQuantity?: number; // 致命缺陷数量
|
||||||
|
majorQuantity?: number; // 严重缺陷数量
|
||||||
|
minorQuantity?: number; // 轻微缺陷数量
|
||||||
|
checkResult?: number; // 检测结果
|
||||||
|
receiveDate?: number; // 来料日期
|
||||||
|
inspectDate?: number; // 检测日期
|
||||||
|
inspector?: string; // 检测人员(昵称)
|
||||||
|
inspectorUserId?: number; // 检测人员 ID
|
||||||
|
inspectorNickname?: string; // 检测人员昵称(关联查询)
|
||||||
|
status?: number; // 状态
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询来料检验单分页 */
|
||||||
|
export function getIqcPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<MesQcIqcApi.Iqc>>('/mes/qc/iqc/page', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询来料检验单详情 */
|
||||||
|
export function getIqc(id: number) {
|
||||||
|
return requestClient.get<MesQcIqcApi.Iqc>(`/mes/qc/iqc/get?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增来料检验单 */
|
||||||
|
export function createIqc(data: MesQcIqcApi.Iqc) {
|
||||||
|
return requestClient.post('/mes/qc/iqc/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改来料检验单 */
|
||||||
|
export function updateIqc(data: MesQcIqcApi.Iqc) {
|
||||||
|
return requestClient.put('/mes/qc/iqc/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 完成来料检验单 */
|
||||||
|
export function finishIqc(id: number) {
|
||||||
|
return requestClient.put(`/mes/qc/iqc/finish?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除来料检验单 */
|
||||||
|
export function deleteIqc(id: number) {
|
||||||
|
return requestClient.delete(`/mes/qc/iqc/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出来料检验单 */
|
||||||
|
export function exportIqc(params: any) {
|
||||||
|
return requestClient.download('/mes/qc/iqc/export-excel', { params });
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace MesQcIqcLineApi {
|
||||||
|
/** MES 来料检验单行 */
|
||||||
|
export interface IqcLine {
|
||||||
|
id?: number; // 编号
|
||||||
|
iqcId?: number; // 来料检验单 ID
|
||||||
|
indicatorId?: number; // 检测指标 ID
|
||||||
|
indicatorCode?: string; // 检测指标编码(关联查询)
|
||||||
|
indicatorName?: string; // 检测指标名称(关联查询)
|
||||||
|
indicatorType?: number; // 检测指标类型(关联查询)
|
||||||
|
tool?: string; // 检测工具
|
||||||
|
checkMethod?: string; // 检测方法
|
||||||
|
standardValue?: number; // 标准值
|
||||||
|
unitMeasureId?: number; // 计量单位 ID
|
||||||
|
unitMeasureName?: string; // 计量单位名称(关联查询)
|
||||||
|
maxThreshold?: number; // 误差上限
|
||||||
|
minThreshold?: number; // 误差下限
|
||||||
|
criticalQuantity?: number; // 致命缺陷数量
|
||||||
|
majorQuantity?: number; // 严重缺陷数量
|
||||||
|
minorQuantity?: number; // 轻微缺陷数量
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询来料检验单行分页 */
|
||||||
|
export function getIqcLinePage(params: PageParam & { iqcId?: number }) {
|
||||||
|
return requestClient.get<PageResult<MesQcIqcLineApi.IqcLine>>(
|
||||||
|
'/mes/qc/iqc/line/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询来料检验单行详情 */
|
||||||
|
export function getIqcLine(id: number) {
|
||||||
|
return requestClient.get<MesQcIqcLineApi.IqcLine>(
|
||||||
|
`/mes/qc/iqc/line/get?id=${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
|
const routes: RouteRecordRaw[] = [
|
||||||
|
{
|
||||||
|
path: '/mes',
|
||||||
|
name: 'MesCenter',
|
||||||
|
meta: {
|
||||||
|
title: 'MES 制造执行',
|
||||||
|
icon: 'lucide:factory',
|
||||||
|
keepAlive: true,
|
||||||
|
hideInMenu: true,
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'wm/warehouse/location',
|
||||||
|
name: 'MesWmLocation',
|
||||||
|
meta: {
|
||||||
|
title: '库区设置',
|
||||||
|
activePath: '/mes/wm/warehouse',
|
||||||
|
},
|
||||||
|
component: () =>
|
||||||
|
import('#/views/mes/wm/warehouse/location/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'wm/warehouse/area',
|
||||||
|
name: 'MesWmArea',
|
||||||
|
meta: {
|
||||||
|
title: '库位设置',
|
||||||
|
activePath: '/mes/wm/warehouse',
|
||||||
|
},
|
||||||
|
component: () => import('#/views/mes/wm/warehouse/area/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'wm/barcode/config',
|
||||||
|
name: 'MesWmBarcodeConfig',
|
||||||
|
meta: {
|
||||||
|
title: '条码配置',
|
||||||
|
activePath: '/mes/wm/barcode',
|
||||||
|
},
|
||||||
|
component: () => import('#/views/mes/wm/barcode/config/index.vue'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default routes;
|
||||||
|
|
@ -0,0 +1,339 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseAreaApi } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
import { Button } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
|
||||||
|
import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
/** 表单类型 */
|
||||||
|
export type FormType = 'create' | 'detail' | 'update';
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(
|
||||||
|
formType: FormType,
|
||||||
|
formApi?: VbenFormApi,
|
||||||
|
): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: { triggerFields: [''], show: () => false },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'warehouseId',
|
||||||
|
label: '所属仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
// 仓库变更时清空所属库区
|
||||||
|
onChange: () => formApi?.setFieldValue('locationId', undefined),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'locationId',
|
||||||
|
label: '所属库区',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['warehouseId'],
|
||||||
|
componentProps: (values) => ({
|
||||||
|
allowClear: true,
|
||||||
|
api: () =>
|
||||||
|
getWarehouseLocationSimpleList(values.warehouseId as number),
|
||||||
|
// 改变 warehouseId 时强制刷新选项
|
||||||
|
params: { warehouseId: values.warehouseId },
|
||||||
|
disabled: !values.warehouseId,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
placeholder: '请选择库区',
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '库位编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入库位编码',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
suffix:
|
||||||
|
formType === 'detail'
|
||||||
|
? undefined
|
||||||
|
: () =>
|
||||||
|
h(
|
||||||
|
Button,
|
||||||
|
{
|
||||||
|
type: 'default',
|
||||||
|
onClick: async () => {
|
||||||
|
try {
|
||||||
|
const code = await generateAutoCode(
|
||||||
|
MesAutoCodeRuleCode.WM_AREA_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '自动生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '库位名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入库位名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'area',
|
||||||
|
label: '面积(㎡)',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
precision: 2,
|
||||||
|
placeholder: '请输入面积',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'maxLoad',
|
||||||
|
label: '最大载重',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
precision: 2,
|
||||||
|
placeholder: '请输入最大载重',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionX',
|
||||||
|
label: '位置 X',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 X',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionY',
|
||||||
|
label: '位置 Y',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 Y',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionZ',
|
||||||
|
label: '位置 Z',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 Z',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||||
|
placeholder: '请选择',
|
||||||
|
},
|
||||||
|
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'frozen',
|
||||||
|
label: '是否冻结',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
checkedChildren: '是',
|
||||||
|
unCheckedChildren: '否',
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(false),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'allowItemMixing',
|
||||||
|
label: '允许物料混放',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
checkedChildren: '是',
|
||||||
|
unCheckedChildren: '否',
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'allowBatchMixing',
|
||||||
|
label: '允许批次混放',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
checkedChildren: '是',
|
||||||
|
unCheckedChildren: '否',
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '库位编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入库位编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '库位名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入库位名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionX',
|
||||||
|
label: '位置 X',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 X',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionY',
|
||||||
|
label: '位置 Y',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 Y',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionZ',
|
||||||
|
label: '位置 Z',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 Z',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmWarehouseAreaApi.WarehouseArea>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '库位编码',
|
||||||
|
minWidth: 140,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '库位名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'area',
|
||||||
|
title: '面积(㎡)',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'maxLoad',
|
||||||
|
title: '最大载重',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'positionX',
|
||||||
|
title: '位置 X',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'positionY',
|
||||||
|
title: '位置 Y',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'positionZ',
|
||||||
|
title: '位置 Z',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
width: 90,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'frozen',
|
||||||
|
title: '冻结',
|
||||||
|
width: 90,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 200,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,219 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseAreaApi } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { Alert, Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deleteWarehouseArea,
|
||||||
|
getWarehouseAreaPage,
|
||||||
|
} from '#/api/mes/wm/warehouse/area';
|
||||||
|
import { getWarehouseLocation } from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
import { BarcodeDetail } from '../../barcode/components';
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
/** 当前库区上下文(同步从 URL 解析,确保首次查询带得上 locationId) */
|
||||||
|
const currentLocation = ref<{
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
warehouseId: number;
|
||||||
|
warehouseName: string;
|
||||||
|
}>(
|
||||||
|
(() => {
|
||||||
|
const id = Number(route.query.locationId);
|
||||||
|
return Number.isInteger(id) && id > 0
|
||||||
|
? { id, name: '', warehouseId: 0, warehouseName: '' }
|
||||||
|
: { id: 0, name: '', warehouseId: 0, warehouseName: '' };
|
||||||
|
})(),
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 异步加载库区/仓库名称(不阻塞列表查询) */
|
||||||
|
async function loadLocationName() {
|
||||||
|
if (!currentLocation.value.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const location = await getWarehouseLocation(currentLocation.value.id);
|
||||||
|
currentLocation.value.name = location.name || '';
|
||||||
|
currentLocation.value.warehouseId = location.warehouseId || 0;
|
||||||
|
currentLocation.value.warehouseName = location.warehouseName || '';
|
||||||
|
} catch {
|
||||||
|
// 忽略上级名称加载异常,不影响列表查询
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadLocationName();
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建库位 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi
|
||||||
|
.setData({
|
||||||
|
formType: 'create',
|
||||||
|
locationId: currentLocation.value.id || undefined,
|
||||||
|
warehouseId: currentLocation.value.warehouseId || undefined,
|
||||||
|
})
|
||||||
|
.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看库位详情 */
|
||||||
|
function handleDetail(row: MesWmWarehouseAreaApi.WarehouseArea) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑库位 */
|
||||||
|
function handleEdit(row: MesWmWarehouseAreaApi.WarehouseArea) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除库位 */
|
||||||
|
async function handleDelete(row: MesWmWarehouseAreaApi.WarehouseArea) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteWarehouseArea(row.id!);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看库位条码 */
|
||||||
|
function handleBarcode(row: MesWmWarehouseAreaApi.WarehouseArea) {
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
row.id!,
|
||||||
|
BarcodeBizTypeEnum.AREA,
|
||||||
|
row.code,
|
||||||
|
row.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getWarehouseAreaPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
locationId: currentLocation.value.id || undefined,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmWarehouseAreaApi.WarehouseArea>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】仓库与库区库位、条码赋码、SN码"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/warehouse-setup/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<FormModal @success="handleRefresh" />
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
|
||||||
|
<Alert
|
||||||
|
v-if="currentLocation.id"
|
||||||
|
class="mb-3"
|
||||||
|
:message="`当前仓库/库区:${currentLocation.warehouseName || `#${currentLocation.warehouseId || '-'}`} / ${currentLocation.name || `#${currentLocation.id}`}`"
|
||||||
|
show-icon
|
||||||
|
type="info"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Grid table-title="库位列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.create', ['库位']),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['mes:wm-warehouse:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #code="{ row }">
|
||||||
|
<Button type="link" @click="handleDetail(row)">
|
||||||
|
{{ row.code }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['mes:wm-warehouse:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm-warehouse:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '条码',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleBarcode.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmWarehouseAreaApi } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createWarehouseArea,
|
||||||
|
getWarehouseArea,
|
||||||
|
updateWarehouseArea,
|
||||||
|
} from '#/api/mes/wm/warehouse/area';
|
||||||
|
import { getWarehouseLocation } from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formType = ref<FormType>('create');
|
||||||
|
const formData = ref<MesWmWarehouseAreaApi.WarehouseArea>();
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['库位']);
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['库位'])
|
||||||
|
: $t('ui.actionTitle.create', ['库位']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-1',
|
||||||
|
labelWidth: 120,
|
||||||
|
},
|
||||||
|
wrapperClass: 'grid-cols-3',
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [],
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 查看条码 */
|
||||||
|
function handleBarcode() {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
formData.value.id,
|
||||||
|
BarcodeBizTypeEnum.AREA,
|
||||||
|
formData.value.code,
|
||||||
|
formData.value.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
await modalApi.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data =
|
||||||
|
(await formApi.getValues()) as MesWmWarehouseAreaApi.WarehouseArea;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateWarehouseArea(data)
|
||||||
|
: createWarehouseArea(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<{
|
||||||
|
formType: FormType;
|
||||||
|
id?: number;
|
||||||
|
locationId?: number;
|
||||||
|
warehouseId?: number;
|
||||||
|
}>();
|
||||||
|
formType.value = data.formType;
|
||||||
|
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||||
|
if (data?.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getWarehouseArea(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 新增态:根据父级上下文带入仓库/库区
|
||||||
|
let warehouseId = data?.warehouseId;
|
||||||
|
if (data?.locationId) {
|
||||||
|
if (!warehouseId) {
|
||||||
|
try {
|
||||||
|
const location = await getWarehouseLocation(data.locationId);
|
||||||
|
warehouseId = location.warehouseId;
|
||||||
|
} catch {
|
||||||
|
// 忽略
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await formApi.setValues({
|
||||||
|
warehouseId,
|
||||||
|
locationId: data.locationId,
|
||||||
|
});
|
||||||
|
} else if (warehouseId) {
|
||||||
|
await formApi.setFieldValue('warehouseId', warehouseId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-3/5">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
<template v-if="formType === 'detail' && formData?.id" #prepend-footer>
|
||||||
|
<Button @click="handleBarcode"> 查看条码 </Button>
|
||||||
|
</template>
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
export { default as WmWarehouseAreaSelect } from './wm-warehouse-area-select.vue';
|
||||||
|
export { default as WmWarehouseLocationSelect } from './wm-warehouse-location-select.vue';
|
||||||
|
export { default as WmWarehouseSelect } from './wm-warehouse-select.vue';
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmWarehouseAreaApi } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
import { computed, ref, useAttrs, watch, watchEffect } from 'vue';
|
||||||
|
|
||||||
|
import { Select, SelectOption, Tag, Tooltip } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getWarehouseAreaSimpleList } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
defineOptions({ name: 'WmWarehouseAreaSelect', inheritAttrs: false });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
allowClear?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
locationId?: number;
|
||||||
|
modelValue?: number;
|
||||||
|
placeholder?: string;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
allowClear: true,
|
||||||
|
disabled: false,
|
||||||
|
locationId: undefined,
|
||||||
|
modelValue: undefined,
|
||||||
|
placeholder: '请选择库位',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
change: [item: MesWmWarehouseAreaApi.WarehouseArea | undefined];
|
||||||
|
'update:modelValue': [value: number | undefined];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const attrs = useAttrs();
|
||||||
|
const allList = ref<MesWmWarehouseAreaApi.WarehouseArea[]>([]);
|
||||||
|
const selectedItem = ref<MesWmWarehouseAreaApi.WarehouseArea>();
|
||||||
|
|
||||||
|
const selectValue = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (val) => emit('update:modelValue', val),
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 选中变化 */
|
||||||
|
function handleChange(val: any) {
|
||||||
|
const item = allList.value.find((o) => o.id === val);
|
||||||
|
selectedItem.value = item;
|
||||||
|
emit('change', item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 前端过滤(name + code) */
|
||||||
|
function filterOption(input: string, option: any) {
|
||||||
|
const item = allList.value.find((o) => o.id === option.value);
|
||||||
|
if (!item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const keyword = input.toLowerCase();
|
||||||
|
return (
|
||||||
|
!!item.name?.toLowerCase().includes(keyword) ||
|
||||||
|
!!item.code?.toLowerCase().includes(keyword)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(val) => {
|
||||||
|
if (val == null) {
|
||||||
|
selectedItem.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (selectedItem.value?.id !== val && allList.value.length > 0) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 库区变更或初始化时重新加载库位列表 */
|
||||||
|
watchEffect(async () => {
|
||||||
|
allList.value = await getWarehouseAreaSimpleList(props.locationId);
|
||||||
|
if (props.modelValue != null) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === props.modelValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Tooltip :mouse-enter-delay="0.5" :open="selectedItem ? undefined : false">
|
||||||
|
<template #title>
|
||||||
|
<div v-if="selectedItem" class="leading-6">
|
||||||
|
<div>编码:{{ selectedItem.code || '-' }}</div>
|
||||||
|
<div>名称:{{ selectedItem.name || '-' }}</div>
|
||||||
|
<div>所属仓库:{{ selectedItem.warehouseName || '-' }}</div>
|
||||||
|
<div>所属库区:{{ selectedItem.locationName || '-' }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<Select
|
||||||
|
v-bind="attrs"
|
||||||
|
v-model:value="selectValue"
|
||||||
|
:allow-clear="allowClear"
|
||||||
|
class="!w-full"
|
||||||
|
:disabled="disabled"
|
||||||
|
:filter-option="filterOption"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
show-search
|
||||||
|
@change="handleChange"
|
||||||
|
>
|
||||||
|
<SelectOption v-for="item in allList" :key="item.id" :value="item.id">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span>{{ item.name }}</span>
|
||||||
|
<Tag v-if="item.code" color="blue">编号: {{ item.code }}</Tag>
|
||||||
|
</div>
|
||||||
|
</SelectOption>
|
||||||
|
</Select>
|
||||||
|
</Tooltip>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmWarehouseLocationApi } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
import { computed, ref, useAttrs, watch, watchEffect } from 'vue';
|
||||||
|
|
||||||
|
import { Select, SelectOption, Tag, Tooltip } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
defineOptions({ name: 'WmWarehouseLocationSelect', inheritAttrs: false });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
allowClear?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
modelValue?: number;
|
||||||
|
placeholder?: string;
|
||||||
|
warehouseId?: number;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
allowClear: true,
|
||||||
|
disabled: false,
|
||||||
|
modelValue: undefined,
|
||||||
|
placeholder: '请选择库区',
|
||||||
|
warehouseId: undefined,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
change: [item: MesWmWarehouseLocationApi.WarehouseLocation | undefined];
|
||||||
|
'update:modelValue': [value: number | undefined];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const attrs = useAttrs();
|
||||||
|
const allList = ref<MesWmWarehouseLocationApi.WarehouseLocation[]>([]);
|
||||||
|
const selectedItem = ref<MesWmWarehouseLocationApi.WarehouseLocation>();
|
||||||
|
|
||||||
|
const selectValue = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (val) => emit('update:modelValue', val),
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 选中变化 */
|
||||||
|
function handleChange(val: any) {
|
||||||
|
const item = allList.value.find((o) => o.id === val);
|
||||||
|
selectedItem.value = item;
|
||||||
|
emit('change', item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 前端过滤(name + code) */
|
||||||
|
function filterOption(input: string, option: any) {
|
||||||
|
const item = allList.value.find((o) => o.id === option.value);
|
||||||
|
if (!item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const keyword = input.toLowerCase();
|
||||||
|
return (
|
||||||
|
!!item.name?.toLowerCase().includes(keyword) ||
|
||||||
|
!!item.code?.toLowerCase().includes(keyword)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(val) => {
|
||||||
|
if (val == null) {
|
||||||
|
selectedItem.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (selectedItem.value?.id !== val && allList.value.length > 0) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 仓库变更或初始化时重新加载库区列表 */
|
||||||
|
watchEffect(async () => {
|
||||||
|
allList.value = await getWarehouseLocationSimpleList(props.warehouseId);
|
||||||
|
if (props.modelValue != null) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === props.modelValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Tooltip :mouse-enter-delay="0.5" :open="selectedItem ? undefined : false">
|
||||||
|
<template #title>
|
||||||
|
<div v-if="selectedItem" class="leading-6">
|
||||||
|
<div>编码:{{ selectedItem.code || '-' }}</div>
|
||||||
|
<div>名称:{{ selectedItem.name || '-' }}</div>
|
||||||
|
<div>所属仓库:{{ selectedItem.warehouseName || '-' }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<Select
|
||||||
|
v-bind="attrs"
|
||||||
|
v-model:value="selectValue"
|
||||||
|
:allow-clear="allowClear"
|
||||||
|
class="!w-full"
|
||||||
|
:disabled="disabled"
|
||||||
|
:filter-option="filterOption"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
show-search
|
||||||
|
@change="handleChange"
|
||||||
|
>
|
||||||
|
<SelectOption v-for="item in allList" :key="item.id" :value="item.id">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span>{{ item.name }}</span>
|
||||||
|
<Tag v-if="item.code" color="blue">编号: {{ item.code }}</Tag>
|
||||||
|
</div>
|
||||||
|
</SelectOption>
|
||||||
|
</Select>
|
||||||
|
</Tooltip>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
|
||||||
|
import { computed, onMounted, ref, useAttrs, watch } from 'vue';
|
||||||
|
|
||||||
|
import { Select, SelectOption, Tag, Tooltip } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
|
||||||
|
|
||||||
|
defineOptions({ name: 'WmWarehouseSelect', inheritAttrs: false });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
allowClear?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
modelValue?: number;
|
||||||
|
placeholder?: string;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
allowClear: true,
|
||||||
|
disabled: false,
|
||||||
|
modelValue: undefined,
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
change: [item: MesWmWarehouseApi.Warehouse | undefined];
|
||||||
|
'update:modelValue': [value: number | undefined];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const attrs = useAttrs();
|
||||||
|
const allList = ref<MesWmWarehouseApi.Warehouse[]>([]);
|
||||||
|
const selectedItem = ref<MesWmWarehouseApi.Warehouse>();
|
||||||
|
|
||||||
|
const selectValue = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (val) => emit('update:modelValue', val),
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 选中变化 */
|
||||||
|
function handleChange(val: any) {
|
||||||
|
const item = allList.value.find((o) => o.id === val);
|
||||||
|
selectedItem.value = item;
|
||||||
|
emit('change', item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 前端过滤(name + code) */
|
||||||
|
function filterOption(input: string, option: any) {
|
||||||
|
const item = allList.value.find((o) => o.id === option.value);
|
||||||
|
if (!item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const keyword = input.toLowerCase();
|
||||||
|
return (
|
||||||
|
!!item.name?.toLowerCase().includes(keyword) ||
|
||||||
|
!!item.code?.toLowerCase().includes(keyword)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(val) => {
|
||||||
|
if (val == null) {
|
||||||
|
selectedItem.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (selectedItem.value?.id !== val && allList.value.length > 0) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
allList.value = await getWarehouseSimpleList();
|
||||||
|
if (props.modelValue != null) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === props.modelValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Tooltip :mouse-enter-delay="0.5" :open="selectedItem ? undefined : false">
|
||||||
|
<template #title>
|
||||||
|
<div v-if="selectedItem" class="leading-6">
|
||||||
|
<div>编码:{{ selectedItem.code || '-' }}</div>
|
||||||
|
<div>名称:{{ selectedItem.name || '-' }}</div>
|
||||||
|
<div>地址:{{ selectedItem.address || '-' }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<Select
|
||||||
|
v-bind="attrs"
|
||||||
|
v-model:value="selectValue"
|
||||||
|
:allow-clear="allowClear"
|
||||||
|
class="!w-full"
|
||||||
|
:disabled="disabled"
|
||||||
|
:filter-option="filterOption"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
show-search
|
||||||
|
@change="handleChange"
|
||||||
|
>
|
||||||
|
<SelectOption v-for="item in allList" :key="item.id" :value="item.id">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span>{{ item.name }}</span>
|
||||||
|
<Tag v-if="item.code" color="blue">编号: {{ item.code }}</Tag>
|
||||||
|
</div>
|
||||||
|
</SelectOption>
|
||||||
|
</Select>
|
||||||
|
</Tooltip>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,226 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
import type { SystemUserApi } from '#/api/system/user';
|
||||||
|
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
|
||||||
|
import { Button } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getSimpleUserList } from '#/api/system/user';
|
||||||
|
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
/** 表单类型 */
|
||||||
|
export type FormType = 'create' | 'detail' | 'update';
|
||||||
|
|
||||||
|
/** 关联数据 */
|
||||||
|
let userList: SystemUserApi.User[] = [];
|
||||||
|
getSimpleUserList().then((data) => (userList = data));
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(
|
||||||
|
formType: FormType,
|
||||||
|
formApi?: VbenFormApi,
|
||||||
|
): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '仓库编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓库编码',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
suffix:
|
||||||
|
formType === 'detail'
|
||||||
|
? undefined
|
||||||
|
: () =>
|
||||||
|
h(
|
||||||
|
Button,
|
||||||
|
{
|
||||||
|
type: 'default',
|
||||||
|
onClick: async () => {
|
||||||
|
try {
|
||||||
|
const code = await generateAutoCode(
|
||||||
|
MesAutoCodeRuleCode.WM_WAREHOUSE_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '自动生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '仓库名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓库名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'chargeUserId',
|
||||||
|
label: '负责人',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
api: getSimpleUserList,
|
||||||
|
labelField: 'nickname',
|
||||||
|
valueField: 'id',
|
||||||
|
placeholder: '请选择负责人',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'address',
|
||||||
|
label: '仓库地址',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓库地址',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'area',
|
||||||
|
label: '面积(㎡)',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
precision: 2,
|
||||||
|
placeholder: '请输入面积',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'frozen',
|
||||||
|
label: '是否冻结',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
checkedChildren: '是',
|
||||||
|
unCheckedChildren: '否',
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(false),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '仓库编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入仓库编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '仓库名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入仓库名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'frozen',
|
||||||
|
label: '是否冻结',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: [
|
||||||
|
{ label: '是', value: true },
|
||||||
|
{ label: '否', value: false },
|
||||||
|
],
|
||||||
|
placeholder: '请选择',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmWarehouseApi.Warehouse>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '仓库编码',
|
||||||
|
minWidth: 140,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '仓库名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'address',
|
||||||
|
title: '仓库地址',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'area',
|
||||||
|
title: '面积(㎡)',
|
||||||
|
width: 110,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'chargeUserId',
|
||||||
|
title: '负责人',
|
||||||
|
width: 120,
|
||||||
|
formatter: ({ cellValue }) =>
|
||||||
|
userList.find((user) => user.id === cellValue)?.nickname ?? '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'frozen',
|
||||||
|
title: '冻结',
|
||||||
|
width: 90,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 220,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,183 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { deleteWarehouse, getWarehousePage } from '#/api/mes/wm/warehouse';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
import { BarcodeDetail } from '../barcode/components';
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建仓库 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData({ formType: 'create' }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看仓库详情 */
|
||||||
|
function handleDetail(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑仓库 */
|
||||||
|
function handleEdit(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除仓库 */
|
||||||
|
async function handleDelete(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteWarehouse(row.id!);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 跳转库区列表 */
|
||||||
|
function handleOpenLocation(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
router.push({
|
||||||
|
name: 'MesWmLocation',
|
||||||
|
query: { warehouseId: String(row.id) },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看仓库条码 */
|
||||||
|
function handleBarcode(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
row.id!,
|
||||||
|
BarcodeBizTypeEnum.WAREHOUSE,
|
||||||
|
row.code,
|
||||||
|
row.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getWarehousePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmWarehouseApi.Warehouse>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】仓库与库区库位、条码赋码、SN码"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/warehouse-setup/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<FormModal @success="handleRefresh" />
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
|
||||||
|
<Grid table-title="仓库列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.create', ['仓库']),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['mes:wm-warehouse:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #code="{ row }">
|
||||||
|
<Button type="link" @click="handleDetail(row)">
|
||||||
|
{{ row.code }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '库区',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleOpenLocation.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['mes:wm-warehouse:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm-warehouse:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '条码',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleBarcode.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,198 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
import type { MesWmWarehouseLocationApi } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
|
||||||
|
import { Button } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
|
||||||
|
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
/** 表单类型 */
|
||||||
|
export type FormType = 'create' | 'detail' | 'update';
|
||||||
|
|
||||||
|
/** 关联数据 */
|
||||||
|
let warehouseList: MesWmWarehouseApi.Warehouse[] = [];
|
||||||
|
getWarehouseSimpleList().then((data) => (warehouseList = data));
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(
|
||||||
|
formType: FormType,
|
||||||
|
formApi?: VbenFormApi,
|
||||||
|
): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: { triggerFields: [''], show: () => false },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '库区编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入库区编码',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
suffix:
|
||||||
|
formType === 'detail'
|
||||||
|
? undefined
|
||||||
|
: () =>
|
||||||
|
h(
|
||||||
|
Button,
|
||||||
|
{
|
||||||
|
type: 'default',
|
||||||
|
onClick: async () => {
|
||||||
|
try {
|
||||||
|
const code = await generateAutoCode(
|
||||||
|
MesAutoCodeRuleCode.WM_LOCATION_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '自动生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '库区名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入库区名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'warehouseId',
|
||||||
|
label: '所属仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'area',
|
||||||
|
label: '面积(㎡)',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
min: 0,
|
||||||
|
precision: 2,
|
||||||
|
placeholder: '请输入面积',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'frozen',
|
||||||
|
label: '是否冻结',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
checkedChildren: '是',
|
||||||
|
unCheckedChildren: '否',
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(false),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '库区编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入库区编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '库区名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入库区名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmWarehouseLocationApi.WarehouseLocation>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '库区编码',
|
||||||
|
minWidth: 140,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '库区名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'warehouseId',
|
||||||
|
title: '所属仓库',
|
||||||
|
minWidth: 140,
|
||||||
|
formatter: ({ cellValue }) =>
|
||||||
|
warehouseList.find((w) => w.id === cellValue)?.name ?? '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'area',
|
||||||
|
title: '面积(㎡)',
|
||||||
|
width: 110,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'frozen',
|
||||||
|
title: '冻结',
|
||||||
|
width: 90,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 240,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,226 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseLocationApi } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { Alert, Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getWarehouse } from '#/api/mes/wm/warehouse';
|
||||||
|
import {
|
||||||
|
deleteWarehouseLocation,
|
||||||
|
getWarehouseLocationPage,
|
||||||
|
} from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
import { BarcodeDetail } from '../../barcode/components';
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
/** 当前仓库上下文(同步从 URL 解析,确保首次查询带得上 warehouseId) */
|
||||||
|
const currentWarehouse = ref<{ id: number; name: string }>(
|
||||||
|
(() => {
|
||||||
|
const id = Number(route.query.warehouseId);
|
||||||
|
return Number.isInteger(id) && id > 0
|
||||||
|
? { id, name: '' }
|
||||||
|
: { id: 0, name: '' };
|
||||||
|
})(),
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 异步加载仓库名称(不阻塞列表查询) */
|
||||||
|
async function loadWarehouseName() {
|
||||||
|
if (!currentWarehouse.value.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const warehouse = await getWarehouse(currentWarehouse.value.id);
|
||||||
|
currentWarehouse.value.name = warehouse.name || '';
|
||||||
|
} catch {
|
||||||
|
// 忽略上级名称加载异常,不影响列表查询
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadWarehouseName();
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建库区 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi
|
||||||
|
.setData({
|
||||||
|
formType: 'create',
|
||||||
|
warehouseId: currentWarehouse.value.id || undefined,
|
||||||
|
})
|
||||||
|
.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看库区详情 */
|
||||||
|
function handleDetail(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑库区 */
|
||||||
|
function handleEdit(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除库区 */
|
||||||
|
async function handleDelete(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteWarehouseLocation(row.id!);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 跳转库位列表 */
|
||||||
|
function handleOpenArea(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
router.push({
|
||||||
|
name: 'MesWmArea',
|
||||||
|
query: { locationId: String(row.id) },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看库区条码 */
|
||||||
|
function handleBarcode(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
row.id!,
|
||||||
|
BarcodeBizTypeEnum.LOCATION,
|
||||||
|
row.code,
|
||||||
|
row.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getWarehouseLocationPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
warehouseId: currentWarehouse.value.id || undefined,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmWarehouseLocationApi.WarehouseLocation>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】仓库与库区库位、条码赋码、SN码"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/warehouse-setup/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<FormModal @success="handleRefresh" />
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
|
||||||
|
<Alert
|
||||||
|
v-if="currentWarehouse.id"
|
||||||
|
class="mb-3"
|
||||||
|
:message="`当前仓库:${currentWarehouse.name || `#${currentWarehouse.id}`}`"
|
||||||
|
show-icon
|
||||||
|
type="info"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Grid table-title="库区列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.create', ['库区']),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['mes:wm-warehouse:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #code="{ row }">
|
||||||
|
<Button type="link" @click="handleDetail(row)">
|
||||||
|
{{ row.code }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '库位',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleOpenArea.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['mes:wm-warehouse:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm-warehouse:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '条码',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleBarcode.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,180 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmWarehouseLocationApi } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createWarehouseLocation,
|
||||||
|
getWarehouseLocation,
|
||||||
|
updateAreaByLocationId,
|
||||||
|
updateWarehouseLocation,
|
||||||
|
} from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formType = ref<FormType>('create');
|
||||||
|
const formData = ref<MesWmWarehouseLocationApi.WarehouseLocation>();
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['库区']);
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['库区'])
|
||||||
|
: $t('ui.actionTitle.create', ['库区']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-1',
|
||||||
|
labelWidth: 110,
|
||||||
|
},
|
||||||
|
wrapperClass: 'grid-cols-3',
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [],
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 查看条码 */
|
||||||
|
function handleBarcode() {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
formData.value.id,
|
||||||
|
BarcodeBizTypeEnum.LOCATION,
|
||||||
|
formData.value.code,
|
||||||
|
formData.value.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量设置库位混放规则 */
|
||||||
|
async function setMixingRule(type: 'batch' | 'item', allow: boolean) {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const text = type === 'item' ? '产品混放' : '批次混放';
|
||||||
|
try {
|
||||||
|
await confirm(`确认要重置库区下所有库位的${text}规则吗?`);
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await updateAreaByLocationId(
|
||||||
|
formData.value.id,
|
||||||
|
type === 'item' ? allow : undefined,
|
||||||
|
type === 'batch' ? allow : undefined,
|
||||||
|
);
|
||||||
|
message.success('设置成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
await modalApi.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data =
|
||||||
|
(await formApi.getValues()) as MesWmWarehouseLocationApi.WarehouseLocation;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateWarehouseLocation(data)
|
||||||
|
: createWarehouseLocation(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<{
|
||||||
|
formType: FormType;
|
||||||
|
id?: number;
|
||||||
|
warehouseId?: number;
|
||||||
|
}>();
|
||||||
|
formType.value = data.formType;
|
||||||
|
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||||
|
if (data?.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getWarehouseLocation(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data?.warehouseId) {
|
||||||
|
await formApi.setFieldValue('warehouseId', data.warehouseId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-3/5">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
<div
|
||||||
|
v-if="formType === 'update' && formData?.id"
|
||||||
|
class="mx-4 mt-2 border-t pt-4"
|
||||||
|
>
|
||||||
|
<div class="mb-2 font-medium">库位混放规则(批量设置)</div>
|
||||||
|
<div class="flex flex-wrap items-center gap-3">
|
||||||
|
<span class="w-20">产品混放</span>
|
||||||
|
<Button size="small" type="primary" @click="setMixingRule('item', true)">
|
||||||
|
允许
|
||||||
|
</Button>
|
||||||
|
<Button size="small" danger @click="setMixingRule('item', false)">
|
||||||
|
不允许
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 flex flex-wrap items-center gap-3">
|
||||||
|
<span class="w-20">批次混放</span>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
@click="setMixingRule('batch', true)"
|
||||||
|
>
|
||||||
|
允许
|
||||||
|
</Button>
|
||||||
|
<Button size="small" danger @click="setMixingRule('batch', false)">
|
||||||
|
不允许
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template v-if="formType === 'detail' && formData?.id" #prepend-footer>
|
||||||
|
<Button @click="handleBarcode"> 查看条码 </Button>
|
||||||
|
</template>
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,122 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createWarehouse,
|
||||||
|
getWarehouse,
|
||||||
|
updateWarehouse,
|
||||||
|
} from '#/api/mes/wm/warehouse';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formType = ref<FormType>('create');
|
||||||
|
const formData = ref<MesWmWarehouseApi.Warehouse>();
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['仓库']);
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['仓库'])
|
||||||
|
: $t('ui.actionTitle.create', ['仓库']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-1',
|
||||||
|
labelWidth: 110,
|
||||||
|
},
|
||||||
|
wrapperClass: 'grid-cols-3',
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [],
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 查看条码 */
|
||||||
|
function handleBarcode() {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
formData.value.id,
|
||||||
|
BarcodeBizTypeEnum.WAREHOUSE,
|
||||||
|
formData.value.code,
|
||||||
|
formData.value.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
await modalApi.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = (await formApi.getValues()) as MesWmWarehouseApi.Warehouse;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id ? updateWarehouse(data) : createWarehouse(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||||
|
formType.value = data.formType;
|
||||||
|
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||||
|
if (!data?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getWarehouse(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-3/5">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
<template v-if="formType === 'detail' && formData?.id" #prepend-footer>
|
||||||
|
<Button @click="handleBarcode"> 查看条码 </Button>
|
||||||
|
</template>
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace MesQcDefectRecordApi {
|
||||||
|
/** MES 质检缺陷记录 */
|
||||||
|
export interface DefectRecord {
|
||||||
|
id?: number; // 编号
|
||||||
|
qcType?: number; // 检验类型
|
||||||
|
qcId?: number; // 检验单 ID
|
||||||
|
lineId?: number; // 检验行 ID
|
||||||
|
name?: string; // 缺陷描述
|
||||||
|
level?: number; // 缺陷等级
|
||||||
|
quantity?: number; // 缺陷数量
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询质检缺陷记录分页 */
|
||||||
|
export function getDefectRecordPage(
|
||||||
|
params: PageParam & { lineId?: number; qcId?: number; qcType?: number; },
|
||||||
|
) {
|
||||||
|
return requestClient.get<PageResult<MesQcDefectRecordApi.DefectRecord>>(
|
||||||
|
'/mes/qc/defect-record/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增质检缺陷记录 */
|
||||||
|
export function createDefectRecord(data: MesQcDefectRecordApi.DefectRecord) {
|
||||||
|
return requestClient.post('/mes/qc/defect-record/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改质检缺陷记录 */
|
||||||
|
export function updateDefectRecord(data: MesQcDefectRecordApi.DefectRecord) {
|
||||||
|
return requestClient.put('/mes/qc/defect-record/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除质检缺陷记录 */
|
||||||
|
export function deleteDefectRecord(id: number) {
|
||||||
|
return requestClient.delete(`/mes/qc/defect-record/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace MesQcIndicatorResultApi {
|
||||||
|
/** MES 检验结果明细 */
|
||||||
|
export interface IndicatorResultDetail {
|
||||||
|
id?: number; // 编号
|
||||||
|
resultId?: number; // 关联检验结果 ID
|
||||||
|
indicatorId?: number; // 检测指标 ID
|
||||||
|
value?: string; // 检测值(统一存为字符串)
|
||||||
|
valueNumber?: number; // UI 数值绑定(提交前转字符串)
|
||||||
|
remark?: string; // 备注
|
||||||
|
// 关联查询字段(来自 indicator)
|
||||||
|
indicatorName?: string; // 检测指标名称
|
||||||
|
valueType?: number; // 质检值类型
|
||||||
|
valueSpecification?: string; // 值属性
|
||||||
|
}
|
||||||
|
|
||||||
|
/** MES 检验结果 */
|
||||||
|
export interface IndicatorResult {
|
||||||
|
id?: number; // 编号
|
||||||
|
code?: string; // 样品编号
|
||||||
|
qcId?: number; // 关联质检单 ID
|
||||||
|
qcType?: number; // 质检类型
|
||||||
|
itemId?: number; // 产品物料 ID
|
||||||
|
sn?: string; // 物资 SN
|
||||||
|
remark?: string; // 备注
|
||||||
|
createTime?: Date; // 创建时间
|
||||||
|
items?: IndicatorResultDetail[]; // 检验结果明细列表
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询检验结果分页 */
|
||||||
|
export function getIndicatorResultPage(
|
||||||
|
params: PageParam & { qcId?: number; qcType?: number },
|
||||||
|
) {
|
||||||
|
return requestClient.get<PageResult<MesQcIndicatorResultApi.IndicatorResult>>(
|
||||||
|
'/mes/qc/indicator-result/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询检验结果明细(含检测项模板):编辑传 id,新增不传 */
|
||||||
|
export function getIndicatorResultDetail(
|
||||||
|
qcId: number,
|
||||||
|
qcType: number,
|
||||||
|
id?: number,
|
||||||
|
) {
|
||||||
|
return requestClient.get<MesQcIndicatorResultApi.IndicatorResult>(
|
||||||
|
'/mes/qc/indicator-result/get-detail',
|
||||||
|
{ params: { id, qcId, qcType } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增检验结果 */
|
||||||
|
export function createIndicatorResult(
|
||||||
|
data: MesQcIndicatorResultApi.IndicatorResult,
|
||||||
|
) {
|
||||||
|
return requestClient.post('/mes/qc/indicator-result/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改检验结果 */
|
||||||
|
export function updateIndicatorResult(
|
||||||
|
data: MesQcIndicatorResultApi.IndicatorResult,
|
||||||
|
) {
|
||||||
|
return requestClient.put('/mes/qc/indicator-result/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除检验结果 */
|
||||||
|
export function deleteIndicatorResult(id: number) {
|
||||||
|
return requestClient.delete(`/mes/qc/indicator-result/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace MesQcIqcApi {
|
||||||
|
/** MES 来料检验单 */
|
||||||
|
export interface Iqc {
|
||||||
|
id?: number; // 编号
|
||||||
|
code?: string; // 检验单编号
|
||||||
|
name?: string; // 检验单名称
|
||||||
|
templateId?: number; // 检验模板 ID
|
||||||
|
sourceDocType?: number; // 来源单据类型
|
||||||
|
sourceDocId?: number; // 来源单据 ID
|
||||||
|
sourceLineId?: number; // 来源单据行 ID
|
||||||
|
sourceDocCode?: string; // 来源单据编号(关联查询)
|
||||||
|
vendorId?: number; // 供应商 ID
|
||||||
|
vendorNickname?: string; // 供应商简称(关联查询)
|
||||||
|
vendorBatch?: string; // 供应商批次号
|
||||||
|
itemId?: number; // 产品物料 ID
|
||||||
|
itemCode?: string; // 产品物料编码(关联查询)
|
||||||
|
itemName?: string; // 产品物料名称(关联查询)
|
||||||
|
itemSpecification?: string; // 规格型号(关联查询)
|
||||||
|
unitName?: string; // 单位名称(关联查询)
|
||||||
|
receivedQuantity?: number; // 本次接收数量
|
||||||
|
checkQuantity?: number; // 本次检测数量
|
||||||
|
qualifiedQuantity?: number; // 合格品数量
|
||||||
|
unqualifiedQuantity?: number; // 不合格品数量
|
||||||
|
criticalRate?: number; // 致命缺陷率(%)
|
||||||
|
majorRate?: number; // 严重缺陷率(%)
|
||||||
|
minorRate?: number; // 轻微缺陷率(%)
|
||||||
|
criticalQuantity?: number; // 致命缺陷数量
|
||||||
|
majorQuantity?: number; // 严重缺陷数量
|
||||||
|
minorQuantity?: number; // 轻微缺陷数量
|
||||||
|
checkResult?: number; // 检测结果
|
||||||
|
receiveDate?: number; // 来料日期
|
||||||
|
inspectDate?: number; // 检测日期
|
||||||
|
inspector?: string; // 检测人员(昵称)
|
||||||
|
inspectorUserId?: number; // 检测人员 ID
|
||||||
|
inspectorNickname?: string; // 检测人员昵称(关联查询)
|
||||||
|
status?: number; // 状态
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询来料检验单分页 */
|
||||||
|
export function getIqcPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<MesQcIqcApi.Iqc>>('/mes/qc/iqc/page', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询来料检验单详情 */
|
||||||
|
export function getIqc(id: number) {
|
||||||
|
return requestClient.get<MesQcIqcApi.Iqc>(`/mes/qc/iqc/get?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增来料检验单 */
|
||||||
|
export function createIqc(data: MesQcIqcApi.Iqc) {
|
||||||
|
return requestClient.post('/mes/qc/iqc/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改来料检验单 */
|
||||||
|
export function updateIqc(data: MesQcIqcApi.Iqc) {
|
||||||
|
return requestClient.put('/mes/qc/iqc/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 完成来料检验单 */
|
||||||
|
export function finishIqc(id: number) {
|
||||||
|
return requestClient.put(`/mes/qc/iqc/finish?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除来料检验单 */
|
||||||
|
export function deleteIqc(id: number) {
|
||||||
|
return requestClient.delete(`/mes/qc/iqc/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出来料检验单 */
|
||||||
|
export function exportIqc(params: any) {
|
||||||
|
return requestClient.download('/mes/qc/iqc/export-excel', { params });
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace MesQcIqcLineApi {
|
||||||
|
/** MES 来料检验单行 */
|
||||||
|
export interface IqcLine {
|
||||||
|
id?: number; // 编号
|
||||||
|
iqcId?: number; // 来料检验单 ID
|
||||||
|
indicatorId?: number; // 检测指标 ID
|
||||||
|
indicatorCode?: string; // 检测指标编码(关联查询)
|
||||||
|
indicatorName?: string; // 检测指标名称(关联查询)
|
||||||
|
indicatorType?: number; // 检测指标类型(关联查询)
|
||||||
|
tool?: string; // 检测工具
|
||||||
|
checkMethod?: string; // 检测方法
|
||||||
|
standardValue?: number; // 标准值
|
||||||
|
unitMeasureId?: number; // 计量单位 ID
|
||||||
|
unitMeasureName?: string; // 计量单位名称(关联查询)
|
||||||
|
maxThreshold?: number; // 误差上限
|
||||||
|
minThreshold?: number; // 误差下限
|
||||||
|
criticalQuantity?: number; // 致命缺陷数量
|
||||||
|
majorQuantity?: number; // 严重缺陷数量
|
||||||
|
minorQuantity?: number; // 轻微缺陷数量
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询来料检验单行分页 */
|
||||||
|
export function getIqcLinePage(params: PageParam & { iqcId?: number }) {
|
||||||
|
return requestClient.get<PageResult<MesQcIqcLineApi.IqcLine>>(
|
||||||
|
'/mes/qc/iqc/line/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询来料检验单行详情 */
|
||||||
|
export function getIqcLine(id: number) {
|
||||||
|
return requestClient.get<MesQcIqcLineApi.IqcLine>(
|
||||||
|
`/mes/qc/iqc/line/get?id=${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
|
|
||||||
|
const routes: RouteRecordRaw[] = [
|
||||||
|
{
|
||||||
|
path: '/mes',
|
||||||
|
name: 'MesCenter',
|
||||||
|
meta: {
|
||||||
|
title: 'MES 制造执行',
|
||||||
|
icon: 'lucide:factory',
|
||||||
|
keepAlive: true,
|
||||||
|
hideInMenu: true,
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'wm/warehouse/location',
|
||||||
|
name: 'MesWmLocation',
|
||||||
|
meta: {
|
||||||
|
title: '库区设置',
|
||||||
|
activePath: '/mes/wm/warehouse',
|
||||||
|
},
|
||||||
|
component: () =>
|
||||||
|
import('#/views/mes/wm/warehouse/location/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'wm/warehouse/area',
|
||||||
|
name: 'MesWmArea',
|
||||||
|
meta: {
|
||||||
|
title: '库位设置',
|
||||||
|
activePath: '/mes/wm/warehouse',
|
||||||
|
},
|
||||||
|
component: () => import('#/views/mes/wm/warehouse/area/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'wm/barcode/config',
|
||||||
|
name: 'MesWmBarcodeConfig',
|
||||||
|
meta: {
|
||||||
|
title: '条码配置',
|
||||||
|
activePath: '/mes/wm/barcode',
|
||||||
|
},
|
||||||
|
component: () => import('#/views/mes/wm/barcode/config/index.vue'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default routes;
|
||||||
|
|
@ -0,0 +1,352 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseAreaApi } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
import { ElButton } from 'element-plus';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
|
||||||
|
import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
/** 表单类型 */
|
||||||
|
export type FormType = 'create' | 'detail' | 'update';
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(
|
||||||
|
formType: FormType,
|
||||||
|
formApi?: VbenFormApi,
|
||||||
|
): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'warehouseId',
|
||||||
|
label: '所属仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
clearable: true,
|
||||||
|
labelField: 'name',
|
||||||
|
// 仓库变更时清空所属库区
|
||||||
|
onChange: () => formApi?.setFieldValue('locationId', undefined),
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'locationId',
|
||||||
|
label: '所属库区',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['warehouseId'],
|
||||||
|
componentProps: (values) => ({
|
||||||
|
api: () =>
|
||||||
|
getWarehouseLocationSimpleList(values.warehouseId as number),
|
||||||
|
clearable: true,
|
||||||
|
disabled: !values.warehouseId,
|
||||||
|
labelField: 'name',
|
||||||
|
// 改变 warehouseId 时强制刷新选项
|
||||||
|
params: { warehouseId: values.warehouseId },
|
||||||
|
placeholder: '请选择库区',
|
||||||
|
valueField: 'id',
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '库位编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入库位编码',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
suffix:
|
||||||
|
formType === 'detail'
|
||||||
|
? undefined
|
||||||
|
: () =>
|
||||||
|
h(
|
||||||
|
ElButton,
|
||||||
|
{
|
||||||
|
onClick: async () => {
|
||||||
|
try {
|
||||||
|
const code = await generateAutoCode(
|
||||||
|
MesAutoCodeRuleCode.WM_AREA_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '自动生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '库位名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入库位名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'area',
|
||||||
|
label: '面积(㎡)',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入面积',
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'maxLoad',
|
||||||
|
label: '最大载重',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入最大载重',
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionX',
|
||||||
|
label: '位置 X',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 X',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionY',
|
||||||
|
label: '位置 Y',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 Y',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionZ',
|
||||||
|
label: '位置 Z',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 Z',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||||
|
placeholder: '请选择',
|
||||||
|
},
|
||||||
|
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'frozen',
|
||||||
|
label: '是否冻结',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
activeText: '是',
|
||||||
|
inactiveText: '否',
|
||||||
|
inlinePrompt: true,
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(false),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'allowItemMixing',
|
||||||
|
label: '允许物料混放',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
activeText: '是',
|
||||||
|
inactiveText: '否',
|
||||||
|
inlinePrompt: true,
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'allowBatchMixing',
|
||||||
|
label: '允许批次混放',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
activeText: '是',
|
||||||
|
inactiveText: '否',
|
||||||
|
inlinePrompt: true,
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '库位编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入库位编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '库位名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入库位名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionX',
|
||||||
|
label: '位置 X',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 X',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionY',
|
||||||
|
label: '位置 Y',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 Y',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'positionZ',
|
||||||
|
label: '位置 Z',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入位置 Z',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmWarehouseAreaApi.WarehouseArea>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '库位编码',
|
||||||
|
minWidth: 140,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '库位名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'area',
|
||||||
|
title: '面积(㎡)',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'maxLoad',
|
||||||
|
title: '最大载重',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'positionX',
|
||||||
|
title: '位置 X',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'positionY',
|
||||||
|
title: '位置 Y',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'positionZ',
|
||||||
|
title: '位置 Z',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
width: 90,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'frozen',
|
||||||
|
title: '冻结',
|
||||||
|
width: 90,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 200,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,221 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseAreaApi } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElAlert, ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deleteWarehouseArea,
|
||||||
|
getWarehouseAreaPage,
|
||||||
|
} from '#/api/mes/wm/warehouse/area';
|
||||||
|
import { getWarehouseLocation } from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
import { BarcodeDetail } from '../../barcode/components';
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
/** 当前库区上下文(同步从 URL 解析,确保首次查询带得上 locationId) */
|
||||||
|
const currentLocation = ref<{
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
warehouseId: number;
|
||||||
|
warehouseName: string;
|
||||||
|
}>(
|
||||||
|
(() => {
|
||||||
|
const id = Number(route.query.locationId);
|
||||||
|
return Number.isInteger(id) && id > 0
|
||||||
|
? { id, name: '', warehouseId: 0, warehouseName: '' }
|
||||||
|
: { id: 0, name: '', warehouseId: 0, warehouseName: '' };
|
||||||
|
})(),
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 异步加载库区/仓库名称(不阻塞列表查询) */
|
||||||
|
async function loadLocationName() {
|
||||||
|
if (!currentLocation.value.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const location = await getWarehouseLocation(currentLocation.value.id);
|
||||||
|
currentLocation.value.name = location.name || '';
|
||||||
|
currentLocation.value.warehouseId = location.warehouseId || 0;
|
||||||
|
currentLocation.value.warehouseName = location.warehouseName || '';
|
||||||
|
} catch {
|
||||||
|
// 忽略上级名称加载异常,不影响列表查询
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadLocationName();
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建库位 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi
|
||||||
|
.setData({
|
||||||
|
formType: 'create',
|
||||||
|
locationId: currentLocation.value.id || undefined,
|
||||||
|
warehouseId: currentLocation.value.warehouseId || undefined,
|
||||||
|
})
|
||||||
|
.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看库位详情 */
|
||||||
|
function handleDetail(row: MesWmWarehouseAreaApi.WarehouseArea) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑库位 */
|
||||||
|
function handleEdit(row: MesWmWarehouseAreaApi.WarehouseArea) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除库位 */
|
||||||
|
async function handleDelete(row: MesWmWarehouseAreaApi.WarehouseArea) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteWarehouseArea(row.id!);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看库位条码 */
|
||||||
|
function handleBarcode(row: MesWmWarehouseAreaApi.WarehouseArea) {
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
row.id!,
|
||||||
|
BarcodeBizTypeEnum.AREA,
|
||||||
|
row.code,
|
||||||
|
row.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getWarehouseAreaPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
locationId: currentLocation.value.id || undefined,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmWarehouseAreaApi.WarehouseArea>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】仓库与库区库位、条码赋码、SN码"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/warehouse-setup/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<FormModal @success="handleRefresh" />
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
|
||||||
|
<ElAlert
|
||||||
|
v-if="currentLocation.id"
|
||||||
|
class="mb-3"
|
||||||
|
:closable="false"
|
||||||
|
show-icon
|
||||||
|
:title="`当前仓库/库区:${currentLocation.warehouseName || `#${currentLocation.warehouseId || '-'}`} / ${currentLocation.name || `#${currentLocation.id}`}`"
|
||||||
|
type="info"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Grid table-title="库位列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.create', ['库位']),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['mes:wm-warehouse:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #code="{ row }">
|
||||||
|
<ElButton link type="primary" @click="handleDetail(row)">
|
||||||
|
{{ row.code }}
|
||||||
|
</ElButton>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['mes:wm-warehouse:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm-warehouse:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '条码',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleBarcode.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmWarehouseAreaApi } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElButton, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createWarehouseArea,
|
||||||
|
getWarehouseArea,
|
||||||
|
updateWarehouseArea,
|
||||||
|
} from '#/api/mes/wm/warehouse/area';
|
||||||
|
import { getWarehouseLocation } from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formType = ref<FormType>('create');
|
||||||
|
const formData = ref<MesWmWarehouseAreaApi.WarehouseArea>();
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['库位']);
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['库位'])
|
||||||
|
: $t('ui.actionTitle.create', ['库位']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-1',
|
||||||
|
labelWidth: 120,
|
||||||
|
},
|
||||||
|
wrapperClass: 'grid-cols-3',
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [],
|
||||||
|
showDefaultActions: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 查看条码 */
|
||||||
|
function handleBarcode() {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
formData.value.id,
|
||||||
|
BarcodeBizTypeEnum.AREA,
|
||||||
|
formData.value.code,
|
||||||
|
formData.value.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
await modalApi.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data =
|
||||||
|
(await formApi.getValues()) as MesWmWarehouseAreaApi.WarehouseArea;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateWarehouseArea(data)
|
||||||
|
: createWarehouseArea(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<{
|
||||||
|
formType: FormType;
|
||||||
|
id?: number;
|
||||||
|
locationId?: number;
|
||||||
|
warehouseId?: number;
|
||||||
|
}>();
|
||||||
|
formType.value = data.formType;
|
||||||
|
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||||
|
if (data?.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getWarehouseArea(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 新增态:根据父级上下文带入仓库/库区
|
||||||
|
let warehouseId = data?.warehouseId;
|
||||||
|
if (data?.locationId) {
|
||||||
|
if (!warehouseId) {
|
||||||
|
try {
|
||||||
|
const location = await getWarehouseLocation(data.locationId);
|
||||||
|
warehouseId = location.warehouseId;
|
||||||
|
} catch {
|
||||||
|
// 忽略
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await formApi.setValues({
|
||||||
|
warehouseId,
|
||||||
|
locationId: data.locationId,
|
||||||
|
});
|
||||||
|
} else if (warehouseId) {
|
||||||
|
await formApi.setFieldValue('warehouseId', warehouseId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-3/5">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
<template v-if="formType === 'detail' && formData?.id" #prepend-footer>
|
||||||
|
<ElButton @click="handleBarcode"> 查看条码 </ElButton>
|
||||||
|
</template>
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
export { default as WmWarehouseAreaSelect } from './wm-warehouse-area-select.vue';
|
||||||
|
export { default as WmWarehouseLocationSelect } from './wm-warehouse-location-select.vue';
|
||||||
|
export { default as WmWarehouseSelect } from './wm-warehouse-select.vue';
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmWarehouseAreaApi } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
import { computed, ref, useAttrs, watch, watchEffect } from 'vue';
|
||||||
|
|
||||||
|
import { ElOption, ElSelect, ElTag, ElTooltip } from 'element-plus';
|
||||||
|
|
||||||
|
import { getWarehouseAreaSimpleList } from '#/api/mes/wm/warehouse/area';
|
||||||
|
|
||||||
|
defineOptions({ name: 'WmWarehouseAreaSelect', inheritAttrs: false });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
clearable?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
locationId?: number;
|
||||||
|
modelValue?: number;
|
||||||
|
placeholder?: string;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
clearable: true,
|
||||||
|
disabled: false,
|
||||||
|
locationId: undefined,
|
||||||
|
modelValue: undefined,
|
||||||
|
placeholder: '请选择库位',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
change: [item: MesWmWarehouseAreaApi.WarehouseArea | undefined];
|
||||||
|
'update:modelValue': [value: number | undefined];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const attrs = useAttrs();
|
||||||
|
const allList = ref<MesWmWarehouseAreaApi.WarehouseArea[]>([]);
|
||||||
|
const filteredList = ref<MesWmWarehouseAreaApi.WarehouseArea[]>([]);
|
||||||
|
const selectedItem = ref<MesWmWarehouseAreaApi.WarehouseArea>(); // 当前选中的库位对象
|
||||||
|
|
||||||
|
const selectValue = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (val) => emit('update:modelValue', val),
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 选中变化 */
|
||||||
|
function handleChange(val: any) {
|
||||||
|
const item = allList.value.find((o) => o.id === val);
|
||||||
|
selectedItem.value = item;
|
||||||
|
emit('change', item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 前端过滤(name + code) */
|
||||||
|
function filterMethod(query: string) {
|
||||||
|
const keyword = query.toLowerCase();
|
||||||
|
filteredList.value = query
|
||||||
|
? allList.value.filter(
|
||||||
|
(item) =>
|
||||||
|
!!item.name?.toLowerCase().includes(keyword) ||
|
||||||
|
!!item.code?.toLowerCase().includes(keyword),
|
||||||
|
)
|
||||||
|
: allList.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(val) => {
|
||||||
|
if (val == null) {
|
||||||
|
selectedItem.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (selectedItem.value?.id !== val && allList.value.length > 0) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
watchEffect(async () => {
|
||||||
|
allList.value = await getWarehouseAreaSimpleList(props.locationId);
|
||||||
|
filteredList.value = allList.value;
|
||||||
|
if (props.modelValue != null) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === props.modelValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ElTooltip :disabled="!selectedItem" placement="top" :show-after="500">
|
||||||
|
<template #content>
|
||||||
|
<div v-if="selectedItem" class="leading-6">
|
||||||
|
<div>编码:{{ selectedItem.code || '-' }}</div>
|
||||||
|
<div>名称:{{ selectedItem.name || '-' }}</div>
|
||||||
|
<div>所属仓库:{{ selectedItem.warehouseName || '-' }}</div>
|
||||||
|
<div>所属库区:{{ selectedItem.locationName || '-' }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<ElSelect
|
||||||
|
v-bind="attrs"
|
||||||
|
v-model="selectValue"
|
||||||
|
class="!w-full"
|
||||||
|
:clearable="clearable"
|
||||||
|
:disabled="disabled"
|
||||||
|
filterable
|
||||||
|
:filter-method="filterMethod"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
@change="handleChange"
|
||||||
|
>
|
||||||
|
<ElOption
|
||||||
|
v-for="item in filteredList"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id!"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span>{{ item.name }}</span>
|
||||||
|
<ElTag v-if="item.code" size="small" type="info">
|
||||||
|
编号: {{ item.code }}
|
||||||
|
</ElTag>
|
||||||
|
</div>
|
||||||
|
</ElOption>
|
||||||
|
</ElSelect>
|
||||||
|
</ElTooltip>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmWarehouseLocationApi } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
import { computed, ref, useAttrs, watch, watchEffect } from 'vue';
|
||||||
|
|
||||||
|
import { ElOption, ElSelect, ElTag, ElTooltip } from 'element-plus';
|
||||||
|
|
||||||
|
import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
defineOptions({ name: 'WmWarehouseLocationSelect', inheritAttrs: false });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
clearable?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
modelValue?: number;
|
||||||
|
placeholder?: string;
|
||||||
|
warehouseId?: number;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
clearable: true,
|
||||||
|
disabled: false,
|
||||||
|
modelValue: undefined,
|
||||||
|
placeholder: '请选择库区',
|
||||||
|
warehouseId: undefined,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
change: [item: MesWmWarehouseLocationApi.WarehouseLocation | undefined];
|
||||||
|
'update:modelValue': [value: number | undefined];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const attrs = useAttrs();
|
||||||
|
const allList = ref<MesWmWarehouseLocationApi.WarehouseLocation[]>([]);
|
||||||
|
const filteredList = ref<MesWmWarehouseLocationApi.WarehouseLocation[]>([]);
|
||||||
|
const selectedItem = ref<MesWmWarehouseLocationApi.WarehouseLocation>(); // 当前选中的库区对象
|
||||||
|
|
||||||
|
const selectValue = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (val) => emit('update:modelValue', val),
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 选中变化 */
|
||||||
|
function handleChange(val: any) {
|
||||||
|
const item = allList.value.find((o) => o.id === val);
|
||||||
|
selectedItem.value = item;
|
||||||
|
emit('change', item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 前端过滤(name + code) */
|
||||||
|
function filterMethod(query: string) {
|
||||||
|
const keyword = query.toLowerCase();
|
||||||
|
filteredList.value = query
|
||||||
|
? allList.value.filter(
|
||||||
|
(item) =>
|
||||||
|
!!item.name?.toLowerCase().includes(keyword) ||
|
||||||
|
!!item.code?.toLowerCase().includes(keyword),
|
||||||
|
)
|
||||||
|
: allList.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(val) => {
|
||||||
|
if (val == null) {
|
||||||
|
selectedItem.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (selectedItem.value?.id !== val && allList.value.length > 0) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
watchEffect(async () => {
|
||||||
|
allList.value = await getWarehouseLocationSimpleList(props.warehouseId);
|
||||||
|
filteredList.value = allList.value;
|
||||||
|
if (props.modelValue != null) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === props.modelValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ElTooltip :disabled="!selectedItem" placement="top" :show-after="500">
|
||||||
|
<template #content>
|
||||||
|
<div v-if="selectedItem" class="leading-6">
|
||||||
|
<div>编码:{{ selectedItem.code || '-' }}</div>
|
||||||
|
<div>名称:{{ selectedItem.name || '-' }}</div>
|
||||||
|
<div>所属仓库:{{ selectedItem.warehouseName || '-' }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<ElSelect
|
||||||
|
v-bind="attrs"
|
||||||
|
v-model="selectValue"
|
||||||
|
class="!w-full"
|
||||||
|
:clearable="clearable"
|
||||||
|
:disabled="disabled"
|
||||||
|
filterable
|
||||||
|
:filter-method="filterMethod"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
@change="handleChange"
|
||||||
|
>
|
||||||
|
<ElOption
|
||||||
|
v-for="item in filteredList"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id!"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span>{{ item.name }}</span>
|
||||||
|
<ElTag v-if="item.code" size="small" type="info">
|
||||||
|
编号: {{ item.code }}
|
||||||
|
</ElTag>
|
||||||
|
</div>
|
||||||
|
</ElOption>
|
||||||
|
</ElSelect>
|
||||||
|
</ElTooltip>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
|
||||||
|
import { computed, onMounted, ref, useAttrs, watch } from 'vue';
|
||||||
|
|
||||||
|
import { ElOption, ElSelect, ElTag, ElTooltip } from 'element-plus';
|
||||||
|
|
||||||
|
import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
|
||||||
|
|
||||||
|
defineOptions({ name: 'WmWarehouseSelect', inheritAttrs: false });
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
clearable?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
modelValue?: number;
|
||||||
|
placeholder?: string;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
clearable: true,
|
||||||
|
disabled: false,
|
||||||
|
modelValue: undefined,
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
change: [item: MesWmWarehouseApi.Warehouse | undefined];
|
||||||
|
'update:modelValue': [value: number | undefined];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const attrs = useAttrs();
|
||||||
|
const allList = ref<MesWmWarehouseApi.Warehouse[]>([]);
|
||||||
|
const filteredList = ref<MesWmWarehouseApi.Warehouse[]>([]);
|
||||||
|
const selectedItem = ref<MesWmWarehouseApi.Warehouse>(); // 当前选中的仓库对象
|
||||||
|
|
||||||
|
const selectValue = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (val) => emit('update:modelValue', val),
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 选中变化 */
|
||||||
|
function handleChange(val: any) {
|
||||||
|
const item = allList.value.find((o) => o.id === val);
|
||||||
|
selectedItem.value = item;
|
||||||
|
emit('change', item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 前端过滤(name + code) */
|
||||||
|
function filterMethod(query: string) {
|
||||||
|
const keyword = query.toLowerCase();
|
||||||
|
filteredList.value = query
|
||||||
|
? allList.value.filter(
|
||||||
|
(item) =>
|
||||||
|
!!item.name?.toLowerCase().includes(keyword) ||
|
||||||
|
!!item.code?.toLowerCase().includes(keyword),
|
||||||
|
)
|
||||||
|
: allList.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(val) => {
|
||||||
|
if (val == null) {
|
||||||
|
selectedItem.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (selectedItem.value?.id !== val && allList.value.length > 0) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
allList.value = await getWarehouseSimpleList();
|
||||||
|
filteredList.value = allList.value;
|
||||||
|
if (props.modelValue != null) {
|
||||||
|
selectedItem.value = allList.value.find((o) => o.id === props.modelValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ElTooltip :disabled="!selectedItem" placement="top" :show-after="500">
|
||||||
|
<template #content>
|
||||||
|
<div v-if="selectedItem" class="leading-6">
|
||||||
|
<div>编码:{{ selectedItem.code || '-' }}</div>
|
||||||
|
<div>名称:{{ selectedItem.name || '-' }}</div>
|
||||||
|
<div>地址:{{ selectedItem.address || '-' }}</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<ElSelect
|
||||||
|
v-bind="attrs"
|
||||||
|
v-model="selectValue"
|
||||||
|
class="!w-full"
|
||||||
|
:clearable="clearable"
|
||||||
|
:disabled="disabled"
|
||||||
|
filterable
|
||||||
|
:filter-method="filterMethod"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
@change="handleChange"
|
||||||
|
>
|
||||||
|
<ElOption
|
||||||
|
v-for="item in filteredList"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id!"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span>{{ item.name }}</span>
|
||||||
|
<ElTag v-if="item.code" size="small" type="info">
|
||||||
|
编号: {{ item.code }}
|
||||||
|
</ElTag>
|
||||||
|
</div>
|
||||||
|
</ElOption>
|
||||||
|
</ElSelect>
|
||||||
|
</ElTooltip>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,227 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
import type { SystemUserApi } from '#/api/system/user';
|
||||||
|
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
|
||||||
|
import { ElButton } from 'element-plus';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getSimpleUserList } from '#/api/system/user';
|
||||||
|
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
/** 表单类型 */
|
||||||
|
export type FormType = 'create' | 'detail' | 'update';
|
||||||
|
|
||||||
|
/** 关联数据 */
|
||||||
|
let userList: SystemUserApi.User[] = [];
|
||||||
|
getSimpleUserList().then((data) => (userList = data));
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(
|
||||||
|
formType: FormType,
|
||||||
|
formApi?: VbenFormApi,
|
||||||
|
): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '仓库编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓库编码',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
suffix:
|
||||||
|
formType === 'detail'
|
||||||
|
? undefined
|
||||||
|
: () =>
|
||||||
|
h(
|
||||||
|
ElButton,
|
||||||
|
{
|
||||||
|
onClick: async () => {
|
||||||
|
try {
|
||||||
|
const code = await generateAutoCode(
|
||||||
|
MesAutoCodeRuleCode.WM_WAREHOUSE_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '自动生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '仓库名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓库名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'chargeUserId',
|
||||||
|
label: '负责人',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: getSimpleUserList,
|
||||||
|
clearable: true,
|
||||||
|
labelField: 'nickname',
|
||||||
|
placeholder: '请选择负责人',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'address',
|
||||||
|
label: '仓库地址',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓库地址',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'area',
|
||||||
|
label: '面积(㎡)',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入面积',
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'frozen',
|
||||||
|
label: '是否冻结',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
activeText: '是',
|
||||||
|
inactiveText: '否',
|
||||||
|
inlinePrompt: true,
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(false),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '仓库编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入仓库编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '仓库名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入仓库名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'frozen',
|
||||||
|
label: '是否冻结',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
options: [
|
||||||
|
{ label: '是', value: true },
|
||||||
|
{ label: '否', value: false },
|
||||||
|
],
|
||||||
|
placeholder: '请选择',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmWarehouseApi.Warehouse>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '仓库编码',
|
||||||
|
minWidth: 140,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '仓库名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'address',
|
||||||
|
title: '仓库地址',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'area',
|
||||||
|
title: '面积(㎡)',
|
||||||
|
width: 110,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'chargeUserId',
|
||||||
|
title: '负责人',
|
||||||
|
width: 120,
|
||||||
|
formatter: ({ cellValue }) =>
|
||||||
|
userList.find((user) => user.id === cellValue)?.nickname ?? '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'frozen',
|
||||||
|
title: '冻结',
|
||||||
|
width: 90,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 240,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,185 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { deleteWarehouse, getWarehousePage } from '#/api/mes/wm/warehouse';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
import { BarcodeDetail } from '../barcode/components';
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建仓库 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData({ formType: 'create' }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看仓库详情 */
|
||||||
|
function handleDetail(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑仓库 */
|
||||||
|
function handleEdit(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除仓库 */
|
||||||
|
async function handleDelete(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteWarehouse(row.id!);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 跳转库区列表 */
|
||||||
|
function handleOpenLocation(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
router.push({
|
||||||
|
name: 'MesWmLocation',
|
||||||
|
query: { warehouseId: String(row.id) },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看仓库条码 */
|
||||||
|
function handleBarcode(row: MesWmWarehouseApi.Warehouse) {
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
row.id!,
|
||||||
|
BarcodeBizTypeEnum.WAREHOUSE,
|
||||||
|
row.code,
|
||||||
|
row.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getWarehousePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmWarehouseApi.Warehouse>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】仓库与库区库位、条码赋码、SN码"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/warehouse-setup/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<FormModal @success="handleRefresh" />
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
|
||||||
|
<Grid table-title="仓库列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.create', ['仓库']),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['mes:wm-warehouse:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #code="{ row }">
|
||||||
|
<ElButton link type="primary" @click="handleDetail(row)">
|
||||||
|
{{ row.code }}
|
||||||
|
</ElButton>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '库区',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleOpenLocation.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['mes:wm-warehouse:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm-warehouse:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '条码',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleBarcode.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,202 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
import type { MesWmWarehouseLocationApi } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
|
||||||
|
import { ElButton } from 'element-plus';
|
||||||
|
|
||||||
|
import { z } from '#/adapter/form';
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
|
||||||
|
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
/** 表单类型 */
|
||||||
|
export type FormType = 'create' | 'detail' | 'update';
|
||||||
|
|
||||||
|
/** 关联数据 */
|
||||||
|
let warehouseList: MesWmWarehouseApi.Warehouse[] = [];
|
||||||
|
getWarehouseSimpleList().then((data) => (warehouseList = data));
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
export function useFormSchema(
|
||||||
|
formType: FormType,
|
||||||
|
formApi?: VbenFormApi,
|
||||||
|
): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '库区编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入库区编码',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
suffix:
|
||||||
|
formType === 'detail'
|
||||||
|
? undefined
|
||||||
|
: () =>
|
||||||
|
h(
|
||||||
|
ElButton,
|
||||||
|
{
|
||||||
|
onClick: async () => {
|
||||||
|
try {
|
||||||
|
const code = await generateAutoCode(
|
||||||
|
MesAutoCodeRuleCode.WM_LOCATION_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '自动生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '库区名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入库区名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'warehouseId',
|
||||||
|
label: '所属仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
clearable: true,
|
||||||
|
labelField: 'name',
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'area',
|
||||||
|
label: '面积(㎡)',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
min: 0,
|
||||||
|
placeholder: '请输入面积',
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'frozen',
|
||||||
|
label: '是否冻结',
|
||||||
|
component: 'Switch',
|
||||||
|
componentProps: {
|
||||||
|
activeText: '是',
|
||||||
|
inactiveText: '否',
|
||||||
|
inlinePrompt: true,
|
||||||
|
},
|
||||||
|
rules: z.boolean().default(false),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '库区编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入库区编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '库区名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入库区名称',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmWarehouseLocationApi.WarehouseLocation>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '库区编码',
|
||||||
|
minWidth: 140,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '库区名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'warehouseId',
|
||||||
|
title: '所属仓库',
|
||||||
|
minWidth: 140,
|
||||||
|
formatter: ({ cellValue }) =>
|
||||||
|
warehouseList.find((w) => w.id === cellValue)?.name ?? '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'area',
|
||||||
|
title: '面积(㎡)',
|
||||||
|
width: 110,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'frozen',
|
||||||
|
title: '冻结',
|
||||||
|
width: 90,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 240,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,229 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmWarehouseLocationApi } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElAlert, ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getWarehouse } from '#/api/mes/wm/warehouse';
|
||||||
|
import {
|
||||||
|
deleteWarehouseLocation,
|
||||||
|
getWarehouseLocationPage,
|
||||||
|
} from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
|
||||||
|
import { BarcodeDetail } from '../../barcode/components';
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
/** 当前仓库上下文(同步从 URL 解析,确保首次查询带得上 warehouseId) */
|
||||||
|
const currentWarehouse = ref<{ id: number; name: string }>(
|
||||||
|
(() => {
|
||||||
|
const id = Number(route.query.warehouseId);
|
||||||
|
return Number.isInteger(id) && id > 0
|
||||||
|
? { id, name: '' }
|
||||||
|
: { id: 0, name: '' };
|
||||||
|
})(),
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 异步加载仓库名称(不阻塞列表查询) */
|
||||||
|
async function loadWarehouseName() {
|
||||||
|
if (!currentWarehouse.value.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const warehouse = await getWarehouse(currentWarehouse.value.id);
|
||||||
|
currentWarehouse.value.name = warehouse.name || '';
|
||||||
|
} catch {
|
||||||
|
// 忽略上级名称加载异常,不影响列表查询
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loadWarehouseName();
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建库区 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi
|
||||||
|
.setData({
|
||||||
|
formType: 'create',
|
||||||
|
warehouseId: currentWarehouse.value.id || undefined,
|
||||||
|
})
|
||||||
|
.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看库区详情 */
|
||||||
|
function handleDetail(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑库区 */
|
||||||
|
function handleEdit(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除库区 */
|
||||||
|
async function handleDelete(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteWarehouseLocation(row.id!);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 跳转库位列表 */
|
||||||
|
function handleOpenArea(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
router.push({
|
||||||
|
name: 'MesWmArea',
|
||||||
|
query: { locationId: String(row.id) },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看库区条码 */
|
||||||
|
function handleBarcode(row: MesWmWarehouseLocationApi.WarehouseLocation) {
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
row.id!,
|
||||||
|
BarcodeBizTypeEnum.LOCATION,
|
||||||
|
row.code,
|
||||||
|
row.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getWarehouseLocationPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
warehouseId: currentWarehouse.value.id || undefined,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmWarehouseLocationApi.WarehouseLocation>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】仓库与库区库位、条码赋码、SN码"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/warehouse-setup/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<FormModal @success="handleRefresh" />
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
|
||||||
|
<ElAlert
|
||||||
|
v-if="currentWarehouse.id"
|
||||||
|
class="mb-3"
|
||||||
|
:closable="false"
|
||||||
|
show-icon
|
||||||
|
:title="`当前仓库:${currentWarehouse.name || `#${currentWarehouse.id}`}`"
|
||||||
|
type="info"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Grid table-title="库区列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.create', ['库区']),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
auth: ['mes:wm-warehouse:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #code="{ row }">
|
||||||
|
<ElButton link type="primary" @click="handleDetail(row)">
|
||||||
|
{{ row.code }}
|
||||||
|
</ElButton>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '库位',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleOpenArea.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['mes:wm-warehouse:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm-warehouse:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '条码',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-warehouse:query'],
|
||||||
|
onClick: handleBarcode.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,192 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmWarehouseLocationApi } from '#/api/mes/wm/warehouse/location';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElButton, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createWarehouseLocation,
|
||||||
|
getWarehouseLocation,
|
||||||
|
updateAreaByLocationId,
|
||||||
|
updateWarehouseLocation,
|
||||||
|
} from '#/api/mes/wm/warehouse/location';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formType = ref<FormType>('create');
|
||||||
|
const formData = ref<MesWmWarehouseLocationApi.WarehouseLocation>();
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['库区']);
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['库区'])
|
||||||
|
: $t('ui.actionTitle.create', ['库区']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-1',
|
||||||
|
labelWidth: 110,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [],
|
||||||
|
showDefaultActions: false,
|
||||||
|
wrapperClass: 'grid-cols-3',
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 查看条码 */
|
||||||
|
function handleBarcode() {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
formData.value.id,
|
||||||
|
BarcodeBizTypeEnum.LOCATION,
|
||||||
|
formData.value.code,
|
||||||
|
formData.value.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量设置库位混放规则 */
|
||||||
|
async function setMixingRule(type: 'batch' | 'item', allow: boolean) {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const text = type === 'item' ? '产品混放' : '批次混放';
|
||||||
|
try {
|
||||||
|
await confirm(`确认要重置库区下所有库位的${text}规则吗?`);
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await updateAreaByLocationId(
|
||||||
|
formData.value.id,
|
||||||
|
type === 'item' ? allow : undefined,
|
||||||
|
type === 'batch' ? allow : undefined,
|
||||||
|
);
|
||||||
|
ElMessage.success('设置成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
await modalApi.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data =
|
||||||
|
(await formApi.getValues()) as MesWmWarehouseLocationApi.WarehouseLocation;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateWarehouseLocation(data)
|
||||||
|
: createWarehouseLocation(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<{
|
||||||
|
formType: FormType;
|
||||||
|
id?: number;
|
||||||
|
warehouseId?: number;
|
||||||
|
}>();
|
||||||
|
formType.value = data.formType;
|
||||||
|
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||||
|
if (data?.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getWarehouseLocation(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data?.warehouseId) {
|
||||||
|
await formApi.setFieldValue('warehouseId', data.warehouseId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-3/5">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
<div
|
||||||
|
v-if="formType === 'update' && formData?.id"
|
||||||
|
class="mx-4 mt-2 border-t pt-4"
|
||||||
|
>
|
||||||
|
<div class="mb-2 font-medium">库位混放规则(批量设置)</div>
|
||||||
|
<div class="flex flex-wrap items-center gap-3">
|
||||||
|
<span class="w-20">产品混放</span>
|
||||||
|
<ElButton
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
@click="setMixingRule('item', true)"
|
||||||
|
>
|
||||||
|
允许
|
||||||
|
</ElButton>
|
||||||
|
<ElButton
|
||||||
|
size="small"
|
||||||
|
type="danger"
|
||||||
|
@click="setMixingRule('item', false)"
|
||||||
|
>
|
||||||
|
不允许
|
||||||
|
</ElButton>
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 flex flex-wrap items-center gap-3">
|
||||||
|
<span class="w-20">批次混放</span>
|
||||||
|
<ElButton
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
@click="setMixingRule('batch', true)"
|
||||||
|
>
|
||||||
|
允许
|
||||||
|
</ElButton>
|
||||||
|
<ElButton
|
||||||
|
size="small"
|
||||||
|
type="danger"
|
||||||
|
@click="setMixingRule('batch', false)"
|
||||||
|
>
|
||||||
|
不允许
|
||||||
|
</ElButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template v-if="formType === 'detail' && formData?.id" #prepend-footer>
|
||||||
|
<ElButton @click="handleBarcode"> 查看条码 </ElButton>
|
||||||
|
</template>
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmWarehouseApi } from '#/api/mes/wm/warehouse';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElButton, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createWarehouse,
|
||||||
|
getWarehouse,
|
||||||
|
updateWarehouse,
|
||||||
|
} from '#/api/mes/wm/warehouse';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||||
|
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formType = ref<FormType>('create');
|
||||||
|
const formData = ref<MesWmWarehouseApi.Warehouse>();
|
||||||
|
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>();
|
||||||
|
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['仓库']);
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['仓库'])
|
||||||
|
: $t('ui.actionTitle.create', ['仓库']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
formItemClass: 'col-span-1',
|
||||||
|
labelWidth: 110,
|
||||||
|
},
|
||||||
|
layout: 'horizontal',
|
||||||
|
schema: [],
|
||||||
|
showDefaultActions: false,
|
||||||
|
wrapperClass: 'grid-cols-3',
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 查看条码 */
|
||||||
|
function handleBarcode() {
|
||||||
|
if (!formData.value?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
barcodeDetailRef.value?.openByBusiness(
|
||||||
|
formData.value.id,
|
||||||
|
BarcodeBizTypeEnum.WAREHOUSE,
|
||||||
|
formData.value.code,
|
||||||
|
formData.value.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
async onConfirm() {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
await modalApi.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
// 提交表单
|
||||||
|
const data = (await formApi.getValues()) as MesWmWarehouseApi.Warehouse;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateWarehouse(data)
|
||||||
|
: createWarehouse(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async onOpenChange(isOpen: boolean) {
|
||||||
|
if (!isOpen) {
|
||||||
|
formData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 加载数据
|
||||||
|
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||||
|
formType.value = data.formType;
|
||||||
|
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||||
|
if (!data?.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getWarehouse(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-3/5">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
<template v-if="formType === 'detail' && formData?.id" #prepend-footer>
|
||||||
|
<ElButton @click="handleBarcode"> 查看条码 </ElButton>
|
||||||
|
</template>
|
||||||
|
<BarcodeDetail ref="barcodeDetailRef" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
Loading…
Reference in New Issue