Browse Source

缓存记录,弹框修改

java8
han\hanst 4 months ago
parent
commit
97a726dcb3
  1. 372
      src/views/modules/ecss/del_upload_excel.vue

372
src/views/modules/ecss/del_upload_excel.vue

@ -1,7 +1,7 @@
<template>
<div class="customer-css">
<el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible"
:width="showPreview ? '1200px' : '600px'" class="customer-dialog" @close="deleteFile">
:width="showPreview ? '1200px' : '600px'" class="customer-dialog" >
<el-form label-position="top">
<el-row :gutter="16">
<el-col :span="12">
@ -64,7 +64,9 @@
placeholder="请选择客户"
@dblclick.native="selectCustomerForRow(scope.row)"
size="small"
style="cursor: pointer;">
style="cursor: pointer;"
readonly>
<i slot="suffix" class="el-icon-edit" style="cursor: pointer;" @click.stop="openEditDialog(scope.row, 'selectedCustomer', '客户', '编辑客户信息')"></i>
</el-input>
</template>
</el-table-column>
@ -75,7 +77,9 @@
placeholder="请选择客户地址"
@dblclick.native="selectLocalAddressForRow(scope.row)"
size="small"
style="cursor: pointer;">
style="cursor: pointer;"
readonly>
<i slot="suffix" class="el-icon-edit" style="cursor: pointer;" @click.stop="openEditDialog(scope.row, 'selectedLocalAddress', '客户地址', '编辑客户地址')"></i>
</el-input>
</template>
</el-table-column>
@ -86,7 +90,9 @@
placeholder="请选择收货单位"
@dblclick.native="selectOverseasShipperForRow(scope.row)"
size="small"
style="cursor: pointer;">
style="cursor: pointer;"
readonly>
<i slot="suffix" class="el-icon-edit" style="cursor: pointer;" @click.stop="openEditDialog(scope.row, 'selectedOverseasShipper', '收货单位', '编辑收货单位')"></i>
</el-input>
</template>
</el-table-column>
@ -97,18 +103,34 @@
placeholder="请选择收货单位地址"
@dblclick.native="selectOverseasAddressForRow(scope.row)"
size="small"
style="cursor: pointer;">
style="cursor: pointer;"
readonly>
<i slot="suffix" class="el-icon-edit" style="cursor: pointer;" @click.stop="openEditDialog(scope.row, 'selectedOverseasAddress', '收货单位地址', '编辑收货单位地址')"></i>
</el-input>
</template>
</el-table-column>
<el-table-column label="运抵国" width="90">
<template slot-scope="scope">
<el-input v-model="scope.row.selectedCnative" placeholder="运抵国" size="small"></el-input>
<el-input
v-model="scope.row.selectedCnative"
placeholder="运抵国"
size="small"
style="cursor: pointer;"
readonly>
<i slot="suffix" class="el-icon-edit" style="cursor: pointer;" @click.stop="openEditDialog(scope.row, 'selectedCnative', '运抵国', '编辑运抵国')"></i>
</el-input>
</template>
</el-table-column>
<el-table-column label="贸易国" min-width="90">
<template slot-scope="scope">
<el-input v-model="scope.row.selectedSalesArea" placeholder="贸易国" size="small"></el-input>
<el-input
v-model="scope.row.selectedSalesArea"
placeholder="贸易国"
size="small"
style="cursor: pointer;"
readonly>
<i slot="suffix" class="el-icon-edit" style="cursor: pointer;" @click.stop="openEditDialog(scope.row, 'selectedSalesArea', '贸易国', '编辑贸易国')"></i>
</el-input>
</template>
</el-table-column>
</el-table>
@ -123,7 +145,7 @@
</el-dialog>
<el-dialog :title="currentRow ? `为发票号 ${currentRow.cmcInvoice} 选择客户模板` : '客户模板'"
@close="templateFlag = false; currentRow = null" :visible.sync="templateFlag" width="850px" v-drag>
@close="templateFlag = false; currentRow = null" :visible.sync="templateFlag" width="1200px" v-drag>
<el-table
:height="400"
:data="customerTemplateList"
@ -143,28 +165,28 @@
prop="ccusname"
header-align="center"
align="left"
width="150"
width="200"
label="客户名称">
</el-table-column>
<el-table-column
prop="localShipAddress"
header-align="center"
align="left"
width="120"
width="300"
label="客户地址">
</el-table-column>
<el-table-column
prop="overseasShipper"
header-align="center"
align="left"
width="120"
width="200"
label="收货单位">
</el-table-column>
<el-table-column
prop="overseasAddress"
header-align="center"
align="left"
width="120"
width="300"
label="收货地址">
</el-table-column>
<el-table-column
@ -292,6 +314,35 @@
<el-button @click="overseasShipperFlag = false; currentRow = null">关闭</el-button>
</el-footer>
</el-dialog>
<!-- 大输入框编辑弹窗 -->
<el-dialog
:title="editDialog.title"
:visible.sync="editDialog.visible"
width="600px"
class="edit-dialog"
@close="closeEditDialog">
<div class="edit-dialog-tip">
<i class="el-icon-info"></i> 提示您可以在此编辑较长的文本内容支持多行输入
</div>
<el-form label-position="top" style="margin-bottom: 120px">
<el-form-item :label="editDialog.label">
<el-input ref="editTextarea"
v-model="editDialog.value"
type="textarea"
:rows="6"
placeholder="请输入内容,支持多行文本..."
maxlength="500"
show-word-limit
class="edit-textarea">
</el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="closeEditDialog">取消</el-button>
<el-button type="primary" @click="confirmEdit">保存</el-button>
</span>
</el-dialog>
</div>
</template>
@ -337,6 +388,17 @@
cacheKey: '', //
cacheTimer: null, //
currentRow: null, //
cachedFileInfo: null, //
cachedFileList: [], //
//
editDialog: {
visible: false,
title: '',
label: '',
value: '',
fieldName: '', //
row: null //
}
}
},
watch: {
@ -349,6 +411,16 @@
}
},
deep: true
},
// previewData
previewData: {
handler: function(newVal, oldVal) {
//
if (this.visible && this.cacheKey && newVal && newVal.length > 0) {
this.saveToCache();
}
},
deep: true
}
},
beforeDestroy() {
@ -383,7 +455,21 @@
overseasAddress: this.pageData.overseasAddress,
cnative: this.pageData.cnative,
salesArea: this.pageData.salesArea,
}
},
//
fileInfo: this.selectedFile ? {
name: this.selectedFile.name,
size: this.selectedFile.size,
lastModified: this.selectedFile.lastModified
} : null,
showPreview: this.showPreview,
previewData: this.previewData,
fileList: this.fileList.map(file => ({
name: file.name,
size: file.size,
lastModified: file.lastModified,
uid: file.uid
}))
};
localStorage.setItem(this.cacheKey, JSON.stringify(cacheData));
} catch (error) {
@ -399,8 +485,22 @@
if (cachedData) {
const parsedData = JSON.parse(cachedData);
if (parsedData.pageData) {
//
//
Object.assign(this.pageData, parsedData.pageData);
//
if (parsedData.previewData && parsedData.previewData.length > 0) {
this.previewData = parsedData.previewData;
this.showPreview = parsedData.showPreview || false;
}
//
if (parsedData.fileList && parsedData.fileList.length > 0) {
//
this.cachedFileInfo = parsedData.fileInfo;
this.cachedFileList = parsedData.fileList;
}
return true;
}
}
@ -419,14 +519,51 @@
}
},
//
checkAndRestoreFileState() {
//
const uploadFiles = this.$refs.uploadFile.uploadFiles;
if (this.cachedFileInfo && this.cachedFileList.length > 0) {
//
if (uploadFiles && uploadFiles.length > 0) {
const currentFile = uploadFiles[0];
const isSameFile = currentFile.name === this.cachedFileInfo.name &&
currentFile.size === this.cachedFileInfo.size &&
currentFile.lastModified === this.cachedFileInfo.lastModified;
if (isSameFile) {
//
this.selectedFile = currentFile;
this.fileList = [currentFile];
console.log('恢复文件状态:', currentFile.name);
} else {
//
this.showPreview = false;
this.previewData = [];
this.selectedFile = null;
this.fileList = [];
console.log('文件不匹配,清除预览状态');
}
} else {
//
this.showPreview = false;
this.previewData = [];
this.selectedFile = null;
this.fileList = [];
console.log('没有找到文件,清除预览状态');
}
}
//
this.saveToCache();
},
//
init () {
this.fileList = []
this.previewData = []
this.showPreview = false
this.selectedFile = null
this.previewLoading = false
//
this.cacheKey = this.generateCacheKey();
this.previewLoading = false
let tempData = {
username: this.$store.state.user.name,
@ -440,6 +577,11 @@
}
// BU
this.loadFromCache();
//
this.$nextTick(() => {
this.checkAndRestoreFileState();
});
})
getCustomerList({}).then(({data}) => {
@ -449,8 +591,13 @@
}
});
//
if (!this.loadFromCache()) {
//
const hasCache = this.loadFromCache();
if (!hasCache) {
this.fileList = []
this.previewData = []
this.showPreview = false
this.selectedFile = null
this.pageData.customerName=''
this.pageData.cnative=''
this.pageData.localShipAddress='',
@ -586,22 +733,32 @@
this.fileList.push(file)
this.selectedFile = file
this.previewFile(file)
//
this.saveToCache()
},
// modal
closeDialog () {
this.deleteFile()
//
this.saveToCache()
//
this.visible = false
//
//
},
deleteFile(){
//
this.fileList = []
this.previewData = []
this.showPreview = false
this.selectedFile = null
this.cachedFileInfo = null
this.cachedFileList = []
//
this.$refs.uploadFile.clearFiles()
//
this.clearCache()
//
this.$emit('refreshTable')
},
//
@ -692,9 +849,9 @@
callback: () => {
if (successList.length > 0){
this.clearCache();
this.clearPreviewData();
this.closeDialog();
}
this.clearPreviewData();
this.closeDialog();
}
});
} else {
@ -741,6 +898,8 @@
this.$set(item, 'selectedCnative', '')
this.$set(item, 'selectedSalesArea','')
})
//
this.saveToCache()
} else {
this.$message.error(data.msg || '文件预览失败')
}
@ -857,7 +1016,12 @@
this.showPreview = false
this.previewData = []
this.fileList = []
this.selectedFile = null
this.cachedFileInfo = null
this.cachedFileList = []
this.$refs.uploadFile.clearFiles()
//
this.saveToCache()
},
//
@ -867,7 +1031,11 @@
this.selectedFile = null
this.fileList = []
this.previewLoading = false
this.cachedFileInfo = null
this.cachedFileList = []
this.$refs.uploadFile.clearFiles()
//
this.saveToCache()
},
//
@ -949,6 +1117,35 @@
});
},
//
openEditDialog(row, fieldName, label, title) {
this.editDialog.visible = true
this.editDialog.title = title
this.editDialog.label = label
this.editDialog.fieldName = fieldName
this.editDialog.row = row
this.editDialog.value = row[fieldName] || ''
this.$nextTick(() => this.$refs.editTextarea.focus());
},
//
closeEditDialog() {
this.editDialog.visible = false
this.editDialog.title = ''
this.editDialog.label = ''
this.editDialog.fieldName = ''
this.editDialog.row = null
this.editDialog.value = ''
},
//
confirmEdit() {
if (this.editDialog.row && this.editDialog.fieldName) {
this.editDialog.row[this.editDialog.fieldName] = this.editDialog.value
}
this.closeEditDialog()
},
//
async downloadFile () {
let file = {
@ -997,4 +1194,127 @@
/deep/ .customer-upload .el-upload .el-upload-dragger {
width: 580px;
}
/* 输入框样式优化 */
.el-input.is-readonly {
cursor: pointer !important;
}
.el-input.is-readonly .el-input__inner {
cursor: pointer !important;
background-color: #f8f9fa;
}
.el-input.is-readonly .el-input__inner:hover {
background-color: #e9ecef;
border-color: #409EFF;
}
/* 编辑图标样式 */
.el-input__suffix .el-icon-edit {
color: #409EFF;
transition: all 0.3s;
font-size: 14px;
padding: 2px;
border-radius: 3px;
}
.el-input__suffix .el-icon-edit:hover {
color: #ffffff;
background-color: #409EFF;
transform: scale(1.1);
}
/* 编辑弹窗整体样式 */
.edit-dialog .el-dialog__body {
padding: 20px 20px 0;
}
.edit-dialog-tip {
margin-bottom: 15px;
color: #909399;
font-size: 12px;
background-color: #f4f4f5;
padding: 8px 12px;
border-radius: 4px;
border-left: 3px solid #409EFF;
}
.edit-dialog-tip .el-icon-info {
margin-right: 5px;
color: #409EFF;
}
/* 大输入框样式 */
.edit-textarea .el-textarea__inner {
resize: vertical !important;
min-height: 120px !important;
border: 1px solid #dcdfe6 !important;
border-radius: 4px !important;
padding: 8px 12px !important;
font-size: 14px !important;
line-height: 1.5 !important;
color: #606266 !important;
background-color: #fff !important;
transition: border-color 0.2s cubic-bezier(.645,.045,.355,1) !important;
box-sizing: border-box !important;
}
.edit-textarea .el-textarea__inner:focus {
outline: none !important;
border-color: #409EFF !important;
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2) !important;
}
.edit-textarea .el-input__count {
color: #909399 !important;
background: #fff !important;
position: absolute !important;
font-size: 12px !important;
bottom: 5px !important;
right: 10px !important;
}
/* 修复弹窗中的表单项样式 */
.edit-dialog .el-form-item {
margin-bottom: 18px !important;
}
.edit-dialog .el-form-item__label {
color: #606266 !important;
font-weight: 500 !important;
line-height: 1.5 !important;
padding: 0 0 8px 0 !important;
box-sizing: border-box !important;
font-size: 14px !important;
}
/* 编辑弹窗按钮样式 */
.edit-dialog .dialog-footer {
text-align: right !important;
padding: 15px 20px 20px !important;
}
.edit-dialog .dialog-footer .el-button {
margin-left: 10px !important;
}
/* 确保弹窗内容不会溢出 */
.edit-dialog .el-dialog__wrapper {
overflow: hidden;
}
.edit-dialog .el-dialog {
margin-top: 5vh !important;
margin-bottom: 50px !important;
}
/* 表格输入框提示文字 */
.el-table .el-input__inner::placeholder {
font-size: 12px;
color: #c0c4cc;
}
</style>
Loading…
Cancel
Save