Merge branch 'main' of http://27.223.88.102:33000/chenx/qhmes
This commit is contained in:
@@ -9,11 +9,13 @@ enum Api {
|
||||
deleteBatch = '/mes/material/material/deleteBatch',
|
||||
importExcel = '/mes/material/material/importExcel',
|
||||
exportXls = '/mes/material/material/exportXls',
|
||||
queryById = '/mes/material/material/queryById',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
export const queryById = (params) => defHttp.get({ url: Api.queryById, params }, { successMessageMode: 'none' });
|
||||
|
||||
export const deleteOne = (params, handleSuccess) =>
|
||||
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<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 as materialList, queryById as queryMaterialById } from '../MesMaterial.api';
|
||||
import { columns as materialColumns, searchFormSchema as materialSearch } from '../MesMaterial.data';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: materialList,
|
||||
columns: materialColumns.slice(0, 6),
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: materialSearch,
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
beforeFetch: (params) => ({
|
||||
...params,
|
||||
enableFlag: params.enableFlag ?? 1,
|
||||
}),
|
||||
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 materialId = data?.materialId as string | undefined;
|
||||
if (materialId) {
|
||||
setSelectedRowKeys?.([materialId]);
|
||||
try {
|
||||
const raw = await queryMaterialById({ id: materialId });
|
||||
const row = (raw as Recordable)?.materialName != null ? raw : (raw as Recordable)?.result;
|
||||
if (row) {
|
||||
selectedRow.value = row;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
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 queryMaterialById({ id: keys[0] });
|
||||
row = (raw as Recordable)?.materialName != null ? raw : (raw as Recordable)?.result;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条胶料信息');
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
materialId: row.id,
|
||||
materialName: row.materialName || '',
|
||||
aliasName: row.aliasName || '',
|
||||
materialCode: row.materialCode || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -85,8 +85,12 @@
|
||||
emit('select', {
|
||||
mixerMaterialId: row.id,
|
||||
materialName: row.materialName || '',
|
||||
materialCode: row.materialCode || '',
|
||||
materialDesc: row.materialDesc || '',
|
||||
materialKind: buildKind(row),
|
||||
minorCategoryId: row.minorCategoryId || '',
|
||||
majorCategoryText: row.majorCategoryId_dictText || '',
|
||||
minorCategoryText: row.minorCategoryId_dictText || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslEquipInspectConfig/list',
|
||||
save = '/xslmes/mesXslEquipInspectConfig/add',
|
||||
edit = '/xslmes/mesXslEquipInspectConfig/edit',
|
||||
deleteOne = '/xslmes/mesXslEquipInspectConfig/delete',
|
||||
deleteBatch = '/xslmes/mesXslEquipInspectConfig/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslEquipInspectConfig/importExcel',
|
||||
exportXls = '/xslmes/mesXslEquipInspectConfig/exportXls',
|
||||
queryById = '/xslmes/mesXslEquipInspectConfig/queryById',
|
||||
queryLineList = '/xslmes/mesXslEquipInspectConfig/queryLineListByConfigId',
|
||||
}
|
||||
|
||||
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 queryLineListByConfigId = (params: { id: string }) => defHttp.get({ url: Api.queryLineList, 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,86 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '设备名称', align: 'center', dataIndex: 'equipmentName', width: 160 },
|
||||
{ title: '设备编号', align: 'center', dataIndex: 'equipmentCode', width: 140 },
|
||||
{ title: '类型', align: 'center', dataIndex: 'configType_dictText', width: 90 },
|
||||
{ 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: 'equipmentName', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '设备编号', field: 'equipmentCode', component: 'Input', colProps: { span: 6 } },
|
||||
{
|
||||
label: '类型',
|
||||
field: 'configType',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_im_item_category' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '', field: 'equipmentLedgerId', component: 'Input', show: false },
|
||||
{
|
||||
label: '设备名称',
|
||||
field: 'equipmentName',
|
||||
component: 'Input',
|
||||
slot: 'equipmentLedgerPicker',
|
||||
dynamicRules: () => [{ required: true, message: '请选择设备台账' }],
|
||||
},
|
||||
{
|
||||
label: '设备编号',
|
||||
field: 'equipmentCode',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true, placeholder: '选择设备后自动带出' },
|
||||
},
|
||||
{
|
||||
label: '类型',
|
||||
field: 'configType',
|
||||
component: 'JDictSelectTag',
|
||||
required: true,
|
||||
componentProps: { dictCode: 'xslmes_im_item_category', placeholder: '点检/保养' },
|
||||
},
|
||||
];
|
||||
|
||||
export const lineJVxeColumns: JVxeColumn[] = [
|
||||
{ title: '', key: 'inspectMaintainItemId', type: JVxeTypes.hidden },
|
||||
{ title: '点检项目编号', key: 'itemCode', type: JVxeTypes.normal, width: 130, disabled: true },
|
||||
{ title: '项目名称', key: 'itemName', type: JVxeTypes.normal, width: 140, disabled: true },
|
||||
{
|
||||
title: '项目类别',
|
||||
key: 'itemCategory',
|
||||
type: JVxeTypes.select,
|
||||
width: 100,
|
||||
disabled: true,
|
||||
dictCode: 'xslmes_im_item_category',
|
||||
},
|
||||
{
|
||||
title: '项目类型',
|
||||
key: 'itemType',
|
||||
type: JVxeTypes.select,
|
||||
width: 100,
|
||||
disabled: true,
|
||||
dictCode: 'xslmes_im_item_type',
|
||||
},
|
||||
{ title: '设备部位', key: 'equipmentPartName', type: JVxeTypes.normal, width: 120, disabled: true },
|
||||
{ title: '设备小部位', key: 'equipmentSubPartName', type: JVxeTypes.normal, width: 120, disabled: true },
|
||||
{
|
||||
title: '点检方式',
|
||||
key: 'inspectMethod',
|
||||
type: JVxeTypes.select,
|
||||
width: 100,
|
||||
disabled: true,
|
||||
dictCode: 'xslmes_im_inspect_method',
|
||||
},
|
||||
{ title: '判断基准', key: 'judgmentCriteria', type: JVxeTypes.normal, width: 180, disabled: true },
|
||||
];
|
||||
@@ -0,0 +1,132 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equip_inspect_config:add'"
|
||||
@click="handleAdd"
|
||||
preIcon="ant-design:plus-outlined"
|
||||
>
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equip_inspect_config:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equip_inspect_config: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_equip_inspect_config: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_equip_inspect_config:edit' },
|
||||
]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslEquipInspectConfigModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslEquipInspectConfig" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslEquipInspectConfigModal from './components/MesXslEquipInspectConfigModal.vue';
|
||||
import { columns, searchFormSchema } from './MesXslEquipInspectConfig.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslEquipInspectConfig.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 });
|
||||
}
|
||||
|
||||
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_equip_inspect_config:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,239 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
destroyOnClose
|
||||
:title="title"
|
||||
width="1100px"
|
||||
@register="registerModal"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<BasicForm @register="registerForm">
|
||||
<template #equipmentLedgerPicker="{ 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="openLedgerSelect">选择</a-button>
|
||||
<a-button v-if="model.equipmentLedgerId && !isDetail" @click="clearLedger">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
</BasicForm>
|
||||
<a-divider orientation="left">点检项目明细</a-divider>
|
||||
<JVxeTable
|
||||
v-if="tableReady"
|
||||
ref="lineTableRef"
|
||||
toolbar
|
||||
row-number
|
||||
rowSelection
|
||||
keep-source
|
||||
:insert-row="false"
|
||||
:max-height="380"
|
||||
:loading="lineLoading"
|
||||
:columns="lineJVxeColumns"
|
||||
:dataSource="lineDataSource"
|
||||
:disabled="!showFooterFlag"
|
||||
:toolbar-config="{ btn: ['remove'], slots: ['suffix'] }"
|
||||
:add-btn-cfg="{ enabled: false }"
|
||||
>
|
||||
<template #toolbarSuffix>
|
||||
<a-button
|
||||
v-if="showFooterFlag"
|
||||
type="primary"
|
||||
preIcon="ant-design:plus-outlined"
|
||||
@click="openBatchItemSelect"
|
||||
>
|
||||
选择点检及保养项目
|
||||
</a-button>
|
||||
</template>
|
||||
</JVxeTable>
|
||||
<MesXslEquipmentLedgerSelectModal @register="registerLedgerModal" @select="onLedgerSelect" />
|
||||
<MesXslInspectMaintainItemSelectModal @register="registerItemModal" @select="onItemsSelect" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import type { JVxeTableInstance } from '/@/components/jeecg/JVxeTable/types';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { formSchema, lineJVxeColumns } from '../MesXslEquipInspectConfig.data';
|
||||
import { saveOrUpdate, queryById, queryLineListByConfigId } from '../MesXslEquipInspectConfig.api';
|
||||
import MesXslEquipmentLedgerSelectModal from './MesXslEquipmentLedgerSelectModal.vue';
|
||||
import MesXslInspectMaintainItemSelectModal from './MesXslInspectMaintainItemSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
const isUpdate = ref(false);
|
||||
const isDetail = ref(false);
|
||||
const showFooterFlag = ref(true);
|
||||
const tableReady = ref(false);
|
||||
const lineLoading = ref(false);
|
||||
const lineDataSource = ref<Recordable[]>([]);
|
||||
const lineTableRef = ref<JVxeTableInstance>();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
|
||||
labelWidth: 110,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 12 },
|
||||
});
|
||||
|
||||
const [registerLedgerModal, { openModal: openLedgerModal }] = useModal();
|
||||
const [registerItemModal, { openModal: openItemModal }] = useModal();
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
tableReady.value = false;
|
||||
lineDataSource.value = [];
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !data?.showFooter;
|
||||
showFooterFlag.value = !!data?.showFooter;
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
if (unref(isUpdate) && data?.record?.id) {
|
||||
lineLoading.value = true;
|
||||
try {
|
||||
const mainRaw = await queryById({ id: data.record.id });
|
||||
const m = (mainRaw as any)?.id != null ? mainRaw : (mainRaw as any)?.result ?? mainRaw;
|
||||
const linesRaw = await queryLineListByConfigId({ id: data.record.id });
|
||||
const list = Array.isArray(linesRaw) ? linesRaw : (linesRaw as any)?.result ?? [];
|
||||
await setFieldsValue({ ...m });
|
||||
lineDataSource.value = [...(list || [])];
|
||||
} finally {
|
||||
lineLoading.value = false;
|
||||
}
|
||||
}
|
||||
tableReady.value = true;
|
||||
});
|
||||
|
||||
const title = computed(() =>
|
||||
!unref(isUpdate) ? '新增设备点检配置' : unref(isDetail) ? '设备点检配置详情' : '编辑设备点检配置',
|
||||
);
|
||||
|
||||
function itemToLineRow(item: Recordable) {
|
||||
return {
|
||||
inspectMaintainItemId: item.id,
|
||||
itemCode: item.itemCode,
|
||||
itemName: item.itemName,
|
||||
itemCategory: item.itemCategory,
|
||||
itemType: item.itemType,
|
||||
equipmentPartName: item.equipmentPartName,
|
||||
equipmentSubPartName: item.equipmentSubPartName,
|
||||
inspectMethod: item.inspectMethod,
|
||||
judgmentCriteria: item.judgmentCriteria,
|
||||
};
|
||||
}
|
||||
|
||||
function getExistingItemIds(): Set<string> {
|
||||
const lineRef = lineTableRef.value as any;
|
||||
const tableData = (lineRef?.getTableData?.() || lineDataSource.value || []) as Recordable[];
|
||||
const ids = new Set<string>();
|
||||
for (const r of tableData) {
|
||||
if (r?.inspectMaintainItemId) {
|
||||
ids.add(String(r.inspectMaintainItemId));
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
function openLedgerSelect() {
|
||||
const vals = getFieldsValue();
|
||||
openLedgerModal(true, { equipmentLedgerId: vals.equipmentLedgerId });
|
||||
}
|
||||
|
||||
function clearLedger() {
|
||||
setFieldsValue({ equipmentLedgerId: '', equipmentName: '', equipmentCode: '' });
|
||||
}
|
||||
|
||||
function onLedgerSelect(payload: { equipmentLedgerId?: string; equipmentName?: string; equipmentCode?: string }) {
|
||||
setFieldsValue({
|
||||
equipmentLedgerId: payload.equipmentLedgerId || '',
|
||||
equipmentName: payload.equipmentName || '',
|
||||
equipmentCode: payload.equipmentCode || '',
|
||||
});
|
||||
}
|
||||
|
||||
function openBatchItemSelect() {
|
||||
const configType = getFieldsValue()?.configType;
|
||||
if (!configType) {
|
||||
createMessage.warning('请先选择类型(点检/保养)');
|
||||
return;
|
||||
}
|
||||
openItemModal(true, { itemCategory: configType, multiple: true });
|
||||
}
|
||||
|
||||
function onItemsSelect(payload: Recordable | Recordable[]) {
|
||||
const items = Array.isArray(payload) ? payload : payload ? [payload] : [];
|
||||
if (!items.length) {
|
||||
return;
|
||||
}
|
||||
const existing = getExistingItemIds();
|
||||
const toAdd: Recordable[] = [];
|
||||
const skipped: string[] = [];
|
||||
for (const item of items) {
|
||||
if (!item?.id) {
|
||||
continue;
|
||||
}
|
||||
const id = String(item.id);
|
||||
if (existing.has(id)) {
|
||||
skipped.push(item.itemName || item.itemCode || id);
|
||||
continue;
|
||||
}
|
||||
existing.add(id);
|
||||
toAdd.push(itemToLineRow(item));
|
||||
}
|
||||
if (!toAdd.length) {
|
||||
if (skipped.length) {
|
||||
createMessage.warning('所选项目均已在明细中,未添加新行');
|
||||
}
|
||||
return;
|
||||
}
|
||||
const lineRef = lineTableRef.value as any;
|
||||
if (lineRef?.pushRows) {
|
||||
lineRef.pushRows(toAdd);
|
||||
} else {
|
||||
lineDataSource.value = [...lineDataSource.value, ...toAdd];
|
||||
}
|
||||
if (skipped.length) {
|
||||
createMessage.warning(`已添加 ${toAdd.length} 项,跳过 ${skipped.length} 项重复项目`);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
const lineRef = lineTableRef.value as any;
|
||||
const tableData = (lineRef?.getTableData?.() || []) as Recordable[];
|
||||
const lineList = tableData
|
||||
.filter((r) => r && r.inspectMaintainItemId)
|
||||
.map((r) => ({
|
||||
inspectMaintainItemId: r.inspectMaintainItemId,
|
||||
itemCode: r.itemCode,
|
||||
itemName: r.itemName,
|
||||
itemCategory: r.itemCategory,
|
||||
itemType: r.itemType,
|
||||
equipmentPartName: r.equipmentPartName,
|
||||
equipmentSubPartName: r.equipmentSubPartName,
|
||||
inspectMethod: r.inspectMethod,
|
||||
judgmentCriteria: r.judgmentCriteria,
|
||||
}));
|
||||
if (!lineList.length) {
|
||||
createMessage.warning('请通过「选择点检及保养项目」至少添加一条明细');
|
||||
return;
|
||||
}
|
||||
const ids = new Set<string>();
|
||||
for (const line of lineList) {
|
||||
if (ids.has(line.inspectMaintainItemId)) {
|
||||
createMessage.warning('明细中点检项目不能重复');
|
||||
return;
|
||||
}
|
||||
ids.add(line.inspectMaintainItemId);
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate({ ...values, lineList }, unref(isUpdate));
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,93 @@
|
||||
<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/mesXslEquipmentLedger/MesXslEquipmentLedger.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
}
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: list,
|
||||
columns: [
|
||||
{ title: '设备名称', dataIndex: 'equipmentName', width: 160 },
|
||||
{ title: '设备编号', dataIndex: 'equipmentCode', width: 140 },
|
||||
{ title: '设备类别', dataIndex: 'equipmentCategoryName', width: 120 },
|
||||
{ title: '设备类型', dataIndex: 'equipmentTypeName', width: 120 },
|
||||
],
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: [
|
||||
{ label: '设备名称', field: 'equipmentName', component: 'Input', colProps: { span: 8 } },
|
||||
{ label: '设备编号', field: 'equipmentCode', 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 lid = data?.equipmentLedgerId as string | undefined;
|
||||
if (lid) {
|
||||
setSelectedRowKeys?.([lid]);
|
||||
try {
|
||||
const raw = await queryById({ id: lid });
|
||||
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', { equipmentLedgerId: '', equipmentName: '', equipmentCode: '' });
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
equipmentLedgerId: row.id,
|
||||
equipmentName: row.equipmentName || '',
|
||||
equipmentCode: row.equipmentCode || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" :title="modalTitle" :width="1100" @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 } from '/@/views/xslmes/mesXslInspectMaintainItem/MesXslInspectMaintainItem.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const multipleMode = ref(true);
|
||||
const filterItemCategory = ref('');
|
||||
const selectedRows = ref<Recordable[]>([]);
|
||||
|
||||
const modalTitle = computed(() => (multipleMode.value ? '选择点检及保养项目(可多选)' : '选择点检及保养项目'));
|
||||
|
||||
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
|
||||
selectedRows.value = rows || [];
|
||||
}
|
||||
|
||||
function fetchItemPage(params: Recordable) {
|
||||
const p = { ...params };
|
||||
if (filterItemCategory.value) {
|
||||
p.itemCategory = filterItemCategory.value;
|
||||
}
|
||||
return list(p);
|
||||
}
|
||||
|
||||
const [registerTable, { reload, getSelectRows, clearSelectedRowKeys }] = useTable({
|
||||
api: fetchItemPage,
|
||||
columns: [
|
||||
{ title: '项目编号', dataIndex: 'itemCode', width: 120 },
|
||||
{ title: '项目名称', dataIndex: 'itemName', width: 140 },
|
||||
{ title: '项目类别', dataIndex: 'itemCategory_dictText', width: 90 },
|
||||
{ title: '项目类型', dataIndex: 'itemType_dictText', width: 90 },
|
||||
{ title: '设备部位', dataIndex: 'equipmentPartName', width: 110 },
|
||||
{ title: '设备小部位', dataIndex: 'equipmentSubPartName', width: 110 },
|
||||
{ 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 } },
|
||||
],
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
rowSelection: {
|
||||
type: 'checkbox',
|
||||
columnWidth: 48,
|
||||
onChange: handleSelectionChange,
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
multipleMode.value = data?.multiple !== false;
|
||||
filterItemCategory.value = data?.itemCategory ? String(data.itemCategory) : '';
|
||||
selectedRows.value = [];
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
reload();
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
let rows = selectedRows.value?.length ? [...selectedRows.value] : ((getSelectRows?.() || []) as Recordable[]);
|
||||
const valid = rows.filter((r) => r?.id && (r.itemCode != null || r.itemName != null));
|
||||
if (!valid.length) {
|
||||
closeModal();
|
||||
return;
|
||||
}
|
||||
if (multipleMode.value) {
|
||||
emit('select', valid);
|
||||
} else {
|
||||
emit('select', valid[0]);
|
||||
}
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,65 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslEquipInspectRecord/list',
|
||||
save = '/xslmes/mesXslEquipInspectRecord/add',
|
||||
edit = '/xslmes/mesXslEquipInspectRecord/edit',
|
||||
deleteOne = '/xslmes/mesXslEquipInspectRecord/delete',
|
||||
deleteBatch = '/xslmes/mesXslEquipInspectRecord/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslEquipInspectRecord/importExcel',
|
||||
exportXls = '/xslmes/mesXslEquipInspectRecord/exportXls',
|
||||
queryById = '/xslmes/mesXslEquipInspectRecord/queryById',
|
||||
queryLineList = '/xslmes/mesXslEquipInspectRecord/queryLineListByRecordId',
|
||||
generateRecordNo = '/xslmes/mesXslEquipInspectRecord/generateRecordNo',
|
||||
loadLinesByEquipment = '/xslmes/mesXslEquipInspectRecord/loadLinesByEquipment',
|
||||
batchCreateFromEquipment = '/xslmes/mesXslEquipInspectRecord/batchCreateFromEquipment',
|
||||
handleFail = '/xslmes/mesXslEquipInspectRecord/handleFail',
|
||||
}
|
||||
|
||||
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 queryLineListByRecordId = (params: { id: string }) => defHttp.get({ url: Api.queryLineList, params });
|
||||
|
||||
export const generateRecordNo = () => defHttp.get({ url: Api.generateRecordNo });
|
||||
|
||||
export const loadLinesByEquipment = (params: { equipmentLedgerId: string; recordType: string }) =>
|
||||
defHttp.get({ url: Api.loadLinesByEquipment, params });
|
||||
|
||||
export const batchCreateFromEquipment = (params: { equipmentLedgerIds: string[]; recordType: string }) =>
|
||||
defHttp.post({ url: Api.batchCreateFromEquipment, 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 });
|
||||
};
|
||||
|
||||
export const handleFailRecord = (params: Recordable) => defHttp.post({ url: Api.handleFail, params });
|
||||
@@ -0,0 +1,222 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
|
||||
import { uploadUrl } from '/@/api/common/api';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '记录编号', align: 'center', dataIndex: 'recordNo', width: 150 },
|
||||
{ title: '计划单号', align: 'center', dataIndex: 'planNo', width: 130 },
|
||||
{ title: '设备名称', align: 'center', dataIndex: 'equipmentName', width: 150 },
|
||||
{ title: '设备编码', align: 'center', dataIndex: 'equipmentCode', width: 130 },
|
||||
{ title: '类型', align: 'center', dataIndex: 'recordType_dictText', width: 80 },
|
||||
{ title: '点检日期', align: 'center', dataIndex: 'inspectDate', width: 110 },
|
||||
{ title: '点检人', align: 'center', dataIndex: 'inspectorRealname', width: 100 },
|
||||
{ title: '点检结果', align: 'center', dataIndex: 'inspectResult_dictText', width: 90 },
|
||||
{ title: '是否已处理', align: 'center', dataIndex: 'handledFlag_dictText', width: 90 },
|
||||
{ title: '状态', align: 'center', dataIndex: 'recordStatus_dictText', width: 90 },
|
||||
{
|
||||
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: 'recordNo', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '计划单号', field: 'planNo', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '设备名称', field: 'equipmentName', component: 'Input', colProps: { span: 6 } },
|
||||
{
|
||||
label: '类型',
|
||||
field: 'recordType',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_im_item_category' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'recordStatus',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_im_record_status' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '', field: 'equipmentLedgerId', component: 'Input', show: false },
|
||||
{ label: '', field: 'planId', component: 'Input', show: false },
|
||||
{ label: '', field: 'equipInspectConfigId', component: 'Input', show: false },
|
||||
{ label: '', field: 'inspectorUserId', component: 'Input', show: false },
|
||||
{ label: '', field: 'inspectorUsername', component: 'Input', show: false },
|
||||
{
|
||||
label: '记录编号',
|
||||
field: 'recordNo',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true, placeholder: '保存时自动生成' },
|
||||
dynamicRules: () => [{ required: true, message: '记录编号不能为空' }],
|
||||
},
|
||||
{ label: '计划单号', field: 'planNo', component: 'Input' },
|
||||
{
|
||||
label: '设备名称',
|
||||
field: 'equipmentName',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
},
|
||||
{
|
||||
label: '设备编码',
|
||||
field: 'equipmentCode',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
},
|
||||
{
|
||||
label: '类型',
|
||||
field: 'recordType',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_im_item_category', disabled: true },
|
||||
},
|
||||
{
|
||||
label: '点检日期',
|
||||
field: 'inspectDate',
|
||||
component: 'DatePicker',
|
||||
required: true,
|
||||
componentProps: { valueFormat: 'YYYY-MM-DD', style: { width: '100%' } },
|
||||
},
|
||||
{
|
||||
label: '点检人',
|
||||
field: 'inspectorRealname',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true, placeholder: '当前登录用户' },
|
||||
dynamicRules: () => [{ required: true, message: '点检人不能为空' }],
|
||||
},
|
||||
{
|
||||
label: '点检结果',
|
||||
field: 'inspectResult',
|
||||
component: 'JDictSelectTag',
|
||||
required: true,
|
||||
componentProps: { dictCode: 'xslmes_im_inspect_result', placeholder: '合格/不合格' },
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'recordStatus',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_im_record_status', disabled: true },
|
||||
},
|
||||
];
|
||||
|
||||
/** 详情页:仅不合格记录展示的处理信息(只读) */
|
||||
export const processDisplayFormSchema: FormSchema[] = [
|
||||
{
|
||||
label: '是否已处理',
|
||||
field: 'handledFlag',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'yn', disabled: true },
|
||||
},
|
||||
{
|
||||
label: '处理人',
|
||||
field: 'handlerRealname',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
},
|
||||
{
|
||||
label: '处理时间',
|
||||
field: 'handleTime',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
style: { width: '100%' },
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
/** 不合格记录处理弹窗 */
|
||||
export const handleFormSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '', field: 'handlerUsername', component: 'Input', show: false },
|
||||
{ label: '', field: 'handlerRealname', component: 'Input', show: false },
|
||||
{
|
||||
label: '处理人',
|
||||
field: 'handlerUserId',
|
||||
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({
|
||||
handlerUsername: row.username,
|
||||
handlerRealname: row.realname,
|
||||
});
|
||||
}
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: '处理时间',
|
||||
field: 'handleTime',
|
||||
component: 'DatePicker',
|
||||
required: true,
|
||||
componentProps: {
|
||||
showTime: true,
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
style: { width: '100%' },
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const lineJVxeColumns: JVxeColumn[] = [
|
||||
{ title: '', key: 'equipInspectConfigLineId', type: JVxeTypes.hidden },
|
||||
{ title: '', key: 'inspectMaintainItemId', type: JVxeTypes.hidden },
|
||||
{ title: '点检项目编号', key: 'itemCode', type: JVxeTypes.normal, width: 120, disabled: true },
|
||||
{ title: '点检项目', key: 'itemName', type: JVxeTypes.normal, width: 130, disabled: true },
|
||||
{
|
||||
title: '项目类别',
|
||||
key: 'itemCategory',
|
||||
type: JVxeTypes.select,
|
||||
width: 90,
|
||||
disabled: true,
|
||||
dictCode: 'xslmes_im_item_category',
|
||||
filters: false,
|
||||
sortable: false,
|
||||
},
|
||||
{
|
||||
title: '项目类型',
|
||||
key: 'itemType',
|
||||
type: JVxeTypes.select,
|
||||
width: 90,
|
||||
disabled: true,
|
||||
dictCode: 'xslmes_im_item_type',
|
||||
filters: false,
|
||||
sortable: false,
|
||||
},
|
||||
{ title: '设备部位', key: 'equipmentPartName', type: JVxeTypes.normal, width: 100, disabled: true },
|
||||
{ title: '设备小部位', key: 'equipmentSubPartName', type: JVxeTypes.normal, width: 100, disabled: true },
|
||||
{
|
||||
title: '点检方式',
|
||||
key: 'inspectMethod',
|
||||
type: JVxeTypes.select,
|
||||
width: 90,
|
||||
disabled: true,
|
||||
dictCode: 'xslmes_im_inspect_method',
|
||||
filters: false,
|
||||
sortable: false,
|
||||
},
|
||||
{ title: '判断基准', key: 'judgmentCriteria', type: JVxeTypes.normal, width: 150, disabled: true },
|
||||
{ title: '点检描述', key: 'lineInspectResult', type: JVxeTypes.input, width: 140 },
|
||||
{
|
||||
title: '图片',
|
||||
key: 'pictureFiles',
|
||||
type: JVxeTypes.image,
|
||||
width: 160,
|
||||
maxCount: 3,
|
||||
token: true,
|
||||
action: uploadUrl,
|
||||
responseName: 'message',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,153 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_equip_inspect_record:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-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_equip_inspect_record:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableActions(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslEquipInspectRecordModal @register="registerModal" @success="handleSuccess" />
|
||||
<MesXslEquipInspectRecordHandleModal @register="registerHandleModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslEquipInspectRecord" 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 MesXslEquipInspectRecordModal from './components/MesXslEquipInspectRecordModal.vue';
|
||||
import MesXslEquipInspectRecordHandleModal from './components/MesXslEquipInspectRecordHandleModal.vue';
|
||||
import { columns, searchFormSchema } from './MesXslEquipInspectRecord.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl } from './MesXslEquipInspectRecord.api';
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
const [registerHandleModal, { openModal: openHandleModal }] = useModal();
|
||||
|
||||
const { tableContext, onExportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '点检保养记录',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
labelWidth: 100,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
actionColumn: {
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: '点检保养记录',
|
||||
url: getExportUrl,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
|
||||
function handleEnterResult(record: Recordable) {
|
||||
if (record.recordStatus !== 'pending') {
|
||||
createMessage.warning('仅待点检记录可录入点检结果');
|
||||
return;
|
||||
}
|
||||
openModal(true, { record, showFooter: true });
|
||||
}
|
||||
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, { record, showFooter: false });
|
||||
}
|
||||
|
||||
function canHandleFail(record: Recordable) {
|
||||
return (
|
||||
record.inspectResult === 'fail' &&
|
||||
record.recordStatus === 'done' &&
|
||||
record.handledFlag !== '1'
|
||||
);
|
||||
}
|
||||
|
||||
function handleProcess(record: Recordable) {
|
||||
if (!canHandleFail(record)) {
|
||||
createMessage.warning('仅未处理的不合格记录可登记处理');
|
||||
return;
|
||||
}
|
||||
openHandleModal(true, { record });
|
||||
}
|
||||
|
||||
function getTableActions(record: Recordable) {
|
||||
if (record.recordStatus === 'pending') {
|
||||
return [
|
||||
{
|
||||
label: '录入点检结果',
|
||||
onClick: handleEnterResult.bind(null, record),
|
||||
auth: 'mes:mes_xsl_equip_inspect_record:edit',
|
||||
},
|
||||
];
|
||||
}
|
||||
const actions: Recordable[] = [{ label: '详情', onClick: handleDetail.bind(null, record) }];
|
||||
if (canHandleFail(record)) {
|
||||
actions.push({
|
||||
label: '处理',
|
||||
onClick: handleProcess.bind(null, record),
|
||||
auth: 'mes:mes_xsl_equip_inspect_record:edit',
|
||||
});
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
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: Recordable) {
|
||||
if (record.recordStatus === 'pending') {
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'mes:mes_xsl_equip_inspect_record:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,63 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" destroyOnClose title="不合格记录处理" width="520px" @register="registerModal" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import dayjs from 'dayjs';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { handleFormSchema } from '../MesXslEquipInspectRecord.data';
|
||||
import { handleFailRecord } from '../MesXslEquipInspectRecord.api';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: handleFormSchema,
|
||||
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;
|
||||
}
|
||||
const user = userStore.getUserInfo || {};
|
||||
await setFieldsValue({
|
||||
id: record.id,
|
||||
handlerUserId: user.id,
|
||||
handlerUsername: user.username,
|
||||
handlerRealname: user.realname,
|
||||
handleTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
});
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
if (!values.handlerUserId) {
|
||||
createMessage.warning('请选择处理人');
|
||||
return;
|
||||
}
|
||||
if (!values.handleTime) {
|
||||
createMessage.warning('请选择处理时间');
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await handleFailRecord(values);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,173 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
destroyOnClose
|
||||
:title="title"
|
||||
width="1150px"
|
||||
@register="registerModal"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<BasicForm @register="registerForm" />
|
||||
<a-divider orientation="left">点检项目明细(来自设备点检配置,只读)</a-divider>
|
||||
<JVxeTable
|
||||
v-if="tableReady"
|
||||
ref="lineTableRef"
|
||||
row-number
|
||||
keep-source
|
||||
:insert-row="false"
|
||||
:toolbar="false"
|
||||
:row-selection="false"
|
||||
:max-height="400"
|
||||
:loading="lineLoading"
|
||||
:columns="lineColumns"
|
||||
:dataSource="lineDataSource"
|
||||
/>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import type { JVxeColumn, JVxeTableInstance } from '/@/components/jeecg/JVxeTable/types';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { formSchema, lineJVxeColumns, processDisplayFormSchema } from '../MesXslEquipInspectRecord.data';
|
||||
import { saveOrUpdate, queryById, queryLineListByRecordId } from '../MesXslEquipInspectRecord.api';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
const userStore = useUserStore();
|
||||
const isDetail = ref(false);
|
||||
const showFooterFlag = ref(true);
|
||||
const tableReady = ref(false);
|
||||
const lineLoading = ref(false);
|
||||
const lineDataSource = ref<Recordable[]>([]);
|
||||
const lineTableRef = ref<JVxeTableInstance>();
|
||||
|
||||
const lineColumns = computed<JVxeColumn[]>(() =>
|
||||
lineJVxeColumns.map((col) => {
|
||||
const editable = col.key === 'lineInspectResult' || col.key === 'pictureFiles';
|
||||
if (editable) {
|
||||
return { ...col, disabled: !showFooterFlag.value };
|
||||
}
|
||||
return { ...col, disabled: true };
|
||||
}),
|
||||
);
|
||||
|
||||
const showProcessFields = ref(false);
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps, resetSchema }] = useForm({
|
||||
labelWidth: 110,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 12 },
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
tableReady.value = false;
|
||||
lineDataSource.value = [];
|
||||
await resetFields();
|
||||
const editable = !!data?.showFooter;
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: editable, showOkBtn: editable });
|
||||
isDetail.value = !editable;
|
||||
showFooterFlag.value = editable;
|
||||
setProps({ disabled: !editable });
|
||||
showProcessFields.value = false;
|
||||
await resetSchema(formSchema);
|
||||
|
||||
if (data?.record?.id) {
|
||||
lineLoading.value = true;
|
||||
try {
|
||||
const mainRaw = await queryById({ id: data.record.id });
|
||||
const m = (mainRaw as any)?.id != null ? mainRaw : (mainRaw as any)?.result ?? mainRaw;
|
||||
if (editable && m.recordStatus !== 'pending') {
|
||||
createMessage.warning('仅待点检记录可录入点检结果');
|
||||
setModalProps({ showOkBtn: false, showCancelBtn: true });
|
||||
isDetail.value = true;
|
||||
showFooterFlag.value = false;
|
||||
setProps({ disabled: true });
|
||||
}
|
||||
const linesRaw = await queryLineListByRecordId({ id: data.record.id });
|
||||
const list = Array.isArray(linesRaw) ? linesRaw : (linesRaw as any)?.result ?? [];
|
||||
const user = userStore.getUserInfo || {};
|
||||
const patch: Recordable = { ...m };
|
||||
if (editable && showFooterFlag.value) {
|
||||
if (!patch.inspectDate) {
|
||||
patch.inspectDate = dayjs().format('YYYY-MM-DD');
|
||||
}
|
||||
if (!patch.inspectorRealname) {
|
||||
patch.inspectorUserId = user.id;
|
||||
patch.inspectorUsername = user.username;
|
||||
patch.inspectorRealname = user.realname;
|
||||
}
|
||||
}
|
||||
await setFieldsValue(patch);
|
||||
if (!editable && m.inspectResult === 'fail') {
|
||||
showProcessFields.value = true;
|
||||
await resetSchema([...formSchema, ...processDisplayFormSchema]);
|
||||
await setFieldsValue(patch);
|
||||
}
|
||||
lineDataSource.value = [...(list || [])];
|
||||
} finally {
|
||||
lineLoading.value = false;
|
||||
}
|
||||
}
|
||||
tableReady.value = true;
|
||||
});
|
||||
|
||||
const title = computed(() =>
|
||||
unref(isDetail) ? '点检保养记录详情' : '录入点检结果',
|
||||
);
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!showFooterFlag.value) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const values = await validate();
|
||||
const lineRef = lineTableRef.value as any;
|
||||
const tableData = (lineRef?.getTableData?.() || lineDataSource.value || []) as Recordable[];
|
||||
const lineList = tableData
|
||||
.filter((r) => r && r.equipInspectConfigLineId)
|
||||
.map((r) => ({
|
||||
id: r.id,
|
||||
equipInspectConfigLineId: r.equipInspectConfigLineId,
|
||||
inspectMaintainItemId: r.inspectMaintainItemId,
|
||||
itemCode: r.itemCode,
|
||||
itemName: r.itemName,
|
||||
itemCategory: r.itemCategory,
|
||||
itemType: r.itemType,
|
||||
equipmentPartName: r.equipmentPartName,
|
||||
equipmentSubPartName: r.equipmentSubPartName,
|
||||
inspectMethod: r.inspectMethod,
|
||||
judgmentCriteria: r.judgmentCriteria,
|
||||
lineInspectResult: r.lineInspectResult,
|
||||
pictureFiles: r.pictureFiles,
|
||||
}));
|
||||
if (!lineList.length) {
|
||||
createMessage.warning('点检明细不能为空');
|
||||
return;
|
||||
}
|
||||
if (!values.inspectResult) {
|
||||
createMessage.warning('请选择点检结果');
|
||||
return;
|
||||
}
|
||||
if (!values.inspectDate) {
|
||||
createMessage.warning('请选择点检日期');
|
||||
return;
|
||||
}
|
||||
if (!values.inspectorRealname) {
|
||||
createMessage.warning('点检人不能为空');
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate({ ...values, recordStatus: 'done', lineList }, true);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -5,6 +5,24 @@
|
||||
<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'"
|
||||
@@ -53,10 +71,14 @@
|
||||
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();
|
||||
|
||||
@@ -87,7 +109,7 @@
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const [registerTable, { reload, getSelectRows }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
|
||||
function handleAdd() {
|
||||
openModal(true, { isUpdate: false, showFooter: true });
|
||||
@@ -114,6 +136,46 @@
|
||||
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) },
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslFormulaSpec/list',
|
||||
save = '/xslmes/mesXslFormulaSpec/add',
|
||||
edit = '/xslmes/mesXslFormulaSpec/edit',
|
||||
deleteOne = '/xslmes/mesXslFormulaSpec/delete',
|
||||
deleteBatch = '/xslmes/mesXslFormulaSpec/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslFormulaSpec/importExcel',
|
||||
exportXls = '/xslmes/mesXslFormulaSpec/exportXls',
|
||||
queryById = '/xslmes/mesXslFormulaSpec/queryById',
|
||||
queryLineList = '/xslmes/mesXslFormulaSpec/queryLineListByMainId',
|
||||
generateRubberCode = '/xslmes/mesXslFormulaSpec/generateRubberCode',
|
||||
getRubberContentSetting = '/xslmes/mesXslFormulaSpec/getRubberContentSetting',
|
||||
saveRubberContentSetting = '/xslmes/mesXslFormulaSpec/saveRubberContentSetting',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||
export const queryLineListByMainId = (params) => defHttp.get({ url: Api.queryLineList, params });
|
||||
export const generateRubberCode = (params) =>
|
||||
defHttp.get({ url: Api.generateRubberCode, params }, { successMessageMode: 'none' });
|
||||
export const getRubberContentSetting = () => defHttp.get({ url: Api.getRubberContentSetting });
|
||||
export const saveRubberContentSetting = (params) => defHttp.post({ url: Api.saveRubberContentSetting, params });
|
||||
|
||||
export const deleteOne = (params, handleSuccess) =>
|
||||
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () =>
|
||||
defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => handleSuccess()),
|
||||
});
|
||||
};
|
||||
|
||||
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'xslmes:mes_xsl_formula_spec:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'xslmes:mes_xsl_formula_spec:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'xslmes:mes_xsl_formula_spec: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="'xslmes:mes_xsl_formula_spec:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableActions(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslFormulaSpecModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslFormulaSpec" setup>
|
||||
import { reactive } from 'vue';
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslFormulaSpecModal from './components/MesXslFormulaSpecModal.vue';
|
||||
import { columns, searchFormSchema, superQuerySchema } from './MesXslFormulaSpec.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslFormulaSpec.api';
|
||||
|
||||
const queryParam = reactive<any>({});
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '配合示方',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
labelWidth: 90,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
actionColumn: {
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
slots: { customRender: 'action' },
|
||||
},
|
||||
beforeFetch: (params) => Object.assign(params, queryParam),
|
||||
},
|
||||
exportConfig: {
|
||||
name: '配合示方',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).forEach((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
reload();
|
||||
}
|
||||
|
||||
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 canEdit(record: Recordable) {
|
||||
return !record?.status || record.status === 'compile';
|
||||
}
|
||||
|
||||
function getTableActions(record: Recordable) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
auth: 'xslmes:mes_xsl_formula_spec:edit',
|
||||
ifShow: canEdit(record),
|
||||
},
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
ifShow: !canEdit(record),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function getDropDownAction(record: Recordable) {
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record), ifShow: canEdit(record) },
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'xslmes:mes_xsl_formula_spec:delete',
|
||||
ifShow: canEdit(record),
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-table) {
|
||||
.ant-table-thead > tr > th {
|
||||
background: #fafafa;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<Popover
|
||||
v-model:open="popoverOpen"
|
||||
trigger="click"
|
||||
placement="bottomRight"
|
||||
:overlayClassName="`${prefixCls}__popover`"
|
||||
@open-change="handleOpenChange"
|
||||
>
|
||||
<template #title>
|
||||
<div :class="`${prefixCls}__title`">
|
||||
<Checkbox :indeterminate="indeterminate" :checked="checkAll" @change="onCheckAllChange">列展示</Checkbox>
|
||||
</div>
|
||||
</template>
|
||||
<template #content>
|
||||
<div :class="`${prefixCls}__list`">
|
||||
<CheckboxGroup v-model:value="draftCheckedList" :options="columnOptions" />
|
||||
</div>
|
||||
<div :class="`${prefixCls}__footer`">
|
||||
<a-button size="small" @click="handleReset">重置</a-button>
|
||||
<a-button size="small" type="primary" @click="handleSave">保存</a-button>
|
||||
</div>
|
||||
</template>
|
||||
<a-tooltip title="列设置">
|
||||
<a-button size="small" class="formula-line-column-setting-btn" @click.stop>
|
||||
<Icon icon="ant-design:setting-outlined" />
|
||||
</a-button>
|
||||
</a-tooltip>
|
||||
</Popover>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, type PropType } from 'vue';
|
||||
import { Popover, Checkbox } from 'ant-design-vue';
|
||||
import type { CheckboxChangeEvent } from 'ant-design-vue/lib/checkbox/interface';
|
||||
import { Icon } from '/@/components/Icon';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import {
|
||||
FORMULA_LINE_LOCKED_COLUMN_KEYS,
|
||||
getFormulaLineColumnSettingItems,
|
||||
saveFormulaLineHiddenColumnKeys,
|
||||
type FormulaLineColumnSettingItem,
|
||||
} from '../MesXslFormulaSpec.data';
|
||||
|
||||
const CheckboxGroup = Checkbox.Group;
|
||||
const prefixCls = 'formula-line-column-setting';
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const props = defineProps({
|
||||
hiddenKeys: {
|
||||
type: Array as PropType<string[]>,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:hiddenKeys', value: string[]): void;
|
||||
(e: 'change', value: string[]): void;
|
||||
}>();
|
||||
|
||||
const popoverOpen = ref(false);
|
||||
const columnItems = ref<FormulaLineColumnSettingItem[]>(getFormulaLineColumnSettingItems());
|
||||
const allKeys = computed(() => columnItems.value.map((item) => item.key));
|
||||
const lockableKeys = computed(() => columnItems.value.filter((item) => !item.locked).map((item) => item.key));
|
||||
|
||||
/** 弹窗内草稿勾选状态,保存后才应用到表格 */
|
||||
const draftCheckedList = ref<string[]>([]);
|
||||
|
||||
const columnOptions = computed(() =>
|
||||
columnItems.value.map((item) => ({
|
||||
label: item.title,
|
||||
value: item.key,
|
||||
disabled: item.locked,
|
||||
})),
|
||||
);
|
||||
|
||||
const checkAll = computed(() => {
|
||||
const keys = lockableKeys.value;
|
||||
return keys.length > 0 && keys.every((key) => draftCheckedList.value.includes(key));
|
||||
});
|
||||
|
||||
const indeterminate = computed(() => {
|
||||
const keys = lockableKeys.value;
|
||||
const checkedCount = keys.filter((key) => draftCheckedList.value.includes(key)).length;
|
||||
return checkedCount > 0 && checkedCount < keys.length;
|
||||
});
|
||||
|
||||
function ensureLockedChecked() {
|
||||
const next = new Set(draftCheckedList.value);
|
||||
FORMULA_LINE_LOCKED_COLUMN_KEYS.forEach((key) => next.add(key));
|
||||
draftCheckedList.value = Array.from(next);
|
||||
}
|
||||
|
||||
function syncDraftFromHidden(hiddenKeys: string[]) {
|
||||
const hiddenSet = new Set(hiddenKeys || []);
|
||||
draftCheckedList.value = allKeys.value.filter((key) => !hiddenSet.has(key));
|
||||
ensureLockedChecked();
|
||||
}
|
||||
|
||||
function buildHiddenKeysFromDraft() {
|
||||
ensureLockedChecked();
|
||||
return allKeys.value.filter((key) => !draftCheckedList.value.includes(key));
|
||||
}
|
||||
|
||||
function handleOpenChange(open: boolean) {
|
||||
if (open) {
|
||||
syncDraftFromHidden(props.hiddenKeys);
|
||||
}
|
||||
}
|
||||
|
||||
function onCheckAllChange(e: CheckboxChangeEvent) {
|
||||
draftCheckedList.value = e.target.checked ? [...allKeys.value] : [...FORMULA_LINE_LOCKED_COLUMN_KEYS];
|
||||
}
|
||||
|
||||
function handleReset() {
|
||||
draftCheckedList.value = [...allKeys.value];
|
||||
}
|
||||
|
||||
function handleSave() {
|
||||
const hiddenKeys = buildHiddenKeysFromDraft();
|
||||
saveFormulaLineHiddenColumnKeys(hiddenKeys);
|
||||
emit('update:hiddenKeys', hiddenKeys);
|
||||
emit('change', hiddenKeys);
|
||||
createMessage.success('保存成功');
|
||||
popoverOpen.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.formula-line-column-setting-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-inline: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
.formula-line-column-setting__popover {
|
||||
.formula-line-column-setting__title {
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.formula-line-column-setting__list {
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 8px;
|
||||
|
||||
.ant-checkbox-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.ant-checkbox-group-item {
|
||||
margin-inline-start: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.formula-line-column-setting__footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding-top: 4px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,240 @@
|
||||
<template>
|
||||
|
||||
<BasicModal
|
||||
|
||||
v-bind="$attrs"
|
||||
|
||||
title="含胶率物料小类设置"
|
||||
|
||||
:width="640"
|
||||
|
||||
@register="registerModal"
|
||||
|
||||
@ok="handleSubmit"
|
||||
|
||||
>
|
||||
|
||||
<a-form layout="vertical" class="rubber-content-setting-form">
|
||||
|
||||
<a-form-item label="天然橡胶">
|
||||
|
||||
<a-select
|
||||
|
||||
v-model:value="formState.naturalMinorCategoryIds"
|
||||
|
||||
mode="multiple"
|
||||
|
||||
allowClear
|
||||
|
||||
showSearch
|
||||
|
||||
optionFilterProp="label"
|
||||
|
||||
placeholder="请选择计入天然橡胶的物料分类"
|
||||
|
||||
:options="minorCategoryOptions"
|
||||
|
||||
:loading="optionsLoading"
|
||||
|
||||
/>
|
||||
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="合成橡胶">
|
||||
|
||||
<a-select
|
||||
|
||||
v-model:value="formState.syntheticMinorCategoryIds"
|
||||
|
||||
mode="multiple"
|
||||
|
||||
allowClear
|
||||
|
||||
showSearch
|
||||
|
||||
optionFilterProp="label"
|
||||
|
||||
placeholder="请选择计入合成橡胶的物料分类"
|
||||
|
||||
:options="minorCategoryOptions"
|
||||
|
||||
:loading="optionsLoading"
|
||||
|
||||
/>
|
||||
|
||||
</a-form-item>
|
||||
|
||||
<div class="setting-tip">选项来自系统分类字典「MES物料分类」全部节点,保存后含胶率将按所选分类汇总明细行重量%。</div>
|
||||
|
||||
</a-form>
|
||||
|
||||
</BasicModal>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
|
||||
import { getRubberContentSetting, saveRubberContentSetting } from '../MesXslFormulaSpec.api';
|
||||
|
||||
import { fetchMaterialCategoryOptions } from '../MesXslFormulaSpec.data';
|
||||
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
|
||||
|
||||
const optionsLoading = ref(false);
|
||||
|
||||
const minorCategoryOptions = ref<Array<{ label: string; value: string }>>([]);
|
||||
|
||||
const formState = reactive({
|
||||
|
||||
naturalMinorCategoryIds: [] as string[],
|
||||
|
||||
syntheticMinorCategoryIds: [] as string[],
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
const [registerModal, { setModalProps, closeModal, getOpen }] = useModalInner();
|
||||
|
||||
watch(
|
||||
() => getOpen.value,
|
||||
async (open) => {
|
||||
if (!open) {
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: false });
|
||||
await Promise.all([loadMinorCategoryOptions(), loadSetting()]);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
|
||||
async function loadMinorCategoryOptions() {
|
||||
|
||||
optionsLoading.value = true;
|
||||
|
||||
try {
|
||||
|
||||
minorCategoryOptions.value = await fetchMaterialCategoryOptions();
|
||||
|
||||
if (!minorCategoryOptions.value.length) {
|
||||
|
||||
createMessage.warning('未加载到 MES物料分类,请先在分类字典中维护。');
|
||||
|
||||
}
|
||||
|
||||
} catch {
|
||||
|
||||
minorCategoryOptions.value = [];
|
||||
|
||||
createMessage.warning('加载 MES物料分类 失败,请检查分类字典是否已配置。');
|
||||
|
||||
} finally {
|
||||
|
||||
optionsLoading.value = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function loadSetting() {
|
||||
|
||||
try {
|
||||
|
||||
const raw = await getRubberContentSetting();
|
||||
|
||||
const setting = (raw as Recordable)?.naturalMinorCategoryIds != null ? raw : (raw as Recordable)?.result ?? raw;
|
||||
|
||||
formState.naturalMinorCategoryIds = [...((setting as Recordable)?.naturalMinorCategoryIds || [])];
|
||||
|
||||
formState.syntheticMinorCategoryIds = [...((setting as Recordable)?.syntheticMinorCategoryIds || [])];
|
||||
|
||||
} catch {
|
||||
|
||||
formState.naturalMinorCategoryIds = [];
|
||||
|
||||
formState.syntheticMinorCategoryIds = [];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function handleSubmit() {
|
||||
|
||||
try {
|
||||
|
||||
setModalProps({ confirmLoading: true });
|
||||
|
||||
await saveRubberContentSetting({
|
||||
|
||||
naturalMinorCategoryIds: formState.naturalMinorCategoryIds,
|
||||
|
||||
syntheticMinorCategoryIds: formState.syntheticMinorCategoryIds,
|
||||
|
||||
});
|
||||
|
||||
createMessage.success('保存成功');
|
||||
|
||||
closeModal();
|
||||
|
||||
emit('success', {
|
||||
|
||||
naturalMinorCategoryIds: [...formState.naturalMinorCategoryIds],
|
||||
|
||||
syntheticMinorCategoryIds: [...formState.syntheticMinorCategoryIds],
|
||||
|
||||
});
|
||||
|
||||
} finally {
|
||||
|
||||
setModalProps({ confirmLoading: false });
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
.rubber-content-setting-form {
|
||||
|
||||
padding-top: 8px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
.setting-tip {
|
||||
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
|
||||
font-size: 12px;
|
||||
|
||||
line-height: 1.6;
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -145,7 +145,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false, placeholder: '保存后按创建人显示' },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
},
|
||||
{
|
||||
label: '担当',
|
||||
@@ -225,7 +224,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.proofreadBy,
|
||||
},
|
||||
{
|
||||
@@ -234,7 +232,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.proofreadTime,
|
||||
},
|
||||
{
|
||||
@@ -243,7 +240,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.auditBy,
|
||||
},
|
||||
{
|
||||
@@ -252,7 +248,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.auditTime,
|
||||
},
|
||||
{
|
||||
@@ -261,7 +256,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.approveBy,
|
||||
},
|
||||
{
|
||||
@@ -270,7 +264,6 @@ export const formSchema: FormSchema[] = [
|
||||
component: 'Input',
|
||||
componentProps: { disabled: true, bordered: false },
|
||||
colProps: colHalf,
|
||||
itemProps: { class: 'ps-workflow-item' },
|
||||
ifShow: ({ values }) => !!values.approveTime,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<div class="ps-compile-modal-body">
|
||||
<BasicForm @register="registerForm" />
|
||||
<BasicForm @register="registerForm" name="MesXslMixerPsCompileForm" />
|
||||
</div>
|
||||
</BasicModal>
|
||||
</template>
|
||||
@@ -166,7 +166,13 @@
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
:deep(.ps-workflow-item) {
|
||||
:deep(#MesXslMixerPsCompileForm_compileBy),
|
||||
:deep(#MesXslMixerPsCompileForm_proofreadBy),
|
||||
:deep(#MesXslMixerPsCompileForm_proofreadTime),
|
||||
:deep(#MesXslMixerPsCompileForm_auditBy),
|
||||
:deep(#MesXslMixerPsCompileForm_auditTime),
|
||||
:deep(#MesXslMixerPsCompileForm_approveBy),
|
||||
:deep(#MesXslMixerPsCompileForm_approveTime) {
|
||||
margin-bottom: 8px;
|
||||
|
||||
.ant-form-item-label > label {
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择密炼PS" :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 type { FormSchema } from '/@/components/Table';
|
||||
import { list as mixerPsList, queryById as queryMixerPsById } from '../MesXslMixerPsCompile.api';
|
||||
import { columns as mixerPsColumns } from '../MesXslMixerPsCompile.data';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const COMPILE_STATUS = 'compile';
|
||||
|
||||
const selectSearchSchema: FormSchema[] = [
|
||||
{ label: 'PS编码', field: 'psCode', component: 'JInput', colProps: { span: 8 } },
|
||||
{ label: '标题', field: 'title', component: 'JInput', colProps: { span: 8 } },
|
||||
];
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: mixerPsList,
|
||||
columns: mixerPsColumns.slice(0, 7),
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: selectSearchSchema,
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
beforeFetch: (params) => ({
|
||||
...params,
|
||||
status: COMPILE_STATUS,
|
||||
}),
|
||||
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 psId = data?.psCompileId as string | undefined;
|
||||
if (psId) {
|
||||
setSelectedRowKeys?.([psId]);
|
||||
try {
|
||||
const raw = await queryMixerPsById({ id: psId });
|
||||
const row = (raw as Recordable)?.psCode != null ? raw : (raw as Recordable)?.result;
|
||||
if (row) {
|
||||
selectedRow.value = row;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
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 queryMixerPsById({ id: keys[0] });
|
||||
row = (raw as Recordable)?.psCode != null ? raw : (raw as Recordable)?.result;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条编制状态的密炼PS');
|
||||
return;
|
||||
}
|
||||
if (row.status && row.status !== COMPILE_STATUS) {
|
||||
createMessage.warning('仅可选择编制状态的密炼PS');
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
psCompileId: row.id,
|
||||
psCode: row.psCode || '',
|
||||
title: row.title || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user