停机记录新增,设备管理查询条件完善
This commit is contained in:
@@ -20,7 +20,14 @@ export const columns: BasicColumn[] = [
|
||||
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: 'processOperationId', component: 'Input', show: false },
|
||||
{
|
||||
label: '所属工序',
|
||||
field: 'processOperationName',
|
||||
component: 'Input',
|
||||
slot: 'processOperationPicker',
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '设备状态',
|
||||
field: 'equipmentStatus',
|
||||
@@ -35,6 +42,38 @@ export const searchFormSchema: FormSchema[] = [
|
||||
componentProps: { dictCode: 'yn' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{ label: '', field: 'manufacturerId', component: 'Input', show: false },
|
||||
{
|
||||
label: '设备厂家',
|
||||
field: 'manufacturerName',
|
||||
component: 'Input',
|
||||
slot: 'manufacturerPicker',
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{ label: '', field: 'equipmentCategoryId', component: 'Input', show: false },
|
||||
{
|
||||
label: '设备类别',
|
||||
field: 'equipmentCategoryName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentCategoryPicker',
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{ label: '', field: 'equipmentTypeId', component: 'Input', show: false },
|
||||
{
|
||||
label: '设备类型',
|
||||
field: 'equipmentTypeName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentTypePicker',
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{ label: '', field: 'factoryId', component: 'Input', show: false },
|
||||
{
|
||||
label: '所属工厂',
|
||||
field: 'factoryName',
|
||||
component: 'Input',
|
||||
slot: 'factoryPicker',
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
|
||||
@@ -1,189 +1,331 @@
|
||||
<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_equip_inspect_record:add'"
|
||||
:disabled="selectedRowKeys.length === 0"
|
||||
preIcon="ant-design:audit-outlined"
|
||||
@click="handleBatchCreateRecord('inspect')"
|
||||
>
|
||||
点检
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equip_inspect_record:add'"
|
||||
:disabled="selectedRowKeys.length === 0"
|
||||
preIcon="ant-design:tool-outlined"
|
||||
@click="handleBatchCreateRecord('maintain')"
|
||||
>
|
||||
保养
|
||||
</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 { useMessage } from '/@/hooks/web/useMessage';
|
||||
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';
|
||||
import { batchCreateFromEquipment } from '../mesXslEquipInspectRecord/MesXslEquipInspectRecord.api';
|
||||
|
||||
const { createMessage, createConfirm } = useMessage();
|
||||
|
||||
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, getSelectRows }, { 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 handleBatchCreateRecord(recordType: 'inspect' | 'maintain') {
|
||||
const rows = (getSelectRows?.() || []) as Recordable[];
|
||||
if (!rows.length) {
|
||||
createMessage.warning('请先勾选设备');
|
||||
return;
|
||||
}
|
||||
const ids = rows.map((r) => r.id).filter(Boolean);
|
||||
const typeLabel = recordType === 'inspect' ? '点检' : '保养';
|
||||
createConfirm({
|
||||
iconType: 'info',
|
||||
title: `生成${typeLabel}记录`,
|
||||
content: `确定为选中的 ${ids.length} 台设备各生成一条${typeLabel}记录?`,
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
try {
|
||||
const res = await batchCreateFromEquipment({ equipmentLedgerIds: ids, recordType });
|
||||
const data = (res as any)?.result ?? res;
|
||||
const failList: string[] = data?.failMessages || [];
|
||||
const successCount = data?.successCount ?? 0;
|
||||
if (successCount > 0 && !failList.length) {
|
||||
createMessage.success(`成功生成 ${successCount} 条${typeLabel}记录`);
|
||||
handleSuccess();
|
||||
} else if (successCount > 0 && failList.length) {
|
||||
createMessage.warning(`成功生成 ${successCount} 条;未生成:${failList.join(';')}`);
|
||||
handleSuccess();
|
||||
} else if (failList.length) {
|
||||
createMessage.warning(failList.join(';'));
|
||||
} else {
|
||||
createMessage.warning((res as any)?.message || `未生成任何${typeLabel}记录`);
|
||||
}
|
||||
} catch (e: any) {
|
||||
const errMsg =
|
||||
e?.response?.data?.message || e?.message || `生成${typeLabel}记录失败`;
|
||||
createMessage.warning(errMsg);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
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>
|
||||
<template>
|
||||
|
||||
<div>
|
||||
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
|
||||
<template #form-processOperationPicker="{ model, field }">
|
||||
|
||||
<MesSearchPickerInput
|
||||
|
||||
:model="model"
|
||||
|
||||
:field="field"
|
||||
|
||||
placeholder="请选择工序"
|
||||
|
||||
:show-clear="!!model.processOperationId"
|
||||
|
||||
@open="openProcessSelect"
|
||||
|
||||
@clear="clearModelFields(model, ['processOperationId', 'processOperationName'])"
|
||||
|
||||
/>
|
||||
|
||||
</template>
|
||||
|
||||
<template #form-manufacturerPicker="{ model, field }">
|
||||
|
||||
<MesSearchPickerInput
|
||||
|
||||
:model="model"
|
||||
|
||||
:field="field"
|
||||
|
||||
placeholder="请选择设备厂家"
|
||||
|
||||
:show-clear="!!model.manufacturerId"
|
||||
|
||||
@open="openManufacturerSelect('manufacturer')"
|
||||
|
||||
@clear="clearModelFields(model, ['manufacturerId', 'manufacturerName'])"
|
||||
|
||||
/>
|
||||
|
||||
</template>
|
||||
|
||||
<template #form-equipmentCategoryPicker="{ model, field }">
|
||||
|
||||
<MesSearchPickerInput
|
||||
|
||||
:model="model"
|
||||
|
||||
:field="field"
|
||||
|
||||
placeholder="请选择设备类别"
|
||||
|
||||
:show-clear="!!model.equipmentCategoryId"
|
||||
|
||||
@open="openCategorySelect"
|
||||
|
||||
@clear="clearModelFields(model, ['equipmentCategoryId', 'equipmentCategoryName'])"
|
||||
|
||||
/>
|
||||
|
||||
</template>
|
||||
|
||||
<template #form-equipmentTypePicker="{ model, field }">
|
||||
|
||||
<MesSearchPickerInput
|
||||
|
||||
:model="model"
|
||||
|
||||
:field="field"
|
||||
|
||||
placeholder="请选择设备类型"
|
||||
|
||||
:show-clear="!!model.equipmentTypeId"
|
||||
|
||||
@open="openTypeSelect"
|
||||
|
||||
@clear="clearModelFields(model, ['equipmentTypeId', 'equipmentTypeName'])"
|
||||
|
||||
/>
|
||||
|
||||
</template>
|
||||
|
||||
<template #form-factoryPicker="{ model, field }">
|
||||
|
||||
<MesSearchPickerInput
|
||||
|
||||
:model="model"
|
||||
|
||||
:field="field"
|
||||
|
||||
placeholder="请选择所属工厂"
|
||||
|
||||
:show-clear="!!model.factoryId"
|
||||
|
||||
@open="openManufacturerSelect('factory')"
|
||||
|
||||
@clear="clearModelFields(model, ['factoryId', 'factoryName'])"
|
||||
|
||||
/>
|
||||
|
||||
</template>
|
||||
|
||||
<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_equip_inspect_record:add'"
|
||||
|
||||
:disabled="selectedRowKeys.length === 0"
|
||||
|
||||
preIcon="ant-design:audit-outlined"
|
||||
|
||||
@click="handleBatchCreateRecord('inspect')"
|
||||
|
||||
>
|
||||
|
||||
点检
|
||||
|
||||
</a-button>
|
||||
|
||||
<a-button
|
||||
|
||||
type="primary"
|
||||
|
||||
v-auth="'mes:mes_xsl_equip_inspect_record:add'"
|
||||
|
||||
:disabled="selectedRowKeys.length === 0"
|
||||
|
||||
preIcon="ant-design:tool-outlined"
|
||||
|
||||
@click="handleBatchCreateRecord('maintain')"
|
||||
|
||||
>
|
||||
|
||||
保养
|
||||
|
||||
</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" />
|
||||
|
||||
<MesXslProcessOperationSelectModal @register="registerProcessModal" @select="onProcessSearchSelect" />
|
||||
|
||||
<MesXslManufacturerSelectModal
|
||||
|
||||
@register="registerManufacturerModal"
|
||||
|
||||
:modal-title="manufacturerModalTitle"
|
||||
|
||||
@select="onManufacturerSearchSelect"
|
||||
|
||||
/>
|
||||
|
||||
<MesXslEquipmentCategorySelectModal @register="registerCategoryModal" @select="onCategorySearchSelect" />
|
||||
|
||||
<MesXslEquipmentTypeSelectModal @register="registerTypeModal" @select="onTypeSearchSelect" />
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslEquipmentLedger" setup>
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
|
||||
import { useModal } from '/@/components/Modal';
|
||||
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
import Icon from '/@/components/Icon';
|
||||
|
||||
import MesSearchPickerInput from '../components/MesSearchPickerInput.vue';
|
||||
|
||||
import MesXslEquipmentLedgerModal from './components/MesXslEquipmentLedgerModal.vue';
|
||||
|
||||
import MesXslProcessOperationSelectModal from '/@/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue';
|
||||
|
||||
import MesXslManufacturerSelectModal from './components/MesXslManufacturerSelectModal.vue';
|
||||
|
||||
import MesXslEquipmentCategorySelectModal from '/@/views/xslmes/mesXslEquipmentType/components/MesXslEquipmentCategorySelectModal.vue';
|
||||
|
||||
import MesXslEquipmentTypeSelectModal from './components/MesXslEquipmentTypeSelectModal.vue';
|
||||
|
||||
import { clearModelFields, createStripIdNameBeforeFetch } from '../utils/mesSearchPickerUtil';
|
||||
|
||||
import { columns, searchFormSchema } from './MesXslEquipmentLedger.data';
|
||||
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslEquipmentLedger.api';
|
||||
|
||||
import { batchCreateFromEquipment } from '../mesXslEquipInspectRecord/MesXslEquipInspectRecord.api';
|
||||
|
||||
|
||||
|
||||
const { createMessage, createConfirm } = useMessage();
|
||||
|
||||
|
||||
|
||||
const SEARCH_ID_NAME_PAIRS = [
|
||||
|
||||
{ idField: 'processOperationId', nameField: 'processOperationName' },
|
||||
|
||||
{ idField: 'manufacturerId', nameField: 'manufacturerName' },
|
||||
|
||||
{ idField: 'equipmentCategoryId', nameField: 'equipmentCategoryName' },
|
||||
|
||||
{ idField: 'equipmentTypeId', nameField: 'equipmentTypeName' },
|
||||
|
||||
{ idField: 'factoryId', nameField: 'factoryName' },
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
const manufacturerPickTarget = ref<'manufacturer' | 'factory'>('manufacturer');
|
||||
|
||||
|
||||
|
||||
const manufacturerModalTitle = computed(() =>
|
||||
|
||||
manufacturerPickTarget.value === 'factory' ? '选择所属工厂' : '选择设备厂家',
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
const [registerProcessModal, { openModal: openProcessModal }] = useModal();
|
||||
|
||||
const [registerManufacturerModal, { openModal: openManufacturerModal }] = useModal();
|
||||
|
||||
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
|
||||
|
||||
const [registerTypeModal, { openModal: openTypeModal }] = useModal();
|
||||
|
||||
Reference in New Issue
Block a user