Merge branch '0.9X' of http://49.232.154.205:10100/DeXun/klp-oa into 0.9X
This commit is contained in:
@@ -105,3 +105,45 @@ export function listVisibleUserByFileId(fileId) {
|
||||
params: { fileId: fileId }
|
||||
})
|
||||
}
|
||||
|
||||
// ============ OSS 上传 ============
|
||||
|
||||
// 上传文件到OSS
|
||||
export function uploadFile(file) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
return request({
|
||||
url: '/system/oss/upload',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
// ============ 文件图片关联 ============
|
||||
|
||||
// 新增图片关联
|
||||
export function addFileImage(data) {
|
||||
return request({
|
||||
url: '/system/fileImage',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改图片关联(替换图片)
|
||||
export function updateFileImage(data) {
|
||||
return request({
|
||||
url: '/system/fileImage',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除图片关联
|
||||
export function delFileImage(imageIds) {
|
||||
return request({
|
||||
url: '/system/fileImage/' + imageIds,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,3 +8,12 @@ export function getAnnealPerformance(query) {
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询退火计划中的加工前钢卷列表
|
||||
export function getAnnealRawCoils(query) {
|
||||
return request({
|
||||
url: '/wms/anneal/performance/rawCoils',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
10
klp-ui/src/api/wms/coilChangeLog.js
Normal file
10
klp-ui/src/api/wms/coilChangeLog.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 根据钢卷ID查询钢卷变更日志
|
||||
export function getCoilChangeLogByCoilId(coilId) {
|
||||
return request({
|
||||
url: '/wms/coilChangeLog/byCoilId/' + coilId,
|
||||
method: 'get',
|
||||
timeout: 100000
|
||||
})
|
||||
}
|
||||
@@ -49,7 +49,11 @@ export function parseTime(time, pattern) {
|
||||
// 表单重置
|
||||
export function resetForm(refName) {
|
||||
if (this.$refs[refName]) {
|
||||
this.$refs[refName].resetFields();
|
||||
try {
|
||||
this.$refs[refName].resetFields();
|
||||
} catch (e) {
|
||||
console.warn('resetFields error:', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1321,6 +1321,8 @@ export default {
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
this.chartSelectedKeys = selected
|
||||
// default: select all
|
||||
if (!this.chartSelectedKeys.length) this.chartSelectedKeys = [...allKeys]
|
||||
},
|
||||
saveChartSelection() {
|
||||
if (!this.activeReport) return
|
||||
@@ -1440,9 +1442,9 @@ export default {
|
||||
/deep/ .summary-row td .cell { color: #303133; }
|
||||
.summary-label { font-weight: bold; color: #303133; padding: 0 5px; }
|
||||
.summary-val { font-weight: bold; color: #303133; }
|
||||
/deep/ .chart-fullscreen { width: 100% !important; max-width: 100% !important; margin: 0 !important; }
|
||||
/deep/ .chart-fullscreen .el-dialog__body { max-height: calc(100vh - 90px); overflow: auto; padding: 16px 20px; }
|
||||
/deep/ .chart-fullscreen .el-dialog__header { padding: 12px 20px; }
|
||||
/deep/ .chart-fullscreen { width: 100% !important; max-width: 100% !important; height: 100vh !important; margin: 0 !important; display: flex; flex-direction: column; }
|
||||
/deep/ .chart-fullscreen .el-dialog__body { flex: 1; max-height: none; overflow: auto; padding: 16px 20px; }
|
||||
/deep/ .chart-fullscreen .el-dialog__header { padding: 12px 20px; flex-shrink: 0; }
|
||||
.chart-tag-bar { padding: 0 4px 8px; }
|
||||
.chart-tag-row { display: flex; flex-wrap: wrap; align-items: center; margin-bottom: 4px; }
|
||||
.chart-tag-row:last-child { margin-bottom: 0; }
|
||||
|
||||
@@ -75,10 +75,11 @@
|
||||
<el-option label="原料" value="raw_material" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发货状态">
|
||||
<el-select v-model="productCoilBo.status" placeholder="全部" clearable style="width: 100px;">
|
||||
<el-option label="在库" :value="0" />
|
||||
<el-option label="已发货" :value="1" />
|
||||
<el-form-item label="钢卷状态">
|
||||
<el-select v-model="productCoilBo.coilStatusType" placeholder="全部" clearable style="width: 100px;" @change="handleProductCoilStatusChange">
|
||||
<el-option label="在库" value="in_stock" />
|
||||
<el-option label="已发货" value="shipped" />
|
||||
<el-option label="历史卷" value="history" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="质量状态">
|
||||
@@ -134,10 +135,11 @@
|
||||
<el-option label="原料" value="raw_material" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发货状态">
|
||||
<el-select v-model="deliveryCoilBo.status" placeholder="全部" clearable style="width: 100px;">
|
||||
<el-option label="在库" :value="0" />
|
||||
<el-option label="已发货" :value="1" />
|
||||
<el-form-item label="钢卷状态">
|
||||
<el-select v-model="deliveryCoilBo.coilStatusType" placeholder="全部" clearable style="width: 100px;" @change="handleDeliveryCoilStatusChange">
|
||||
<el-option label="在库" value="in_stock" />
|
||||
<el-option label="已发货" value="shipped" />
|
||||
<el-option label="历史卷" value="history" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="质量状态">
|
||||
@@ -417,7 +419,7 @@ export default {
|
||||
orderId: this.orderId,
|
||||
pageNum: this.productPagination.currentPage,
|
||||
pageSize: this.productPagination.pageSize,
|
||||
...this.productCoilBo
|
||||
coilBo: this.productCoilBo
|
||||
}).then(res => {
|
||||
this.productCoilList = res.rows || [];
|
||||
this.productPagination.total = res.total || 0;
|
||||
@@ -431,7 +433,7 @@ export default {
|
||||
});
|
||||
},
|
||||
fetchProductCoilStatistics() {
|
||||
getProductCoilsStatisticsByContract({ ...this.productCoilBo, orderId: this.orderId }).then(res => {
|
||||
getProductCoilsStatisticsByContract({ orderId: this.orderId, coilBo: this.productCoilBo }).then(res => {
|
||||
this.productCoilStatistics = res.data || {};
|
||||
});
|
||||
},
|
||||
@@ -445,6 +447,21 @@ export default {
|
||||
this.productCoilBo = {};
|
||||
this.handleProductFilter();
|
||||
},
|
||||
handleProductCoilStatusChange(val) {
|
||||
if (val === 'in_stock') {
|
||||
this.productCoilBo.status = 0;
|
||||
this.productCoilBo.dataType = 1;
|
||||
} else if (val === 'shipped') {
|
||||
this.productCoilBo.status = 1;
|
||||
this.productCoilBo.dataType = undefined;
|
||||
} else if (val === 'history') {
|
||||
this.productCoilBo.status = 0;
|
||||
this.productCoilBo.dataType = 0;
|
||||
} else {
|
||||
this.productCoilBo.status = undefined;
|
||||
this.productCoilBo.dataType = undefined;
|
||||
}
|
||||
},
|
||||
handleDeliveryFilter() {
|
||||
this.deliveryCoilBo.selectType = this.deliveryCoilBo.itemType || '';
|
||||
this.deliveryPagination.currentPage = 1;
|
||||
@@ -455,6 +472,21 @@ export default {
|
||||
this.deliveryCoilBo = {};
|
||||
this.handleDeliveryFilter();
|
||||
},
|
||||
handleDeliveryCoilStatusChange(val) {
|
||||
if (val === 'in_stock') {
|
||||
this.deliveryCoilBo.status = 0;
|
||||
this.deliveryCoilBo.dataType = 1;
|
||||
} else if (val === 'shipped') {
|
||||
this.deliveryCoilBo.status = 1;
|
||||
this.deliveryCoilBo.dataType = undefined;
|
||||
} else if (val === 'history') {
|
||||
this.deliveryCoilBo.status = 0;
|
||||
this.deliveryCoilBo.dataType = 0;
|
||||
} else {
|
||||
this.deliveryCoilBo.status = undefined;
|
||||
this.deliveryCoilBo.dataType = undefined;
|
||||
}
|
||||
},
|
||||
handleProductPageChange({ currentPage, pageSize }) {
|
||||
this.productPagination.currentPage = currentPage;
|
||||
this.productPagination.pageSize = pageSize;
|
||||
|
||||
@@ -93,10 +93,11 @@
|
||||
<el-option label="原料" value="raw_material" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发货状态">
|
||||
<el-select v-model="productCoilBo.status" placeholder="全部" clearable style="width: 100px;">
|
||||
<el-option label="在库" :value="0" />
|
||||
<el-option label="已发货" :value="1" />
|
||||
<el-form-item label="钢卷状态">
|
||||
<el-select v-model="productCoilBo.coilStatusType" placeholder="全部" clearable style="width: 100px;" @change="handleCoilStatusChange">
|
||||
<el-option label="在库" value="in_stock" />
|
||||
<el-option label="已发货" value="shipped" />
|
||||
<el-option label="历史卷" value="history" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="质量状态">
|
||||
@@ -144,6 +145,13 @@
|
||||
<el-option label="原料" value="raw_material" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="钢卷状态">
|
||||
<el-select v-model="deliveryCoilBo.coilStatusType" placeholder="全部" clearable style="width: 100px;" @change="handleDeliveryCoilStatusChange">
|
||||
<el-option label="在库" value="in_stock" />
|
||||
<el-option label="已发货" value="shipped" />
|
||||
<el-option label="历史卷" value="history" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="质量状态">
|
||||
<muti-select v-model="deliveryCoilBo.qualityStatusCsv" :options="dict.type.coil_quality_status" placeholder="请选择品质" clearable style="width: 160px;" />
|
||||
</el-form-item>
|
||||
@@ -470,6 +478,36 @@ export default {
|
||||
this.productCoilBo = {};
|
||||
this.handleProductFilter();
|
||||
},
|
||||
handleCoilStatusChange(val) {
|
||||
if (val === 'in_stock') {
|
||||
this.productCoilBo.status = 0;
|
||||
this.productCoilBo.dataType = 1;
|
||||
} else if (val === 'shipped') {
|
||||
this.productCoilBo.status = 1;
|
||||
this.productCoilBo.dataType = undefined;
|
||||
} else if (val === 'history') {
|
||||
this.productCoilBo.status = 0;
|
||||
this.productCoilBo.dataType = 0;
|
||||
} else {
|
||||
this.productCoilBo.status = undefined;
|
||||
this.productCoilBo.dataType = undefined;
|
||||
}
|
||||
},
|
||||
handleDeliveryCoilStatusChange(val) {
|
||||
if (val === 'in_stock') {
|
||||
this.deliveryCoilBo.status = 0;
|
||||
this.deliveryCoilBo.dataType = 1;
|
||||
} else if (val === 'shipped') {
|
||||
this.deliveryCoilBo.status = 1;
|
||||
this.deliveryCoilBo.dataType = undefined;
|
||||
} else if (val === 'history') {
|
||||
this.deliveryCoilBo.status = 0;
|
||||
this.deliveryCoilBo.dataType = 0;
|
||||
} else {
|
||||
this.deliveryCoilBo.status = undefined;
|
||||
this.deliveryCoilBo.dataType = undefined;
|
||||
}
|
||||
},
|
||||
fetchDeliveryCoils(principal) {
|
||||
this.deliveryCoilLoading = true;
|
||||
return listDeliveryCoilsByPrincipal({
|
||||
|
||||
@@ -751,7 +751,7 @@ export default {
|
||||
.cell-input {
|
||||
width: 100%;
|
||||
height: 28px;
|
||||
border: none;
|
||||
border: 1px solid #dcdfe6;
|
||||
outline: none;
|
||||
text-align: right;
|
||||
padding: 0 6px;
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
@clear="handleQuery"
|
||||
/>
|
||||
<el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">上传文件</el-button>
|
||||
<el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
|
||||
<el-button v-if="isAdmin" type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete">删除</el-button>
|
||||
<span v-if="selectedCardIds.length > 0" class="selected-count">已选 {{ selectedCardIds.length }} 项</span>
|
||||
</div>
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<el-button type="text" size="mini" icon="el-icon-view" @click.stop="handleShowInfo(file)">详情</el-button>
|
||||
<el-button v-if="isAdmin || file.createBy === $store.getters.name" type="text" size="mini" icon="el-icon-edit" @click.stop="handleUpdate(file)">编辑</el-button>
|
||||
<el-button type="text" size="mini" icon="el-icon-download" @click.stop="downloadFile(file)">下载</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -139,25 +140,75 @@
|
||||
<el-dialog :title="dialogTitle" :visible.sync="open" width="650px" append-to-body @close="handleDialogClose">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="文件名称" prop="fileName">
|
||||
<el-input v-model="form.fileName" placeholder="请输入文件名称" :disabled="isEdit" />
|
||||
<el-input v-model="form.fileName" placeholder="请输入文件名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上传文件" v-if="!isEdit">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:action="uploadUrl"
|
||||
:headers="uploadHeaders"
|
||||
:file-list="uploadFileList"
|
||||
:before-upload="handleBeforeUpload"
|
||||
:on-success="handleUploadSuccess"
|
||||
:on-error="handleUploadError"
|
||||
:auto-upload="false"
|
||||
:limit="1"
|
||||
class="upload-demo"
|
||||
drag
|
||||
>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击选取</em></div>
|
||||
</el-upload>
|
||||
<!-- 上传模式 - 选择方式 -->
|
||||
<el-form-item label="上传方式" v-if="!isEdit">
|
||||
<el-radio-group v-model="uploadMode">
|
||||
<el-radio label="file">上传文件</el-radio>
|
||||
<el-radio label="image">上传图片</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<!-- 上传文件 -->
|
||||
<el-form-item v-if="!isEdit && uploadMode === 'file'" label="选择文件" required>
|
||||
<div class="file-upload-area">
|
||||
<input type="file" ref="mainFileInput" style="display:none" @change="handleMainFileSelect" />
|
||||
<el-button type="primary" @click="$refs.mainFileInput.click()">选择文件</el-button>
|
||||
<span class="upload-hint">支持 pdf / xlsx / docx / 图片 等格式</span>
|
||||
<div v-if="mainFile" class="main-file-info">
|
||||
<i class="el-icon-document"></i>
|
||||
<span class="main-file-name">{{ mainFile.name }}</span>
|
||||
<span class="main-file-size">({{ formatFileSize(mainFile.size) }})</span>
|
||||
<el-button type="text" size="mini" icon="el-icon-delete" @click="removeMainFile" style="color:#f56c6c;"></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- 上传图片(多张) -->
|
||||
<el-form-item v-if="!isEdit && uploadMode === 'image'" label="选择图片" required>
|
||||
<div class="image-upload-area">
|
||||
<input type="file" multiple accept="image/*" ref="fileInput" style="display:none" @change="handleFileSelect" />
|
||||
<el-button @click="$refs.fileInput.click()">选择图片</el-button>
|
||||
<span class="upload-hint">支持多选 jpg/png/webp/bmp</span>
|
||||
<div v-if="stagedImages.length > 0" class="image-grid">
|
||||
<div v-for="(img, idx) in stagedImages" :key="idx" class="image-item">
|
||||
<img :src="img.url" />
|
||||
<div class="image-item-mask">
|
||||
<el-button type="danger" size="mini" icon="el-icon-delete" circle @click="removeStagedImage(idx)"></el-button>
|
||||
</div>
|
||||
<div class="image-item-name">{{ img.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- 编辑模式 - 主文件信息 -->
|
||||
<el-form-item label="当前文件" v-if="isEdit && form.filePath">
|
||||
<div class="main-file-info">
|
||||
<i class="el-icon-document"></i>
|
||||
<span class="main-file-name">{{ form.fileName }}</span>
|
||||
<span class="main-file-size" v-if="form.fileSize">({{ formatFileSize(form.fileSize) }})</span>
|
||||
<el-button type="text" size="mini" icon="el-icon-refresh" @click="handleReplaceMainFile" style="margin-left:8px;">替换</el-button>
|
||||
<el-button type="text" size="mini" icon="el-icon-download" @click="downloadFile(form)" v-if="form.filePath">下载</el-button>
|
||||
<input type="file" ref="replaceMainFileInput" style="display:none" @change="handleReplaceMainFileSelect" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- 编辑模式 - 图片管理 -->
|
||||
<el-form-item label="文件图片" v-if="isEdit">
|
||||
<div v-if="form.imageList && form.imageList.length > 0" class="image-grid">
|
||||
<div v-for="(img, idx) in form.imageList" :key="img.imageId || idx" class="image-item">
|
||||
<img :src="img.imagePath" />
|
||||
<div class="image-item-mask">
|
||||
<el-button type="warning" size="mini" icon="el-icon-refresh" circle @click="handleReplaceImage(idx)" title="替换"></el-button>
|
||||
<el-button type="danger" size="mini" icon="el-icon-delete" circle @click="handleRemoveImage(idx)" title="删除"></el-button>
|
||||
</div>
|
||||
<div class="image-item-name">{{ img.imageName }}</div>
|
||||
</div>
|
||||
<div class="image-item image-add-btn" @click="handleAddImage">
|
||||
<i class="el-icon-plus"></i>
|
||||
<span>添加图片</span>
|
||||
</div>
|
||||
<input type="file" multiple accept="image/*" ref="editFileInput" style="display:none" @change="handleEditFileSelect" />
|
||||
</div>
|
||||
<div v-else class="no-images-hint">暂无图片,<el-button type="text" @click="handleAddImage">添加图片</el-button></div>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单编号" prop="orderNo">
|
||||
<el-input v-model="form.orderNo" placeholder="请输入订单编号" />
|
||||
@@ -194,14 +245,33 @@
|
||||
<div v-if="infoFile" class="info-dialog-body">
|
||||
<div class="info-main-row">
|
||||
<div class="info-preview">
|
||||
<ImagePreview v-if="infoFileCategory === 'image'" :src="infoFile.filePath" />
|
||||
<PdfPreview v-else-if="infoFileCategory === 'pdf'" :src="infoFile.filePath" />
|
||||
<DocxPreview v-else-if="infoFileCategory === 'docx'" :src="infoFile.filePath" />
|
||||
<XlsxPreview v-else-if="infoFileCategory === 'xlsx'" :src="infoFile.filePath" />
|
||||
<XlsPreview v-else-if="infoFileCategory === 'xls'" :src="infoFile.filePath" />
|
||||
<div v-else class="info-preview-empty">
|
||||
<el-empty description="暂不支持预览此文件类型" />
|
||||
</div>
|
||||
<!-- 多图模式 -->
|
||||
<template v-if="infoFile.imageList && infoFile.imageList.length > 0">
|
||||
<div class="image-carousel-wrap">
|
||||
<el-carousel height="400px" indicator-position="none" arrow="always" ref="previewCarousel" @change="handlePreviewChange">
|
||||
<el-carousel-item v-for="(img, idx) in infoFile.imageList" :key="idx">
|
||||
<el-image :src="img.imagePath" fit="contain" :preview-src-list="previewSrcList" :initial-index="idx" class="carousel-image" />
|
||||
</el-carousel-item>
|
||||
</el-carousel>
|
||||
<div class="thumbnail-strip">
|
||||
<div v-for="(img, idx) in infoFile.imageList" :key="idx" class="thumbnail-item" :class="{ active: activeImageIndex === idx }" @click="handleThumbnailClick(idx)">
|
||||
<img :src="img.imagePath" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="image-counter">{{ activeImageIndex + 1 }} / {{ infoFile.imageList.length }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 单文件模式 -->
|
||||
<template v-else>
|
||||
<ImagePreview v-if="infoFileCategory === 'image'" :src="infoFile.filePath" />
|
||||
<PdfPreview v-else-if="infoFileCategory === 'pdf'" :src="infoFile.filePath" />
|
||||
<DocxPreview v-else-if="infoFileCategory === 'docx'" :src="infoFile.filePath" />
|
||||
<XlsxPreview v-else-if="infoFileCategory === 'xlsx'" :src="infoFile.filePath" />
|
||||
<XlsPreview v-else-if="infoFileCategory === 'xls'" :src="infoFile.filePath" />
|
||||
<div v-else class="info-preview-empty">
|
||||
<el-empty description="暂不支持预览此文件类型" />
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="info-meta">
|
||||
<el-descriptions :column="1" border size="small">
|
||||
@@ -260,9 +330,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listFile, getFile, addFile, updateFile, delFile, exportFile, listVisibleUser, addVisibleUser, delVisibleUser, listVisibleUserByFileId, listRelatedToMe, incrementView } from '@/api/system/file'
|
||||
import { listFile, getFile, addFile, updateFile, delFile, exportFile, listVisibleUser, addVisibleUser, delVisibleUser, listVisibleUserByFileId, listRelatedToMe, incrementView, uploadFile, delFileImage } from '@/api/system/file'
|
||||
import { listFileComment, addFileComment } from '@/api/system/fileComment'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import UserSelect from '@/components/KLPService/UserSelect/index'
|
||||
import ImagePreview from '@/components/FilePreview/preview/image/index.vue'
|
||||
import PdfPreview from '@/components/FilePreview/preview/pdf/index.vue'
|
||||
@@ -326,7 +395,8 @@ export default {
|
||||
fileType: undefined,
|
||||
scopeType: 1,
|
||||
visibleUsers: [],
|
||||
remark: undefined
|
||||
remark: undefined,
|
||||
imageList: []
|
||||
},
|
||||
// 可见用户原始数据(编辑时回显)
|
||||
originalVisibleUsers: [],
|
||||
@@ -346,12 +416,12 @@ export default {
|
||||
privateFiles: 0,
|
||||
myFiles: 0
|
||||
},
|
||||
// 上传相关
|
||||
uploadUrl: process.env.VUE_APP_BASE_API + '/system/oss/upload',
|
||||
uploadHeaders: {
|
||||
Authorization: 'Bearer ' + getToken()
|
||||
},
|
||||
uploadFileList: [],
|
||||
// 上传方式 file | image
|
||||
uploadMode: 'file',
|
||||
// 多图上传
|
||||
mainFile: null,
|
||||
stagedImages: [],
|
||||
uploading: false,
|
||||
// 文件详情弹窗
|
||||
infoVisible: false,
|
||||
infoTitle: '',
|
||||
@@ -360,7 +430,9 @@ export default {
|
||||
comments: [],
|
||||
commentExpanded: false,
|
||||
commentInput: '',
|
||||
commentLoading: false
|
||||
commentLoading: false,
|
||||
// 详情弹窗多图预览
|
||||
activeImageIndex: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -380,6 +452,22 @@ export default {
|
||||
if (ext === 'xlsx') return 'xlsx'
|
||||
if (ext === 'xls') return 'xls'
|
||||
return 'other'
|
||||
},
|
||||
/** 多图预览源列表(用于全屏查看) */
|
||||
previewSrcList() {
|
||||
if (this.infoFile && this.infoFile.imageList && this.infoFile.imageList.length > 0) {
|
||||
return this.infoFile.imageList.map(img => img.imagePath)
|
||||
}
|
||||
return []
|
||||
},
|
||||
/** 是否管理员 */
|
||||
isAdmin() {
|
||||
try {
|
||||
const roles = this.$store.getters.roles
|
||||
return roles && roles.some && roles.some(r => r === 'admin')
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -446,10 +534,6 @@ export default {
|
||||
if (size < 1024 * 1024) return (size / 1024).toFixed(1) + ' KB'
|
||||
return (size / 1024 / 1024).toFixed(1) + ' MB'
|
||||
},
|
||||
/** 是否可编辑 */
|
||||
canEdit(row) {
|
||||
return row.createBy === this.$store.getters.name
|
||||
},
|
||||
/** 卡片选中判断 */
|
||||
isSelected(fileId) {
|
||||
return this.selectedCardIds.includes(fileId)
|
||||
@@ -492,11 +576,14 @@ export default {
|
||||
fileType: undefined,
|
||||
scopeType: 1,
|
||||
visibleUsers: [],
|
||||
remark: undefined
|
||||
remark: undefined,
|
||||
imageList: []
|
||||
}
|
||||
this.uploadFileList = []
|
||||
this.stagedImages = []
|
||||
this.mainFile = null
|
||||
this.originalVisibleUsers = []
|
||||
this.isEdit = false
|
||||
this.uploadMode = 'file'
|
||||
this.resetForm('form')
|
||||
},
|
||||
/** 可见范围切换 */
|
||||
@@ -547,6 +634,9 @@ export default {
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
this.isEdit = true
|
||||
this.dialogTitle = '编辑文件'
|
||||
// 先打开对话框,让用户感知操作已触发
|
||||
this.open = true
|
||||
const fileId = row.fileId || this.ids[0]
|
||||
getFile(fileId).then(response => {
|
||||
const data = response.data
|
||||
@@ -561,55 +651,225 @@ export default {
|
||||
fileType: data.fileType,
|
||||
scopeType: data.scopeType,
|
||||
visibleUsers: [],
|
||||
remark: data.remark
|
||||
remark: data.remark,
|
||||
imageList: data.imageList || []
|
||||
}
|
||||
if (data.scopeType === 2) {
|
||||
listVisibleUserByFileId(fileId).then(res => {
|
||||
const rows = res.rows || []
|
||||
this.form.visibleUsers = rows.map(r => r.userId)
|
||||
this.originalVisibleUsers = [...this.form.visibleUsers]
|
||||
// 去重,防止重复 userId 导致 el-select 渲染异常
|
||||
const userIds = [...new Set(rows.map(r => r.userId).filter(id => id != null))]
|
||||
this.form.visibleUsers = userIds
|
||||
this.originalVisibleUsers = [...userIds]
|
||||
}).catch(() => {
|
||||
// 可见用户加载失败不影响对话框使用
|
||||
})
|
||||
}
|
||||
this.open = true
|
||||
this.dialogTitle = '编辑文件'
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('获取文件信息失败')
|
||||
this.open = false
|
||||
})
|
||||
},
|
||||
/** 上传前校验 */
|
||||
handleBeforeUpload(file) {
|
||||
/** 上传模式:选择图片 */
|
||||
handleFileSelect(event) {
|
||||
const files = Array.from(event.target.files || [])
|
||||
files.forEach(file => {
|
||||
if (!file.type.startsWith('image/')) return
|
||||
this.stagedImages.push({
|
||||
file: file,
|
||||
url: URL.createObjectURL(file),
|
||||
name: file.name
|
||||
})
|
||||
})
|
||||
event.target.value = ''
|
||||
},
|
||||
|
||||
/** 上传模式:移除已选图片 */
|
||||
removeStagedImage(idx) {
|
||||
const img = this.stagedImages[idx]
|
||||
if (img && img.url) {
|
||||
URL.revokeObjectURL(img.url)
|
||||
}
|
||||
this.stagedImages.splice(idx, 1)
|
||||
},
|
||||
|
||||
/** 编辑模式:替换图片 */
|
||||
handleReplaceImage(idx) {
|
||||
this._replaceIndex = idx
|
||||
this.$refs.editFileInput.click()
|
||||
},
|
||||
|
||||
/** 编辑模式:删除图片 */
|
||||
handleRemoveImage(idx) {
|
||||
this.$modal.confirm('是否确认删除此图片?').then(() => {
|
||||
this.form.imageList.splice(idx, 1)
|
||||
}).catch(() => {})
|
||||
},
|
||||
|
||||
/** 编辑模式:添加新图片 */
|
||||
handleAddImage() {
|
||||
this._replaceIndex = null
|
||||
this.$refs.editFileInput.click()
|
||||
},
|
||||
|
||||
/** 编辑模式:文件选择后上传到 OSS */
|
||||
handleEditFileSelect(event) {
|
||||
const files = Array.from(event.target.files || [])
|
||||
if (files.length === 0) return
|
||||
event.target.value = ''
|
||||
|
||||
this.uploading = true
|
||||
const promises = files
|
||||
.filter(file => file.type.startsWith('image/'))
|
||||
.map(file => {
|
||||
return uploadFile(file).then(res => {
|
||||
if (res.code === 200) {
|
||||
return {
|
||||
imageName: file.name,
|
||||
imagePath: res.data.url,
|
||||
imageSize: file.size,
|
||||
suffix: file.name.split('.').pop().toLowerCase()
|
||||
}
|
||||
} else {
|
||||
this.$modal.msgError(res.msg || file.name + ' 上传失败')
|
||||
return null
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Promise.all(promises).then(results => {
|
||||
const validResults = results.filter(r => r != null)
|
||||
if (validResults.length === 0) return
|
||||
if (this._replaceIndex !== null && this._replaceIndex !== undefined) {
|
||||
validResults.forEach((img, i) => {
|
||||
const idx = this._replaceIndex + i
|
||||
if (idx < this.form.imageList.length) {
|
||||
this.$set(this.form.imageList, idx, img)
|
||||
} else {
|
||||
this.form.imageList.push(img)
|
||||
}
|
||||
})
|
||||
this._replaceIndex = null
|
||||
} else {
|
||||
validResults.forEach(img => this.form.imageList.push(img))
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('图片上传失败,请重试')
|
||||
}).finally(() => {
|
||||
this.uploading = false
|
||||
})
|
||||
},
|
||||
|
||||
/** 上传模式:选择主文件 */
|
||||
handleMainFileSelect(event) {
|
||||
const file = event.target.files && event.target.files[0]
|
||||
if (!file) return
|
||||
event.target.value = ''
|
||||
this.mainFile = file
|
||||
if (!this.form.fileName) {
|
||||
this.form.fileName = file.name
|
||||
}
|
||||
const ext = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase()
|
||||
this.form.suffix = ext
|
||||
this.form.fileSize = file.size
|
||||
},
|
||||
/** 上传成功 */
|
||||
handleUploadSuccess(response, file, fileList) {
|
||||
if (response.code === 200) {
|
||||
this.form.filePath = response.data.url
|
||||
this.form.fileName = this.form.fileName || response.data.fileName
|
||||
this.$modal.msgSuccess('文件上传成功')
|
||||
this.doSubmit()
|
||||
} else {
|
||||
this.$modal.msgError(response.msg || '上传失败')
|
||||
const name = file.name.lastIndexOf('.') > 0
|
||||
? file.name.substring(0, file.name.lastIndexOf('.'))
|
||||
: file.name
|
||||
this.form.fileName = name
|
||||
}
|
||||
},
|
||||
/** 上传失败 */
|
||||
handleUploadError(err, file, fileList) {
|
||||
this.$modal.msgError('文件上传失败')
|
||||
|
||||
/** 上传模式:移除已选主文件 */
|
||||
removeMainFile() {
|
||||
this.mainFile = null
|
||||
},
|
||||
|
||||
/** 编辑模式:触发替换主文件 */
|
||||
handleReplaceMainFile() {
|
||||
this.$refs.replaceMainFileInput.click()
|
||||
},
|
||||
|
||||
/** 编辑模式:选择替换的主文件后直接上传 OSS 并更新表单 */
|
||||
handleReplaceMainFileSelect(event) {
|
||||
const file = event.target.files && event.target.files[0]
|
||||
if (!file) return
|
||||
event.target.value = ''
|
||||
this.uploading = true
|
||||
uploadFile(file).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.form.filePath = res.data.url
|
||||
this.form.fileSize = file.size
|
||||
const ext = file.name.split('.').pop().toLowerCase()
|
||||
this.form.suffix = ext
|
||||
if (!this.form.fileName) {
|
||||
this.form.fileName = file.name.lastIndexOf('.') > 0
|
||||
? file.name.substring(0, file.name.lastIndexOf('.'))
|
||||
: file.name
|
||||
}
|
||||
this.$modal.msgSuccess('文件替换成功')
|
||||
} else {
|
||||
this.$modal.msgError(res.msg || '文件上传失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('文件上传失败')
|
||||
}).finally(() => {
|
||||
this.uploading = false
|
||||
})
|
||||
},
|
||||
|
||||
/** 提交表单 */
|
||||
submitForm() {
|
||||
this.$refs['form'].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.isEdit) {
|
||||
this.doSubmit()
|
||||
} else {
|
||||
if (this.$refs.upload && this.$refs.upload.uploadFiles.length > 0) {
|
||||
this.$refs.upload.submit()
|
||||
} else {
|
||||
} else if (this.uploadMode === 'file') {
|
||||
// 上传文件模式
|
||||
if (!this.mainFile) {
|
||||
this.$modal.msgWarning('请选择要上传的文件')
|
||||
return
|
||||
}
|
||||
this.uploading = true
|
||||
uploadFile(this.mainFile).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.form.filePath = res.data.url
|
||||
this.form.fileSize = this.mainFile.size
|
||||
this.form.suffix = this.mainFile.name.split('.').pop().toLowerCase()
|
||||
this.doSubmit()
|
||||
} else {
|
||||
this.$modal.msgError(res.msg || '文件上传失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('文件上传失败,请重试')
|
||||
}).finally(() => {
|
||||
this.uploading = false
|
||||
})
|
||||
} else if (this.uploadMode === 'image') {
|
||||
// 上传图片模式(串行避免前端防重复提交拦截)
|
||||
if (!this.stagedImages || this.stagedImages.length === 0) {
|
||||
this.$modal.msgWarning('请选择要上传的图片')
|
||||
return
|
||||
}
|
||||
this.uploading = true
|
||||
const imageList = []
|
||||
const uploadNext = (idx) => {
|
||||
if (idx >= this.stagedImages.length) {
|
||||
this.form.imageList = imageList
|
||||
this.doSubmit()
|
||||
return
|
||||
}
|
||||
const img = this.stagedImages[idx]
|
||||
uploadFile(img.file).then(res => {
|
||||
if (res.code === 200) {
|
||||
imageList.push({
|
||||
imageName: img.name,
|
||||
imagePath: res.data.url,
|
||||
imageSize: img.file.size,
|
||||
suffix: img.name.split('.').pop().toLowerCase()
|
||||
})
|
||||
}
|
||||
uploadNext(idx + 1)
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('图片上传失败:' + img.name)
|
||||
this.uploading = false
|
||||
})
|
||||
}
|
||||
uploadNext(0)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -679,10 +939,30 @@ export default {
|
||||
},
|
||||
/** 打开详情弹窗 */
|
||||
handleShowInfo(row) {
|
||||
this.infoFile = row
|
||||
this.activeImageIndex = 0
|
||||
this.infoTitle = '文件详情 - ' + row.fileName
|
||||
this.infoVisible = true
|
||||
incrementView(row.fileId)
|
||||
// 加载完整详情(含 imageList)
|
||||
getFile(row.fileId).then(response => {
|
||||
this.infoFile = response.data
|
||||
}).catch(() => {
|
||||
// 详情加载失败时用行数据兜底
|
||||
this.infoFile = row
|
||||
})
|
||||
},
|
||||
|
||||
/** 多图预览切换 */
|
||||
handlePreviewChange(idx) {
|
||||
this.activeImageIndex = idx
|
||||
},
|
||||
|
||||
/** 缩略图点击跳转 */
|
||||
handleThumbnailClick(idx) {
|
||||
this.activeImageIndex = idx
|
||||
if (this.$refs.previewCarousel) {
|
||||
this.$refs.previewCarousel.setActiveItem(idx)
|
||||
}
|
||||
},
|
||||
/** 点击行选中 */
|
||||
handleRowClick(row) {
|
||||
@@ -1168,4 +1448,206 @@ export default {
|
||||
padding: 8px 12px;
|
||||
border-top: 1px solid #f2f2f2;
|
||||
}
|
||||
|
||||
/* 图片上传/编辑区域 */
|
||||
.image-upload-area {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.upload-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.image-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.image-item {
|
||||
position: relative;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
cursor: default;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.image-item img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.image-item-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.image-item:hover .image-item-mask {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.image-item-name {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 2px 4px;
|
||||
font-size: 11px;
|
||||
color: #fff;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.image-add-btn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
border: 1px dashed #dcdfe6;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.image-add-btn:hover {
|
||||
border-color: #409eff;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.image-add-btn i {
|
||||
font-size: 28px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.image-count {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
/* 主文件上传区域 */
|
||||
.file-upload-area {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.main-file-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 8px;
|
||||
padding: 8px 12px;
|
||||
background: #f5f7fa;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.main-file-info .el-icon-document {
|
||||
font-size: 18px;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.main-file-name {
|
||||
color: #303133;
|
||||
max-width: 260px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.main-file-size {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.no-images-hint {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* 详情弹窗多图轮播 */
|
||||
.image-carousel-wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.image-carousel-wrap .el-carousel {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.carousel-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.carousel-image /deep/ .el-image__inner {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.thumbnail-strip {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
padding: 8px 0;
|
||||
overflow-x: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.thumbnail-item {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.thumbnail-item:hover {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
.thumbnail-item.active {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
.thumbnail-item img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.image-counter {
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -150,25 +150,75 @@
|
||||
<el-dialog :title="dialogTitle" :visible.sync="open" width="650px" append-to-body @close="handleDialogClose">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="文件名称" prop="fileName">
|
||||
<el-input v-model="form.fileName" placeholder="请输入文件名称" :disabled="isEdit" />
|
||||
<el-input v-model="form.fileName" placeholder="请输入文件名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="上传文件" v-if="!isEdit">
|
||||
<el-upload
|
||||
ref="upload"
|
||||
:action="uploadUrl"
|
||||
:headers="uploadHeaders"
|
||||
:file-list="uploadFileList"
|
||||
:before-upload="handleBeforeUpload"
|
||||
:on-success="handleUploadSuccess"
|
||||
:on-error="handleUploadError"
|
||||
:auto-upload="false"
|
||||
:limit="1"
|
||||
class="upload-demo"
|
||||
drag
|
||||
>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击选取</em></div>
|
||||
</el-upload>
|
||||
<!-- 上传模式 - 选择方式 -->
|
||||
<el-form-item label="上传方式" v-if="!isEdit">
|
||||
<el-radio-group v-model="uploadMode">
|
||||
<el-radio label="file">上传文件</el-radio>
|
||||
<el-radio label="image">上传图片</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<!-- 上传文件 -->
|
||||
<el-form-item v-if="!isEdit && uploadMode === 'file'" label="选择文件" required>
|
||||
<div class="file-upload-area">
|
||||
<input type="file" ref="mainFileInput" style="display:none" @change="handleMainFileSelect" />
|
||||
<el-button type="primary" @click="$refs.mainFileInput.click()">选择文件</el-button>
|
||||
<span class="upload-hint">支持 pdf / xlsx / docx / 图片 等格式</span>
|
||||
<div v-if="mainFile" class="main-file-info">
|
||||
<i class="el-icon-document"></i>
|
||||
<span class="main-file-name">{{ mainFile.name }}</span>
|
||||
<span class="main-file-size">({{ formatFileSize(mainFile.size) }})</span>
|
||||
<el-button type="text" size="mini" icon="el-icon-delete" @click="removeMainFile" style="color:#f56c6c;"></el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- 上传图片(多张) -->
|
||||
<el-form-item v-if="!isEdit && uploadMode === 'image'" label="选择图片" required>
|
||||
<div class="image-upload-area">
|
||||
<input type="file" multiple accept="image/*" ref="fileInput" style="display:none" @change="handleFileSelect" />
|
||||
<el-button @click="$refs.fileInput.click()">选择图片</el-button>
|
||||
<span class="upload-hint">支持多选 jpg/png/webp/bmp</span>
|
||||
<div v-if="stagedImages.length > 0" class="image-grid">
|
||||
<div v-for="(img, idx) in stagedImages" :key="idx" class="image-item">
|
||||
<img :src="img.url" />
|
||||
<div class="image-item-mask">
|
||||
<el-button type="danger" size="mini" icon="el-icon-delete" circle @click="removeStagedImage(idx)"></el-button>
|
||||
</div>
|
||||
<div class="image-item-name">{{ img.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- 编辑模式 - 主文件信息 -->
|
||||
<el-form-item label="当前文件" v-if="isEdit && form.filePath">
|
||||
<div class="main-file-info">
|
||||
<i class="el-icon-document"></i>
|
||||
<span class="main-file-name">{{ form.fileName }}</span>
|
||||
<span class="main-file-size" v-if="form.fileSize">({{ formatFileSize(form.fileSize) }})</span>
|
||||
<el-button type="text" size="mini" icon="el-icon-refresh" @click="handleReplaceMainFile" style="margin-left:8px;">替换</el-button>
|
||||
<el-button type="text" size="mini" icon="el-icon-download" @click="downloadFile(form)" v-if="form.filePath">下载</el-button>
|
||||
<input type="file" ref="replaceMainFileInput" style="display:none" @change="handleReplaceMainFileSelect" />
|
||||
</div>
|
||||
</el-form-item>
|
||||
<!-- 编辑模式 - 图片管理 -->
|
||||
<el-form-item label="文件图片" v-if="isEdit">
|
||||
<div v-if="form.imageList && form.imageList.length > 0" class="image-grid">
|
||||
<div v-for="(img, idx) in form.imageList" :key="img.imageId || idx" class="image-item">
|
||||
<img :src="img.imagePath" />
|
||||
<div class="image-item-mask">
|
||||
<el-button type="warning" size="mini" icon="el-icon-refresh" circle @click="handleReplaceImage(idx)" title="替换"></el-button>
|
||||
<el-button type="danger" size="mini" icon="el-icon-delete" circle @click="handleRemoveImage(idx)" title="删除"></el-button>
|
||||
</div>
|
||||
<div class="image-item-name">{{ img.imageName }}</div>
|
||||
</div>
|
||||
<div class="image-item image-add-btn" @click="handleAddImage">
|
||||
<i class="el-icon-plus"></i>
|
||||
<span>添加图片</span>
|
||||
</div>
|
||||
<input type="file" multiple accept="image/*" ref="editFileInput" style="display:none" @change="handleEditFileSelect" />
|
||||
</div>
|
||||
<div v-else class="no-images-hint">暂无图片,<el-button type="text" @click="handleAddImage">添加图片</el-button></div>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单编号" prop="orderNo">
|
||||
<el-input v-model="form.orderNo" placeholder="请输入订单编号" />
|
||||
@@ -204,14 +254,33 @@
|
||||
<el-dialog :title="infoTitle" :visible.sync="infoVisible" width="1100px" append-to-body top="5vh" @close="handleInfoClose">
|
||||
<div v-if="infoFile" class="info-dialog-body">
|
||||
<div class="info-preview">
|
||||
<ImagePreview v-if="infoFileCategory === 'image'" :src="infoFile.filePath" />
|
||||
<PdfPreview v-else-if="infoFileCategory === 'pdf'" :src="infoFile.filePath" />
|
||||
<DocxPreview v-else-if="infoFileCategory === 'docx'" :src="infoFile.filePath" />
|
||||
<XlsxPreview v-else-if="infoFileCategory === 'xlsx'" :src="infoFile.filePath" />
|
||||
<XlsPreview v-else-if="infoFileCategory === 'xls'" :src="infoFile.filePath" />
|
||||
<div v-else class="info-preview-empty">
|
||||
<el-empty description="暂不支持预览此文件类型" />
|
||||
</div>
|
||||
<!-- 多图模式 -->
|
||||
<template v-if="infoFile.imageList && infoFile.imageList.length > 0">
|
||||
<div class="image-carousel-wrap">
|
||||
<el-carousel height="400px" indicator-position="none" arrow="always" ref="previewCarousel" @change="handlePreviewChange">
|
||||
<el-carousel-item v-for="(img, idx) in infoFile.imageList" :key="idx">
|
||||
<el-image :src="img.imagePath" fit="contain" :preview-src-list="previewSrcList" :initial-index="idx" class="carousel-image" />
|
||||
</el-carousel-item>
|
||||
</el-carousel>
|
||||
<div class="thumbnail-strip">
|
||||
<div v-for="(img, idx) in infoFile.imageList" :key="idx" class="thumbnail-item" :class="{ active: activeImageIndex === idx }" @click="handleThumbnailClick(idx)">
|
||||
<img :src="img.imagePath" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="image-counter">{{ activeImageIndex + 1 }} / {{ infoFile.imageList.length }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 单文件模式 -->
|
||||
<template v-else>
|
||||
<ImagePreview v-if="infoFileCategory === 'image'" :src="infoFile.filePath" />
|
||||
<PdfPreview v-else-if="infoFileCategory === 'pdf'" :src="infoFile.filePath" />
|
||||
<DocxPreview v-else-if="infoFileCategory === 'docx'" :src="infoFile.filePath" />
|
||||
<XlsxPreview v-else-if="infoFileCategory === 'xlsx'" :src="infoFile.filePath" />
|
||||
<XlsPreview v-else-if="infoFileCategory === 'xls'" :src="infoFile.filePath" />
|
||||
<div v-else class="info-preview-empty">
|
||||
<el-empty description="暂不支持预览此文件类型" />
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="info-meta">
|
||||
<el-descriptions :column="1" border size="small">
|
||||
@@ -269,9 +338,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listFile, getFile, addFile, updateFile, delFile, exportFile, listVisibleUser, addVisibleUser, delVisibleUser, listVisibleUserByFileId, listRelatedToMe, incrementView } from '@/api/system/file'
|
||||
import { listFile, getFile, addFile, updateFile, delFile, exportFile, listVisibleUser, addVisibleUser, delVisibleUser, listVisibleUserByFileId, listRelatedToMe, incrementView, uploadFile, delFileImage } from '@/api/system/file'
|
||||
import { listFileComment, addFileComment } from '@/api/system/fileComment'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import UserSelect from '@/components/KLPService/UserSelect/index'
|
||||
import ImagePreview from '@/components/FilePreview/preview/image/index.vue'
|
||||
import PdfPreview from '@/components/FilePreview/preview/pdf/index.vue'
|
||||
@@ -338,7 +406,8 @@ export default {
|
||||
fileType: undefined,
|
||||
scopeType: 1,
|
||||
visibleUsers: [],
|
||||
remark: undefined
|
||||
remark: undefined,
|
||||
imageList: []
|
||||
},
|
||||
// 可见用户原始数据(编辑时回显)
|
||||
originalVisibleUsers: [],
|
||||
@@ -351,12 +420,12 @@ export default {
|
||||
{ required: true, message: '请选择文件类型', trigger: 'change' }
|
||||
]
|
||||
},
|
||||
// 上传相关
|
||||
uploadUrl: process.env.VUE_APP_BASE_API + '/system/oss/upload',
|
||||
uploadHeaders: {
|
||||
Authorization: 'Bearer ' + getToken()
|
||||
},
|
||||
uploadFileList: [],
|
||||
// 上传方式 file | image
|
||||
uploadMode: 'file',
|
||||
// 多图上传
|
||||
mainFile: null,
|
||||
stagedImages: [],
|
||||
uploading: false,
|
||||
// 文件详情弹窗
|
||||
infoVisible: false,
|
||||
infoTitle: '',
|
||||
@@ -365,7 +434,9 @@ export default {
|
||||
comments: [],
|
||||
commentExpanded: false,
|
||||
commentInput: '',
|
||||
commentLoading: false
|
||||
commentLoading: false,
|
||||
// 详情弹窗多图预览
|
||||
activeImageIndex: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -385,6 +456,13 @@ export default {
|
||||
if (ext === 'xlsx') return 'xlsx'
|
||||
if (ext === 'xls') return 'xls'
|
||||
return 'other'
|
||||
},
|
||||
/** 多图预览源列表(用于全屏查看) */
|
||||
previewSrcList() {
|
||||
if (this.infoFile && this.infoFile.imageList && this.infoFile.imageList.length > 0) {
|
||||
return this.infoFile.imageList.map(img => img.imagePath)
|
||||
}
|
||||
return []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -458,20 +536,23 @@ export default {
|
||||
reset() {
|
||||
this.form = {
|
||||
fileId: undefined,
|
||||
fileName: undefined,
|
||||
filePath: undefined,
|
||||
fileSize: undefined,
|
||||
suffix: undefined,
|
||||
orderNo: undefined,
|
||||
dept: undefined,
|
||||
fileType: undefined,
|
||||
fileName: '',
|
||||
filePath: '',
|
||||
fileSize: '',
|
||||
suffix: '',
|
||||
orderNo: '',
|
||||
dept: '',
|
||||
fileType: '',
|
||||
scopeType: 1,
|
||||
visibleUsers: [],
|
||||
remark: undefined
|
||||
remark: '',
|
||||
imageList: []
|
||||
}
|
||||
this.uploadFileList = []
|
||||
this.stagedImages = []
|
||||
this.mainFile = null
|
||||
this.originalVisibleUsers = []
|
||||
this.isEdit = false
|
||||
this.uploadMode = 'file'
|
||||
this.resetForm('form')
|
||||
},
|
||||
/** 可见范围切换 */
|
||||
@@ -527,6 +608,9 @@ export default {
|
||||
handleUpdate(row) {
|
||||
this.reset()
|
||||
this.isEdit = true
|
||||
this.dialogTitle = '编辑文件'
|
||||
// 先打开对话框,让用户感知操作已触发
|
||||
this.open = true
|
||||
const fileId = row.fileId || this.ids[0]
|
||||
getFile(fileId).then(response => {
|
||||
const data = response.data
|
||||
@@ -541,55 +625,228 @@ export default {
|
||||
fileType: data.fileType,
|
||||
scopeType: data.scopeType,
|
||||
visibleUsers: [],
|
||||
remark: data.remark
|
||||
remark: data.remark,
|
||||
imageList: data.imageList || []
|
||||
}
|
||||
if (data.scopeType === 2) {
|
||||
listVisibleUserByFileId(fileId).then(res => {
|
||||
const rows = res.rows || []
|
||||
this.form.visibleUsers = rows.map(r => r.userId)
|
||||
this.originalVisibleUsers = [...this.form.visibleUsers]
|
||||
// 去重,防止重复 userId 导致 el-select 渲染异常
|
||||
const userIds = [...new Set(rows.map(r => r.userId).filter(id => id != null))]
|
||||
this.form.visibleUsers = userIds
|
||||
this.originalVisibleUsers = [...userIds]
|
||||
}).catch(() => {
|
||||
// 可见用户加载失败不影响对话框使用
|
||||
})
|
||||
}
|
||||
this.open = true
|
||||
this.dialogTitle = '编辑文件'
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('获取文件信息失败')
|
||||
this.open = false
|
||||
})
|
||||
},
|
||||
/** 上传前校验 */
|
||||
handleBeforeUpload(file) {
|
||||
/** 上传模式:选择图片 */
|
||||
handleFileSelect(event) {
|
||||
const files = Array.from(event.target.files || [])
|
||||
files.forEach(file => {
|
||||
if (!file.type.startsWith('image/')) return
|
||||
this.stagedImages.push({
|
||||
file: file,
|
||||
url: URL.createObjectURL(file),
|
||||
name: file.name
|
||||
})
|
||||
})
|
||||
event.target.value = ''
|
||||
},
|
||||
|
||||
/** 上传模式:移除已选图片 */
|
||||
removeStagedImage(idx) {
|
||||
const img = this.stagedImages[idx]
|
||||
if (img && img.url) {
|
||||
URL.revokeObjectURL(img.url)
|
||||
}
|
||||
this.stagedImages.splice(idx, 1)
|
||||
},
|
||||
|
||||
/** 编辑模式:替换图片 */
|
||||
handleReplaceImage(idx) {
|
||||
this._replaceIndex = idx
|
||||
this.$refs.editFileInput.click()
|
||||
},
|
||||
|
||||
/** 编辑模式:删除图片 */
|
||||
handleRemoveImage(idx) {
|
||||
this.$modal.confirm('是否确认删除此图片?').then(() => {
|
||||
this.form.imageList.splice(idx, 1)
|
||||
}).catch(() => {})
|
||||
},
|
||||
|
||||
/** 编辑模式:添加新图片 */
|
||||
handleAddImage() {
|
||||
this._replaceIndex = null
|
||||
this.$refs.editFileInput.click()
|
||||
},
|
||||
|
||||
/** 编辑模式:文件选择后上传到 OSS */
|
||||
handleEditFileSelect(event) {
|
||||
const files = Array.from(event.target.files || [])
|
||||
if (files.length === 0) return
|
||||
event.target.value = ''
|
||||
|
||||
this.uploading = true
|
||||
const promises = files
|
||||
.filter(file => file.type.startsWith('image/'))
|
||||
.map(file => {
|
||||
return uploadFile(file).then(res => {
|
||||
if (res.code === 200) {
|
||||
return {
|
||||
imageName: file.name,
|
||||
imagePath: res.data.url,
|
||||
imageSize: file.size,
|
||||
suffix: file.name.split('.').pop().toLowerCase()
|
||||
}
|
||||
} else {
|
||||
this.$modal.msgError(res.msg || file.name + ' 上传失败')
|
||||
return null
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Promise.all(promises).then(results => {
|
||||
const validResults = results.filter(r => r != null)
|
||||
if (validResults.length === 0) return
|
||||
if (this._replaceIndex !== null && this._replaceIndex !== undefined) {
|
||||
// 替换已有图片
|
||||
validResults.forEach((img, i) => {
|
||||
const idx = this._replaceIndex + i
|
||||
if (idx < this.form.imageList.length) {
|
||||
this.$set(this.form.imageList, idx, img)
|
||||
} else {
|
||||
this.form.imageList.push(img)
|
||||
}
|
||||
})
|
||||
this._replaceIndex = null
|
||||
} else {
|
||||
// 新增图片
|
||||
validResults.forEach(img => this.form.imageList.push(img))
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('图片上传失败,请重试')
|
||||
}).finally(() => {
|
||||
this.uploading = false
|
||||
})
|
||||
},
|
||||
|
||||
/** 上传模式:选择主文件 */
|
||||
handleMainFileSelect(event) {
|
||||
const file = event.target.files && event.target.files[0]
|
||||
if (!file) return
|
||||
event.target.value = ''
|
||||
this.mainFile = file
|
||||
// 自动填充文件名(不含扩展名)
|
||||
if (!this.form.fileName) {
|
||||
this.form.fileName = file.name
|
||||
}
|
||||
const ext = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase()
|
||||
this.form.suffix = ext
|
||||
this.form.fileSize = file.size
|
||||
},
|
||||
/** 上传成功 */
|
||||
handleUploadSuccess(response, file, fileList) {
|
||||
if (response.code === 200) {
|
||||
this.form.filePath = response.data.url
|
||||
this.form.fileName = this.form.fileName || response.data.fileName
|
||||
this.$modal.msgSuccess('文件上传成功')
|
||||
this.doSubmit()
|
||||
} else {
|
||||
this.$modal.msgError(response.msg || '上传失败')
|
||||
const name = file.name.lastIndexOf('.') > 0
|
||||
? file.name.substring(0, file.name.lastIndexOf('.'))
|
||||
: file.name
|
||||
this.form.fileName = name
|
||||
}
|
||||
},
|
||||
/** 上传失败 */
|
||||
handleUploadError(err, file, fileList) {
|
||||
this.$modal.msgError('文件上传失败')
|
||||
|
||||
/** 上传模式:移除已选主文件 */
|
||||
removeMainFile() {
|
||||
this.mainFile = null
|
||||
},
|
||||
|
||||
/** 编辑模式:触发替换主文件 */
|
||||
handleReplaceMainFile() {
|
||||
this.$refs.replaceMainFileInput.click()
|
||||
},
|
||||
|
||||
/** 编辑模式:选择替换的主文件后直接上传 OSS 并更新表单 */
|
||||
handleReplaceMainFileSelect(event) {
|
||||
const file = event.target.files && event.target.files[0]
|
||||
if (!file) return
|
||||
event.target.value = ''
|
||||
this.uploading = true
|
||||
uploadFile(file).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.form.filePath = res.data.url
|
||||
this.form.fileSize = file.size
|
||||
const ext = file.name.split('.').pop().toLowerCase()
|
||||
this.form.suffix = ext
|
||||
if (!this.form.fileName) {
|
||||
this.form.fileName = file.name.lastIndexOf('.') > 0
|
||||
? file.name.substring(0, file.name.lastIndexOf('.'))
|
||||
: file.name
|
||||
}
|
||||
this.$modal.msgSuccess('文件替换成功')
|
||||
} else {
|
||||
this.$modal.msgError(res.msg || '文件上传失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('文件上传失败')
|
||||
}).finally(() => {
|
||||
this.uploading = false
|
||||
})
|
||||
},
|
||||
|
||||
/** 提交表单 */
|
||||
submitForm() {
|
||||
this.$refs['form'].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.isEdit) {
|
||||
this.doSubmit()
|
||||
} else {
|
||||
if (this.$refs.upload && this.$refs.upload.uploadFiles.length > 0) {
|
||||
this.$refs.upload.submit()
|
||||
} else {
|
||||
} else if (this.uploadMode === 'file') {
|
||||
// 上传文件模式
|
||||
if (!this.mainFile) {
|
||||
this.$modal.msgWarning('请选择要上传的文件')
|
||||
return
|
||||
}
|
||||
this.uploading = true
|
||||
uploadFile(this.mainFile).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.form.filePath = res.data.url
|
||||
this.form.fileSize = this.mainFile.size
|
||||
this.form.suffix = this.mainFile.name.split('.').pop().toLowerCase()
|
||||
this.doSubmit()
|
||||
} else {
|
||||
this.$modal.msgError(res.msg || '文件上传失败')
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('文件上传失败,请重试')
|
||||
}).finally(() => {
|
||||
this.uploading = false
|
||||
})
|
||||
} else if (this.uploadMode === 'image') {
|
||||
// 上传图片模式(串行避免前端防重复提交拦截)
|
||||
if (!this.stagedImages || this.stagedImages.length === 0) {
|
||||
this.$modal.msgWarning('请选择要上传的图片')
|
||||
return
|
||||
}
|
||||
this.uploading = true
|
||||
const imageList = []
|
||||
const uploadNext = (idx) => {
|
||||
if (idx >= this.stagedImages.length) {
|
||||
this.form.imageList = imageList
|
||||
this.doSubmit()
|
||||
return
|
||||
}
|
||||
const img = this.stagedImages[idx]
|
||||
uploadFile(img.file).then(res => {
|
||||
if (res.code === 200) {
|
||||
imageList.push({
|
||||
imageName: img.name,
|
||||
imagePath: res.data.url,
|
||||
imageSize: img.file.size,
|
||||
suffix: img.name.split('.').pop().toLowerCase()
|
||||
})
|
||||
}
|
||||
uploadNext(idx + 1)
|
||||
}).catch(() => {
|
||||
this.$modal.msgError('图片上传失败:' + img.name)
|
||||
this.uploading = false
|
||||
})
|
||||
}
|
||||
uploadNext(0)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -665,10 +922,30 @@ export default {
|
||||
},
|
||||
/** 打开详情弹窗 */
|
||||
handleShowInfo(row) {
|
||||
this.infoFile = row
|
||||
this.activeImageIndex = 0
|
||||
this.infoTitle = '文件详情 - ' + row.fileName
|
||||
this.infoVisible = true
|
||||
incrementView(row.fileId)
|
||||
// 加载完整详情(含 imageList)
|
||||
getFile(row.fileId).then(response => {
|
||||
this.infoFile = response.data
|
||||
}).catch(() => {
|
||||
// 详情加载失败时用行数据兜底
|
||||
this.infoFile = row
|
||||
})
|
||||
},
|
||||
|
||||
/** 多图预览切换 */
|
||||
handlePreviewChange(idx) {
|
||||
this.activeImageIndex = idx
|
||||
},
|
||||
|
||||
/** 缩略图点击跳转 */
|
||||
handleThumbnailClick(idx) {
|
||||
this.activeImageIndex = idx
|
||||
if (this.$refs.previewCarousel) {
|
||||
this.$refs.previewCarousel.setActiveItem(idx)
|
||||
}
|
||||
},
|
||||
/** 点击行选中 */
|
||||
handleRowClick(row) {
|
||||
@@ -829,11 +1106,6 @@ export default {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 上传区域 */
|
||||
.upload-demo {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 操作列按钮对齐 */
|
||||
.action-cell {
|
||||
display: flex;
|
||||
@@ -962,6 +1234,208 @@ export default {
|
||||
padding: 8px 12px;
|
||||
border-top: 1px solid #f2f2f2;
|
||||
}
|
||||
|
||||
/* 图片上传/编辑区域 */
|
||||
.image-upload-area {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.upload-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.image-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.image-item {
|
||||
position: relative;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
cursor: default;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.image-item img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.image-item-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.image-item:hover .image-item-mask {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.image-item-name {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 2px 4px;
|
||||
font-size: 11px;
|
||||
color: #fff;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.image-add-btn {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
border: 1px dashed #dcdfe6;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.image-add-btn:hover {
|
||||
border-color: #409eff;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.image-add-btn i {
|
||||
font-size: 28px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.image-count {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
/* 主文件上传区域 */
|
||||
.file-upload-area {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.main-file-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 8px;
|
||||
padding: 8px 12px;
|
||||
background: #f5f7fa;
|
||||
border: 1px solid #e4e7ed;
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.main-file-info .el-icon-document {
|
||||
font-size: 18px;
|
||||
color: #409eff;
|
||||
}
|
||||
|
||||
.main-file-name {
|
||||
color: #303133;
|
||||
max-width: 260px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.main-file-size {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.no-images-hint {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* 详情弹窗多图轮播 */
|
||||
.image-carousel-wrap {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.image-carousel-wrap .el-carousel {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.carousel-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.carousel-image /deep/ .el-image__inner {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.thumbnail-strip {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
padding: 8px 0;
|
||||
overflow-x: auto;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.thumbnail-item {
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border: 2px solid transparent;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
|
||||
.thumbnail-item:hover {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
.thumbnail-item.active {
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
.thumbnail-item img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.image-counter {
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- 表格选中行高亮 -->
|
||||
|
||||
@@ -1,75 +1,119 @@
|
||||
<template>
|
||||
<div class="app-container" v-loading="loading">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="90px">
|
||||
<el-form-item label="时间">
|
||||
<time-range-picker v-model="timeRangeParams" start-key="startTime" end-key="endTime"
|
||||
:default-start-time="queryParams.startTime" :default-end-time="queryParams.endTime"
|
||||
@quick-select="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="目标炉" prop="targetFurnaceId">
|
||||
<el-select v-model="queryParams.targetFurnaceId" placeholder="请选择" clearable filterable>
|
||||
<el-option v-for="item in furnaceOptions" :key="item.furnaceId" :label="item.furnaceName"
|
||||
:value="item.furnaceId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划号" prop="planNo">
|
||||
<el-input v-model="queryParams.planNo" placeholder="请输入计划号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
||||
<el-input v-model="queryParams.enterCoilNo" placeholder="请输入入场钢卷号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="当前钢卷号" prop="currentCoilNo">
|
||||
<el-input v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="出炉库区" prop="warehouseId">
|
||||
<WarehouseSelect v-model="queryParams.warehouseId" placeholder="请选择" clearable filterable />
|
||||
</el-form-item>
|
||||
<el-form-item label="逻辑库区" prop="coilWarehouseId">
|
||||
<WarehouseSelect v-model="queryParams.coilWarehouseId" placeholder="请选择" clearable filterable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
<el-button icon="el-icon-download" size="mini" @click="exportData">导出</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- <el-tabs v-model="activeTab" @tab-click="handleTabClick">
|
||||
<el-tab-pane label="退火后" name="processed" />
|
||||
<el-tab-pane label="加工前" name="raw" />
|
||||
</el-tabs> -->
|
||||
|
||||
<el-descriptions title="统计信息" :column="3" class="summary-block" border>
|
||||
<el-descriptions-item label="计划数量">{{ summary.planCount || 0 }}</el-descriptions-item>
|
||||
<el-descriptions-item label="钢卷数量">{{ summary.coilCount || 0 }}</el-descriptions-item>
|
||||
<el-descriptions-item label="总重量">{{ summary.totalWeight || 0 }} t</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<!-- ========== 退火后 ========== -->
|
||||
<template v-if="activeTab === 'processed'">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="90px">
|
||||
<el-form-item label="时间">
|
||||
<time-range-picker v-model="timeRangeParams" start-key="startTime" end-key="endTime"
|
||||
:default-start-time="queryParams.startTime" :default-end-time="queryParams.endTime"
|
||||
@quick-select="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="目标炉" prop="targetFurnaceId">
|
||||
<el-select v-model="queryParams.targetFurnaceId" placeholder="请选择" clearable filterable>
|
||||
<el-option v-for="item in furnaceOptions" :key="item.furnaceId" :label="item.furnaceName"
|
||||
:value="item.furnaceId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划号" prop="planNo">
|
||||
<el-input v-model="queryParams.planNo" placeholder="请输入计划号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
||||
<el-input v-model="queryParams.enterCoilNo" placeholder="请输入入场钢卷号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="当前钢卷号" prop="currentCoilNo">
|
||||
<el-input v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="出炉库区" prop="warehouseId">
|
||||
<WarehouseSelect v-model="queryParams.warehouseId" placeholder="请选择" clearable filterable />
|
||||
</el-form-item>
|
||||
<el-form-item label="逻辑库区" prop="coilWarehouseId">
|
||||
<WarehouseSelect v-model="queryParams.coilWarehouseId" placeholder="请选择" clearable filterable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
<el-button icon="el-icon-download" size="mini" @click="exportData">导出</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table :data="detailList" border height="calc(100vh - 330px)">
|
||||
<el-table-column label="计划号" prop="planNo" align="center" />
|
||||
<el-table-column label="目标炉" prop="targetFurnaceName" align="center" />
|
||||
<el-table-column label="开始时间" prop="actualStartTime" align="center" width="160">
|
||||
<template slot-scope="scope">
|
||||
{{ parseTime(scope.row.actualStartTime, '{y}-{m}-{d} {h}:{i}') }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="结束时间" prop="endTime" align="center" width="160">
|
||||
<template slot-scope="scope">
|
||||
{{ parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}') }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品类型" align="center" width="250">
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row" />
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="出炉库区" prop="logicWarehouseName" align="center" />
|
||||
<el-table-column label="逻辑库区" prop="warehouseName" align="center" />
|
||||
<el-table-column label="入场钢卷号" prop="enterCoilNo" align="center" />
|
||||
<el-table-column label="当前钢卷号" prop="currentCoilNo" align="center" />
|
||||
<el-table-column label="重量(t)" prop="netWeight" align="center" />
|
||||
</el-table>
|
||||
<el-descriptions title="统计信息" :column="3" class="summary-block" border>
|
||||
<el-descriptions-item label="计划数量">{{ summary.planCount || 0 }}</el-descriptions-item>
|
||||
<el-descriptions-item label="钢卷数量">{{ summary.coilCount || 0 }}</el-descriptions-item>
|
||||
<el-descriptions-item label="总重量">{{ summary.totalWeight || 0 }} t</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-table :data="detailList" border height="calc(100vh - 330px)">
|
||||
<el-table-column label="计划号" prop="planNo" align="center" />
|
||||
<el-table-column label="目标炉" prop="targetFurnaceName" align="center" />
|
||||
<el-table-column label="开始时间" prop="actualStartTime" align="center" width="160">
|
||||
<template slot-scope="scope">
|
||||
{{ parseTime(scope.row.actualStartTime, '{y}-{m}-{d} {h}:{i}') }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="结束时间" prop="endTime" align="center" width="160">
|
||||
<template slot-scope="scope">
|
||||
{{ parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}') }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品类型" align="center" width="250">
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row" />
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="出炉库区" prop="logicWarehouseName" align="center" />
|
||||
<el-table-column label="逻辑库区" prop="warehouseName" align="center" />
|
||||
<el-table-column label="入场钢卷号" prop="enterCoilNo" align="center" />
|
||||
<el-table-column label="当前钢卷号" prop="currentCoilNo" align="center" />
|
||||
<el-table-column label="重量(t)" prop="netWeight" align="center" />
|
||||
</el-table>
|
||||
</template>
|
||||
|
||||
<!-- ========== 加工前 ========== -->
|
||||
<template v-if="activeTab === 'raw'">
|
||||
<el-form :model="rawQueryParams" ref="rawQueryForm" size="small" :inline="true" label-width="90px">
|
||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
||||
<el-input v-model="rawQueryParams.enterCoilNo" placeholder="请输入入场钢卷号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="当前钢卷号" prop="currentCoilNo">
|
||||
<el-input v-model="rawQueryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="逻辑库区" prop="warehouseId">
|
||||
<WarehouseSelect v-model="rawQueryParams.warehouseId" placeholder="请选择" clearable filterable />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetRawQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-descriptions title="统计信息" :column="2" class="summary-block" border>
|
||||
<el-descriptions-item label="钢卷数量">{{ rawSummary.coilCount || 0 }}</el-descriptions-item>
|
||||
<el-descriptions-item label="总重量">{{ rawSummary.totalWeight || 0 }} t</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-table :data="rawDetailList" border height="calc(100vh - 330px)">
|
||||
<el-table-column label="入场钢卷号" prop="enterCoilNo" align="center" width="140" />
|
||||
<el-table-column label="当前钢卷号" prop="currentCoilNo" align="center" width="140" />
|
||||
<el-table-column label="物料名称" prop="itemName" align="center" />
|
||||
<el-table-column label="物料编码" prop="itemCode" align="center" />
|
||||
<el-table-column label="规格" prop="specification" align="center" />
|
||||
<el-table-column label="材质" prop="material" align="center" />
|
||||
<el-table-column label="锌层" prop="zincLayer" align="center" />
|
||||
<el-table-column label="重量(t)" prop="netWeight" align="center" />
|
||||
<el-table-column label="逻辑库区" prop="warehouseName" align="center" />
|
||||
</el-table>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getAnnealPerformance } from "@/api/wms/annealPerformance";
|
||||
import { getAnnealPerformance, getAnnealRawCoils } from "@/api/wms/annealPerformance";
|
||||
import { listAnnealFurnace } from "@/api/wms/annealFurnace";
|
||||
import ProductInfo from "@/components/KLPService/Renderer/ProductInfo";
|
||||
import RawMaterialInfo from "@/components/KLPService/Renderer/RawMaterialInfo";
|
||||
@@ -96,7 +140,9 @@ export default {
|
||||
return `${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,'0')}-${String(d.getDate()).padStart(2,'0')} 00:00:00`;
|
||||
})()
|
||||
return {
|
||||
activeTab: 'processed',
|
||||
loading: false,
|
||||
// 退火后查询参数
|
||||
timeRangeParams: {
|
||||
startTime,
|
||||
endTime,
|
||||
@@ -114,6 +160,14 @@ export default {
|
||||
summary: {},
|
||||
detailList: [],
|
||||
furnaceOptions: [],
|
||||
// 加工前查询参数
|
||||
rawQueryParams: {
|
||||
enterCoilNo: undefined,
|
||||
currentCoilNo: undefined,
|
||||
warehouseId: undefined,
|
||||
},
|
||||
rawSummary: {},
|
||||
rawDetailList: [],
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@@ -138,26 +192,42 @@ export default {
|
||||
},
|
||||
handleQuery() {
|
||||
this.loading = true;
|
||||
getAnnealPerformance(this.queryParams).then(response => {
|
||||
const data = response.data || {};
|
||||
this.summary = data.summary || {};
|
||||
this.detailList = data.details.map(item => {
|
||||
return item.coils?.map(coil => {
|
||||
return {
|
||||
...item,
|
||||
...coil,
|
||||
}
|
||||
}) || []
|
||||
}).flat();
|
||||
this.loading = false;
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
if (this.activeTab === 'raw') {
|
||||
getAnnealRawCoils(this.rawQueryParams).then(response => {
|
||||
const list = response.data || [];
|
||||
this.rawDetailList = list;
|
||||
this.rawSummary = {
|
||||
coilCount: list.length,
|
||||
totalWeight: list.reduce((s, r) => s + Number(r.netWeight || 0), 0).toFixed(3),
|
||||
};
|
||||
this.loading = false;
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
} else {
|
||||
getAnnealPerformance(this.queryParams).then(response => {
|
||||
const data = response.data || {};
|
||||
this.summary = data.summary || {};
|
||||
this.detailList = (data.details || []).map(item => {
|
||||
return item.coil ? { ...item, ...item.coil } : item;
|
||||
});
|
||||
this.loading = false;
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
handleTabClick() {
|
||||
this.handleQuery();
|
||||
},
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
resetRawQuery() {
|
||||
this.resetForm("rawQueryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
exportData() {
|
||||
this.download('/wms/materialCoil/exportAnneal', {
|
||||
coilIds: this.detailList.map(item => item.coilId).join(','),
|
||||
|
||||
486
klp-ui/src/views/wms/coil/info/components/ChangeLogSection.vue
Normal file
486
klp-ui/src/views/wms/coil/info/components/ChangeLogSection.vue
Normal file
@@ -0,0 +1,486 @@
|
||||
<template>
|
||||
<div class="section change-log-section">
|
||||
<div class="section-header">
|
||||
<span class="section-icon">📝</span>
|
||||
<span class="section-title">修改日志</span>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<el-table
|
||||
v-if="changeLogs.length"
|
||||
:data="changeLogs"
|
||||
border
|
||||
stripe
|
||||
size="small"
|
||||
v-loading="loading"
|
||||
:header-cell-style="{ background: '#f5f7fa', color: '#303133', fontWeight: 600 }"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-table-column prop="operationDesc" label="操作类型" min-width="120" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
<span class="operation-badge">{{ scope.row.operationDesc }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="修改信息" min-width="420">
|
||||
<template slot-scope="scope">
|
||||
<div class="change-log-line">
|
||||
<div class="change-log-line-boxes">
|
||||
<div
|
||||
v-for="(item, idx) in scope.row.previewItems"
|
||||
:key="scope.row.logId + '-' + idx"
|
||||
class="mini-change-item"
|
||||
:title="previewText(item)"
|
||||
>
|
||||
<span class="mini-change-label">{{ item.label }}</span>
|
||||
<span class="mini-change-box old">{{ item.oldText }}</span>
|
||||
<span class="mini-change-arrow">→</span>
|
||||
<span class="mini-change-box new">{{ item.newText }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<el-button
|
||||
v-if="scope.row.moreCount > 0"
|
||||
type="text"
|
||||
size="mini"
|
||||
class="more-btn"
|
||||
@click="openMoreDialog(scope.row)"
|
||||
>
|
||||
更多 {{ scope.row.moreCount }} 项
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createBy" label="修改人" width="120" show-overflow-tooltip />
|
||||
<el-table-column label="修改时间" width="170" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
{{ formatDateTime(scope.row.createTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-empty
|
||||
v-else-if="!loading"
|
||||
description="暂无修改日志"
|
||||
:image-size="60"
|
||||
/>
|
||||
|
||||
<el-dialog
|
||||
title="全部修改信息"
|
||||
:visible.sync="dialogVisible"
|
||||
width="960px"
|
||||
append-to-body
|
||||
>
|
||||
<div v-if="activeLog" class="change-log-dialog">
|
||||
<div class="change-log-dialog-meta">
|
||||
<span>操作类型:{{ activeLog.operationDesc }}</span>
|
||||
<span>修改人:{{ activeLog.createBy }}</span>
|
||||
<span>修改时间:{{ formatDateTime(activeLog.createTime) }}</span>
|
||||
</div>
|
||||
<div class="change-log-grid all-items">
|
||||
<div
|
||||
v-for="(item, idx) in activeLog.summaryItems"
|
||||
:key="'dialog-' + activeLog.logId + '-' + idx"
|
||||
class="change-log-card"
|
||||
>
|
||||
<div class="change-log-card-header">
|
||||
<span class="change-field-name">{{ item.label }}</span>
|
||||
</div>
|
||||
<div class="change-log-card-body">
|
||||
<div class="change-value-box old">
|
||||
<span class="change-value-label">原值</span>
|
||||
<span class="change-value-text">{{ item.oldText }}</span>
|
||||
</div>
|
||||
<span class="change-arrow">→</span>
|
||||
<div class="change-value-box new">
|
||||
<span class="change-value-label">新值</span>
|
||||
<span class="change-value-text">{{ item.newText }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCoilChangeLogByCoilId } from '@/api/wms/coilChangeLog'
|
||||
|
||||
const CHANGE_FIELD_LABELS = {
|
||||
currentCoilNo: '当前钢卷号',
|
||||
enterCoilNo: '入场钢卷号',
|
||||
supplierCoilNo: '厂家原料号',
|
||||
itemName: '物料名称',
|
||||
specification: '规格',
|
||||
material: '材质',
|
||||
netWeight: '净重',
|
||||
grossWeight: '毛重',
|
||||
warehouseName: '库位',
|
||||
actualWarehouseName: '实际库区',
|
||||
qualityStatus: '质量状态',
|
||||
manufacturer: '厂家',
|
||||
zincLayer: '镀层质量',
|
||||
status: '状态',
|
||||
remark: '备注',
|
||||
saleName: '销售员',
|
||||
actualLength: '实际长度',
|
||||
actualWidth: '实际宽度',
|
||||
actualThickness: '实际厚度',
|
||||
length: '长度',
|
||||
theoreticalLength: '理论长度',
|
||||
theoreticalThickness: '理论厚度',
|
||||
trimmingRequirement: '净边料要求',
|
||||
packagingRequirement: '包装要求',
|
||||
contractNo: '合同号',
|
||||
chromePlateCoilNo: '镀铬卷号',
|
||||
productionStartTime: '生产开始时间',
|
||||
productionEndTime: '生产结束时间',
|
||||
productionDuration: '生产时长'
|
||||
}
|
||||
|
||||
const HIDDEN_CHANGE_FIELDS = new Set([
|
||||
'warehouseId',
|
||||
'actualWarehouseId',
|
||||
'itemId',
|
||||
'parentCoilId',
|
||||
'parentCoilIds',
|
||||
'parentCoilNos',
|
||||
'hasMergeSplit',
|
||||
'exclusiveStatus'
|
||||
])
|
||||
|
||||
const PREVIEW_ITEM_LIMIT = 3
|
||||
|
||||
export default {
|
||||
name: 'ChangeLogSection',
|
||||
props: {
|
||||
coilId: { type: [String, Number], default: '' }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
changeLogs: [],
|
||||
dialogVisible: false,
|
||||
activeLog: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
coilId: {
|
||||
immediate: true,
|
||||
handler(val) {
|
||||
if (val) {
|
||||
this.loadChangeLogs()
|
||||
} else {
|
||||
this.changeLogs = []
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatDateTime(val) {
|
||||
if (!val) return '-'
|
||||
const date = new Date(val)
|
||||
if (isNaN(date.getTime())) return String(val)
|
||||
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')
|
||||
const ss = String(date.getSeconds()).padStart(2, '0')
|
||||
return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
|
||||
},
|
||||
getFieldLabel(field) {
|
||||
return CHANGE_FIELD_LABELS[field] || field
|
||||
},
|
||||
shouldHideField(field, diffMap) {
|
||||
if (HIDDEN_CHANGE_FIELDS.has(field)) return true
|
||||
if (field.endsWith('Id') && diffMap[`${field.slice(0, -2)}Name`]) return true
|
||||
return false
|
||||
},
|
||||
normalizeDisplayValue(field, val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
if (typeof val === 'number' && /Time$/.test(field)) {
|
||||
return this.formatDateTime(val)
|
||||
}
|
||||
if (typeof val === 'string' && /^\d{13}$/.test(val) && /Time$/.test(field)) {
|
||||
return this.formatDateTime(Number(val))
|
||||
}
|
||||
if (Array.isArray(val)) return val.length ? val.join(', ') : '-'
|
||||
if (typeof val === 'object') {
|
||||
try {
|
||||
return JSON.stringify(val)
|
||||
} catch (e) {
|
||||
return String(val)
|
||||
}
|
||||
}
|
||||
return String(val)
|
||||
},
|
||||
buildSummaryItem(field, oldVal, newVal) {
|
||||
const oldText = this.normalizeDisplayValue(field, oldVal)
|
||||
const newText = this.normalizeDisplayValue(field, newVal)
|
||||
if (oldText === newText) return null
|
||||
return {
|
||||
field,
|
||||
label: this.getFieldLabel(field),
|
||||
oldText,
|
||||
newText
|
||||
}
|
||||
},
|
||||
buildSummaryItems(log) {
|
||||
const items = []
|
||||
if (log.changedFields) {
|
||||
try {
|
||||
const diffMap = JSON.parse(log.changedFields)
|
||||
Object.keys(diffMap || {}).forEach(key => {
|
||||
if (this.shouldHideField(key, diffMap)) return
|
||||
const item = diffMap[key] || {}
|
||||
const summaryItem = this.buildSummaryItem(key, item.old, item.new)
|
||||
if (summaryItem) items.push(summaryItem)
|
||||
})
|
||||
} catch (e) {
|
||||
items.push({
|
||||
field: 'raw',
|
||||
label: '修改内容',
|
||||
oldText: '-',
|
||||
newText: log.changedFields
|
||||
})
|
||||
}
|
||||
}
|
||||
if (!items.length && log.oldCoilNo !== log.newCoilNo) {
|
||||
items.push(this.buildSummaryItem('currentCoilNo', log.oldCoilNo, log.newCoilNo))
|
||||
}
|
||||
if (!items.length && log.operationDesc) {
|
||||
items.push({
|
||||
field: 'operationDesc',
|
||||
label: '修改内容',
|
||||
oldText: '-',
|
||||
newText: log.operationDesc
|
||||
})
|
||||
}
|
||||
return items.length ? items : [{
|
||||
field: 'empty',
|
||||
label: '修改内容',
|
||||
oldText: '-',
|
||||
newText: '-'
|
||||
}]
|
||||
},
|
||||
previewText(item) {
|
||||
if (!item) return '-'
|
||||
return `${item.label}:${item.oldText}→${item.newText}`
|
||||
},
|
||||
openMoreDialog(row) {
|
||||
this.activeLog = row
|
||||
this.dialogVisible = true
|
||||
},
|
||||
async loadChangeLogs() {
|
||||
if (!this.coilId) return
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await getCoilChangeLogByCoilId(this.coilId)
|
||||
const rows = (res && res.data) || []
|
||||
this.changeLogs = rows.map(item => ({
|
||||
...item,
|
||||
createBy: item.createBy || '-',
|
||||
operationDesc: item.operationDesc || '-',
|
||||
summaryItems: this.buildSummaryItems(item)
|
||||
})).map(item => {
|
||||
const previewItems = (item.summaryItems || []).slice(0, PREVIEW_ITEM_LIMIT)
|
||||
return {
|
||||
...item,
|
||||
previewItems,
|
||||
moreCount: Math.max(item.summaryItems.length - previewItems.length, 0)
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('获取钢卷修改日志失败:', e)
|
||||
this.changeLogs = []
|
||||
this.activeLog = null
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.operation-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
border-radius: 11px;
|
||||
background: rgba(59, 130, 246, 0.1);
|
||||
border: 1px solid rgba(59, 130, 246, 0.18);
|
||||
color: #2563eb;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.change-log-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.change-log-line-boxes {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.mini-change-item {
|
||||
flex: 0 0 auto;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 2px 6px;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.mini-change-label {
|
||||
color: #475569;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.mini-change-box {
|
||||
display: inline-block;
|
||||
max-width: 140px;
|
||||
padding: 0 6px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid transparent;
|
||||
font-size: 11px;
|
||||
line-height: 18px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.mini-change-box.old {
|
||||
background: #fff7ed;
|
||||
border-color: #fed7aa;
|
||||
}
|
||||
|
||||
.mini-change-box.new {
|
||||
background: #ecfdf5;
|
||||
border-color: #a7f3d0;
|
||||
}
|
||||
|
||||
.mini-change-arrow {
|
||||
color: #94a3b8;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.change-log-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
||||
gap: 6px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.change-log-grid.all-items {
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
}
|
||||
|
||||
.more-btn {
|
||||
padding: 0;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.change-log-card {
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.change-log-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 26px;
|
||||
padding: 0 8px;
|
||||
background: #f8fafc;
|
||||
border-bottom: 1px solid #edf2f7;
|
||||
}
|
||||
|
||||
.change-field-name {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.change-log-card-body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 8px;
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
.change-value-box {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
padding: 6px 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #ebeef5;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.change-value-box.old {
|
||||
background: #fff7ed;
|
||||
border-color: #fed7aa;
|
||||
}
|
||||
|
||||
.change-value-box.new {
|
||||
background: #ecfdf5;
|
||||
border-color: #a7f3d0;
|
||||
}
|
||||
|
||||
.change-value-label {
|
||||
margin-bottom: 2px;
|
||||
font-size: 10px;
|
||||
color: #94a3b8;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.change-value-text {
|
||||
color: #1e293b;
|
||||
font-size: 11px;
|
||||
line-height: 1.35;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.change-arrow {
|
||||
flex: 0 0 auto;
|
||||
color: #94a3b8;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.change-log-dialog-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px 20px;
|
||||
margin-bottom: 10px;
|
||||
color: #606266;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.change-log-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -53,6 +53,7 @@
|
||||
<div v-else-if="!pathLoading && pathChecked" class="cost-chart-wrap">
|
||||
<el-empty description="暂无加工路径数据" :image-size="60" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -704,4 +705,5 @@ export default {
|
||||
font-weight: 600;
|
||||
color: #f56c6c;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<template>
|
||||
<template>
|
||||
<div class="coil-info-page" v-loading="loading">
|
||||
<div class="content-container">
|
||||
<BasicInfoSection :coilInfo="coilInfo" :initialQualityStatus="initialQualityStatus" />
|
||||
@@ -42,6 +42,8 @@
|
||||
<ProductionCharts v-if="isColdHardCoil"
|
||||
:segData="segData" :gaugeRows="gaugeRows" :shapeRows="shapeRows"
|
||||
:perfSegCount="perfSegCount" :segLoading="segLoading" :realtimeLoading="realtimeLoading" />
|
||||
|
||||
<ChangeLogSection :coil-id="coilId" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -64,6 +66,7 @@ import LifecycleTrace from './components/LifecycleTrace.vue'
|
||||
import ContractInfo from './components/ContractInfo.vue'
|
||||
import SalesObjectionTable from './components/SalesObjectionTable.vue'
|
||||
import TransferRecords from './components/TransferRecords.vue'
|
||||
import ChangeLogSection from './components/ChangeLogSection.vue'
|
||||
// import InspectionInfo from './components/InspectionInfo.vue'
|
||||
import ProductionCharts from './components/ProductionCharts.vue'
|
||||
|
||||
@@ -77,6 +80,7 @@ export default {
|
||||
ContractInfo,
|
||||
SalesObjectionTable,
|
||||
TransferRecords,
|
||||
ChangeLogSection,
|
||||
// InspectionInfo,
|
||||
ProductionCharts
|
||||
},
|
||||
|
||||
@@ -142,10 +142,11 @@
|
||||
<el-option label="原料" value="raw_material" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发货状态">
|
||||
<el-select v-model="productCoilBo.status" placeholder="全部" clearable style="width: 100px;">
|
||||
<el-option label="在库" :value="0" />
|
||||
<el-option label="已发货" :value="1" />
|
||||
<el-form-item label="钢卷状态">
|
||||
<el-select v-model="productCoilBo.coilStatusType" placeholder="全部" clearable style="width: 100px;" @change="handleCoilStatusChange">
|
||||
<el-option label="在库" value="in_stock" />
|
||||
<el-option label="已发货" value="shipped" />
|
||||
<el-option label="历史卷" value="history" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="质量状态">
|
||||
@@ -433,7 +434,7 @@ export default {
|
||||
orderId: this.currentOrder.orderId,
|
||||
pageNum: this.productPagination.currentPage,
|
||||
pageSize: this.productPagination.pageSize,
|
||||
...this.productCoilBo
|
||||
coilBo: this.productCoilBo
|
||||
}).then(res => {
|
||||
this.productCoilList = res.rows || []
|
||||
this.productPagination.total = res.total || 0
|
||||
@@ -443,7 +444,7 @@ export default {
|
||||
},
|
||||
fetchProductCoilStatistics() {
|
||||
if (!this.currentOrder || !this.currentOrder.orderId) return
|
||||
getProductCoilsStatisticsByContract({ ...this.productCoilBo, orderId: this.currentOrder.orderId }).then(res => {
|
||||
getProductCoilsStatisticsByContract({ orderId: this.currentOrder.orderId, coilBo: this.productCoilBo }).then(res => {
|
||||
this.productCoilStatistics = res.data || {}
|
||||
})
|
||||
},
|
||||
@@ -457,6 +458,21 @@ export default {
|
||||
this.productCoilBo = {}
|
||||
this.handleProductFilter()
|
||||
},
|
||||
handleCoilStatusChange(val) {
|
||||
if (val === 'in_stock') {
|
||||
this.productCoilBo.status = 0;
|
||||
this.productCoilBo.dataType = 1;
|
||||
} else if (val === 'shipped') {
|
||||
this.productCoilBo.status = 1;
|
||||
this.productCoilBo.dataType = undefined;
|
||||
} else if (val === 'history') {
|
||||
this.productCoilBo.status = 0;
|
||||
this.productCoilBo.dataType = 0;
|
||||
} else {
|
||||
this.productCoilBo.status = undefined;
|
||||
this.productCoilBo.dataType = undefined;
|
||||
}
|
||||
},
|
||||
handleProductSelectionChange(selection) {
|
||||
this.selectedProductRows = selection
|
||||
},
|
||||
|
||||
@@ -524,7 +524,12 @@ export default {
|
||||
endDate = `${dateStr}-${lastDayOfMonth.toString().padStart(2, '0')}`;
|
||||
} else if (dayPattern.test(dateStr)) {
|
||||
startDate = dateStr;
|
||||
endDate = dateStr;
|
||||
const nextDay = new Date(dateStr);
|
||||
nextDay.setDate(nextDay.getDate() + 1);
|
||||
const nextYear = nextDay.getFullYear();
|
||||
const nextMonth = String(nextDay.getMonth() + 1).padStart(2, '0');
|
||||
const nextDayNum = String(nextDay.getDate()).padStart(2, '0');
|
||||
endDate = `${nextYear}-${nextMonth}-${nextDayNum}`;
|
||||
} else {
|
||||
throw new Error('输入格式错误,请传入 yyyy、yyyy-MM 或 yyyy-MM-dd 格式的字符串');
|
||||
}
|
||||
@@ -552,7 +557,7 @@ export default {
|
||||
defaultEndTime,
|
||||
getDayTimeRange,
|
||||
// all 类型专用
|
||||
viewType: 'custom',
|
||||
viewType: 'day',
|
||||
yesterdaySummary: {},
|
||||
monthChart: null,
|
||||
dayChart: null,
|
||||
@@ -734,9 +739,9 @@ export default {
|
||||
this.queryParams.byCreateTimeStart = start;
|
||||
this.queryParams.byCreateTimeEnd = end;
|
||||
} else if (this.reportType === 'all') {
|
||||
// all 类型默认使用当前月份作为自定义时间范围
|
||||
this.viewType = 'custom';
|
||||
const { start, end } = this.getDayTimeRange(this.monthDate);
|
||||
// all 类型默认使用日视图,选中今天,筛选今天07:00到明天07:00的数据
|
||||
this.viewType = 'day';
|
||||
const { start, end } = this.getDayTimeRange(this.dayDate);
|
||||
this.queryParams.startTime = start;
|
||||
this.queryParams.endTime = end;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user