Browse Source

修改高级查询导出

zhaoke 1 year ago
parent
commit
5b1c6ddfe6
1 changed files with 60 additions and 7 deletions
  1. 60 7
      src/views/advancedQuery/views/advancedHome.vue

+ 60 - 7
src/views/advancedQuery/views/advancedHome.vue

@@ -32,7 +32,7 @@
           <button class="btnAn" @click="dialogShow">
             高级查询
           </button>
-          <button class="btnAn" @click="exportHandler('table', '高级查询结果')">
+          <button class="btnAn" @click="exportHandler('tableAll', '高级查询结果')">
             导出
           </button>
           <button class="btnAn" @click="toNewAdvance">
@@ -57,6 +57,18 @@
         </el-table-column>
       </el-table>
     </div>
+    <!--下载全部-->
+    <div v-show="tableFlag" class="advance__table_all">
+      <el-table ref="tableAll" max-height="100%" class="table" :data="dealedTableDataAll" border :span-method="objectSpanMethod" stripe fit style="width: 100%">
+        <el-table-column v-for="col in tableCols" :key="col.prop" :prop="col.prop" :label="col.label" :width="col.width" :fixed="col.fixed" :formatter="tableFormat">
+          <template #header>
+            <el-tooltip :content="col.desc || col.label" placement="top">
+              <TableHeaderCell :label="col.label" :filter-options="tableDataFilters[col.prop]" :filter-values.sync="filterValues[col.prop]" :sortable="col.sortable" :sort-rule.sync="tableDataSortRules[col.prop]" />
+            </el-tooltip>
+          </template>
+        </el-table-column>
+      </el-table>
+    </div>
     <!--列设置-->
     <!-- <Dialog
       :flag="dialogFlag"
@@ -184,6 +196,8 @@ export default {
       page: -1,
       noMore: false,
       checkList: [],
+      dealedTableDataAll: [],
+      tableFlag: false,
       tableCols: [
         {
           prop: 'flightNO',
@@ -1172,15 +1186,54 @@ export default {
         return ['合计', `共${num}件`]
       }
     },
+    //设置表格数据
+    async setTableDataAll () {
+      this.tableFlag = true
+      this.loading = true
+      let flag = false
+      try {
+        const {
+          code,
+          returnData: { listValues: result, needPage },
+        } = await TempQuery({
+          serviceId: SERVICE_ID.advancedQueryId,
+          page: 1,
+          pageSize: 9999,
+          dataContent: this.dataContent,
+        })
+        if (code == 0) {
+          this.dealedTableDataAll = [...result]
+          this.tableFlag = false
+          this.loading = false
+          flag = true
+        } else {
+          this.$message.error('数据获取失败,请重新下载')
+          this.tableFlag = false
+          this.loading = false
+          flag = false
+        }
+      } catch (error) {
+        this.tableFlag = false
+        this.loading = false
+        flag = false
+        this.$message.error(error || '数据获取失败,请重新下载')
+      }
+      return flag
+    },
     exportHandler: _.throttle(
-      function (refName, tableName) {
-        if (!this.tableData.length) {
+      async function (refName, tableName) {
+        const flag = await this.setTableDataAll()
+        if (flag) {
+          if (!this.dealedTableDataAll.length) {
+            this.$message.info('无数据')
+            return
+          }
+          const table = this.$refs[refName].$el.cloneNode(true)
+          const fileName = `${tableName}.xlsx`
+          exportToExcel(table, tableName, fileName)
+        } else {
           this.$message.info('无数据')
-          return
         }
-        const table = this.$refs[refName].$el.cloneNode(true)
-        const fileName = `${tableName}.xlsx`
-        exportToExcel(table, tableName, fileName)
       },
       2000,
       { trailing: false }