胶料小料锁定原因、锁定日志添加
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslRubberSmallLockLog/list',
|
||||
save = '/xslmes/mesXslRubberSmallLockLog/add',
|
||||
edit = '/xslmes/mesXslRubberSmallLockLog/edit',
|
||||
deleteOne = '/xslmes/mesXslRubberSmallLockLog/delete',
|
||||
deleteBatch = '/xslmes/mesXslRubberSmallLockLog/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslRubberSmallLockLog/importExcel',
|
||||
exportXls = '/xslmes/mesXslRubberSmallLockLog/exportXls',
|
||||
queryById = '/xslmes/mesXslRubberSmallLockLog/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 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,110 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '类型', align: 'center', dataIndex: 'barcodeType_dictText', width: 90 },
|
||||
{ title: '条码', align: 'center', dataIndex: 'barcode', width: 140 },
|
||||
{ title: '状态', align: 'center', dataIndex: 'lockType_dictText', width: 90 },
|
||||
{ title: '原因', align: 'center', dataIndex: 'reasonDesc', width: 200, ellipsis: true },
|
||||
{ title: '日期', align: 'center', dataIndex: 'logDate', width: 110 },
|
||||
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
|
||||
{ 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),
|
||||
},
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{
|
||||
label: '类型',
|
||||
field: 'barcodeType',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_rubber_small_lock_barcode_type', placeholder: '请选择类型' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{ label: '条码', field: 'barcode', component: 'Input', colProps: { span: 6 } },
|
||||
{
|
||||
label: '状态',
|
||||
field: 'lockType',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_rubber_small_lock_type', placeholder: '请选择状态' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '日期',
|
||||
field: 'logDate',
|
||||
component: 'DatePicker',
|
||||
componentProps: { valueFormat: 'YYYY-MM-DD', style: { width: '100%' } },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{
|
||||
label: '类型',
|
||||
field: 'barcodeType',
|
||||
component: 'JDictSelectTag',
|
||||
required: true,
|
||||
componentProps: { dictCode: 'xslmes_rubber_small_lock_barcode_type', placeholder: '请选择条码类型' },
|
||||
},
|
||||
{
|
||||
label: '条码',
|
||||
field: 'barcode',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
componentProps: { placeholder: '请输入条码', maxlength: 128 },
|
||||
},
|
||||
{
|
||||
label: '锁定原因',
|
||||
field: 'lockReasonId',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
slot: 'lockReasonSelect',
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'lockType',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_rubber_small_lock_type', disabled: true, placeholder: '选择锁定原因后自动带出' },
|
||||
},
|
||||
{
|
||||
label: '原因',
|
||||
field: 'reasonDesc',
|
||||
component: 'InputTextArea',
|
||||
componentProps: { rows: 2, readonly: true, placeholder: '选择锁定原因后自动带出' },
|
||||
},
|
||||
{
|
||||
label: '日期',
|
||||
field: 'logDate',
|
||||
component: 'DatePicker',
|
||||
required: true,
|
||||
defaultValue: dayjs().format('YYYY-MM-DD'),
|
||||
componentProps: { valueFormat: 'YYYY-MM-DD', style: { width: '100%' } },
|
||||
},
|
||||
{
|
||||
label: '创建人',
|
||||
field: 'createBy',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
ifShow: ({ values }) => !!values?.id,
|
||||
},
|
||||
{
|
||||
label: '修改人',
|
||||
field: 'updateBy',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
ifShow: ({ values }) => !!values?.id,
|
||||
},
|
||||
{
|
||||
label: '修改日期',
|
||||
field: 'updateTime',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
ifShow: ({ values }) => !!values?.id,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_rubber_small_lock_log:add'"
|
||||
@click="handleAdd"
|
||||
preIcon="ant-design:plus-outlined"
|
||||
>
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_rubber_small_lock_log:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_rubber_small_lock_log: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_rubber_small_lock_log: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_rubber_small_lock_log:edit',
|
||||
},
|
||||
]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslRubberSmallLockLogModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslRubberSmallLockLog" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslRubberSmallLockLogModal from './components/MesXslRubberSmallLockLogModal.vue';
|
||||
import { columns, searchFormSchema } from './MesXslRubberSmallLockLog.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslRubberSmallLockLog.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_rubber_small_lock_log:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<BasicModal @register="registerModal" :title="title" width="640px" v-bind="$attrs" destroyOnClose @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm">
|
||||
<template #lockReasonSelect="{ model, field }">
|
||||
<a-select
|
||||
v-model:value="model[field]"
|
||||
:options="reasonOptions"
|
||||
:disabled="isDetail || !model.barcodeType"
|
||||
allow-clear
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
placeholder="请先选择类型,再选择锁定原因"
|
||||
style="width: 100%"
|
||||
@change="(val) => onLockReasonChange(val, model)"
|
||||
/>
|
||||
</template>
|
||||
</BasicForm>
|
||||
</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 '../MesXslRubberSmallLockLog.data';
|
||||
import { saveOrUpdate } from '../MesXslRubberSmallLockLog.api';
|
||||
import { optionsByBarcodeType } from '../../mesXslRubberSmallLockReason/MesXslRubberSmallLockReason.api';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(false);
|
||||
const isDetail = ref(false);
|
||||
const reasonOptions = ref<{ label: string; value: string; lockType?: string; reasonDesc?: string }[]>([]);
|
||||
const reasonMap = ref<Record<string, { lockType?: string; reasonDesc?: string }>>({});
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue, updateSchema }] = useForm({
|
||||
labelWidth: 110,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
|
||||
async function loadReasonOptions(barcodeType?: string, keepReasonId?: string) {
|
||||
reasonOptions.value = [];
|
||||
reasonMap.value = {};
|
||||
if (!barcodeType) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const list = await optionsByBarcodeType({ barcodeType });
|
||||
const rows = Array.isArray(list) ? list : [];
|
||||
reasonOptions.value = rows.map((r: Recordable) => {
|
||||
const label = `${r.reasonCode || ''} ${r.reasonDesc || ''}`.trim();
|
||||
reasonMap.value[r.id] = { lockType: r.lockType, reasonDesc: r.reasonDesc };
|
||||
return { label, value: r.id, lockType: r.lockType, reasonDesc: r.reasonDesc };
|
||||
});
|
||||
if (keepReasonId && reasonMap.value[keepReasonId]) {
|
||||
onLockReasonChange(keepReasonId, getFieldsValue());
|
||||
}
|
||||
} catch {
|
||||
reasonOptions.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
function onLockReasonChange(val: string | undefined, model: Recordable) {
|
||||
if (!val) {
|
||||
model.lockType = undefined;
|
||||
model.reasonDesc = undefined;
|
||||
return;
|
||||
}
|
||||
const row = reasonMap.value[val];
|
||||
if (row) {
|
||||
model.lockType = row.lockType;
|
||||
model.reasonDesc = row.reasonDesc;
|
||||
}
|
||||
}
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
reasonOptions.value = [];
|
||||
reasonMap.value = {};
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.value = !data?.showFooter;
|
||||
if (unref(isUpdate)) {
|
||||
const record = { ...data.record };
|
||||
await setFieldsValue(record);
|
||||
await loadReasonOptions(record.barcodeType, record.lockReasonId);
|
||||
} else {
|
||||
await setFieldsValue({ logDate: dayjs().format('YYYY-MM-DD') });
|
||||
}
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
updateSchema({
|
||||
field: 'barcodeType',
|
||||
componentProps: {
|
||||
dictCode: 'xslmes_rubber_small_lock_barcode_type',
|
||||
placeholder: '请选择条码类型',
|
||||
disabled: !data?.showFooter,
|
||||
onChange: async (val: string) => {
|
||||
await setFieldsValue({ lockReasonId: undefined, lockType: undefined, reasonDesc: undefined });
|
||||
await loadReasonOptions(val);
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
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>
|
||||
@@ -13,6 +13,7 @@ enum Api {
|
||||
importExcel = '/xslmes/mesXslRubberSmallLockReason/importExcel',
|
||||
exportXls = '/xslmes/mesXslRubberSmallLockReason/exportXls',
|
||||
queryById = '/xslmes/mesXslRubberSmallLockReason/queryById',
|
||||
optionsByBarcodeType = '/xslmes/mesXslRubberSmallLockReason/optionsByBarcodeType',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
@@ -24,6 +25,9 @@ export const queryById = (params: { id: string }) => defHttp.get({ url: Api.quer
|
||||
|
||||
export const fetchNextReasonCode = () => defHttp.get({ url: Api.nextReasonCode }, { successMessageMode: 'none' });
|
||||
|
||||
export const optionsByBarcodeType = (params: { barcodeType: string }) =>
|
||||
defHttp.get({ url: Api.optionsByBarcodeType, params }, { successMessageMode: 'none' });
|
||||
|
||||
export const deleteOne = (params, handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
|
||||
@@ -4,6 +4,7 @@ export const columns: BasicColumn[] = [
|
||||
{ title: '编号', align: 'center', dataIndex: 'reasonCode', width: 100 },
|
||||
{ title: '类型', align: 'center', dataIndex: 'lockType_dictText', width: 100 },
|
||||
{ title: '条码类型', align: 'center', dataIndex: 'barcodeType_dictText', width: 100 },
|
||||
{ title: '原因', align: 'center', dataIndex: 'reasonDesc', width: 220, ellipsis: true },
|
||||
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
|
||||
{
|
||||
title: '创建日期',
|
||||
@@ -16,6 +17,7 @@ export const columns: BasicColumn[] = [
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '编号', field: 'reasonCode', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '原因', field: 'reasonDesc', component: 'Input', colProps: { span: 6 } },
|
||||
{
|
||||
label: '类型',
|
||||
field: 'lockType',
|
||||
@@ -54,6 +56,14 @@ export const formSchema: FormSchema[] = [
|
||||
required: true,
|
||||
componentProps: { dictCode: 'xslmes_rubber_small_lock_barcode_type', placeholder: '请选择条码类型' },
|
||||
},
|
||||
{
|
||||
label: '原因',
|
||||
field: 'reasonDesc',
|
||||
component: 'InputTextArea',
|
||||
required: true,
|
||||
colProps: { span: 24 },
|
||||
componentProps: { rows: 3, maxlength: 500, showCount: true, placeholder: '请输入原因' },
|
||||
},
|
||||
{
|
||||
label: '创建人',
|
||||
field: 'createBy',
|
||||
|
||||
Reference in New Issue
Block a user