1.上传文件 代码
<div class="common-table-layout divInstant">
<div class="left must">
证书名称:
</div>
<div class="right">
<el-input class="input-style-300px" v-model="fileName" disabled clearable placeholder="请点击上传证书按钮"></el-input>
<form @click="importFile" id="upload-form" enctype="multipart/form-data" style="position:relative; display:inline;">
<button class="button button-primary button-rounded button-small" style="cursor: pointer;" :disabled="!importStatus">
<i class="fa fa-upload"></i>
上传证书
</button>
<input
@change="importFileChange"
:disabled="!importStatus"
ref="importFile"
type="file"
name="file"
accept=".pem, .key"
class="position-center inline-block el-input-file"
style="width: 100%;display: none;"
>
</form>
<span class="config-tips">
<i class="fa fa-info-circle"></i>
证书文件的格式仅支持 .pem 与 .key
</span>
</div>
</div>
-----------------------------------------------------------------------------------------------
importFile() {
this.$refs.importFile.click();
},
importFileChange(val) {
this.importStatus = false;
const file = new FormData();
file.append('file', val.target.files[0]);
const userToken = this.$store.getters.userInfo === '' ? '' : this.$store.getters.userInfo.token;
$.ajax({
url: process.env.BASE_API + '/fast/https/uploadCert' + '?user_token=' + userToken,
type: 'POST',
cache: false,
processData: false,
contentType: false,
data: file,
success: (response) => {
this.importStatus = true;
if (response.status) {
this.fileName = val.target.files[0].name;
this.filePath = response.data.filePath;
this.$refs.importFile.value = '';
} else {
layerMsg.msg(response.message, 0, '');
this.importStatus = true;
this.$refs.importFile.value = '';
}
},
error: (err) => {
layerMsg.msg(err.message, 0, '');
this.importStatus = true;
this.$refs.importFile.value = '';
}
});
},
2.table序号(1,2,3,4,5)
<el-table-column label="序号" type="index" :index="getTableOrder" width="80" ></el-table-column>
----------------------------------------------------------------------------------------------------------------------------
getTableOrder(index) {
return index + (this.pageNum - 1) * this.pageSize + 1;
},