【修改】生成笔试试卷按钮 加载状态
This commit is contained in:
@@ -104,7 +104,9 @@ export async function openDown(ids) {
|
|||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.setAttribute('download', '试卷.docx');
|
// 使用示例
|
||||||
|
const filename = `${getNowTimeString()}.zip`;
|
||||||
|
link.setAttribute('download', filename);
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
@@ -115,4 +117,13 @@ export async function openDown(ids) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNowTimeString() {
|
||||||
|
const now = new Date();
|
||||||
|
const Y = now.getFullYear();
|
||||||
|
const M = String(now.getMonth() + 1).padStart(2, '0');
|
||||||
|
const D = String(now.getDate()).padStart(2, '0');
|
||||||
|
const h = String(now.getHours()).padStart(2, '0');
|
||||||
|
const m = String(now.getMinutes()).padStart(2, '0');
|
||||||
|
const s = String(now.getSeconds()).padStart(2, '0');
|
||||||
|
return `${Y}${M}${D}${h}${m}${s}`;
|
||||||
|
}
|
||||||
|
@@ -56,13 +56,16 @@
|
|||||||
>
|
>
|
||||||
<Icon icon="ep:set-up" class="mr-5px" /> 抽卷调整
|
<Icon icon="ep:set-up" class="mr-5px" /> 抽卷调整
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
@click="openDown"
|
@click="openDown"
|
||||||
>
|
:loading="downloadLoading"
|
||||||
<Icon icon="ep:files" class="mr-5px" /> 生成笔试试卷
|
:disabled="downloadLoading"
|
||||||
</el-button>
|
>
|
||||||
|
<Icon icon="ep:files" class="mr-5px" />
|
||||||
|
生成笔试试卷
|
||||||
|
</el-button>
|
||||||
<!-- 批量删除按钮 -->
|
<!-- 批量删除按钮 -->
|
||||||
<!-- <el-button
|
<!-- <el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
@@ -77,7 +80,7 @@
|
|||||||
|
|
||||||
<!-- 列表展示 -->
|
<!-- 列表展示 -->
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<el-table v-loading="loading" :data="list" :row-key="row => row.id" ref="tableRef" :selected-rows="selectedRows">
|
<el-table v-loading="loading" :data="list" :row-key="row => row.id" ref="tableRef" @selection-change="handleSelectionChange">
|
||||||
|
|
||||||
<!-- 多选列 -->
|
<!-- 多选列 -->
|
||||||
<el-table-column type="selection" width="55" />
|
<el-table-column type="selection" width="55" />
|
||||||
@@ -259,7 +262,9 @@ const reload = () => {
|
|||||||
getList();
|
getList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSelectionChange = (rows) => {
|
||||||
|
selections.value = rows;
|
||||||
|
}
|
||||||
// 搜索操作
|
// 搜索操作
|
||||||
const handleQuery = () => {
|
const handleQuery = () => {
|
||||||
queryParams.pageNo = 1;
|
queryParams.pageNo = 1;
|
||||||
@@ -288,22 +293,30 @@ const openSet = () => {
|
|||||||
};
|
};
|
||||||
/** 表格选中数据 */
|
/** 表格选中数据 */
|
||||||
const selections = ref([]);
|
const selections = ref([]);
|
||||||
|
const downloadLoading = ref(false)
|
||||||
|
|
||||||
const openDown = async () => {
|
const openDown = async () => {
|
||||||
|
try {
|
||||||
try {
|
|
||||||
const rows = selections.value;
|
const rows = selections.value;
|
||||||
if (!rows.length) {
|
if (!rows.length) {
|
||||||
message.error('请至少选择一条数据');
|
message.error('请至少选择一条数据');
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadLoading.value = true;
|
||||||
|
message.info('正在生成试卷中,请稍后...');
|
||||||
|
|
||||||
|
selectedRows.value = rows.map((d: any) => d.paperId);
|
||||||
|
await PaperApi.openDown(selectedRows.value);
|
||||||
|
|
||||||
|
message.success(t('下载成功'));
|
||||||
|
await getList();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('下载失败');
|
||||||
|
} finally {
|
||||||
|
downloadLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedRows.value = rows.map((d: any) => d.paperId); // 保存选中的行数据
|
|
||||||
await PaperApi.openDown(selectedRows.value)
|
|
||||||
message.success(t('common.delSuccess'))
|
|
||||||
// 刷新列表
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
// 打开编辑弹窗
|
// 打开编辑弹窗
|
||||||
const openEdit = (type: string, row?: object) => {
|
const openEdit = (type: string, row?: object) => {
|
||||||
|
@@ -56,13 +56,16 @@
|
|||||||
>
|
>
|
||||||
<Icon icon="ep:set-up" class="mr-5px" /> 抽卷调整
|
<Icon icon="ep:set-up" class="mr-5px" /> 抽卷调整
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
@click="openDown"
|
@click="openDown"
|
||||||
>
|
:loading="downloadLoading"
|
||||||
<Icon icon="ep:files" class="mr-5px" /> 生成笔试试卷
|
:disabled="downloadLoading"
|
||||||
</el-button>
|
>
|
||||||
|
<Icon icon="ep:files" class="mr-5px" />
|
||||||
|
生成笔试试卷
|
||||||
|
</el-button>
|
||||||
<!-- 批量删除按钮 -->
|
<!-- 批量删除按钮 -->
|
||||||
<!-- <el-button
|
<!-- <el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
@@ -77,7 +80,7 @@
|
|||||||
|
|
||||||
<!-- 列表展示 -->
|
<!-- 列表展示 -->
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<el-table v-loading="loading" :data="list" :row-key="row => row.id" ref="tableRef" :selected-rows="selectedRows">
|
<el-table v-loading="loading" :data="list" :row-key="row => row.id" ref="tableRef" @selection-change="handleSelectionChange">
|
||||||
|
|
||||||
<!-- 多选列 -->
|
<!-- 多选列 -->
|
||||||
<el-table-column type="selection" width="55" />
|
<el-table-column type="selection" width="55" />
|
||||||
@@ -260,6 +263,9 @@ const reload = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const handleSelectionChange = (rows) => {
|
||||||
|
selections.value = rows;
|
||||||
|
}
|
||||||
// 搜索操作
|
// 搜索操作
|
||||||
const handleQuery = () => {
|
const handleQuery = () => {
|
||||||
queryParams.pageNo = 1;
|
queryParams.pageNo = 1;
|
||||||
@@ -288,22 +294,30 @@ const openSet = () => {
|
|||||||
};
|
};
|
||||||
/** 表格选中数据 */
|
/** 表格选中数据 */
|
||||||
const selections = ref([]);
|
const selections = ref([]);
|
||||||
|
const downloadLoading = ref(false)
|
||||||
|
|
||||||
const openDown = async () => {
|
const openDown = async () => {
|
||||||
|
try {
|
||||||
try {
|
|
||||||
const rows = selections.value;
|
const rows = selections.value;
|
||||||
if (!rows.length) {
|
if (!rows.length) {
|
||||||
message.error('请至少选择一条数据');
|
message.error('请至少选择一条数据');
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadLoading.value = true;
|
||||||
|
message.info('正在生成试卷中,请稍后...');
|
||||||
|
|
||||||
|
selectedRows.value = rows.map((d: any) => d.paperId);
|
||||||
|
await PaperApi.openDown(selectedRows.value);
|
||||||
|
|
||||||
|
message.success(t('下载成功'));
|
||||||
|
await getList();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('下载失败');
|
||||||
|
} finally {
|
||||||
|
downloadLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedRows.value = rows.map((d: any) => d.paperId); // 保存选中的行数据
|
|
||||||
await PaperApi.openDown(selectedRows.value)
|
|
||||||
message.success(t('common.delSuccess'))
|
|
||||||
// 刷新列表
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
// 打开编辑弹窗
|
// 打开编辑弹窗
|
||||||
const openEdit = (type: string, row?: object) => {
|
const openEdit = (type: string, row?: object) => {
|
||||||
|
@@ -56,13 +56,17 @@
|
|||||||
>
|
>
|
||||||
<Icon icon="ep:set-up" class="mr-5px" /> 抽卷调整
|
<Icon icon="ep:set-up" class="mr-5px" /> 抽卷调整
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
@click="openDown"
|
@click="openDown"
|
||||||
>
|
:loading="downloadLoading"
|
||||||
<Icon icon="ep:files" class="mr-5px" /> 生成笔试试卷
|
:disabled="downloadLoading"
|
||||||
</el-button>
|
>
|
||||||
|
<Icon icon="ep:files" class="mr-5px" />
|
||||||
|
生成笔试试卷
|
||||||
|
</el-button>
|
||||||
|
|
||||||
<!-- 批量删除按钮 -->
|
<!-- 批量删除按钮 -->
|
||||||
<!-- <el-button
|
<!-- <el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
@@ -289,25 +293,35 @@ const openSet = () => {
|
|||||||
|
|
||||||
/** 表格选中数据 */
|
/** 表格选中数据 */
|
||||||
const selections = ref([]);
|
const selections = ref([]);
|
||||||
|
const downloadLoading = ref(false)
|
||||||
|
|
||||||
const openDown = async () => {
|
const openDown = async () => {
|
||||||
|
try {
|
||||||
try {
|
|
||||||
const rows = selections.value;
|
const rows = selections.value;
|
||||||
if (!rows.length) {
|
if (!rows.length) {
|
||||||
message.error('请至少选择一条数据');
|
message.error('请至少选择一条数据');
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadLoading.value = true;
|
||||||
|
message.info('正在生成试卷中,请稍后...');
|
||||||
|
|
||||||
|
selectedRows.value = rows.map((d: any) => d.paperId);
|
||||||
|
await PaperApi.openDown(selectedRows.value);
|
||||||
|
|
||||||
|
message.success(t('下载成功'));
|
||||||
|
await getList();
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('下载失败');
|
||||||
|
} finally {
|
||||||
|
downloadLoading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedRows.value = rows.map((d: any) => d.paperId); // 保存选中的行数据
|
|
||||||
await PaperApi.openDown(selectedRows.value)
|
|
||||||
message.success(t('下载成功'))
|
|
||||||
// 刷新列表
|
|
||||||
await getList()
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handleSelectionChange = (rows) => {
|
const handleSelectionChange = (rows) => {
|
||||||
selections.value = rows;
|
selections.value = rows;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user