This commit is contained in:
2025-05-10 03:31:03 +08:00
7 changed files with 73 additions and 33 deletions

View File

@@ -16,7 +16,7 @@
<el-date-picker v-model="searchInfo.endCreatedAt" type="datetime" placeholder="结束日期" :disabled-date="time=> searchInfo.startCreatedAt ? time.getTime() < searchInfo.startCreatedAt.getTime() : false"></el-date-picker>
</el-form-item>
<template v-if="showAllQuery">
<!-- 将需要控制显示状态的查询条件添加到此范围内 -->
@@ -34,7 +34,7 @@
<div class="gva-btn-list">
<el-button type="primary" icon="plus" @click="openDialog()">新增</el-button>
<el-button icon="delete" style="margin-left: 10px;" :disabled="!multipleSelection.length" @click="onDelete">删除</el-button>
</div>
<el-table
ref="multipleTable"
@@ -45,11 +45,11 @@
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" />
<el-table-column align="left" label="日期" prop="createdAt"width="180">
<template #default="scope">{{ formatDate(scope.row.CreatedAt) }}</template>
</el-table-column>
<el-table-column align="left" label="关键词" prop="keyword" width="120" />
<el-table-column label="内容" prop="content" width="200">
<template #default="scope">

View File

@@ -18,15 +18,34 @@
:data="tableData"
:config="USER_TABLE_CONFIG"
>
<template #avatar="{ row }">
<el-image
style="width: 100px; height: 100px"
:src="row.avatar"
:zoom-rate="1.2"
:max-scale="7"
:min-scale="0.2"
:preview-src-list="[row.avatar]"
show-progress
:initial-index="4"
fit="cover"
/>
</template>
<template #status="{ row }">
<!-- <el-tag :type="tag(row.status).extend">{{ tag(row.status).label }}</el-tag>-->
<el-switch v-model="row.status"
active-value="1"
inactive-value="0"
:loading="statusChangeLoading"
:active-value="1"
:inactive-value="0"
:loading="row.loading"
:before-change="() => statusChangeBefore(row)" />
</template>
<template #CreatedAt="{ row }">
{{ formatDate(row.CreatedAt) }}
</template>
<template #UpdatedAt="{ row }">
{{ formatDate(row.UpdatedAt) }}
</template>
<template #operate="{ row }">
<el-button type="text" @click="handleDetail(row)">详情</el-button>
<!-- <el-button type="text" @click="handleDelete(row)">删除</el-button>-->
@@ -39,10 +58,11 @@
<script setup>
import searchForm from '@/components/searchForm/index.vue'
import Content from '@/components/content/index.vue'
import {list} from '@/api/user/index.js'
import {list, status} from '@/api/user/index.js'
import { ref, onMounted } from 'vue'
import {formatDate} from '@/utils/format'
import { USER_SEARCH_CONFIG, USER_TABLE_CONFIG } from '@/config'
const tableLoading = ref(true), tableData = ref([{status:1}])
const tableLoading = ref(true), tableData = ref([])
const queryParams = ref({
page: 1,
pageSize: 10,
@@ -50,11 +70,7 @@
startTime: '',
endTime: ''
}), total = ref(0)
const statusChangeLoading = ref(false)
// const EMPTY_STR = '- -'
// const tag = (status) => {
// return userStatus.find((item) => item.value === status+'') || { type: '', label: EMPTY_STR }
// }
const searchData = (data) => {
if (data.times) {
data.startTime = data.times[0]
@@ -79,6 +95,9 @@
const res = await list(queryParams.value)
if(res.code === 0) {
tableData.value = res.data.list
for(let item of tableData.value) {
item.loading = false
}
total.value = res.data.total
}
}
@@ -91,15 +110,15 @@
queryParams.value.pageNum = data
getList()
}
function statusChangeBefore(row) {
console.log(row)
statusChangeLoading.value = true
return new Promise(resolve => {
setTimeout(() => {
statusChangeLoading.value = false
return resolve(true)
},500)
})
async function statusChangeBefore(row) {
row.loading = true
let params = JSON.parse(JSON.stringify(row))
params.status = row.status === 1 ? 0 : 0
const res = await status(params)
row.loading = false
if(res.code === 0) {
row.status = row.status === 1? 0 :1
}
}
</script>
<style lang="scss" scoped>