diff --git a/yudao-module-infra/src/main/resources/codegen/vue/views/index.vue.vm b/yudao-module-infra/src/main/resources/codegen/vue/views/index.vue.vm
index bbc9131..0f0cd9a 100644
--- a/yudao-module-infra/src/main/resources/codegen/vue/views/index.vue.vm
+++ b/yudao-module-infra/src/main/resources/codegen/vue/views/index.vue.vm
@@ -50,6 +50,14 @@
v-hasPermi="['${permissionPrefix}:create']">新增
+ 导入
+
+
+ 导入模板
+
+
导出
@@ -78,6 +86,7 @@
#end
+
## 特殊:主子表专属逻辑
#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
@@ -244,6 +253,8 @@ export default {
loading: true,
// 导出遮罩层
exportLoading: false,
+ // 导入遮罩层
+ importLoading: false,
// 显示搜索条件
showSearch: true,
## 特殊:树表专属逻辑(树不需要分页接口)
@@ -322,6 +333,42 @@ export default {
openForm(id) {
this.#[[$]]#refs["formRef"].open(id);
},
+ /** 导入按钮操作 */
+ handleImport() {
+ this.$refs.importFileRef && this.$refs.importFileRef.click();
+ },
+ /** 导入模板下载 */
+ async handleImportTemplate() {
+ const data = await ${simpleClassName}Api.import${simpleClassName}Template();
+ this.#[[$]]#download.excel(data, '${table.classComment}导入模板.xls');
+ },
+ /** 导入文件变更 */
+ async handleImportFileChange(event) {
+ const target = event.target;
+ const file = target.files && target.files[0];
+ if (!file) {
+ return;
+ }
+ this.importLoading = true;
+ try {
+ const formData = new FormData();
+ formData.append('file', file);
+ const res = await ${simpleClassName}Api.import${simpleClassName}(formData);
+ const data = res.data || res;
+ let text = '导入成功数量:' + (data.successCount || 0) + ';导入失败数量:' + (data.failureCount || 0) + ';';
+ if (data.failureRows) {
+ Object.keys(data.failureRows).forEach((rowNo) => {
+ text += '< 第' + rowNo + '行: ' + data.failureRows[rowNo] + ' >';
+ });
+ }
+ await this.$alert(text, '${table.classComment}导入结果', { dangerouslyUseHTMLString: true });
+ await this.getList();
+ } catch {
+ } finally {
+ target.value = '';
+ this.importLoading = false;
+ }
+ },
/** 删除按钮操作 */
async handleDelete(row) {
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
diff --git a/yudao-module-infra/src/main/resources/codegen/vue3_vben/views/index.vue.vm b/yudao-module-infra/src/main/resources/codegen/vue3_vben/views/index.vue.vm
index 9e59b12..6fa5c7c 100644
--- a/yudao-module-infra/src/main/resources/codegen/vue3_vben/views/index.vue.vm
+++ b/yudao-module-infra/src/main/resources/codegen/vue3_vben/views/index.vue.vm
@@ -1,18 +1,27 @@