no message

main
HUOJIN\92525 2025-11-14 22:55:53 +08:00
parent cfb4aaf5a4
commit cee141f803
8 changed files with 958 additions and 10 deletions

View File

@ -11,7 +11,7 @@ export const columns: BasicColumn[] = [
{
title: '外部单号',
align: 'center',
dataIndex: 'thirdPartyOrderNo',
dataIndex: 'thirdOrderNo',
},
{
title: '任务号',
@ -72,7 +72,6 @@ export const asnDetailColumns: JVxeColumn[] = [
title: '入库单ID',
key: 'asnId',
type: JVxeTypes.hidden,
width: '130px',
},
{
title: '物料',
@ -183,6 +182,7 @@ export const asnDetailColumns: JVxeColumn[] = [
type: JVxeTypes.input,
width: '130px',
placeholder: '请输入${title}',
defaultValue: null,
},
{
title: '任务号',
@ -190,6 +190,7 @@ export const asnDetailColumns: JVxeColumn[] = [
type: JVxeTypes.input,
width: '130px',
placeholder: '请输入${title}',
defaultValue: null,
},
{
title: '批次号',
@ -197,12 +198,14 @@ export const asnDetailColumns: JVxeColumn[] = [
type: JVxeTypes.input,
width: '130px',
placeholder: '请输入${title}',
defaultValue: null,
},
{
title: '库存状态',
title: '外部库存状态',
key: 'propC3',
type: JVxeTypes.input,
width: '130px',
placeholder: '请输入${title}',
defaultValue: null,
},
];

View File

@ -5,8 +5,8 @@
<a-form v-bind="formItemLayout" name="AsnForm" ref="formRef" class="jeecg-native-form">
<a-row class="form-row" :gutter="24">
<a-col :span="8">
<a-form-item label="外部单号" v-bind="validateInfos.thirdPartyOrderNo" id="AsnForm-thirdPartyOrderNo" name="thirdPartyOrderNo">
<a-input v-model:value="formData.thirdPartyOrderNo" placeholder="请输入外部单号" allow-clear></a-input>
<a-form-item label="外部单号" v-bind="validateInfos.thirdOrderNo" id="AsnForm-thirdOrderNo" name="thirdOrderNo">
<a-input v-model:value="formData.thirdOrderNo" placeholder="请输入外部单号" allow-clear></a-input>
</a-form-item>
</a-col>
<a-col :span="8">
@ -138,9 +138,9 @@
let tenantId = getTenantId();
const formData = reactive<Record<string, any>>({
id: '',
thirdPartyOrderNo: '',
thirdOrderNo: '',
no: '',
status: 'CREATED',
status: 1,
orderType: '',
supplierCode: '',
whCode: '',
@ -151,9 +151,10 @@
//
const validatorRules = reactive({
thirdPartyOrderNo: [{ required: true, message: '请输入外部单号!' }],
thirdOrderNo: [{ required: true, message: '请输入外部单号!' }],
no: [{ required: true, message: '请输入任务号!' }],
orderType: [{ required: true, message: '请选择单据类型!' }],
whCode: [{ required: true, message: '请输入外部仓库代码' }],
});
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });

View File

@ -0,0 +1,81 @@
import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/shipping/pick/list',
save='/shipping/pick/add',
edit='/shipping/pick/edit',
deleteOne = '/shipping/pick/delete',
deleteBatch = '/shipping/pick/deleteBatch',
importExcel = '/shipping/pick/importExcel',
exportXls = '/shipping/pick/exportXls',
queryDataById = '/shipping/pick/queryById',
pickDetailList = '/shipping/pick/queryPickDetailByMainId',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const queryPickDetailListByMainId = (id) => defHttp.get({url: Api.pickDetailList, params:{ id }});
/**
*
* @param params
*/
export const list = (params) =>
defHttp.get({url: Api.list, params});
/**
*
*/
export const deleteOne = (params,handleSuccess) => {
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
/**
*
* @param params
*/
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();
});
}
});
}
/**
*
* @param params
*/
export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({url: url, params});
}
/**
* id
* @param params
*/
export const queryDataById = (id) => defHttp.get({url: Api.queryDataById, params:{ id }});

View File

@ -0,0 +1,202 @@
import { BasicColumn } from '/@/components/Table';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types';
import { render } from '@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
{
title: '系统单号',
align: 'center',
dataIndex: 'orderNo',
},
{
title: '外部单号',
align: 'center',
dataIndex: 'thirdOrderNo',
},
{
title: '任务号',
align: 'center',
dataIndex: 'no',
},
{
title: '订单状态',
align: 'center',
dataIndex: 'status_dictText',
customRender: ({ text }) => {
//入库状态:1.已创建;2.部分分配;3.已分配;4.拣货中;5.拣货完成;6.已关闭;7.已取消。
const statusColorMap = {
: 'orange',
: 'cyan',
: 'cyan',
: 'blue',
: 'green',
: 'green',
: 'red',
};
const color = statusColorMap[text] || 'red';
return render.renderTag(text, color);
},
},
{
title: '单据类型',
align: 'center',
dataIndex: 'orderType_dictText',
},
{
title: '需求数量',
align: 'center',
dataIndex: 'orderQty',
},
{
title: '分配数量',
align: 'center',
dataIndex: 'allocatedQty',
},
{
title: '拣货数量',
align: 'center',
dataIndex: 'pickedQty',
},
{
title: '外部仓库',
align: 'center',
dataIndex: 'whCode',
},
{
title: '客户代码',
align: 'center',
dataIndex: 'customerCode',
},
{
title: '外部仓库',
align: 'center',
dataIndex: 'whCode',
},
{
title: '订单日期',
align: 'center',
dataIndex: 'orderDate',
},
];
//子表表格配置
export const pickDetailColumns: JVxeColumn[] = [
{
title: '出库单ID',
key: 'pickId',
type: JVxeTypes.hidden,
},
{
title: '物料',
key: 'itemId',
type: JVxeTypes.selectSearch,
width: 150,
async: true, // 异步搜索,默认为 true
//查询状态启用、未删除的物料
dictCode: 'base_item where iz_active=1 and del_flag=0,item_code,id',
tipsContent: '请搜索物料',
validateRules: [
{
required: true, // 必填
message: '请选择${title}', // 显示的文本
},
],
},
{
title: '单位',
key: 'unit',
type: JVxeTypes.select,
dictCode: 'package_unit',
width: '130px',
placeholder: '请选择${title}',
defaultValue: '托',
},
{
title: '需求数量',
key: 'orderQty',
type: JVxeTypes.inputNumber,
width: '130px',
validateRules: [
{
required: true, // 必填
message: '请输入${title}', // 显示的文本
},
],
},
{
title: '分配数量',
key: 'allocatedQty',
type: JVxeTypes.normal,
width: '130px',
defaultValue: '0',
disabled: true,
},
{
title: '拣货数量',
key: 'pickedQty',
type: JVxeTypes.normal,
width: '130px',
placeholder: '请输入${title}',
defaultValue: '0',
disabled: true,
},
{
title: '明细状态',
key: 'status',
type: JVxeTypes.normal,
width: '120px',
defaultValue: '1',
formatter: ({ cellValue }) => {
//入库状态:1.已创建;2.部分收货;3.收货完成;4.已取消。
const statusMap = {
1: '已创建',
2: '部分收货',
3: '收货完成',
4: '已取消',
};
// 状态颜色映射
const statusColorMap = {
: 'orange',
: 'blue',
: 'green',
: 'red',
};
const text = statusMap[cellValue] || '未知状态';
const color = statusColorMap[text] || 'red';
return render.renderTag(text, color);
},
},
{
title: '项目号',
key: 'project',
type: JVxeTypes.input,
width: '130px',
placeholder: '请输入${title}',
defaultValue: null,
},
{
title: '任务号',
key: 'taskNo',
type: JVxeTypes.input,
width: '130px',
placeholder: '请输入${title}',
defaultValue: null,
},
{
title: '批次号',
key: 'propC1',
type: JVxeTypes.input,
width: '130px',
placeholder: '请输入${title}',
defaultValue: null,
},
{
title: '外部库存状态',
key: 'propC3',
type: JVxeTypes.input,
width: '130px',
placeholder: '请输入${title}',
defaultValue: null,
},
];

View File

@ -0,0 +1,239 @@
<template>
<div class="p-2">
<!--查询区域-->
<div class="jeecg-basic-table-form-container">
<a-form ref="formRef" @keyup.enter.native="reload" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-row :gutter="24"> </a-row>
</a-form>
</div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" v-auth="'shipping:data_pick:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> </a-button>
<a-button type="primary" v-auth="'shipping:data_pick:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> </a-button>
<j-upload-button type="primary" v-auth="'shipping:data_pick: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"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'shipping:data_pick:deleteBatch'"
>批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template>
<!--字段回显插槽-->
<template v-slot:bodyCell="{ column, record, index, text }"> </template>
</BasicTable>
<!-- 表单区域 -->
<PickModal @register="registerModal" @success="handleSuccess"></PickModal>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive } from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { useModal } from '/@/components/Modal';
import PickModal from './components/PickModal.vue';
import { columns } from './Pick.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './Pick.api';
import { useMessage } from '/@/hooks/web/useMessage';
import { getDateByPicker } from '/@/utils';
import { useUserStore } from '/@/store/modules/user';
const fieldPickers = reactive({});
const formRef = ref();
const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]);
//model
const [registerModal, { openModal }] = useModal();
const userStore = useUserStore();
const { createMessage } = useMessage();
//table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '出库单',
api: list,
columns,
canResize: true,
useSearchForm: false,
actionColumn: {
width: 120,
fixed: 'right',
},
beforeFetch: async (params) => {
for (let key in fieldPickers) {
if (queryParam[key] && fieldPickers[key]) {
queryParam[key] = getDateByPicker(queryParam[key], fieldPickers[key]);
}
}
return Object.assign(params, queryParam);
},
},
exportConfig: {
name: '出库单',
url: getExportUrl,
params: queryParam,
},
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 getTableAction(record) {
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
auth: 'shipping:data_pick:edit',
},
];
}
/**
* 下拉操作栏
*/
function getDropDownAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
},
{
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
placement: 'topLeft',
},
auth: 'shipping:data_pick:delete',
},
];
}
/* ----------------------以下为原生查询需要添加的-------------------------- */
const toggleSearchStatus = ref<boolean>(false);
const labelCol = reactive({
xs: 24,
sm: 4,
xl: 6,
xxl: 4,
});
const wrapperCol = reactive({
xs: 24,
sm: 20,
});
/**
* 重置
*/
function searchReset() {
formRef.value.resetFields();
selectedRowKeys.value = [];
//
reload();
}
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
padding: 0;
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust {
min-width: 100px !important;
}
.query-group-split-cust {
width: 30px;
display: inline-block;
text-align: center;
}
.ant-form-item:not(.ant-form-item-with-help) {
margin-bottom: 16px;
height: 32px;
}
:deep(.ant-picker),
:deep(.ant-input-number) {
width: 100%;
}
}
</style>

View File

@ -0,0 +1,40 @@
-- 注意该页面对应的前台目录为views/shipping文件夹下
-- 如果你想更改到其他目录请修改sql中component字段对应的值
-- 主菜单
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external)
VALUES ('176310372519801', NULL, '出库单', '/shipping/pickList', 'shipping/PickList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2025-11-14 15:02:05', NULL, NULL, 0);
-- 新增
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('176310372519802', '176310372519801', '添加出库单', NULL, NULL, 0, NULL, NULL, 2, 'shipping:data_pick:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-11-14 15:02:05', NULL, NULL, 0, 0, '1', 0);
-- 编辑
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('176310372519803', '176310372519801', '编辑出库单', NULL, NULL, 0, NULL, NULL, 2, 'shipping:data_pick:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-11-14 15:02:05', NULL, NULL, 0, 0, '1', 0);
-- 删除
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('176310372519804', '176310372519801', '删除出库单', NULL, NULL, 0, NULL, NULL, 2, 'shipping:data_pick:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-11-14 15:02:05', NULL, NULL, 0, 0, '1', 0);
-- 批量删除
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('176310372519805', '176310372519801', '批量删除出库单', NULL, NULL, 0, NULL, NULL, 2, 'shipping:data_pick:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-11-14 15:02:05', NULL, NULL, 0, 0, '1', 0);
-- 导出excel
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('176310372519806', '176310372519801', '导出excel_出库单', NULL, NULL, 0, NULL, NULL, 2, 'shipping:data_pick:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-11-14 15:02:05', NULL, NULL, 0, 0, '1', 0);
-- 导入excel
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('176310372519807', '176310372519801', '导入excel_出库单', NULL, NULL, 0, NULL, NULL, 2, 'shipping:data_pick:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-11-14 15:02:05', NULL, NULL, 0, 0, '1', 0);
-- 角色授权(以 admin 角色为例role_id 可替换)
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176310372519808', 'f6817f48af4fb3af11b9e8bf182f618b', '176310372519801', NULL, '2025-11-14 15:02:05', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176310372519809', 'f6817f48af4fb3af11b9e8bf182f618b', '176310372519802', NULL, '2025-11-14 15:02:05', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176310372519810', 'f6817f48af4fb3af11b9e8bf182f618b', '176310372519803', NULL, '2025-11-14 15:02:05', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176310372519811', 'f6817f48af4fb3af11b9e8bf182f618b', '176310372519804', NULL, '2025-11-14 15:02:05', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176310372519812', 'f6817f48af4fb3af11b9e8bf182f618b', '176310372519805', NULL, '2025-11-14 15:02:05', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176310372519813', 'f6817f48af4fb3af11b9e8bf182f618b', '176310372519806', NULL, '2025-11-14 15:02:05', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176310372519814', 'f6817f48af4fb3af11b9e8bf182f618b', '176310372519807', NULL, '2025-11-14 15:02:05', '127.0.0.1');

View File

@ -0,0 +1,315 @@
<template>
<a-spin :spinning="loading">
<JFormContainer :disabled="disabled">
<template #detail>
<a-form v-bind="formItemLayout" name="PickForm" ref="formRef" class="jeecg-native-form">
<a-row class="form-row" :gutter="24">
<a-col :span="8">
<a-form-item label="外部单号" v-bind="validateInfos.thirdOrderNo" id="PickForm-thirdOrderNo" name="thirdOrderNo">
<a-input v-model:value="formData.thirdOrderNo" placeholder="请输入外部单号" allow-clear></a-input>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="任务号" v-bind="validateInfos.no" id="PickForm-no" name="no">
<a-input v-model:value="formData.no" placeholder="请输入任务号" allow-clear></a-input>
</a-form-item>
</a-col>
<a-col class="form-row" :span="8">
<a-form-item label="单据类型" v-bind="validateInfos.orderType" id="PickForm-orderType" name="orderType">
<JDictSelectTag
type="select"
v-model:value="formData.orderType"
dictCode="pick_order_type"
placeholder="请选择单据类型"
:string-to-number="true"
/>
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="24">
<a-col class="form-row" :span="8">
<a-form-item label="客户" v-bind="validateInfos.customerCode" id="PickForm-customerCode" name="customerCode">
<a-input v-model:value="formData.customerCode" placeholder="请输入客户" allow-clear></a-input>
</a-form-item>
</a-col>
<a-col class="form-row" :span="8">
<a-form-item label="外部仓库" v-bind="validateInfos.whCode" id="PickForm-whCode" name="whCode">
<a-input v-model:value="formData.whCode" placeholder="请输入外部仓库代码" allow-clear></a-input>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="订单日期" v-bind="validateInfos.orderDate" id="PickForm-orderDate" name="orderDate">
<a-date-picker
placeholder="请选择订单日期"
v-model:value="formData.orderDate"
showTime
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
allow-clear
/>
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="24">
<a-col :span="24">
<a-form-item
label="描述"
v-bind="validateInfos.description"
id="PickForm-description"
name="description"
:labelCol="{ span: 2 }"
:wrapperCol="{ span: 24 }"
>
<a-textarea v-model:value="formData.description" :rows="4" placeholder="请输入描述" />
</a-form-item>
</a-col>
</a-row>
</a-form>
</template>
</JFormContainer>
<!-- 子表单区域 -->
<a-tabs v-model:activeKey="activeKey" animated style="overflow: hidden" class="jeecg-native-tab">
<a-tab-pane tab="出库明细" key="pickDetail" :forceRender="true">
<j-vxe-table
:keep-source="true"
resizable
ref="pickDetailTableRef"
:loading="pickDetailTable.loading"
:columns="pickDetailTable.columns"
:dataSource="pickDetailTable.dataSource"
:height="340"
:disabled="disabled"
:rowNumber="true"
:rowSelection="true"
:toolbar="true"
/>
</a-tab-pane>
</a-tabs>
</a-spin>
</template>
<script lang="ts">
import { defineComponent, ref, reactive, computed, toRaw } from 'vue';
import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
import { queryPickDetailListByMainId, queryDataById, saveOrUpdate } from '../Pick.api';
import { JVxeTable } from '/@/components/jeecg/JVxeTable';
import { pickDetailColumns } from '../Pick.data';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
import { JDictSelectTag } from '@/components/Form';
import { Form } from 'ant-design-vue';
import { getDateByPicker } from '/@/utils';
import { getTenantId } from '@/utils/auth';
import dayjs from 'dayjs';
const useForm = Form.useForm;
export default defineComponent({
name: 'PickForm',
components: {
JVxeTable,
JDictSelectTag,
JFormContainer,
},
props: {
formDisabled: {
type: Boolean,
default: false,
},
formData: {
type: Object,
default: () => {},
},
formBpm: { type: Boolean, default: true },
},
emits: ['success'],
setup(props, { emit }) {
const loading = ref(false);
const formRef = ref();
const pickDetailTableRef = ref();
const pickDetailTable = reactive<Record<string, any>>({
loading: false,
columns: pickDetailColumns,
dataSource: [],
});
const activeKey = ref('pickDetail');
// ID
let tenantId = getTenantId();
const formData = reactive<Record<string, any>>({
id: '',
orderNo: '',
thirdOrderNo: '',
no: '',
whCode: '',
customerCode: '',
orderType: '',
status: 1,
orderDate: dayjs(),
tenantId: tenantId,
description: '',
});
//
const validatorRules = reactive({
thirdOrderNo: [{ required: true, message: '请输入外部单号!' }],
no: [{ required: true, message: '请输入任务号!' }],
orderType: [{ required: true, message: '请选择单据类型!' }],
whCode: [{ required: true, message: '请输入外部仓库代码' }]
});
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
//
const fieldPickers = reactive({});
const dbData = {};
const formItemLayout = {
labelCol: { xs: { span: 24 }, sm: { span: 6 } },
wrapperCol: { xs: { span: 24 }, sm: { span: 24 } },
};
//
const disabled = computed(() => {
if (props.formBpm === true) {
if (props.formData.disabled === false) {
return false;
} else {
return true;
}
}
return props.formDisabled;
});
function add() {
resetFields();
pickDetailTable.dataSource = [];
}
async function edit(row) {
//
await queryMainData(row.id);
//
const pickDetailDataList = await queryPickDetailListByMainId(row['id']);
pickDetailTable.dataSource = [...pickDetailDataList];
}
async function queryMainData(id) {
const row = await queryDataById(id);
resetFields();
const tmpData = {};
Object.keys(formData).forEach((key) => {
if (row.hasOwnProperty(key)) {
tmpData[key] = row[key];
}
});
//
Object.assign(formData, tmpData);
}
const { getSubFormAndTableData, transformData } = useValidateAntFormAndTable(activeKey, {
pickDetail: pickDetailTableRef,
});
async function getFormData() {
try {
//
await validate();
} catch ({ errorFields }) {
if (errorFields) {
const firstField = errorFields[0];
if (firstField) {
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
}
}
return Promise.reject(errorFields);
}
return transformData(toRaw(formData));
}
async function submitForm() {
const mainData = await getFormData();
const subData = await getSubFormAndTableData();
//
changeDateValue(mainData, subData);
const values = Object.assign({}, dbData, mainData, subData);
console.log('表单提交数据', values);
const isUpdate = values.id ? true : false;
await saveOrUpdate(values, isUpdate);
//
emit('success');
}
function setFieldsValue(values) {
if (values) {
Object.keys(values).map((k) => {
formData[k] = values[k];
});
}
}
/**
* 处理日期值
* @param formData 表单数据
*/
const changeDateValue = (mainData, subData) => {
for (let key in mainData) {
//
mainData[key] = getDateByPicker(mainData[key], fieldPickers[key]);
}
if (subData.pickDetailList && subData.pickDetailList.length > 0) {
pickDetailColumns.forEach((subFormField) => {
if (subFormField && subFormField.picker && subFormField.key) {
let subPicker = subFormField.picker;
const subFieldName = subFormField.key;
subData.pickDetailList.forEach((subFormData) => {
if (subPicker === 'year') {
subFormData[subFieldName] = dayjs(subFormData[subFieldName]).set('month', 0).set('date', 1).format('YYYY-MM-DD');
} else if (subPicker === 'month') {
subFormData[subFieldName] = dayjs(subFormData[subFieldName]).set('date', 1).format('YYYY-MM-DD');
} else if (subPicker === 'week') {
subFormData[subFieldName] = dayjs(subFormData[subFieldName]).startOf('week').format('YYYY-MM-DD');
}
});
}
});
}
};
/**
* 值改变事件触发-树控件回调
* @param key
* @param value
*/
function handleFormChange(key, value) {
formData[key] = value;
}
return {
pickDetailTableRef,
pickDetailTable,
validatorRules,
validateInfos,
activeKey,
loading,
formData,
setFieldsValue,
handleFormChange,
formItemLayout,
disabled,
getFormData,
submitForm,
add,
edit,
formRef,
};
},
});
</script>
<style lang="less" scoped>
.ant-tabs-tabpane.sub-one-form {
max-height: 340px;
overflow: auto;
}
.jeecg-native-form,
.jeecg-native-tab {
padding: 0 20px;
}
</style>

View File

@ -0,0 +1,67 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" :okText="'保存'" :defaultFullscreen="true" @ok="handleSubmit">
<pick-form ref="formComponent" :formDisabled="formDisabled" :formBpm="false" @success="submitSuccess"></pick-form>
</BasicModal>
</template>
<script lang="ts">
import { ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import PickForm from './PickForm.vue';
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
export default {
name: "TestCgMainVxeModal",
components:{
BasicModal,
PickForm
},
emits:['register','success'],
setup(_p, {emit}){
const formComponent = ref()
const isUpdate = ref(true);
const formDisabled = ref(false);
const title = ref('')
//
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
setModalProps({confirmLoading: false,showCancelBtn:data?.showFooter,showOkBtn:data?.showFooter});
isUpdate.value = !!data?.isUpdate;
formDisabled.value = !data?.showFooter;
title.value = data?.isUpdate ? (unref(formDisabled) ? '出库单详情' : '编辑出库单') : '新增出库单';
if (unref(isUpdate)) {
formComponent.value.edit(data.record)
}else{
formComponent.value.add()
}
});
function handleSubmit() {
formComponent.value.submitForm();
}
function submitSuccess(){
emit('success');
closeModal();
}
return {
registerModal,
title,
formComponent,
formDisabled,
handleSubmit,
submitSuccess,
}
}
}
</script>
<style lang="less" scoped>
/** 时间和数字输入框样式 */
:deep(.ant-input-number) {
width: 100%;
}
:deep(.ant-calendar-picker) {
width: 100%;
}
</style>