项目文档历史记录文件名称修改方式修改
continuous-integration/drone/push Build is passing Details

main
wangxiaoshuang 2025-06-11 16:53:22 +08:00
parent 3489d34628
commit 2b89163419
1 changed files with 67 additions and 40 deletions

View File

@ -13,10 +13,22 @@
<el-button size="mini" type="primary" style="float:right" @click.stop="openFile(false)">
{{ $t('trials:trialDocument:historyFileList:button:addFile') }}</el-button>
<el-table :data="list" style="width: 100%" max-height="300px" v-loading="loading"
@sort-change="handleSortByColumn">
@sort-change="handleSortByColumn" @cell-mouse-enter="handleCellMouseEnter">
<el-table-column type="index" width="60" />
<el-table-column prop="FileName" :label="$t('trials:trialDocument:historyFileList:FileName')"
sortable="custom" />
sortable="custom" width="200px">
<template slot-scope="scope">
<div v-if="renameId !== scope.row.Id" class="name_box">
<span class="name" :title="scope.row.FileName">{{ scope.row.FileName }}</span>
<i class="el-icon-edit icon_edit" @click="addRenameId(scope.row)"
:title="$t('trials:trialDocument:historyFileList:icon:rename')" />
</div>
<el-input v-model="scope.row.FileName" :ref="`renameInp_${scope.row.Id}`" :autofocus="true"
class="renameInp" @blur="save(scope.row)" v-else />
</template>
</el-table-column>
<el-table-column prop="FileFormat" :label="$t('trials:trialDocument:historyFileList:FileType')"
sortable="custom" />
<el-table-column prop="FileSize" :label="$t('trials:trialDocument:historyFileList:FileSize')"
@ -36,9 +48,6 @@
<el-button size="mini" type="text" @click.stop="preview(scope.row)">
{{ $t('common:button:preview') }}
</el-button>
<el-button size="mini" type="text" @click.stop="openAudit(scope.row)">
{{ $t('common:button:edit') }}
</el-button>
<el-button size="mini" type="text" @click.stop="del(scope.row)">
{{ $t('common:button:delete') }}
</el-button>
@ -55,25 +64,6 @@
</viewer>
<upload-files :config="upload_config" :faccept="faccept" :uploadPath="uploadPath" v-if="upload_config.visible"
@close="close" @uplaodFile="uplaodFile" />
<!-- 新增/编辑附件 -->
<el-dialog :visible.sync="visible" :close-on-click-modal="false" :append-to-body="true" :title="title"
width="500px" custom-class="base-dialog-wrapper">
<el-form :model="form" :rules="rules" ref="historyFileForm" label-width="100px" class="demo-ruleForm"
v-if="visible">
<el-form-item :label="$t('trials:trialDocument:historyFileList:FileName')" prop="FileName">
<el-input v-model="form.FileName" clearable></el-input>
</el-form-item>
<el-form-item :label="$t('trials:trialDocument:historyFileList:FileName')" prop="FileName"
v-show="false">
<el-input v-model="form.FileName" clearable></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ $t("common:button:cancel") }}</el-button>
<el-button type="primary" @click="save">{{ $t("common:button:save") }}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
@ -157,14 +147,7 @@ export default {
'.xlsx',
".mp4",
".zip"],
visible: false,
title: this.$t('trials:trialDocument:historyFileList:audit'),
form: {},
rules: {
FileName: [
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: ['blur', 'change'], },
]
}
renameId: null
}
},
watch: {
@ -180,12 +163,21 @@ export default {
}
},
methods: {
// hover
handleCellMouseEnter(row) {
this.hoverId = row.Id
},
addRenameId(row) {
this.renameId = row.Id
this.$nextTick(() => {
if (this.$refs[`renameInp_${row.Id}`]) {
this.$refs[`renameInp_${row.Id}`].focus()
}
})
},
close() {
this.upload_config.visible = false
},
closeDialog() {
this.visible = false
},
getAllList() {
this.getList()
this.$emit("getList")
@ -194,14 +186,17 @@ export default {
this.form = Object.assign({}, row)
this.visible = true
},
async save() {
async save(row) {
try {
let validate = await this.$refs.historyFileForm.validate()
if (!validate) return false
let res = await addOrUpdateTrialHistoryRecordFile(this.form)
if (!row.FileName) {
this.$message.warning(this.$t("trials:trialDocument:historyFileList:message:fileNameMust"))
return this.addRenameId(row)
}
this.renameId = null
let res = await addOrUpdateTrialHistoryRecordFile(row)
if (res.IsSuccess) {
this.getList()
this.visible = false
}
} catch (err) {
console.log(err)
@ -321,4 +316,36 @@ export default {
display: block;
width: 90%;
}
.name_box {
display: flex;
align-items: center;
width: calc(100% - 20px);
.name {
max-width: calc(100% - 60px);
white-space: nowrap;
/* 文本不换行 */
overflow: hidden;
/* 超出部分隐藏 */
text-overflow: ellipsis;
}
}
.icon_edit {
cursor: pointer;
color: rgba(0, 0, 0, 0.3);
margin-left: 2px;
&:hover {
color: rgba(0, 0, 0, 0.5);
}
}
.renameInp {
::v-deep .el-input__inner {
line-height: 23px;
height: 23px;
}
}
</style>