From 2cd045a6da3490443eeb7dc56620ee5553fc1e45 Mon Sep 17 00:00:00 2001 From: Yanko <747575620@qq.com> Date: Fri, 23 Aug 2024 10:39:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BPA.MES.Base.Application.xml | 241 +++++++ .../Entitys/Base/FinalMaterialEntity.cs | 39 + .../Dtos/FinalMaterialDto.cs | 98 +++ .../Services/FinalMaterialService.cs | 130 ++++ .../Services/IFinalMaterialService.cs | 49 ++ .../Services/ProductLineService.cs | 2 +- .../Services/ProductLineStepsService.cs | 2 +- frontend/src/api/finalMaterial/dto.d.ts | 303 ++++++++ frontend/src/api/finalMaterial/service.ts | 89 +++ frontend/src/pages/final/index.tsx | 275 ++++--- frontend/src/pages/productLine/line.tsx | 671 +++++++++--------- 11 files changed, 1475 insertions(+), 424 deletions(-) create mode 100644 backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs create mode 100644 backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs create mode 100644 backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs create mode 100644 backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/IFinalMaterialService.cs create mode 100644 frontend/src/api/finalMaterial/dto.d.ts create mode 100644 frontend/src/api/finalMaterial/service.ts diff --git a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml index 7a42e4e..fbad5c8 100644 --- a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml +++ b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml @@ -915,6 +915,36 @@ 排序 + + + 成品配方 + + + + + 物料Id + + + + + 配方Id + + + + + 重量 + + + + + 描述 + + + + + 误差 + + 名 称 :分组信息 @@ -4687,6 +4717,104 @@ + + + 名 称 :配方物料Dto类 + 创 建 人 :yangxiao + 创建时间 :2023/3/2 16:12:06 + 描 述 : + + + + + 物料Id + + + + + 成品Id + + + + + 重量 + + + + + 描述 + + + + + 误差 + + + + + 增加 + + + + + 更新 + + + + + 主键 + + + + + 删除 + + + + + 主键 + + + + + 不分页 + + + + + 配方Id + + + + + 分页 + + + + + 输出 + + + + + 主键 + + + + + 配方名称 + + + + + 物料名称 + + + + + 物料编码 + + 名 称 :成品管理 @@ -4775,6 +4903,67 @@ 工艺名称 + + + 名 称 :配方物料服务 + 创 建 人 :yangxiao + 创建时间 :2023/3/2 16:11:04 + 描 述 :配方物料数据维护 + + + + + 增加 + + + + + + + 批量增加 + + + + + + + + 删除 + + + + + + + + 详情 + + + + + + + + 列表 + + + + + + + 分页 + + + + + + + 更新 + + + + + 名 称 :成品管理服务 @@ -4835,6 +5024,58 @@ + + + 名 称 :成品配方物料服务 + 创 建 人 :yangxiao + 创建时间 :2023/3/2 18:33:18 + 描 述 : + + + + + 增加 + + + + + + 批量增加 + + + + + + + 移除 + + + + + + 更新 + + + + + + 不分页列表 + + + + + + 分页列表 + + + + + + 查询单条 + + + + 名 称 :成品信息管理 diff --git a/backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs new file mode 100644 index 0000000..c8d0c23 --- /dev/null +++ b/backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPA.MES.Base.Application.Entitys +{ + /// + /// 成品配方 + /// + [SugarTable("final_material")] + public class FinalMaterialEntity : DEntityBase + { + /// + /// 物料Id + /// + public string MaterialId { get; set; } + /// + /// 配方Id + /// + public string FinalId { get; set; } + /// + /// 重量 + /// + [SugarColumn(IsNullable = true)] + public string Weight { get; set; } + /// + /// 描述 + /// + [SugarColumn(IsNullable = true)] + public string Describe { get; set; } + /// + /// 误差 + /// + [SugarColumn(IsNullable = true)] + public string ErrorWeight { get; set; } + } +} diff --git a/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs new file mode 100644 index 0000000..024f455 --- /dev/null +++ b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs @@ -0,0 +1,98 @@ +namespace BPA.MES.Base.Application.Services +{ + /// + /// 名 称 :配方物料Dto类 + /// 创 建 人 :yangxiao + /// 创建时间 :2023/3/2 16:12:06 + /// 描 述 : + /// + public class FinalMaterialDto + { + /// + /// 物料Id + /// + public string MaterialId { get; set; } + /// + /// 成品Id + /// + public string FinalId { get; set; } + /// + /// 重量 + /// + public string Weight { get; set; } + /// + /// 描述 + /// + public string Describe { get; set; } + /// + /// 误差 + /// + public string ErrorWeight { get; set; } + } + /// + /// 增加 + /// + public class FinalMaterialAddInput : FinalMaterialDto + { + + } + /// + /// 更新 + /// + public class FinalMaterialUpdateInput : FinalMaterialDto + { + /// + /// 主键 + /// + public string Id { get; set; } + } + /// + /// 删除 + /// + public class FinalMaterialDelInput + { + /// + /// 主键 + /// + public string Id { get; set; } + } + /// + /// 不分页 + /// + public class FinalMaterialQueryInput + { + /// + /// 配方Id + /// + public string FinalId { get; set; } + } + /// + /// 分页 + /// + public class FinalMaterialQueryPageInput : RequestPage + { + + } + /// + /// 输出 + /// + public class FinalMaterialOutput : FinalMaterialDto + { + /// + /// 主键 + /// + public string Id { get; set; } + /// + /// 配方名称 + /// + public string RecipesName { get; set; } + /// + /// 物料名称 + /// + public string MaterialName { get; set; } + /// + /// 物料编码 + /// + public string MaterialCode { get; set; } + } +} diff --git a/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs new file mode 100644 index 0000000..42d2043 --- /dev/null +++ b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs @@ -0,0 +1,130 @@ +namespace BPA.MES.Base.Application.Services +{ + /// + /// 名 称 :配方物料服务 + /// 创 建 人 :yangxiao + /// 创建时间 :2023/3/2 16:11:04 + /// 描 述 :配方物料数据维护 + /// + [ApiDescriptionSettings("配方工艺管理", Name = "FinalMaterial", Tag = "配方物料服务", KeepName = true, SplitCamelCase = true, KeepVerb = true)] + public class FinalMaterialService : IFinalMaterialService, ITransient, IDynamicApiController + { + private readonly ISqlSugarClient _dbContext; + public FinalMaterialService(ISqlSugarClient db) + { + _dbContext = db; + } + /// + /// 增加 + /// + /// + /// + [HttpPost] + public async Task Add(FinalMaterialAddInput input) + { + FinalMaterialEntity entity = input.Adapt(); + return await _dbContext.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandIdentityIntoEntityAsync(); + } + /// + /// 批量增加 + /// + /// + /// + /// + public async Task BatchAdd(List inputs) + { + bool result = false; + List entitys = inputs.Adapt>(); + try + { + _dbContext.Ado.BeginTran(); + await _dbContext.Deleteable().Where(x => x.FinalId == inputs[0].FinalId).ExecuteCommandAsync(); + await _dbContext.Insertable(entitys).ExecuteCommandAsync(); + _dbContext.Ado.CommitTran(); + result = true; + } + catch (Exception ex) + { + _dbContext.Ado.RollbackTran(); + throw Oops.Bah("保存失败!"); + } + return result; + } + + /// + /// 删除 + /// + /// + /// + /// + [HttpPost] + public async Task Del(FinalMaterialDelInput input) + { + var res = await _dbContext.Deleteable().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync(); + return res; + } + /// + /// 详情 + /// + /// + /// + /// + [HttpGet] + public async Task Detail(string Id) + { + var entity = await _dbContext.Queryable().FirstAsync(x => x.Id == Id); + FinalMaterialOutput output = entity.Adapt(); + return output; + } + /// + /// 列表 + /// + /// + /// + [HttpPost,AllowAnonymous] + public async Task> List(FinalMaterialQueryInput input) + { + var output = await _dbContext.Queryable() + .LeftJoin((a,b)=>a.MaterialId==b.Id) + .WhereIF(!string.IsNullOrEmpty(input.FinalId),(a,b)=>a.FinalId==input.FinalId) + .Select((a,b)=>new FinalMaterialOutput + { + Id = a.Id, + MaterialName = b.Name, + MaterialCode = b.Code, + MaterialId = b.Id, + FinalId = a.FinalId, + RecipesName = b.Name, + ErrorWeight = a.ErrorWeight, + Weight = a.Weight + }) + .ToListAsync(); + return output; + } + /// + /// 分页 + /// + /// + /// + [HttpPost] + public async Task> PagedList(FinalMaterialQueryPageInput input) + { + var entity = await _dbContext.Queryable() + .ToPagedListAsync(input.PageIndex, input.PageSize); + SqlSugarPagedList output = entity.Adapt>(); + return output; + } + /// + /// 更新 + /// + /// + /// + /// + [HttpPost] + public async Task Update(FinalMaterialUpdateInput input) + { + var res = await _dbContext.Updateable().ExecuteCommandHasChangeAsync(); + return res; + } + } +} diff --git a/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/IFinalMaterialService.cs b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/IFinalMaterialService.cs new file mode 100644 index 0000000..4880ebe --- /dev/null +++ b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/IFinalMaterialService.cs @@ -0,0 +1,49 @@ +namespace BPA.MES.Base.Application.Services +{ + /// + /// 名 称 :成品配方物料服务 + /// 创 建 人 :yangxiao + /// 创建时间 :2023/3/2 18:33:18 + /// 描 述 : + /// + public interface IFinalMaterialService + { + /// + /// 增加 + /// + /// + Task Add(FinalMaterialAddInput input); + /// + /// 批量增加 + /// + /// + /// + Task BatchAdd(List inputs); + /// + /// 移除 + /// + /// + Task Del(FinalMaterialDelInput input); + /// + /// 更新 + /// + /// + Task Update(FinalMaterialUpdateInput input); + /// + /// 不分页列表 + /// + /// + Task> List(FinalMaterialQueryInput input); + /// + /// 分页列表 + /// + /// + Task> PagedList(FinalMaterialQueryPageInput input); + /// + /// 查询单条 + /// + /// + /// + Task Detail(string Id); + } +} diff --git a/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs b/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs index 2a64b93..98b1702 100644 --- a/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs +++ b/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs @@ -107,7 +107,7 @@ [HttpPost] public async Task Update(ProductLineUpdateInput input) { - var isExit =await _dbContext.Queryable().Where(x => x.Id != input.Id && (x.Name == input.Name || x.Code == input.Code)).FirstAsync(); + var isExit =await _dbContext.Queryable().Where(x => x.Id != input.Id && (x.Name == input.Name)).FirstAsync(); if (isExit != null) { throw Oops.Bah("名称或编码已存在!"); diff --git a/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineStepsService.cs b/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineStepsService.cs index 178b117..bbaf36d 100644 --- a/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineStepsService.cs +++ b/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineStepsService.cs @@ -114,7 +114,7 @@ namespace BPA.MES.Base.Application.Services // throw Oops.Bah("名称已存在!"); //} var entity = input.Adapt(); - var res = await _dbContext.Updateable(entity).IgnoreColumns(true).ExecuteCommandHasChangeAsync(); + var res = await _dbContext.Updateable(entity).IgnoreColumns(it=>it.Step).IgnoreColumns(true).ExecuteCommandHasChangeAsync(); return res; } /// diff --git a/frontend/src/api/finalMaterial/dto.d.ts b/frontend/src/api/finalMaterial/dto.d.ts new file mode 100644 index 0000000..ed38077 --- /dev/null +++ b/frontend/src/api/finalMaterial/dto.d.ts @@ -0,0 +1,303 @@ +declare namespace finalMaterialTypes { + /** + * 基类 + */ + type base_dto = { + materialId: string, + finalId: string, + weight: string, + } + /** + * 增加输入参数 + */ + type addInput = base_dto + /** + * 更新输入参数 + */ + interface updateInput extends base_dto { + /** + * 主键 + */ + id: string + } + /** + * 删除输入参数 + */ + interface delInput { + /** + * 主键 + */ + id: string + } + /** + * 查询输入参数 + */ + interface queryParms { + /** + * 名称 + */ + name?: null | string; + finalId: string, + } + /** + * 查询分页输入参数 + */ + interface queryPage { + pageIndex: number, + pageSize: number, + /** + * 报警信息 + */ + msgInfo?: null | string; + /** + * 报警值 + */ + value?: null | string; + /** + * 报警等级 + */ + grade?: null | string; + /** + * 设备名称 + */ + deviceName?: null | string; + startTime?: Date | null + endTime?: Date | null, + } + /** + * 查询输出参数 + */ + interface output extends base_dto { + /** + * 主键 + */ + id: string + } +} +declare namespace programlog { + /** + * 基类 + */ + type base_dto = { + /** + * 类型 + */ + logType?: null | number; + /** + * 日志消息 + */ + msgInfo?: null | string; + createDate: string; + } + /** + * 增加输入参数 + */ + type addInput = base_dto + /** + * 更新输入参数 + */ + interface updateInput extends base_dto { + /** + * 主键 + */ + id: string + } + /** + * 删除输入参数 + */ + interface delInput { + /** + * 主键 + */ + id: string + } + /** + * 查询输入参数 + */ + interface queryParms { + /** + * 日志消息 + */ + msgInfo?: null | string; + } + /** + * 查询分页输入参数 + */ + interface queryPage { + pageIndex: number, + pageSize: number, + /** + * 编码 + */ + logType?: null | number; + /** + * 日志消息 + */ + msgInfo?: null | string; + + startTime?: Date | null; + endTime?: Date | null + } + /** + * 查询输出参数 + */ + interface output extends base_dto { + /** + * 主键 + */ + id: string + } +} +declare namespace userlog { + /** + * 基类 + */ + type base_dto = { + /** + * 权限 + */ + permission?: null | string; + /** + * 用户名 + */ + userName?: null | string; + /** + * 日志消息 + */ + msgInfo?: null | string; + + createDate: string; + + } + /** + * 增加输入参数 + */ + type addInput = base_dto + /** + * 更新输入参数 + */ + interface updateInput extends base_dto { + /** + * 主键 + */ + id: string + typeId: string + } + /** + * 删除输入参数 + */ + interface delInput { + /** + * 主键 + */ + id: string + } + /** + * 查询输入参数 + */ + interface queryParms { + /** + * 名称 + */ + name?: null | string; + } + /** + * 查询分页输入参数 + */ + interface queryPage { + pageIndex: number, + pageSize: number, + /** + * 用户名 + */ + userName?: null | string; + /** + * 日志消息 + */ + msgInfo?: null | string; + } + /** + * 查询输出参数 + */ + interface output extends base_dto { + /** + * 主键 + */ + id: string + } +} +declare namespace runlog { + /** + * 基类 + */ + type base_dto = { + /** + * 日志类别 + */ + logType?: null | string; + /** + * 日志消息 + */ + msgInfo?: null | string; + createDate: string + + } + /** + * 增加输入参数 + */ + type addInput = base_dto + /** + * 更新输入参数 + */ + interface updateInput extends base_dto { + /** + * 主键 + */ + id: string + typeId: string + } + /** + * 删除输入参数 + */ + interface delInput { + /** + * 主键 + */ + id: string + } + /** + * 查询输入参数 + */ + interface queryParms { + /** + * 名称 + */ + name?: null | string; + } + /** + * 查询分页输入参数 + */ + interface queryPage { + pageIndex: number, + pageSize: number, + /** + * 日志类别 + */ + logType?: null | string; + /** + * 日志消息 + */ + msgInfo?: null | string; + startTime?: Date | null; + endTime?: Date | null + } + /** + * 查询输出参数 + */ + interface output extends base_dto { + /** + * 主键 + */ + id: string + } +} \ No newline at end of file diff --git a/frontend/src/api/finalMaterial/service.ts b/frontend/src/api/finalMaterial/service.ts new file mode 100644 index 0000000..8905ec6 --- /dev/null +++ b/frontend/src/api/finalMaterial/service.ts @@ -0,0 +1,89 @@ + +import { request } from '@umijs/max'; + + +export default { + /** + * 新增 + * @param parms + * @returns + */ + Add(parms: finalMaterialTypes.addInput) { + return request('/api/finalmaterial/add', { + method: 'POST', + data: { + ...parms, + }, + }); + }, + /** + * 删除 + * @param parms + * @returns + */ + Del(parms: finalMaterialTypes.delInput) { + return request(`/api/finalmaterial/del`, { + method: 'POST', + data: { + ...parms, + }, + }); + }, + /** + * 修改 + * @param parms + * @returns + */ + Update(parms: finalMaterialTypes.updateInput) { + return request('/api/finalmaterial/update', { + method: 'POST', + data: { + ...parms, + }, + }); + }, + /** + * 详情 + * @param parms + * @returns + */ + Detail(id: string) { + return request(`/api/finalmaterial/detail?id=${id}`, { + method: 'GET' + }); + }, + /** + * 获取列表 + * @param parms + * @returns + */ + List(parms: finalMaterialTypes.queryParms) { + return request('/api/finalmaterial/list', { + method: 'POST', + data: { + ...parms, + }, + }); + }, + /** + * 分页查询 + * @param parms + * @returns + */ + PagedList(parms: finalMaterialTypes.queryPage) { + return request('/api/finalmaterial/pagedlist', { + method: 'POST', + data: { + ...parms, + }, + }); + }, + //批量创建物料信息 + BatchAdd(parms: finalMaterialTypes.addInput[]){ + return request('/api/finalmaterial/batchadd', { + method: 'POST', + data: parms + }); +}, +} + diff --git a/frontend/src/pages/final/index.tsx b/frontend/src/pages/final/index.tsx index 12deadb..ff9a561 100644 --- a/frontend/src/pages/final/index.tsx +++ b/frontend/src/pages/final/index.tsx @@ -1,20 +1,24 @@ // 成品管理 -import type { ActionType, ProColumns } from '@ant-design/pro-components'; -import { ProTable } from '@ant-design/pro-components'; -import { Button, Modal, Form, Input, message, Popconfirm, TreeSelect, Select, Tag, Dropdown, Space, MenuProps } from 'antd'; +import type { ActionType, EditableFormInstance, ProColumns } from '@ant-design/pro-components'; +import { EditableProTable, ProCard, ProTable } from '@ant-design/pro-components'; +import { Button, Modal, Form, Input, message, Popconfirm, TreeSelect, Select, Tag, Dropdown, Space, MenuProps, Spin } from 'antd'; import { useEffect, useRef, useState } from 'react'; import finalInfoAPI from '@/api/finalService'; -import { DownOutlined } from '@ant-design/icons'; -import FormItem from 'antd/lib/form/FormItem'; -import { ItemType } from 'rc-menu/lib/interface'; // 工艺服务 -import craftsinfoAPI from '@/api/craftsinfo'; -// 配方服务 -import recipeAPI from '@/api/recipeService'; +import finalMaterialAPI from '@/api/finalMaterial/service'; +// 无聊服务 +import MaterialsInfoAPI from '@/api/materialService' const final = () => { - + const [formRef] = Form.useForm(); + const [spinStatus, setSpinStatus] = useState(false); + const [isEditModalOpen, setIsEditModalOpen] = useState(false); + const editactionformRef = useRef(); + const editactionRef = useRef(); + const [materiallist, setMateriallist] = useState([]); + const [selectMateriallist, setSelectMateriallist] = useState([]); + const [selectRowItem, setSelectRowItem] = useState(); //定于表单 // eslint-disable-next-line react-hooks/rules-of-hooks const [typeForm] = Form.useForm(); @@ -37,7 +41,6 @@ const final = () => { { title: 'id', dataIndex: 'id', - tip: '规则名称是唯一的 key', hideInSearch: true, hideInTable: true, }, @@ -54,19 +57,6 @@ const final = () => { hideInSearch: false, ellipsis: true, }, - { - title: '成品配方', - dataIndex: 'recipeName', - ellipsis: true, - hideInSearch: true, - }, - { - title: '成品工艺', - dataIndex: 'craftName', - ellipsis: true, - hideInSearch: true, - }, - { title: '操作', valueType: 'option', @@ -91,12 +81,32 @@ const final = () => { type="primary" ghost onClick={async () => { - setPeifangOpen(true); + + + setSpinStatus(true); + const jsonData: finalMaterialTypes.queryParms = { + finalId: record.id!, + }; + setSelectRowItem(record); + //根据工艺列表查询功能值 + finalMaterialAPI.List(jsonData) + .then((res: MyResponse.Content) => { + if (res.statusCode === 200) { + setMateriallist(res.data) + setPeifangOpen(true); + } + setSpinStatus(false) + }) + .catch(() => { + setPeifangOpen(false); + setSpinStatus(false) + }); // const copyFormData = JSON.parse(JSON.stringify(record)); // copyFormData.state = copyFormData.state === '0'; // typeForm.setFieldsValue(copyFormData); }}> 配方设置 + , { }, ]; - // eslint-disable-next-line react-hooks/rules-of-hooks - useEffect(() => { - if (isModalOpen) { - // 下拉工艺列表信息 - const formulaList = async () => { - - const crafts = await craftsinfoAPI.selectlist(); - // console.log(crafts); - - // eslint-disable-next-line @typescript-eslint/no-use-before-define - setformula(crafts.data); - }; - formulaList(); - // 下拉列表信息 - const areasList = async () => { - - const recipe = await recipeAPI.selectlist(); - // console.log(recipe); - - // eslint-disable-next-line @typescript-eslint/no-use-before-define - setareas(recipe.data); - }; - areasList(); - } - }, [isModalOpen]); - - - - - - const OnSubmit = async (values: FinalTypes.Info) => { @@ -304,66 +283,152 @@ const final = () => { - - {/* 工艺列表 */} - - {/* - { - formula.map((item: MySelectType.Select) => { - return - {item.value} - - }) - } - - - - - {/* 配方列表 */} - - {/* - { - areas.map((item: MySelectType.Select) => { - return - {item.value} - - }) - } - - + { setPeifangOpen(false); + setMateriallist([]); }} - footer={[ - , - , - ]} + } else { + message.error("保存失败!"); + } + }); + }} > - + + +
+ + rowKey="id" + controlled + editableFormRef={editactionformRef} + actionRef={editactionRef} + columns={[ + { + title: '物料名称', + dataIndex: 'materialId', + valueType: 'select', + ellipsis: true, + request: async () => { + const res: MyResponse.Content = await MaterialsInfoAPI.List(); + const myData: any[] = []; + if (res.statusCode === 200) { + setSelectMateriallist(res.data) + res.data.map((item: MaterialsTypes.Info) => ( + myData.push({ + label: `${item.name}[${item.unit}]`, + value: item.id, + }) + )) + } + return myData; + }, + formItemProps: () => { + return { + rules: [{ required: true, message: '此项为必填项' }] + }; + }, + }, + { + title: '重量', + dataIndex: 'weight', + valueType: 'text', + ellipsis: true, + formItemProps: () => { + return { + rules: [{ required: true, message: '此项为必填项' }], + }; + }, + }, + { + title: '重量误差(±)', + dataIndex: 'errorWeight', + valueType: 'text', + ellipsis: true, + formItemProps: () => { + return { + rules: [{ required: true, message: '此项为必填项' }], + }; + }, + }, + { + title: '操作', + valueType: 'option', + render: (_, row) => [ + , + + ], + }, + ]} + value={materiallist} + + recordCreatorProps={{ + record: () => ( + { + id: Date.now().toString(), + materialId: '', + finalId: '', + weight: '', + }) + , + } + } + editable={{ + form: formRef, + type: 'single', + onValuesChange: (record, recordList: finalMaterialTypes.output[]) => { + console.log(selectMateriallist); + if (!recordList) { + materiallist.push(record); + setMateriallist(materiallist); + } else { + setMateriallist(recordList); + } + console.log('materiallist', materiallist); + + }, + actionRender: (row, _, dom) => { + return [dom.delete, dom.save, dom.cancel]; + }, + }} + /> +
+
+
+ + diff --git a/frontend/src/pages/productLine/line.tsx b/frontend/src/pages/productLine/line.tsx index c0478c0..4cc8535 100644 --- a/frontend/src/pages/productLine/line.tsx +++ b/frontend/src/pages/productLine/line.tsx @@ -20,39 +20,39 @@ import { v4 as uuid } from 'uuid' import productlineInfoAPI from '@/api/productlineInfo/service' import processAPI from '@/api/process/service'; import productlineInfoStepsAPI from '@/api/productlinesteps/service' -import { edges, nodes as newnodes } from './data'; +import { edges, nodes as newnodes } from './data'; export default () => { const [fromType, setFromType] = useState('table') const ref = useRef(); const actionRef = useRef(); - const Reolod = () =>{ + const Reolod = () => { ref.current?.resetFields() actionRef.current?.reload() } - - const [flowOpen,setFlowOpen] = useState(false) - const [flowItemOpen,setFlowItemOpen] = useState(false) - + + const [flowOpen, setFlowOpen] = useState(false) + const [flowItemOpen, setFlowItemOpen] = useState(false) + const columns: ProColumns[] = [ { title: '主键', dataIndex: 'id', width: 160, - - formItemProps: { - hidden:true + + formItemProps: { + hidden: true }, - hideInSearch:true + hideInSearch: true }, { title: '名称', dataIndex: 'name', ellipsis: true, width: 120, - formItemProps:{ - rules:[{ required: true, message: '此项为必填项!' }] + formItemProps: { + rules: [{ required: true, message: '此项为必填项!' }] } }, // { @@ -64,11 +64,11 @@ export default () => { // valueEnum:{ // 0: { // text: '人工', - + // }, // 1: { // text: '设备', - + // }, // }, // formItemProps:{ @@ -78,7 +78,7 @@ export default () => { { title: '描述', dataIndex: 'describe', - + search: false, }, { @@ -88,48 +88,54 @@ export default () => { return <>{dayjs(record.createTime).format("YYYY-MM-DD HH:mm:ss")} }, search: false, - hideInForm:true + hideInForm: true }, { title: '操作', valueType: 'option', render: (text, row) => [ - { - setFromType('form') + { + setFromType('form') ref.current?.setFieldsValue(row) }} key={+new Date() + Math.random()} target="_blank" rel="noopener noreferrer"> 编辑 - { + { setFlowOpen(true) setStepparams({ lineId: row.id }) }} key={+new Date() + Math.random()} target="_blank" rel="noopener noreferrer"> 配置工艺流程 - { - - productlineInfoAPI.Del(row).then((res: MyResponse.Content) => { - if (res.statusCode === 200) { - message.info("删除成功!"); - Reolod() - } else { - message.error(res.errors); - } - }) - }} - onCancel={() => { - message.info('已取消删除'); - }} - okText="确认" - cancelText="关闭" - > - - 删除 + { + // setFlowOpen(true) + // setStepparams({ lineId: row.id }) + }} key={+new Date() + Math.random()} target="_blank" rel="noopener noreferrer"> + 配置设备 + { + + productlineInfoAPI.Del(row).then((res: MyResponse.Content) => { + if (res.statusCode === 200) { + message.info("删除成功!"); + Reolod() + } else { + message.error(res.errors); + } + }) + }} + onCancel={() => { + message.info('已取消删除'); + }} + okText="确认" + cancelText="关闭" + > + + 删除 + ], @@ -143,8 +149,8 @@ export default () => { }, }; }); - const [selectLineItem,setSelectLineItem] = useState(); - const [processList,setProcessList] = useState(); + const [selectLineItem, setSelectLineItem] = useState(); + const [processList, setProcessList] = useState(); const [stepparams, setStepparams] = useState(); const [dongtaiformRef] = Form.useForm(); const { styles } = useStyles(); @@ -152,312 +158,343 @@ export default () => { const [nodes, , onNodesChange] = useNodesState(newnodes); const [node, setNode] = useState(null); const sortActionRef = useRef(); - const [proList,setProList] = useState([]); + const [proList, setProList] = useState([]); const [form] = Form.useForm(); useEffect(() => { - processAPI.Selectlist().then((v:MyResponse.Content)=>{ - if (v.statusCode===200) { - console.log('v.data',v.data); + processAPI.Selectlist().then((v: MyResponse.Content) => { + if (v.statusCode === 200) { + console.log('v.data', v.data); setProList(v.data) } }) - - + + }, []) return ( <> - - columns={columns} - type={fromType as 'table'} - formRef={ref} - actionRef={actionRef} - onSubmit={(params: any) => { - console.log(params); - if (fromType === 'form') { - if (params.id) { - productlineInfoAPI.Update(params).then((res: MyResponse.Content) => { - if (res.statusCode === 200) { - message.info("更新成功!"); - setFromType('table') - Reolod() - } else { - message.error(res.errors); - } - }) - } else { - productlineInfoAPI.Add(params).then((res: MyResponse.Content) => { - if (res.statusCode === 200) { - message.info("新增成功!"); - setFromType('table') - Reolod() - } else { - message.error(res.errors); - } - }) - } - } - }} - - form={{ignoreRules:true,// 自定义提交按钮的属性 - submitter: { - onReset:()=>{ - ref.current?.resetFields() - setFromType("table") - }, - searchConfig: { resetText: fromType === 'form' ? '返回': '重置',submitText: fromType === 'form' ? '提交': '查询'}, } - }} - request={async (params = {}) => { - const jsonData: productlineInfoTypes.queryPage = { - pageIndex: params.current || 1, - pageSize: params.pageSize || 10, - name: params.name || '', - }; - const response = await productlineInfoAPI.PagedList(jsonData); - if (response.statusCode === 200) { - return { - data: response.data.items, - success: true, - total: response.data.total, - }; + + columns={columns} + type={fromType as 'table'} + formRef={ref} + actionRef={actionRef} + onSubmit={(params: any) => { + console.log(params); + if (fromType === 'form') { + if (params.id) { + productlineInfoAPI.Update(params).then((res: MyResponse.Content) => { + if (res.statusCode === 200) { + message.info("更新成功!"); + setFromType('table') + Reolod() + } else { + message.error(res.errors); + } + }) } else { - return { - data: [], - success: false, - total: 0, - }; + productlineInfoAPI.Add(params).then((res: MyResponse.Content) => { + if (res.statusCode === 200) { + message.info("新增成功!"); + setFromType('table') + Reolod() + } else { + message.error(res.errors); + } + }) } - }} - pagination={{ - pageSize: 10, - showSizeChanger:false - }} - rowKey="id" - dateFormatter="string" - headerTitle="列表" - toolBarRender={() => [ - , - ]} - /> - { setFlowOpen(false) }} onCancel={_ => setFlowOpen(false)}> - -
- { - return {...element,title : proList.find((x)=>x.key==element.processId)?.value,status: 'finish', } - - }) - } + } + }} + + form={{ + ignoreRules: true,// 自定义提交按钮的属性 + submitter: { + onReset: () => { + ref.current?.resetFields() + setFromType("table") + }, + searchConfig: { resetText: fromType === 'form' ? '返回' : '重置', submitText: fromType === 'form' ? '提交' : '查询' }, + } + }} + request={async (params = {}) => { + const jsonData: productlineInfoTypes.queryPage = { + pageIndex: params.current || 1, + pageSize: params.pageSize || 10, + name: params.name || '', + }; + const response = await productlineInfoAPI.PagedList(jsonData); + if (response.statusCode === 200) { + return { + data: response.data.items, + success: true, + total: response.data.total, + }; + } else { + return { + data: [], + success: false, + total: 0, + }; + } + }} + pagination={{ + pageSize: 10, + showSizeChanger: false + }} + rowKey="id" + dateFormatter="string" + headerTitle="列表" + toolBarRender={() => [ + , + ]} /> + { setFlowOpen(false) }} onCancel={_ => setFlowOpen(false)}> + +
+ { + return { ...element, title: proList.find((x) => x.key == element.processId)?.value, status: 'finish', } + + }) + } + />
-
- - style={{width:'600px'}} - toolBarRender={() => [ - , - ]} - actionRef={sortActionRef} - - columns={[ - { - title: '工序', - dataIndex: 'step', - align: 'center', - hideInSearch: true, - render: (dom, rowData, index) => { - return ( - {`${index + 1}`} - ); + setFlowItemOpen(true) + }} + > + 添加步骤 + , + ]} + actionRef={sortActionRef} + + columns={[ + + { + title: '工序', + dataIndex: 'step', + align: 'center', + hideInSearch: true, + render: (dom, rowData, index) => { + return ( + {`${index + 1}`} + ); + }, }, - }, - { - title: '工艺名称', - dataIndex: 'processId', - align: 'center', - hideInSearch: true, - render(dom, entity, index, action, schema) { - return <>{proList.find((x)=>x.key==entity.processId)?.value} + { + title: 'Id', + dataIndex: 'id', + align: 'center', + + hideInSearch: true, }, - }, - { - title: '操作', - align: 'center', + { + title: '工艺名称', + dataIndex: 'processId', + align: 'center', + hideInSearch: true, + render(dom, entity, index, action, schema) { + return <>{proList.find((x) => x.key == entity.processId)?.value} + }, + }, + { + title: '操作', + align: 'center', - valueType: 'option', + valueType: 'option', - key: 'option', - render: (_, record, index, action) => [ - - - // typeForm.setFieldsValue(copyFormData); - // setIsSetpModalOpen(true); - }} - > - 编辑 - - - { - const delData: productlinestepsTypes.delInput = { - id: record.id, - }; - productlineInfoStepsAPI.Del(delData).then((r) => { - if (r.statusCode === 200) { - message.success(r.statusCode === 200 ? '删除成功' : r.message); - action?.reload(); - } - }); - }} - onCancel={() => { - message.info('已取消删除'); - }} - okText="确认" - cancelText="关闭" - > - - - - ], - }, - ]} - rowKey="step" - search={false} - pagination={{ pageSize: 100,showSizeChanger:false }} - - params={stepparams} - request={async (params = {}) => { - // if (!params.lineId) { - // return { - // data: [], - // success: false, - // total: 0, - // }; - // } - const jsonData: productlinestepsTypes.queryParms = { - lineId: params.lineId - }; - const response = await productlineInfoStepsAPI.List(jsonData); - if (response.statusCode === 200) { - setProcessList(response.data) - - return { - data: response.data, - success: true, - }; - } else { - return { - data: [], - success: false, - total: 0, + { + const delData: productlinestepsTypes.delInput = { + id: record.id, + }; + productlineInfoStepsAPI.Del(delData).then((r) => { + if (r.statusCode === 200) { + message.success(r.statusCode === 200 ? '删除成功' : r.message); + action?.reload(); + } + }); + }} + onCancel={() => { + message.info('已取消删除'); + }} + okText="确认" + cancelText="关闭" + > + + + + ], + }, + ]} + rowKey="step" + search={false} + pagination={{ pageSize: 100, showSizeChanger: false }} + + params={stepparams} + request={async (params = {}) => { + // if (!params.lineId) { + // return { + // data: [], + // success: false, + // total: 0, + // }; + // } + const jsonData: productlinestepsTypes.queryParms = { + lineId: params.lineId }; - } - }} - dragSortKey="step" - onDragSortEnd={(beforeIndex: number, afterIndex: number,newDataSource: any[]) => { + const response = await productlineInfoStepsAPI.List(jsonData); + if (response.statusCode === 200) { + setProcessList(response.data) - console.log('newDataSource',newDataSource); - - // 模拟将排序后数据发送到服务器的场景 - // remoteData = newDataSource; - // 请求成功之后刷新列表 - newDataSource.map((item, index) => { - item.step = index + 1; - }) - console.log('排序后的数据', newDataSource); - productlineInfoStepsAPI.BatchUpdateStep(newDataSource).then((res: MyResponse.Content) => { - if (res.data) { - sortActionRef.current?.reload(); - message.success('修改列表排序成功'); + return { + data: response.data, + success: true, + }; + } else { + return { + data: [], + success: false, + total: 0, + }; } - }); + }} + dragSortKey="step" + onDragSortEnd={(beforeIndex: number, afterIndex: number, newDataSource: any[]) => { - }} - /> + console.log('newDataSource', newDataSource); + + // 模拟将排序后数据发送到服务器的场景 + // remoteData = newDataSource; + // 请求成功之后刷新列表 + newDataSource.map((item, index) => { + item.step = index + 1; + }) + console.log('排序后的数据', newDataSource); + productlineInfoStepsAPI.BatchUpdateStep(newDataSource).then((res: MyResponse.Content) => { + if (res.data) { + sortActionRef.current?.reload(); + message.success('修改列表排序成功'); + } + }); + + }} + />
- +
- +
- { - setFlowItemOpen(false) - }} + key="back" + onClick={() => { + setFlowItemOpen(false) + }} > - 返回 + 返回 , , - ]} - - onOk={() => { setFlowItemOpen(false) }} onCancel={_ => setFlowItemOpen(false)}> -
{ - console.log(v); - const jsonData:productlinestepsTypes.addInput = { - step: 0, - processId: v.processId, - id: '', - lineId: stepparams.lineId, - processName: '' - } - productlineInfoStepsAPI.Add(jsonData).then((v:MyResponse.Content)=>{ - if (v.statusCode===200) { - setFlowItemOpen(false) - sortActionRef.current?.reload(); - } - }) - }}> - - - - - -
+ ]} + + onOk={() => { setFlowItemOpen(false) }} onCancel={_ => setFlowItemOpen(false)}> +
{ + console.log(v); + if (v.id) { + const jsonData: productlinestepsTypes.addInput = { + step: 0, + processId: v.processId, + id: v.id, + lineId: stepparams.lineId, + processName: '' + } + productlineInfoStepsAPI.Update(jsonData).then((v: MyResponse.Content) => { + if (v.statusCode === 200) { + setFlowItemOpen(false) + sortActionRef.current?.reload(); + } + }) + } else { + const jsonData: productlinestepsTypes.addInput = { + step: 0, + processId: v.processId, + id: '', + lineId: stepparams.lineId, + processName: '' + } + productlineInfoStepsAPI.Add(jsonData).then((v: MyResponse.Content) => { + if (v.statusCode === 200) { + setFlowItemOpen(false) + sortActionRef.current?.reload(); + } + }) + } + + }}> + + + + + + +
);