Browse Source

文件查阅接口循环调用问题

cyy 5 days ago
parent
commit
a0af78e3dd
1 changed files with 26 additions and 48 deletions
  1. 26 48
      src/views/platform/bpmn/documents/test.vue

+ 26 - 48
src/views/platform/bpmn/documents/test.vue

@@ -114,7 +114,6 @@ import IbpsListResultPage from '@/components/ibps-list-result-page'
 import IbpsBpmnFormrenderDialog from '@/business/platform/bpmn/form/dialog'
 import LookDocument from './lookDocument'
 import { queryFileInfo } from '@/api/platform/feature/sqlInject'
-import { keyBy, mapValues } from 'lodash'
 
 const _ = require('lodash')
 
@@ -219,8 +218,7 @@ export default {
       fileDownloadAuthority,
       current: 0,
       footText: false,
-      noData: false,
-      watchF: false
+      noData: false
     }
   },
   computed: {
@@ -231,16 +229,6 @@ export default {
       return this.checkedIds.join(',')
     }
   },
-  watch: {
-    listData: {
-      handler(newValue, oldValue) {
-        if (newValue.length === 10 && this.watchF === false) {
-          this.watchF = true
-          this.onRefresh()
-        }
-      }
-    }
-  },
   mounted() {
     this.$nextTick(() => {
       const timer = setInterval(() => {
@@ -394,27 +382,33 @@ export default {
        *
       */
     loadData() {
+      if (!this.typeId) {
+        this.loading = false
+        this.finished = true
+        return
+      }
       this.loading = true
       this.noData = false
       this.footText = false
-      let page = 0
-      if (this.current === 0) {
-        page = 0
-      } else {
-        page = this.current * 10
-      }
-      const sqlPart = this.getData()
-      if (!sqlPart) return
-      const sql = sqlPart + ' ' + `LIMIT ${page},10`
+      const limit = this.pagination.limit || 20
+
       queryFileInfo(this.getSearchParams()).then(res => {
-        this.loading = false
         const { data = [], ...rest } = res.variables || {}
         ActionUtils.handleListData(this, {
           dataResult: data,
-          pageResult: rest
+          pageResult: {
+            ...rest,
+            page: this.pagination.page || 1,
+            limit
+          }
         })
-      }).finally(() => {
-        this.loading = false
+        if (this.$utils.isEmpty(rest.totalCount)) {
+          this.finished = data.length < limit
+        }
+        this.noData = this.listData.length === 0
+        this.footText = this.finished && this.listData.length > 0
+      }).catch((e) => {
+        ActionUtils.handleErrorData(this, e)
       })
       //   curdPost('sql', sql).then(res => {
       //     if (res.variables.data.length === 0) {
@@ -446,12 +440,10 @@ export default {
     //   })
     },
     getSearchParams() {
-      const { parameters, requestPage, sorts } = this.getSearchFormData() || {}
-      const { pageNo = 1, limit = 20 } = requestPage || {}
-      const params = mapValues(keyBy(parameters, 'key'), 'value')
-
-      if (sorts?.length) {
-        params.order = sorts.map(i => `${i.field} ${i.order}`).join(',')
+      const params = {
+        pageNo: this.pagination.page || 1,
+        limit: this.pagination.limit || 20,
+        order: 'FA_FANG_SHI_JIAN_ DESC'
       }
       if (this.typeId) {
         params.folderId = this.typeId
@@ -459,19 +451,7 @@ export default {
       if (this.subject) {
         params.fileName = this.subject
       }
-      return {
-        pageNo,
-        limit,
-        order: 'FA_FANG_SHI_JIAN_ DESC',
-        ...params
-      }
-    },
-    getSearchFormData() {
-      return ActionUtils.formatParams(
-        this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {},
-        this.pagination,
-        this.sorts
-      )
+      return params
     },
     /**
        * 获取格式化参数
@@ -547,7 +527,6 @@ export default {
       this.typeTreePopup = true
     },
     clickTypeNode(nodeData) {
-      this.watchF = false
       this.current = 0
       // this.listData = []
       this.typeId = nodeData.id
@@ -612,8 +591,7 @@ export default {
       this.sqlWhere = {
         fileType: fileTypes.join(',')
       }
-      this.listData = []
-      this.loadData()
+      this.onSearch()
     },
     son() {
       this.documentsSon = false