file finished todo
This commit is contained in:
parent
d46812483f
commit
b6e3a583ff
@ -137,3 +137,12 @@ export const generateUUID = () => {
|
||||
return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16)
|
||||
})
|
||||
}
|
||||
|
||||
export const fileSizeFormatter = (row) => {
|
||||
const unitArr = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||
const srcSize = parseFloat(row.size)
|
||||
const index = Math.floor(Math.log(srcSize) / Math.log(1024))
|
||||
const size = srcSize / Math.pow(1024, index)
|
||||
const sizeStr = size.toFixed(2) //保留的小数位数
|
||||
return sizeStr + ' ' + unitArr[index]
|
||||
}
|
||||
|
@ -50,7 +50,7 @@
|
||||
align="center"
|
||||
prop="size"
|
||||
width="120"
|
||||
:formatter="sizeFormat"
|
||||
:formatter="fileSizeFormatter"
|
||||
/>
|
||||
<el-table-column label="文件类型" align="center" prop="type" width="180px" />
|
||||
<el-table-column
|
||||
@ -86,6 +86,7 @@
|
||||
<file-upload-form ref="modalRef" @success="getList" />
|
||||
</template>
|
||||
<script setup lang="ts" name="Config">
|
||||
import { fileSizeFormatter } from '@/utils'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as FileApi from '@/api/infra/file'
|
||||
import FileUploadForm from './form.vue'
|
||||
@ -147,16 +148,6 @@ const handleDelete = async (id: number) => {
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// TODO 写到 utils/index.ts 中
|
||||
const sizeFormat = (row) => {
|
||||
const unitArr = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||
const srcSize = parseFloat(row.size)
|
||||
const index = Math.floor(Math.log(srcSize) / Math.log(1024))
|
||||
const size = srcSize / Math.pow(1024, index)
|
||||
const sizeStr = size.toFixed(2) //保留的小数位数
|
||||
return sizeStr + ' ' + unitArr[index]
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
|
@ -175,28 +175,21 @@ const handleDelete = async (id: number) => {
|
||||
}
|
||||
|
||||
/** 主配置按钮操作 */
|
||||
const handleMaster = (id) => {
|
||||
// TODO 改成 await 的形式
|
||||
message
|
||||
.confirm('是否确认修改配置编号为"' + id + '"的数据项为主配置?')
|
||||
.then(function () {
|
||||
return FileConfigApi.updateFileConfigMaster(id)
|
||||
})
|
||||
.then(() => {
|
||||
getList()
|
||||
const handleMaster = async (id) => {
|
||||
try {
|
||||
await message.confirm('是否确认修改配置编号为"' + id + '"的数据项为主配置?')
|
||||
await FileConfigApi.updateFileConfigMaster(id)
|
||||
message.success(t('common.updateSuccess'))
|
||||
})
|
||||
.catch(() => {})
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 测试按钮操作 */
|
||||
const handleTest = (id) => {
|
||||
// TODO 改成 await 的形式
|
||||
FileConfigApi.testFileConfig(id)
|
||||
.then((response) => {
|
||||
const handleTest = async (id) => {
|
||||
try {
|
||||
const response = await FileConfigApi.testFileConfig(id)
|
||||
message.alert('测试通过,上传文件成功!访问地址:' + response)
|
||||
})
|
||||
.catch(() => {})
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
|
Loading…
Reference in New Issue
Block a user