停机记录新增,设备管理查询条件完善
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslDowntimeRecord/list',
|
||||
save = '/xslmes/mesXslDowntimeRecord/add',
|
||||
edit = '/xslmes/mesXslDowntimeRecord/edit',
|
||||
deleteOne = '/xslmes/mesXslDowntimeRecord/delete',
|
||||
deleteBatch = '/xslmes/mesXslDowntimeRecord/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslDowntimeRecord/importExcel',
|
||||
exportXls = '/xslmes/mesXslDowntimeRecord/exportXls',
|
||||
queryById = '/xslmes/mesXslDowntimeRecord/queryById',
|
||||
saveMaintenanceResult = '/xslmes/mesXslDowntimeRecord/saveMaintenanceResult',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params });
|
||||
|
||||
export const saveMaintenanceResult = (params) => defHttp.post({ url: Api.saveMaintenanceResult, params });
|
||||
|
||||
export const deleteOne = (params, handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
};
|
||||
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
const url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url, params });
|
||||
};
|
||||
@@ -0,0 +1,177 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
|
||||
/** 弹窗内日期时间选择:下拉挂到 body,避免被 Modal 滚动区裁剪 */
|
||||
const dateTimePickerProps = {
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
style: { width: '100%' },
|
||||
getPopupContainer: () => document.body,
|
||||
};
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '机台', align: 'center', dataIndex: 'equipmentName', width: 150 },
|
||||
{ title: '设备编号', align: 'center', dataIndex: 'equipmentCode', width: 130 },
|
||||
{ title: '停机原因', align: 'center', dataIndex: 'downtimeTypeName', width: 150 },
|
||||
{
|
||||
title: '开始时间',
|
||||
align: 'center',
|
||||
dataIndex: 'startTime',
|
||||
width: 165,
|
||||
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
|
||||
},
|
||||
{
|
||||
title: '结束时间',
|
||||
align: 'center',
|
||||
dataIndex: 'endTime',
|
||||
width: 165,
|
||||
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
|
||||
},
|
||||
{ title: '设备部位', align: 'center', dataIndex: 'equipmentPartName', width: 120 },
|
||||
{ title: '维修项目', align: 'center', dataIndex: 'inspectMaintainItemName', width: 140 },
|
||||
{ title: '维修结果', align: 'center', dataIndex: 'maintenanceResult', width: 160, ellipsis: true },
|
||||
{ title: '维修人', align: 'center', dataIndex: 'maintainerRealname', width: 100 },
|
||||
{ title: '是否已录入维修', align: 'center', dataIndex: 'maintenanceFilledFlag_dictText', width: 120 },
|
||||
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
|
||||
{
|
||||
title: '创建时间',
|
||||
align: 'center',
|
||||
dataIndex: 'createTime',
|
||||
width: 165,
|
||||
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
|
||||
},
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '', field: 'equipmentLedgerId', component: 'Input', show: false },
|
||||
{
|
||||
label: '机台',
|
||||
field: 'equipmentName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentPicker',
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{ label: '设备编号', field: 'equipmentCode', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '', field: 'downtimeTypeId', component: 'Input', show: false },
|
||||
{
|
||||
label: '停机原因',
|
||||
field: 'downtimeTypeName',
|
||||
component: 'Input',
|
||||
slot: 'downtimeTypePicker',
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '是否已录入维修',
|
||||
field: 'maintenanceFilledFlag',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'yn' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{
|
||||
label: '',
|
||||
field: 'equipmentLedgerId',
|
||||
component: 'Input',
|
||||
show: false,
|
||||
dynamicRules: () => [{ required: true, message: '请选择机台' }],
|
||||
},
|
||||
{
|
||||
label: '机台',
|
||||
field: 'equipmentName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentPicker',
|
||||
},
|
||||
{
|
||||
label: '',
|
||||
field: 'downtimeTypeId',
|
||||
component: 'Input',
|
||||
show: false,
|
||||
dynamicRules: () => [{ required: true, message: '请选择停机原因' }],
|
||||
},
|
||||
{
|
||||
label: '停机原因',
|
||||
field: 'downtimeTypeName',
|
||||
component: 'Input',
|
||||
slot: 'downtimeTypePicker',
|
||||
},
|
||||
{
|
||||
label: '开始时间',
|
||||
field: 'startTime',
|
||||
component: 'DatePicker',
|
||||
required: true,
|
||||
componentProps: { ...dateTimePickerProps, placeholder: '请选择开始时间' },
|
||||
},
|
||||
{
|
||||
label: '结束时间',
|
||||
field: 'endTime',
|
||||
component: 'DatePicker',
|
||||
componentProps: { ...dateTimePickerProps, placeholder: '请选择结束时间' },
|
||||
},
|
||||
];
|
||||
|
||||
/** 录入维修结果弹窗 */
|
||||
export const maintenanceFormSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '', field: 'equipmentLedgerId', component: 'Input', show: false },
|
||||
{ label: '', field: 'equipmentCategoryId', component: 'Input', show: false },
|
||||
{ label: '', field: 'equipmentTypeId', component: 'Input', show: false },
|
||||
{ label: '', field: 'maintainerUsername', component: 'Input', show: false },
|
||||
{ label: '', field: 'maintainerRealname', component: 'Input', show: false },
|
||||
{
|
||||
label: '',
|
||||
field: 'equipmentPartId',
|
||||
component: 'Input',
|
||||
show: false,
|
||||
dynamicRules: () => [{ required: true, message: '请选择设备部位' }],
|
||||
},
|
||||
{
|
||||
label: '设备部位',
|
||||
field: 'equipmentPartName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentPartPicker',
|
||||
},
|
||||
{
|
||||
label: '',
|
||||
field: 'inspectMaintainItemId',
|
||||
component: 'Input',
|
||||
show: false,
|
||||
dynamicRules: () => [{ required: true, message: '请选择维修项目' }],
|
||||
},
|
||||
{
|
||||
label: '维修项目',
|
||||
field: 'inspectMaintainItemName',
|
||||
component: 'Input',
|
||||
slot: 'inspectItemPicker',
|
||||
},
|
||||
{
|
||||
label: '维修结果',
|
||||
field: 'maintenanceResult',
|
||||
component: 'InputTextArea',
|
||||
required: true,
|
||||
componentProps: { rows: 3, placeholder: '手输维修结果' },
|
||||
},
|
||||
{
|
||||
label: '维修人',
|
||||
field: 'maintainerUserId',
|
||||
component: 'JSelectUser',
|
||||
required: true,
|
||||
componentProps: ({ formActionType }) => ({
|
||||
rowKey: 'id',
|
||||
labelKey: 'realname',
|
||||
isRadioSelection: true,
|
||||
maxSelectCount: 1,
|
||||
onOptionsChange: (options) => {
|
||||
const row = options?.[0];
|
||||
if (row && formActionType) {
|
||||
formActionType.setFieldsValue({
|
||||
maintainerUsername: row.username,
|
||||
maintainerRealname: row.realname,
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #form-equipmentPicker="{ model, field }">
|
||||
<MesSearchPickerInput
|
||||
:model="model"
|
||||
:field="field"
|
||||
placeholder="请选择设备"
|
||||
:show-clear="!!model.equipmentLedgerId"
|
||||
@open="openEquipmentSelect"
|
||||
@clear="clearModelFields(model, ['equipmentLedgerId', 'equipmentName'])"
|
||||
/>
|
||||
</template>
|
||||
<template #form-downtimeTypePicker="{ model, field }">
|
||||
<MesSearchPickerInput
|
||||
:model="model"
|
||||
:field="field"
|
||||
placeholder="请选择停机类型"
|
||||
:show-clear="!!model.downtimeTypeId"
|
||||
@open="openDowntimeTypeSelect"
|
||||
@clear="clearModelFields(model, ['downtimeTypeId', 'downtimeTypeName'])"
|
||||
/>
|
||||
</template>
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'mes:mes_xsl_downtime_record:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_downtime_record:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_downtime_record: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_downtime_record:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableActions(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslDowntimeRecordModal @register="registerModal" @success="handleSuccess" />
|
||||
<MesXslDowntimeRecordMaintenanceModal @register="registerMaintenanceModal" @success="handleSuccess" />
|
||||
<MesXslEquipmentLedgerSelectModal @register="registerEquipmentModal" @select="onEquipmentSelect" />
|
||||
<MesXslDowntimeTypeSelectModal @register="registerDowntimeTypeModal" @select="onDowntimeTypeSelect" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslDowntimeRecord" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesSearchPickerInput from '../components/MesSearchPickerInput.vue';
|
||||
import MesXslDowntimeRecordModal from './components/MesXslDowntimeRecordModal.vue';
|
||||
import MesXslDowntimeRecordMaintenanceModal from './components/MesXslDowntimeRecordMaintenanceModal.vue';
|
||||
import MesXslEquipmentLedgerSelectModal from '/@/views/xslmes/mesXslEquipInspectConfig/components/MesXslEquipmentLedgerSelectModal.vue';
|
||||
import MesXslDowntimeTypeSelectModal from './components/MesXslDowntimeTypeSelectModal.vue';
|
||||
import { clearModelFields, createStripIdNameBeforeFetch } from '../utils/mesSearchPickerUtil';
|
||||
import { columns, searchFormSchema } from './MesXslDowntimeRecord.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslDowntimeRecord.api';
|
||||
|
||||
const SEARCH_ID_NAME_PAIRS = [
|
||||
{ idField: 'equipmentLedgerId', nameField: 'equipmentName' },
|
||||
{ idField: 'downtimeTypeId', nameField: 'downtimeTypeName' },
|
||||
];
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
const [registerMaintenanceModal, { openModal: openMaintenanceModal }] = useModal();
|
||||
const [registerEquipmentModal, { openModal: openEquipmentModal }] = useModal();
|
||||
const [registerDowntimeTypeModal, { openModal: openDowntimeTypeModal }] = useModal();
|
||||
|
||||
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '停机记录',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
beforeFetch: createStripIdNameBeforeFetch(SEARCH_ID_NAME_PAIRS),
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
labelWidth: 100,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
actionColumn: {
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: '停机记录',
|
||||
url: getExportUrl,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload, getForm }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
|
||||
function openEquipmentSelect() {
|
||||
const v = getForm()?.getFieldsValue?.() || {};
|
||||
openEquipmentModal(true, { equipmentLedgerId: v.equipmentLedgerId });
|
||||
}
|
||||
|
||||
function onEquipmentSelect(payload: Recordable) {
|
||||
getForm()?.setFieldsValue?.({
|
||||
equipmentLedgerId: payload.equipmentLedgerId || '',
|
||||
equipmentName: payload.equipmentName || '',
|
||||
});
|
||||
}
|
||||
|
||||
function openDowntimeTypeSelect() {
|
||||
const v = getForm()?.getFieldsValue?.() || {};
|
||||
openDowntimeTypeModal(true, { downtimeTypeId: v.downtimeTypeId });
|
||||
}
|
||||
|
||||
function onDowntimeTypeSelect(payload: Recordable) {
|
||||
getForm()?.setFieldsValue?.({
|
||||
downtimeTypeId: payload.downtimeTypeId || '',
|
||||
downtimeTypeName: payload.downtimeTypeName || '',
|
||||
});
|
||||
}
|
||||
|
||||
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 handleEnterMaintenance(record: Recordable) {
|
||||
openMaintenanceModal(true, { record });
|
||||
}
|
||||
|
||||
function getTableActions(record: Recordable) {
|
||||
return [
|
||||
{
|
||||
label: '录入维修结果',
|
||||
onClick: handleEnterMaintenance.bind(null, record),
|
||||
auth: 'mes:mes_xsl_downtime_record:edit',
|
||||
},
|
||||
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_xsl_downtime_record:edit' },
|
||||
];
|
||||
}
|
||||
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
selectedRowKeys.value = [];
|
||||
reload();
|
||||
}
|
||||
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'mes:mes_xsl_downtime_record:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" destroyOnClose title="录入维修结果" width="640px" @register="registerModal" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm">
|
||||
<template #equipmentPartPicker="{ 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" @click="openPartSelect">选择部位</a-button>
|
||||
<a-button v-if="model.equipmentPartId" @click="clearPart">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #inspectItemPicker="{ 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="!model.equipmentPartId" @click="openItemSelect">选择项目</a-button>
|
||||
<a-button v-if="model.inspectMaintainItemId" @click="clearItem">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
</BasicForm>
|
||||
<MesXslEquipmentPartSelectModal @register="registerPartModal" @select="onPartSelect" />
|
||||
<MesXslInspectMaintainItemSelectModal @register="registerItemModal" @select="onItemSelect" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { maintenanceFormSchema } from '../MesXslDowntimeRecord.data';
|
||||
import { saveMaintenanceResult } from '../MesXslDowntimeRecord.api';
|
||||
import { queryById as queryEquipmentById } from '/@/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api';
|
||||
import MesXslEquipmentPartSelectModal from '/@/views/xslmes/mesXslEquipmentSubPart/components/MesXslEquipmentPartSelectModal.vue';
|
||||
import MesXslInspectMaintainItemSelectModal from './MesXslInspectMaintainItemSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const [registerPartModal, { openModal: openPartModal }] = useModal();
|
||||
const [registerItemModal, { openModal: openItemModal }] = useModal();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, getFieldsValue }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: maintenanceFormSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 },
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const record = data?.record;
|
||||
if (!record?.id) {
|
||||
return;
|
||||
}
|
||||
let equipmentCategoryId = '';
|
||||
let equipmentTypeId = '';
|
||||
if (record.equipmentLedgerId) {
|
||||
try {
|
||||
const raw = await queryEquipmentById({ id: record.equipmentLedgerId });
|
||||
const ledger = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
equipmentCategoryId = ledger?.equipmentCategoryId || '';
|
||||
equipmentTypeId = ledger?.equipmentTypeId || '';
|
||||
} catch {
|
||||
// 忽略
|
||||
}
|
||||
}
|
||||
await setFieldsValue({
|
||||
id: record.id,
|
||||
equipmentLedgerId: record.equipmentLedgerId,
|
||||
equipmentCategoryId,
|
||||
equipmentTypeId,
|
||||
equipmentPartId: record.equipmentPartId,
|
||||
equipmentPartName: record.equipmentPartName,
|
||||
inspectMaintainItemId: record.inspectMaintainItemId,
|
||||
inspectMaintainItemName: record.inspectMaintainItemName,
|
||||
maintenanceResult: record.maintenanceResult,
|
||||
maintainerUserId: record.maintainerUserId,
|
||||
maintainerUsername: record.maintainerUsername,
|
||||
maintainerRealname: record.maintainerRealname,
|
||||
});
|
||||
});
|
||||
|
||||
function openPartSelect() {
|
||||
const vals = getFieldsValue();
|
||||
if (!vals.equipmentCategoryId) {
|
||||
createMessage.warning('无法获取设备类别,请确认停机记录已关联有效设备');
|
||||
return;
|
||||
}
|
||||
openPartModal(true, {
|
||||
equipmentCategoryId: vals.equipmentCategoryId,
|
||||
equipmentPartId: vals.equipmentPartId,
|
||||
});
|
||||
}
|
||||
|
||||
function clearPart() {
|
||||
setFieldsValue({
|
||||
equipmentPartId: '',
|
||||
equipmentPartName: '',
|
||||
inspectMaintainItemId: '',
|
||||
inspectMaintainItemName: '',
|
||||
});
|
||||
}
|
||||
|
||||
function onPartSelect(payload: { equipmentPartId?: string; equipmentPartName?: string }) {
|
||||
const vals = getFieldsValue();
|
||||
const pid = payload.equipmentPartId || '';
|
||||
if (vals.inspectMaintainItemId && vals.equipmentPartId && vals.equipmentPartId !== pid) {
|
||||
setFieldsValue({
|
||||
equipmentPartId: pid,
|
||||
equipmentPartName: payload.equipmentPartName || '',
|
||||
inspectMaintainItemId: '',
|
||||
inspectMaintainItemName: '',
|
||||
});
|
||||
} else {
|
||||
setFieldsValue({
|
||||
equipmentPartId: pid,
|
||||
equipmentPartName: payload.equipmentPartName || '',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function openItemSelect() {
|
||||
const vals = getFieldsValue();
|
||||
if (!vals.equipmentPartId) {
|
||||
createMessage.warning('请先选择设备部位');
|
||||
return;
|
||||
}
|
||||
openItemModal(true, {
|
||||
equipmentPartId: vals.equipmentPartId,
|
||||
equipmentTypeId: vals.equipmentTypeId,
|
||||
inspectMaintainItemId: vals.inspectMaintainItemId,
|
||||
});
|
||||
}
|
||||
|
||||
function clearItem() {
|
||||
setFieldsValue({ inspectMaintainItemId: '', inspectMaintainItemName: '' });
|
||||
}
|
||||
|
||||
function onItemSelect(payload: { inspectMaintainItemId?: string; inspectMaintainItemName?: string }) {
|
||||
setFieldsValue({
|
||||
inspectMaintainItemId: payload.inspectMaintainItemId || '',
|
||||
inspectMaintainItemName: payload.inspectMaintainItemName || '',
|
||||
});
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
if (!values.maintainerUserId) {
|
||||
createMessage.warning('请选择维修人');
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveMaintenanceResult(values);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<BasicModal @register="registerModal" :title="title" width="720" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm">
|
||||
<template #equipmentPicker="{ 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="openEquipmentSelect">选择设备</a-button>
|
||||
<a-button v-if="model.equipmentLedgerId && !isDetail" @click="clearEquipment">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #downtimeTypePicker="{ 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="openDowntimeTypeSelect">选择停机类型</a-button>
|
||||
<a-button v-if="model.downtimeTypeId && !isDetail" @click="clearDowntimeType">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
</BasicForm>
|
||||
<MesXslEquipmentLedgerSelectModal @register="registerEquipmentModal" @select="onEquipmentSelect" />
|
||||
<MesXslDowntimeTypeSelectModal @register="registerDowntimeTypeModal" @select="onDowntimeTypeSelect" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { formSchema } from '../MesXslDowntimeRecord.data';
|
||||
import { saveOrUpdate } from '../MesXslDowntimeRecord.api';
|
||||
import MesXslEquipmentLedgerSelectModal from '/@/views/xslmes/mesXslEquipInspectConfig/components/MesXslEquipmentLedgerSelectModal.vue';
|
||||
import MesXslDowntimeTypeSelectModal from './MesXslDowntimeTypeSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
|
||||
const [registerEquipmentModal, { openModal: openEquipmentModal }] = useModal();
|
||||
const [registerDowntimeTypeModal, { openModal: openDowntimeTypeModal }] = useModal();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
|
||||
labelWidth: 110,
|
||||
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;
|
||||
isDetail.value = !data?.showFooter;
|
||||
if (unref(isUpdate)) {
|
||||
await setFieldsValue({ ...data.record });
|
||||
} else {
|
||||
await setFieldsValue({ startTime: dayjs().format('YYYY-MM-DD HH:mm:ss') });
|
||||
}
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
});
|
||||
|
||||
const title = computed(() =>
|
||||
!unref(isUpdate) ? '新增停机记录' : unref(isDetail) ? '停机记录详情' : '编辑停机记录',
|
||||
);
|
||||
|
||||
function openEquipmentSelect() {
|
||||
const vals = getFieldsValue();
|
||||
openEquipmentModal(true, { equipmentLedgerId: vals.equipmentLedgerId });
|
||||
}
|
||||
|
||||
function clearEquipment() {
|
||||
setFieldsValue({ equipmentLedgerId: '', equipmentName: '', equipmentCode: '' });
|
||||
}
|
||||
|
||||
function onEquipmentSelect(payload: { equipmentLedgerId?: string; equipmentName?: string; equipmentCode?: string }) {
|
||||
setFieldsValue({
|
||||
equipmentLedgerId: payload.equipmentLedgerId || '',
|
||||
equipmentName: payload.equipmentName || '',
|
||||
equipmentCode: payload.equipmentCode || '',
|
||||
});
|
||||
}
|
||||
|
||||
function openDowntimeTypeSelect() {
|
||||
const vals = getFieldsValue();
|
||||
openDowntimeTypeModal(true, { downtimeTypeId: vals.downtimeTypeId });
|
||||
}
|
||||
|
||||
function clearDowntimeType() {
|
||||
setFieldsValue({ downtimeTypeId: '', downtimeTypeName: '' });
|
||||
}
|
||||
|
||||
function onDowntimeTypeSelect(payload: { downtimeTypeId?: string; downtimeTypeName?: string }) {
|
||||
setFieldsValue({
|
||||
downtimeTypeId: payload.downtimeTypeId || '',
|
||||
downtimeTypeName: payload.downtimeTypeName || '',
|
||||
});
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate(values, isUpdate.value);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择停机类型" :width="1000" @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/mesXslDowntimeType/MesXslDowntimeType.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
}
|
||||
|
||||
function fetchTypePage(params: Recordable) {
|
||||
return list({ ...params, status: '0' });
|
||||
}
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: fetchTypePage,
|
||||
columns: [
|
||||
{ title: '工序名称', dataIndex: 'processOperationName', width: 140 },
|
||||
{ title: '所属主类型', dataIndex: 'downtimeMainTypeName', width: 140 },
|
||||
{ title: '停机类型', dataIndex: 'downtimeType', width: 160 },
|
||||
{ title: '故障等级', dataIndex: 'faultLevel', width: 100 },
|
||||
],
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{ label: '停机类型', field: 'downtimeType', component: 'Input', colProps: { span: 8 } },
|
||||
{ label: '工序名称', field: 'processOperationName', component: 'Input', colProps: { span: 8 } },
|
||||
],
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: handleSelectionChange,
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const tid = data?.downtimeTypeId 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', { downtimeTypeId: '', downtimeTypeName: '' });
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
downtimeTypeId: row.id,
|
||||
downtimeTypeName: row.downtimeType || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,117 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择维修项目" :width="1000" @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/mesXslInspectMaintainItem/MesXslInspectMaintainItem.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
const filterEquipmentPartId = ref('');
|
||||
const filterEquipmentTypeId = ref('');
|
||||
|
||||
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
}
|
||||
|
||||
function fetchItemPage(params: Recordable) {
|
||||
const p: Recordable = { ...params };
|
||||
if (filterEquipmentPartId.value) {
|
||||
p.equipmentPartId = filterEquipmentPartId.value;
|
||||
}
|
||||
if (filterEquipmentTypeId.value) {
|
||||
p.equipmentTypeId = filterEquipmentTypeId.value;
|
||||
}
|
||||
return list(p);
|
||||
}
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: fetchItemPage,
|
||||
columns: [
|
||||
{ title: '项目编号', dataIndex: 'itemCode', width: 120 },
|
||||
{ title: '项目名称', dataIndex: 'itemName', width: 140 },
|
||||
{ title: '项目类别', dataIndex: 'itemCategory_dictText', width: 90 },
|
||||
{ title: '设备部位', dataIndex: 'equipmentPartName', width: 120 },
|
||||
{ title: '设备小部位', dataIndex: 'equipmentSubPartName', width: 120 },
|
||||
{ title: '点检方式', dataIndex: 'inspectMethod_dictText', width: 90 },
|
||||
{ title: '判断基准', dataIndex: 'judgmentCriteria', width: 160, ellipsis: true },
|
||||
],
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{ label: '项目编号', field: 'itemCode', component: 'Input', colProps: { span: 8 } },
|
||||
{ label: '项目名称', field: 'itemName', component: 'Input', colProps: { span: 8 } },
|
||||
{
|
||||
label: '项目类别',
|
||||
field: 'itemCategory',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_im_item_category', placeholder: '点检/保养' },
|
||||
colProps: { span: 8 },
|
||||
},
|
||||
],
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: handleSelectionChange,
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
filterEquipmentPartId.value = data?.equipmentPartId ? String(data.equipmentPartId) : '';
|
||||
filterEquipmentTypeId.value = data?.equipmentTypeId ? String(data.equipmentTypeId) : '';
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const iid = data?.inspectMaintainItemId as string | undefined;
|
||||
if (iid) {
|
||||
setSelectedRowKeys?.([iid]);
|
||||
try {
|
||||
const raw = await queryById({ id: iid });
|
||||
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', { inspectMaintainItemId: '', inspectMaintainItemName: '' });
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
inspectMaintainItemId: row.id,
|
||||
inspectMaintainItemName: row.itemName || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user