更新VSCode配置,启用Maven支持,设置Java 17环境,调整MybatisPlusSaasConfig以开启系统租户控制并添加新租户表。更新pom.xml以包含新模块jeecg-module-xslmes,优化Vue3环境配置以统一API路径,增强代理设置以支持完整的后端路径。修复useForm钩子中的字段重置逻辑,改进axios配置以处理相对URL的上下文路径问题。
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslCustomer/list',
|
||||
queryById = '/xslmes/mesXslCustomer/queryById',
|
||||
save = '/xslmes/mesXslCustomer/add',
|
||||
edit = '/xslmes/mesXslCustomer/edit',
|
||||
updateStatus = '/xslmes/mesXslCustomer/updateStatus',
|
||||
deleteOne = '/xslmes/mesXslCustomer/delete',
|
||||
deleteBatch = '/xslmes/mesXslCustomer/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslCustomer/importExcel',
|
||||
exportXls = '/xslmes/mesXslCustomer/exportXls',
|
||||
}
|
||||
|
||||
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 });
|
||||
};
|
||||
|
||||
/** 启用/停用:status 0 启用 1 停用(与供应商管理 MesXslSupplier.api.updateStatus 一致) */
|
||||
export const updateStatus = (params: { id: string; status: string }, handleSuccess?: () => void) => {
|
||||
return defHttp.post({ url: Api.updateStatus, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess?.();
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,105 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: 'ID', align: 'center', dataIndex: 'id', width: 280, ellipsis: true, defaultHidden: true },
|
||||
{ title: '客户编码', align: 'center', dataIndex: 'customerCode', width: 140 },
|
||||
{ title: '客户名称', align: 'center', dataIndex: 'customerName', width: 180 },
|
||||
{ title: '客户简称', align: 'center', dataIndex: 'customerShortName', width: 120 },
|
||||
{ title: '客户区域', align: 'center', dataIndex: 'customerRegion_dictText', width: 100 },
|
||||
{ title: 'ERP编码', align: 'center', dataIndex: 'erpCode', width: 140 },
|
||||
// 库表 status + 字典 xslmes_customer_status 翻译(后端 DictAspect 填充 status_dictText)
|
||||
{ title: '状态', align: 'center', dataIndex: 'status_dictText', width: 100 },
|
||||
{ title: '客户描述', align: 'center', dataIndex: 'customerDesc', width: 200, 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: 'customerCode', component: 'JInput', colProps: { span: 6 } },
|
||||
{ label: '客户名称', field: 'customerName', component: 'JInput', colProps: { span: 6 } },
|
||||
{ label: '客户简称', field: 'customerShortName', component: 'JInput', colProps: { span: 6 } },
|
||||
{
|
||||
label: '客户区域',
|
||||
field: 'customerRegion',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_customer_region' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'status',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_customer_status' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{
|
||||
label: '客户编码',
|
||||
field: 'customerCode',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '请输入客户编码' },
|
||||
},
|
||||
{
|
||||
label: '客户名称',
|
||||
field: 'customerName',
|
||||
required: true,
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '请输入客户名称' },
|
||||
},
|
||||
{
|
||||
label: '客户简称',
|
||||
field: 'customerShortName',
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '请输入客户简称' },
|
||||
},
|
||||
{
|
||||
label: '客户区域',
|
||||
field: 'customerRegion',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_customer_region', placeholder: '请选择客户区域' },
|
||||
},
|
||||
{
|
||||
label: 'ERP编码',
|
||||
field: 'erpCode',
|
||||
component: 'Input',
|
||||
componentProps: { placeholder: '请输入ERP编码' },
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
field: 'status',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_customer_status', placeholder: '请选择状态' },
|
||||
// 默认启用仅在新增弹窗内通过 setFieldsValue 写入,避免编辑时 schema 默认值覆盖接口里的 status
|
||||
},
|
||||
{
|
||||
label: '客户描述',
|
||||
field: 'customerDesc',
|
||||
component: 'InputTextArea',
|
||||
componentProps: { rows: 3, placeholder: '请输入客户描述' },
|
||||
},
|
||||
{
|
||||
label: '租户ID',
|
||||
field: 'tenantId',
|
||||
component: 'InputNumber',
|
||||
componentProps: { placeholder: '租户ID,可空' },
|
||||
},
|
||||
];
|
||||
|
||||
export const superQuerySchema = {
|
||||
customerCode: { title: '客户编码', order: 0, view: 'text' },
|
||||
customerName: { title: '客户名称', order: 1, view: 'text' },
|
||||
customerShortName: { title: '客户简称', order: 2, view: 'text' },
|
||||
customerRegion: { title: '客户区域', order: 3, view: 'list', dictCode: 'xslmes_customer_region' },
|
||||
status: { title: '状态', order: 4, view: 'list', dictCode: 'xslmes_customer_status' },
|
||||
};
|
||||
@@ -0,0 +1,159 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'xslmes:mes_xsl_customer:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||
<a-button type="primary" v-auth="'xslmes:mes_xsl_customer:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||
<j-upload-button type="primary" v-auth="'xslmes:mes_xsl_customer:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined" />
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button v-auth="'xslmes:mes_xsl_customer:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslCustomerModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslCustomer" setup>
|
||||
import { reactive } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import MesXslCustomerModal from './components/MesXslCustomerModal.vue';
|
||||
import { columns, searchFormSchema, superQuerySchema } from './MesXslCustomer.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, updateStatus } from './MesXslCustomer.api';
|
||||
import Icon from '/@/components/Icon';
|
||||
|
||||
const queryParam = reactive<any>({});
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
|
||||
const { tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '客户管理',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
actionColumn: {
|
||||
width: 280,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: '客户管理',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).forEach((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
openModal(true, { isUpdate: false, showFooter: true });
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: true });
|
||||
}
|
||||
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, { record, isUpdate: true, showFooter: false });
|
||||
}
|
||||
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
/** 与供应商管理一致:status===0 或 0 为启用 */
|
||||
function isRecordEnabled(record: Recordable) {
|
||||
return record.status === '0' || record.status === 0;
|
||||
}
|
||||
|
||||
async function handleToggleStatus(record: Recordable, status: string) {
|
||||
await updateStatus({ id: record.id, status }, handleSuccess);
|
||||
}
|
||||
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
selectedRowKeys.value = [];
|
||||
reload();
|
||||
}
|
||||
|
||||
function getTableAction(record) {
|
||||
const enabled = isRecordEnabled(record);
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
auth: 'xslmes:mes_xsl_customer:edit',
|
||||
},
|
||||
{
|
||||
label: '启用',
|
||||
ifShow: !enabled,
|
||||
onClick: handleToggleStatus.bind(null, record, '0'),
|
||||
auth: 'xslmes:mes_xsl_customer:updateStatus',
|
||||
},
|
||||
{
|
||||
label: '停用',
|
||||
ifShow: enabled,
|
||||
onClick: handleToggleStatus.bind(null, record, '1'),
|
||||
auth: 'xslmes:mes_xsl_customer:updateStatus',
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
},
|
||||
auth: 'xslmes:mes_xsl_customer:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function getDropDownAction(record) {
|
||||
return [{ label: '详情', onClick: handleDetail.bind(null, record) }];
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-picker-range) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,91 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" name="MesXslCustomerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { formSchema } from '../MesXslCustomer.data';
|
||||
import { saveOrUpdate, queryById } from '../MesXslCustomer.api';
|
||||
|
||||
/** 字典下拉 value 与接口一致为字符串,避免 number/string 与选项不一致导致回显成第一项「启用」 */
|
||||
function normalizeCustomerFormValues(record: Recordable) {
|
||||
const o = { ...record };
|
||||
if (o.status !== undefined && o.status !== null && o.status !== '') {
|
||||
o.status = String(o.status);
|
||||
}
|
||||
if (o.customerRegion !== undefined && o.customerRegion !== null && o.customerRegion !== '') {
|
||||
o.customerRegion = String(o.customerRegion);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
|
||||
const [registerForm, { setProps, resetFields, setFieldsValue, validate, scrollToField }] = useForm({
|
||||
labelWidth: 120,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 },
|
||||
});
|
||||
|
||||
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)) {
|
||||
let row = data?.record;
|
||||
// 以详情接口为准,避免列表行字段缺失或与字典组件 value 类型不一致(列表仍显示 status_dictText)
|
||||
if (row?.id) {
|
||||
try {
|
||||
const res = await queryById({ id: String(row.id) });
|
||||
const full = (res as any)?.id != null ? res : (res as any)?.result ?? res;
|
||||
if (full && (full as any).id) {
|
||||
row = full as Recordable;
|
||||
}
|
||||
} catch {
|
||||
// 仍使用列表行
|
||||
}
|
||||
}
|
||||
await setFieldsValue(normalizeCustomerFormValues(row || {}));
|
||||
} else {
|
||||
// 新增默认启用(与后端 MesXslCustomerBizStatus.ENABLED 一致,0=启用)
|
||||
await setFieldsValue({ status: '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, unref(isUpdate));
|
||||
closeModal();
|
||||
emit('success');
|
||||
} catch (e: any) {
|
||||
if (e?.errorFields) {
|
||||
const firstField = e.errorFields[0];
|
||||
if (firstField) {
|
||||
scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
}
|
||||
return Promise.reject(e);
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user