2025-09-16 15:03:25 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<!-- 归档配置 -->
|
|
|
|
|
|
<div class="app-container">
|
2025-09-18 14:12:03 +08:00
|
|
|
|
<el-card class="section-card">
|
|
|
|
|
|
<div class="section-header">
|
|
|
|
|
|
<div class="section-title">
|
|
|
|
|
|
<i class="el-icon-notebook-2" /> 定期归档配置
|
|
|
|
|
|
<el-switch v-model="periodicEnabled" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-09-16 15:03:25 +08:00
|
|
|
|
|
2025-09-18 14:12:03 +08:00
|
|
|
|
<el-form label-width="80px" :inline="false" class="section-form">
|
|
|
|
|
|
<el-form-item label="周期周期">
|
|
|
|
|
|
<el-select v-model="periodicCycle" placeholder="请选择">
|
|
|
|
|
|
<el-option label="每天" value="daily" />
|
|
|
|
|
|
<el-option label="每周" value="weekly" />
|
|
|
|
|
|
<el-option label="每月" value="monthly" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 每天 -->
|
|
|
|
|
|
<el-form-item v-if="periodicCycle==='daily'" label="">
|
|
|
|
|
|
<el-time-picker
|
|
|
|
|
|
v-model="dailyTime"
|
|
|
|
|
|
placeholder="选择时间"
|
|
|
|
|
|
format="HH:mm"
|
|
|
|
|
|
value-format="HH:mm"
|
|
|
|
|
|
:clearable="false"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 每周 -->
|
|
|
|
|
|
<el-form-item v-if="periodicCycle==='weekly'" label="">
|
|
|
|
|
|
<el-time-picker
|
|
|
|
|
|
v-model="weeklyTime"
|
|
|
|
|
|
placeholder="选择时间"
|
|
|
|
|
|
format="HH:mm"
|
|
|
|
|
|
value-format="HH:mm"
|
|
|
|
|
|
:clearable="false"
|
|
|
|
|
|
style="margin-right: 10px;"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-select v-model="weeklyDay" style="width: 120px;">
|
|
|
|
|
|
<el-option label="星期一" value="1" />
|
|
|
|
|
|
<el-option label="星期二" value="2" />
|
|
|
|
|
|
<el-option label="星期三" value="3" />
|
|
|
|
|
|
<el-option label="星期四" value="4" />
|
|
|
|
|
|
<el-option label="星期五" value="5" />
|
|
|
|
|
|
<el-option label="星期六" value="6" />
|
|
|
|
|
|
<el-option label="星期日" value="7" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
2025-09-18 15:42:20 +08:00
|
|
|
|
<!-- 每月:选择时间 + 天数(1-31) -->
|
2025-09-18 14:12:03 +08:00
|
|
|
|
<el-form-item v-if="periodicCycle==='monthly'" label="">
|
2025-09-18 15:42:20 +08:00
|
|
|
|
<el-time-picker
|
|
|
|
|
|
v-model="monthTime"
|
|
|
|
|
|
placeholder="选择时间"
|
|
|
|
|
|
format="HH:mm"
|
|
|
|
|
|
value-format="HH:mm"
|
2025-09-18 14:12:03 +08:00
|
|
|
|
:clearable="false"
|
2025-09-18 15:42:20 +08:00
|
|
|
|
style="margin-right: 10px;"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-input-number
|
|
|
|
|
|
v-model="monthlyDay"
|
|
|
|
|
|
:min="1"
|
|
|
|
|
|
:max="31"
|
|
|
|
|
|
:step="1"
|
|
|
|
|
|
controls-position="right"
|
|
|
|
|
|
style="width: 140px;"
|
2025-09-18 14:12:03 +08:00
|
|
|
|
/>
|
2025-09-18 15:42:20 +08:00
|
|
|
|
<span style="margin-left: 6px;color:#909399;">日</span>
|
2025-09-18 14:12:03 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
|
|
<el-card class="section-card">
|
|
|
|
|
|
<div class="section-header">
|
|
|
|
|
|
<div class="section-title">
|
|
|
|
|
|
<i class="el-icon-collection" /> 不定期归档配置
|
|
|
|
|
|
<el-switch v-model="nonPeriodicEnabled" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="section-body">
|
|
|
|
|
|
<el-date-picker
|
|
|
|
|
|
v-model="nonPeriodicDateTime"
|
|
|
|
|
|
type="datetime"
|
|
|
|
|
|
placeholder="选择日期时间"
|
|
|
|
|
|
format="yyyy-MM-dd HH:mm"
|
|
|
|
|
|
value-format="yyyy-MM-dd HH:mm"
|
|
|
|
|
|
:clearable="false"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="actions">
|
|
|
|
|
|
<el-button type="primary" icon="el-icon-check" @click="handleSave">保存</el-button>
|
|
|
|
|
|
</div>
|
2025-09-16 15:03:25 +08:00
|
|
|
|
</div>
|
2025-09-18 14:12:03 +08:00
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-09-18 15:42:20 +08:00
|
|
|
|
import { queryAPI, editAPI } from '@/api/filesTransfer/setting'
|
2025-09-18 14:12:03 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'ArchiveSetting',
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
// 定期归档
|
|
|
|
|
|
periodicEnabled: true,
|
|
|
|
|
|
periodicCycle: 'daily', // daily | weekly | monthly
|
|
|
|
|
|
dailyTime: '00:00',
|
|
|
|
|
|
weeklyTime: '00:00',
|
|
|
|
|
|
weeklyDay: '1',
|
2025-09-18 15:42:20 +08:00
|
|
|
|
monthTime: '00:00',
|
|
|
|
|
|
monthlyDay: 1,
|
2025-09-18 14:12:03 +08:00
|
|
|
|
// 不定期归档
|
|
|
|
|
|
nonPeriodicEnabled: true,
|
|
|
|
|
|
nonPeriodicDateTime: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
periodicCycle(newVal) {
|
|
|
|
|
|
if (newVal === 'daily' && !this.dailyTime) this.dailyTime = '00:00'
|
|
|
|
|
|
if (newVal === 'weekly') {
|
|
|
|
|
|
if (!this.weeklyTime) this.weeklyTime = '00:00'
|
|
|
|
|
|
if (!this.weeklyDay) this.weeklyDay = '1'
|
|
|
|
|
|
}
|
2025-09-18 15:42:20 +08:00
|
|
|
|
if (newVal === 'monthly') {
|
|
|
|
|
|
if (!this.monthTime) this.monthTime = '00:00'
|
|
|
|
|
|
if (!this.monthlyDay) this.monthlyDay = 1
|
2025-09-18 14:12:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-09-18 15:42:20 +08:00
|
|
|
|
created() {
|
|
|
|
|
|
this.query()
|
|
|
|
|
|
},
|
2025-09-18 14:12:03 +08:00
|
|
|
|
methods: {
|
|
|
|
|
|
formatDateTime(date) {
|
|
|
|
|
|
const y = date.getFullYear()
|
|
|
|
|
|
const m = String(date.getMonth() + 1).padStart(2, '0')
|
|
|
|
|
|
const d = String(date.getDate()).padStart(2, '0')
|
|
|
|
|
|
const hh = String(date.getHours()).padStart(2, '0')
|
|
|
|
|
|
const mm = String(date.getMinutes()).padStart(2, '0')
|
|
|
|
|
|
return `${y}-${m}-${d} ${hh}:${mm}`
|
|
|
|
|
|
},
|
2025-09-18 15:42:20 +08:00
|
|
|
|
// 修改归档配置
|
2025-09-18 14:12:03 +08:00
|
|
|
|
handleSave() {
|
2025-09-18 15:42:20 +08:00
|
|
|
|
// 组合两条配置数据:第一条定期归档,第二条不定期归档
|
|
|
|
|
|
const periodicPayload = {
|
|
|
|
|
|
useStatus: this.periodicEnabled ? 1 : 0,
|
|
|
|
|
|
cycle: this.periodicCycle,
|
|
|
|
|
|
time: this.dailyTime,
|
|
|
|
|
|
time: this.weeklyTime,
|
|
|
|
|
|
weekOfDay: this.weeklyDay,
|
|
|
|
|
|
monthTime: this.monthTime,
|
|
|
|
|
|
monthDay: this.monthlyDay,
|
|
|
|
|
|
id:1,
|
|
|
|
|
|
archivedType:1,
|
|
|
|
|
|
}
|
|
|
|
|
|
const nonPeriodicPayload = {
|
|
|
|
|
|
useStatus: this.nonPeriodicEnabled ? 1 : 0,
|
|
|
|
|
|
time: this.nonPeriodicDateTime,
|
|
|
|
|
|
id:2,
|
|
|
|
|
|
archivedType:2,
|
2025-09-18 14:12:03 +08:00
|
|
|
|
}
|
2025-09-18 15:42:20 +08:00
|
|
|
|
const payload = [periodicPayload, nonPeriodicPayload]
|
2025-09-18 14:12:03 +08:00
|
|
|
|
console.log('保存归档配置: ', payload)
|
2025-09-18 15:42:20 +08:00
|
|
|
|
editAPI(payload).then(() => {
|
|
|
|
|
|
this.$message.success('保存成功')
|
|
|
|
|
|
this.query()
|
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
this.$message.error('保存失败')
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 查询归档配置
|
|
|
|
|
|
query() {
|
|
|
|
|
|
queryAPI().then(res => {
|
|
|
|
|
|
console.log('查询归档配置: ', res)
|
|
|
|
|
|
const list = Array.isArray(res.data) ? res.data : []
|
|
|
|
|
|
const periodic = list[0] || {}
|
|
|
|
|
|
const nonPeriodic = list[1] || {}
|
|
|
|
|
|
|
|
|
|
|
|
// 第一条:定期归档配置
|
|
|
|
|
|
this.periodicEnabled = (periodic.useStatus !== undefined && periodic.useStatus !== null)
|
|
|
|
|
|
? String(periodic.useStatus) === '1'
|
|
|
|
|
|
: this.periodicEnabled
|
|
|
|
|
|
this.periodicCycle = periodic.cycle || this.periodicCycle
|
|
|
|
|
|
this.dailyTime = periodic.time || this.dailyTime
|
|
|
|
|
|
this.weeklyTime = periodic.time || this.weeklyTime
|
|
|
|
|
|
this.weeklyDay = periodic.weekOfDay || this.weeklyDay
|
|
|
|
|
|
this.monthTime = periodic.time || this.monthTime
|
|
|
|
|
|
this.monthlyDay = periodic.monthDay || this.monthlyDay
|
|
|
|
|
|
|
|
|
|
|
|
// 第二条:不定期归档配置
|
|
|
|
|
|
this.nonPeriodicEnabled = (nonPeriodic.useStatus !== undefined && nonPeriodic.useStatus !== null)
|
|
|
|
|
|
? String(nonPeriodic.useStatus) === '1'
|
|
|
|
|
|
: this.nonPeriodicEnabled
|
|
|
|
|
|
this.nonPeriodicDateTime = nonPeriodic.time || this.nonPeriodicDateTime
|
|
|
|
|
|
})
|
2025-09-18 14:12:03 +08:00
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.section-card {
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.section-header {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.section-title {
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: #606266;
|
|
|
|
|
|
}
|
|
|
|
|
|
.section-title i {
|
|
|
|
|
|
margin-right: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.section-title .el-switch {
|
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.section-form {
|
|
|
|
|
|
padding-left: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.section-body {
|
|
|
|
|
|
padding-left: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.actions {
|
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|