归档配置

This commit is contained in:
cwchen 2025-09-18 15:42:20 +08:00
parent aee364070d
commit 9144a584c6
7 changed files with 288 additions and 28 deletions

View File

@ -0,0 +1,19 @@
import request from '@/utils/request'
// 归档配置查询
export function queryAPI(params) {
return request({
url: '/smartArchives/archivedSetting/query',
method: 'GET',
params: params,
})
}
// 修改归档配置
export function editAPI(data) {
return request({
url: '/smartArchives/archivedSetting/edit',
method: 'POST',
data
})
}

View File

@ -203,7 +203,6 @@ export default {
const res = await getFileManageTreeApi({proId:this.projectId})
const transformedData = this.convertToVueTree(res.data)
this.treeDataList = transformedData;
console.log(this.treeDataList);
//
this.originalTreeData = JSON.parse(JSON.stringify(this.treeDataList))

View File

@ -158,7 +158,6 @@ export default {
watch: {
selectedNode: {
handler(newVal) {
console.log(newVal);
this.addBtnIsShow = !(newVal && Number(newVal.level) === 4)
// parentId
const parentId = newVal && newVal.id ? newVal.id : 0

View File

@ -0,0 +1,37 @@
export const formLabel = [
{
isShow: false, // 是否展示label
f_type: 'ipt',
f_label: '项目名称',
f_model: 'proName',
f_max: 32,
},
{
isShow: false, // 是否展示label
f_type: 'sel',
f_label: '项目类型',
f_model: 'proType',
f_selList: [],
f_dict: 'pro_type',
},
{
isShow: false, // 是否展示label
f_type: 'sel',
f_label: '电压等级',
f_model: 'voltageLevel',
f_selList: [],
f_dict: 'voltage_level',
},
]
export const columnsList = [
{ t_props: 'proName', t_label: '项目名称' },
{ t_props: 'singleProName', t_label: '单项工程名称' },
{ t_props: 'proTypeName', t_label: '工程类型' },
{ t_props: 'voltageLevelName', t_label: '电压等级' },
{ t_props: 'planStartDate', t_label: '计划开工日期' },
{ t_props: 'planEndDate', t_label: '计划竣工日期' },
{ t_props: 'planTcDate', t_label: '计划投产日期' },
{ t_props: 'proStatusName', t_label: '工程状态' },
{ t_slot: 'contentsName', t_label: '匹配档案目录类型' },
]

View File

@ -0,0 +1,87 @@
<template>
<!-- 项目管理 -->
<div class="app-container">
<TableModel :formLabel="formLabel" :showOperation="true" :showRightTools="true" ref="proTableRef"
:columnsList="columnsList" :request-api="getProListAPI">
<template slot="contentsName" slot-scope="{ data }">
<el-tag
size="mini"
:type="data.contentsName ? 'success' : 'danger'"
>
{{ data.contentsName ? data.contentsName : '未配置' }}
</el-tag>
</template>
<template slot="handle" slot-scope="{ data }">
<el-button plain size="mini" type="primary" icon="el-icon-edit" v-hasPermi="['data:classify:update']"
@click="handleUpdate(data)" v-if="!data.contentsName">
配置档案类型
</el-button>
</template>
</TableModel>
<!-- 配置 -->
<FileSetForm v-if="isflag" :isAdd="isAdd" :rowData="row" @handleQuery="handleQuery" :title="title"
@closeDialog="closeDialog" @showColose="showColose" :dataForm="row" :disabled="loading" :width="600" />
</div>
</template>
<script>
import TableModel from '@/components/TableModel'
import { columnsList, formLabel } from './config'
import {
getProListAPI
} from '@/api/archivesManagement/project'
// import FileSetForm from './prop/fileSetForm'
export default {
name: 'ProManager',
dicts:['pro_type','voltage_level'],
components: {
TableModel,
// FileSetForm
},
data() {
return {
formLabel,
columnsList,
getProListAPI,
title: "",
isflag: false,
isAdd: '',
row: {},
loading: false,
}
},
created() {
//
if (Array.isArray(this.formLabel)) {
this.formLabel.forEach((item) => {
if (item.f_dict && this.dict && this.dict.type && this.dict.type[item.f_dict]) {
this.$set(item, 'f_selList', this.dict.type[item.f_dict])
}
})
}
},
methods: {
closeDialog() {
this.isflag = false;
},
showColose() {
this.isflag = false;
},
/** 配置档案类型 */
handleUpdate(row) {
this.title = "配置档案类型";
this.isAdd = 'edit';
this.row = row;
this.isflag = true;
},
/* 搜索操作 */
handleQuery() {
this.$refs.proTableRef.getTableList()
},
},
}
</script>

View File

@ -50,16 +50,25 @@
</el-select>
</el-form-item>
<!-- 每月 -->
<!-- 每月选择时间 + 天数1-31 -->
<el-form-item v-if="periodicCycle==='monthly'" label="">
<el-date-picker
v-model="monthlyDateTime"
type="datetime"
placeholder="选择日期时间"
format="yyyy-MM-dd HH:mm"
value-format="yyyy-MM-dd HH:mm"
<el-time-picker
v-model="monthTime"
placeholder="选择时间"
format="HH:mm"
value-format="HH:mm"
:clearable="false"
style="margin-right: 10px;"
/>
<el-input-number
v-model="monthlyDay"
:min="1"
:max="31"
:step="1"
controls-position="right"
style="width: 140px;"
/>
<span style="margin-left: 6px;color:#909399;"></span>
</el-form-item>
</el-form>
</el-card>
@ -92,6 +101,7 @@
</template>
<script>
import { queryAPI, editAPI } from '@/api/filesTransfer/setting'
export default {
name: 'ArchiveSetting',
data() {
@ -102,7 +112,8 @@ export default {
dailyTime: '00:00',
weeklyTime: '00:00',
weeklyDay: '1',
monthlyDateTime: '',
monthTime: '00:00',
monthlyDay: 1,
//
nonPeriodicEnabled: true,
nonPeriodicDateTime: ''
@ -115,14 +126,15 @@ export default {
if (!this.weeklyTime) this.weeklyTime = '00:00'
if (!this.weeklyDay) this.weeklyDay = '1'
}
if (newVal === 'monthly' && !this.monthlyDateTime) {
// 00:00
const now = new Date()
now.setHours(0, 0, 0, 0)
this.monthlyDateTime = this.formatDateTime(now)
if (newVal === 'monthly') {
if (!this.monthTime) this.monthTime = '00:00'
if (!this.monthlyDay) this.monthlyDay = 1
}
}
},
created() {
this.query()
},
methods: {
formatDateTime(date) {
const y = date.getFullYear()
@ -132,22 +144,61 @@ export default {
const mm = String(date.getMinutes()).padStart(2, '0')
return `${y}-${m}-${d} ${hh}:${mm}`
},
//
handleSave() {
//
const payload = {
periodicEnabled: this.periodicEnabled,
periodicCycle: this.periodicCycle,
dailyTime: this.dailyTime,
weeklyTime: this.weeklyTime,
weeklyDay: this.weeklyDay,
monthlyDateTime: this.monthlyDateTime,
nonPeriodicEnabled: this.nonPeriodicEnabled,
nonPeriodicDateTime: this.nonPeriodicDateTime
//
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,
}
const payload = [periodicPayload, nonPeriodicPayload]
console.log('保存归档配置: ', payload)
this.$message.success('保存成功')
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
})
},
}
}
</script>

View File

@ -5,6 +5,9 @@
<div style="text-align:center">
<!-- 图片预览 -->
<template v-if="isImage">
<div class="image-toolbar">
<el-button size="mini" @click="downloadFile"><i class="el-icon-download"></i> 下载</el-button>
</div>
<el-image :src="processedFileUrl" :preview-src-list="previewList" fit="contain"
style="max-width:100%;max-height:70vh">
<div slot="error" class="image-slot">
@ -44,7 +47,9 @@
下一页 <i class="el-icon-arrow-right"></i>
</el-button>
</div>
<div class="pdf-actions">
<el-button size="mini" @click="downloadFile"><i class="el-icon-download"></i> 下载</el-button>
</div>
</div>
<!-- PDF显示区域 -->
@ -192,6 +197,57 @@ export default {
this.currentPage++;
}
},
// PDFbase64 -> Blobbase64
downloadFile() {
if (!this.fileUrl) return
const filename = this.fileName || '文件'
// MIME
let mime = this.isPdf ? 'application/pdf' : this.getImageMimeType()
// data: mime
let base64Data = this.fileUrl
if (typeof base64Data === 'string' && base64Data.startsWith('data:')) {
try {
const parts = base64Data.split(',')
const header = parts[0]
const dataPart = parts[1]
const match = header.match(/^data:(.*?);base64$/)
if (match && match[1]) mime = match[1]
base64Data = dataPart
} catch (e) {
//
}
}
const blob = this.base64ToBlob(base64Data, mime)
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.style.display = 'none'
a.href = url
a.download = filename
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
URL.revokeObjectURL(url)
},
// base64(data) Blob
base64ToBlob(base64, mime) {
const byteChars = atob(base64)
const sliceSize = 1024
const byteArrays = []
for (let offset = 0; offset < byteChars.length; offset += sliceSize) {
const slice = byteChars.slice(offset, offset + sliceSize)
const byteNumbers = new Array(slice.length)
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i)
}
const byteArray = new Uint8Array(byteNumbers)
byteArrays.push(byteArray)
}
return new Blob(byteArrays, { type: mime || 'application/octet-stream' })
},
// MIME
getImageMimeType() {
@ -344,6 +400,18 @@ export default {
gap: 8px;
}
.image-toolbar {
display: flex;
justify-content: flex-end;
padding: 4px 0 8px 0;
}
.pdf-actions {
display: flex;
align-items: center;
gap: 8px;
}
.page-info {
font-size: 14px;
color: #606266;