Răsfoiți Sursa

增加批量导出

zrd 3 luni în urmă
părinte
comite
c88ac4a28d
2 a modificat fișierele cu 28 adăugiri și 3 ștergeri
  1. 3 1
      src/api/infra/codegen/index.ts
  2. 25 2
      src/views/infra/codegen/index.vue

+ 3 - 1
src/api/infra/codegen/index.ts

@@ -95,7 +95,9 @@ export const updateCodegenTable = (data: CodegenUpdateReqVO) => {
 export const syncCodegenFromDB = (id: number) => {
   return request.put({ url: '/infra/codegen/sync-from-db?tableId=' + id })
 }
-
+export const downloadCodegenNewAll = (ids: number) => {
+  return request.download({ url: '/infra/codegen/downloadAll?ids=' + ids.ids })
+}
 // 预览生成代码
 export const previewCodegen = (id: number) => {
   return request.get({ url: '/infra/codegen/preview?tableId=' + id })

+ 25 - 2
src/views/infra/codegen/index.vue

@@ -50,13 +50,18 @@
           <Icon class="mr-5px" icon="ep:zoom-in" />
           导入
         </el-button>
+        <el-button type="primary" @click="generateClick()">
+          <Icon class="mr-5px" icon="ep:zoom-in" />
+          批量生成
+        </el-button>
       </el-form-item>
     </el-form>
   </ContentWrap>
 
   <!-- 列表 -->
   <ContentWrap>
-    <el-table v-loading="loading" :data="list">
+    <el-table v-loading="loading" :data="list" @selection-change="selectionChange">
+      <el-table-column type="selection" width="55" />
       <el-table-column align="center" label="数据源">
         <template #default="scope">
           {{
@@ -212,7 +217,25 @@ const importRef = ref()
 const openImportTable = () => {
   importRef.value.open()
 }
-
+const selectList = ref([])
+const selectionChange = (val) => {
+  console.log(val, 544545455)
+  selectList.value = val
+}
+const generateClick = async () => {
+  if (selectList.value.length === 0) {
+    ElMessage({
+      message: '请至少选择一条!',
+      type: 'warning'
+    })
+    return
+  }
+  const params = {
+    ids: selectList.value.map((item) => item.id)
+  }
+  const res = await CodegenApi.downloadCodegenNewAll(params)
+  download.zip(res, 'codegen-all.zip')
+}
 /** 编辑操作 */
 const handleUpdate = (id: number) => {
   push('/codegen/edit?id=' + id)