归档配置
This commit is contained in:
parent
aee364070d
commit
9144a584c6
|
|
@ -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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -203,7 +203,6 @@ export default {
|
||||||
const res = await getFileManageTreeApi({proId:this.projectId})
|
const res = await getFileManageTreeApi({proId:this.projectId})
|
||||||
const transformedData = this.convertToVueTree(res.data)
|
const transformedData = this.convertToVueTree(res.data)
|
||||||
this.treeDataList = transformedData;
|
this.treeDataList = transformedData;
|
||||||
console.log(this.treeDataList);
|
|
||||||
|
|
||||||
// 保存原始数据
|
// 保存原始数据
|
||||||
this.originalTreeData = JSON.parse(JSON.stringify(this.treeDataList))
|
this.originalTreeData = JSON.parse(JSON.stringify(this.treeDataList))
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,6 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
selectedNode: {
|
selectedNode: {
|
||||||
handler(newVal) {
|
handler(newVal) {
|
||||||
console.log(newVal);
|
|
||||||
this.addBtnIsShow = !(newVal && Number(newVal.level) === 4)
|
this.addBtnIsShow = !(newVal && Number(newVal.level) === 4)
|
||||||
// 更新并下发默认请求参数(例如 parentId)
|
// 更新并下发默认请求参数(例如 parentId)
|
||||||
const parentId = newVal && newVal.id ? newVal.id : 0
|
const parentId = newVal && newVal.id ? newVal.id : 0
|
||||||
|
|
|
||||||
|
|
@ -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: '匹配档案目录类型' },
|
||||||
|
]
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -50,16 +50,25 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<!-- 每月 -->
|
<!-- 每月:选择时间 + 天数(1-31) -->
|
||||||
<el-form-item v-if="periodicCycle==='monthly'" label="">
|
<el-form-item v-if="periodicCycle==='monthly'" label="">
|
||||||
<el-date-picker
|
<el-time-picker
|
||||||
v-model="monthlyDateTime"
|
v-model="monthTime"
|
||||||
type="datetime"
|
placeholder="选择时间"
|
||||||
placeholder="选择日期时间"
|
format="HH:mm"
|
||||||
format="yyyy-MM-dd HH:mm"
|
value-format="HH:mm"
|
||||||
value-format="yyyy-MM-dd HH:mm"
|
|
||||||
:clearable="false"
|
: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-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
@ -92,6 +101,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { queryAPI, editAPI } from '@/api/filesTransfer/setting'
|
||||||
export default {
|
export default {
|
||||||
name: 'ArchiveSetting',
|
name: 'ArchiveSetting',
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -102,7 +112,8 @@ export default {
|
||||||
dailyTime: '00:00',
|
dailyTime: '00:00',
|
||||||
weeklyTime: '00:00',
|
weeklyTime: '00:00',
|
||||||
weeklyDay: '1',
|
weeklyDay: '1',
|
||||||
monthlyDateTime: '',
|
monthTime: '00:00',
|
||||||
|
monthlyDay: 1,
|
||||||
// 不定期归档
|
// 不定期归档
|
||||||
nonPeriodicEnabled: true,
|
nonPeriodicEnabled: true,
|
||||||
nonPeriodicDateTime: ''
|
nonPeriodicDateTime: ''
|
||||||
|
|
@ -115,14 +126,15 @@ export default {
|
||||||
if (!this.weeklyTime) this.weeklyTime = '00:00'
|
if (!this.weeklyTime) this.weeklyTime = '00:00'
|
||||||
if (!this.weeklyDay) this.weeklyDay = '1'
|
if (!this.weeklyDay) this.weeklyDay = '1'
|
||||||
}
|
}
|
||||||
if (newVal === 'monthly' && !this.monthlyDateTime) {
|
if (newVal === 'monthly') {
|
||||||
// 默认今天 00:00
|
if (!this.monthTime) this.monthTime = '00:00'
|
||||||
const now = new Date()
|
if (!this.monthlyDay) this.monthlyDay = 1
|
||||||
now.setHours(0, 0, 0, 0)
|
|
||||||
this.monthlyDateTime = this.formatDateTime(now)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.query()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatDateTime(date) {
|
formatDateTime(date) {
|
||||||
const y = date.getFullYear()
|
const y = date.getFullYear()
|
||||||
|
|
@ -132,22 +144,61 @@ export default {
|
||||||
const mm = String(date.getMinutes()).padStart(2, '0')
|
const mm = String(date.getMinutes()).padStart(2, '0')
|
||||||
return `${y}-${m}-${d} ${hh}:${mm}`
|
return `${y}-${m}-${d} ${hh}:${mm}`
|
||||||
},
|
},
|
||||||
|
// 修改归档配置
|
||||||
handleSave() {
|
handleSave() {
|
||||||
// 这里只做前端演示,实际应调用后端接口保存
|
// 组合两条配置数据:第一条定期归档,第二条不定期归档
|
||||||
const payload = {
|
const periodicPayload = {
|
||||||
periodicEnabled: this.periodicEnabled,
|
useStatus: this.periodicEnabled ? 1 : 0,
|
||||||
periodicCycle: this.periodicCycle,
|
cycle: this.periodicCycle,
|
||||||
dailyTime: this.dailyTime,
|
time: this.dailyTime,
|
||||||
weeklyTime: this.weeklyTime,
|
time: this.weeklyTime,
|
||||||
weeklyDay: this.weeklyDay,
|
weekOfDay: this.weeklyDay,
|
||||||
monthlyDateTime: this.monthlyDateTime,
|
monthTime: this.monthTime,
|
||||||
nonPeriodicEnabled: this.nonPeriodicEnabled,
|
monthDay: this.monthlyDay,
|
||||||
nonPeriodicDateTime: this.nonPeriodicDateTime
|
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)
|
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>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
<div style="text-align:center">
|
<div style="text-align:center">
|
||||||
<!-- 图片预览 -->
|
<!-- 图片预览 -->
|
||||||
<template v-if="isImage">
|
<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"
|
<el-image :src="processedFileUrl" :preview-src-list="previewList" fit="contain"
|
||||||
style="max-width:100%;max-height:70vh">
|
style="max-width:100%;max-height:70vh">
|
||||||
<div slot="error" class="image-slot">
|
<div slot="error" class="image-slot">
|
||||||
|
|
@ -44,7 +47,9 @@
|
||||||
下一页 <i class="el-icon-arrow-right"></i>
|
下一页 <i class="el-icon-arrow-right"></i>
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pdf-actions">
|
||||||
|
<el-button size="mini" @click="downloadFile"><i class="el-icon-download"></i> 下载</el-button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- PDF显示区域 -->
|
<!-- PDF显示区域 -->
|
||||||
|
|
@ -192,6 +197,57 @@ export default {
|
||||||
this.currentPage++;
|
this.currentPage++;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 下载文件(图片或PDF,base64 -> Blob,避免在控制台暴露base64)
|
||||||
|
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类型
|
// 获取图片MIME类型
|
||||||
getImageMimeType() {
|
getImageMimeType() {
|
||||||
|
|
@ -344,6 +400,18 @@ export default {
|
||||||
gap: 8px;
|
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 {
|
.page-info {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #606266;
|
color: #606266;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue