From 82f0c124b5c32d1f8b01cb59f0ac33150c808a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B7=BB=E7=A0=96-JAVA=5CAdministrator?= <591141169@qq.com> Date: Wed, 10 Jul 2024 14:58:47 +0800 Subject: [PATCH] =?UTF-8?q?BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/formatTime.ts | 20 +- .../orderManage/shift/shift.data.ts | 478 +++++++++--------- 2 files changed, 251 insertions(+), 247 deletions(-) diff --git a/src/utils/formatTime.ts b/src/utils/formatTime.ts index 64bb9c8b3..db7948081 100644 --- a/src/utils/formatTime.ts +++ b/src/utils/formatTime.ts @@ -26,11 +26,10 @@ export function formatDate(date: Date | number, format?: string): string { /** * 获取当前的日期+时间 */ -export function addDay(date: Date | number,addDay:number) { - return dayjs(date).add(addDay,'day') +export function addDay(date: Date | number, addDay: number) { + return dayjs(date).add(addDay, 'day') } - /** * 获取当前的日期+时间 */ @@ -163,6 +162,21 @@ export const dateFormatter = (row, column, cellValue) => { } return formatDate(cellValue) } +/** + * element plus 的时间 Formatter 实现,使用 YYYY-MM-DD HH:mm:ss 格式 + * + * @param row 行数据 + * @param column 字段 + * @param cellValue 字段值 + */ +// @ts-ignore +export const dateFormatter3 = (row, column, cellValue) => { + if (!cellValue) { + return + } + let str = formatDate(cellValue).split(' ')[1] + return str +} // 获取时间戳 export const formatGetTime = (row, column, cellValue) => { console.log(cellValue.getTime()) diff --git a/src/views/wms/basicDataManage/orderManage/shift/shift.data.ts b/src/views/wms/basicDataManage/orderManage/shift/shift.data.ts index df23c425a..045efa49a 100644 --- a/src/views/wms/basicDataManage/orderManage/shift/shift.data.ts +++ b/src/views/wms/basicDataManage/orderManage/shift/shift.data.ts @@ -1,283 +1,273 @@ import type { CrudSchema } from '@/hooks/web/useCrudSchemas' -import { dateFormatter } from '@/utils/formatTime' +import { dateFormatter, dateFormatter3 } from '@/utils/formatTime' const { t } = useI18n() // 国际化 -import {validateYS} from '@/utils/validator' +import { validateYS } from '@/utils/validator' /** * @returns {Array} 班次 */ -export const Shift = useCrudSchemas(reactive([ - { - label: '代码', - field: 'code', - sort: 'custom', - table: { - width: 150, - fixed: 'left' +export const Shift = useCrudSchemas( + reactive([ + { + label: '代码', + field: 'code', + sort: 'custom', + table: { + width: 150, + fixed: 'left' + }, + isSearch: true }, - isSearch: true, - }, - { - label: '名称', - field: 'name', - sort: 'custom', - table: { - width: 150 - }, - }, - { - label: '开始时间', - field: 'beginTime', - isTable: true, - formatter: dateFormatter, - detail: { - dateFormat: 'HH:mm:ss' - }, - sort: 'custom', - table: { - width: 180, - }, - form: { - component: 'TimePicker', - componentProps: { - style: {width:'100%'}, - type: 'time', - dateFormat: 'HH:mm:ss', - valueFormat: 'x', + { + label: '名称', + field: 'name', + sort: 'custom', + table: { + width: 150 } }, - isSearch: false, - search: { - show: false, - component: 'TimePicker', - componentProps: { - valueFormat: 'HH:mm:ss', - type: 'timeSelect', + { + label: '开始时间', + field: 'beginTime', + isTable: true, + formatter: dateFormatter3, + detail: { + dateFormat: 'HH:mm:ss' + }, + sort: 'custom', + table: { + width: 180 + }, + form: { + component: 'TimePicker', + componentProps: { + style: { width: '100%' }, + type: 'time', + dateFormat: 'HH:mm:ss', + valueFormat: 'x' + } + }, + isSearch: false, + search: { + show: false, + component: 'TimePicker', + componentProps: { + valueFormat: 'HH:mm:ss', + type: 'timeSelect' + } } - } - }, - { - label: '结束时间', - field: 'entTime', - isTable: true, - formatter: dateFormatter, - detail: { - dateFormat: 'HH:mm:ss', - }, - sort: 'custom', - table: { - width: 180 }, - form: { - component: 'TimePicker', - componentProps: { - style: {width:'100%'}, - type: 'time', - dateFormat: 'HH:mm:ss', - valueFormat: 'x', + { + label: '结束时间', + field: 'entTime', + isTable: true, + formatter: dateFormatter3, + detail: { + dateFormat: 'HH:mm:ss' + }, + sort: 'custom', + table: { + width: 180 + }, + form: { + component: 'TimePicker', + componentProps: { + style: { width: '100%' }, + type: 'time', + dateFormat: 'HH:mm:ss', + valueFormat: 'x' + } + }, + isSearch: false, + search: { + show: false, + component: 'TimePicker', + componentProps: { + valueFormat: 'HH:mm:ss', + type: 'timeSelect' + } } }, - isSearch: false, - search: { - show: false, - component: 'TimePicker', - componentProps: { - valueFormat: 'HH:mm:ss', - type: 'timeSelect', + { + label: '是否跨天', + field: 'endAtNextDay', + dictType: DICT_TYPE.TRUE_FALSE, + dictClass: 'string', + isTable: true, + sort: 'custom', + table: { + width: 150 + }, + form: { + component: 'Switch', + value: 'TRUE', + componentProps: { + inactiveValue: 'FALSE', + activeValue: 'TRUE' + } } - } - }, - { - label: '是否跨天', - field: 'endAtNextDay', - dictType: DICT_TYPE.TRUE_FALSE, - dictClass: 'string', - isTable: true, - sort: 'custom', - table: { - width: 150 }, - form: { - component: 'Switch', - value: 'TRUE', - componentProps: { - inactiveValue: 'FALSE', - activeValue: 'TRUE' + { + label: '是否可用', + field: 'available', + dictType: DICT_TYPE.TRUE_FALSE, + dictClass: 'string', + isTable: true, + isSearch: true, + sort: 'custom', + table: { + width: 150 + }, + form: { + component: 'Switch', + value: 'TRUE', + componentProps: { + inactiveValue: 'FALSE', + activeValue: 'TRUE' + } } }, - }, - { - label: '是否可用', - field: 'available', - dictType: DICT_TYPE.TRUE_FALSE, - dictClass: 'string', - isTable: true, - isSearch: true, - sort: 'custom', - table: { - width: 150 - }, - form: { - component: 'Switch', - value: 'TRUE', - componentProps: { - inactiveValue: 'FALSE', - activeValue: 'TRUE' + { + label: '生效时间', + field: 'activeTime', + isTable: true, + formatter: dateFormatter, + detail: { + dateFormat: 'YYYY-MM-DD HH:mm:ss' + }, + sort: 'custom', + table: { + width: 180 + }, + form: { + component: 'DatePicker', + componentProps: { + style: { width: '100%' }, + type: 'datetime', + dateFormat: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x' + } } }, - }, - { - label: '生效时间', - field: 'activeTime', - isTable: true, - formatter: dateFormatter, - detail: { - dateFormat: 'YYYY-MM-DD HH:mm:ss' - }, - sort: 'custom', - table: { - width: 180 - }, - form: { - component: 'DatePicker', - componentProps: { - style: {width:'100%'}, - type: 'datetime', - dateFormat: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'x', + { + label: '失效时间', + field: 'expireTime', + isTable: true, + formatter: dateFormatter, + detail: { + dateFormat: 'YYYY-MM-DD HH:mm:ss' + }, + sort: 'custom', + table: { + width: 180 + }, + form: { + component: 'DatePicker', + componentProps: { + style: { width: '100%' }, + type: 'datetime', + dateFormat: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x' + } } }, - }, - { - label: '失效时间', - field: 'expireTime', - isTable: true, - formatter: dateFormatter, - detail: { - dateFormat: 'YYYY-MM-DD HH:mm:ss' - }, - sort: 'custom', - table: { - width: 180 - }, - form: { - component: 'DatePicker', - componentProps: { - style: {width:'100%'}, - type: 'datetime', - dateFormat: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'x', + { + label: '备注', + field: 'remark', + sort: 'custom', + table: { + width: 150 } }, - }, - { - label: '备注', - field: 'remark', - sort: 'custom', - table: { - width: 150 - }, - }, - { - label: '创建时间', - field: 'createTime', - isForm: false, - table: { - width: 180 + { + label: '创建时间', + field: 'createTime', + isForm: false, + table: { + width: 180 + }, + formatter: dateFormatter, + detail: { + dateFormat: 'YYYY-MM-DD HH:mm:ss' + }, + form: { + component: 'DatePicker', + componentProps: { + style: { width: '100%' }, + type: 'datetime', + dateFormat: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x' + } + } }, - formatter: dateFormatter, - detail: { - dateFormat : 'YYYY-MM-DD HH:mm:ss' + { + label: '创建者', + field: 'creator', + table: { + width: 130 + }, + isForm: false, + isTable: true }, - form: { - component: 'DatePicker', - componentProps: { - style: {width:'100%'}, - type: 'datetime', - dateFormat: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'x', + { + label: '最后更新时间', + field: 'updateTime', + sort: 'custom', + isDetail: true, + isForm: false, + isTable: false, + formatter: dateFormatter, + detail: { + dateFormat: 'YYYY-MM-DD HH:mm:ss' + }, + table: { + width: 180 + }, + form: { + component: 'DatePicker', + componentProps: { + style: { width: '100%' }, + type: 'datetime', + dateFormat: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x' + } } - } - }, - { - label: '创建者', - field: 'creator', - table: { - width: 130 - }, - isForm: false, - isTable: true - }, - { - label: '最后更新时间', - field: 'updateTime', - sort: 'custom', - isDetail: true, - isForm: false, - isTable: false, - formatter: dateFormatter, - detail: { - dateFormat: 'YYYY-MM-DD HH:mm:ss' }, - table: { - width: 180 + { + label: '最后更新者', + field: 'updater', + isDetail: true, + isForm: false, + isTable: false, + table: { + width: 150 + } }, - form: { - component: 'DatePicker', - componentProps: { - style: {width:'100%'}, - type: 'datetime', - dateFormat: 'YYYY-MM-DD HH:mm:ss', - valueFormat: 'x', + { + label: '操作', + field: 'action', + isDetail: false, + isForm: false, + table: { + width: 150, + fixed: 'right' } } - }, - { - label: '最后更新者', - field: 'updater', - isDetail: true, - isForm: false, - isTable: false, - table: { - width: 150 - } - }, - { - label: '操作', - field: 'action', - isDetail: false, - isForm: false , - table: { - width: 150, - fixed: 'right' - } - } -])) + ]) +) //表单校验 export const ShiftRules = reactive({ code: [ { required: true, message: '请输入代码', trigger: 'blur' }, { max: 50, message: '不得超过50个字符', trigger: 'blur' }, - { validator:validateYS, message: '请输入正确的代码', trigger: 'blur'} - ], - name: [ - { max: 50, message: '不得超过50个字符', trigger: 'blur' } - ], - remark: [ - { max: 50, message: '不得超过50个字符', trigger: 'blur' } - ], - beginTime: [ - { required: true, message: '请输入开始时间', trigger: 'blur' } - ], - entTime: [ - { required: true, message: '请输入结束时间', trigger: 'blur' } - ], - endAtNextDay: [ - { required: true, message: '请选择是否跨天', trigger: 'change' } - ], - available: [ - { required: true, message: '请选择是否可用', trigger: 'change' } + { validator: validateYS, message: '请输入正确的代码', trigger: 'blur' } ], + name: [{ max: 50, message: '不得超过50个字符', trigger: 'blur' }], + remark: [{ max: 50, message: '不得超过50个字符', trigger: 'blur' }], + beginTime: [{ required: true, message: '请输入开始时间', trigger: 'blur' }], + entTime: [{ required: true, message: '请输入结束时间', trigger: 'blur' }], + endAtNextDay: [{ required: true, message: '请选择是否跨天', trigger: 'change' }], + available: [{ required: true, message: '请选择是否可用', trigger: 'change' }] })