附件工具文件上传文件名称处理
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
33bc40d750
commit
df365e97df
|
@ -27,11 +27,11 @@ async function ossGenerateSTS() {
|
|||
Vue.prototype.OSSclientConfig.timeout = 10 * 60 * 1000
|
||||
let OSSclient = new OSS(Vue.prototype.OSSclientConfig)
|
||||
Vue.prototype.OSSclient = {
|
||||
put: function (objectName, object) {
|
||||
put: function (objectName, object, timestamp = true) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
let _vm = router.default.app
|
||||
if (_vm._route.path !== '/trials/trials-panel/visit/crc-upload') {
|
||||
if (_vm._route.path !== '/trials/trials-panel/visit/crc-upload' && timestamp) {
|
||||
var objectItem = objectName.split('/')
|
||||
objectItem[objectItem.length - 1] = new Date().getTime() + '_' + objectItem[objectItem.length - 1]
|
||||
objectName = objectItem.join('/')
|
||||
|
@ -40,7 +40,7 @@ async function ossGenerateSTS() {
|
|||
if (res && res.url) {
|
||||
resolve({
|
||||
name: objectName,
|
||||
url: res.url
|
||||
url: res.url
|
||||
})
|
||||
} else {
|
||||
reject()
|
||||
|
@ -56,12 +56,12 @@ async function ossGenerateSTS() {
|
|||
case 'MinIO':
|
||||
let minioClient = new Minio.Client(Vue.prototype.OSSclientConfig);
|
||||
Vue.prototype.OSSclient = {
|
||||
put: function (objectName, object) {
|
||||
put: function (objectName, object, timestamp = true) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
var name = objectName.split('/')[objectName.split('/').length - 1]
|
||||
let _vm = router.default.app
|
||||
if (_vm._route.path !== '/trials/trials-panel/visit/crc-upload') {
|
||||
if (_vm._route.path !== '/trials/trials-panel/visit/crc-upload' && timestamp) {
|
||||
var objectItem = objectName.split('/')
|
||||
objectItem[objectItem.length - 1] = new Date().getTime() + '_' + objectItem[objectItem.length - 1]
|
||||
objectName = objectItem.join('/')
|
||||
|
@ -71,7 +71,7 @@ async function ossGenerateSTS() {
|
|||
const bufferStream = new stream.PassThrough()
|
||||
bufferStream.end(Buffer.from(ex.target.result))
|
||||
// minioClient.bucketExists('ecgdata'
|
||||
minioClient.putObject(Vue.prototype.OSSclientConfig.bucketName, objectName, bufferStream, function(err,etag) {
|
||||
minioClient.putObject(Vue.prototype.OSSclientConfig.bucketName, objectName, bufferStream, function (err, etag) {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
reject()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class="upload-temporary-file">
|
||||
<div class="base-dialog-body">
|
||||
<el-form-item :label="$t('dictionary:attachment:label:code')" prop="Code">
|
||||
<el-input v-model="form.Code" />
|
||||
<el-input v-model="form.Code" :disabled="fileList.length > 0" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('dictionary:attachment:label:businessScenario')" prop="BusinessScenarioEnum">
|
||||
<el-select v-model="form.BusinessScenarioEnum" style="width: 100%" size="small" filterable>
|
||||
|
@ -16,8 +16,10 @@
|
|||
<div class="upload-container">
|
||||
<el-upload class="upload-demo" action accept="" :before-upload="beforeUpload" :http-request="handleUploadFile"
|
||||
:on-preview="handlePreview" :on-remove="handleRemoveFile" :show-file-list="true" :file-list="fileList"
|
||||
:limit="1" :on-exceed="handleExceed" :disabled="(!form.FileTypeEnum && form.FileTypeEnum !== 0)">
|
||||
<el-button size="small" type="primary" :disabled="(!form.FileTypeEnum && form.FileTypeEnum !== 0)"
|
||||
:limit="1" :on-exceed="handleExceed"
|
||||
:disabled="((!form.FileTypeEnum && form.FileTypeEnum !== 0) || (!form.Code || (form.Code && !codeReg.test(form.Code))))">
|
||||
<el-button size="small" type="primary"
|
||||
:disabled="((!form.FileTypeEnum && form.FileTypeEnum !== 0) || (!form.Code || (form.Code && !codeReg.test(form.Code))))"
|
||||
:loading="btnLoading">Select</el-button>
|
||||
<!-- <span slot="tip" style="margin-left: 10px" class="el-upload__tip">
|
||||
(must be in xlsx/xls/doc/docx format)
|
||||
|
@ -79,9 +81,20 @@ export default {
|
|||
Description: '',
|
||||
IsDeleted: false,
|
||||
},
|
||||
codeReg: /^[a-zA-Z_]+$/,
|
||||
rules: {
|
||||
Code: [
|
||||
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: ['blur'] },
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
if (value && !this.codeReg.test(value)) {
|
||||
callback(new Error(this.$t('common:ruleMessage:codeRule')));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
Name: [
|
||||
{ required: true, message: this.$t('common:ruleMessage:specify'), trigger: ['blur'] },
|
||||
|
@ -154,7 +167,7 @@ export default {
|
|||
.substring(param.file.name.lastIndexOf('.'))
|
||||
.toLocaleLowerCase()
|
||||
let file = await this.fileToBlob(param.file)
|
||||
let res = await this.OSSclient.put(`/System/Tools/${this.$guid()}${extendName}`, file)
|
||||
let res = await this.OSSclient.put(`/System/Tools/${this.form.Code}${extendName}`, file, false)
|
||||
this.form.Path = this.$getObjectName(res.url)
|
||||
this.form.NameCN = param.file.name
|
||||
this.fileList.push({
|
||||
|
@ -165,15 +178,6 @@ export default {
|
|||
})
|
||||
this.loading = false
|
||||
this.btnLoading = false
|
||||
// Upload(formData, 1).then((res) => {
|
||||
// this.fileList.push({
|
||||
// name: param.file.name,
|
||||
// path: res.Result.FilePath,
|
||||
// fullPath: res.Result.FullFilePath,
|
||||
// url: res.Result.FilePath,
|
||||
// })
|
||||
|
||||
// })
|
||||
},
|
||||
fileToBlob(file) {
|
||||
// 创建 FileReader 对象
|
||||
|
|
Loading…
Reference in New Issue