更新:vip列表取消有效期时分秒的显示

This commit is contained in:
2025-10-22 16:37:56 +08:00
parent e22007b2e1
commit 17f904c360
3 changed files with 60 additions and 10 deletions

View File

@@ -88,5 +88,50 @@ export function throttle(func, wait) {
};
}
/**
* Parse the time to string
* @param {(Object|string|number)} time
* @param {string} cFormat
* @returns {string | null}
*/
export function parseTime(time, cFormat) {
if (arguments.length === 0 || !time) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string')) {
if ((/^[0-9]+$/.test(time))) {
// support "1548221490638"
time = parseInt(time)
} else {
// support safari
time = time.replace(new RegExp(/-/gm), '/')
}
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
const value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
return value.toString().padStart(2, '0')
})
return time_str
}

View File

@@ -441,6 +441,7 @@
<script>
import OpenVip from "./user-open-vip";
import { parseTime } from "@/utils";
export default {
data() {
return {
@@ -627,10 +628,10 @@ if (latest && latest.endTime) {
: '<i class="el-icon-close"></i>'
}</span>
<span style="color: #888;margin-left: 10px;">有效期:${
e.startTime ? e.startTime : ""
e.startTime ? parseTime(e.startTime, '{y}-{m}-{d}') : ""
}</span>
<span>~</span>
<span style="color: #888;">${e.endTime ? e.endTime : ""}</span>
<span style="color: #888;">${e.endTime ? parseTime(e.endTime, '{y}-{m}-{d}') : ""}</span>
`
);
@@ -647,10 +648,10 @@ if (latest && latest.endTime) {
: '<i class="el-icon-close"></i>'
}</span>
<span style="color: #888;margin-left: 10px;">有效期:${
e.startTime ? e.startTime : ""
e.startTime ? parseTime(e.startTime, '{y}-{m}-{d}') : ""
}</span>
<span>~</span>
<span style="color: #888;">${e.endTime ? e.endTime : ""}</span>
<span style="color: #888;">${e.endTime ? parseTime(e.endTime, '{y}-{m}-{d}') : ""}</span>
`
);
@@ -669,10 +670,10 @@ if (latest && latest.endTime) {
: '<i class="el-icon-close"></i>'
}</span>
<span style="color: #888;margin-left: 10px;">有效期:${
e.startTime ? e.startTime : ""
e.startTime ? parseTime(e.startTime, '{y}-{m}-{d}') : ""
}</span>
<span>~</span>
<span style="color: #888;">${e.endTime ? e.endTime : ""}</span>
<span style="color: #888;">${e.endTime ? parseTime(e.endTime, '{y}-{m}-{d}') : ""}</span>
`
);
@@ -947,11 +948,11 @@ if (latest && latest.endTime) {
};
</script>
<style scoped>
/deep/ .mod-config .el-table .el-table__cell {
::v-deep .mod-config .el-table .el-table__cell {
padding: 4px 0 !important;
box-sizing: border-box;
}
/deep/ .mod-config .el-table .cell,
::v-deep .mod-config .el-table .cell,
.el-table th div {
padding: 0 !important;
box-sizing: border-box;

View File

@@ -56,7 +56,7 @@
:style="
`color:${item.state == 0 ? '#515a6e' : '#888'} !important`
"
>有效期 {{ item.startTime }} {{ item.endTime }}</span
>有效期 {{ parseTime(item.startTime, '{y}-{m}-{d}') }} {{ parseTime(item.endTime, '{y}-{m}-{d}') }}</span
>
</div>
<el-collapse v-model="activeNames">
@@ -109,8 +109,10 @@
</template>
</el-table-column>
<el-table-column prop="startTime" label="开始时间" width="150">
<template slot-scope="scope">{{ parseTime(scope.row.startTime, "{y}-{m}-{d}") }}</template>
</el-table-column>
<el-table-column prop="endTime" label="结束时间" width="150">
<template slot-scope="scope">{{ parseTime(scope.row.endTime, "{y}-{m}-{d}") }}</template>
</el-table-column>
<el-table-column prop="remark" label="备注"> </el-table-column>
@@ -389,6 +391,7 @@
<script>
// import AddOrUpdate from "./buyorderdetail-add-or-update";
// import setDeliverDialog from "./set-deliver-dialog";
import { parseTime } from '@/utils';
export default {
props: ["orderSn", "pageType"],
data() {
@@ -475,6 +478,7 @@ export default {
// this.getOrderSheetList()
},
methods: {
parseTime,
addYearsToTime(timeStr, yearsToAdd, type) {
// 1. 拆分时间字符串为「日期部分」和「时间部分」
const [datePart, timePart] = timeStr.split(" ");