Browse Source

优化合同管理功能(存档,附件放入操作栏中)

master
panxinyu-YUYwp 2 months ago
parent
commit
5f20ec6b4d
  1. 252
      src/views/modules/contract/info.vue

252
src/views/modules/contract/info.vue

@ -63,33 +63,47 @@
<el-table-column prop="contractAmount" header-align="center" align="right" min-width="80" label="合同金额"></el-table-column>
<el-table-column prop="currency" header-align="center" align="center" min-width="70" label="货币"></el-table-column>
<el-table-column prop="versionNo" header-align="center" align="center" min-width="100" label="版本号" show-overflow-tooltip></el-table-column>
<el-table-column prop="partnerType" header-align="center" align="center" min-width="100" label="往来单位类型"></el-table-column>
<el-table-column prop="partnerType" header-align="center" align="center" min-width="85" label="往来单位类型"></el-table-column>
<el-table-column prop="validStartDate" header-align="center" align="center" min-width="100" label="有效期起始"></el-table-column>
<el-table-column prop="validEndDate" header-align="center" align="center" min-width="100" label="有效期终止"></el-table-column>
<el-table-column prop="remark" header-align="center" align="left" min-width="120" label="备注" show-overflow-tooltip></el-table-column>
<el-table-column header-align="center" align="center" width="70" label="附件">
<template slot-scope="scope">
<a v-if="scope.row.attachmentCount > 0" type="text" size="small"
style="cursor:pointer; color:#409EFF;"
@click="openAttachmentDetail(scope.row)">详情</a>
<span v-else style="color:#909399;">无</span>
</template>
</el-table-column>
<el-table-column fixed="right" header-align="center" align="center" width="100" label="是否存档">
<template slot-scope="scope">
<el-checkbox
:value="scope.row.whetherArchive === 'Y'"
@change="val => handleArchiveChange(val, scope.row)">
</el-checkbox>
<a v-if="scope.row.whetherArchive === 'Y'"
style="margin-left: 6px; cursor: pointer; color: #409EFF;"
@click="viewArchiveDetail(scope.row)">详情</a>
</template>
</el-table-column>
<el-table-column fixed="right" header-align="center" align="center" width="100" label="操作">
<el-table-column fixed="right" header-align="center" align="right" class-name="op-col" width="200" label="操作">
<template slot-scope="scope">
<a type="text" size="small" @click="editContract(scope.row)">编辑</a>
<a type="text" size="small" @click="deleteContract(scope.row)">删除</a>
<a type="text" size="small" style="margin-left: 8px;" @click="deleteContract(scope.row)">删除</a>
<!-- 存档:已存档→存档详情 / 取消存档(都走原有逻辑);未存档→存档(默认登录人+今天,可改) -->
<template v-if="scope.row.whetherArchive === 'Y'">
<a type="text" size="small" style="margin-left: 8px;"
@click="viewArchiveDetail(scope.row)">存档详情</a>
</template>
<a v-else type="text" size="small" style="margin-left: 8px;"
@click="openArchiveModal(scope.row)">存档</a>
<!-- 附件:无附件→文字;有附件→鼠标悬浮下拉,每个附件都能预览/下载 -->
<span v-if="!(scope.row.attachmentCount > 0)"
style="margin-left: 8px; color:#909399; font-size:12px;">无附件</span>
<el-dropdown v-else trigger="hover" style="margin-left: 8px;"
@mouseenter.native="loadRowAttachments(scope.row)">
<span class="el-dropdown-link" style="cursor:pointer; color:#409EFF; font-size:12px;">
附件<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-if="isRowAttachmentLoading(scope.row)">
<span style="color:#909399; font-size:12px;">加载中...</span>
</el-dropdown-item>
<el-dropdown-item v-if="!isRowAttachmentLoading(scope.row) && !getRowAttachments(scope.row).length">
<span style="color:#909399; font-size:12px;">暂无附件</span>
</el-dropdown-item>
<el-dropdown-item v-for="file in getRowAttachments(scope.row)" :key="file.id">
<span :title="file.fileName" style="display:inline-block; max-width:220px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; vertical-align:middle;">{{ file.fileName }}</span>
<a style="margin-left:10px; color:#409EFF; cursor:pointer; font-size:12px;"
@click.stop="previewAttachment(file)">预览</a>
<a style="margin-left:8px; color:#409EFF; cursor:pointer; font-size:12px;"
@click.stop="downloadAttachment(file)">下载</a>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
@ -124,6 +138,14 @@
:before-close="beforeCloseContractModal"
:close-on-click-modal="false">
<template slot="title">
<span class="el-dialog__title">{{ contractModalTitle }}</span>
<span v-if="isEditContract" style="font-size: 12px; margin-left: 6px;"
:style="{ color: contractForm.whetherArchive === 'Y' ? '#E6A23C' : '#909399' }">
{{ contractForm.whetherArchive === 'Y' ? '已存档' : '未存档' }}
</span>
</template>
<el-form :inline="true" label-position="top" :model="contractForm" style="margin-left:7px; margin-top:-5px; font-size: 0;">
<!-- 表单字段:统一宽度自动换行(4列),控件宽度由底部样式统一控制 -->
<el-form-item label="客户名称" required class="wide-item">
@ -309,57 +331,28 @@
该文件类型不支持预览,请下载后查看
</div>
</el-dialog>
<!-- 附件详情弹窗(列表"详情"入口) -->
<el-dialog title="附件详情" :visible.sync="showAttachmentModal" width="620px"
top="5vh" :close-on-click-modal="false">
<el-table :data="attachmentDetailList" border size="mini"
:header-cell-style="{background:'#d4e8e8', color:'#333'}">
<el-table-column prop="fileName" header-align="center" align="left" label="文件名称" show-overflow-tooltip></el-table-column>
<el-table-column header-align="center" align="center" width="110" label="操作">
<template slot-scope="scope">
<a type="text" size="small" @click="previewAttachment(scope.row)">预览</a>
<a type="text" size="small" style="margin-left: 8px;" @click="downloadAttachment(scope.row)">下载</a>
</template>
</el-table-column>
<template slot="empty">
<span style="color:#909399; font-size:12px;">暂无附件</span>
</template>
</el-table>
</el-dialog>
<!-- 存档弹窗 -->
<el-dialog title="存档" :visible.sync="showArchiveModal" width="400px" top="15vh">
<el-form :model="archiveForm" label-width="80px">
<el-form-item label="存档人" required>
<el-input v-model="archiveForm.archivePerson" size="small"></el-input>
<!-- 存档弹窗(新增 / 查看共用) -->
<el-dialog :title="archiveModalTitle" :visible.sync="showArchiveModal" width="270px" top="15vh">
<el-form class="archive-form" :model="archiveForm" label-position="left" label-width="72px">
<el-form-item label="存档人">
<el-input v-if="archiveMode === 'edit'" v-model="archiveForm.archivePerson" size="small" style="width: 130px;margin-top: 3px"></el-input>
<span v-else style="line-height: 38px;">{{ archiveForm.archivePerson || '-' }}</span>
</el-form-item>
<el-form-item label="存档日期" required>
<el-date-picker v-model="archiveForm.archiveDate" type="date"
<el-form-item label="存档日期">
<el-date-picker v-if="archiveMode === 'edit'" v-model="archiveForm.archiveDate" type="date"
format="yyyy-MM-dd" value-format="yyyy-MM-dd"
size="small" style="width: 100%;"></el-date-picker>
size="small" style="width: 130px;margin-top: 3px"></el-date-picker>
<span v-else style="line-height: 38px;">{{ (archiveForm.archiveDate || '').substring(0, 10) || '-' }}</span>
</el-form-item>
</el-form>
<span slot="footer">
<el-button size="small" @click="showArchiveModal = false">取消</el-button>
<el-button size="small" type="primary" @click="confirmArchive">确定</el-button>
</span>
</el-dialog>
<!-- 存档详情弹窗 -->
<el-dialog title="存档详情" :visible.sync="showArchiveDetail" width="400px" top="15vh">
<div style="padding: 0 20px;">
<div style="display: flex; line-height: 40px; border-bottom: 1px solid #eee;">
<span style="width: 80px; color: #606266; text-align: right; padding-right: 12px;">存档人</span>
<span style="flex: 1; color: #303133;">{{ archiveForm.archivePerson || '-' }}</span>
</div>
<div style="display: flex; line-height: 40px;">
<span style="width: 80px; color: #606266; text-align: right; padding-right: 12px;">存档日期</span>
<span style="flex: 1; color: #303133;">{{ (archiveForm.archiveDate || '').substring(0, 10) || '-' }}</span>
</div>
</div>
<span slot="footer">
<el-button size="small" @click="showArchiveDetail = false">关闭</el-button>
</span>
<el-button v-if="archiveMode === 'edit'" size="small" @click="showArchiveModal = false">取消</el-button>
<el-button v-if="archiveMode === 'edit'" size="small" type="primary" @click="confirmArchive">确定</el-button>
<template v-else>
<el-button size="small" type="danger" plain @click="cancelArchive(currentArchiveRow)">取消存档</el-button>
<el-button size="small" @click="showArchiveModal = false">关闭</el-button>
</template>
</span>
</el-dialog>
</div>
</template>
@ -412,8 +405,6 @@ export default {
customerListOptions: [],
projectListOptions: [],
attachmentList: [],
showAttachmentModal: false,
attachmentDetailList: [],
uploadUrl: '',
pendingFiles: [],
selectedFileNames: '',
@ -426,8 +417,11 @@ export default {
previewType: '',
previewName: '',
showArchiveModal: false,
showArchiveDetail: false,
archiveMode: 'edit',
archiveModalTitle: '',
currentArchiveRow: null,
rowAttachmentMap: {},
rowAttachmentLoading: {},
archiveForm: {
archivePerson: '',
archiveDate: ''
@ -504,6 +498,7 @@ export default {
},
// 查询合同列表
fetchContracts() {
this.rowAttachmentMap = {}
this.searchData.page = this.pageIndex
this.searchData.limit = this.pageSize
contractData(this.searchData).then(({data}) => {
@ -753,6 +748,7 @@ export default {
},
closeContractModal() {
this.showContractModal = false
this.fetchContracts()
this.isEditContract = false
this.projectListOptions = []
this.attachmentList = []
@ -832,25 +828,6 @@ export default {
}
}
},
// 列表"详情":打开附件详情弹窗并加载该合同附件
openAttachmentDetail(row) {
this.attachmentDetailList = []
this.showAttachmentModal = true
this.$http({
url: this.$http.adornUrl('/sys/oss/list'),
method: 'get',
params: this.$http.adornParams({
page: 1,
limit: 999,
orderRef1: row.id,
fileType: 'contract'
})
}).then(({data}) => {
if (data && data.code === 0) {
this.attachmentDetailList = data.page.list
}
})
},
// 查询该合同的附件列表(每次重新拼 URL,确保带最新的合同ID)
fetchAttachments(contractId) {
if (!contractId) {
@ -1095,21 +1072,12 @@ export default {
} else {
this.$message.error((data && data.msg) || '删除失败')
}
}).catch(err => {
console.error(err)
this.$message.error('删除失败')
})
}).catch(err => {
console.error(err)
this.$message.error('删除失败')
})
},
// 时间格式化显示
formatDateTime(val) {
if (!val) return ''
let d = new Date(val)
let pad = n => n < 10 ? '0' + n : n
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) +
' ' + pad(d.getHours()) + ':' + pad(d.getMinutes())
}).catch(() => {})
},
// 勾选/取消 存档
handleArchiveChange(checked, row) {
if (checked) {
this.currentArchiveRow = row
@ -1119,6 +1087,8 @@ export default {
archivePerson: this.$store.state.user.userDisplay,
archiveDate: d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate())
}
this.archiveMode = 'edit'
this.archiveModalTitle = '存档'
this.showArchiveModal = true
} else {
this.$confirm('确定取消存档吗?', '提示', { type: 'warning' }).then(() => {
@ -1130,6 +1100,7 @@ export default {
}).then(({data}) => {
if (data && data.code === 0) {
this.$message.success('取消存档成功')
this.showArchiveModal = false
this.fetchContracts()
} else {
this.$message.error((data && data.msg) || '操作失败')
@ -1169,11 +1140,53 @@ export default {
// 查看存档详情
viewArchiveDetail(row) {
this.archiveMode = 'view'
this.currentArchiveRow = row
this.archiveModalTitle = '存档详情'
this.archiveForm = {
archivePerson: row.archivePerson || '',
archiveDate: row.archiveDate || ''
}
this.showArchiveDetail = true
this.showArchiveModal = true
},
// 操作列"取消存档"入口:复用原有取消逻辑(带二次确认)
cancelArchive(row) {
this.handleArchiveChange(false, row)
},
// 操作列"存档"入口:复用原有存档逻辑(默认带出登录人+今天,且两项都可改)
openArchiveModal(row) {
this.handleArchiveChange(true, row)
},
// 操作列附件下拉:首次悬浮时按合同ID加载附件列表,结果缓存
loadRowAttachments(row) {
if (!row || !row.id) return
if (this.rowAttachmentMap[row.id] || this.rowAttachmentLoading[row.id]) return
this.$set(this.rowAttachmentLoading, row.id, true)
this.$http({
url: this.$http.adornUrl('/sys/oss/list'),
method: 'get',
params: this.$http.adornParams({
page: 1,
limit: 999,
orderRef1: row.id,
fileType: 'contract'
})
}).then(({data}) => {
this.$set(this.rowAttachmentMap, row.id,
(data && data.code === 0 && data.page.list) ? data.page.list : [])
this.$set(this.rowAttachmentLoading, row.id, false)
}).catch(err => {
console.error(err)
this.$set(this.rowAttachmentMap, row.id, [])
this.$set(this.rowAttachmentLoading, row.id, false)
})
},
getRowAttachments(row) {
return (row && this.rowAttachmentMap[row.id]) || []
},
isRowAttachmentLoading(row) {
return !!(row && this.rowAttachmentLoading[row.id])
}
}
}
@ -1220,4 +1233,35 @@ export default {
margin-bottom: 10px;
vertical-align: middle;
}
/* ===== 存档弹窗(存档 / 存档详情共用)===== */
/* 1) 输入框/日期框缩小到 150px:否则被上面的 170px!important 撑出 250px 的弹窗 */
.contract-maintenance .el-dialog .el-form.archive-form .el-form-item .el-input,
.contract-maintenance .el-dialog .el-form.archive-form .el-form-item .el-select {
width: 130px !important;
}
/* 2) 解除 180px 的弹窗等宽规则,字段宽度交回弹窗(否则内容区只有 108px,装不下输入框) */
.contract-maintenance .el-dialog .el-form.archive-form .el-form-item {
width: auto;
margin-right: 0;
}
/* 3) 标签与取值统一字号+行高(都 14px / 32px,与 32px 的小号输入框等高),基线才能完全重合 */
.contract-maintenance .el-dialog .el-form.archive-form .el-form-item__label,
.contract-maintenance .el-dialog .el-form.archive-form .el-form-item__content {
font-size: 14px;
line-height: 32px;
height: auto;
}
/* 操作列:固定第3、4槽宽度,让整组总宽恒定,各行"编辑"起点才一致 */
.contract-maintenance td.op-col .cell > a:nth-child(3),
.contract-maintenance td.op-col .cell > span:nth-child(4),
.contract-maintenance td.op-col .cell > .el-dropdown:nth-child(4) {
display: inline-block;
width: 50px;
text-align: center;
}
/* 第4槽改左对齐:无附件/附件 左边缘才重合(居中会把宽度差摊到左边) */
.contract-maintenance td.op-col .cell > span:nth-child(4),
.contract-maintenance td.op-col .cell > .el-dropdown:nth-child(4) {
text-align: left;
}
</style>
Loading…
Cancel
Save