This commit is contained in:
2026-05-15 17:35:21 +08:00
134 changed files with 8988 additions and 115 deletions

View File

@@ -0,0 +1,10 @@
<template>
<MesXslProcessOperationList />
</template>
<script lang="ts" setup>
/**
* 兼容旧菜单 componentmes/processoperation/indexV3.9.2_53 历史配置),实际页面在 xslmes。
*/
import MesXslProcessOperationList from '/@/views/xslmes/mesXslProcessOperation/MesXslProcessOperationList.vue';
</script>

View File

@@ -0,0 +1,58 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslEquipmentCategory/list',
checkCategoryName = '/xslmes/mesXslEquipmentCategory/checkCategoryName',
save = '/xslmes/mesXslEquipmentCategory/add',
edit = '/xslmes/mesXslEquipmentCategory/edit',
deleteOne = '/xslmes/mesXslEquipmentCategory/delete',
deleteBatch = '/xslmes/mesXslEquipmentCategory/deleteBatch',
importExcel = '/xslmes/mesXslEquipmentCategory/importExcel',
exportXls = '/xslmes/mesXslEquipmentCategory/exportXls',
queryById = '/xslmes/mesXslEquipmentCategory/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: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const checkCategoryName = (params: { categoryName: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkCategoryName, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
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 });
};

View File

@@ -0,0 +1,87 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkCategoryName } from './MesXslEquipmentCategory.api';
export const columns: BasicColumn[] = [
{ title: '类别名称', align: 'center', dataIndex: 'categoryName', width: 160 },
{ title: '工序名称', align: 'center', dataIndex: 'processOperationName', width: 180 },
{ title: '点检区分', align: 'center', dataIndex: 'inspectDistinct_dictText', width: 100 },
{ title: '保养区分', align: 'center', dataIndex: 'maintainDistinct_dictText', width: 100 },
{ 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),
},
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
];
export const searchFormSchema: FormSchema[] = [
{ label: '类别名称', field: 'categoryName', component: 'Input', colProps: { span: 6 } },
{ label: '工序名称', field: 'processOperationName', component: 'Input', colProps: { span: 6 } },
{
label: '点检区分',
field: 'inspectDistinct',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_equipment_inspect_distinct' },
colProps: { span: 6 },
},
{
label: '保养区分',
field: 'maintainDistinct',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_equipment_maintain_distinct' },
colProps: { span: 6 },
},
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '类别名称',
field: 'categoryName',
component: 'Input',
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入类别名称' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkCategoryName({ categoryName: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '该类别名称已存在';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{ label: '', field: 'processOperationId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择所属工序' }] },
{
label: '所属工序',
field: 'processOperationName',
component: 'Input',
slot: 'processOperationPicker',
},
{
label: '点检区分',
field: 'inspectDistinct',
required: true,
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_equipment_inspect_distinct', placeholder: '请选择' },
},
{
label: '保养区分',
field: 'maintainDistinct',
required: true,
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_equipment_maintain_distinct', placeholder: '请选择' },
},
];

View File

@@ -0,0 +1,127 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_xsl_equipment_category:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_equipment_category:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_equipment_category: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_category: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_category:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslEquipmentCategoryModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslEquipmentCategory" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslEquipmentCategoryModal from './components/MesXslEquipmentCategoryModal.vue';
import { columns, searchFormSchema } from './MesXslEquipmentCategory.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslEquipmentCategory.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '设备类别',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 120,
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_equipment_category:delete',
},
];
}
</script>

View File

@@ -0,0 +1,76 @@
<template>
<BasicModal @register="registerModal" :title="title" width="640" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
<BasicForm @register="registerForm">
<template #processOperationPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择工序" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openProcessSelect">选择工序</a-button>
<a-button v-if="model.processOperationId && !isDetail" @click="clearProcess">清除</a-button>
</a-input-group>
</template>
</BasicForm>
<MesXslProcessOperationSelectModal @register="registerProcessModal" @select="onProcessSelect" />
</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 { formSchema } from '../MesXslEquipmentCategory.data';
import { saveOrUpdate } from '../MesXslEquipmentCategory.api';
import MesXslProcessOperationSelectModal from './MesXslProcessOperationSelectModal.vue';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerProcessModal, { openModal: openProcessModal }] = useModal();
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
setProps({ disabled: !data?.showFooter });
});
const title = computed(() =>
!unref(isUpdate) ? '新增设备类别' : unref(isDetail) ? '设备类别详情' : '编辑设备类别',
);
function openProcessSelect() {
const vals = getFieldsValue();
openProcessModal(true, { processOperationId: vals.processOperationId });
}
function clearProcess() {
setFieldsValue({ processOperationId: '', processOperationName: '' });
}
function onProcessSelect(payload: { processOperationId?: string; processOperationName?: string }) {
setFieldsValue({
processOperationId: payload.processOperationId || '',
processOperationName: payload.processOperationName || '',
});
}
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,99 @@
<template>
<BasicModal v-bind="$attrs" title="选择工序" :width="960" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { list, queryById } from '/@/views/xslmes/mesXslProcessOperation/MesXslProcessOperation.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, setProps, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] =
useTable({
api: list,
columns: [
{ title: '工序编码', dataIndex: 'operationCode', width: 140 },
{ title: '工序名称', dataIndex: 'operationName', width: 200 },
],
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 90,
schemas: [
{ label: '工序编码', field: 'operationCode', component: 'Input', colProps: { span: 8 } },
{ label: '工序名称', field: 'operationName', 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?.();
setProps({
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: handleSelectionChange,
},
clickToRowSelect: true,
});
setModalProps({ confirmLoading: false });
const pid = data?.processOperationId as string | undefined;
if (pid) {
setSelectedRowKeys?.([pid]);
try {
const raw = await queryById({ id: pid });
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', { processOperationId: '', processOperationName: '' });
closeModal();
return;
}
emit('select', {
processOperationId: row.id,
processOperationName: row.operationName || '',
});
closeModal();
}
</script>

View File

@@ -0,0 +1,58 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslEquipmentPart/list',
checkPartCode = '/xslmes/mesXslEquipmentPart/checkPartCode',
save = '/xslmes/mesXslEquipmentPart/add',
edit = '/xslmes/mesXslEquipmentPart/edit',
deleteOne = '/xslmes/mesXslEquipmentPart/delete',
deleteBatch = '/xslmes/mesXslEquipmentPart/deleteBatch',
importExcel = '/xslmes/mesXslEquipmentPart/importExcel',
exportXls = '/xslmes/mesXslEquipmentPart/exportXls',
queryById = '/xslmes/mesXslEquipmentPart/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: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const checkPartCode = (params: { partCode: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkPartCode, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
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 });
};

View File

@@ -0,0 +1,84 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkPartCode } from './MesXslEquipmentPart.api';
export const columns: BasicColumn[] = [
{ title: '部位代码', align: 'center', dataIndex: 'partCode', width: 120 },
{ title: '类别名称', align: 'center', dataIndex: 'equipmentCategoryName', width: 160 },
{ title: '部位名称', align: 'center', dataIndex: 'partName', width: 140 },
{ title: '部位描述', align: 'center', dataIndex: 'partDescription', width: 200, ellipsis: true },
{ title: '是否启用', align: 'center', dataIndex: 'enableStatus_dictText', width: 100 },
{ 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),
},
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
];
export const searchFormSchema: FormSchema[] = [
{ label: '部位代码', field: 'partCode', component: 'Input', colProps: { span: 6 } },
{ label: '类别名称', field: 'equipmentCategoryName', component: 'Input', colProps: { span: 6 } },
{ label: '部位名称', field: 'partName', component: 'Input', colProps: { span: 6 } },
{
label: '是否启用',
field: 'enableStatus',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_unit_status' },
colProps: { span: 6 },
},
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '部位代码',
field: 'partCode',
component: 'Input',
componentProps: { placeholder: '同租户下部位代码全局唯一(未删除数据中不可重复)' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入部位代码' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkPartCode({ partCode: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '部位代码不能重复';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{ label: '', field: 'equipmentCategoryId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择所属设备类别' }] },
{
label: '所属类别',
field: 'equipmentCategoryName',
component: 'Input',
slot: 'equipmentCategoryPicker',
},
{
label: '部位名称',
field: 'partName',
required: true,
component: 'Input',
componentProps: { placeholder: '请输入部位名称' },
},
{ label: '部位描述', field: 'partDescription', component: 'InputTextArea', componentProps: { rows: 3 } },
{
label: '是否启用',
field: 'enableStatus',
required: true,
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_unit_status', placeholder: '请选择' },
defaultValue: '0',
},
];

View File

@@ -0,0 +1,127 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_xsl_equipment_part:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_equipment_part:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_equipment_part: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_part: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_part:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslEquipmentPartModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslEquipmentPart" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslEquipmentPartModal from './components/MesXslEquipmentPartModal.vue';
import { columns, searchFormSchema } from './MesXslEquipmentPart.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslEquipmentPart.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '设备部位',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 120,
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_equipment_part:delete',
},
];
}
</script>

View File

@@ -0,0 +1,76 @@
<template>
<BasicModal @register="registerModal" :title="title" width="720" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
<BasicForm @register="registerForm">
<template #equipmentCategoryPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择设备类别" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openCategorySelect">选择类别</a-button>
<a-button v-if="model.equipmentCategoryId && !isDetail" @click="clearCategory">清除</a-button>
</a-input-group>
</template>
</BasicForm>
<MesXslEquipmentCategorySelectModal @register="registerCategoryModal" @select="onCategorySelect" />
</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 { formSchema } from '../MesXslEquipmentPart.data';
import { saveOrUpdate } from '../MesXslEquipmentPart.api';
import MesXslEquipmentCategorySelectModal from '/@/views/xslmes/mesXslEquipmentType/components/MesXslEquipmentCategorySelectModal.vue';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
setProps({ disabled: !data?.showFooter });
});
const title = computed(() =>
!unref(isUpdate) ? '新增设备部位' : unref(isDetail) ? '设备部位详情' : '编辑设备部位',
);
function openCategorySelect() {
const vals = getFieldsValue();
openCategoryModal(true, { equipmentCategoryId: vals.equipmentCategoryId });
}
function clearCategory() {
setFieldsValue({ equipmentCategoryId: '', equipmentCategoryName: '' });
}
function onCategorySelect(payload: { equipmentCategoryId?: string; equipmentCategoryName?: string }) {
setFieldsValue({
equipmentCategoryId: payload.equipmentCategoryId || '',
equipmentCategoryName: payload.equipmentCategoryName || '',
});
}
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,58 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslEquipmentSubPart/list',
checkSubPartCode = '/xslmes/mesXslEquipmentSubPart/checkSubPartCode',
save = '/xslmes/mesXslEquipmentSubPart/add',
edit = '/xslmes/mesXslEquipmentSubPart/edit',
deleteOne = '/xslmes/mesXslEquipmentSubPart/delete',
deleteBatch = '/xslmes/mesXslEquipmentSubPart/deleteBatch',
importExcel = '/xslmes/mesXslEquipmentSubPart/importExcel',
exportXls = '/xslmes/mesXslEquipmentSubPart/exportXls',
queryById = '/xslmes/mesXslEquipmentSubPart/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: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const checkSubPartCode = (params: { subPartCode: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkSubPartCode, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
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 });
};

View File

@@ -0,0 +1,110 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkSubPartCode } from './MesXslEquipmentSubPart.api';
export const columns: BasicColumn[] = [
{ title: '小部位代码', align: 'center', dataIndex: 'subPartCode', width: 120 },
{ title: '类别名称', align: 'center', dataIndex: 'equipmentCategoryName', width: 140 },
{ title: '大部位名称', align: 'center', dataIndex: 'equipmentPartName', width: 140 },
{ title: '小部位名称', align: 'center', dataIndex: 'subPartName', width: 140 },
{ title: '部位描述', align: 'center', dataIndex: 'subPartDescription', width: 200, ellipsis: true },
{ title: '是否启用', align: 'center', dataIndex: 'enableStatus_dictText', width: 100 },
{ 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),
},
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
];
export const searchFormSchema: FormSchema[] = [
{ label: '小部位代码', field: 'subPartCode', component: 'Input', colProps: { span: 6 } },
{ label: '类别名称', field: 'equipmentCategoryName', component: 'Input', colProps: { span: 6 } },
{ label: '大部位名称', field: 'equipmentPartName', component: 'Input', colProps: { span: 6 } },
{ label: '小部位名称', field: 'subPartName', component: 'Input', colProps: { span: 6 } },
{
label: '是否启用',
field: 'enableStatus',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_unit_status' },
colProps: { span: 6 },
},
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '小部位代码',
field: 'subPartCode',
component: 'Input',
componentProps: { placeholder: '同租户下小部位代码全局唯一(未删除数据中不可重复)' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入小部位代码' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkSubPartCode({ subPartCode: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '小部位代码不能重复';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{
label: '',
field: 'equipmentCategoryId',
component: 'Input',
show: false,
dynamicRules: () => [{ required: true, message: '请选择所属设备类别' }],
},
{
label: '所属类别',
field: 'equipmentCategoryName',
component: 'Input',
slot: 'equipmentCategoryPicker',
},
{
label: '',
field: 'equipmentPartId',
component: 'Input',
show: false,
dynamicRules: () => [{ required: true, message: '请选择所属设备大部位' }],
},
{
label: '所属大部位',
field: 'equipmentPartName',
component: 'Input',
slot: 'equipmentPartPicker',
},
{
label: '小部位名称',
field: 'subPartName',
required: true,
component: 'Input',
componentProps: { placeholder: '请输入小部位名称' },
},
{
label: '部位描述',
field: 'subPartDescription',
component: 'InputTextArea',
componentProps: { rows: 3 },
},
{
label: '是否启用',
field: 'enableStatus',
required: true,
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_unit_status', placeholder: '请选择' },
defaultValue: '0',
},
];

View File

@@ -0,0 +1,127 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_xsl_equipment_sub_part:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_equipment_sub_part:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_equipment_sub_part: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_sub_part: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_sub_part:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslEquipmentSubPartModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslEquipmentSubPart" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslEquipmentSubPartModal from './components/MesXslEquipmentSubPartModal.vue';
import { columns, searchFormSchema } from './MesXslEquipmentSubPart.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslEquipmentSubPart.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '设备小部位',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 120,
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_equipment_sub_part:delete',
},
];
}
</script>

View File

@@ -0,0 +1,110 @@
<template>
<BasicModal v-bind="$attrs" title="选择设备大部位" :width="960" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { list, queryById } from '/@/views/xslmes/mesXslEquipmentPart/MesXslEquipmentPart.api';
const emit = defineEmits(['register', 'select']);
const selectedRow = ref<Recordable | null>(null);
const filterCategoryId = ref('');
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
selectedRow.value = rows?.[0] ?? null;
}
function fetchPartPage(params: Recordable) {
const p = { ...params };
if (filterCategoryId.value) {
p.equipmentCategoryId = filterCategoryId.value;
}
return list(p);
}
const [registerTable, { reload, setProps, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] =
useTable({
api: fetchPartPage,
columns: [
{ title: '部位代码', dataIndex: 'partCode', width: 120 },
{ title: '部位名称', dataIndex: 'partName', width: 160 },
{ title: '类别名称', dataIndex: 'equipmentCategoryName', width: 160 },
],
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 90,
schemas: [
{ label: '部位代码', field: 'partCode', component: 'Input', colProps: { span: 8 } },
{ label: '部位名称', field: 'partName', 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) => {
filterCategoryId.value = data?.equipmentCategoryId ? String(data.equipmentCategoryId) : '';
selectedRow.value = null;
clearSelectedRowKeys?.();
setProps({
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: handleSelectionChange,
},
clickToRowSelect: true,
});
setModalProps({ confirmLoading: false });
const pid = data?.equipmentPartId as string | undefined;
if (pid) {
setSelectedRowKeys?.([pid]);
try {
const raw = await queryById({ id: pid });
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', { equipmentPartId: '', equipmentPartName: '' });
closeModal();
return;
}
emit('select', {
equipmentPartId: row.id,
equipmentPartName: row.partName || '',
});
closeModal();
}
</script>

View File

@@ -0,0 +1,113 @@
<template>
<BasicModal @register="registerModal" :title="title" width="720" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
<BasicForm @register="registerForm">
<template #equipmentCategoryPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择设备类别" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openCategorySelect">选择类别</a-button>
<a-button v-if="model.equipmentCategoryId && !isDetail" @click="clearCategory">清除</a-button>
</a-input-group>
</template>
<template #equipmentPartPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择设备大部位" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openPartSelect">选择大部位</a-button>
<a-button v-if="model.equipmentPartId && !isDetail" @click="clearPart">清除</a-button>
</a-input-group>
</template>
</BasicForm>
<MesXslEquipmentCategorySelectModal @register="registerCategoryModal" @select="onCategorySelect" />
<MesXslEquipmentPartSelectModal @register="registerPartModal" @select="onPartSelect" />
</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 { useMessage } from '/@/hooks/web/useMessage';
import { formSchema } from '../MesXslEquipmentSubPart.data';
import { saveOrUpdate } from '../MesXslEquipmentSubPart.api';
import MesXslEquipmentCategorySelectModal from '/@/views/xslmes/mesXslEquipmentType/components/MesXslEquipmentCategorySelectModal.vue';
import MesXslEquipmentPartSelectModal from './MesXslEquipmentPartSelectModal.vue';
const emit = defineEmits(['register', 'success']);
const { createMessage } = useMessage();
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
const [registerPartModal, { openModal: openPartModal }] = useModal();
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
setProps({ disabled: !data?.showFooter });
});
const title = computed(() =>
!unref(isUpdate) ? '新增设备小部位' : unref(isDetail) ? '设备小部位详情' : '编辑设备小部位',
);
function openCategorySelect() {
const vals = getFieldsValue();
openCategoryModal(true, { equipmentCategoryId: vals.equipmentCategoryId });
}
function clearCategory() {
setFieldsValue({ equipmentCategoryId: '', equipmentCategoryName: '', equipmentPartId: '', equipmentPartName: '' });
}
function onCategorySelect(payload: { equipmentCategoryId?: string; equipmentCategoryName?: string }) {
setFieldsValue({
equipmentCategoryId: payload.equipmentCategoryId || '',
equipmentCategoryName: payload.equipmentCategoryName || '',
equipmentPartId: '',
equipmentPartName: '',
});
}
function openPartSelect() {
const vals = getFieldsValue();
if (!vals.equipmentCategoryId) {
createMessage.warning('请先选择所属设备类别');
return;
}
openPartModal(true, {
equipmentCategoryId: vals.equipmentCategoryId,
equipmentPartId: vals.equipmentPartId,
});
}
function clearPart() {
setFieldsValue({ equipmentPartId: '', equipmentPartName: '' });
}
function onPartSelect(payload: { equipmentPartId?: string; equipmentPartName?: string }) {
setFieldsValue({
equipmentPartId: payload.equipmentPartId || '',
equipmentPartName: payload.equipmentPartName || '',
});
}
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,58 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslEquipmentType/list',
checkTypeName = '/xslmes/mesXslEquipmentType/checkTypeName',
save = '/xslmes/mesXslEquipmentType/add',
edit = '/xslmes/mesXslEquipmentType/edit',
deleteOne = '/xslmes/mesXslEquipmentType/delete',
deleteBatch = '/xslmes/mesXslEquipmentType/deleteBatch',
importExcel = '/xslmes/mesXslEquipmentType/importExcel',
exportXls = '/xslmes/mesXslEquipmentType/exportXls',
queryById = '/xslmes/mesXslEquipmentType/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: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const checkTypeName = (params: { typeName: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkTypeName, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
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 });
};

View File

@@ -0,0 +1,66 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkTypeName } from './MesXslEquipmentType.api';
export const columns: BasicColumn[] = [
{ title: '类型名称', align: 'center', dataIndex: 'typeName', width: 160 },
{ title: '工序名称', align: 'center', dataIndex: 'processOperationName', width: 180 },
{ title: '类别名称', align: 'center', dataIndex: 'equipmentCategoryName', width: 160 },
{ 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),
},
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
];
export const searchFormSchema: FormSchema[] = [
{ label: '类型名称', field: 'typeName', component: 'Input', colProps: { span: 6 } },
{ label: '工序名称', field: 'processOperationName', component: 'Input', colProps: { span: 6 } },
{ label: '类别名称', field: 'equipmentCategoryName', component: 'Input', colProps: { span: 6 } },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '类型名称',
field: 'typeName',
component: 'Input',
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入类型名称' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkTypeName({ typeName: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '该类型名称已存在';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{ label: '', field: 'processOperationId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择所属工序' }] },
{
label: '所属工序',
field: 'processOperationName',
component: 'Input',
slot: 'processOperationPicker',
},
{ label: '', field: 'equipmentCategoryId', component: 'Input', show: false, dynamicRules: () => [{ required: true, message: '请选择所属设备类别' }] },
{
label: '所属类别',
field: 'equipmentCategoryName',
component: 'Input',
slot: 'equipmentCategoryPicker',
},
];

View File

@@ -0,0 +1,127 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_xsl_equipment_type:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_equipment_type:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_equipment_type: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_type: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_type:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslEquipmentTypeModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslEquipmentType" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslEquipmentTypeModal from './components/MesXslEquipmentTypeModal.vue';
import { columns, searchFormSchema } from './MesXslEquipmentType.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslEquipmentType.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '设备类型',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 120,
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_equipment_type:delete',
},
];
}
</script>

View File

@@ -0,0 +1,99 @@
<template>
<BasicModal v-bind="$attrs" title="选择设备类别" :width="960" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { list, queryById } from '/@/views/xslmes/mesXslEquipmentCategory/MesXslEquipmentCategory.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, setProps, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] =
useTable({
api: list,
columns: [
{ title: '类别名称', dataIndex: 'categoryName', width: 160 },
{ title: '工序名称', dataIndex: 'processOperationName', width: 180 },
],
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 90,
schemas: [
{ label: '类别名称', field: 'categoryName', component: 'Input', colProps: { span: 8 } },
{ label: '工序名称', field: 'processOperationName', component: 'Input', colProps: { span: 8 } },
],
},
pagination: { pageSize: 10 },
canResize: false,
showIndexColumn: false,
immediate: true,
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: handleSelectionChange,
},
clickToRowSelect: true,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
selectedRow.value = null;
clearSelectedRowKeys?.();
setProps({
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: handleSelectionChange,
},
clickToRowSelect: true,
});
setModalProps({ confirmLoading: false });
const cid = data?.equipmentCategoryId as string | undefined;
if (cid) {
setSelectedRowKeys?.([cid]);
try {
const raw = await queryById({ id: cid });
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', { equipmentCategoryId: '', equipmentCategoryName: '' });
closeModal();
return;
}
emit('select', {
equipmentCategoryId: row.id,
equipmentCategoryName: row.categoryName || '',
});
closeModal();
}
</script>

View File

@@ -0,0 +1,102 @@
<template>
<BasicModal @register="registerModal" :title="title" width="720" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
<BasicForm @register="registerForm">
<template #processOperationPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择工序" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openProcessSelect">选择工序</a-button>
<a-button v-if="model.processOperationId && !isDetail" @click="clearProcess">清除</a-button>
</a-input-group>
</template>
<template #equipmentCategoryPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择设备类别" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openCategorySelect">选择类别</a-button>
<a-button v-if="model.equipmentCategoryId && !isDetail" @click="clearCategory">清除</a-button>
</a-input-group>
</template>
</BasicForm>
<MesXslProcessOperationSelectModal @register="registerProcessModal" @select="onProcessSelect" />
<MesXslEquipmentCategorySelectModal @register="registerCategoryModal" @select="onCategorySelect" />
</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 { formSchema } from '../MesXslEquipmentType.data';
import { saveOrUpdate } from '../MesXslEquipmentType.api';
import MesXslProcessOperationSelectModal from '/@/views/xslmes/mesXslEquipmentCategory/components/MesXslProcessOperationSelectModal.vue';
import MesXslEquipmentCategorySelectModal from './MesXslEquipmentCategorySelectModal.vue';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerProcessModal, { openModal: openProcessModal }] = useModal();
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
setProps({ disabled: !data?.showFooter });
});
const title = computed(() =>
!unref(isUpdate) ? '新增设备类型' : unref(isDetail) ? '设备类型详情' : '编辑设备类型',
);
function openProcessSelect() {
const vals = getFieldsValue();
openProcessModal(true, { processOperationId: vals.processOperationId });
}
function clearProcess() {
setFieldsValue({ processOperationId: '', processOperationName: '' });
}
function onProcessSelect(payload: { processOperationId?: string; processOperationName?: string }) {
setFieldsValue({
processOperationId: payload.processOperationId || '',
processOperationName: payload.processOperationName || '',
});
}
function openCategorySelect() {
const vals = getFieldsValue();
openCategoryModal(true, { equipmentCategoryId: vals.equipmentCategoryId });
}
function clearCategory() {
setFieldsValue({ equipmentCategoryId: '', equipmentCategoryName: '' });
}
function onCategorySelect(payload: { equipmentCategoryId?: string; equipmentCategoryName?: string }) {
setFieldsValue({
equipmentCategoryId: payload.equipmentCategoryId || '',
equipmentCategoryName: payload.equipmentCategoryName || '',
});
}
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,58 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslManufacturer/list',
checkManufacturerName = '/xslmes/mesXslManufacturer/checkManufacturerName',
save = '/xslmes/mesXslManufacturer/add',
edit = '/xslmes/mesXslManufacturer/edit',
deleteOne = '/xslmes/mesXslManufacturer/delete',
deleteBatch = '/xslmes/mesXslManufacturer/deleteBatch',
importExcel = '/xslmes/mesXslManufacturer/importExcel',
exportXls = '/xslmes/mesXslManufacturer/exportXls',
queryById = '/xslmes/mesXslManufacturer/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: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const checkManufacturerName = (params: { manufacturerName: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkManufacturerName, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
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 });
};

View File

@@ -0,0 +1,79 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkManufacturerName } from './MesXslManufacturer.api';
export const columns: BasicColumn[] = [
{ title: '厂家类别', align: 'center', dataIndex: 'manufacturerCategory_dictText', width: 120 },
{ title: '厂家名称', align: 'center', dataIndex: 'manufacturerName', width: 200 },
{ title: '是否有效', align: 'center', dataIndex: 'validStatus_dictText', width: 100 },
{ 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),
},
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
];
export const searchFormSchema: FormSchema[] = [
{
label: '厂家类别',
field: 'manufacturerCategory',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_manufacturer_category' },
colProps: { span: 8 },
},
{ label: '厂家名称', field: 'manufacturerName', component: 'Input', colProps: { span: 8 } },
{
label: '是否有效',
field: 'validStatus',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_manufacturer_valid' },
colProps: { span: 8 },
},
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '厂家类别',
field: 'manufacturerCategory',
required: true,
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_manufacturer_category', placeholder: '请选择' },
},
{
label: '厂家名称',
field: 'manufacturerName',
component: 'Input',
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入厂家名称' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkManufacturerName({ manufacturerName: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '厂家名称不能重复';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{
label: '是否有效',
field: 'validStatus',
required: true,
defaultValue: '0',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_manufacturer_valid', placeholder: '请选择' },
},
];

View File

@@ -0,0 +1,127 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_xsl_manufacturer:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_manufacturer:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_manufacturer: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_manufacturer: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_manufacturer:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslManufacturerModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslManufacturer" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslManufacturerModal from './components/MesXslManufacturerModal.vue';
import { columns, searchFormSchema } from './MesXslManufacturer.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslManufacturer.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_manufacturer:delete',
},
];
}
</script>

View File

@@ -0,0 +1,49 @@
<template>
<BasicModal @register="registerModal" :title="title" width="640" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from '../MesXslManufacturer.data';
import { saveOrUpdate } from '../MesXslManufacturer.api';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
else await setFieldsValue({ validStatus: '0' });
setProps({ disabled: !data?.showFooter });
});
const title = computed(() =>
!unref(isUpdate) ? '新增厂家信息' : unref(isDetail) ? '厂家信息详情' : '编辑厂家信息',
);
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,59 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslProcessOperation/list',
checkOperationCode = '/xslmes/mesXslProcessOperation/checkOperationCode',
save = '/xslmes/mesXslProcessOperation/add',
edit = '/xslmes/mesXslProcessOperation/edit',
deleteOne = '/xslmes/mesXslProcessOperation/delete',
deleteBatch = '/xslmes/mesXslProcessOperation/deleteBatch',
importExcel = '/xslmes/mesXslProcessOperation/importExcel',
exportXls = '/xslmes/mesXslProcessOperation/exportXls',
queryById = '/xslmes/mesXslProcessOperation/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: { id: string }) => defHttp.get({ url: Api.queryById, params });
/** 工序编码唯一性校验(仅未删除数据;同租户;编辑传 dataId */
export const checkOperationCode = (params: { operationCode: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkOperationCode, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
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 });
};

View File

@@ -0,0 +1,66 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkOperationCode } from './MesXslProcessOperation.api';
export const columns: BasicColumn[] = [
{ title: '工序编码', align: 'center', dataIndex: 'operationCode', width: 140 },
{ title: '工序名称', align: 'center', dataIndex: 'operationName', width: 180 },
{ 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),
},
{ title: '修改人', align: 'center', dataIndex: 'updateBy', width: 100 },
{
title: '修改时间',
align: 'center',
dataIndex: 'updateTime',
width: 165,
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
},
{ title: '备注', align: 'center', dataIndex: 'remark', width: 200, ellipsis: true },
];
export const searchFormSchema: FormSchema[] = [
{ label: '工序编码', field: 'operationCode', component: 'Input', colProps: { span: 6 } },
{ label: '工序名称', field: 'operationName', component: 'Input', colProps: { span: 6 } },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '工序编码',
field: 'operationCode',
component: 'Input',
componentProps: { placeholder: '同租户内唯一,未删除数据中不可重复' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入工序编码' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkOperationCode({ operationCode: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '该工序编码已存在';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{
label: '工序名称',
field: 'operationName',
component: 'Input',
required: true,
componentProps: { placeholder: '请输入工序名称' },
},
{ label: '备注', field: 'remark', component: 'InputTextArea', componentProps: { rows: 3 } },
];

View File

@@ -0,0 +1,127 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_process_operation:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_process_operation:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_process_operation: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_process_operation: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_process_operation:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslProcessOperationModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslProcessOperation" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslProcessOperationModal from './components/MesXslProcessOperationModal.vue';
import { columns, searchFormSchema } from './MesXslProcessOperation.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslProcessOperation.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '工序管理',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 120,
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_process_operation:delete',
},
];
}
</script>

View File

@@ -0,0 +1,48 @@
<template>
<BasicModal @register="registerModal" :title="title" width="50%" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from '../MesXslProcessOperation.data';
import { saveOrUpdate } from '../MesXslProcessOperation.api';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
setProps({ disabled: !data?.showFooter });
});
const title = computed(() =>
!unref(isUpdate) ? '新增工序' : unref(isDetail) ? '工序详情' : '编辑工序',
);
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,58 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslSparePart/list',
checkSparePartName = '/xslmes/mesXslSparePart/checkSparePartName',
save = '/xslmes/mesXslSparePart/add',
edit = '/xslmes/mesXslSparePart/edit',
deleteOne = '/xslmes/mesXslSparePart/delete',
deleteBatch = '/xslmes/mesXslSparePart/deleteBatch',
importExcel = '/xslmes/mesXslSparePart/importExcel',
exportXls = '/xslmes/mesXslSparePart/exportXls',
queryById = '/xslmes/mesXslSparePart/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: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const checkSparePartName = (params: { sparePartName: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkSparePartName, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
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 });
};

View File

@@ -0,0 +1,101 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkSparePartName } from './MesXslSparePart.api';
export const columns: BasicColumn[] = [
{ title: '备品件名称', align: 'center', dataIndex: 'sparePartName', width: 160 },
{ title: '类别名称', align: 'center', dataIndex: 'sparePartsCategoryName', width: 140 },
{ title: '规格型号', align: 'center', dataIndex: 'specModel', width: 140, ellipsis: true },
{ title: '最大库存', align: 'center', dataIndex: 'maxStock', width: 110 },
{ title: '最小库存', align: 'center', dataIndex: 'minStock', width: 110 },
{ title: '单位', align: 'center', dataIndex: 'unitName', 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),
},
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
];
export const searchFormSchema: FormSchema[] = [
{ label: '备品件名称', field: 'sparePartName', component: 'Input', colProps: { span: 6 } },
{ label: '类别名称', field: 'sparePartsCategoryName', component: 'Input', colProps: { span: 6 } },
{ label: '规格型号', field: 'specModel', component: 'Input', colProps: { span: 6 } },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '备品件名称',
field: 'sparePartName',
component: 'Input',
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入备品件名称' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkSparePartName({ sparePartName: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '备品件名称不能重复';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{
label: '',
field: 'sparePartsCategoryId',
component: 'Input',
show: false,
dynamicRules: () => [{ required: true, message: '请选择所属备品件类别' }],
},
{
label: '所属类别',
field: 'sparePartsCategoryName',
component: 'Input',
slot: 'sparePartsCategoryPicker',
},
{
label: '规格型号',
field: 'specModel',
component: 'Input',
componentProps: { placeholder: '可选' },
},
{
label: '最大库存',
field: 'maxStock',
required: true,
component: 'InputNumber',
componentProps: { min: 0, precision: 4, style: { width: '100%' } },
},
{
label: '最小库存',
field: 'minStock',
required: true,
component: 'InputNumber',
componentProps: { min: 0, precision: 4, style: { width: '100%' } },
},
{
label: '',
field: 'unitId',
component: 'Input',
show: false,
dynamicRules: () => [{ required: true, message: '请选择单位' }],
},
{
label: '单位',
field: 'unitName',
component: 'Input',
slot: 'unitPicker',
},
];

View File

@@ -0,0 +1,127 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_xsl_spare_part:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_spare_part:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_spare_part: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_spare_part: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_spare_part:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslSparePartModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslSparePart" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslSparePartModal from './components/MesXslSparePartModal.vue';
import { columns, searchFormSchema } from './MesXslSparePart.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslSparePart.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '备品件信息',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 110,
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_spare_part:delete',
},
];
}
</script>

View File

@@ -0,0 +1,105 @@
<template>
<BasicModal @register="registerModal" :title="title" width="720" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
<BasicForm @register="registerForm">
<template #sparePartsCategoryPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择备品件类别" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openCategorySelect">选择类别</a-button>
<a-button v-if="model.sparePartsCategoryId && !isDetail" @click="clearCategory">清除</a-button>
</a-input-group>
</template>
<template #unitPicker="{ 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="openUnitSelect">选择单位</a-button>
<a-button v-if="model.unitId && !isDetail" @click="clearUnit">清除</a-button>
</a-input-group>
</template>
</BasicForm>
<MesXslSparePartsCategorySelectModal @register="registerCategoryModal" @select="onCategorySelect" />
<MesXslUnitSelectModal @register="registerUnitModal" @select="onUnitSelect" />
</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 { formSchema } from '../MesXslSparePart.data';
import { saveOrUpdate } from '../MesXslSparePart.api';
import MesXslSparePartsCategorySelectModal from '/@/views/xslmes/mesXslSparePartsCategory/components/MesXslSparePartsCategorySelectModal.vue';
import MesXslUnitSelectModal from '/@/views/xslmes/mesXslVehicle/components/MesXslUnitSelectModal.vue';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerCategoryModal, { openModal: openCategoryModal }] = useModal();
const [registerUnitModal, { openModal: openUnitModal }] = useModal();
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
else {
await setFieldsValue({ maxStock: 0, minStock: 0 });
}
setProps({ disabled: !data?.showFooter });
});
const title = computed(() =>
!unref(isUpdate) ? '新增备品件信息' : unref(isDetail) ? '备品件信息详情' : '编辑备品件信息',
);
function openCategorySelect() {
const vals = getFieldsValue();
openCategoryModal(true, { sparePartsCategoryId: vals.sparePartsCategoryId });
}
function clearCategory() {
setFieldsValue({ sparePartsCategoryId: '', sparePartsCategoryName: '' });
}
function onCategorySelect(payload: { sparePartsCategoryId?: string; sparePartsCategoryName?: string }) {
setFieldsValue({
sparePartsCategoryId: payload.sparePartsCategoryId || '',
sparePartsCategoryName: payload.sparePartsCategoryName || '',
});
}
function openUnitSelect() {
const vals = getFieldsValue();
openUnitModal(true, { unitId: vals.unitId });
}
function clearUnit() {
setFieldsValue({ unitId: '', unitName: '' });
}
function onUnitSelect(payload: { unitId?: string; unitName?: string }) {
setFieldsValue({
unitId: payload.unitId || '',
unitName: payload.unitName || '',
});
}
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,58 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslSparePartsCategory/list',
checkCategoryName = '/xslmes/mesXslSparePartsCategory/checkCategoryName',
save = '/xslmes/mesXslSparePartsCategory/add',
edit = '/xslmes/mesXslSparePartsCategory/edit',
deleteOne = '/xslmes/mesXslSparePartsCategory/delete',
deleteBatch = '/xslmes/mesXslSparePartsCategory/deleteBatch',
importExcel = '/xslmes/mesXslSparePartsCategory/importExcel',
exportXls = '/xslmes/mesXslSparePartsCategory/exportXls',
queryById = '/xslmes/mesXslSparePartsCategory/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: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const checkCategoryName = (params: { categoryName: string; dataId?: string }) =>
defHttp.get(
{ url: Api.checkCategoryName, params },
{
successMessageMode: 'none',
errorMessageMode: 'none',
},
);
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 });
};

View File

@@ -0,0 +1,56 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkCategoryName } from './MesXslSparePartsCategory.api';
export const columns: BasicColumn[] = [
{ title: '类别名称', align: 'center', dataIndex: 'categoryName', width: 180 },
{ title: '描述', align: 'center', dataIndex: 'categoryDescription', width: 260, ellipsis: true },
{ 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),
},
{ title: '租户ID', align: 'center', dataIndex: 'tenantId', width: 90, defaultHidden: true },
];
export const searchFormSchema: FormSchema[] = [
{ label: '类别名称', field: 'categoryName', component: 'Input', colProps: { span: 8 } },
{ label: '描述', field: 'categoryDescription', component: 'Input', colProps: { span: 8 } },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '类别名称',
field: 'categoryName',
component: 'Input',
componentProps: { placeholder: '同租户内未删除数据中不可重复' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入类别名称' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkCategoryName({ categoryName: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '类别名称不能重复';
return Promise.reject(msg);
}
},
trigger: 'blur',
},
],
},
{
label: '描述',
field: 'categoryDescription',
component: 'InputTextArea',
componentProps: { rows: 4, placeholder: '可选' },
},
];

View File

@@ -0,0 +1,127 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_xsl_spare_parts_category:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_spare_parts_category:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_spare_parts_category: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_spare_parts_category: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_spare_parts_category:edit' },
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslSparePartsCategoryModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslSparePartsCategory" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslSparePartsCategoryModal from './components/MesXslSparePartsCategoryModal.vue';
import { columns, searchFormSchema } from './MesXslSparePartsCategory.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslSparePartsCategory.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_spare_parts_category:delete',
},
];
}
</script>

View File

@@ -0,0 +1,48 @@
<template>
<BasicModal @register="registerModal" :title="title" width="640" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from '../MesXslSparePartsCategory.data';
import { saveOrUpdate } from '../MesXslSparePartsCategory.api';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
labelWidth: 100,
schemas: formSchema,
showActionButtonGroup: false,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
setProps({ disabled: !data?.showFooter });
});
const title = computed(() =>
!unref(isUpdate) ? '新增备品件类别' : unref(isDetail) ? '备品件类别详情' : '编辑备品件类别',
);
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>

View File

@@ -0,0 +1,93 @@
<template>
<BasicModal v-bind="$attrs" title="选择备品件类别" :width="800" @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/mesXslSparePartsCategory/MesXslSparePartsCategory.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, setProps, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] =
useTable({
api: list,
columns: [{ title: '类别名称', dataIndex: 'categoryName', width: 220 }],
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 90,
schemas: [{ label: '类别名称', field: 'categoryName', component: 'Input', colProps: { span: 12 } }],
},
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?.();
setProps({
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: handleSelectionChange,
},
clickToRowSelect: true,
});
setModalProps({ confirmLoading: false });
const cid = data?.sparePartsCategoryId as string | undefined;
if (cid) {
setSelectedRowKeys?.([cid]);
try {
const raw = await queryById({ id: cid });
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', { sparePartsCategoryId: '', sparePartsCategoryName: '' });
closeModal();
return;
}
emit('select', {
sparePartsCategoryId: row.id,
sparePartsCategoryName: row.categoryName || '',
});
closeModal();
}
</script>