Merge branch '生产及设备基础资料'
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslEquipmentLedger/list',
|
||||
checkEquipmentCode = '/xslmes/mesXslEquipmentLedger/checkEquipmentCode',
|
||||
checkEquipmentName = '/xslmes/mesXslEquipmentLedger/checkEquipmentName',
|
||||
save = '/xslmes/mesXslEquipmentLedger/add',
|
||||
edit = '/xslmes/mesXslEquipmentLedger/edit',
|
||||
deleteOne = '/xslmes/mesXslEquipmentLedger/delete',
|
||||
deleteBatch = '/xslmes/mesXslEquipmentLedger/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslEquipmentLedger/importExcel',
|
||||
exportXls = '/xslmes/mesXslEquipmentLedger/exportXls',
|
||||
queryById = '/xslmes/mesXslEquipmentLedger/queryById',
|
||||
}
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
export const checkEquipmentCode = (params: { equipmentCode: string; dataId?: string }) =>
|
||||
defHttp.get({ url: Api.checkEquipmentCode, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
|
||||
|
||||
export const checkEquipmentName = (params: { equipmentName: string; dataId?: string }) =>
|
||||
defHttp.get({ url: Api.checkEquipmentName, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
|
||||
export const deleteOne = (params, handleSuccess) => defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||
export const batchDelete = (params, handleSuccess) => defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
const url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url, params });
|
||||
};
|
||||
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
@@ -0,0 +1,199 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { checkEquipmentCode, checkEquipmentName } from './MesXslEquipmentLedger.api';
|
||||
|
||||
const colHalf = { span: 12 };
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '设备编号', align: 'center', dataIndex: 'equipmentCode', width: 130 },
|
||||
{ title: '设备名称', align: 'center', dataIndex: 'equipmentName', width: 160 },
|
||||
{ title: '工序', align: 'center', dataIndex: 'processOperationName', width: 120 },
|
||||
{ title: '设备类别', align: 'center', dataIndex: 'equipmentCategoryName', width: 110 },
|
||||
{ title: '设备类型', align: 'center', dataIndex: 'equipmentTypeName', width: 110 },
|
||||
{ title: '设备厂家', align: 'center', dataIndex: 'manufacturerName', width: 120 },
|
||||
{ title: '所属工厂', align: 'center', dataIndex: 'factoryName', width: 120 },
|
||||
{ title: '设备状态', align: 'center', dataIndex: 'equipmentStatus_dictText', width: 90 },
|
||||
{ title: '是否启用', align: 'center', dataIndex: 'enabledFlag_dictText', width: 90 },
|
||||
{ title: '设备型号', align: 'center', dataIndex: 'equipmentModel', width: 110, defaultHidden: true },
|
||||
{ title: '创建时间', align: 'center', dataIndex: 'createTime', width: 165, defaultHidden: true },
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '设备编号', field: 'equipmentCode', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '设备名称', field: 'equipmentName', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '工序名称', field: 'processOperationName', component: 'Input', colProps: { span: 6 } },
|
||||
{
|
||||
label: '设备状态',
|
||||
field: 'equipmentStatus',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_equipment_ledger_status' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '是否启用',
|
||||
field: 'enabledFlag',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'yn' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '', field: 'processOperationId', component: 'Input', show: false },
|
||||
{ label: '', field: 'manufacturerId', component: 'Input', show: false },
|
||||
{ label: '', field: 'equipmentCategoryId', component: 'Input', show: false },
|
||||
{ label: '', field: 'equipmentTypeId', component: 'Input', show: false },
|
||||
{ label: '', field: 'factoryId', component: 'Input', show: false },
|
||||
{
|
||||
label: '所属工序',
|
||||
field: 'processOperationName',
|
||||
component: 'Input',
|
||||
slot: 'processOperationPicker',
|
||||
colProps: colHalf,
|
||||
dynamicRules: () => [{ required: true, message: '请选择所属工序' }],
|
||||
},
|
||||
{
|
||||
label: '设备编号',
|
||||
field: 'equipmentCode',
|
||||
component: 'Input',
|
||||
colProps: colHalf,
|
||||
componentProps: { placeholder: '同租户内不可重复' },
|
||||
dynamicRules: ({ model }) => [
|
||||
{ required: true, message: '请输入设备编号' },
|
||||
{
|
||||
validator: async (_rule, value) => {
|
||||
const v = value == null ? '' : String(value).trim();
|
||||
if (!v) return Promise.resolve();
|
||||
try {
|
||||
await checkEquipmentCode({ equipmentCode: v, dataId: model?.id });
|
||||
return Promise.resolve();
|
||||
} catch (e: any) {
|
||||
return Promise.reject(e?.response?.data?.message || e?.message || '设备编号不能重复');
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '设备名称',
|
||||
field: 'equipmentName',
|
||||
component: 'Input',
|
||||
colProps: colHalf,
|
||||
componentProps: { placeholder: '同租户内不可重复' },
|
||||
dynamicRules: ({ model }) => [
|
||||
{ required: true, message: '请输入设备名称' },
|
||||
{
|
||||
validator: async (_rule, value) => {
|
||||
const v = value == null ? '' : String(value).trim();
|
||||
if (!v) return Promise.resolve();
|
||||
try {
|
||||
await checkEquipmentName({ equipmentName: v, dataId: model?.id });
|
||||
return Promise.resolve();
|
||||
} catch (e: any) {
|
||||
return Promise.reject(e?.response?.data?.message || e?.message || '设备名称不能重复');
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '所属设备厂家',
|
||||
field: 'manufacturerName',
|
||||
component: 'Input',
|
||||
slot: 'manufacturerPicker',
|
||||
colProps: colHalf,
|
||||
},
|
||||
{
|
||||
label: '设备类别',
|
||||
field: 'equipmentCategoryName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentCategoryPicker',
|
||||
colProps: colHalf,
|
||||
},
|
||||
{
|
||||
label: '设备类型',
|
||||
field: 'equipmentTypeName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentTypePicker',
|
||||
colProps: colHalf,
|
||||
},
|
||||
{
|
||||
label: '所属工厂',
|
||||
field: 'factoryName',
|
||||
component: 'Input',
|
||||
slot: 'factoryPicker',
|
||||
colProps: colHalf,
|
||||
},
|
||||
{ label: '设备型号', field: 'equipmentModel', component: 'Input', colProps: colHalf },
|
||||
{
|
||||
label: '设备状态',
|
||||
field: 'equipmentStatus',
|
||||
component: 'JDictSelectTag',
|
||||
defaultValue: '0',
|
||||
componentProps: { dictCode: 'xslmes_equipment_ledger_status' },
|
||||
colProps: colHalf,
|
||||
required: true,
|
||||
},
|
||||
{ label: '序列号', field: 'serialNo', component: 'Input', colProps: colHalf },
|
||||
{ label: '铭牌', field: 'nameplate', component: 'Input', colProps: colHalf },
|
||||
{
|
||||
label: '维修部门',
|
||||
field: 'maintainDeptId',
|
||||
component: 'JSelectDept',
|
||||
componentProps: { checkStrictly: true, multiple: false },
|
||||
colProps: colHalf,
|
||||
},
|
||||
{ label: '维修人员', field: 'maintainPerson', component: 'Input', colProps: colHalf },
|
||||
{
|
||||
label: '主管部门',
|
||||
field: 'manageDeptId',
|
||||
component: 'JSelectDept',
|
||||
componentProps: { checkStrictly: true, multiple: false },
|
||||
colProps: colHalf,
|
||||
},
|
||||
{ label: '资料文件编号', field: 'docFileNo', component: 'Input', colProps: colHalf },
|
||||
{
|
||||
label: '生产日期',
|
||||
field: 'productionDate',
|
||||
component: 'DatePicker',
|
||||
componentProps: { valueFormat: 'YYYY-MM-DD', style: { width: '100%' } },
|
||||
colProps: colHalf,
|
||||
},
|
||||
{
|
||||
label: '购买日期',
|
||||
field: 'purchaseDate',
|
||||
component: 'DatePicker',
|
||||
componentProps: { valueFormat: 'YYYY-MM-DD', style: { width: '100%' } },
|
||||
colProps: colHalf,
|
||||
},
|
||||
{
|
||||
label: '使用日期',
|
||||
field: 'useDate',
|
||||
component: 'DatePicker',
|
||||
componentProps: { valueFormat: 'YYYY-MM-DD', style: { width: '100%' } },
|
||||
colProps: colHalf,
|
||||
},
|
||||
{ label: '厂商联系人', field: 'vendorContact', component: 'Input', colProps: colHalf },
|
||||
{ label: '价值', field: 'assetValue', component: 'Input', colProps: colHalf },
|
||||
{ label: '受控PDA', field: 'controlledPda', component: 'Input', colProps: colHalf },
|
||||
{ label: '超产比率', field: 'overproductionRatio', component: 'Input', colProps: colHalf },
|
||||
{ label: '有效体积', field: 'effectiveVolume', component: 'Input', colProps: colHalf },
|
||||
{
|
||||
label: '是否启用',
|
||||
field: 'enabledFlag',
|
||||
component: 'JDictSelectTag',
|
||||
defaultValue: '1',
|
||||
componentProps: { dictCode: 'yn' },
|
||||
colProps: colHalf,
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: '设备描述',
|
||||
field: 'equipmentDesc',
|
||||
component: 'InputTextArea',
|
||||
componentProps: { rows: 3 },
|
||||
colProps: { span: 24 },
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'mes:mes_xsl_equipment_ledger:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equipment_ledger:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equipment_ledger: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 v-auth="'mes:mes_xsl_equipment_ledger:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_xsl_equipment_ledger:edit' },
|
||||
]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslEquipmentLedgerModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslEquipmentLedger" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslEquipmentLedgerModal from './components/MesXslEquipmentLedgerModal.vue';
|
||||
import { columns, searchFormSchema } from './MesXslEquipmentLedger.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslEquipmentLedger.api';
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '设备台账',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
labelWidth: 100,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
actionColumn: {
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
},
|
||||
},
|
||||
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 });
|
||||
}
|
||||
|
||||
function handleDelete(record: Recordable) {
|
||||
deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
function batchHandleDelete() {
|
||||
batchDelete({ ids: selectedRowKeys.value.join(',') }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
reload();
|
||||
selectedRowKeys.value = [];
|
||||
}
|
||||
|
||||
function getDropDownAction(record: Recordable) {
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'mes:mes_xsl_equipment_ledger:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,243 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
@register="registerModal"
|
||||
destroyOnClose
|
||||
:title="title"
|
||||
:width="MODAL_WIDTH"
|
||||
:maxHeight="modalContentMaxHeight"
|
||||
wrap-class-name="mes-xsl-equipment-ledger-modal"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<BasicForm @register="registerForm">
|
||||
<template #processOperationPicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择工序" style="flex: 1" />
|
||||
<a-button type="primary" :disabled="isDetail" @click="openProcessSelect">选择</a-button>
|
||||
<a-button v-if="model.processOperationId && !isDetail" @click="clearProcess(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #manufacturerPicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择设备厂家" style="flex: 1" />
|
||||
<a-button type="primary" :disabled="isDetail" @click="openManufacturerSelect('manufacturer')">选择</a-button>
|
||||
<a-button v-if="model.manufacturerId && !isDetail" @click="clearManufacturer(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #equipmentCategoryPicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择设备类别" style="flex: 1" />
|
||||
<a-button type="primary" :disabled="isDetail" @click="openCategorySelect">选择</a-button>
|
||||
<a-button v-if="model.equipmentCategoryId && !isDetail" @click="clearCategory(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #equipmentTypePicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择设备类型" style="flex: 1" />
|
||||
<a-button type="primary" :disabled="isDetail" @click="openTypeSelect">选择</a-button>
|
||||
<a-button v-if="model.equipmentTypeId && !isDetail" @click="clearType(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #factoryPicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input v-model:value="model[field]" read-only placeholder="请选择所属工厂" style="flex: 1" />
|
||||
<a-button type="primary" :disabled="isDetail" @click="openManufacturerSelect('factory')">选择</a-button>
|
||||
<a-button v-if="model.factoryId && !isDetail" @click="clearFactory(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
</BasicForm>
|
||||
<MesXslProcessOperationSelectModal @register="registerProcessModal" @select="onProcessSelect" />
|
||||
<MesXslManufacturerSelectModal
|
||||
@register="registerManufacturerModal"
|
||||
:modal-title="manufacturerModalTitle"
|
||||
@select="onManufacturerSelect"
|
||||
/>
|
||||
<MesXslEquipmentCategorySelectModal @register="registerCategoryModal" @select="onCategorySelect" />
|
||||
<MesXslEquipmentTypeSelectModal @register="registerTypeModal" @select="onTypeSelect" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref, onMounted } from 'vue';
|
||||
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { formSchema } from '../MesXslEquipmentLedger.data';
|
||||
import { saveOrUpdate } from '../MesXslEquipmentLedger.api';
|
||||
import MesXslProcessOperationSelectModal from '/@/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue';
|
||||
import MesXslManufacturerSelectModal from './MesXslManufacturerSelectModal.vue';
|
||||
import MesXslEquipmentCategorySelectModal from '/@/views/xslmes/mesXslEquipmentType/components/MesXslEquipmentCategorySelectModal.vue';
|
||||
import MesXslEquipmentTypeSelectModal from './MesXslEquipmentTypeSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
|
||||
/** 弹窗宽度;须配合 wrap-class-name 覆盖全局 .ant-modal{width:520px} */
|
||||
const MODAL_WIDTH = 1200;
|
||||
|
||||
/** 仅纵向滚动(像素高度,供 ModalWrapper 使用);在基准高度上缩短 20% */
|
||||
const MODAL_HEIGHT_SCALE = 0.8;
|
||||
const modalContentMaxHeight = ref(Math.round(600 * MODAL_HEIGHT_SCALE));
|
||||
|
||||
onMounted(() => {
|
||||
const base = Math.min(800, Math.max(480, window.innerHeight - 220));
|
||||
modalContentMaxHeight.value = Math.round(base * MODAL_HEIGHT_SCALE);
|
||||
});
|
||||
const manufacturerPickTarget = ref<'manufacturer' | 'factory'>('manufacturer');
|
||||
|
||||
const manufacturerModalTitle = computed(() =>
|
||||
manufacturerPickTarget.value === 'factory' ? '选择所属工厂' : '选择设备厂家',
|
||||
);
|
||||
|
||||
const [registerProcessModal, { openModal: openProcessModal }] = useModal();
|
||||
const [registerManufacturerModal, { openModal: openManufacturerModal }] = useModal();
|
||||
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
|
||||
const [registerTypeModal, { openModal: openTypeModal }] = useModal();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
|
||||
labelWidth: 110,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 12 },
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
setModalProps({
|
||||
width: MODAL_WIDTH,
|
||||
confirmLoading: false,
|
||||
showCancelBtn: data?.showFooter,
|
||||
showOkBtn: data?.showFooter,
|
||||
});
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !data?.showFooter;
|
||||
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
|
||||
else await setFieldsValue({ equipmentStatus: '0', enabledFlag: '1' });
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
});
|
||||
|
||||
const title = computed(() =>
|
||||
!unref(isUpdate) ? '新增设备台账' : unref(isDetail) ? '设备台账详情' : '编辑设备台账',
|
||||
);
|
||||
|
||||
function openProcessSelect() {
|
||||
const v = getFieldsValue();
|
||||
openProcessModal(true, { processOperationId: v?.processOperationId });
|
||||
}
|
||||
|
||||
function openManufacturerSelect(target: 'manufacturer' | 'factory') {
|
||||
manufacturerPickTarget.value = target;
|
||||
const v = getFieldsValue();
|
||||
openManufacturerModal(true, {
|
||||
manufacturerId: target === 'factory' ? v?.factoryId : v?.manufacturerId,
|
||||
});
|
||||
}
|
||||
|
||||
function openCategorySelect() {
|
||||
const v = getFieldsValue();
|
||||
openCategoryModal(true, { equipmentCategoryId: v?.equipmentCategoryId });
|
||||
}
|
||||
|
||||
function openTypeSelect() {
|
||||
const v = getFieldsValue();
|
||||
openTypeModal(true, { equipmentTypeId: v?.equipmentTypeId });
|
||||
}
|
||||
|
||||
function onProcessSelect(payload: Recordable) {
|
||||
setFieldsValue({
|
||||
processOperationId: payload.processOperationId,
|
||||
processOperationName: payload.processOperationName,
|
||||
});
|
||||
}
|
||||
|
||||
function onManufacturerSelect(payload: Recordable) {
|
||||
if (manufacturerPickTarget.value === 'factory') {
|
||||
setFieldsValue({
|
||||
factoryId: payload.manufacturerId,
|
||||
factoryName: payload.manufacturerName,
|
||||
});
|
||||
} else {
|
||||
setFieldsValue({
|
||||
manufacturerId: payload.manufacturerId,
|
||||
manufacturerName: payload.manufacturerName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function onCategorySelect(payload: Recordable) {
|
||||
setFieldsValue({
|
||||
equipmentCategoryId: payload.equipmentCategoryId,
|
||||
equipmentCategoryName: payload.equipmentCategoryName,
|
||||
});
|
||||
}
|
||||
|
||||
function onTypeSelect(payload: Recordable) {
|
||||
setFieldsValue({
|
||||
equipmentTypeId: payload.equipmentTypeId,
|
||||
equipmentTypeName: payload.equipmentTypeName,
|
||||
equipmentCategoryId: payload.equipmentCategoryId || getFieldsValue()?.equipmentCategoryId,
|
||||
equipmentCategoryName: payload.equipmentCategoryName || getFieldsValue()?.equipmentCategoryName,
|
||||
});
|
||||
}
|
||||
|
||||
function clearProcess(model: Recordable) {
|
||||
model.processOperationId = '';
|
||||
model.processOperationName = '';
|
||||
}
|
||||
|
||||
function clearManufacturer(model: Recordable) {
|
||||
model.manufacturerId = '';
|
||||
model.manufacturerName = '';
|
||||
}
|
||||
|
||||
function clearFactory(model: Recordable) {
|
||||
model.factoryId = '';
|
||||
model.factoryName = '';
|
||||
}
|
||||
|
||||
function clearCategory(model: Recordable) {
|
||||
model.equipmentCategoryId = '';
|
||||
model.equipmentCategoryName = '';
|
||||
}
|
||||
|
||||
function clearType(model: Recordable) {
|
||||
model.equipmentTypeId = '';
|
||||
model.equipmentTypeName = '';
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
if (!values.processOperationId) {
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate(values, isUpdate.value);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
/* 覆盖 jeecg components/Modal/src/index.less 中 .ant-modal { width: 520px } */
|
||||
.ant-modal-wrap.mes-xsl-equipment-ledger-modal > .ant-modal,
|
||||
.mes-xsl-equipment-ledger-modal .ant-modal {
|
||||
width: min(1200px, calc(100vw - 48px)) !important;
|
||||
max-width: min(1200px, calc(100vw - 48px)) !important;
|
||||
}
|
||||
|
||||
.mes-xsl-equipment-ledger-modal {
|
||||
|
||||
.scroll-container .scrollbar__wrap {
|
||||
overflow-x: hidden !important;
|
||||
overflow-y: auto !important;
|
||||
}
|
||||
|
||||
.scrollbar__view > div {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择设备类型" :width="960" @register="registerModal" @ok="handleOk">
|
||||
<BasicTable @register="registerTable" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable } from '/@/components/Table';
|
||||
import { list, queryById } from '/@/views/xslmes/mesXslEquipmentType/MesXslEquipmentType.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: list,
|
||||
columns: [
|
||||
{ title: '类型名称', dataIndex: 'typeName', width: 160 },
|
||||
{ title: '工序名称', dataIndex: 'processOperationName', width: 160 },
|
||||
{ title: '设备类别', dataIndex: 'equipmentCategoryName', width: 160 },
|
||||
],
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{ label: '类型名称', field: 'typeName', component: 'Input', colProps: { span: 8 } },
|
||||
{ label: '类别名称', field: 'equipmentCategoryName', component: 'Input', colProps: { span: 8 } },
|
||||
],
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: (_keys, rows) => {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
},
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const tid = data?.equipmentTypeId as string | undefined;
|
||||
if (tid) {
|
||||
setSelectedRowKeys?.([tid]);
|
||||
try {
|
||||
const raw = await queryById({ id: tid });
|
||||
const row = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
if (row) selectedRow.value = row;
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
}
|
||||
reload();
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
const keys = (getSelectRowKeys?.() || []) as string[];
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row && keys.length) {
|
||||
try {
|
||||
const raw = await queryById({ id: keys[0] });
|
||||
row = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
emit('select', {
|
||||
equipmentTypeId: '',
|
||||
equipmentTypeName: '',
|
||||
equipmentCategoryId: '',
|
||||
equipmentCategoryName: '',
|
||||
});
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
equipmentTypeId: row.id,
|
||||
equipmentTypeName: row.typeName || '',
|
||||
equipmentCategoryId: row.equipmentCategoryId || '',
|
||||
equipmentCategoryName: row.equipmentCategoryName || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,95 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" :title="title" :width="900" @register="registerModal" @ok="handleOk">
|
||||
<BasicTable @register="registerTable" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable } from '/@/components/Table';
|
||||
import { list, queryById } from '/@/views/xslmes/mesXslManufacturer/MesXslManufacturer.api';
|
||||
|
||||
const props = defineProps<{ modalTitle?: string }>();
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const title = computed(() => props.modalTitle || '选择厂家信息');
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: list,
|
||||
columns: [
|
||||
{ title: '厂家类别', dataIndex: 'manufacturerCategory_dictText', width: 120 },
|
||||
{ title: '厂家名称', dataIndex: 'manufacturerName', width: 200 },
|
||||
{ title: '是否有效', dataIndex: 'validStatus_dictText', width: 90 },
|
||||
],
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{
|
||||
label: '厂家类别',
|
||||
field: 'manufacturerCategory',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_manufacturer_category' },
|
||||
colProps: { span: 8 },
|
||||
},
|
||||
{ label: '厂家名称', field: 'manufacturerName', component: 'Input', colProps: { span: 8 } },
|
||||
],
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: (_keys, rows) => {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
},
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const mid = data?.manufacturerId as string | undefined;
|
||||
if (mid) {
|
||||
setSelectedRowKeys?.([mid]);
|
||||
try {
|
||||
const raw = await queryById({ id: mid });
|
||||
const row = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
if (row) selectedRow.value = row;
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
}
|
||||
reload();
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
const keys = (getSelectRowKeys?.() || []) as string[];
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row && keys.length) {
|
||||
try {
|
||||
const raw = await queryById({ id: keys[0] });
|
||||
row = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
emit('select', { manufacturerId: '', manufacturerName: '' });
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
manufacturerId: row.id,
|
||||
manufacturerName: row.manufacturerName || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user