维修app创建工单时的bug修复

This commit is contained in:
许允枞 2024-10-21 18:11:30 +08:00
parent 1d401a0581
commit f9fcc0f7ec
9 changed files with 628 additions and 89 deletions

View File

@ -0,0 +1,270 @@
<template>
<view class="orderCard">
<!-- <view class="order-top">-->
<!--&lt;!&ndash; <view class="orderNo">&ndash;&gt;-->
<!--&lt;!&ndash; 工单编号{{ order.orderNo }}&ndash;&gt;-->
<!--&lt;!&ndash; </view>&ndash;&gt;-->
<!-- <view :style="{ color: getFlagColor(order.flag) }" class="flag">-->
<!-- {{ order.flagStr }}-->
<!-- </view>-->
<!-- </view>-->
<view class="order-body">
<view class="carNum">
{{ order.carNo }}
</view>
<view class="carModel">
{{ order.carModel }}
</view>
<!-- <view class="project">-->
<!-- <view class="project-left">-->
<!-- <view class="title">-->
<!-- <image class="titleIcon" mode="aspectFit" src="/static/icons/order-icon1.png"></image>-->
<!-- 维修项目-->
<!-- </view>-->
<!-- <view class="desc">-->
<!-- {{ projectName }}-->
<!-- </view>-->
<!-- </view>-->
<!-- <view v-if="order.ticketsStatus == '05'" class="project-right">-->
<!-- <image class="rightIcon" mode="aspectFit" src="/static/icons/success.png"></image>-->
<!-- <text class="rightText">已派工</text>-->
<!-- </view>-->
<!-- </view>-->
<view class="baseInfo">
<view>
客户信息{{ order.userName }} {{ order.userPhone }}
</view>
<view v-if="order.appointDate">
预约时间{{ order.appointDate }}
</view>
<view v-if="order.counselorName">
服务顾问{{ order.counselorName }}
</view>
</view>
<!-- <view class="footer">-->
<!-- <view @click="projectDis" v-if="order.ticketsStatus == '04' && roleCanPg" class="btn pg">-->
<!-- 项目派工-->
<!-- </view>-->
<!-- <view @click="projectDis" v-if="order.ticketsStatus == '05' && roleCanPg" class="btn pg">-->
<!-- 重新派工-->
<!-- </view>-->
<!-- <view @click="receiveOrder(order.id)" v-if="order.ticketsStatus == '05' && order.ticketsWorkStatus=='01' && roleCanJd" class="btn qc">-->
<!-- 接单-->
<!-- </view>-->
<!--&lt;!&ndash; <view @click="doOrder(order.id)" v-if="order.ticketsStatus == '05' && order.ticketsWorkStatus=='04' && roleCanSg" class="btn qc">&ndash;&gt;-->
<!--&lt;!&ndash; 开始施工&ndash;&gt;-->
<!--&lt;!&ndash; </view>&ndash;&gt;-->
<!-- <view v-if="order.ticketsStatus == '06' && roleCanQc" class="btn qc">-->
<!-- 告知取车-->
<!-- </view>-->
<!-- <view @click="gotoDetail" class="btn pg">-->
<!--&lt;!&ndash; 在什么都不能操作的情况下可以查看详情&ndash;&gt;-->
<!-- 查看详情-->
<!-- </view>-->
<!-- </view>-->
</view>
</view>
</template>
<script>
import {
getUserInfo,
getStrData
} from '@/utils/auth';
import request from '@/utils/request';
export default {
name: "bookingOrderCard",
props: {
order: {
type: Object,
default: () => {
return {}
}
}
},
computed: {
projectName() {
if (this.order && this.order.projectList && this.order.projectList.length > 0) {
return this.order.projectList.map(m => m.name).join(',')
}
return ''
}
},
data() {
return {
//
roleCanPg:false,
//
roleCanQc:false,
//
roleCanJd:false,
//---
roleCanSg:false,
}
},
mounted(){
let userInfo = getUserInfo()
if(userInfo.roleCodes.includes("service_advisor") || userInfo.roleCodes.includes("general_inspection") || (userInfo.roleCodes.includes("repair_staff") && getStrData("ifLeader"))){
//
this.roleCanPg = true
}
if(userInfo.roleCodes.includes("service_advisor")){
//
this.roleCanQc = true
}
if(userInfo.roleCodes.includes("repair_staff") && this.order.nowRepairId==userInfo.id){
//,
this.roleCanJd = true
}
},
onLoad(){
},
methods: {
getFlagColor(flag) {
if (flag == 1) {
return '#E8A321'
} else if (flag === 2) {
return '#999'
}
},
}
}
</script>
<style lang="less" scoped>
.orderCard {
background: #FFFFFF;
border-radius: 8rpx 8rpx 8rpx 8rpx;
border-left: 4rpx solid #FFB323;
padding: 5rpx 30rpx;
margin: 15rpx 0;
}
.order-top {
padding: 20rpx 0;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #F3F5F7;
.orderNo {
font-weight: 500;
font-size: 24rpx;
color: #858BA0;
}
.flag {
font-family: PingFang SC, PingFang SC;
font-weight: 500;
font-size: 24rpx;
}
}
.order-body {
.carNum {
margin: 20rpx 0;
}
.carModel {
margin: 20rpx 0;
font-weight: 500;
font-size: 28rpx;
color: #858BA0;
}
.project {
padding: 20rpx 10rpx;
background: #F2F2F7;
border-radius: 4rpx 4rpx 4rpx 4rpx;
display: flex;
align-items: center;
.project-left {
flex: 1;
width: 0;
}
.project-right {
padding: 0 16rpx;
display: flex;
flex-direction: column;
align-items: center;
border-left: 1rpx solid #DDDDDD;
.rightIcon {
width: 40rpx;
height: 40rpx;
}
.rightText {
font-weight: 500;
font-size: 24rpx;
color: #17DBB1;
}
}
.title {
font-weight: 500;
font-size: 24rpx;
color: #0174F6;
display: flex;
align-items: center;
column-gap: 8rpx;
}
.titleIcon {
width: 24rpx;
height: 24rpx;
}
.desc {
font-weight: 500;
font-size: 24rpx;
color: #333333;
margin-top: 10rpx;
}
}
.baseInfo {
font-weight: 500;
font-size: 28rpx;
color: #858BA0;
& > view {
margin: 30rpx 0;
}
}
.footer {
display: flex;
align-items: center;
justify-content: flex-end;
column-gap: 10rpx;
padding-bottom: 30rpx;
.btn {
width: 172rpx;
height: 60rpx;
border-radius: 30rpx 30rpx 30rpx 30rpx;
border: 2rpx solid #0174F6;
display: flex;
align-items: center;
justify-content: center;
font-weight: 500;
font-size: 28rpx;
color: #0174F6;
&.qc {
background: #0174F6;
color: #fff;
}
}
}
}
</style>

View File

@ -20,9 +20,9 @@
</view>
<view v-if="typeList && typeList.length > 0" class="projPicker" style="display: flex">
<view class="type">
<view v-for="item in typeList" :key="item.typeId" :class="{'active': typeId === item.typeId}" class="typeItem"
<view v-for="item in typeList" :key="item.id" :class="{'active': typeId === item.id}" class="typeItem"
@click="chooseType(item)">
{{ item.typeName }}
{{ item.name }}
</view>
</view>
<view class="container">
@ -39,6 +39,9 @@
<image v-if="selectedProj && selectedProj.find(f => f.id === item.id)" class="projChooseIcon"
mode="aspectFit" src="/static/icons/duihao.png"></image>
</view>
<view class="projItem" @click="addProject()">
<text class="projName">新增维修项目</text>
</view>
</view>
</view>
</view>
@ -68,6 +71,10 @@ export default {
console.log("执行onload")
this.$refs.popup.open()
this.getProjeectList()
if (this.typeList && this.typeList.length > 0) {
this.typeId = this.typeList[0].id
this.getProject()
}
// this.selectedProj = JSON.parse(JSON.stringify(selectedProj))
},
removeProj(index) {
@ -82,46 +89,44 @@ export default {
}
},
chooseType(type) {
this.groupList = type.groupList
this.typeId = type.typeId
this.typeId = type.id
this.getProject()
console.log("this.groupList",this.groupList)
// this.typeId = type.typeId
},
addProject() {
uni.navigateTo({
url: `/pages/project/project?typeId=${this.typeId}`
})
},
getProjeectList() {
const categoryList = []
console.log("执行")
const params = {
pageNo: 1,
pageSize: 10000,
type: '03'
}
request({
url: '/admin-api/repair/project/getRepairProjectAndCateGory',
// url: '/admin-api/repair/project/getRepairProjectAndCateGory',
url: '/admin-api/conf/baseType/list',
method: 'GET',
params: params
}).then(res => {
console.log("分类",res);
this.typeList = res.data
// categoryList.push(...res.data)
// console.log("categoryList",categoryList)
//
// categoryList.forEach(item => {
// let a = {
// name: item.name,
// id: item.id,
// groupList: [
//
// ]
// }
// this.typeList.push(a)
// })
// console.log("typeList",this.typeList)
})
},
getProject() {
request({
url: '/admin-api/repair/project/page',
method: 'GET',
params: params
params: {
pageNo: 1,
pageSize: 10000,
type: this.typeId
}
}).then(res => {
console.log("项目",res);
this.projectList = res.data.records
this.groupList = res.data.records
})
},

View File

@ -10,7 +10,7 @@
<view>
<radio-group @change="handleChange">
<label v-for="(option, index) in options" :key="index" class="radio-label">
<radio :value="option.value" :checked="option.value === ticketType" />
<radio :value="option.value" :checked="option.value === ticketType"/>
<text>{{ option.label }}</text>
</label>
</radio-group>
@ -37,16 +37,21 @@
</template>
<template v-else>
<view class="carTitle">车辆信息</view>
<view class="carListTab">
<view v-for="(item, index) in carList" :key="index" :class="{'active': activeCarIndex === index}"
class="carTabItem" @click="() => activeCarIndex = index">
<image :src="item.carLicenseImg" class="carImage" mode="aspectFit"></image>
<text>{{ item.licenseNumber }}</text>
<scroll-view scroll-x="true">
<view class="carListTab">
<view v-for="(item, index) in carList" :key="index" :class="{'active': activeCarIndex === index}"
class="carTabItem" @click="() => activeCarIndex = index">
<image :src="imgUrlPrex + item.logoImg" class="carImage" mode="aspectFit"></image>
<text>{{ item.licenseNumber }}</text>
</view>
<view class="carTabItemNew" @click="editCarInfo()">
<text>+</text>
</view>
</view>
</view>
</scroll-view>
<view class="carDetail">
<view class="carHeader">
<image :src="carList[activeCarIndex].carLicenseImg" class="carImage" mode="aspectFill"></image>
<image :src="imgUrlPrex + carList[activeCarIndex].logoImg" class="carImage" mode="aspectFill"></image>
<view class="carHeaderRight">
<text class="carNumber">{{ carList[activeCarIndex].licenseNumber }}</text>
<text class="carType">{{
@ -69,11 +74,11 @@
<view style="display: flex;align-items: center">
<view class="infoItem" style="flex: 1">
<view class="label">年检时间</view>
<view class="value">{{ carList[activeCarIndex].nextInspectionDate }}</view>
<view class="value">{{ carList[activeCarIndex].inspectionDate }}</view>
</view>
<view class="infoItem" style="flex: 1">
<view class="label">保险时间</view>
<view class="value">{{ carList[activeCarIndex].insuranceExpiryDate }}</view>
<view class="value">{{ carList[activeCarIndex].insuranceDate }}</view>
</view>
</view>
<view class="infoItem">
@ -170,7 +175,9 @@ import VNavigationBar from '@/components/VNavigationBar.vue'
import ProjectPicker from "@/components/projectPicker.vue";
import {bus} from "@/utils/eventBus";
import request from "@/utils/request";
import {getToken,setUserInfo,getUserInfo} from '@/utils/auth.js'
import {getToken, setUserInfo, getUserInfo} from '@/utils/auth.js'
import config from "@/config";
import {formatTimestamp, formatTimestampCustom} from "@/utils/utils";
export default {
components: {
@ -184,25 +191,42 @@ export default {
activeCarIndex: 0,
userInfo: null,
selectedProj: [],
typeList:[],
typeList: [],
ticketType: '01',
options: [
{ label: 'A单', value: '01' },
{ label: 'B单', value: '02' }
{label: 'A单', value: '01'},
{label: 'B单', value: '02'}
],
imgUrlPrex: config.baseImageUrl,
ticketNo: '',
}
},
onLoad(data) {
this.ticketNo = this.createUniqueCodeByHead('GD')
if (data.phone) {
this.phone = data.phone
this.listUserInfo()
}
},
onShow() {
if (this.phone != '') {
this.listUserInfo()
}
},
methods: {
createUniqueCodeByHead(head = '') {
const min = 100; //
const max = 999; //
return head.toString() + Date.now().toString() + Math.floor(Math.random() * (max - min + 1)) + min;
},
//
submit() {
console.log('userInfo',this.userInfo)
console.log('userInfo', this.userInfo)
console.log(this.carList[this.activeCarIndex])
console.log('selectedProj',this.selectedProj)
console.log("ticketType",this.ticketType)
console.log('登陆人信息',getUserInfo())
if (this.userInfo === null || this.carList.length === 0 || this.selectedProj.length === 0){
console.log('selectedProj', this.selectedProj)
console.log("ticketType", this.ticketType)
console.log('登陆人信息', getUserInfo())
if (this.userInfo === null || this.carList.length === 0 || this.selectedProj.length === 0) {
uni.showToast({
title: '请完善信息',
icon: 'none'
@ -214,6 +238,7 @@ export default {
method: 'POST',
data: {
userId: this.userInfo.id,
ticketNo: this.ticketNo,
userName: this.userInfo.cusName,
userMobile: this.userInfo.phoneNumber,
carId: this.carList[this.activeCarIndex].id,
@ -242,20 +267,27 @@ export default {
this.carList = []
this.userInfo = null
console.log("获取用户信息")
const params = {
phoneNumber: this.phone
}
request({
url: '/admin-api/base/custom/page',
method: 'GET',
params: params
}).then(res => {
console.log(res);
if (res.data.records.length > 0) {
this.userInfo = res.data.records[0]
this.getCarList()
if (this.phone != '') {
const params = {
phoneNumber: this.phone
}
})
request({
url: '/admin-api/base/custom/page',
method: 'GET',
params: params
}).then(res => {
console.log(res);
if (res.data.records.length > 0) {
this.userInfo = res.data.records[0]
this.getCarList()
}
})
} else {
uni.showToast({
title: '请输入手机号',
icon: 'none'
})
}
},
//
formatItem(list) {
@ -295,6 +327,12 @@ export default {
}).then(res => {
console.log(res);
this.carList = res.data.records
//
this.carList.forEach(item => {
item.inspectionDate = formatTimestampCustom(item.inspectionDate)
item.insuranceDate = formatTimestampCustom(item.insuranceDate)
item.carRegisterDate = formatTimestampCustom(item.carRegisterDate)
})
})
},
editCarInfo(index) {
@ -482,6 +520,26 @@ export default {
border-radius: 8rpx 8rpx 8rpx 8rpx;
}
}
.carTabItemNew {
display: flex;
flex-direction: column;
align-items: center;
row-gap: 10rpx;
font-weight: 500;
font-size: 24rpx;
color: #333333;
border: 2rpx solid #0174F6; /* 默认边框颜色为透明 */
justify-content: center; /* 垂直居中 */
font-weight: bold;
font-size: 32rpx;
padding: 10rpx; /* 可以根据需要调整内边距 */
width: 128rpx; /* 与 .carImage 宽度一致 */
height: 80rpx; /* 与 .carImage 高度一致 */
border-radius: 8rpx 8rpx 8rpx 8rpx;
margin-top: -37rpx;
}
}
.carDetail {
@ -617,6 +675,7 @@ export default {
}
}
.radio-label {
display: flex;
align-items: center;

View File

@ -12,7 +12,7 @@
<view class="searchBox">
<input v-model="phone" placeholder="请输入手机号码" type="tel">
</view>
<view class="btn">
<view class="btn" @click="listUserInfo">
<image class="btnIcon" mode="aspectFit" src="/pages-order/static/search.png"></image>
确认查找
</view>
@ -20,8 +20,8 @@
</view>
<view class="orderList">
<view v-for="item in orderList" :key="item.id" class="orderItem">
<order-card :order="item"></order-card>
<view v-for="item in orderList" :key="item.id" class="orderItem" @click="addOrder">
<booking-order-card :order="item"></booking-order-card>
</view>
</view>
</view>
@ -32,49 +32,101 @@
<script>
import VNavigationBar from '@/components/VNavigationBar.vue'
import OrderCard from "@/components/orderCard.vue";
import request from "@/utils/request";
import BookingOrderCard from "@/components/bookingOrderCard.vue";
export default {
components: {
OrderCard,
BookingOrderCard,
VNavigationBar,
},
data() {
return {
phone: '',
userInfo: null,
carList: [],
orderList: [
{
orderNo: '1209840149750105501',
flag: 1, flagStr: '待处理', carNum: '川A 184AO1',
carModel: '一汽奥迪 2024款 A6L',
projectList: [
{ name: '清洗内饰', id: 1 },
{ name: '内饰精洗除臭', id: 2 },
{ name: '烘干底板胶及脚垫', id: 3 }
],
userName: '张三',
userPhone: '157****6879',
appointDate: '2024-10-20 12:00',
counselorName: '李相东'
},
{
orderNo: '1209840149750105501',
flag: 1, flagStr: '待处理', carNum: '川A 184AO1',
carModel: '一汽奥迪 2024款 A6L',
projectList: [
{ name: '清洗内饰', id: 1 },
{ name: '内饰精洗除臭', id: 2 },
{ name: '烘干底板胶及脚垫', id: 3 }
],
userName: '张三',
userPhone: '157****6879',
appointDate: '2024-10-20 12:00',
counselorName: '李相东'
}
// {
// orderNo: '1209840149750105501',
// flag: 1, flagStr: '', carNum: 'A 184AO1',
// carModel: ' 2024 A6L',
// projectList: [
// {name: '', id: 1},
// {name: '', id: 2},
// {name: '', id: 3}
// ],
// userName: '',
// userPhone: '157****6879',
// appointDate: '2024-10-20 12:00',
// counselorName: ''
// },
// {
// orderNo: '1209840149750105501',
// flag: 1, flagStr: '', carNum: 'A 184AO1',
// carModel: ' 2024 A6L',
// projectList: [
// {name: '', id: 1},
// {name: '', id: 2},
// {name: '', id: 3}
// ],
// userName: '',
// userPhone: '157****6879',
// appointDate: '2024-10-20 12:00',
// counselorName: ''
// }
]
}
},
onLoad(data) {
},
methods: {}
methods: {
listUserInfo() {
this.carList = []
this.userInfo = null
console.log("获取用户信息")
if (this.phone != '') {
const params = {
phoneNumber: this.phone
}
request({
url: '/admin-api/base/custom/page',
method: 'GET',
params: params
}).then(res => {
console.log(res);
if (res.data.records.length > 0) {
const params = {
userId: res.data.records[0].userId
}
request({
url: '/admin-api/repair/booking/list',
method: 'GET',
params: params
}).then(res => {
console.log(res);
this.orderList = res.data
this.orderList.map((item) => {
item.userPhone = item.userMobile
item.appointDate = item.bookingTime
})
})
}
})
} else {
uni.showToast({
title: '请输入手机号',
icon: 'none'
})
}
},
addOrder(){
console.log('执行')
uni.navigateTo({
url: `/pages-order/addOrder/addOrder?phone=${this.phone}`
});
},
}
}
</script>

View File

@ -234,7 +234,7 @@
</view>
</view>
<view v-if="isDetail == '0'" class="foot">
<view class="submit">保存工单</view>
<view class="submit" @click="submit">保存工单</view>
</view>
</view>
<!-- 悬浮操作-->
@ -383,6 +383,11 @@ export default {
current: index
});
},
submit (){
uni.navigateTo({
url: '/pages-home/home/home'
})
},
afterRead(file) {
for (let i = 0; i < file.tempFilePaths.length; i++) {
upload({

View File

@ -63,6 +63,13 @@
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "pages/project/project",
"style": {
"navigationBarTitleText": "新增维修项目",
"enablePullDownRefresh": true
}
}
],
"subPackages": [

View File

@ -177,6 +177,7 @@ export default {
if (options.car) {
//
this.car = JSON.parse(decodeURIComponent(options.car));
this.brandId = this.car.carBrand
console.log('初始化页面数据', this.car)
this.bo1 = true;
this.bo2 = false;
@ -199,6 +200,7 @@ export default {
brandSelect(e) {
console.log('e', e)
this.brandId = e.value
this.car.brandStr = e.name
// this.getCarModule()
},
getBrandList() {
@ -238,8 +240,24 @@ export default {
this.datePickerShow = true
},
datePickerConfirm({value}, field, picker) {
const date = new Date(value)
let date;
// value
if (typeof value === 'number') {
//
date = new Date(value);
} else if (typeof value === 'string') {
//
date = new Date(value);
}
//
if (isNaN(date.getTime())) {
console.error('Invalid date:', value);
return;
}
this.car[this.pickerConfirmField] = date.getFullYear() + '-' + (Number(date.getMonth()) + 1 + '').padStart(2, '0') + '-' + (date.getDate() + '').padStart(2, '0')
console.log("this.car[this.pickerConfirmField]",this.car[this.pickerConfirmField])
this.datePickerCancel(picker)
},
datePickerCancel(picker) {
@ -264,11 +282,17 @@ export default {
// bus.$emit('updateCarInfo', this.car)
this.car.brandAndModel = [this.brandId, this.car.carModel]
console.log("car",this.car)
//
this.car.inspectionDate = new Date(this.car.inspectionDate).getTime()
this.car.insuranceDate = new Date(this.car.insuranceDate).getTime()
this.car.carRegisterDate = new Date(this.car.carRegisterDate).getTime()
if (this.car.id != null) {
request({
url: '/admin-api/base/carMain/update',
method: 'PUT',
data: this.car,
}).then(res => {
uni.navigateBack();
})
} else {
request({

89
pages/project/project.vue Normal file
View File

@ -0,0 +1,89 @@
<template>
<view class="container">
<VNavigationBar :title="pageTitle" background-color="#fff" title-color="#333"></VNavigationBar>
<view class="body">
<u-form labelPosition="top">
<view class="card">
<u-form-item borderBottom label="名称" labelWidth="200">
<u-input v-model="project.vin" border="none" placeholder="请输入名称"></u-input>
</u-form-item>
<u-form-item borderBottom label="编码" labelWidth="200">
<u-input v-model="project.engineNumber" border="none" placeholder="请输入编码"></u-input>
</u-form-item>
<u-form-item borderBottom label="规格" labelWidth="200">
<u-input v-model="project.engineNumber" border="none" placeholder="请输入规格"></u-input>
</u-form-item>
<u-form-item borderBottom label="工时" labelWidth="200">
<u-input v-model="project.engineNumber" border="none" placeholder="请输入规格"></u-input>
</u-form-item>
</view>
</u-form>
</view>
<view class="footer">
<view class="btnItem edit" @click="submit">
确定
</view>
</view>
</view>
</template>
<script>
import VNavigationBar from "@/components/VNavigationBar.vue";
export default {
components: {VNavigationBar},
data() {
return {
pageTitle: '新增维修项目',
project:{},
};
},
onLoad(options) {
console.log("options",options)
},
}
</script>
<style lang="less" scoped>
.container {
box-sizing: border-box;
height: 100%;
background-color: #f3f5f7;
display: flex;
flex-direction: column;
.body {
flex: 1;
height: 0;
overflow: auto;
.card {
margin: 20rpx 30rpx;
padding: 0 30rpx;
background-color: #fff;
}
}
.footer {
background: #ffffff;
display: flex;
align-items: center;
justify-content: center;
padding: 30rpx 0;
.btnItem {
width: 510rpx;
height: 76rpx;
background: #0174F6;
border-radius: 38rpx 38rpx 38rpx 38rpx;
font-size: 32rpx;
color: #FFFFFF;
line-height: 76rpx;
text-align: center;
}
}
}
</style>

View File

@ -170,6 +170,34 @@ export function formatTimestamp(timestamp) {
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
/**
* 将时间戳转换为指定格式的日期字符串
* @param {number} timestamp - 时间戳毫秒
* @param {string} [format='YYYY-MM-DD'] - 日期格式默认为 'YYYY-MM-DD'
* @returns {string} - 格式化的日期字符串
*/
export function formatTimestampCustom(timestamp, format = 'YYYY-MM-DD') {
const date = new Date(timestamp);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hour = date.getHours().toString().padStart(2, '0');
const minute = date.getMinutes().toString().padStart(2, '0');
const second = date.getSeconds().toString().padStart(2, '0');
const replaceMap = {
'YYYY': year,
'MM': month,
'DD': day,
'HH': hour,
'mm': minute,
'ss': second
};
return format.replace(/YYYY|MM|DD|HH|mm|ss/g, match => replaceMap[match]);
}
/**
* 组装订单对象
* @param order