完善请求
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<div class="system-user-search mb15">
|
||||
<el-form :inline="true">
|
||||
<el-form-item label="产品名称">
|
||||
<el-input size="default" v-model="tableData.param.productName" placeholder="请输入产品名称" class="w-50 m-2" clearable />
|
||||
<el-input size="default" v-model="tableData.param.name" placeholder="请输入产品名称" class="w-50 m-2" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button size="default" type="primary" class="ml10" @click="handleSearch">
|
||||
@@ -43,11 +43,19 @@
|
||||
<el-table-column prop="name" label="产品名称" show-overflow-tooltip />
|
||||
<el-table-column prop="creator" label="创建人" show-overflow-tooltip />
|
||||
<el-table-column prop="updater" label="修改人" show-overflow-tooltip />
|
||||
<el-table-column prop="createdAtString" label="创建时间" show-overflow-tooltip />
|
||||
<el-table-column prop="updatedAtString" label="修改时间" show-overflow-tooltip />
|
||||
<el-table-column prop="createdAtString" label="创建时间" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ formatTime(row.createdAt) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="updatedAtString" label="修改时间" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
{{ formatTime(row.createdAt) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="220">
|
||||
<template #default="scope">
|
||||
<el-button size="small" text type="primary" @click="onOpenEditRole(scope.row)">
|
||||
<el-button style="color: deepskyblue" size="small" text type="primary" @click="onOpenEditRole(scope.row)">
|
||||
<el-icon><ele-EditPen /></el-icon>修改
|
||||
</el-button>
|
||||
<el-button size="small" text type="primary" @click="onRowDel(scope.row)">
|
||||
@@ -63,7 +71,7 @@
|
||||
:total="tableData.total"
|
||||
v-model:page="tableData.param.pageNum"
|
||||
v-model:limit="tableData.param.pageSize"
|
||||
@pagination="handlePaginationChange"
|
||||
@pagination="getProductList"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
@@ -104,7 +112,7 @@ interface ProductData {
|
||||
* 查询参数接口
|
||||
*/
|
||||
interface QueryParam {
|
||||
productName: string; // 产品名称
|
||||
name: string; // 产品名称
|
||||
roleStatus: string; // 状态
|
||||
pageNum: number; // 页码
|
||||
pageSize: number; // 每页大小
|
||||
@@ -130,7 +138,7 @@ const tableData = reactive<TableState>({
|
||||
total: 0,
|
||||
loading: false,
|
||||
param: {
|
||||
productName: '',
|
||||
name: '',
|
||||
roleStatus: '',
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
@@ -162,6 +170,49 @@ const getProductList = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// ==================== 时间处理函数 ====================
|
||||
/**
|
||||
* 格式化时间显示
|
||||
*/
|
||||
const formatTime = (time: string | number | Date): string => {
|
||||
if (!time) return '-';
|
||||
|
||||
try {
|
||||
let date: Date;
|
||||
|
||||
if (time instanceof Date) {
|
||||
date = time;
|
||||
} else if (typeof time === 'string') {
|
||||
date = new Date(time);
|
||||
} else {
|
||||
let timestamp = time;
|
||||
if (timestamp > 1000000000000) {
|
||||
// 已经是毫秒时间戳
|
||||
} else if (timestamp > 1000000000) {
|
||||
// 秒时间戳,转换为毫秒
|
||||
timestamp = timestamp * 1000;
|
||||
}
|
||||
date = new Date(timestamp);
|
||||
}
|
||||
|
||||
if (isNaN(date.getTime())) {
|
||||
return String(time);
|
||||
}
|
||||
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
} catch (error) {
|
||||
console.error('时间格式化错误:', error);
|
||||
return String(time);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理搜索
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user