fix 时间数据格式化

This commit is contained in:
admin 2024-07-20 16:34:44 +08:00
parent 88a7428ed6
commit b99d776016
12 changed files with 60 additions and 30 deletions

View File

@ -66,6 +66,7 @@ import ProductDialog from "./components/ProductDialog.vue";
import { formatDate, getCurrentMonthStartAndEnd } from "@/utils"; import { formatDate, getCurrentMonthStartAndEnd } from "@/utils";
import { ShipmentApi } from "@/services"; import { ShipmentApi } from "@/services";
import _ from "underscore"; import _ from "underscore";
import {formatStartAndEndTime} from "@/utils";
const getOptions = (x: Array<any>, y: Array<any>) => { const getOptions = (x: Array<any>, y: Array<any>) => {
return { return {
tooltip: { tooltip: {
@ -158,8 +159,8 @@ const handleDialog = (key: string, v: boolean) => {
}; };
const getList = () => { const getList = () => {
let params: any = { let params: any = {
startTime: state.startTime + " 00:00:00", startTime: formatStartAndEndTime(state.startTime, 's'),
endTime: state.endTime + " 23:59:59", endTime: formatStartAndEndTime(state.endTime, 'e'),
}; };
if (state.scaleStatus > -1) { if (state.scaleStatus > -1) {
params.scaleStatus = state.scaleStatus; params.scaleStatus = state.scaleStatus;

View File

@ -185,8 +185,14 @@ const state = reactive<{
averagePrice: 0, // averagePrice: 0, //
rankings: [], rankings: [],
}, },
startTime: formatDate(getCurrentMonthStartAndEnd().start, "{y}-{m}-{d} {h}:{i}:{s}"), startTime: formatDate(
endTime: formatDate(getCurrentMonthStartAndEnd().end, "{y}-{m}-{d} {h}:{i}:{s}"), getCurrentMonthStartAndEnd().start,
"{y}-{m}-{d} {h}:{i}:{s}"
),
endTime: formatDate(
getCurrentMonthStartAndEnd().end,
"{y}-{m}-{d} {h}:{i}:{s}"
),
scaleStatus: -1, scaleStatus: -1,
userId: -1, userId: -1,
productId: -1, productId: -1,
@ -210,8 +216,8 @@ const handleDialog = (key: string, v: boolean) => {
const getList = () => { const getList = () => {
let params: any = { let params: any = {
startTime: state.startTime + " 00:00:00", startTime: state.startTime,
endTime: state.endTime + " 23:59:59", endTime: state.endTime,
}; };
if (state.scaleStatus > -1) { if (state.scaleStatus > -1) {
params.scaleStatus = state.scaleStatus; params.scaleStatus = state.scaleStatus;

View File

@ -61,7 +61,7 @@ import TimeDialog from "@/components/Dialog/TimeDialog.vue";
import CEcharts from "./Echarts/echarts.vue"; import CEcharts from "./Echarts/echarts.vue";
import ProductDialog from "./components/ProductDialog.vue"; import ProductDialog from "./components/ProductDialog.vue";
import { ReceiveApi } from "@/services"; import { ReceiveApi } from "@/services";
import { formatDate, getCurrentMonthStartAndEnd } from "@/utils"; import { formatDate, getCurrentMonthStartAndEnd, formatStartAndEndTime } from "@/utils";
import _ from "underscore"; import _ from "underscore";
const getOptions = (x: Array<any>, y: Array<any>) => { const getOptions = (x: Array<any>, y: Array<any>) => {
return { return {
@ -156,8 +156,8 @@ const changeTime = (obj: any) => {
const getList = () => { const getList = () => {
let params: any = { let params: any = {
startTime: state.startTime + " 00:00:00", startTime: formatStartAndEndTime(state.startTime, 's'),
endTime: state.endTime + " 23:59:59", endTime: formatStartAndEndTime(state.endTime, 's'),
}; };
if (state.scaleStatus > -1) { if (state.scaleStatus > -1) {
params.scaleStatus = state.scaleStatus; params.scaleStatus = state.scaleStatus;

View File

@ -112,7 +112,11 @@
<script setup lang="ts"> <script setup lang="ts">
import { FinanceApi } from "@/services"; import { FinanceApi } from "@/services";
import PageView from "@/components/PageView/index.vue"; import PageView from "@/components/PageView/index.vue";
import { formatDate, getCurrentMonthStartAndEnd } from "@/utils"; import {
formatDate,
getCurrentMonthStartAndEnd,
formatStartAndEndTime,
} from "@/utils";
import TimeDialog from "@/components/Dialog/TimeDialog.vue"; import TimeDialog from "@/components/Dialog/TimeDialog.vue";
import FilterDialog from "./components/CustomFilterDialog.vue"; import FilterDialog from "./components/CustomFilterDialog.vue";
import { onShow } from "@dcloudio/uni-app"; import { onShow } from "@dcloudio/uni-app";
@ -238,8 +242,8 @@ const getList = (v?: boolean) => {
let params: any = { let params: any = {
pageSize: pageList.pageSize, pageSize: pageList.pageSize,
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
startTime: state.startTime + " 00:00:00", startTime: formatStartAndEndTime(state.startTime, 's'),
endTime: state.endTime + " 23:59:59", endTime: formatStartAndEndTime(state.endTime, 'e'),
oddNumbers: keyword.value, oddNumbers: keyword.value,
}; };
if (state.currentPaymentType > -1) { if (state.currentPaymentType > -1) {

View File

@ -107,7 +107,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { FinanceApi } from "@/services"; import { FinanceApi } from "@/services";
import PageView from "@/components/PageView/index.vue"; import PageView from "@/components/PageView/index.vue";
import { formatDate, getCurrentMonthStartAndEnd } from "@/utils"; import { formatDate, getCurrentMonthStartAndEnd, formatStartAndEndTime } from "@/utils";
import TimeDialog from "@/components/Dialog/TimeDialog.vue"; import TimeDialog from "@/components/Dialog/TimeDialog.vue";
import FilterDialog from "./components/CustomFilterDialog.vue"; import FilterDialog from "./components/CustomFilterDialog.vue";
import { onShow } from "@dcloudio/uni-app"; import { onShow } from "@dcloudio/uni-app";
@ -242,8 +242,8 @@ const getList = (v?: boolean) => {
let params: any = { let params: any = {
pageSize: pageList.pageSize, pageSize: pageList.pageSize,
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
startTime: state.startTime + " 00:00:00", startTime: formatStartAndEndTime(state.startTime, 's'),
endTime: state.endTime + " 23:59:59", endTime: formatStartAndEndTime(state.endTime, 'e'),
oddNumbers: keyword.value, oddNumbers: keyword.value,
}; };
if (state.currentPaymentType > -1) { if (state.currentPaymentType > -1) {

View File

@ -158,6 +158,7 @@ import {
formatDate, formatDate,
getCurrentMonthStartAndEnd, getCurrentMonthStartAndEnd,
filterNullUndefined, filterNullUndefined,
formatStartAndEndTime
} from "@/utils"; } from "@/utils";
import TimeDialog from "@/components/Dialog/TimeDialog.vue"; import TimeDialog from "@/components/Dialog/TimeDialog.vue";
import FilterDialog from "./components/FilterDialog.vue"; import FilterDialog from "./components/FilterDialog.vue";
@ -375,8 +376,8 @@ const getList = (v?: boolean) => {
let params: any = { let params: any = {
pageSize: pageList.pageSize, pageSize: pageList.pageSize,
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
startTime: state.startTime + " 00:00:00", startTime: formatStartAndEndTime(state.startTime, 's'),
endTime: state.endTime + " 23:59:59", endTime: formatStartAndEndTime(state.endTime, 'e'),
}; };
if (state.currentScaleStatus > -1) { if (state.currentScaleStatus > -1) {
params.scaleStatus = state.currentScaleStatus; params.scaleStatus = state.currentScaleStatus;

View File

@ -173,6 +173,7 @@ import {
formatDate, formatDate,
getCurrentMonthStartAndEnd, getCurrentMonthStartAndEnd,
filterNullUndefined, filterNullUndefined,
formatStartAndEndTime
} from "@/utils"; } from "@/utils";
import TimeDialog from "@/components/Dialog/TimeDialog.vue"; import TimeDialog from "@/components/Dialog/TimeDialog.vue";
import FilterDialog from "./components/FilterDialog.vue"; import FilterDialog from "./components/FilterDialog.vue";
@ -408,8 +409,8 @@ const getList = (v?: boolean) => {
let params: any = { let params: any = {
pageSize: pageList.pageSize, pageSize: pageList.pageSize,
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
startTime: state.startTime + " 00:00:00", startTime: formatStartAndEndTime(state.startTime, 's'),
endTime: state.endTime + " 23:59:59", endTime: formatStartAndEndTime(state.endTime, 'e'),
}; };
if (state.currentScaleStatus > -1) { if (state.currentScaleStatus > -1) {
params.scaleStatus = state.currentScaleStatus; params.scaleStatus = state.currentScaleStatus;

View File

@ -62,6 +62,7 @@ import PageView from "@/components/PageView/index.vue";
import { ScaleStatus } from "@/utils/enum"; import { ScaleStatus } from "@/utils/enum";
import TimeDialog from "@/components/Dialog/TimeDialog.vue"; import TimeDialog from "@/components/Dialog/TimeDialog.vue";
import Detail from "./components/detail.vue"; import Detail from "./components/detail.vue";
import {formatStartAndEndTime} from "@/utils";
// //
const filterState = reactive({ const filterState = reactive({
showTime: false, showTime: false,
@ -117,8 +118,8 @@ const getList = (v?: boolean) => {
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
scaleStatus: ScaleStatus.Paid, scaleStatus: ScaleStatus.Paid,
userName: keyword.value, userName: keyword.value,
startTime: filterState.startTime ? `${filterState.startTime} 00:00:00` : "", startTime: formatStartAndEndTime(filterState.startTime, 's'),
endTime: filterState.startTime ? `${filterState.endTime} 00:00:00` : "", endTime: formatStartAndEndTime(filterState.endTime, 'e'),
}).then((res: any) => { }).then((res: any) => {
if (res.code === 200) { if (res.code === 200) {
pageList.isLoading = false; pageList.isLoading = false;

View File

@ -320,8 +320,8 @@ const getList = (v?: boolean) => {
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
scaleStatus: currentTab.value, scaleStatus: currentTab.value,
userName: keyword.value, userName: keyword.value,
startTime: filterState.startTime ? `${filterState.startTime} 00:00:00` : '', startTime: filterState.startTime ? `${filterState.startTime}` : '',
endTime: filterState.startTime ? `${filterState.endTime} 00:00:00` : '', endTime: filterState.startTime ? `${filterState.endTime}` : '',
}).then((res: any) => { }).then((res: any) => {
if (res.code === 200) { if (res.code === 200) {
pageList.isLoading = false; pageList.isLoading = false;

View File

@ -57,11 +57,12 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ShipmentApi } from "@/services/index"; import { ShipmentApi } from "@/services/index";
import { ScaleStatus, ScaleStatusBtnType } from "@/utils/enum"; import { ScaleStatus } from "@/utils/enum";
import { onShow } from "@dcloudio/uni-app"; import { onShow } from "@dcloudio/uni-app";
import PageView from "@/components/PageView/index.vue"; import PageView from "@/components/PageView/index.vue";
import TimeDialog from "@/components/Dialog/TimeDialog.vue"; import TimeDialog from "@/components/Dialog/TimeDialog.vue";
import ReceivedDetail from "./components/receivedDetail.vue"; import ReceivedDetail from "./components/receivedDetail.vue";
import {formatStartAndEndTime} from "@/utils";
// //
const filterState = reactive({ const filterState = reactive({
showTime: false, showTime: false,
@ -115,8 +116,8 @@ const getList = (v?: boolean) => {
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
scaleStatus: ScaleStatus.ToBeShipmentReview, scaleStatus: ScaleStatus.ToBeShipmentReview,
userName: keyword.value, userName: keyword.value,
startTime: filterState.startTime ? `${filterState.startTime} 00:00:00` : "", startTime: formatStartAndEndTime(filterState.startTime, 's'),
endTime: filterState.startTime ? `${filterState.endTime} 00:00:00` : "", endTime: formatStartAndEndTime(filterState.endTime, 'e'),
}).then((res) => { }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
pageList.isLoading = false; pageList.isLoading = false;

View File

@ -135,11 +135,11 @@
<script setup lang="ts"> <script setup lang="ts">
import { ShipmentApi } from "@/services/index"; import { ShipmentApi } from "@/services/index";
import { ScaleStatus, ScaleStatusBtnType } from "@/utils/enum"; import { ScaleStatus, ScaleStatusBtnType } from "@/utils/enum";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad, onShow } from "@dcloudio/uni-app";
import { onShow } from "@dcloudio/uni-app";
import PageView from "@/components/PageView/index.vue"; import PageView from "@/components/PageView/index.vue";
import type { ComType } from "@/types/global"; import type { ComType } from "@/types/global";
import TimeDialog from "@/components/Dialog/TimeDialog.vue"; import TimeDialog from "@/components/Dialog/TimeDialog.vue";
import {formatStartAndEndTime} from "@/utils";
// //
const filterState = reactive({ const filterState = reactive({
showTime: false, showTime: false,
@ -292,8 +292,8 @@ const getList = (v?: boolean) => {
pageNumber: pageList.pageNum, pageNumber: pageList.pageNum,
scaleStatus: ScaleStatus.ToBeShipmentReview, scaleStatus: ScaleStatus.ToBeShipmentReview,
userName: keyword.value, userName: keyword.value,
startTime: filterState.startTime ? `${filterState.startTime} 00:00:00` : "", startTime: formatStartAndEndTime(filterState.startTime, 's'),
endTime: filterState.startTime ? `${filterState.endTime} 00:00:00` : "", endTime: formatStartAndEndTime(filterState.endTime, 'e'),
}).then((res) => { }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
pageList.isLoading = false; pageList.isLoading = false;

View File

@ -307,3 +307,18 @@ export function getScaleStatus(type: number, value: number) {
} }
} }
} }
// 判断是否是时间格式
export function isDateTimePicker(str: any) {
return str.split(' ').length === 2
}
// 格式化开始时间和结束时间
export function formatStartAndEndTime(str:string, type:string) {
if (type === 's') {
return str ? isDateTimePicker(str) ? str : (str + " 00:00:00") : ''
}else if (type === 'e') {
return str ? isDateTimePicker(str) ? str : (str + " 23:59:59") : ''
}
}