feat(任务管理): 优化时间筛选功能并重构提交逻辑

- 新增创建时间范围筛选组件,统一使用秒级精度展示和查询
- 重构表单提交逻辑,分离展示字段与业务字段
main
zch 2 months ago
parent 8e5819858f
commit 03a8a162ba

@ -105,8 +105,8 @@ export interface TaskQueueVO {
*/
updatedTime: string;
/** 实时任务明细列表 */
details: TaskDetailVO[];
/** 实时任务明细列表;列表接口不挂载明细,详情接口按需返回。 */
details?: TaskDetailVO[];
/** 创建人 */
createdBy: string | number;

@ -15,6 +15,18 @@
<el-option v-for="dict in wcs_location_status" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
</el-select>
</el-form-item>
<el-form-item label="创建时间" style="width: 410px">
<el-date-picker
v-model="dateRange"
:format="CREATED_TIME_PICKER_FORMAT"
:value-format="CREATED_TIME_VALUE_FORMAT"
type="datetimerange"
range-separator="-"
start-placeholder="开始时间"
end-placeholder="结束时间"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
@ -68,9 +80,9 @@
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="创建时间" align="center" prop="createdTime" width="100">
<el-table-column label="创建时间" align="center" prop="createdTime" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.createdTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.createdTime, CREATED_TIME_DISPLAY_FORMAT) }}</span>
</template>
</el-table-column>
<el-table-column label="创建人" align="center" prop="createdByName" width="100" />
@ -190,6 +202,12 @@ import { getMaterialInfoList } from '@/api/wcs/materialInfo';
import { LocationInfoVO, LocationInfoQuery, LocationInfoForm } from '@/api/wcs/locationInfo/types';
import { StoreInfoVO } from '@/api/wcs/storeInfo/types';
import { MaterialInfoVO } from '@/api/wcs/materialInfo/types';
import {
CREATED_TIME_DISPLAY_FORMAT,
CREATED_TIME_PICKER_FORMAT,
CREATED_TIME_VALUE_FORMAT,
getTodayCreatedTimeRange
} from '../utils/createdTimeRange';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { wcs_location_status, wcs_is_flag } = toRefs<any>(proxy?.useDict('wcs_location_status', 'wcs_is_flag'));
@ -205,6 +223,9 @@ const single = ref(true);
const multiple = ref(true);
const total = ref(0);
// SysUser addDateRange params.beginTime/endTime
const dateRange = ref<[string, string]>(getTodayCreatedTimeRange());
const queryFormRef = ref<ElFormInstance>();
const locationInfoFormRef = ref<ElFormInstance>();
@ -280,7 +301,8 @@ const { queryParams, form, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
const res = await listLocationInfo(queryParams.value);
// addDateRange params.beginTime/endTime SysUser
const res = await listLocationInfo(proxy?.addDateRange(queryParams.value, dateRange.value));
locationInfoList.value = res.rows;
total.value = res.total;
loading.value = false;
@ -318,6 +340,8 @@ const handleQuery = () => {
const resetQuery = () => {
queryFormRef.value?.resetFields();
//
dateRange.value = getTodayCreatedTimeRange();
handleQuery();
}
@ -344,14 +368,34 @@ const handleUpdate = async (row?: LocationInfoVO) => {
dialog.title = "修改库位信息";
}
const buildSubmitData = (): LocationInfoForm => ({
objId: form.value.objId,
locationCode: form.value.locationCode,
locationName: form.value.locationName,
locationArea: form.value.locationArea,
storeCode: form.value.storeCode,
locationRows: form.value.locationRows,
locationColumns: form.value.locationColumns,
locationLayers: form.value.locationLayers,
agvPosition: form.value.agvPosition,
materialCode: form.value.materialCode,
palletBarcode: form.value.palletBarcode,
stackCount: form.value.stackCount,
locationStatus: form.value.locationStatus,
isFlag: form.value.isFlag,
remark: form.value.remark
});
const submitForm = () => {
locationInfoFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.objId) {
await updateLocationInfo(form.value).finally(() => buttonLoading.value = false);
//
const submitData = buildSubmitData();
if (submitData.objId) {
await updateLocationInfo(submitData).finally(() => buttonLoading.value = false);
} else {
await addLocationInfo(form.value).finally(() => buttonLoading.value = false);
await addLocationInfo(submitData).finally(() => buttonLoading.value = false);
}
proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false;

@ -15,6 +15,18 @@
<el-option v-for="dict in wcs_is_flag" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
</el-select>
</el-form-item>
<el-form-item label="创建时间" style="width: 308px">
<el-date-picker
v-model="dateRange"
:format="CREATED_TIME_PICKER_FORMAT"
:value-format="CREATED_TIME_VALUE_FORMAT"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
@ -54,9 +66,9 @@
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="创建时间" align="center" prop="createdTime" width="100">
<el-table-column label="创建时间" align="center" prop="createdTime" width="150">
<template #default="scope">
<span>{{ parseTime(scope.row.createdTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.createdTime, CREATED_TIME_DISPLAY_FORMAT) }}</span>
</template>
</el-table-column>
<el-table-column label="创建人" align="center" prop="createdByName" width="100" />
@ -149,6 +161,12 @@
import { listPathInfo, getPathInfo, delPathInfo, addPathInfo, updatePathInfo } from '@/api/wcs/pathInfo';
import { PathInfoVO, PathInfoQuery, PathInfoForm } from '@/api/wcs/pathInfo/types';
import type { PathDetailsForm } from '@/api/wcs/pathDetails/types';
import {
CREATED_TIME_DISPLAY_FORMAT,
CREATED_TIME_PICKER_FORMAT,
CREATED_TIME_VALUE_FORMAT,
getTodayCreatedTimeRange
} from '../utils/createdTimeRange';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { wcs_is_flag } = toRefs<any>(proxy?.useDict('wcs_is_flag'));
@ -164,6 +182,9 @@ const single = ref(true);
const multiple = ref(true);
const total = ref(0);
// SysUser addDateRange params.beginTime/endTime
const dateRange = ref<[string, string]>(getTodayCreatedTimeRange());
const queryFormRef = ref<ElFormInstance>();
const pathInfoFormRef = ref<ElFormInstance>();
@ -200,7 +221,8 @@ const { queryParams, form, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
const res = await listPathInfo(queryParams.value);
// addDateRange params.beginTime/endTime SysUser
const res = await listPathInfo(proxy?.addDateRange(queryParams.value, dateRange.value));
pathInfoList.value = res.rows;
total.value = res.total;
loading.value = false;
@ -225,6 +247,8 @@ const handleQuery = () => {
const resetQuery = () => {
queryFormRef.value?.resetFields();
//
dateRange.value = getTodayCreatedTimeRange();
handleQuery();
}
@ -267,16 +291,32 @@ const handleDelDetail = (index: number) => {
detailList.value.splice(index, 1);
}
const buildSubmitData = (): PathInfoForm => ({
objId: form.value.objId,
pathCode: form.value.pathCode,
pathName: form.value.pathName,
isFlag: form.value.isFlag,
remark: form.value.remark,
// /
details: detailList.value.map((item) => ({
objId: item.objId,
pathCode: form.value.pathCode || '',
startPoint: item.startPoint,
endPoint: item.endPoint,
isFlag: item.isFlag,
remark: item.remark
}))
});
const submitForm = () => {
pathInfoFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
// Bo.details
form.value.details = detailList.value;
if (form.value.objId) {
await updatePathInfo(form.value).finally(() => buttonLoading.value = false);
const submitData = buildSubmitData();
if (submitData.objId) {
await updatePathInfo(submitData).finally(() => buttonLoading.value = false);
} else {
await addPathInfo(form.value).finally(() => buttonLoading.value = false);
await addPathInfo(submitData).finally(() => buttonLoading.value = false);
}
proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false;

@ -23,6 +23,18 @@
<el-option v-for="dict in wcs_task_status" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
</el-select>
</el-form-item>
<el-form-item label="创建时间" style="width: 410px">
<el-date-picker
v-model="dateRange"
:format="CREATED_TIME_PICKER_FORMAT"
:value-format="CREATED_TIME_VALUE_FORMAT"
type="datetimerange"
range-separator="-"
start-placeholder="开始时间"
end-placeholder="结束时间"
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
@ -89,9 +101,9 @@
<dict-tag :options="wcs_is_flag" :value="scope.row.isFlag" />
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createdTime" width="100">
<el-table-column label="创建时间" align="center" prop="createdTime" width="180">
<template #default="scope">
<span>{{ parseTime(scope.row.createdTime, '{y}-{m}-{d}') }}</span>
<span>{{ parseTime(scope.row.createdTime, CREATED_TIME_DISPLAY_FORMAT) }}</span>
</template>
</el-table-column>
<el-table-column label="创建人" align="center" prop="createdByName" width="100" />
@ -134,7 +146,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="物料条码" prop="materialBarcode">
<el-input v-model="form.materialBarcode" placeholder="请输入物料条码" />
<el-input v-model="form.materialBarcode" placeholder="物料条码" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
@ -218,6 +230,12 @@ import { getMaterialInfoList } from '@/api/wcs/materialInfo';
import { MaterialInfoVO } from '@/api/wcs/materialInfo/types';
import { getPathInfoList } from '@/api/wcs/pathInfo';
import { PathInfoVO } from '@/api/wcs/pathInfo/types';
import {
CREATED_TIME_DISPLAY_FORMAT,
CREATED_TIME_PICKER_FORMAT,
CREATED_TIME_VALUE_FORMAT,
getTodayCreatedTimeRange
} from '../utils/createdTimeRange';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { wcs_is_flag, wcs_task_category, wcs_task_type, wcs_task_status } = toRefs<any>(
@ -235,6 +253,9 @@ const single = ref(true);
const multiple = ref(true);
const total = ref(0);
// SysUser addDateRange params.beginTime/endTime
const dateRange = ref<[string, string]>(getTodayCreatedTimeRange());
const queryFormRef = ref<ElFormInstance>();
const taskDetailFormRef = ref<ElFormInstance>();
@ -293,7 +314,8 @@ const { queryParams, form, rules } = toRefs(data);
const getList = async () => {
loading.value = true;
try {
const res = await listTaskDetail(queryParams.value);
// addDateRange params.beginTime/endTime SysUser
const res = await listTaskDetail(proxy?.addDateRange(queryParams.value, dateRange.value));
taskDetailList.value = res.rows;
total.value = res.total;
} finally {
@ -319,8 +341,8 @@ const loadFormOptions = async () => {
const handleMaterialChange = (materialCode?: string) => {
const material = materialList.value.find(item => item.materialCode === materialCode);
//
form.value.materialBarcode = material?.materialBarcode || form.value.materialBarcode;
//
form.value.materialBarcode = material?.materialBarcode;
}
const cancel = () => {
@ -340,6 +362,8 @@ const handleQuery = () => {
const resetQuery = () => {
queryFormRef.value?.resetFields();
//
dateRange.value = getTodayCreatedTimeRange();
handleQuery();
}
@ -366,14 +390,34 @@ const handleUpdate = async (row?: TaskDetailVO) => {
dialog.title = "修改实时任务明细";
}
const buildSubmitData = (): TaskDetailForm => ({
objId: form.value.objId,
taskCode: form.value.taskCode,
materialCode: form.value.materialCode,
palletBarcode: form.value.palletBarcode,
materialBarcode: form.value.materialBarcode,
materialCount: form.value.materialCount,
taskType: form.value.taskType,
taskCategory: form.value.taskCategory,
startPoint: form.value.startPoint,
endPoint: form.value.endPoint,
isValidate: form.value.isValidate,
pathCode: form.value.pathCode,
taskStatus: form.value.taskStatus,
isFlag: form.value.isFlag,
remark: form.value.remark
});
const submitForm = () => {
taskDetailFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.objId) {
await updateTaskDetail(form.value).finally(() => buttonLoading.value = false);
//
const submitData = buildSubmitData();
if (submitData.objId) {
await updateTaskDetail(submitData).finally(() => buttonLoading.value = false);
} else {
await addTaskDetail(form.value).finally(() => buttonLoading.value = false);
await addTaskDetail(submitData).finally(() => buttonLoading.value = false);
}
proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false;

@ -0,0 +1,19 @@
// WCS 任务与库位排查常按秒定位新增/流转记录,前端展示和查询统一保留秒级精度。
export const CREATED_TIME_DISPLAY_FORMAT = '{y}-{m}-{d} {h}:{i}:{s}';
export const CREATED_TIME_PICKER_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export const CREATED_TIME_VALUE_FORMAT = 'YYYY-MM-DD HH:mm:ss';
const formatDateTime = (date: Date) => {
const pad = (value: number) => `${value}`.padStart(2, '0');
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
};
export const getTodayCreatedTimeRange = (): [string, string] => {
const now = new Date();
const startTime = new Date(now);
const endTime = new Date(now);
startTime.setHours(0, 0, 0, 0);
endTime.setHours(23, 59, 59, 999);
// 默认筛今天完整区间,避免页面打开后新增的数据因为超过旧结束时间而查不到。
return [formatDateTime(startTime), formatDateTime(endTime)];
};
Loading…
Cancel
Save