|
|
|
@ -25,6 +25,9 @@ |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
<div> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
round |
|
|
|
|
@click="batchImport">导入</el-button> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
round |
|
|
|
|
@click="add" |
|
|
|
@ -209,6 +212,48 @@ |
|
|
|
|
@click="teamVisible = false">取消</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
|
<el-dialog title="批量导入" |
|
|
|
|
:visible.sync="importVisible" |
|
|
|
|
width="24%" |
|
|
|
|
:close-on-click-modal="false"> |
|
|
|
|
<div style="text-align: center"> |
|
|
|
|
<div style="margin-bottom: 10px;"> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
@click="download">模板下载<i class="el-icon-download el-icon--right"></i></el-button> |
|
|
|
|
</div> |
|
|
|
|
<el-upload ref="importStaff" |
|
|
|
|
name="file" |
|
|
|
|
accept=".xls,.xlsx" |
|
|
|
|
:on-remove="handleRemove" |
|
|
|
|
:on-error="uploadError" |
|
|
|
|
:on-success="uploadSuccess" |
|
|
|
|
:before-remove="beforeRemove" |
|
|
|
|
:limit="1" |
|
|
|
|
:data="{ |
|
|
|
|
competitionId: id, |
|
|
|
|
platformId: 1 |
|
|
|
|
}" |
|
|
|
|
:on-exceed="handleExceed" |
|
|
|
|
:action="info.completeCompetitionSetup.competitionType ? this.api.batchImportTeamData : this.api.batchImportPersonalData" |
|
|
|
|
:file-list="uploadList" |
|
|
|
|
:headers="headers"> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
class="ml20">上传文件<i class="el-icon-upload2 el-icon--right"></i></el-button> |
|
|
|
|
</el-upload> |
|
|
|
|
<el-link v-if="uploadFaild" |
|
|
|
|
type="primary" |
|
|
|
|
@click="showFaild">部分数据导入失败,查看失败原因</el-link> |
|
|
|
|
</div> |
|
|
|
|
<span slot="footer" |
|
|
|
|
class="dialog-footer"> |
|
|
|
|
<el-button size="small" |
|
|
|
|
@click="importVisible = false">取 消</el-button> |
|
|
|
|
<el-button size="small" |
|
|
|
|
type="primary" |
|
|
|
|
@click="uploadSure">确 定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
@ -294,7 +339,15 @@ export default { |
|
|
|
|
originForm: {}, |
|
|
|
|
exitMember: 0, |
|
|
|
|
notExit: 0, |
|
|
|
|
schoolDisable: false |
|
|
|
|
schoolDisable: false, |
|
|
|
|
|
|
|
|
|
importVisible: false, |
|
|
|
|
uploadList: [], |
|
|
|
|
uploadFaild: false, |
|
|
|
|
exportCode: '', |
|
|
|
|
headers: { |
|
|
|
|
token: util.local.get(Setting.tokenKey) |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
@ -362,6 +415,64 @@ export default { |
|
|
|
|
if (column.prop === 'teamName') this.teamOrder = column.order ? column.order === 'ascending' ? 2 : 1 : '' |
|
|
|
|
this.getData() |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 批量导入 |
|
|
|
|
batchImport () { |
|
|
|
|
this.importVisible = true |
|
|
|
|
this.uploadList = [] |
|
|
|
|
this.uploadFaild = false |
|
|
|
|
}, |
|
|
|
|
// 模板下载 |
|
|
|
|
download () { |
|
|
|
|
location.href = this.api[this.info.completeCompetitionSetup.competitionType ? 'competionTeamTemplate' : 'competionPersonTemplate'] |
|
|
|
|
}, |
|
|
|
|
// 上传文件 |
|
|
|
|
handleExceed (files, fileList) { |
|
|
|
|
util.warningMsg( |
|
|
|
|
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` |
|
|
|
|
) |
|
|
|
|
}, |
|
|
|
|
// 下载失败文件 |
|
|
|
|
showFaild () { |
|
|
|
|
axios.get(`${this.api.TeamDataExportFailure}?exportCode=${this.exportCode}&platformId=1&type=${this.info.completeCompetitionSetup.competitionType ? 1 : 2}`, { |
|
|
|
|
headers: this.headers, |
|
|
|
|
responseType: 'blob' |
|
|
|
|
}).then((res) => { |
|
|
|
|
console.log("🚀 ~ showFaild ~ res:", res) |
|
|
|
|
util.downloadFileDirect(decodeURI(res.headers['content-disposition']), new Blob([res.data])) |
|
|
|
|
}).catch(res => { }) |
|
|
|
|
}, |
|
|
|
|
uploadSuccess ({ data, status }) { |
|
|
|
|
this.uploadFaild = false |
|
|
|
|
if (status === 200) { |
|
|
|
|
if (data.exportCode) { |
|
|
|
|
this.exportCode = data.exportCode |
|
|
|
|
this.uploadFaild = true |
|
|
|
|
util.errorMsg(data.tip) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
res.message ? util.errorMsg(res.message) : util.errorMsg("上传失败,请检查数据") |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
uploadError (err, file, fileList) { |
|
|
|
|
this.$message({ |
|
|
|
|
message: "上传出错,请重试!", |
|
|
|
|
type: "error", |
|
|
|
|
center: true |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
beforeRemove (file, fileList) { |
|
|
|
|
return this.$confirm(`确定移除 ${file.name}?`) |
|
|
|
|
}, |
|
|
|
|
handleRemove (file, fileList) { |
|
|
|
|
this.uploadList = fileList |
|
|
|
|
this.uploadFaild = false |
|
|
|
|
}, |
|
|
|
|
uploadSure () { |
|
|
|
|
this.importVisible = false |
|
|
|
|
this.keyWord = '' |
|
|
|
|
}, |
|
|
|
|
// 新增 |
|
|
|
|
add () { |
|
|
|
|
this.notExit = 0 |
|
|
|
|