密炼物料信息

This commit is contained in:
2026-05-06 17:15:52 +08:00
parent 76ed8f0534
commit d2941aa0c7
13 changed files with 540 additions and 2 deletions

11
.vscode/launch.json vendored
View File

@@ -0,0 +1,11 @@
{
"configurations": [
{
"type": "java",
"name": "JeecgSystemApplication",
"request": "launch",
"mainClass": "org.jeecg.JeecgSystemApplication",
"projectName": "jeecg-system-start"
}
]
}

View File

@@ -87,6 +87,25 @@ ON DUPLICATE KEY UPDATE
parent_id=VALUES(parent_id), name=VALUES(name), menu_type=VALUES(menu_type), perms=VALUES(perms), perms_type=VALUES(perms_type),
status=VALUES(status), del_flag=VALUES(del_flag);
-- 二级菜单密炼物料信息
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, menu_type, perms, perms_type, sort_no, is_route, is_leaf, hidden, status, del_flag, keep_alive, internal_or_external, create_by, create_time)
VALUES ('1860000000000000051', '1860000000000000001', '密炼物料信息', '/mes/mixermaterialinfo', 'mes/mixermaterialinfo/index', 'MesMixerMaterialList', 1, NULL, '1', 5, 1, 1, 0, '1', 0, 1, 0, 'admin', NOW())
ON DUPLICATE KEY UPDATE
parent_id=VALUES(parent_id), name=VALUES(name), url=VALUES(url), component=VALUES(component), component_name=VALUES(component_name),
menu_type=VALUES(menu_type), perms=VALUES(perms), perms_type=VALUES(perms_type), sort_no=VALUES(sort_no),
is_route=VALUES(is_route), is_leaf=VALUES(is_leaf), hidden=VALUES(hidden), status=VALUES(status), del_flag=VALUES(del_flag),
keep_alive=VALUES(keep_alive), internal_or_external=VALUES(internal_or_external);
INSERT INTO sys_permission(id,parent_id,name,menu_type,perms,perms_type,status,del_flag,create_by,create_time) VALUES
('1860000000000000052','1860000000000000051','新增',2,'mes:mes_mixer_material:add','1','1',0,'admin',NOW()),
('1860000000000000053','1860000000000000051','编辑',2,'mes:mes_mixer_material:edit','1','1',0,'admin',NOW()),
('1860000000000000054','1860000000000000051','删除',2,'mes:mes_mixer_material:delete','1','1',0,'admin',NOW()),
('1860000000000000055','1860000000000000051','批量删除',2,'mes:mes_mixer_material:deleteBatch','1','1',0,'admin',NOW()),
('1860000000000000056','1860000000000000051','导出',2,'mes:mes_mixer_material:exportXls','1','1',0,'admin',NOW()),
('1860000000000000057','1860000000000000051','导入',2,'mes:mes_mixer_material:importExcel','1','1',0,'admin',NOW())
ON DUPLICATE KEY UPDATE
parent_id=VALUES(parent_id), name=VALUES(name), menu_type=VALUES(menu_type), perms=VALUES(perms), perms_type=VALUES(perms_type),
status=VALUES(status), del_flag=VALUES(del_flag);
-- admin 角色授权
INSERT INTO sys_role_permission(id, role_id, permission_id, operate_date, operate_ip)
SELECT REPLACE(UUID(),'-',''), 'f6817f48af4fb3af11b9e8bf182f618b', p.id, NOW(), '127.0.0.1'
@@ -96,7 +115,8 @@ WHERE p.id IN (
'1860000000000000011','1860000000000000012','1860000000000000013','1860000000000000014','1860000000000000015','1860000000000000016','1860000000000000017',
'1860000000000000021','1860000000000000022','1860000000000000023','1860000000000000024','1860000000000000025','1860000000000000026','1860000000000000027',
'1860000000000000031','1860000000000000032','1860000000000000033','1860000000000000034','1860000000000000035','1860000000000000036','1860000000000000037',
'1860000000000000041','1860000000000000042','1860000000000000043','1860000000000000044','1860000000000000045','1860000000000000046','1860000000000000047'
'1860000000000000041','1860000000000000042','1860000000000000043','1860000000000000044','1860000000000000045','1860000000000000046','1860000000000000047',
'1860000000000000051','1860000000000000052','1860000000000000053','1860000000000000054','1860000000000000055','1860000000000000056','1860000000000000057'
) AND NOT EXISTS (
SELECT 1
FROM sys_role_permission rp
@@ -125,5 +145,6 @@ WHERE id IN (
'1860000000000000011',
'1860000000000000021',
'1860000000000000031',
'1860000000000000041'
'1860000000000000041',
'1860000000000000051'
);

View File

@@ -0,0 +1,30 @@
-- 密炼物料信息表菜单与权限已合并进 db/mes-material-menu.sql
SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS `mes_mixer_material` (
`id` varchar(32) NOT NULL COMMENT '主键',
`material_code` varchar(64) DEFAULT NULL COMMENT '物料编码',
`material_name` varchar(200) DEFAULT NULL COMMENT '物料名称',
`erp_code` varchar(64) DEFAULT NULL COMMENT 'ERP编号',
`major_category_id` varchar(32) DEFAULT NULL COMMENT '物料大类',
`minor_category_id` varchar(32) DEFAULT NULL COMMENT '物料小类',
`material_desc` varchar(500) DEFAULT NULL COMMENT '物料描述',
`alias_name` varchar(200) DEFAULT NULL COMMENT '物料别名',
`feed_manage_status` int DEFAULT NULL COMMENT '投管状态1在投管 0未投管',
`use_status` int DEFAULT NULL COMMENT '使用状态1使用中 0停用',
`specific_gravity` decimal(18,6) DEFAULT NULL COMMENT '比重',
`shelf_life_days` int DEFAULT NULL COMMENT '保质期()',
`min_bake_minutes` int DEFAULT NULL COMMENT '最短烘胶时间(分钟)',
`total_safety_stock_kg` decimal(18,4) DEFAULT NULL COMMENT '总安全库存KG',
`qualified_safety_stock_kg` decimal(18,4) DEFAULT NULL COMMENT '合格品安全库存KG',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`tenant_id` int DEFAULT NULL COMMENT '租户',
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门',
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
`del_flag` int DEFAULT '0' COMMENT '删除标记',
PRIMARY KEY (`id`),
KEY `idx_mixer_material_code` (`material_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES密炼物料信息';

View File

@@ -0,0 +1,93 @@
package org.jeecg.modules.mes.material.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.mes.material.entity.MesMixerMaterial;
import org.jeecg.modules.mes.material.service.IMesMixerMaterialService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
@Slf4j
@Tag(name = "MES-密炼物料信息")
@RestController
@RequestMapping("/mes/material/mixerMaterial")
public class MesMixerMaterialController extends JeecgController<MesMixerMaterial, IMesMixerMaterialService> {
@GetMapping("/list")
public Result<IPage<MesMixerMaterial>> queryPageList(
MesMixerMaterial model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesMixerMaterial> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
IPage<MesMixerMaterial> pageList = service.page(new Page<>(pageNo, pageSize), queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES-密炼物料信息-添加")
@Operation(summary = "MES-密炼物料信息-添加")
@RequiresPermissions("mes:mes_mixer_material:add")
@PostMapping("/add")
public Result<String> add(@RequestBody MesMixerMaterial model) {
service.save(model);
return Result.OK("添加成功!");
}
@AutoLog(value = "MES-密炼物料信息-编辑")
@Operation(summary = "MES-密炼物料信息-编辑")
@RequiresPermissions("mes:mes_mixer_material:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesMixerMaterial model) {
service.updateById(model);
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES-密炼物料信息-通过id删除")
@Operation(summary = "MES-密炼物料信息-通过id删除")
@RequiresPermissions("mes:mes_mixer_material:delete")
@DeleteMapping("/delete")
public Result<String> delete(@RequestParam(name = "id") String id) {
service.removeById(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES-密炼物料信息-批量删除")
@Operation(summary = "MES-密炼物料信息-批量删除")
@RequiresPermissions("mes:mes_mixer_material:deleteBatch")
@DeleteMapping("/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) {
List<String> idList = Arrays.asList(ids.split(","));
service.removeByIds(idList);
return Result.OK("批量删除成功!");
}
@GetMapping("/queryById")
public Result<MesMixerMaterial> queryById(@RequestParam(name = "id") String id) {
return Result.OK(service.getById(id));
}
@RequiresPermissions("mes:mes_mixer_material:exportXls")
@RequestMapping("/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesMixerMaterial model) {
return super.exportXls(request, model, MesMixerMaterial.class, "MES密炼物料信息");
}
@RequiresPermissions("mes:mes_mixer_material:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, MesMixerMaterial.class);
}
}

View File

@@ -0,0 +1,79 @@
package org.jeecg.modules.mes.material.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
@Data
@TableName("mes_mixer_material")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES密炼物料信息")
public class MesMixerMaterial implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Excel(name = "物料编码", width = 15)
private String materialCode;
@Excel(name = "物料名称", width = 20)
private String materialName;
@Excel(name = "ERP编号", width = 15)
private String erpCode;
@Excel(name = "物料大类", width = 15, dictTable = "mes_material_category", dicText = "category_name", dicCode = "id")
@Dict(dictTable = "mes_material_category", dicText = "category_name", dicCode = "id")
private String majorCategoryId;
@Excel(name = "物料小类", width = 15, dictTable = "mes_material_category", dicText = "category_name", dicCode = "id")
@Dict(dictTable = "mes_material_category", dicText = "category_name", dicCode = "id")
private String minorCategoryId;
@Excel(name = "物料描述", width = 25)
private String materialDesc;
@Excel(name = "物料别名", width = 15)
private String aliasName;
@Excel(name = "投管状态", width = 12, replace = {"在投管_1", "未投管_0"})
private Integer feedManageStatus;
@Excel(name = "使用状态", width = 12, replace = {"使用中_1", "停用_0"})
private Integer useStatus;
@Excel(name = "比重", width = 10)
private BigDecimal specificGravity;
@Excel(name = "保质期(天)", width = 12)
private Integer shelfLifeDays;
@Excel(name = "最短烘胶时间(分钟)", width = 18)
private Integer minBakeMinutes;
@Excel(name = "总安全库存KG", width = 14)
private BigDecimal totalSafetyStockKg;
@Excel(name = "合格品安全库存KG", width = 16)
private BigDecimal qualifiedSafetyStockKg;
@Excel(name = "备注", width = 20)
private String remark;
private Integer tenantId;
private String sysOrgCode;
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
private Integer delFlag;
}

View File

@@ -0,0 +1,6 @@
package org.jeecg.modules.mes.material.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.mes.material.entity.MesMixerMaterial;
public interface MesMixerMaterialMapper extends BaseMapper<MesMixerMaterial> {}

View File

@@ -0,0 +1,6 @@
package org.jeecg.modules.mes.material.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.mes.material.entity.MesMixerMaterial;
public interface IMesMixerMaterialService extends IService<MesMixerMaterial> {}

View File

@@ -0,0 +1,11 @@
package org.jeecg.modules.mes.material.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.mes.material.entity.MesMixerMaterial;
import org.jeecg.modules.mes.material.mapper.MesMixerMaterialMapper;
import org.jeecg.modules.mes.material.service.IMesMixerMaterialService;
import org.springframework.stereotype.Service;
@Service
public class MesMixerMaterialServiceImpl extends ServiceImpl<MesMixerMaterialMapper, MesMixerMaterial>
implements IMesMixerMaterialService {}

View File

@@ -0,0 +1,32 @@
import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';
enum Api {
list = '/mes/material/mixerMaterial/list',
save = '/mes/material/mixerMaterial/add',
edit = '/mes/material/mixerMaterial/edit',
deleteOne = '/mes/material/mixerMaterial/delete',
deleteBatch = '/mes/material/mixerMaterial/deleteBatch',
importExcel = '/mes/material/mixerMaterial/importExcel',
exportXls = '/mes/material/mixerMaterial/exportXls',
}
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const deleteOne = (params, handleSuccess) =>
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
export const batchDelete = (params, handleSuccess) => {
Modal.confirm({
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () =>
defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => handleSuccess()),
});
};
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });

View File

@@ -0,0 +1,117 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
function feedManageStatusText(v: unknown) {
if (v === 1) return '在投管';
if (v === 0) return '未投管';
return '-';
}
function useStatusText(v: unknown) {
if (v === 1) return '使用中';
if (v === 0) return '停用';
return '-';
}
export const columns: BasicColumn[] = [
{ title: '物料编码', align: 'center', width: 120, dataIndex: 'materialCode' },
{ title: '物料名称', align: 'center', width: 160, dataIndex: 'materialName' },
{ title: 'ERP编号', align: 'center', width: 120, dataIndex: 'erpCode' },
{ title: '物料大类', align: 'center', width: 120, dataIndex: 'majorCategoryId_dictText' },
{ title: '物料小类', align: 'center', width: 120, dataIndex: 'minorCategoryId_dictText' },
{ title: '物料描述', align: 'center', width: 180, ellipsis: true, dataIndex: 'materialDesc' },
{ title: '物料别名', align: 'center', width: 120, dataIndex: 'aliasName' },
{
title: '投管状态',
align: 'center',
width: 100,
dataIndex: 'feedManageStatus',
customRender: ({ text }) => feedManageStatusText(text),
},
{
title: '使用状态',
align: 'center',
width: 100,
dataIndex: 'useStatus',
customRender: ({ text }) => useStatusText(text),
},
{ title: '比重', align: 'center', width: 90, dataIndex: 'specificGravity' },
{ title: '保质期(天)', align: 'center', width: 100, dataIndex: 'shelfLifeDays' },
{ title: '最短烘胶(分)', align: 'center', width: 110, dataIndex: 'minBakeMinutes' },
{ title: '总安全库存KG', align: 'center', width: 120, dataIndex: 'totalSafetyStockKg' },
{ title: '合格品安全库存KG', align: 'center', width: 130, dataIndex: 'qualifiedSafetyStockKg' },
{ title: '创建时间', align: 'center', width: 160, dataIndex: 'createTime' },
];
export const searchFormSchema: FormSchema[] = [
{ label: '物料编码', field: 'materialCode', component: 'Input', colProps: { span: 6 } },
{ label: '物料名称', field: 'materialName', component: 'Input', colProps: { span: 6 } },
{ label: 'ERP编号', field: 'erpCode', component: 'Input', colProps: { span: 6 } },
{
label: '物料大类',
field: 'majorCategoryId',
component: 'JDictSelectTag',
componentProps: { dictCode: 'mes_material_category,category_name,id' },
colProps: { span: 6 },
},
];
const feedManageOptions = [
{ label: '在投管', value: 1 },
{ label: '未投管', value: 0 },
];
const useStatusOptions = [
{ label: '使用中', value: 1 },
{ label: '停用', value: 0 },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{ label: '物料编码', field: 'materialCode', component: 'Input', required: true },
{ label: '物料名称', field: 'materialName', component: 'Input', required: true },
{ label: 'ERP编号', field: 'erpCode', component: 'Input' },
{
label: '物料大类',
field: 'majorCategoryId',
component: 'JDictSelectTag',
componentProps: { dictCode: 'mes_material_category,category_name,id' },
},
{
label: '物料小类',
field: 'minorCategoryId',
component: 'JDictSelectTag',
componentProps: { dictCode: 'mes_material_category,category_name,id' },
},
{ label: '物料描述', field: 'materialDesc', component: 'InputTextArea' },
{ label: '物料别名', field: 'aliasName', component: 'Input' },
{
label: '投管状态',
field: 'feedManageStatus',
component: 'Select',
defaultValue: 1,
componentProps: { options: feedManageOptions },
},
{
label: '使用状态',
field: 'useStatus',
component: 'Select',
defaultValue: 1,
componentProps: { options: useStatusOptions },
},
{ label: '比重', field: 'specificGravity', component: 'InputNumber', componentProps: { min: 0, step: 0.001, precision: 6 } },
{ label: '保质期(天)', field: 'shelfLifeDays', component: 'InputNumber', componentProps: { min: 0, precision: 0 } },
{ label: '最短烘胶时间(分钟)', field: 'minBakeMinutes', component: 'InputNumber', componentProps: { min: 0, precision: 0 } },
{
label: '总安全库存KG',
field: 'totalSafetyStockKg',
component: 'InputNumber',
componentProps: { min: 0, step: 0.0001, precision: 4 },
},
{
label: '合格品安全库存KG',
field: 'qualifiedSafetyStockKg',
component: 'InputNumber',
componentProps: { min: 0, step: 0.0001, precision: 4 },
},
{ label: '备注', field: 'remark', component: 'InputTextArea' },
];

View File

@@ -0,0 +1,79 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_mixer_material:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
<a-button type="primary" v-auth="'mes:mes_mixer_material:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
<j-upload-button type="primary" v-auth="'mes:mes_mixer_material:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete"><Icon icon="ant-design:delete-outlined" />删除</a-menu-item>
</a-menu>
</template>
<a-button>批量操作<Icon icon="mdi:chevron-down" /></a-button>
</a-dropdown>
</template>
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template>
</BasicTable>
<MesMixerMaterialModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import MesMixerMaterialModal from './modules/MesMixerMaterialModal.vue';
import { columns, searchFormSchema } from './MesMixerMaterial.data';
import { batchDelete, deleteOne, getExportUrl, getImportUrl, list } from './MesMixerMaterial.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '密炼物料信息',
api: list,
columns,
canResize: true,
formConfig: { labelWidth: 120, schemas: searchFormSchema, autoSubmitOnEnter: true, showAdvancedButton: true },
actionColumn: { width: 120 },
},
exportConfig: { name: '密炼物料信息', url: getExportUrl },
importConfig: { url: getImportUrl, success: handleSuccess },
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
function handleAdd() {
openModal(true, { isUpdate: false, showFooter: true });
}
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: true });
}
function handleDetail(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: false });
}
async function handleDelete(record) {
await deleteOne({ id: record.id }, reload);
}
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, reload);
}
function handleSuccess() {
reload();
}
function getTableAction(record) {
return [{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_mixer_material:edit' }];
}
function getDropDownAction(record) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'mes:mes_mixer_material:delete',
},
];
}
</script>

View File

@@ -0,0 +1,46 @@
<template>
<BasicModal @register="registerModal" :title="title" width="720px" v-bind="$attrs" @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from '../MesMixerMaterial.data';
import { saveOrUpdate } from '../MesMixerMaterial.api';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
labelWidth: 140,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
await setFieldsValue({ ...data.record });
}
setProps({ disabled: !data?.showFooter });
});
const title = computed(() => (!unref(isUpdate) ? '新增密炼物料' : '编辑密炼物料'));
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,7 @@
<template>
<MesMixerMaterialList />
</template>
<script lang="ts" setup>
import MesMixerMaterialList from '../material/MesMixerMaterialList.vue';
</script>