调整文件列表表格的样式及列表分页参数

上传文件的逻辑调整及接口联调
This commit is contained in:
renpy 2023-08-28 15:11:50 +08:00
parent ff60577144
commit 5c6dff9888

View File

@ -30,7 +30,11 @@
<!-- 底部按钮 --> <!-- 底部按钮 -->
<template slot="custom-footer"> <template slot="custom-footer">
<a-space> <a-space>
<a-button type="primary" @click="handleUpload">Upload</a-button> <a-upload :custom-request="handleUpload" :multiple="true" :show-upload-list="false" :before-upload="beforeUpload" >
<a-button type="primary" :loading="uploading">
Upload
</a-button>
</a-upload>
<a-button type="primary" @click="handleReset">Reset</a-button> <a-button type="primary" @click="handleReset">Reset</a-button>
<a-button type="primary" @click="handleLoad">Load</a-button> <a-button type="primary" @click="handleLoad">Load</a-button>
<a-button type="primary" @click="handleCancel">Cancel</a-button> <a-button type="primary" @click="handleCancel">Cancel</a-button>
@ -39,7 +43,7 @@
<!-- 底部按钮结束 --> <!-- 底部按钮结束 -->
</custom-modal> </custom-modal>
<custom-modal v-model="visible_file" :width="1200" title="File List"> <custom-modal v-model="visible_file" :width="1200" title="File List">
<div style="position: relative;padding-bottom: 40px;height: 460px;"> <div style="position: relative;padding-bottom: 40px;height: 460px;overflow: hidden;">
<a-table <a-table
:data-source="list_file" :data-source="list_file"
:columns="columns_file" :columns="columns_file"
@ -63,31 +67,6 @@
/> />
</div> </div>
</custom-modal> </custom-modal>
<a-modal v-model="visible_upload" :width="300" title="Upload File" @ok="handleUploadFile">
<div>
<span class="item-label">Type</span>
<a-select style="width:180px"
v-model="type"
placeholder="select..."
show-arrow
allowClear
:options="typeOptions"
@change="onTypeChange"
>
<img slot="suffixIcon" src="@/assets/images/global/select-down.png" alt="" />
</a-select>
</div>
<div>
<a-upload
name="file"
:multiple="true"
:before-upload="beforeUpload"
:file-list="fileList"
>
<a-button> <a-icon type="upload" /> Select File </a-button>
</a-upload>
</div>
</a-modal>
</div> </div>
</template> </template>
@ -144,6 +123,7 @@ const columns_file = [
{ {
title: 'Name', title: 'Name',
dataIndex: 'name', dataIndex: 'name',
width: '45%',
align: 'left', align: 'left',
ellipsis: true ellipsis: true
},{ },{
@ -184,21 +164,9 @@ export default {
total: 0 total: 0
}, },
selectedRowKeys: [], selectedRowKeys: [],
visible_upload: false,
type: undefined,
typeOptions: [
{
label: "stop",
value: "stop"
},{
label: "over",
value: "over"
},{
label: "skip",
value: "skip"
},
],
fileList: [], fileList: [],
fileNum: 0,
uploading: false
} }
}, },
methods: { methods: {
@ -224,6 +192,7 @@ export default {
getAction("/spectrumFile/get", params).then(res => { getAction("/spectrumFile/get", params).then(res => {
this.loading_file = false this.loading_file = false
if (res.success) { if (res.success) {
this.ipagination.total = res.result.total
this.list_file = res.result.records this.list_file = res.result.records
} else { } else {
this.$message.warning("This operation fails. Contact your system administrator") this.$message.warning("This operation fails. Contact your system administrator")
@ -250,25 +219,30 @@ export default {
console.log('selectedRowKeys changed: ', selectedRowKeys); console.log('selectedRowKeys changed: ', selectedRowKeys);
this.selectedRowKeys = selectedRowKeys; this.selectedRowKeys = selectedRowKeys;
}, },
handleUpload() {
this.visible_upload = true
},
onTypeChange(val) {
console.log(val);
this.type = val
},
beforeUpload(file,fileList) { beforeUpload(file,fileList) {
console.log(file, fileList);
this.fileList = fileList this.fileList = fileList
// this.fileList = [...this.fileList, file]
}, },
// async transformFile() { async handleUpload({ file }) {
// // jszip this.uploading = true
// let zipData = await this.zipFile(this.fileList, (added) => {}) this.fileNum += 1
// console.log(zipData); if (this.fileNum == this.fileList.length) {
// }, await this.zipFile(this.fileList, (added) => { }).then(content => {
let file = new File([content], 'test.zip', { type: content.type })
const formData = new FormData()
formData.append("file",file)
postAction("/spectrumFile/upload", formData).then(res => {
this.uploading = false
this.fileNum = 0
if (res.success) {
console.log(res);
this.$message.success(res.message)
} else {
this.$message.warning(res.message)
}
})
})
}
},
async zipFile(fileList, onProgress) { async zipFile(fileList, onProgress) {
const zip = new JSZip() const zip = new JSZip()
let i = 0 let i = 0
@ -294,22 +268,6 @@ export default {
} }
}) })
}, },
async handleUploadFile() {
await this.zipFile(this.fileList, (added) => { }).then(content => {
console.log(content);
const formData = new FormData()
formData.append("file",content)
formData.append("choice",this.type)
postAction("/spectrumFile/upload", formData).then(res => {
if (res.success) {
console.log(res);
} else {
this.$message.warning("This operation fails. Contact your system administrator")
}
})
})
},
handleReset() { handleReset() {
this.list = this.getInitialList() this.list = this.getInitialList()