Commit 2686386c by 史雅文

工序管理新增产品弹窗

parents adb7a340 761d12ce
import { MesEquipmentFileInfoPageModel, MesEquipmentFileInfoPageParams, MesEquipmentFileInfoPageResult } from './model/SbglModel';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/#/axios';
enum Api {
Page = '/jcsj/sbgl/page',
List = '/jcsj/sbgl/list',
Info = '/jcsj/sbgl/info',
MesEquipmentFileInfo = '/jcsj/sbgl',
}
/**
* @description: 查询MesEquipmentFileInfo分页列表
*/
export async function getMesEquipmentFileInfoPage(params: MesEquipmentFileInfoPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesEquipmentFileInfoPageResult>(
{
url: Api.Page,
params,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 获取MesEquipmentFileInfo信息
*/
export async function getMesEquipmentFileInfo(id: String, mode: ErrorMessageMode = 'modal') {
return defHttp.get<MesEquipmentFileInfoPageModel>(
{
url: Api.Info,
params: { id },
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 新增MesEquipmentFileInfo
*/
export async function addMesEquipmentFileInfo(mesEquipmentFileInfo: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.post<boolean>(
{
url: Api.MesEquipmentFileInfo,
params: mesEquipmentFileInfo,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 更新MesEquipmentFileInfo
*/
export async function updateMesEquipmentFileInfo(mesEquipmentFileInfo: Recordable, mode: ErrorMessageMode = 'modal') {
return defHttp.put<boolean>(
{
url: Api.MesEquipmentFileInfo,
params: mesEquipmentFileInfo,
},
{
errorMessageMode: mode,
},
);
}
/**
* @description: 删除MesEquipmentFileInfo(批量删除)
*/
export async function deleteMesEquipmentFileInfo(ids: string[], mode: ErrorMessageMode = 'modal') {
return defHttp.delete<boolean>(
{
url: Api.MesEquipmentFileInfo,
data: ids,
},
{
errorMessageMode: mode,
},
);
}
import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
/**
* @description: MesEquipmentFileInfo分页参数 模型
*/
export interface MesEquipmentFileInfoPageParams extends BasicPageParams {
sbmc: string;
sbbm: string;
sblx: string;
sbzt: string;
fzr: string;
gs: string;
ggxh: string;
zjbm: string;
cj: string;
ccbh: string;
zcdm: string;
syz: string;
bxqrq: string;
bcjyrq: string;
xcjyrq: string;
bz: string;
}
/**
* @description: MesEquipmentFileInfo分页返回值模型
*/
export interface MesEquipmentFileInfoPageModel {
id: string;
sbmc: string;
sbbm: string;
sblx: string;
sbzt: string;
ggxh: string;
zjbm: string;
cj: string;
fzr: string;
gs: string;
ccbh: string;
zcdm: string;
syz: string;
bxqrq: string;
bcjyrq: string;
xcjyrq: string;
bz: string;
}
/**
* @description: MesEquipmentFileInfo表类型
*/
export interface MesEquipmentFileInfoModel {
id: string;
sbbm: string;
sbmc: string;
lxid: string;
deleteMark: string;
sblx: string;
sbzt: string;
fzr: string;
gs: string;
ggxh: string;
zjbm: string;
cj: string;
ccbh: string;
zcdm: string;
bxqrq: string;
syz: string;
bcjyrq: string;
xcjyrq: string;
bz: string;
p1: string;
p2: string;
p3: string;
p4: string;
p5: string;
p6: string;
p7: string;
p8: string;
p9: string;
p10: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
mesEquipmentFileInfoItemList?: MesEquipmentFileInfoItemModel;
}
/**
* @description: MesEquipmentFileInfoItem表类型
*/
export interface MesEquipmentFileInfoItemModel {
id: string;
sbid: string;
sbbm: string;
sbmc: string;
lxid: string;
deleteMark: string;
sblx: string;
sbzt: string;
fzr: string;
gs: string;
ggxh: string;
zjbm: string;
cj: string;
ccbh: string;
zcdm: string;
bxqrq: string;
syz: string;
bcjyrq: string;
xcjyrq: string;
bz: string;
p1: string;
p2: string;
p3: string;
p4: string;
p5: string;
p6: string;
p7: string;
p8: string;
p9: string;
p10: string;
createDate: string;
createUserId: string;
modifyDate: string;
modifyUserId: string;
}
/**
* @description: MesEquipmentFileInfo分页返回值结构
*/
export type MesEquipmentFileInfoPageResult = BasicFetchResult<MesEquipmentFileInfoPageModel>;
<template>
<div class="pt-4">
<SimpleForm
ref="systemFormRef"
:formProps="data.formDataProps"
:formModel="state.formModel"
:isWorkFlow="props.fromPage!=FromPageType.MENU"
:isCamelCase="true"
@model-change="handleChange"
/>
</div>
</template>
<script lang="ts" setup>
import { reactive, ref, onMounted, nextTick, watch } from 'vue';
import { formProps, formEventConfigs } from './config';
import SimpleForm from '/@/components/SimpleForm/src/SimpleForm.vue';
import { addMesEquipmentFileInfo, getMesEquipmentFileInfo, updateMesEquipmentFileInfo } from '/@/api/jcsj/sbgl';
import { cloneDeep, isString } from 'lodash-es';
import { FormDataProps } from '/@/components/Designer/src/types';
import { usePermission } from '/@/hooks/web/usePermission';
import CustomButtonModal from '/@/components/Form/src/components/CustomButtonModal.vue';
import { FromPageType } from '/@/enums/workflowEnum';
import { createFormEvent, getFormDataEvent, loadFormEvent, submitFormEvent,} from '/@/hooks/web/useFormEvent';
import { changeWorkFlowForm, changeSchemaDisabled } from '/@/hooks/web/useWorkFlowForm';
import { WorkFlowFormParams } from '/@/model/workflow/bpmnConfig';
import { useRouter } from 'vue-router';
const { filterFormSchemaAuth } = usePermission();
const RowKey = 'id';
const emits = defineEmits(['changeUploadComponentIds','loadingCompleted', 'update:value']);
const props = defineProps({
fromPage: {
type: Number,
default: FromPageType.MENU,
},
});
const systemFormRef = ref();
const data: { formDataProps: FormDataProps } = reactive({
formDataProps: cloneDeep(formProps),
});
const state = reactive({
formModel: {},
formInfo:{formId:'',formName:''}
});
const { currentRoute } = useRouter();
watch(
() => state.formModel,
(val) => {
emits('update:value', val);
},
{
deep: true,
},
);
onMounted(async () => {
try {
if (props.fromPage == FromPageType.MENU) {
setMenuPermission();
if(currentRoute.value.meta){
state.formInfo.formName = currentRoute.value.meta.title&&isString(currentRoute.value.meta.title)?currentRoute.value.meta.title:'';
state.formInfo.formId = currentRoute.value.meta.formId&&isString(currentRoute.value.meta.formId)?currentRoute.value.meta.formId:'';
}
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await nextTick();
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
} else if (props.fromPage == FromPageType.FLOW) {
emits('loadingCompleted'); //告诉系统表单已经加载完毕
// loadingCompleted后 工作流页面直接利用Ref调用setWorkFlowForm方法
} else if (props.fromPage == FromPageType.PREVIEW) {
// 预览 无需权限,表单事件也无需执行
} else if (props.fromPage == FromPageType.DESKTOP) {
// 桌面设计 表单事件需要执行
emits('loadingCompleted'); //告诉系统表单已经加载完毕
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
}
} catch (error) {}
});
// 根据菜单页面权限,设置表单属性(必填,禁用,显示)
function setMenuPermission() {
data.formDataProps.schemas = filterFormSchemaAuth(data.formDataProps.schemas!);
}
// 校验form 通过返回表单数据
async function validate() {
let values = [];
try {
values = await systemFormRef.value?.validate();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
}
return values;
}
// 根据行唯一ID查询行数据,并设置表单数据 【编辑】
async function setFormDataFromId(rowId) {
try {
const record = await getMesEquipmentFileInfo(rowId);
setFieldsValue(record);
state.formModel = record;
await getFormDataEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:获取表单数据
} catch (error) {
}
}
// 辅助返回表单数据
async function getFieldsValue() {
let values = [];
try {
values = await systemFormRef.value?.getFieldsValue();
//添加隐藏组件
if (data.formDataProps.hiddenComponent?.length) {
data.formDataProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
} finally {
}
return values;
}
// 辅助设置表单数据
function setFieldsValue(record) {
systemFormRef.value.setFieldsValue(record);
}
// 重置表单数据
async function resetFields() {
await systemFormRef.value.resetFields();
}
// 设置表单数据全部为Disabled 【查看】
async function setDisabledForm( ) {
data.formDataProps.schemas = changeSchemaDisabled(cloneDeep(data.formDataProps.schemas));
}
// 获取行键值
function getRowKey() {
return RowKey;
}
// 更新api表单数据
async function update({ values, rowId }) {
try {
values[RowKey] = rowId;
state.formModel = values;
let saveVal = await updateMesEquipmentFileInfo(values);
await submitFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 新增api表单数据
async function add(values) {
try {
state.formModel = values;
let saveVal = await addMesEquipmentFileInfo(values);
await submitFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:提交表单
return saveVal;
} catch (error) {}
}
// 根据工作流页面权限,设置表单属性(必填,禁用,显示)
async function setWorkFlowForm(obj: WorkFlowFormParams) {
try {
if (obj.formId) state.formInfo.formId = obj.formId;
if (obj.formName) state.formInfo.formName = obj.formName;
let flowData = await changeWorkFlowForm(cloneDeep(formProps), obj);
let { buildOptionJson, uploadComponentIds, formModels, isViewProcess } = flowData;
data.formDataProps = buildOptionJson;
emits('changeUploadComponentIds', uploadComponentIds); //工作流中必须保存上传组件id【附件汇总需要】
if (isViewProcess) {
setDisabledForm(); //查看
}
state.formModel = formModels;
setFieldsValue(formModels);
} catch (error) {}
await createFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:初始化表单
await loadFormEvent(formEventConfigs, state.formModel,
systemFormRef.value,
formProps.schemas, true, state.formInfo.formName,state.formInfo.formId); //表单事件:加载表单
}
function handleChange(val) {
emits('update:value', val);
}
async function sendMessageForAllIframe() {
try {
if (systemFormRef.value && systemFormRef.value.sendMessageForAllIframe) {
systemFormRef.value.sendMessageForAllIframe();
}
} catch (error) {}
}
defineExpose({
setFieldsValue,
resetFields,
validate,
add,
update,
setFormDataFromId,
setDisabledForm,
setMenuPermission,
setWorkFlowForm,
getRowKey,
getFieldsValue,
sendMessageForAllIframe
});
</script>
\ No newline at end of file
<template>
<BasicModal
:height="1080"
v-bind="$attrs" @register="registerModal" :title="getTitle"
@ok="handleSubmit" @cancel="handleClose" >
<ModalForm ref="formRef" v-model:value="state.formModel" :fromPage="FromPageType.MENU" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, reactive, provide, Ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { formProps } from './config';
import ModalForm from './Form.vue';
import { FromPageType } from '/@/enums/workflowEnum';
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const formRef = ref();
const isCopy = ref<boolean>(false)
const state = reactive({
formModel: {},
isUpdate: true,
isView: false,
rowId: '',
});
provide<Ref<boolean>>('isCopy', isCopy);
const { t } = useI18n();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await handleInner(data);
});
const getTitle = computed(() => (state.isView ? '查看' : state.isUpdate ? '编辑' : isCopy.value ? '复制数据' : '新增'));
async function handleInner(data){
state.isUpdate = !!data?.isUpdate;
state.isView = !!data?.isView;
isCopy.value = !!data?.isCopy;
setModalProps({
destroyOnClose: true,
maskClosable: false,
showCancelBtn: !state.isView,
showOkBtn: !state.isView,
canFullscreen: true,
width: 1920,
footer: state.isView ? null : undefined,defaultFullscreen:true,
});
if (state.isUpdate || state.isView || isCopy.value) {
state.rowId = data.id;
if (state.isView) {
await formRef.value.setDisabledForm();
}
await formRef.value.setFormDataFromId(state.rowId);
} else {
formRef.value.resetFields();
}
}
async function saveModal() {
let saveSuccess = false;
try {
const values = await formRef.value?.validate();
//添加隐藏组件
if (formProps.hiddenComponent?.length) {
formProps.hiddenComponent.forEach((component) => {
values[component.bindField] = component.value;
});
}
if (values !== false) {
try {
if (!state.isUpdate || isCopy.value) {
saveSuccess = await formRef.value.add(values);
} else {
saveSuccess = await formRef.value.update({ values, rowId: state.rowId });
}
return saveSuccess;
} catch (error) {}
}
} catch (error) {
return saveSuccess;
}
}
async function handleSubmit() {
try {
const saveSuccess = await saveModal();
setModalProps({ confirmLoading: true });
if (saveSuccess) {
if (!state.isUpdate || isCopy.value) {
//false 新增
notification.success({
message: 'Tip',
description: isCopy.value ? '复制成功' : t('新增成功!'),
}); //提示消息
} else {
notification.success({
message: 'Tip',
description: t('修改成功!'),
}); //提示消息
}
closeModal();
formRef.value.resetFields();
emit('success');
}
} finally {
setModalProps({ confirmLoading: false });
}
}
function handleClose() {
formRef.value.resetFields();
}
</script>
\ No newline at end of file
export const permissionList = [
{
required: true,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '设备名称',
fieldId: 'sbmc',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'b20b170860d448e0b05118d3d8f2f73d',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '设备编码',
fieldId: 'sbbm',
isSubTable: false,
showChildren: true,
type: 'input',
key: '993427fdfa9e430483ea088ce9735472',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '设备类型',
fieldId: 'sblx',
isSubTable: false,
showChildren: true,
type: 'select',
key: 'e9da0ec0de7b40cc87a8d2e317b11f76',
children: [],
options: {},
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '设备状态',
fieldId: 'sbzt',
isSubTable: false,
showChildren: true,
type: 'select',
key: '9ea9a3717ee842c5a1f465f95d2aa716',
children: [],
options: {},
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '负责人',
fieldId: 'fzr',
isSubTable: false,
showChildren: true,
type: 'select',
key: '6ac08c6440ea4504931aa787b30854a7',
children: [],
options: {},
defaultValue: '2',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '公司',
fieldId: 'gs',
isSubTable: false,
showChildren: true,
type: 'select',
key: '66d22eb52be845319c4a039e4b79d3dd',
children: [],
options: {},
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '规格型号',
fieldId: 'ggxh',
isSubTable: false,
showChildren: true,
type: 'input',
key: '321a925f0949407c852d233d37dbe182',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '整机编码',
fieldId: 'zjbm',
isSubTable: false,
showChildren: true,
type: 'input',
key: '48ea92df4cd3461bb50657809b97f57c',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '厂家',
fieldId: 'cj',
isSubTable: false,
showChildren: true,
type: 'input',
key: '4ca3e508868349638680ac36da7cd203',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '出厂编号',
fieldId: 'ccbh',
isSubTable: false,
showChildren: true,
type: 'input',
key: 'a43345e2552142cc90212c82711fe638',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '注册代码',
fieldId: 'zcdm',
isSubTable: false,
showChildren: true,
type: 'input',
key: '7635c9dadf1a4dfa8e842199e1ba8718',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '使用证编号',
fieldId: 'syz',
isSubTable: false,
showChildren: true,
type: 'input',
key: '9262f92514f54819867bab30f11b2f1d',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '保修期日期',
fieldId: 'bxqrq',
isSubTable: false,
showChildren: true,
type: 'date',
key: '9e5d3c135660400fbc200f82ace8b11b',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '本次检验日期',
fieldId: 'bcjyrq',
isSubTable: false,
showChildren: true,
type: 'date',
key: '6a8e757af4904dd0893520dbc4d01ac1',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '下次检验日期',
fieldId: 'xcjyrq',
isSubTable: false,
showChildren: true,
type: 'date',
key: '9065fd2f539e4db69719607a01ff162b',
children: [],
options: {},
defaultValue: '',
},
{
required: false,
view: true,
edit: true,
disabled: false,
isSaveTable: false,
tableName: '',
fieldName: '备注',
fieldId: 'bz',
isSubTable: false,
showChildren: true,
type: 'textarea',
key: 'af6639b5cdee4960aea69ab38a68f285',
children: [],
options: {},
defaultValue: '',
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: true,
showChildren: false,
tableName: 'mesEquipmentFileInfoItemList',
fieldName: '',
fieldId: 'mesEquipmentFileInfoItemList',
type: 'form',
key: '8594e1ce231a4ca4867cdd37805f7ace',
children: [
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesEquipmentFileInfoItemList',
fieldName: '选择设备',
fieldId: 'sbmc',
type: 'MultiplePopup',
key: '59bb5c96f9e443d4b684f3be1a428256',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesEquipmentFileInfoItemList',
fieldName: '设备编码',
fieldId: 'sbbm',
type: 'Input',
key: '485d23d40fdd4686b3305787d1938c17',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesEquipmentFileInfoItemList',
fieldName: '设备类型',
fieldId: 'sblx',
type: 'XjrSelect',
key: '9637a074c0714669b9ed548f9b3c56b7',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesEquipmentFileInfoItemList',
fieldName: '设备状态',
fieldId: 'sbzt',
type: 'XjrSelect',
key: '661a0cf626084e3bac8e7f04f9350050',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesEquipmentFileInfoItemList',
fieldName: '规格型号',
fieldId: 'ggxh',
type: 'Input',
key: '8eab0f870d2f44a3a4b96d9e3a48813b',
children: [],
},
{
required: true,
view: true,
edit: true,
disabled: false,
isSubTable: false,
isSaveTable: false,
showChildren: false,
tableName: 'mesEquipmentFileInfoItemList',
fieldName: '厂家',
fieldId: 'cj',
type: 'Input',
key: '40d7c05f9998488084e250d6d274f6f0',
children: [],
},
],
},
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment