no message

main
HUOJIN\92525 2025-12-26 18:14:08 +08:00
parent 514d840de7
commit 9c6e3000d6
12 changed files with 957 additions and 26 deletions

View File

@ -78,7 +78,9 @@ export default defineComponent({
//
izActive: propTypes.number.def(1),
//
delFlag:propTypes.number.def(0)
delFlag:propTypes.number.def(0),
//
areaCode: propTypes.array
},
emits: ['change', 'update:value', 'optionsLoaded'],
setup(props, { emit }) {
@ -160,13 +162,14 @@ export default defineComponent({
loading.value = true;
const res = await defHttp.get<ResponseData>({
url: '/base/Area/list',
url: '/base/area/list',
params: {
pageSize: props.pageSize,
pageNo: page,
keyword: keyword,
izActive: props.izActive,
delFlag: props.delFlag
delFlag: props.delFlag,
areaCode: props.areaCode,
},
});

View File

@ -27,6 +27,11 @@ export const columns: BasicColumn[] = [
align: 'center',
dataIndex: 'colNum',
},
{
title: '储位编码',
align: 'center',
dataIndex: 'nodeCode',
},
{
title: '层',
align: 'center',

View File

@ -78,6 +78,11 @@
<a-input-number v-model:value="formData.positionY" placeholder="请输入坐标Y" allow-clear style="width: 220px"></a-input-number>
</a-form-item>
</a-col>
<a-col :span="12" v-if="showSpecialFields">
<a-form-item label="储位编码" v-bind="validateInfos.nodeCode" id="PointForm-nodeCode" name="nodeCode">
<a-input-number v-model:value="formData.nodeCode" placeholder="请输入储位编码" allow-clear style="width: 220px"></a-input-number>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item
label="描述"
@ -157,6 +162,7 @@
rowNum: null,
positionX: 0,
positionY: 0,
nodeCode:'',
izDoubleLane: 1,
description: '',
delFlag: 0,
@ -177,6 +183,7 @@
layerNum: [], //
positionX: [], //
positionY: [], //
nodeCode:[]//
});
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
//
@ -231,6 +238,7 @@
validatorRules.layerNum.splice(0);
validatorRules.positionX.splice(0);
validatorRules.positionY.splice(0);
validatorRules.nodeCode.splice(0);
//
if (isSpecialArea) {
@ -238,6 +246,7 @@
validatorRules.colNum.push({ required: true, message: '请输入巷道编码!' });
validatorRules.rowNum.push({ required: true, message: '请输入深度!' });
validatorRules.layerNum.push({ required: true, message: '请输入层!' });
validatorRules.nodeCode.push({ required: true, message: '请输入储位编码!' });
} else {
// pointCode
validatorRules.pointCode.push({ required: true, message: '请输入编码!' });

View File

@ -79,7 +79,7 @@
izActive: propTypes.number.def(1),
//
delFlag: propTypes.number.def(0),
//ID
//
areaCode: propTypes.array,
},
emits: ['change', 'update:value', 'optionsLoaded'],

View File

@ -0,0 +1,74 @@
import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/count/countPlan/list',
save='/count/countPlan/add',
edit='/count/countPlan/edit',
deleteOne = '/count/countPlan/delete',
deleteBatch = '/count/countPlan/deleteBatch',
importExcel = '/count/countPlan/importExcel',
exportXls = '/count/countPlan/exportXls',
queryDataById = '/count/countPlan/queryById',
countDetailList = '/count/countPlan/queryCountDetailByMainId',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const queryCountDetailListByMainId = (id) => defHttp.get({url: Api.countDetailList, params:{ id }});
export const queryDataById = (id) => defHttp.get({url: Api.queryDataById, 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) => {
const url = isUpdate ? Api.edit : Api.save;
return defHttp.post({url: url, params});
}

View File

@ -0,0 +1,81 @@
import { BasicColumn } from '/@/components/Table';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types';
//列表数据
export const columns: BasicColumn[] = [
{
title: '盘点单号',
align: 'center',
dataIndex: 'orderNo',
},
{
title: '盘点类型',
align: 'center',
dataIndex: 'countType_dictText',
},
{
title: '状态',
align: 'center',
dataIndex: 'status_dictText',
},
{
title: '审核人',
align: 'center',
dataIndex: 'auditor',
},
{
title: '创建时间',
align: 'center',
dataIndex: 'createTime',
},
];
//子表表格配置
export const countDetailColumns: JVxeColumn[] = [
{
title: '盘点明细ID',
key: 'id',
type: JVxeTypes.hidden,
},
{
title: '物料',
key: 'itemCode',
type: JVxeTypes.normal,
width: '200px',
},
{
title: '库位',
key: 'pointCode',
type: JVxeTypes.normal,
width: '200px',
},
{
title: '容器',
key: 'stockCode',
type: JVxeTypes.normal,
width: '200px',
},
{
title: '库存数量',
key: 'invQty',
type: JVxeTypes.normal,
width: '200px',
},
{
title: '盘点数量',
key: 'countQty',
type: JVxeTypes.normal,
width: '200px',
},
{
title: '盘点人',
key: 'countBy',
type: JVxeTypes.normal,
width: '200px',
},
{
title: '盘点日期',
key: 'planDate',
type: JVxeTypes.normal,
width: '200px',
},
];

View File

@ -0,0 +1,309 @@
<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-col :lg="6">
<a-form-item name="no">
<template #label><span title="任务号">任务号</span></template>
<JInput v-model:value="queryParam.no" :placeholder="'请输入任务号'" :type="JInputTypeEnum.JINPUT_RIGHT_LIKE" />
</a-form-item>
</a-col>
<a-col :lg="6">
<a-form-item name="orderType">
<template #label><span title="单据类型">单据类型</span></template>
<JDictSelectTag v-model:value="queryParam.orderType" placeholder="请选择" dictCode="asn_order_type" allowClear />
</a-form-item>
</a-col>
<a-col :lg="6">
<a-form-item name="orderDate">
<template #label><span title="订单日期">订单日期</span></template>
<JRangeDate v-model:value="queryParam.orderDate" />
</a-form-item>
</a-col>
<a-col :xl="6" :lg="7" :md="8" :sm="24">
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
<a-col :lg="6">
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery"></a-button>
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
<a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
{{ toggleSearchStatus ? '收起' : '展开' }}
<Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
</a>
</a-col>
</span>
</a-col>
</a-row>
<a-row :gutter="24">
<!-- <a-col :lg="6">
<a-form-item name="status">
<template #label><span title="状态">状态</span></template>
<JDictSelectTag v-model:value="queryParam.status" placeholder="请选择" dictCode="asn_status" allowClear />
</a-form-item>
</a-col>-->
</a-row>
</a-form>
</div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" v-auth="'count:data_count_plan:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> </a-button>
<a-button type="primary" v-auth="'count:data_count_plan:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls">
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'count:data_count_plan:importExcel'"
v-show="false"
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="'count:data_count_plan: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>
<!-- 表单区域 -->
<CountPlanModal @register="registerModal" @success="handleSuccess"></CountPlanModal>
</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 CountPlanModal from './components/CountPlanModal.vue';
import { columns } from './CountPlan.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './CountPlan.api';
import { getDateByPicker } from '/@/utils';
import { JInputTypeEnum } from '@/enums/cpteEnum';
import { JInput, JDictSelectTag } from '@/components/Form';
import JRangeDate from '@/components/Form/src/jeecg/components/JRangeDate.vue';
const fieldPickers = reactive({});
const formRef = ref();
const queryParam = reactive<any>({});
//model
const [registerModal, { openModal }] = useModal();
//table
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '盘点单',
api: list,
columns,
canResize: true,
useSearchForm: false,
actionColumn: {
width: 120,
fixed: 'right',
},
beforeFetch: async (params) => {
//
const newQueryParam = { ...queryParam };
//
if (newQueryParam.orderDate) {
try {
const [begin, end] = newQueryParam.orderDate.split(',');
if (begin !== undefined) newQueryParam.orderDate_begin = begin;
if (end !== undefined) newQueryParam.orderDate_end = end;
delete newQueryParam.orderDate;
} catch (error) {
console.error('日期范围处理错误:', error);
}
}
for (let key in fieldPickers) {
if (newQueryParam[key] && fieldPickers[key]) {
newQueryParam[key] = getDateByPicker(newQueryParam[key], fieldPickers[key]);
}
}
return Object.assign(params, newQueryParam);
},
},
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) {
let showFooter = true;
if (record.status > 1) {
showFooter = false;
}
openModal(true, {
record,
isUpdate: true,
showFooter: showFooter,
});
}
/**
* 详情
*/
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: 'count:data_count_plan:edit',
},
];
}
/**
* 下拉操作栏
*/
function getDropDownAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
},
{
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
placement: 'topLeft',
},
auth: 'count:data_count_plan:delete',
disabled: record.status != 1,
},
];
}
/* ----------------------以下为原生查询需要添加的-------------------------- */
const toggleSearchStatus = ref<boolean>(false);
const labelCol = reactive({
xs: 24,
sm: 4,
xl: 6,
xxl: 4,
});
const wrapperCol = reactive({
xs: 24,
sm: 20,
});
/**
* 查询
*/
function searchQuery() {
reload();
}
/**
* 重置
*/
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/count文件夹下
-- 如果你想更改到其他目录请修改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 ('176647664878701', NULL, '盘点', '/count/countPlanList', 'count/CountPlanList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2025-12-23 15:57:28', 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 ('176647664878702', '176647664878701', '添加盘点', NULL, NULL, 0, NULL, NULL, 2, 'count:data_count_plan:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-12-23 15:57:28', 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 ('176647664878703', '176647664878701', '编辑盘点', NULL, NULL, 0, NULL, NULL, 2, 'count:data_count_plan:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-12-23 15:57:28', 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 ('176647664878704', '176647664878701', '删除盘点', NULL, NULL, 0, NULL, NULL, 2, 'count:data_count_plan:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-12-23 15:57:28', 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 ('176647664878705', '176647664878701', '批量删除盘点', NULL, NULL, 0, NULL, NULL, 2, 'count:data_count_plan:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-12-23 15:57:28', 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 ('176647664878706', '176647664878701', '导出excel_盘点', NULL, NULL, 0, NULL, NULL, 2, 'count:data_count_plan:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-12-23 15:57:28', 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 ('176647664878707', '176647664878701', '导入excel_盘点', NULL, NULL, 0, NULL, NULL, 2, 'count:data_count_plan:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-12-23 15:57:28', 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 ('176647664878708', 'f6817f48af4fb3af11b9e8bf182f618b', '176647664878701', NULL, '2025-12-23 15:57:28', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176647664878709', 'f6817f48af4fb3af11b9e8bf182f618b', '176647664878702', NULL, '2025-12-23 15:57:28', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176647664878810', 'f6817f48af4fb3af11b9e8bf182f618b', '176647664878703', NULL, '2025-12-23 15:57:28', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176647664878811', 'f6817f48af4fb3af11b9e8bf182f618b', '176647664878704', NULL, '2025-12-23 15:57:28', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176647664878812', 'f6817f48af4fb3af11b9e8bf182f618b', '176647664878705', NULL, '2025-12-23 15:57:28', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176647664878813', 'f6817f48af4fb3af11b9e8bf182f618b', '176647664878706', NULL, '2025-12-23 15:57:28', '127.0.0.1');
INSERT INTO sys_role_permission (id, role_id, permission_id, data_rule_ids, operate_date, operate_ip) VALUES ('176647664878814', 'f6817f48af4fb3af11b9e8bf182f618b', '176647664878707', NULL, '2025-12-23 15:57:28', '127.0.0.1');

View File

@ -0,0 +1,333 @@
<template>
<a-spin :spinning="loading">
<JFormContainer :disabled="disabled">
<template #detail>
<a-form v-bind="formItemLayout" name="CountPlanForm" ref="formRef" class="jeecg-native-form">
<a-row class="form-row" :gutter="24">
<a-col class="form-row" :span="8">
<a-form-item label="库区" v-bind="validateInfos.areaId" id="CountPlanForm-areaId" name="areaId">
<AreaSelect v-model:value="formData.areaId" :area-code="['CPCCQ', 'MJCCQ']" />
</a-form-item>
</a-col>
<a-col class="form-row" :span="8">
<a-form-item label="盘点类型" v-bind="validateInfos.countType" id="CountPlanForm-countType" name="countType">
<JDictSelectTag
type="select"
v-model:value="formData.countType"
dictCode="count_type"
placeholder="请选择盘点类型"
:string-to-number="true"
/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="创建日期" v-bind="validateInfos.createTime" id="CountPlanForm-createTime" name="createTime">
<a-date-picker
placeholder="请选择订单日期"
v-model:value="formData.createTime"
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-row>
<a-row class="form-row" :gutter="24">
<a-col :span="24">
<a-form-item
:label="materialLabel"
v-bind="validateInfos.description"
id="CountPlanForm-description"
name="description"
:labelCol="{ span: 2 }"
:wrapperCol="{ span: 24 }"
>
<a-textarea v-model:value="formData.description" :rows="4" :placeholder="materialPlaceholder" />
</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="countDetail" :forceRender="true">
<j-vxe-table
:row-number="true"
:keep-source="true"
resizable
ref="countDetailTableRef"
:loading="countDetailTable.loading"
:columns="countDetailTable.columns"
:dataSource="countDetailTable.dataSource"
:height="340"
:disabled="disabled"
:rowSelection="true"
:toolbar="false"
/>
</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 { queryCountDetailListByMainId, queryDataById, saveOrUpdate } from '../CountPlan.api';
import { JVxeTable } from '/@/components/jeecg/JVxeTable';
import { countDetailColumns } from '../CountPlan.data';
import { getTenantId } from '@/utils/auth';
import { getDateByPicker } from '/@/utils';
import dayjs from 'dayjs';
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
import { Form } from 'ant-design-vue';
import { JDictSelectTag } from '@/components/Form';
import AreaSelect from '@/views/base/area/components/AreaSelect.vue';
const useForm = Form.useForm;
export default defineComponent({
name: 'CountPlanForm',
components: {
AreaSelect,
JDictSelectTag,
JVxeTable,
JFormContainer,
},
props: {
formDisabled: {
type: Boolean,
default: false,
},
formData: {
type: Object,
default: () => {},
},
formBpm: { type: Boolean, default: true },
},
emits: ['success'],
setup(props, { emit }) {
const materialLabel = computed(() => {
if (formData.countType === 0) {
// 0
return '物料';
} else if (formData.countType === 1) {
// 1
return '托盘';
}
return '物料'; //
});
const materialPlaceholder = computed(() => {
if (formData.countType === 0) {
return '请输入物料';
} else if (formData.countType === 1) {
return '请输入托盘';
}
return '请输入物料'; //
});
const loading = ref(false);
const formRef = ref();
const countDetailTableRef = ref();
const countDetailTable = reactive<Record<string, any>>({
loading: false,
columns: countDetailColumns,
dataSource: [],
});
const activeKey = ref('countDetail');
// ID
let tenantId = getTenantId();
const formData = reactive<Record<string, any>>({
id: '',
areaId: '',
status: 1,
countType: 0,
description: '',
createTime: dayjs(),
tenantId: tenantId,
});
//
const validatorRules = reactive({
areaId: [{ required: true, message: '库区必填!' }],
countType: [{ required: true, message: '请选择盘点类型!' }],
description: [{ required: true, message: materialPlaceholder }],
});
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();
countDetailTable.dataSource = [];
}
async function edit(row) {
//
await queryMainData(row.id);
//
const countDetailDataList = await queryCountDetailListByMainId(row['id']);
countDetailTable.dataSource = [...countDetailDataList];
}
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, {
countDetail: countDetailTableRef,
});
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() {
//
if (loading.value) {
return;
}
//
loading.value = true;
try {
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');
} catch (error) {
console.error('提交失败:', error);
} finally {
//
loading.value = false;
}
}
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.countDetailList && subData.countDetailList.length > 0) {
countDetailColumns.forEach((subFormField) => {
if (subFormField && subFormField.picker && subFormField.key) {
let subPicker = subFormField.picker;
const subFieldName = subFormField.key;
subData.countDetailList.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 {
countDetailTableRef,
countDetailTable,
validatorRules,
validateInfos,
activeKey,
loading,
formData,
setFieldsValue,
handleFormChange,
formItemLayout,
disabled,
getFormData,
submitForm,
add,
edit,
formRef,
materialLabel,
materialPlaceholder,
};
},
});
</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,73 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" :okText="'保存'" :defaultFullscreen="true" @ok="handleSubmit">
<CountPlanForm ref="formComponent" :formDisabled="formDisabled" :formBpm="false" @success="submitSuccess"></CountPlanForm>
</BasicModal>
</template>
<script lang="ts">
import { ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import CountPlanForm from '@/views/count/components/CountPlanForm.vue';
import { queryCountDetailListByMainId } from '@/views/count/CountPlan.api';
export default {
name: 'CountPlanModal',
components: {
BasicModal,
CountPlanForm,
},
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>

View File

@ -1,6 +1,6 @@
<template>
' <BasicModal v-bind="$attrs" @register="registerModal" :title="title" :okText="'保存'" :defaultFullscreen="true" @ok="handleSubmit">
' <asn-form ref="formComponent" :formDisabled="formDisabled" :formBpm="false" @success="submitSuccess"></asn-form>
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" :okText="'保存'" :defaultFullscreen="true" @ok="handleSubmit">
<asn-form ref="formComponent" :formDisabled="formDisabled" :formBpm="false" @success="submitSuccess"></asn-form>
</BasicModal>
</template>
@ -8,31 +8,34 @@
import { ref, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import AsnForm from './AsnForm.vue';
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
export default {
name: "TestCgMainVxeModal",
name: 'AsnModal',
components: {
BasicModal,
AsnForm
AsnForm,
},
emits: ['register', 'success'],
setup(_p, { emit }) {
const formComponent = ref()
const formComponent = ref();
const isUpdate = ref(true);
const formDisabled = ref(false);
const title = ref('')
const title = ref('');
//
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({confirmLoading: false,showCancelBtn:data?.showFooter,showOkBtn:data?.showFooter});
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)
formComponent.value.edit(data.record);
} else {
formComponent.value.add()
formComponent.value.add();
}
});
@ -44,6 +47,7 @@
emit('success');
closeModal();
}
return {
registerModal,
title,
@ -51,9 +55,9 @@
formDisabled,
handleSubmit,
submitSuccess,
}
}
}
};
},
};
</script>
<style lang="less" scoped>
/** 时间和数字输入框样式 */

View File

@ -11,7 +11,7 @@
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
export default {
name: "TestCgMainVxeModal",
name: "PickModal",
components:{
BasicModal,
PickForm