feat(mes): 迁移工作站管理及设备、工具、人员关联
parent
057ca0bfde
commit
751ba2c782
|
|
@ -0,0 +1,45 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesDvMachineryApi {
|
||||
/** MES 设备台账 */
|
||||
export interface Machinery {
|
||||
id?: number; // 设备编号
|
||||
code?: string; // 设备编码
|
||||
name?: string; // 设备名称
|
||||
brand?: string; // 品牌
|
||||
specification?: string; // 规格型号
|
||||
machineryTypeId?: number; // 设备类型编号
|
||||
machineryTypeName?: string; // 设备类型名称
|
||||
workshopId?: number; // 所属车间编号
|
||||
workshopName?: string; // 所属车间名称
|
||||
status?: number; // 设备状态
|
||||
lastMaintenTime?: Date; // 最近保养时间
|
||||
lastCheckTime?: Date; // 最近点检时间
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询设备分页 */
|
||||
export function getMachineryPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesDvMachineryApi.Machinery>>(
|
||||
'/mes/dv/machinery/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询设备精简列表 */
|
||||
export function getMachinerySimpleList() {
|
||||
return requestClient.get<MesDvMachineryApi.Machinery[]>(
|
||||
'/mes/dv/machinery/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询设备详情 */
|
||||
export function getMachinery(id: number) {
|
||||
return requestClient.get<MesDvMachineryApi.Machinery>(
|
||||
`/mes/dv/machinery/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesMdWorkstationApi {
|
||||
/** MES 工作站 */
|
||||
export interface Workstation {
|
||||
id?: number; // 工作站编号
|
||||
code?: string; // 工作站编码
|
||||
name?: string; // 工作站名称
|
||||
address?: string; // 工作站地点
|
||||
workshopId?: number; // 所在车间编号
|
||||
workshopName?: string; // 所在车间名称
|
||||
processId?: number; // 工序编号
|
||||
processName?: string; // 工序名称
|
||||
warehouseId?: number; // 线边库编号
|
||||
locationId?: number; // 库区编号
|
||||
areaId?: number; // 库位编号
|
||||
status?: number; // 状态
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工作站分页 */
|
||||
export function getWorkstationPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesMdWorkstationApi.Workstation>>(
|
||||
'/mes/md-workstation/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询工作站详情 */
|
||||
export function getWorkstation(id: number) {
|
||||
return requestClient.get<MesMdWorkstationApi.Workstation>(
|
||||
`/mes/md-workstation/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增工作站 */
|
||||
export function createWorkstation(data: MesMdWorkstationApi.Workstation) {
|
||||
return requestClient.post<number>('/mes/md-workstation/create', data);
|
||||
}
|
||||
|
||||
/** 修改工作站 */
|
||||
export function updateWorkstation(data: MesMdWorkstationApi.Workstation) {
|
||||
return requestClient.put('/mes/md-workstation/update', data);
|
||||
}
|
||||
|
||||
/** 删除工作站 */
|
||||
export function deleteWorkstation(id: number) {
|
||||
return requestClient.delete(`/mes/md-workstation/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 导出工作站 */
|
||||
export function exportWorkstation(params: any) {
|
||||
return requestClient.download('/mes/md-workstation/export-excel', { params });
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesMdWorkstationMachineApi {
|
||||
/** MES 工作站设备资源 */
|
||||
export interface WorkstationMachine {
|
||||
id?: number; // 资源编号
|
||||
workstationId?: number; // 工作站编号
|
||||
machineryId?: number; // 设备编号
|
||||
machineryCode?: string; // 设备编码
|
||||
machineryName?: string; // 设备名称
|
||||
quantity?: number; // 数量
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工作站设备资源列表 */
|
||||
export function getWorkstationMachineList(workstationId: number) {
|
||||
return requestClient.get<MesMdWorkstationMachineApi.WorkstationMachine[]>(
|
||||
'/mes/md-workstation-machine/list-by-workstation',
|
||||
{ params: { workstationId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增工作站设备资源 */
|
||||
export function createWorkstationMachine(
|
||||
data: MesMdWorkstationMachineApi.WorkstationMachine,
|
||||
) {
|
||||
return requestClient.post('/mes/md-workstation-machine/create', data);
|
||||
}
|
||||
|
||||
/** 删除工作站设备资源 */
|
||||
export function deleteWorkstationMachine(id: number) {
|
||||
return requestClient.delete(`/mes/md-workstation-machine/delete?id=${id}`);
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesMdWorkstationToolApi {
|
||||
/** MES 工作站工装夹具资源 */
|
||||
export interface WorkstationTool {
|
||||
id?: number; // 资源编号
|
||||
workstationId?: number; // 工作站编号
|
||||
toolTypeId?: number; // 工具类型编号
|
||||
toolTypeName?: string; // 工具类型名称
|
||||
quantity?: number; // 数量
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工作站工装夹具资源列表 */
|
||||
export function getWorkstationToolList(workstationId: number) {
|
||||
return requestClient.get<MesMdWorkstationToolApi.WorkstationTool[]>(
|
||||
'/mes/md-workstation-tool/list-by-workstation',
|
||||
{ params: { workstationId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增工作站工装夹具资源 */
|
||||
export function createWorkstationTool(
|
||||
data: MesMdWorkstationToolApi.WorkstationTool,
|
||||
) {
|
||||
return requestClient.post('/mes/md-workstation-tool/create', data);
|
||||
}
|
||||
|
||||
/** 修改工作站工装夹具资源 */
|
||||
export function updateWorkstationTool(
|
||||
data: MesMdWorkstationToolApi.WorkstationTool,
|
||||
) {
|
||||
return requestClient.put('/mes/md-workstation-tool/update', data);
|
||||
}
|
||||
|
||||
/** 删除工作站工装夹具资源 */
|
||||
export function deleteWorkstationTool(id: number) {
|
||||
return requestClient.delete(`/mes/md-workstation-tool/delete?id=${id}`);
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesMdWorkstationWorkerApi {
|
||||
/** MES 工作站人力资源 */
|
||||
export interface WorkstationWorker {
|
||||
id?: number; // 资源编号
|
||||
workstationId?: number; // 工作站编号
|
||||
postId?: number; // 岗位编号
|
||||
postName?: string; // 岗位名称
|
||||
quantity?: number; // 数量
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工作站人力资源列表 */
|
||||
export function getWorkstationWorkerList(workstationId: number) {
|
||||
return requestClient.get<MesMdWorkstationWorkerApi.WorkstationWorker[]>(
|
||||
'/mes/md-workstation-worker/list-by-workstation',
|
||||
{ params: { workstationId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增工作站人力资源 */
|
||||
export function createWorkstationWorker(
|
||||
data: MesMdWorkstationWorkerApi.WorkstationWorker,
|
||||
) {
|
||||
return requestClient.post('/mes/md-workstation-worker/create', data);
|
||||
}
|
||||
|
||||
/** 修改工作站人力资源 */
|
||||
export function updateWorkstationWorker(
|
||||
data: MesMdWorkstationWorkerApi.WorkstationWorker,
|
||||
) {
|
||||
return requestClient.put('/mes/md-workstation-worker/update', data);
|
||||
}
|
||||
|
||||
/** 删除工作站人力资源 */
|
||||
export function deleteWorkstationWorker(id: number) {
|
||||
return requestClient.delete(`/mes/md-workstation-worker/delete?id=${id}`);
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesTmToolTypeApi {
|
||||
/** MES 工具类型 */
|
||||
export interface ToolType {
|
||||
id?: number; // 工具类型编号
|
||||
code?: string; // 类型编码
|
||||
name?: string; // 类型名称
|
||||
codeFlag?: boolean; // 是否编码管理
|
||||
maintenType?: number; // 保养维护类型
|
||||
maintenPeriod?: number; // 保养周期
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工具类型分页 */
|
||||
export function getToolTypePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesTmToolTypeApi.ToolType>>(
|
||||
'/mes/tm/tool-type/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询工具类型精简列表 */
|
||||
export function getToolTypeSimpleList() {
|
||||
return requestClient.get<MesTmToolTypeApi.ToolType[]>(
|
||||
'/mes/tm/tool-type/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询工具类型详情 */
|
||||
export function getToolType(id: number) {
|
||||
return requestClient.get<MesTmToolTypeApi.ToolType>(
|
||||
`/mes/tm/tool-type/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesWmWarehouseAreaApi {
|
||||
/** MES 库位 */
|
||||
export interface WarehouseArea {
|
||||
id?: number; // 库位编号
|
||||
code?: string; // 库位编码
|
||||
name?: string; // 库位名称
|
||||
warehouseId?: number; // 仓库编号
|
||||
warehouseName?: string; // 仓库名称
|
||||
locationId?: number; // 库区编号
|
||||
locationName?: string; // 库区名称
|
||||
area?: number; // 面积
|
||||
maxLoad?: number; // 最大载荷
|
||||
positionX?: number; // X 坐标
|
||||
positionY?: number; // Y 坐标
|
||||
positionZ?: number; // Z 坐标
|
||||
status?: number; // 状态
|
||||
frozen?: boolean; // 是否冻结
|
||||
allowItemMixing?: boolean; // 是否允许物料混放
|
||||
allowBatchMixing?: boolean; // 是否允许批次混放
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询库位分页 */
|
||||
export function getWarehouseAreaPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesWmWarehouseAreaApi.WarehouseArea>>(
|
||||
'/mes/wm/warehouse-area/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询库位精简列表 */
|
||||
export function getWarehouseAreaSimpleList(locationId?: number) {
|
||||
return requestClient.get<MesWmWarehouseAreaApi.WarehouseArea[]>(
|
||||
'/mes/wm/warehouse-area/simple-list',
|
||||
{ params: { locationId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询库位详情 */
|
||||
export function getWarehouseArea(id: number) {
|
||||
return requestClient.get<MesWmWarehouseAreaApi.WarehouseArea>(
|
||||
`/mes/wm/warehouse-area/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesWmWarehouseApi {
|
||||
/** MES 仓库 */
|
||||
export interface Warehouse {
|
||||
id?: number; // 仓库编号
|
||||
code?: string; // 仓库编码
|
||||
name?: string; // 仓库名称
|
||||
address?: string; // 地址
|
||||
area?: number; // 面积
|
||||
chargeUserId?: number; // 负责人
|
||||
frozen?: boolean; // 是否冻结
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询仓库分页 */
|
||||
export function getWarehousePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesWmWarehouseApi.Warehouse>>(
|
||||
'/mes/wm/warehouse/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询仓库精简列表 */
|
||||
export function getWarehouseSimpleList() {
|
||||
return requestClient.get<MesWmWarehouseApi.Warehouse[]>(
|
||||
'/mes/wm/warehouse/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询仓库详情 */
|
||||
export function getWarehouse(id: number) {
|
||||
return requestClient.get<MesWmWarehouseApi.Warehouse>(
|
||||
`/mes/wm/warehouse/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesWmWarehouseLocationApi {
|
||||
/** MES 库区 */
|
||||
export interface WarehouseLocation {
|
||||
id?: number; // 库区编号
|
||||
code?: string; // 库区编码
|
||||
name?: string; // 库区名称
|
||||
warehouseId?: number; // 仓库编号
|
||||
warehouseName?: string; // 仓库名称
|
||||
area?: number; // 面积
|
||||
frozen?: boolean; // 是否冻结
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询库区分页 */
|
||||
export function getWarehouseLocationPage(params: PageParam) {
|
||||
return requestClient.get<
|
||||
PageResult<MesWmWarehouseLocationApi.WarehouseLocation>
|
||||
>('/mes/wm/warehouse-location/page', { params });
|
||||
}
|
||||
|
||||
/** 查询库区精简列表 */
|
||||
export function getWarehouseLocationSimpleList(warehouseId?: number) {
|
||||
return requestClient.get<MesWmWarehouseLocationApi.WarehouseLocation[]>(
|
||||
'/mes/wm/warehouse-location/simple-list',
|
||||
{ params: { warehouseId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询库区详情 */
|
||||
export function getWarehouseLocation(id: number) {
|
||||
return requestClient.get<MesWmWarehouseLocationApi.WarehouseLocation>(
|
||||
`/mes/wm/warehouse-location/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import type { Recordable } from '@vben/types';
|
||||
|
||||
export * from './cron';
|
||||
export * from './rangePickerProps';
|
||||
export * from './routerHelper';
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,479 @@
|
|||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdClientApi } from '#/api/mes/md/client';
|
||||
|
||||
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 { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 新增/修改客户的表单 */
|
||||
export function useFormSchema(formApi?: any): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '客户编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户编码',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['id'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.id,
|
||||
}),
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
type: 'default',
|
||||
onClick: async () => {
|
||||
try {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.MD_CLIENT_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ default: () => '自动生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '客户名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户名称',
|
||||
},
|
||||
rules: z.string().min(1, '客户名称不能为空').max(100),
|
||||
},
|
||||
{
|
||||
fieldName: 'nickname',
|
||||
label: '客户简称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户简称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'englishName',
|
||||
label: '客户英文名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户英文名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '客户类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_CLIENT_TYPE, 'number'),
|
||||
placeholder: '请选择客户类型',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'description',
|
||||
label: '客户简介',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户简介',
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'address',
|
||||
label: '客户地址',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户地址',
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'website',
|
||||
label: '客户官网地址',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户官网地址',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'email',
|
||||
label: '客户邮箱地址',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户邮箱地址',
|
||||
},
|
||||
rules: z.string().email('邮箱格式不正确').or(z.literal('')).optional(),
|
||||
},
|
||||
{
|
||||
fieldName: 'telephone',
|
||||
label: '客户电话',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户电话',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'logo',
|
||||
label: '客户 LOGO',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入客户 LOGO 地址',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'contact1Name',
|
||||
label: '联系人1',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入联系人1',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'contact1Telephone',
|
||||
label: '联系人1电话',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入联系人1电话',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'contact1Email',
|
||||
label: '联系人1邮箱',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入联系人1邮箱',
|
||||
},
|
||||
rules: z.string().email('邮箱格式不正确').or(z.literal('')).optional(),
|
||||
},
|
||||
{
|
||||
fieldName: 'contact2Name',
|
||||
label: '联系人2',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入联系人2',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'contact2Telephone',
|
||||
label: '联系人2电话',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入联系人2电话',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'contact2Email',
|
||||
label: '联系人2邮箱',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入联系人2邮箱',
|
||||
},
|
||||
rules: z.string().email('邮箱格式不正确').or(z.literal('')).optional(),
|
||||
},
|
||||
{
|
||||
fieldName: 'creditCode',
|
||||
label: '社会信用代码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入统一社会信用代码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 导入客户的表单 */
|
||||
export function useImportFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'file',
|
||||
label: '客户数据',
|
||||
component: 'Upload',
|
||||
rules: 'required',
|
||||
help: '仅允许导入 xls、xlsx 格式文件',
|
||||
},
|
||||
{
|
||||
fieldName: 'updateSupport',
|
||||
label: '是否覆盖',
|
||||
component: 'Switch',
|
||||
componentProps: {
|
||||
checkedChildren: '是',
|
||||
unCheckedChildren: '否',
|
||||
},
|
||||
rules: z.boolean().default(false),
|
||||
help: '是否更新已经存在的客户数据',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '客户编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入客户编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '客户名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入客户名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'nickname',
|
||||
label: '客户简称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入客户简称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'englishName',
|
||||
label: '英文名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入客户英文名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '客户类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_CLIENT_TYPE, 'number'),
|
||||
placeholder: '请选择客户类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
placeholder: '请选择状态',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesMdClientApi.Client>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '客户编码',
|
||||
minWidth: 150,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '客户名称',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'nickname',
|
||||
title: '客户简称',
|
||||
minWidth: 130,
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '客户类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_CLIENT_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'telephone',
|
||||
title: '客户电话',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'contact1Name',
|
||||
title: '联系人1',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'contact1Telephone',
|
||||
title: '联系人1电话',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
width: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 客户选择弹窗的搜索表单 */
|
||||
export function useClientSelectGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '客户编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入客户编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '客户名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入客户名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'nickname',
|
||||
label: '客户简称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入客户简称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'englishName',
|
||||
label: '英文名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入客户英文名称',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 客户选择弹窗的字段 */
|
||||
export function useClientSelectGridColumns(): VxeTableGridOptions<MesMdClientApi.Client>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 50 },
|
||||
{
|
||||
field: 'code',
|
||||
title: '客户编码',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '客户名称',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'nickname',
|
||||
title: '客户简称',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '客户类型',
|
||||
width: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_CLIENT_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'contact1Name',
|
||||
title: '联系人',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'telephone',
|
||||
title: '联系电话',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
field: 'contact1Telephone',
|
||||
title: '联系人电话',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
export { default as MdWorkshopSelect } from './md-workshop-select.vue';
|
||||
export { default as MdWorkstationSelectDialog } from './md-workstation-select-dialog.vue';
|
||||
export { default as MdWorkstationSelect } from './md-workstation-select.vue';
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesMdWorkshopApi } from '#/api/mes/md/workstation/workshop';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { Select, Tag, Tooltip } from 'ant-design-vue';
|
||||
|
||||
import { getWorkshopSimpleList } from '#/api/mes/md/workstation/workshop';
|
||||
|
||||
defineOptions({ name: 'MdWorkshopSelect', 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: MesMdWorkshopApi.Workshop | undefined];
|
||||
'update:modelValue': [value: number | undefined];
|
||||
}>();
|
||||
|
||||
const allList = ref<MesMdWorkshopApi.Workshop[]>([]);
|
||||
const selectedItem = ref<MesMdWorkshopApi.Workshop>();
|
||||
|
||||
const selectValue = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: number | undefined) => {
|
||||
emit('update:modelValue', value);
|
||||
},
|
||||
});
|
||||
|
||||
function handleFilter(input: string, option: any) {
|
||||
const keyword = input.toLowerCase();
|
||||
const item = option?.item as MesMdWorkshopApi.Workshop | undefined;
|
||||
return Boolean(
|
||||
item?.name?.toLowerCase().includes(keyword) ||
|
||||
item?.code?.toLowerCase().includes(keyword),
|
||||
);
|
||||
}
|
||||
|
||||
/** 根据当前值同步 tooltip 展示的车间详情 */
|
||||
function syncSelectedItem(value: number | undefined) {
|
||||
selectedItem.value =
|
||||
value === undefined ? undefined : allList.value.find((item) => item.id === value);
|
||||
}
|
||||
|
||||
/** 除 v-model 外,额外抛出完整车间对象给业务表单使用 */
|
||||
function handleChange(value: any) {
|
||||
const nextValue = value === undefined ? undefined : Number(value);
|
||||
syncSelectedItem(nextValue);
|
||||
emit('change', selectedItem.value);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(value) => {
|
||||
syncSelectedItem(value);
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
allList.value = await getWorkshopSimpleList();
|
||||
syncSelectedItem(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.area != null ? `${selectedItem.area} ㎡` : '-' }}</div>
|
||||
<div>负责人:{{ selectedItem.chargeUserName || '-' }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<Select
|
||||
v-bind="$attrs"
|
||||
v-model:value="selectValue"
|
||||
:allow-clear="allowClear"
|
||||
:disabled="disabled"
|
||||
:filter-option="handleFilter"
|
||||
:placeholder="placeholder"
|
||||
class="w-full"
|
||||
show-search
|
||||
@change="handleChange"
|
||||
>
|
||||
<Select.Option
|
||||
v-for="item in allList"
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
:value="item.id"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<span>{{ item.name }}</span>
|
||||
<Tag v-if="item.code" color="default">{{ item.code }}</Tag>
|
||||
</div>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Tooltip>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { nextTick, ref } from 'vue';
|
||||
|
||||
import { CommonStatusEnum } from '@vben/constants';
|
||||
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getWorkstationPage } from '#/api/mes/md/workstation';
|
||||
|
||||
import {
|
||||
useWorkstationSelectGridColumns,
|
||||
useWorkstationSelectGridFormSchema,
|
||||
} from '../data';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
processId?: number;
|
||||
}>(),
|
||||
{
|
||||
processId: undefined,
|
||||
},
|
||||
);
|
||||
const emit = defineEmits<{
|
||||
selected: [rows: MesMdWorkstationApi.Workstation[]];
|
||||
}>();
|
||||
|
||||
const open = ref(false); // 弹窗是否打开
|
||||
const multiple = ref(true); // 是否多选
|
||||
const syncingSingleSelection = ref(false); // 是否同步单选勾选状态
|
||||
const selectedRows = ref<MesMdWorkstationApi.Workstation[]>([]); // 已选工作站列表
|
||||
const preSelectedIds = ref<number[]>([]); // 预选工作站编号列表
|
||||
|
||||
/** 单选模式下同步 VXE 勾选状态 */
|
||||
async function syncSingleSelection(row?: MesMdWorkstationApi.Workstation) {
|
||||
syncingSingleSelection.value = true;
|
||||
await nextTick();
|
||||
await gridApi.grid.clearCheckboxRow();
|
||||
if (row) {
|
||||
await gridApi.grid.setCheckboxRow(row, true);
|
||||
}
|
||||
await nextTick();
|
||||
syncingSingleSelection.value = false;
|
||||
}
|
||||
|
||||
/** 处理勾选变化,单选模式只保留最后一条 */
|
||||
async function handleCheckboxChange({
|
||||
checked,
|
||||
records,
|
||||
row,
|
||||
}: {
|
||||
checked: boolean;
|
||||
records: MesMdWorkstationApi.Workstation[];
|
||||
row?: MesMdWorkstationApi.Workstation;
|
||||
}) {
|
||||
if (syncingSingleSelection.value) {
|
||||
return;
|
||||
}
|
||||
if (!multiple.value) {
|
||||
const selected = checked && row ? [row] : [];
|
||||
selectedRows.value = selected;
|
||||
await syncSingleSelection(selected[0]);
|
||||
return;
|
||||
}
|
||||
selectedRows.value = records;
|
||||
}
|
||||
|
||||
/** 处理全选变化 */
|
||||
function handleCheckboxAll({ records }: { records: MesMdWorkstationApi.Workstation[] }) {
|
||||
if (syncingSingleSelection.value) {
|
||||
return;
|
||||
}
|
||||
selectedRows.value = records;
|
||||
}
|
||||
|
||||
/** 回显预选工作站 */
|
||||
function applyPreSelection() {
|
||||
if (preSelectedIds.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
const rows = gridApi.grid.getData() as MesMdWorkstationApi.Workstation[];
|
||||
for (const row of rows) {
|
||||
if (row.id && preSelectedIds.value.includes(row.id)) {
|
||||
gridApi.grid.setCheckboxRow(row, true);
|
||||
if (!multiple.value) {
|
||||
selectedRows.value = [row];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useWorkstationSelectGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useWorkstationSelectGridColumns(),
|
||||
height: 520,
|
||||
keepSource: true,
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
range: true,
|
||||
reserve: true,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getWorkstationPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationApi.Workstation>,
|
||||
gridEvents: {
|
||||
checkboxAll: handleCheckboxAll,
|
||||
checkboxChange: handleCheckboxChange,
|
||||
},
|
||||
});
|
||||
|
||||
/** 重置查询和选择状态 */
|
||||
async function resetQueryState() {
|
||||
selectedRows.value = [];
|
||||
await gridApi.grid.clearCheckboxRow();
|
||||
await gridApi.formApi.resetForm();
|
||||
if (props.processId) {
|
||||
await gridApi.formApi.setFieldValue('processId', props.processId);
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开工作站选择弹窗 */
|
||||
async function openModal(selectedIds?: number[], options?: { multiple?: boolean }) {
|
||||
open.value = true;
|
||||
multiple.value = options?.multiple ?? true;
|
||||
preSelectedIds.value = selectedIds || [];
|
||||
await nextTick();
|
||||
await resetQueryState();
|
||||
await gridApi.query();
|
||||
await nextTick();
|
||||
applyPreSelection();
|
||||
}
|
||||
|
||||
/** 关闭工作站选择弹窗 */
|
||||
async function closeModal() {
|
||||
open.value = false;
|
||||
await resetQueryState();
|
||||
}
|
||||
|
||||
/** 确认选择工作站 */
|
||||
function handleConfirm() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
message.warning(multiple.value ? '请至少选择一条数据' : '请选择一条数据');
|
||||
return;
|
||||
}
|
||||
emit('selected', multiple.value ? selectedRows.value : [selectedRows.value[0]!]);
|
||||
open.value = false;
|
||||
}
|
||||
|
||||
defineExpose({ open: openModal });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
v-model:open="open"
|
||||
title="工作站选择"
|
||||
width="70%"
|
||||
:destroy-on-close="true"
|
||||
@ok="handleConfirm"
|
||||
@cancel="closeModal"
|
||||
>
|
||||
<Grid table-title="工作站列表" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { computed, ref, useAttrs, watch } from 'vue';
|
||||
|
||||
import { IconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Input, Tooltip } from 'ant-design-vue';
|
||||
|
||||
import { getWorkstation } from '#/api/mes/md/workstation';
|
||||
|
||||
import MdWorkstationSelectDialog from './md-workstation-select-dialog.vue';
|
||||
|
||||
defineOptions({ name: 'MdWorkstationSelect', inheritAttrs: false });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
allowClear?: boolean;
|
||||
disabled?: boolean;
|
||||
modelValue?: number;
|
||||
placeholder?: string;
|
||||
processId?: number;
|
||||
}>(),
|
||||
{
|
||||
allowClear: true,
|
||||
disabled: false,
|
||||
modelValue: undefined,
|
||||
placeholder: '请选择工作站',
|
||||
processId: undefined,
|
||||
},
|
||||
);
|
||||
const emit = defineEmits<{
|
||||
change: [item: MesMdWorkstationApi.Workstation | undefined];
|
||||
'update:modelValue': [value: number | undefined];
|
||||
}>();
|
||||
const attrs = useAttrs(); // 透传属性
|
||||
const dialogRef = ref<InstanceType<typeof MdWorkstationSelectDialog>>(); // 工作站选择弹窗
|
||||
const hovering = ref(false); // 是否悬停
|
||||
const selectedItem = ref<MesMdWorkstationApi.Workstation>(); // 选中的工作站
|
||||
|
||||
const displayLabel = computed(() => selectedItem.value?.name ?? ''); // 选择器展示名称
|
||||
const showClear = computed( // 是否显示清空图标
|
||||
() => props.allowClear && !props.disabled && hovering.value && props.modelValue != null,
|
||||
);
|
||||
|
||||
/** 根据工作站编号回显选择器 */
|
||||
async function resolveItemById(id: number | undefined) {
|
||||
if (id == null) {
|
||||
selectedItem.value = undefined;
|
||||
return;
|
||||
}
|
||||
if (selectedItem.value?.id === id) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
selectedItem.value = await getWorkstation(id);
|
||||
} catch (error) {
|
||||
console.error('[MdWorkstationSelect] resolveItemById failed:', error);
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(value) => {
|
||||
resolveItemById(value);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/** 清空已选工作站 */
|
||||
function clearSelected() {
|
||||
selectedItem.value = undefined;
|
||||
emit('update:modelValue', undefined);
|
||||
emit('change', undefined);
|
||||
}
|
||||
|
||||
/** 打开工作站选择弹窗 */
|
||||
function handleClick(event: MouseEvent) {
|
||||
if (props.disabled) {
|
||||
return;
|
||||
}
|
||||
const target = event.target as HTMLElement;
|
||||
if (showClear.value && target.closest('.ant-input-suffix')) {
|
||||
event.stopPropagation();
|
||||
clearSelected();
|
||||
return;
|
||||
}
|
||||
const selectedIds = props.modelValue == null ? [] : [props.modelValue];
|
||||
dialogRef.value?.open(selectedIds, { multiple: false });
|
||||
}
|
||||
|
||||
/** 回填选中的工作站 */
|
||||
function handleSelected(rows: MesMdWorkstationApi.Workstation[]) {
|
||||
const item = rows[0];
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
selectedItem.value = item;
|
||||
emit('update:modelValue', item.id);
|
||||
emit('change', item);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-bind="attrs"
|
||||
class="w-full"
|
||||
:class="disabled ? 'cursor-not-allowed' : 'cursor-pointer'"
|
||||
@click="handleClick"
|
||||
@mouseenter="hovering = true"
|
||||
@mouseleave="hovering = false"
|
||||
>
|
||||
<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.workshopName || '-' }}</div>
|
||||
<div>所属工序:{{ selectedItem.processName || '-' }}</div>
|
||||
<div>地点:{{ selectedItem.address || '-' }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<Input
|
||||
:disabled="disabled"
|
||||
:placeholder="placeholder"
|
||||
:value="displayLabel"
|
||||
readonly
|
||||
>
|
||||
<template #suffix>
|
||||
<IconifyIcon
|
||||
class="size-4"
|
||||
:icon="showClear ? 'lucide:circle-x' : 'lucide:search'"
|
||||
/>
|
||||
</template>
|
||||
</Input>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<MdWorkstationSelectDialog
|
||||
ref="dialogRef"
|
||||
:process-id="processId"
|
||||
@selected="handleSelected"
|
||||
/>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,351 @@
|
|||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { h, markRaw } 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 { getWarehouseAreaSimpleList } from '#/api/mes/wm/warehouse/area';
|
||||
import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
|
||||
import { ProProcessSelect } from '#/views/mes/pro/process/components';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
import { MdWorkshopSelect } from './components';
|
||||
|
||||
/** 新增/修改工作站的表单 */
|
||||
export function useFormSchema(formApi?: any): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '工作站编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入工作站编码',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
type: 'default',
|
||||
onClick: async () => {
|
||||
try {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '工作站名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入工作站名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'workshopId',
|
||||
label: '所在车间',
|
||||
component: markRaw(MdWorkshopSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择车间',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'address',
|
||||
label: '工作站地点',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入工作站地点',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'processId',
|
||||
label: '所属工序',
|
||||
component: markRaw(ProProcessSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择所属工序',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'warehouseId',
|
||||
label: '仓库',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
api: getWarehouseSimpleList,
|
||||
labelField: 'name',
|
||||
onChange: async () => {
|
||||
await formApi?.setFieldValue('locationId', undefined);
|
||||
await formApi?.setFieldValue('areaId', undefined);
|
||||
},
|
||||
placeholder: '请选择仓库',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'locationId',
|
||||
label: '库区',
|
||||
component: 'Select',
|
||||
dependencies: {
|
||||
triggerFields: ['warehouseId'],
|
||||
disabled: (values) => !values.warehouseId,
|
||||
async componentProps(values) {
|
||||
const list = values.warehouseId
|
||||
? await getWarehouseLocationSimpleList(values.warehouseId)
|
||||
: [];
|
||||
return {
|
||||
allowClear: true,
|
||||
onChange: async () => {
|
||||
await formApi?.setFieldValue('areaId', undefined);
|
||||
},
|
||||
options: list.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择库区',
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '库位',
|
||||
component: 'Select',
|
||||
dependencies: {
|
||||
triggerFields: ['locationId'],
|
||||
disabled: (values) => !values.locationId,
|
||||
async componentProps(values) {
|
||||
const list = values.locationId
|
||||
? await getWarehouseAreaSimpleList(values.locationId)
|
||||
: [];
|
||||
return {
|
||||
allowClear: true,
|
||||
options: list.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择库位',
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
buttonStyle: 'solid',
|
||||
optionType: 'button',
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
{
|
||||
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: 'workshopId',
|
||||
label: '所在车间',
|
||||
component: markRaw(MdWorkshopSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择车间',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'processId',
|
||||
label: '所属工序',
|
||||
component: markRaw(ProProcessSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择工序',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
placeholder: '请选择状态',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesMdWorkstationApi.Workstation>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '工作站编码',
|
||||
minWidth: 150,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '工作站名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'address',
|
||||
title: '工作站地点',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'workshopName',
|
||||
title: '所在车间',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
field: 'processName',
|
||||
title: '所属工序',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
width: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 210,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 工作站选择弹窗的搜索表单 */
|
||||
export function useWorkstationSelectGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '工作站编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入工作站编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'processId',
|
||||
label: '所属工序',
|
||||
component: markRaw(ProProcessSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择工序',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'workshopId',
|
||||
label: '所在车间',
|
||||
component: markRaw(MdWorkshopSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择车间',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 工作站选择弹窗的字段 */
|
||||
export function useWorkstationSelectGridColumns(): VxeTableGridOptions<MesMdWorkstationApi.Workstation>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 50 },
|
||||
{
|
||||
field: 'code',
|
||||
title: '工作站编码',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '工作站名称',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'address',
|
||||
title: '工作站地点',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'workshopName',
|
||||
title: '所在车间',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'processName',
|
||||
title: '所属工序',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
minWidth: 140,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,189 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteWorkstation,
|
||||
exportWorkstation,
|
||||
getWorkstationPage,
|
||||
} from '#/api/mes/md/workstation';
|
||||
import { $t } from '#/locales';
|
||||
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstation' });
|
||||
|
||||
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); // 条码详情弹窗
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建工作站 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看工作站 */
|
||||
function handleDetail(row: MesMdWorkstationApi.Workstation) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑工作站 */
|
||||
function handleEdit(row: MesMdWorkstationApi.Workstation) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除工作站 */
|
||||
async function handleDelete(row: MesMdWorkstationApi.Workstation) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.name]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteWorkstation(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 查看工作站条码 */
|
||||
function handleBarcode(row: MesMdWorkstationApi.Workstation) {
|
||||
if (!row.id) {
|
||||
return;
|
||||
}
|
||||
barcodeDetailRef.value?.openByBusiness(
|
||||
row.id,
|
||||
BarcodeBizTypeEnum.WORKSTATION,
|
||||
row.code,
|
||||
row.name,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出工作站 */
|
||||
async function handleExport() {
|
||||
const data = await exportWorkstation(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '工作站.xls', source: data });
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getWorkstationPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationApi.Workstation>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【基础】车间设置、工作站设置"
|
||||
url="https://doc.iocoder.cn/mes/md/workshop/"
|
||||
/>
|
||||
</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:md-workstation:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:md-workstation:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</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:md-workstation:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:md-workstation:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '条码',
|
||||
type: 'link',
|
||||
auth: ['mes:md-workstation:query'],
|
||||
onClick: handleBarcode.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, message, Tabs } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createWorkstation,
|
||||
getWorkstation,
|
||||
updateWorkstation,
|
||||
} from '#/api/mes/md/workstation';
|
||||
import { $t } from '#/locales';
|
||||
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
import MachineList from './machine-list.vue';
|
||||
import ToolList from './tool-list.vue';
|
||||
import WorkerList from './worker-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstationForm' });
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const subTabsName = ref('machine'); // 当前资源页签
|
||||
const formData = ref<MesMdWorkstationApi.Workstation>();
|
||||
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); // 条码详情弹窗
|
||||
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
const titles: Record<FormMode, string> = {
|
||||
create: '新增工作站',
|
||||
update: '修改工作站',
|
||||
detail: '查看工作站',
|
||||
};
|
||||
return titles[formMode.value];
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-1',
|
||||
labelWidth: 110,
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
/** 表单 schema 需要 formApi 引用,所以通过 setState 设置 schema */
|
||||
formApi.setState({ schema: useFormSchema(formApi) });
|
||||
|
||||
/** 查看工作站条码 */
|
||||
function handleBarcode() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
barcodeDetailRef.value?.openByBusiness(
|
||||
formData.value.id,
|
||||
BarcodeBizTypeEnum.WORKSTATION,
|
||||
formData.value.code,
|
||||
formData.value.name,
|
||||
);
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (isDetail.value) {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesMdWorkstationApi.Workstation;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
const id = await createWorkstation(data);
|
||||
formData.value = { ...data, id };
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
} else {
|
||||
await updateWorkstation(data);
|
||||
formData.value = { ...formData.value, ...data };
|
||||
}
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
await formApi.resetForm();
|
||||
subTabsName.value = 'machine';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getWorkstation(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<Tabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
<Tabs.TabPane key="machine" tab="设备资源">
|
||||
<MachineList :form-type="formMode" :workstation-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="tool" tab="工装夹具">
|
||||
<ToolList :form-type="formMode" :workstation-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="worker" tab="人力资源">
|
||||
<WorkerList :form-type="formMode" :workstation-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center">
|
||||
<Button
|
||||
v-if="isDetail && formData?.id"
|
||||
type="primary"
|
||||
@click="handleBarcode"
|
||||
>
|
||||
查看条码
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
<BarcodeDetail ref="barcodeDetailRef" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,212 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationMachineApi } from '#/api/mes/md/workstation/machine';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm, z } from '#/adapter/form';
|
||||
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getMachinerySimpleList } from '#/api/mes/dv/machinery';
|
||||
import {
|
||||
createWorkstationMachine,
|
||||
deleteWorkstationMachine,
|
||||
getWorkstationMachineList,
|
||||
} from '#/api/mes/md/workstation/machine';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstationMachineList' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
workstationId: number;
|
||||
}>(),
|
||||
{
|
||||
formType: 'update',
|
||||
},
|
||||
);
|
||||
|
||||
const isReadOnly = computed(() => props.formType === 'detail'); // 是否只读
|
||||
const formOpen = ref(false); // 设备资源表单是否打开
|
||||
const formLoading = ref(false); // 设备资源表单提交中
|
||||
const list = ref<MesMdWorkstationMachineApi.WorkstationMachine[]>([]); // 设备资源列表
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{ fieldName: 'workstationId', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{
|
||||
fieldName: 'machineryId',
|
||||
label: '设备',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
api: getMachinerySimpleList,
|
||||
labelField: 'name',
|
||||
placeholder: '请选择设备',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 1,
|
||||
precision: 0,
|
||||
},
|
||||
rules: z.number().default(1),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: { placeholder: '请输入备注', rows: 3 },
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
autoResize: true,
|
||||
border: true,
|
||||
columns: [
|
||||
{ field: 'machineryCode', title: '设备编码', width: 140 },
|
||||
{ field: 'machineryName', title: '设备名称', minWidth: 160 },
|
||||
{ field: 'quantity', title: '数量', width: 100 },
|
||||
{ field: 'remark', title: '备注', minWidth: 160 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 90,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !isReadOnly.value,
|
||||
},
|
||||
],
|
||||
data: list.value,
|
||||
minHeight: 240,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
keyField: 'id',
|
||||
},
|
||||
showOverflow: true,
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationMachineApi.WorkstationMachine>,
|
||||
});
|
||||
|
||||
/** 加载设备资源列表 */
|
||||
async function getList() {
|
||||
gridApi.setLoading(true);
|
||||
try {
|
||||
list.value = await getWorkstationMachineList(props.workstationId);
|
||||
gridApi.setGridOptions({ data: list.value });
|
||||
} finally {
|
||||
gridApi.setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开设备资源表单 */
|
||||
async function openForm() {
|
||||
formOpen.value = true;
|
||||
await formApi.resetForm();
|
||||
await formApi.setValues({
|
||||
quantity: 1,
|
||||
workstationId: props.workstationId,
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交设备资源表单 */
|
||||
async function submitForm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
formLoading.value = true;
|
||||
try {
|
||||
const data = (await formApi.getValues()) as MesMdWorkstationMachineApi.WorkstationMachine;
|
||||
await createWorkstationMachine(data);
|
||||
formOpen.value = false;
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
await getList();
|
||||
} finally {
|
||||
formLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除设备资源 */
|
||||
async function handleDelete(id: number) {
|
||||
await deleteWorkstationMachine(id);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', ['设备资源']));
|
||||
await getList();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.workstationId,
|
||||
(value) => {
|
||||
if (value) {
|
||||
getList();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!isReadOnly" class="mb-3 flex items-center justify-start">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '添加设备',
|
||||
type: 'primary',
|
||||
onClick: openForm,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
<Grid class="w-full">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
type: 'link',
|
||||
danger: true,
|
||||
popConfirm: {
|
||||
title: '确认删除该设备资源吗?',
|
||||
confirm: handleDelete.bind(null, row.id!),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<Modal
|
||||
v-model:open="formOpen"
|
||||
title="添加设备"
|
||||
width="520px"
|
||||
:confirm-loading="formLoading"
|
||||
@ok="submitForm"
|
||||
>
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationToolApi } from '#/api/mes/md/workstation/tool';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm, z } from '#/adapter/form';
|
||||
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
createWorkstationTool,
|
||||
deleteWorkstationTool,
|
||||
getWorkstationToolList,
|
||||
updateWorkstationTool,
|
||||
} from '#/api/mes/md/workstation/tool';
|
||||
import { getToolTypeSimpleList } from '#/api/mes/tm/tool/type';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstationToolList' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
workstationId: number;
|
||||
}>(),
|
||||
{
|
||||
formType: 'update',
|
||||
},
|
||||
);
|
||||
|
||||
const isReadOnly = computed(() => props.formType === 'detail'); // 是否只读
|
||||
const formOpen = ref(false); // 工装夹具表单是否打开
|
||||
const formLoading = ref(false); // 工装夹具表单提交中
|
||||
const formData = ref<MesMdWorkstationToolApi.WorkstationTool>();
|
||||
const list = ref<MesMdWorkstationToolApi.WorkstationTool[]>([]); // 工装夹具列表
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{ fieldName: 'id', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{ fieldName: 'workstationId', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{
|
||||
fieldName: 'toolTypeId',
|
||||
label: '工具类型',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
api: getToolTypeSimpleList,
|
||||
labelField: 'name',
|
||||
placeholder: '请选择工具类型',
|
||||
valueField: 'id',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['id'],
|
||||
disabled: (values) => !!values.id,
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 1,
|
||||
precision: 0,
|
||||
},
|
||||
rules: z.number().default(1),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: { placeholder: '请输入备注', rows: 3 },
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
autoResize: true,
|
||||
border: true,
|
||||
columns: [
|
||||
{ field: 'toolTypeId', title: '工具类型编号', width: 140 },
|
||||
{ field: 'toolTypeName', title: '工具类型名称', minWidth: 160 },
|
||||
{ field: 'quantity', title: '数量', width: 100 },
|
||||
{ field: 'remark', title: '备注', minWidth: 160 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 130,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !isReadOnly.value,
|
||||
},
|
||||
],
|
||||
data: list.value,
|
||||
minHeight: 240,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
keyField: 'id',
|
||||
},
|
||||
showOverflow: true,
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationToolApi.WorkstationTool>,
|
||||
});
|
||||
|
||||
/** 加载工装夹具列表 */
|
||||
async function getList() {
|
||||
gridApi.setLoading(true);
|
||||
try {
|
||||
list.value = await getWorkstationToolList(props.workstationId);
|
||||
gridApi.setGridOptions({ data: list.value });
|
||||
} finally {
|
||||
gridApi.setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开工装夹具表单 */
|
||||
async function openForm(row?: MesMdWorkstationToolApi.WorkstationTool) {
|
||||
formOpen.value = true;
|
||||
formData.value = row;
|
||||
await formApi.resetForm();
|
||||
await formApi.setValues({
|
||||
quantity: 1,
|
||||
workstationId: props.workstationId,
|
||||
...row,
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交工装夹具表单 */
|
||||
async function submitForm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
formLoading.value = true;
|
||||
try {
|
||||
const data = (await formApi.getValues()) as MesMdWorkstationToolApi.WorkstationTool;
|
||||
await (formData.value?.id ? updateWorkstationTool(data) : createWorkstationTool(data));
|
||||
formOpen.value = false;
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
await getList();
|
||||
} finally {
|
||||
formLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除工装夹具 */
|
||||
async function handleDelete(id: number) {
|
||||
await deleteWorkstationTool(id);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', ['工装夹具']));
|
||||
await getList();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.workstationId,
|
||||
(value) => {
|
||||
if (value) {
|
||||
getList();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!isReadOnly" class="mb-3 flex items-center justify-start">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '添加工具',
|
||||
type: 'primary',
|
||||
onClick: openForm.bind(null, undefined),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
<Grid class="w-full">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '编辑',
|
||||
type: 'link',
|
||||
onClick: openForm.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'link',
|
||||
danger: true,
|
||||
popConfirm: {
|
||||
title: '确认删除该工装夹具吗?',
|
||||
confirm: handleDelete.bind(null, row.id!),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<Modal
|
||||
v-model:open="formOpen"
|
||||
:title="formData?.id ? '编辑工具' : '添加工具'"
|
||||
width="520px"
|
||||
:confirm-loading="formLoading"
|
||||
@ok="submitForm"
|
||||
>
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationWorkerApi } from '#/api/mes/md/workstation/worker';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm, z } from '#/adapter/form';
|
||||
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
createWorkstationWorker,
|
||||
deleteWorkstationWorker,
|
||||
getWorkstationWorkerList,
|
||||
updateWorkstationWorker,
|
||||
} from '#/api/mes/md/workstation/worker';
|
||||
import { getSimplePostList } from '#/api/system/post';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstationWorkerList' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
workstationId: number;
|
||||
}>(),
|
||||
{
|
||||
formType: 'update',
|
||||
},
|
||||
);
|
||||
|
||||
const isReadOnly = computed(() => props.formType === 'detail'); // 是否只读
|
||||
const formOpen = ref(false); // 人力资源表单是否打开
|
||||
const formLoading = ref(false); // 人力资源表单提交中
|
||||
const formData = ref<MesMdWorkstationWorkerApi.WorkstationWorker>();
|
||||
const list = ref<MesMdWorkstationWorkerApi.WorkstationWorker[]>([]); // 人力资源列表
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{ fieldName: 'id', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{ fieldName: 'workstationId', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{
|
||||
fieldName: 'postId',
|
||||
label: '岗位',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
api: getSimplePostList,
|
||||
labelField: 'name',
|
||||
placeholder: '请选择岗位',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 1,
|
||||
precision: 0,
|
||||
},
|
||||
rules: z.number().default(1),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: { placeholder: '请输入备注', rows: 3 },
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
autoResize: true,
|
||||
border: true,
|
||||
columns: [
|
||||
{ field: 'postId', title: '岗位编号', width: 140 },
|
||||
{ field: 'postName', title: '岗位名称', minWidth: 160 },
|
||||
{ field: 'quantity', title: '数量', width: 100 },
|
||||
{ field: 'remark', title: '备注', minWidth: 160 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 130,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !isReadOnly.value,
|
||||
},
|
||||
],
|
||||
data: list.value,
|
||||
minHeight: 240,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
keyField: 'id',
|
||||
},
|
||||
showOverflow: true,
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationWorkerApi.WorkstationWorker>,
|
||||
});
|
||||
|
||||
/** 加载人力资源列表 */
|
||||
async function getList() {
|
||||
gridApi.setLoading(true);
|
||||
try {
|
||||
list.value = await getWorkstationWorkerList(props.workstationId);
|
||||
gridApi.setGridOptions({ data: list.value });
|
||||
} finally {
|
||||
gridApi.setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开人力资源表单 */
|
||||
async function openForm(row?: MesMdWorkstationWorkerApi.WorkstationWorker) {
|
||||
formOpen.value = true;
|
||||
formData.value = row;
|
||||
await formApi.resetForm();
|
||||
await formApi.setValues({
|
||||
quantity: 1,
|
||||
workstationId: props.workstationId,
|
||||
...row,
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交人力资源表单 */
|
||||
async function submitForm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
formLoading.value = true;
|
||||
try {
|
||||
const data = (await formApi.getValues()) as MesMdWorkstationWorkerApi.WorkstationWorker;
|
||||
await (formData.value?.id ? updateWorkstationWorker(data) : createWorkstationWorker(data));
|
||||
formOpen.value = false;
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
await getList();
|
||||
} finally {
|
||||
formLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除人力资源 */
|
||||
async function handleDelete(id: number) {
|
||||
await deleteWorkstationWorker(id);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', ['人力资源']));
|
||||
await getList();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.workstationId,
|
||||
(value) => {
|
||||
if (value) {
|
||||
getList();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!isReadOnly" class="mb-3 flex items-center justify-start">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '添加人员',
|
||||
type: 'primary',
|
||||
onClick: openForm.bind(null, undefined),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
<Grid class="w-full">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '编辑',
|
||||
type: 'link',
|
||||
onClick: openForm.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'link',
|
||||
danger: true,
|
||||
popConfirm: {
|
||||
title: '确认删除该人力资源吗?',
|
||||
confirm: handleDelete.bind(null, row.id!),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<Modal
|
||||
v-model:open="formOpen"
|
||||
:title="formData?.id ? '编辑人员' : '添加人员'"
|
||||
width="520px"
|
||||
:confirm-loading="formLoading"
|
||||
@ok="submitForm"
|
||||
>
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -16,6 +16,7 @@ export const MesAutoCodeRuleCode = {
|
|||
MD_ITEM_TYPE_CODE: 'MD_ITEM_TYPE_CODE',
|
||||
MD_ITEM_CODE: 'MD_ITEM_CODE',
|
||||
MD_VENDOR_CODE: 'MD_VENDOR_CODE',
|
||||
MD_WORKSTATION_CODE: 'MD_WORKSTATION_CODE',
|
||||
MD_WORKSHOP_CODE: 'MD_WORKSHOP_CODE',
|
||||
} as const;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesDvMachineryApi {
|
||||
/** MES 设备台账 */
|
||||
export interface Machinery {
|
||||
id?: number; // 设备编号
|
||||
code?: string; // 设备编码
|
||||
name?: string; // 设备名称
|
||||
brand?: string; // 品牌
|
||||
specification?: string; // 规格型号
|
||||
machineryTypeId?: number; // 设备类型编号
|
||||
machineryTypeName?: string; // 设备类型名称
|
||||
workshopId?: number; // 所属车间编号
|
||||
workshopName?: string; // 所属车间名称
|
||||
status?: number; // 设备状态
|
||||
lastMaintenTime?: Date; // 最近保养时间
|
||||
lastCheckTime?: Date; // 最近点检时间
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询设备分页 */
|
||||
export function getMachineryPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesDvMachineryApi.Machinery>>(
|
||||
'/mes/dv/machinery/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询设备精简列表 */
|
||||
export function getMachinerySimpleList() {
|
||||
return requestClient.get<MesDvMachineryApi.Machinery[]>(
|
||||
'/mes/dv/machinery/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询设备详情 */
|
||||
export function getMachinery(id: number) {
|
||||
return requestClient.get<MesDvMachineryApi.Machinery>(
|
||||
`/mes/dv/machinery/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesMdWorkstationApi {
|
||||
/** MES 工作站 */
|
||||
export interface Workstation {
|
||||
id?: number; // 工作站编号
|
||||
code?: string; // 工作站编码
|
||||
name?: string; // 工作站名称
|
||||
address?: string; // 工作站地点
|
||||
workshopId?: number; // 所在车间编号
|
||||
workshopName?: string; // 所在车间名称
|
||||
processId?: number; // 工序编号
|
||||
processName?: string; // 工序名称
|
||||
warehouseId?: number; // 线边库编号
|
||||
locationId?: number; // 库区编号
|
||||
areaId?: number; // 库位编号
|
||||
status?: number; // 状态
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工作站分页 */
|
||||
export function getWorkstationPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesMdWorkstationApi.Workstation>>(
|
||||
'/mes/md-workstation/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询工作站详情 */
|
||||
export function getWorkstation(id: number) {
|
||||
return requestClient.get<MesMdWorkstationApi.Workstation>(
|
||||
`/mes/md-workstation/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增工作站 */
|
||||
export function createWorkstation(data: MesMdWorkstationApi.Workstation) {
|
||||
return requestClient.post<number>('/mes/md-workstation/create', data);
|
||||
}
|
||||
|
||||
/** 修改工作站 */
|
||||
export function updateWorkstation(data: MesMdWorkstationApi.Workstation) {
|
||||
return requestClient.put('/mes/md-workstation/update', data);
|
||||
}
|
||||
|
||||
/** 删除工作站 */
|
||||
export function deleteWorkstation(id: number) {
|
||||
return requestClient.delete(`/mes/md-workstation/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 导出工作站 */
|
||||
export function exportWorkstation(params: any) {
|
||||
return requestClient.download('/mes/md-workstation/export-excel', { params });
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesMdWorkstationMachineApi {
|
||||
/** MES 工作站设备资源 */
|
||||
export interface WorkstationMachine {
|
||||
id?: number; // 资源编号
|
||||
workstationId?: number; // 工作站编号
|
||||
machineryId?: number; // 设备编号
|
||||
machineryCode?: string; // 设备编码
|
||||
machineryName?: string; // 设备名称
|
||||
quantity?: number; // 数量
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工作站设备资源列表 */
|
||||
export function getWorkstationMachineList(workstationId: number) {
|
||||
return requestClient.get<MesMdWorkstationMachineApi.WorkstationMachine[]>(
|
||||
'/mes/md-workstation-machine/list-by-workstation',
|
||||
{ params: { workstationId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增工作站设备资源 */
|
||||
export function createWorkstationMachine(
|
||||
data: MesMdWorkstationMachineApi.WorkstationMachine,
|
||||
) {
|
||||
return requestClient.post('/mes/md-workstation-machine/create', data);
|
||||
}
|
||||
|
||||
/** 删除工作站设备资源 */
|
||||
export function deleteWorkstationMachine(id: number) {
|
||||
return requestClient.delete(`/mes/md-workstation-machine/delete?id=${id}`);
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesMdWorkstationToolApi {
|
||||
/** MES 工作站工装夹具资源 */
|
||||
export interface WorkstationTool {
|
||||
id?: number; // 资源编号
|
||||
workstationId?: number; // 工作站编号
|
||||
toolTypeId?: number; // 工具类型编号
|
||||
toolTypeName?: string; // 工具类型名称
|
||||
quantity?: number; // 数量
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工作站工装夹具资源列表 */
|
||||
export function getWorkstationToolList(workstationId: number) {
|
||||
return requestClient.get<MesMdWorkstationToolApi.WorkstationTool[]>(
|
||||
'/mes/md-workstation-tool/list-by-workstation',
|
||||
{ params: { workstationId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增工作站工装夹具资源 */
|
||||
export function createWorkstationTool(
|
||||
data: MesMdWorkstationToolApi.WorkstationTool,
|
||||
) {
|
||||
return requestClient.post('/mes/md-workstation-tool/create', data);
|
||||
}
|
||||
|
||||
/** 修改工作站工装夹具资源 */
|
||||
export function updateWorkstationTool(
|
||||
data: MesMdWorkstationToolApi.WorkstationTool,
|
||||
) {
|
||||
return requestClient.put('/mes/md-workstation-tool/update', data);
|
||||
}
|
||||
|
||||
/** 删除工作站工装夹具资源 */
|
||||
export function deleteWorkstationTool(id: number) {
|
||||
return requestClient.delete(`/mes/md-workstation-tool/delete?id=${id}`);
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesMdWorkstationWorkerApi {
|
||||
/** MES 工作站人力资源 */
|
||||
export interface WorkstationWorker {
|
||||
id?: number; // 资源编号
|
||||
workstationId?: number; // 工作站编号
|
||||
postId?: number; // 岗位编号
|
||||
postName?: string; // 岗位名称
|
||||
quantity?: number; // 数量
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工作站人力资源列表 */
|
||||
export function getWorkstationWorkerList(workstationId: number) {
|
||||
return requestClient.get<MesMdWorkstationWorkerApi.WorkstationWorker[]>(
|
||||
'/mes/md-workstation-worker/list-by-workstation',
|
||||
{ params: { workstationId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增工作站人力资源 */
|
||||
export function createWorkstationWorker(
|
||||
data: MesMdWorkstationWorkerApi.WorkstationWorker,
|
||||
) {
|
||||
return requestClient.post('/mes/md-workstation-worker/create', data);
|
||||
}
|
||||
|
||||
/** 修改工作站人力资源 */
|
||||
export function updateWorkstationWorker(
|
||||
data: MesMdWorkstationWorkerApi.WorkstationWorker,
|
||||
) {
|
||||
return requestClient.put('/mes/md-workstation-worker/update', data);
|
||||
}
|
||||
|
||||
/** 删除工作站人力资源 */
|
||||
export function deleteWorkstationWorker(id: number) {
|
||||
return requestClient.delete(`/mes/md-workstation-worker/delete?id=${id}`);
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesTmToolTypeApi {
|
||||
/** MES 工具类型 */
|
||||
export interface ToolType {
|
||||
id?: number; // 工具类型编号
|
||||
code?: string; // 类型编码
|
||||
name?: string; // 类型名称
|
||||
codeFlag?: boolean; // 是否编码管理
|
||||
maintenType?: number; // 保养维护类型
|
||||
maintenPeriod?: number; // 保养周期
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询工具类型分页 */
|
||||
export function getToolTypePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesTmToolTypeApi.ToolType>>(
|
||||
'/mes/tm/tool-type/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询工具类型精简列表 */
|
||||
export function getToolTypeSimpleList() {
|
||||
return requestClient.get<MesTmToolTypeApi.ToolType[]>(
|
||||
'/mes/tm/tool-type/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询工具类型详情 */
|
||||
export function getToolType(id: number) {
|
||||
return requestClient.get<MesTmToolTypeApi.ToolType>(
|
||||
`/mes/tm/tool-type/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesWmWarehouseAreaApi {
|
||||
/** MES 库位 */
|
||||
export interface WarehouseArea {
|
||||
id?: number; // 库位编号
|
||||
code?: string; // 库位编码
|
||||
name?: string; // 库位名称
|
||||
warehouseId?: number; // 仓库编号
|
||||
warehouseName?: string; // 仓库名称
|
||||
locationId?: number; // 库区编号
|
||||
locationName?: string; // 库区名称
|
||||
area?: number; // 面积
|
||||
maxLoad?: number; // 最大载荷
|
||||
positionX?: number; // X 坐标
|
||||
positionY?: number; // Y 坐标
|
||||
positionZ?: number; // Z 坐标
|
||||
status?: number; // 状态
|
||||
frozen?: boolean; // 是否冻结
|
||||
allowItemMixing?: boolean; // 是否允许物料混放
|
||||
allowBatchMixing?: boolean; // 是否允许批次混放
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询库位分页 */
|
||||
export function getWarehouseAreaPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesWmWarehouseAreaApi.WarehouseArea>>(
|
||||
'/mes/wm/warehouse-area/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询库位精简列表 */
|
||||
export function getWarehouseAreaSimpleList(locationId?: number) {
|
||||
return requestClient.get<MesWmWarehouseAreaApi.WarehouseArea[]>(
|
||||
'/mes/wm/warehouse-area/simple-list',
|
||||
{ params: { locationId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询库位详情 */
|
||||
export function getWarehouseArea(id: number) {
|
||||
return requestClient.get<MesWmWarehouseAreaApi.WarehouseArea>(
|
||||
`/mes/wm/warehouse-area/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesWmWarehouseApi {
|
||||
/** MES 仓库 */
|
||||
export interface Warehouse {
|
||||
id?: number; // 仓库编号
|
||||
code?: string; // 仓库编码
|
||||
name?: string; // 仓库名称
|
||||
address?: string; // 地址
|
||||
area?: number; // 面积
|
||||
chargeUserId?: number; // 负责人
|
||||
frozen?: boolean; // 是否冻结
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询仓库分页 */
|
||||
export function getWarehousePage(params: PageParam) {
|
||||
return requestClient.get<PageResult<MesWmWarehouseApi.Warehouse>>(
|
||||
'/mes/wm/warehouse/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询仓库精简列表 */
|
||||
export function getWarehouseSimpleList() {
|
||||
return requestClient.get<MesWmWarehouseApi.Warehouse[]>(
|
||||
'/mes/wm/warehouse/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询仓库详情 */
|
||||
export function getWarehouse(id: number) {
|
||||
return requestClient.get<MesWmWarehouseApi.Warehouse>(
|
||||
`/mes/wm/warehouse/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesWmWarehouseLocationApi {
|
||||
/** MES 库区 */
|
||||
export interface WarehouseLocation {
|
||||
id?: number; // 库区编号
|
||||
code?: string; // 库区编码
|
||||
name?: string; // 库区名称
|
||||
warehouseId?: number; // 仓库编号
|
||||
warehouseName?: string; // 仓库名称
|
||||
area?: number; // 面积
|
||||
frozen?: boolean; // 是否冻结
|
||||
remark?: string; // 备注
|
||||
createTime?: Date; // 创建时间
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询库区分页 */
|
||||
export function getWarehouseLocationPage(params: PageParam) {
|
||||
return requestClient.get<
|
||||
PageResult<MesWmWarehouseLocationApi.WarehouseLocation>
|
||||
>('/mes/wm/warehouse-location/page', { params });
|
||||
}
|
||||
|
||||
/** 查询库区精简列表 */
|
||||
export function getWarehouseLocationSimpleList(warehouseId?: number) {
|
||||
return requestClient.get<MesWmWarehouseLocationApi.WarehouseLocation[]>(
|
||||
'/mes/wm/warehouse-location/simple-list',
|
||||
{ params: { warehouseId } },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询库区详情 */
|
||||
export function getWarehouseLocation(id: number) {
|
||||
return requestClient.get<MesWmWarehouseLocationApi.WarehouseLocation>(
|
||||
`/mes/wm/warehouse-location/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
export { default as MdWorkshopSelect } from './md-workshop-select.vue';
|
||||
export { default as MdWorkstationSelectDialog } from './md-workstation-select-dialog.vue';
|
||||
export { default as MdWorkstationSelect } from './md-workstation-select.vue';
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesMdWorkshopApi } from '#/api/mes/md/workstation/workshop';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { ElOption, ElSelect, ElTag, ElTooltip } from 'element-plus';
|
||||
|
||||
import { getWorkshopSimpleList } from '#/api/mes/md/workstation/workshop';
|
||||
|
||||
defineOptions({ name: 'MdWorkshopSelect', 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: MesMdWorkshopApi.Workshop | undefined];
|
||||
'update:modelValue': [value: number | undefined];
|
||||
}>();
|
||||
|
||||
const allList = ref<MesMdWorkshopApi.Workshop[]>([]);
|
||||
const filteredList = ref<MesMdWorkshopApi.Workshop[]>([]);
|
||||
const selectedItem = ref<MesMdWorkshopApi.Workshop>(); // 选中的车间
|
||||
|
||||
const selectValue = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (value: number | undefined) => {
|
||||
emit('update:modelValue', value);
|
||||
},
|
||||
});
|
||||
|
||||
/** 前端过滤车间名称和编码 */
|
||||
function handleFilter(query: string) {
|
||||
if (!query) {
|
||||
filteredList.value = allList.value;
|
||||
return;
|
||||
}
|
||||
const keyword = query.toLowerCase();
|
||||
filteredList.value = allList.value.filter(
|
||||
(item) =>
|
||||
item.name?.toLowerCase().includes(keyword) ||
|
||||
item.code?.toLowerCase().includes(keyword),
|
||||
);
|
||||
}
|
||||
|
||||
/** 根据当前值同步 tooltip 展示的车间详情 */
|
||||
function syncSelectedItem(value: number | undefined) {
|
||||
selectedItem.value =
|
||||
value === undefined ? undefined : allList.value.find((item) => item.id === value);
|
||||
}
|
||||
|
||||
/** 除 v-model 外,额外抛出完整车间对象给业务表单使用 */
|
||||
function handleChange(value: number | undefined) {
|
||||
syncSelectedItem(value);
|
||||
emit('change', selectedItem.value);
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(value) => {
|
||||
syncSelectedItem(value);
|
||||
},
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
allList.value = await getWorkshopSimpleList();
|
||||
filteredList.value = allList.value;
|
||||
syncSelectedItem(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.area != null ? `${selectedItem.area} ㎡` : '-' }}</div>
|
||||
<div>负责人:{{ selectedItem.chargeUserName || '-' }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<ElSelect
|
||||
v-bind="$attrs"
|
||||
v-model="selectValue"
|
||||
:clearable="clearable"
|
||||
:disabled="disabled"
|
||||
:filter-method="handleFilter"
|
||||
:placeholder="placeholder"
|
||||
class="w-full"
|
||||
filterable
|
||||
@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" type="info">{{ item.code }}</ElTag>
|
||||
</div>
|
||||
</ElOption>
|
||||
</ElSelect>
|
||||
</ElTooltip>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,190 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { nextTick, ref } from 'vue';
|
||||
|
||||
import { CommonStatusEnum } from '@vben/constants';
|
||||
|
||||
import { ElButton, ElDialog, ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getWorkstationPage } from '#/api/mes/md/workstation';
|
||||
|
||||
import {
|
||||
useWorkstationSelectGridColumns,
|
||||
useWorkstationSelectGridFormSchema,
|
||||
} from '../data';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
processId?: number;
|
||||
}>(),
|
||||
{
|
||||
processId: undefined,
|
||||
},
|
||||
);
|
||||
const emit = defineEmits<{
|
||||
selected: [rows: MesMdWorkstationApi.Workstation[]];
|
||||
}>();
|
||||
|
||||
const open = ref(false); // 弹窗是否打开
|
||||
const multiple = ref(true); // 是否多选
|
||||
const syncingSingleSelection = ref(false); // 是否同步单选勾选状态
|
||||
const selectedRows = ref<MesMdWorkstationApi.Workstation[]>([]); // 已选工作站列表
|
||||
const preSelectedIds = ref<number[]>([]); // 预选工作站编号列表
|
||||
|
||||
/** 单选模式下同步 VXE 勾选状态 */
|
||||
async function syncSingleSelection(row?: MesMdWorkstationApi.Workstation) {
|
||||
syncingSingleSelection.value = true;
|
||||
await nextTick();
|
||||
await gridApi.grid.clearCheckboxRow();
|
||||
if (row) {
|
||||
await gridApi.grid.setCheckboxRow(row, true);
|
||||
}
|
||||
await nextTick();
|
||||
syncingSingleSelection.value = false;
|
||||
}
|
||||
|
||||
/** 处理勾选变化,单选模式只保留最后一条 */
|
||||
async function handleCheckboxChange({
|
||||
checked,
|
||||
records,
|
||||
row,
|
||||
}: {
|
||||
checked: boolean;
|
||||
records: MesMdWorkstationApi.Workstation[];
|
||||
row?: MesMdWorkstationApi.Workstation;
|
||||
}) {
|
||||
if (syncingSingleSelection.value) {
|
||||
return;
|
||||
}
|
||||
if (!multiple.value) {
|
||||
const selected = checked && row ? [row] : [];
|
||||
selectedRows.value = selected;
|
||||
await syncSingleSelection(selected[0]);
|
||||
return;
|
||||
}
|
||||
selectedRows.value = records;
|
||||
}
|
||||
|
||||
/** 处理全选变化 */
|
||||
function handleCheckboxAll({ records }: { records: MesMdWorkstationApi.Workstation[] }) {
|
||||
if (syncingSingleSelection.value) {
|
||||
return;
|
||||
}
|
||||
selectedRows.value = records;
|
||||
}
|
||||
|
||||
/** 回显预选工作站 */
|
||||
function applyPreSelection() {
|
||||
if (preSelectedIds.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
const rows = gridApi.grid.getData() as MesMdWorkstationApi.Workstation[];
|
||||
for (const row of rows) {
|
||||
if (row.id && preSelectedIds.value.includes(row.id)) {
|
||||
gridApi.grid.setCheckboxRow(row, true);
|
||||
if (!multiple.value) {
|
||||
selectedRows.value = [row];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useWorkstationSelectGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useWorkstationSelectGridColumns(),
|
||||
height: 520,
|
||||
keepSource: true,
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
range: true,
|
||||
reserve: true,
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getWorkstationPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationApi.Workstation>,
|
||||
gridEvents: {
|
||||
checkboxAll: handleCheckboxAll,
|
||||
checkboxChange: handleCheckboxChange,
|
||||
},
|
||||
});
|
||||
|
||||
/** 重置查询和选择状态 */
|
||||
async function resetQueryState() {
|
||||
selectedRows.value = [];
|
||||
await gridApi.grid.clearCheckboxRow();
|
||||
await gridApi.formApi.resetForm();
|
||||
if (props.processId) {
|
||||
await gridApi.formApi.setFieldValue('processId', props.processId);
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开工作站选择弹窗 */
|
||||
async function openModal(selectedIds?: number[], options?: { multiple?: boolean }) {
|
||||
open.value = true;
|
||||
multiple.value = options?.multiple ?? true;
|
||||
preSelectedIds.value = selectedIds || [];
|
||||
await nextTick();
|
||||
await resetQueryState();
|
||||
await gridApi.query();
|
||||
await nextTick();
|
||||
applyPreSelection();
|
||||
}
|
||||
|
||||
/** 关闭工作站选择弹窗 */
|
||||
async function closeModal() {
|
||||
open.value = false;
|
||||
await resetQueryState();
|
||||
}
|
||||
|
||||
/** 确认选择工作站 */
|
||||
function handleConfirm() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning(multiple.value ? '请至少选择一条数据' : '请选择一条数据');
|
||||
return;
|
||||
}
|
||||
emit('selected', multiple.value ? selectedRows.value : [selectedRows.value[0]!]);
|
||||
open.value = false;
|
||||
}
|
||||
|
||||
defineExpose({ open: openModal });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElDialog
|
||||
v-model="open"
|
||||
title="工作站选择"
|
||||
width="70%"
|
||||
destroy-on-close
|
||||
@close="closeModal"
|
||||
>
|
||||
<Grid table-title="工作站列表" />
|
||||
<template #footer>
|
||||
<ElButton @click="closeModal">取消</ElButton>
|
||||
<ElButton type="primary" @click="handleConfirm">确定</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { computed, ref, useAttrs, watch } from 'vue';
|
||||
|
||||
import { CircleX, Search } from '@vben/icons';
|
||||
|
||||
import { ElInput, ElTooltip } from 'element-plus';
|
||||
|
||||
import { getWorkstation } from '#/api/mes/md/workstation';
|
||||
|
||||
import MdWorkstationSelectDialog from './md-workstation-select-dialog.vue';
|
||||
|
||||
defineOptions({ name: 'MdWorkstationSelect', inheritAttrs: false });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
clearable?: boolean;
|
||||
disabled?: boolean;
|
||||
modelValue?: number;
|
||||
placeholder?: string;
|
||||
processId?: number;
|
||||
}>(),
|
||||
{
|
||||
clearable: true,
|
||||
disabled: false,
|
||||
modelValue: undefined,
|
||||
placeholder: '请选择工作站',
|
||||
processId: undefined,
|
||||
},
|
||||
);
|
||||
const emit = defineEmits<{
|
||||
change: [item: MesMdWorkstationApi.Workstation | undefined];
|
||||
'update:modelValue': [value: number | undefined];
|
||||
}>();
|
||||
const attrs = useAttrs(); // 透传属性
|
||||
const dialogRef = ref<InstanceType<typeof MdWorkstationSelectDialog>>(); // 工作站选择弹窗
|
||||
const hovering = ref(false); // 是否悬停
|
||||
const selectedItem = ref<MesMdWorkstationApi.Workstation>(); // 选中的工作站
|
||||
|
||||
const displayLabel = computed(() => selectedItem.value?.name ?? ''); // 选择器展示名称
|
||||
const showClear = computed( // 是否显示清空图标
|
||||
() => props.clearable && !props.disabled && hovering.value && props.modelValue != null,
|
||||
);
|
||||
|
||||
/** 根据工作站编号回显选择器 */
|
||||
async function resolveItemById(id: number | undefined) {
|
||||
if (id == null) {
|
||||
selectedItem.value = undefined;
|
||||
return;
|
||||
}
|
||||
if (selectedItem.value?.id === id) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
selectedItem.value = await getWorkstation(id);
|
||||
} catch (error) {
|
||||
console.error('[MdWorkstationSelect] resolveItemById failed:', error);
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(value) => {
|
||||
resolveItemById(value);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/** 清空已选工作站 */
|
||||
function clearSelected() {
|
||||
selectedItem.value = undefined;
|
||||
emit('update:modelValue', undefined);
|
||||
emit('change', undefined);
|
||||
}
|
||||
|
||||
/** 打开工作站选择弹窗 */
|
||||
function handleClick(event: MouseEvent) {
|
||||
if (props.disabled) {
|
||||
return;
|
||||
}
|
||||
const target = event.target as HTMLElement;
|
||||
if (showClear.value && target.closest('.el-input__suffix')) {
|
||||
event.stopPropagation();
|
||||
clearSelected();
|
||||
return;
|
||||
}
|
||||
const selectedIds = props.modelValue == null ? [] : [props.modelValue];
|
||||
dialogRef.value?.open(selectedIds, { multiple: false });
|
||||
}
|
||||
|
||||
/** 回填选中的工作站 */
|
||||
function handleSelected(rows: MesMdWorkstationApi.Workstation[]) {
|
||||
const item = rows[0];
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
selectedItem.value = item;
|
||||
emit('update:modelValue', item.id);
|
||||
emit('change', item);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-bind="attrs"
|
||||
class="w-full"
|
||||
:class="disabled ? 'cursor-not-allowed' : 'cursor-pointer'"
|
||||
@click="handleClick"
|
||||
@mouseenter="hovering = true"
|
||||
@mouseleave="hovering = false"
|
||||
>
|
||||
<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.workshopName || '-' }}</div>
|
||||
<div>所属工序:{{ selectedItem.processName || '-' }}</div>
|
||||
<div>地点:{{ selectedItem.address || '-' }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<ElInput
|
||||
:disabled="disabled"
|
||||
:model-value="displayLabel"
|
||||
:placeholder="placeholder"
|
||||
readonly
|
||||
>
|
||||
<template #suffix>
|
||||
<CircleX v-if="showClear" class="size-4" />
|
||||
<Search v-else class="size-4" />
|
||||
</template>
|
||||
</ElInput>
|
||||
</ElTooltip>
|
||||
</div>
|
||||
<MdWorkstationSelectDialog
|
||||
ref="dialogRef"
|
||||
:process-id="processId"
|
||||
@selected="handleSelected"
|
||||
/>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,348 @@
|
|||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { h, markRaw } 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 { getWarehouseAreaSimpleList } from '#/api/mes/wm/warehouse/area';
|
||||
import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
|
||||
import { ProProcessSelect } from '#/views/mes/pro/process/components';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
import { MdWorkshopSelect } from './components';
|
||||
|
||||
/** 新增/修改工作站的表单 */
|
||||
export function useFormSchema(formApi?: any): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '工作站编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入工作站编码',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: () =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
onClick: async () => {
|
||||
try {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.MD_WORKSTATION_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '工作站名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入工作站名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'workshopId',
|
||||
label: '所在车间',
|
||||
component: markRaw(MdWorkshopSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择车间',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'address',
|
||||
label: '工作站地点',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入工作站地点',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'processId',
|
||||
label: '所属工序',
|
||||
component: markRaw(ProProcessSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择所属工序',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'warehouseId',
|
||||
label: '仓库',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getWarehouseSimpleList,
|
||||
clearable: true,
|
||||
labelField: 'name',
|
||||
onChange: async () => {
|
||||
await formApi?.setFieldValue('locationId', undefined);
|
||||
await formApi?.setFieldValue('areaId', undefined);
|
||||
},
|
||||
placeholder: '请选择仓库',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'locationId',
|
||||
label: '库区',
|
||||
component: 'Select',
|
||||
dependencies: {
|
||||
triggerFields: ['warehouseId'],
|
||||
disabled: (values) => !values.warehouseId,
|
||||
async componentProps(values) {
|
||||
const list = values.warehouseId
|
||||
? await getWarehouseLocationSimpleList(values.warehouseId)
|
||||
: [];
|
||||
return {
|
||||
clearable: true,
|
||||
onChange: async () => {
|
||||
await formApi?.setFieldValue('areaId', undefined);
|
||||
},
|
||||
options: list.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择库区',
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '库位',
|
||||
component: 'Select',
|
||||
dependencies: {
|
||||
triggerFields: ['locationId'],
|
||||
disabled: (values) => !values.locationId,
|
||||
async componentProps(values) {
|
||||
const list = values.locationId
|
||||
? await getWarehouseAreaSimpleList(values.locationId)
|
||||
: [];
|
||||
return {
|
||||
clearable: true,
|
||||
options: list.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
})),
|
||||
placeholder: '请选择库位',
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||
},
|
||||
{
|
||||
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: 'workshopId',
|
||||
label: '所在车间',
|
||||
component: markRaw(MdWorkshopSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择车间',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'processId',
|
||||
label: '所属工序',
|
||||
component: markRaw(ProProcessSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择工序',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
placeholder: '请选择状态',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesMdWorkstationApi.Workstation>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '工作站编码',
|
||||
minWidth: 150,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '工作站名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'address',
|
||||
title: '工作站地点',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'workshopName',
|
||||
title: '所在车间',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
field: 'processName',
|
||||
title: '所属工序',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
width: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 210,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 工作站选择弹窗的搜索表单 */
|
||||
export function useWorkstationSelectGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '工作站编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入工作站编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'processId',
|
||||
label: '所属工序',
|
||||
component: markRaw(ProProcessSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择工序',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'workshopId',
|
||||
label: '所在车间',
|
||||
component: markRaw(MdWorkshopSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择车间',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 工作站选择弹窗的字段 */
|
||||
export function useWorkstationSelectGridColumns(): VxeTableGridOptions<MesMdWorkstationApi.Workstation>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 50 },
|
||||
{
|
||||
field: 'code',
|
||||
title: '工作站编码',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '工作站名称',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'address',
|
||||
title: '工作站地点',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'workshopName',
|
||||
title: '所在车间',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'processName',
|
||||
title: '所属工序',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
minWidth: 140,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,190 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteWorkstation,
|
||||
exportWorkstation,
|
||||
getWorkstationPage,
|
||||
} from '#/api/mes/md/workstation';
|
||||
import { $t } from '#/locales';
|
||||
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstation' });
|
||||
|
||||
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); // 条码详情弹窗
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建工作站 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看工作站 */
|
||||
function handleDetail(row: MesMdWorkstationApi.Workstation) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑工作站 */
|
||||
function handleEdit(row: MesMdWorkstationApi.Workstation) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除工作站 */
|
||||
async function handleDelete(row: MesMdWorkstationApi.Workstation) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||
});
|
||||
try {
|
||||
await deleteWorkstation(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 查看工作站条码 */
|
||||
function handleBarcode(row: MesMdWorkstationApi.Workstation) {
|
||||
if (!row.id) {
|
||||
return;
|
||||
}
|
||||
barcodeDetailRef.value?.openByBusiness(
|
||||
row.id,
|
||||
BarcodeBizTypeEnum.WORKSTATION,
|
||||
row.code,
|
||||
row.name,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出工作站 */
|
||||
async function handleExport() {
|
||||
const data = await exportWorkstation(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '工作站.xls', source: data });
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getWorkstationPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationApi.Workstation>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【基础】车间设置、工作站设置"
|
||||
url="https://doc.iocoder.cn/mes/md/workshop/"
|
||||
/>
|
||||
</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:md-workstation:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:md-workstation:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</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:md-workstation:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:md-workstation:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '条码',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
auth: ['mes:md-workstation:query'],
|
||||
onClick: handleBarcode.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElButton, ElMessage, ElTabPane, ElTabs } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createWorkstation,
|
||||
getWorkstation,
|
||||
updateWorkstation,
|
||||
} from '#/api/mes/md/workstation';
|
||||
import { $t } from '#/locales';
|
||||
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||
import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
import MachineList from './machine-list.vue';
|
||||
import ToolList from './tool-list.vue';
|
||||
import WorkerList from './worker-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstationForm' });
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const subTabsName = ref('machine'); // 当前资源页签
|
||||
const formData = ref<MesMdWorkstationApi.Workstation>();
|
||||
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); // 条码详情弹窗
|
||||
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
const titles: Record<FormMode, string> = {
|
||||
create: '新增工作站',
|
||||
update: '修改工作站',
|
||||
detail: '查看工作站',
|
||||
};
|
||||
return titles[formMode.value];
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-1',
|
||||
labelWidth: 110,
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
/** 表单 schema 需要 formApi 引用,所以通过 setState 设置 schema */
|
||||
formApi.setState({ schema: useFormSchema(formApi) });
|
||||
|
||||
/** 查看工作站条码 */
|
||||
function handleBarcode() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
barcodeDetailRef.value?.openByBusiness(
|
||||
formData.value.id,
|
||||
BarcodeBizTypeEnum.WORKSTATION,
|
||||
formData.value.code,
|
||||
formData.value.name,
|
||||
);
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (isDetail.value) {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesMdWorkstationApi.Workstation;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
const id = await createWorkstation(data);
|
||||
formData.value = { ...data, id };
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
} else {
|
||||
await updateWorkstation(data);
|
||||
formData.value = { ...formData.value, ...data };
|
||||
}
|
||||
emit('success');
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
await formApi.resetForm();
|
||||
subTabsName.value = 'machine';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getWorkstation(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<ElTabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-model="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
<ElTabPane name="machine" label="设备资源">
|
||||
<MachineList :form-type="formMode" :workstation-id="formData.id" />
|
||||
</ElTabPane>
|
||||
<ElTabPane name="tool" label="工装夹具">
|
||||
<ToolList :form-type="formMode" :workstation-id="formData.id" />
|
||||
</ElTabPane>
|
||||
<ElTabPane name="worker" label="人力资源">
|
||||
<WorkerList :form-type="formMode" :workstation-id="formData.id" />
|
||||
</ElTabPane>
|
||||
</ElTabs>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center">
|
||||
<ElButton
|
||||
v-if="isDetail && formData?.id"
|
||||
type="primary"
|
||||
@click="handleBarcode"
|
||||
>
|
||||
查看条码
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
<BarcodeDetail ref="barcodeDetailRef" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,213 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationMachineApi } from '#/api/mes/md/workstation/machine';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { ElButton, ElDialog, ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm, z } from '#/adapter/form';
|
||||
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getMachinerySimpleList } from '#/api/mes/dv/machinery';
|
||||
import {
|
||||
createWorkstationMachine,
|
||||
deleteWorkstationMachine,
|
||||
getWorkstationMachineList,
|
||||
} from '#/api/mes/md/workstation/machine';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstationMachineList' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
workstationId: number;
|
||||
}>(),
|
||||
{
|
||||
formType: 'update',
|
||||
},
|
||||
);
|
||||
|
||||
const isReadOnly = computed(() => props.formType === 'detail'); // 是否只读
|
||||
const formOpen = ref(false); // 设备资源表单是否打开
|
||||
const formLoading = ref(false); // 设备资源表单提交中
|
||||
const list = ref<MesMdWorkstationMachineApi.WorkstationMachine[]>([]); // 设备资源列表
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{ fieldName: 'workstationId', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{
|
||||
fieldName: 'machineryId',
|
||||
label: '设备',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getMachinerySimpleList,
|
||||
clearable: true,
|
||||
labelField: 'name',
|
||||
placeholder: '请选择设备',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 1,
|
||||
precision: 0,
|
||||
},
|
||||
rules: z.number().default(1),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: { placeholder: '请输入备注', rows: 3 },
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
autoResize: true,
|
||||
border: true,
|
||||
columns: [
|
||||
{ field: 'machineryCode', title: '设备编码', width: 140 },
|
||||
{ field: 'machineryName', title: '设备名称', minWidth: 160 },
|
||||
{ field: 'quantity', title: '数量', width: 100 },
|
||||
{ field: 'remark', title: '备注', minWidth: 160 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 90,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !isReadOnly.value,
|
||||
},
|
||||
],
|
||||
data: list.value,
|
||||
minHeight: 240,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
keyField: 'id',
|
||||
},
|
||||
showOverflow: true,
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationMachineApi.WorkstationMachine>,
|
||||
});
|
||||
|
||||
/** 加载设备资源列表 */
|
||||
async function getList() {
|
||||
gridApi.setLoading(true);
|
||||
try {
|
||||
list.value = await getWorkstationMachineList(props.workstationId);
|
||||
gridApi.setGridOptions({ data: list.value });
|
||||
} finally {
|
||||
gridApi.setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开设备资源表单 */
|
||||
async function openForm() {
|
||||
formOpen.value = true;
|
||||
await formApi.resetForm();
|
||||
await formApi.setValues({
|
||||
quantity: 1,
|
||||
workstationId: props.workstationId,
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交设备资源表单 */
|
||||
async function submitForm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
formLoading.value = true;
|
||||
try {
|
||||
const data = (await formApi.getValues()) as MesMdWorkstationMachineApi.WorkstationMachine;
|
||||
await createWorkstationMachine(data);
|
||||
formOpen.value = false;
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
await getList();
|
||||
} finally {
|
||||
formLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除设备资源 */
|
||||
async function handleDelete(id: number) {
|
||||
await deleteWorkstationMachine(id);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', ['设备资源']));
|
||||
await getList();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.workstationId,
|
||||
(value) => {
|
||||
if (value) {
|
||||
getList();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!isReadOnly" class="mb-3 flex items-center justify-start">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '添加设备',
|
||||
type: 'primary',
|
||||
onClick: openForm,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
<Grid class="w-full">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
popConfirm: {
|
||||
title: '确认删除该设备资源吗?',
|
||||
confirm: handleDelete.bind(null, row.id!),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<ElDialog v-model="formOpen" title="添加设备" width="520px">
|
||||
<Form class="mx-4" />
|
||||
<template #footer>
|
||||
<ElButton @click="formOpen = false">取消</ElButton>
|
||||
<ElButton type="primary" :loading="formLoading" @click="submitForm">
|
||||
确定
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationToolApi } from '#/api/mes/md/workstation/tool';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { ElButton, ElDialog, ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm, z } from '#/adapter/form';
|
||||
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
createWorkstationTool,
|
||||
deleteWorkstationTool,
|
||||
getWorkstationToolList,
|
||||
updateWorkstationTool,
|
||||
} from '#/api/mes/md/workstation/tool';
|
||||
import { getToolTypeSimpleList } from '#/api/mes/tm/tool/type';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstationToolList' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
workstationId: number;
|
||||
}>(),
|
||||
{
|
||||
formType: 'update',
|
||||
},
|
||||
);
|
||||
|
||||
const isReadOnly = computed(() => props.formType === 'detail'); // 是否只读
|
||||
const formOpen = ref(false); // 工装夹具表单是否打开
|
||||
const formLoading = ref(false); // 工装夹具表单提交中
|
||||
const formData = ref<MesMdWorkstationToolApi.WorkstationTool>();
|
||||
const list = ref<MesMdWorkstationToolApi.WorkstationTool[]>([]); // 工装夹具列表
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{ fieldName: 'id', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{ fieldName: 'workstationId', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{
|
||||
fieldName: 'toolTypeId',
|
||||
label: '工具类型',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getToolTypeSimpleList,
|
||||
clearable: true,
|
||||
labelField: 'name',
|
||||
placeholder: '请选择工具类型',
|
||||
valueField: 'id',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['id'],
|
||||
disabled: (values) => !!values.id,
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 1,
|
||||
precision: 0,
|
||||
},
|
||||
rules: z.number().default(1),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: { placeholder: '请输入备注', rows: 3 },
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
autoResize: true,
|
||||
border: true,
|
||||
columns: [
|
||||
{ field: 'toolTypeId', title: '工具类型编号', width: 140 },
|
||||
{ field: 'toolTypeName', title: '工具类型名称', minWidth: 160 },
|
||||
{ field: 'quantity', title: '数量', width: 100 },
|
||||
{ field: 'remark', title: '备注', minWidth: 160 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 130,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !isReadOnly.value,
|
||||
},
|
||||
],
|
||||
data: list.value,
|
||||
minHeight: 240,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
keyField: 'id',
|
||||
},
|
||||
showOverflow: true,
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationToolApi.WorkstationTool>,
|
||||
});
|
||||
|
||||
/** 加载工装夹具列表 */
|
||||
async function getList() {
|
||||
gridApi.setLoading(true);
|
||||
try {
|
||||
list.value = await getWorkstationToolList(props.workstationId);
|
||||
gridApi.setGridOptions({ data: list.value });
|
||||
} finally {
|
||||
gridApi.setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开工装夹具表单 */
|
||||
async function openForm(row?: MesMdWorkstationToolApi.WorkstationTool) {
|
||||
formOpen.value = true;
|
||||
formData.value = row;
|
||||
await formApi.resetForm();
|
||||
await formApi.setValues({
|
||||
quantity: 1,
|
||||
workstationId: props.workstationId,
|
||||
...row,
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交工装夹具表单 */
|
||||
async function submitForm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
formLoading.value = true;
|
||||
try {
|
||||
const data = (await formApi.getValues()) as MesMdWorkstationToolApi.WorkstationTool;
|
||||
await (formData.value?.id ? updateWorkstationTool(data) : createWorkstationTool(data));
|
||||
formOpen.value = false;
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
await getList();
|
||||
} finally {
|
||||
formLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除工装夹具 */
|
||||
async function handleDelete(id: number) {
|
||||
await deleteWorkstationTool(id);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', ['工装夹具']));
|
||||
await getList();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.workstationId,
|
||||
(value) => {
|
||||
if (value) {
|
||||
getList();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!isReadOnly" class="mb-3 flex items-center justify-start">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '添加工具',
|
||||
type: 'primary',
|
||||
onClick: openForm.bind(null, undefined),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
<Grid class="w-full">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '编辑',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
onClick: openForm.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
popConfirm: {
|
||||
title: '确认删除该工装夹具吗?',
|
||||
confirm: handleDelete.bind(null, row.id!),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<ElDialog
|
||||
v-model="formOpen"
|
||||
:title="formData?.id ? '编辑工具' : '添加工具'"
|
||||
width="520px"
|
||||
>
|
||||
<Form class="mx-4" />
|
||||
<template #footer>
|
||||
<ElButton @click="formOpen = false">取消</ElButton>
|
||||
<ElButton type="primary" :loading="formLoading" @click="submitForm">
|
||||
确定
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationWorkerApi } from '#/api/mes/md/workstation/worker';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { ElButton, ElDialog, ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm, z } from '#/adapter/form';
|
||||
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
createWorkstationWorker,
|
||||
deleteWorkstationWorker,
|
||||
getWorkstationWorkerList,
|
||||
updateWorkstationWorker,
|
||||
} from '#/api/mes/md/workstation/worker';
|
||||
import { getSimplePostList } from '#/api/system/post';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
defineOptions({ name: 'MesMdWorkstationWorkerList' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
workstationId: number;
|
||||
}>(),
|
||||
{
|
||||
formType: 'update',
|
||||
},
|
||||
);
|
||||
|
||||
const isReadOnly = computed(() => props.formType === 'detail'); // 是否只读
|
||||
const formOpen = ref(false); // 人力资源表单是否打开
|
||||
const formLoading = ref(false); // 人力资源表单提交中
|
||||
const formData = ref<MesMdWorkstationWorkerApi.WorkstationWorker>();
|
||||
const list = ref<MesMdWorkstationWorkerApi.WorkstationWorker[]>([]); // 人力资源列表
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [
|
||||
{ fieldName: 'id', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{ fieldName: 'workstationId', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
||||
{
|
||||
fieldName: 'postId',
|
||||
label: '岗位',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getSimplePostList,
|
||||
clearable: true,
|
||||
labelField: 'name',
|
||||
placeholder: '请选择岗位',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 1,
|
||||
precision: 0,
|
||||
},
|
||||
rules: z.number().default(1),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: { placeholder: '请输入备注', rows: 3 },
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
autoResize: true,
|
||||
border: true,
|
||||
columns: [
|
||||
{ field: 'postId', title: '岗位编号', width: 140 },
|
||||
{ field: 'postName', title: '岗位名称', minWidth: 160 },
|
||||
{ field: 'quantity', title: '数量', width: 100 },
|
||||
{ field: 'remark', title: '备注', minWidth: 160 },
|
||||
{
|
||||
title: '操作',
|
||||
width: 130,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
visible: !isReadOnly.value,
|
||||
},
|
||||
],
|
||||
data: list.value,
|
||||
minHeight: 240,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
isHover: true,
|
||||
keyField: 'id',
|
||||
},
|
||||
showOverflow: true,
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesMdWorkstationWorkerApi.WorkstationWorker>,
|
||||
});
|
||||
|
||||
/** 加载人力资源列表 */
|
||||
async function getList() {
|
||||
gridApi.setLoading(true);
|
||||
try {
|
||||
list.value = await getWorkstationWorkerList(props.workstationId);
|
||||
gridApi.setGridOptions({ data: list.value });
|
||||
} finally {
|
||||
gridApi.setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开人力资源表单 */
|
||||
async function openForm(row?: MesMdWorkstationWorkerApi.WorkstationWorker) {
|
||||
formOpen.value = true;
|
||||
formData.value = row;
|
||||
await formApi.resetForm();
|
||||
await formApi.setValues({
|
||||
quantity: 1,
|
||||
workstationId: props.workstationId,
|
||||
...row,
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交人力资源表单 */
|
||||
async function submitForm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
formLoading.value = true;
|
||||
try {
|
||||
const data = (await formApi.getValues()) as MesMdWorkstationWorkerApi.WorkstationWorker;
|
||||
await (formData.value?.id ? updateWorkstationWorker(data) : createWorkstationWorker(data));
|
||||
formOpen.value = false;
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
await getList();
|
||||
} finally {
|
||||
formLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除人力资源 */
|
||||
async function handleDelete(id: number) {
|
||||
await deleteWorkstationWorker(id);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', ['人力资源']));
|
||||
await getList();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.workstationId,
|
||||
(value) => {
|
||||
if (value) {
|
||||
getList();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="!isReadOnly" class="mb-3 flex items-center justify-start">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '添加人员',
|
||||
type: 'primary',
|
||||
onClick: openForm.bind(null, undefined),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
<Grid class="w-full">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '编辑',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
onClick: openForm.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
popConfirm: {
|
||||
title: '确认删除该人力资源吗?',
|
||||
confirm: handleDelete.bind(null, row.id!),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<ElDialog
|
||||
v-model="formOpen"
|
||||
:title="formData?.id ? '编辑人员' : '添加人员'"
|
||||
width="520px"
|
||||
>
|
||||
<Form class="mx-4" />
|
||||
<template #footer>
|
||||
<ElButton @click="formOpen = false">取消</ElButton>
|
||||
<ElButton type="primary" :loading="formLoading" @click="submitForm">
|
||||
确定
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -16,6 +16,7 @@ export const MesAutoCodeRuleCode = {
|
|||
MD_ITEM_TYPE_CODE: 'MD_ITEM_TYPE_CODE',
|
||||
MD_ITEM_CODE: 'MD_ITEM_CODE',
|
||||
MD_VENDOR_CODE: 'MD_VENDOR_CODE',
|
||||
MD_WORKSTATION_CODE: 'MD_WORKSTATION_CODE',
|
||||
MD_WORKSHOP_CODE: 'MD_WORKSHOP_CODE',
|
||||
} as const;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue