mirror of
				https://github.com/nsnail/NetAdmin.git
				synced 2025-11-01 03:35:28 +08:00 
			
		
		
		
	fix: 🐛 scTable dataChanged
This commit is contained in:
		| @@ -325,8 +325,7 @@ export default { | |||||||
|         } |         } | ||||||
|         //判断是否静态数据 |         //判断是否静态数据 | ||||||
|         if (this.queryApi) { |         if (this.queryApi) { | ||||||
|             const res = await this.getData() |             await this.getData() | ||||||
|             this.$emit('dataChange', res, this.tableData) |  | ||||||
|         } else if (this.data) { |         } else if (this.data) { | ||||||
|             this.tableData = this.data |             this.tableData = this.data | ||||||
|             this.total = this.tableData.length |             this.total = this.tableData.length | ||||||
| @@ -460,44 +459,48 @@ export default { | |||||||
|         }, |         }, | ||||||
|         //获取数据 |         //获取数据 | ||||||
|         async getData() { |         async getData() { | ||||||
|             this.loading = true |             const ret = await (async () => { | ||||||
|  |                 this.loading = true | ||||||
|  |  | ||||||
|             let res |                 let res | ||||||
|             let response |                 let response | ||||||
|             try { |                 try { | ||||||
|                 const reqData = this.getQueryParams() |                     const reqData = this.getQueryParams() | ||||||
|                 if (!this.beforePost || this.beforePost(reqData)) res = await this.queryApi.post(reqData) |                     if (!this.beforePost || this.beforePost(reqData)) res = await this.queryApi.post(reqData) | ||||||
|             } catch (error) { |                 } catch (error) { | ||||||
|                 this._clearData() |                     this._clearData() | ||||||
|                 this.loading = false |                     this.loading = false | ||||||
|                 this.emptyText = error.statusText |                     this.emptyText = error.statusText | ||||||
|                 return false |                     return false | ||||||
|             } |  | ||||||
|             try { |  | ||||||
|                 response = config.parseData(res) |  | ||||||
|             } catch (error) { |  | ||||||
|                 this._clearData() |  | ||||||
|                 this.loading = false |  | ||||||
|                 this.emptyText = '数据格式错误' |  | ||||||
|                 return false |  | ||||||
|             } |  | ||||||
|             if (response.code !== config.successCode) { |  | ||||||
|                 this._clearData() |  | ||||||
|                 this.loading = false |  | ||||||
|                 this.emptyText = response.msg |  | ||||||
|             } else { |  | ||||||
|                 this.emptyText = '暂无数据' |  | ||||||
|                 if (this.hidePagination) { |  | ||||||
|                     this.tableData = response.data || [] |  | ||||||
|                 } else { |  | ||||||
|                     this.tableData = response.rows || [] |  | ||||||
|                 } |                 } | ||||||
|                 this.total = response.total || 0 |                 try { | ||||||
|                 this.summary = response.summary || {} |                     response = config.parseData(res) | ||||||
|                 this.loading = false |                 } catch (error) { | ||||||
|             } |                     this._clearData() | ||||||
|             this.$refs.scTable?.setScrollTop(0) |                     this.loading = false | ||||||
|             return res |                     this.emptyText = '数据格式错误' | ||||||
|  |                     return false | ||||||
|  |                 } | ||||||
|  |                 if (response.code !== config.successCode) { | ||||||
|  |                     this._clearData() | ||||||
|  |                     this.loading = false | ||||||
|  |                     this.emptyText = response.msg | ||||||
|  |                 } else { | ||||||
|  |                     this.emptyText = '暂无数据' | ||||||
|  |                     if (this.hidePagination) { | ||||||
|  |                         this.tableData = response.data || [] | ||||||
|  |                     } else { | ||||||
|  |                         this.tableData = response.rows || [] | ||||||
|  |                     } | ||||||
|  |                     this.total = response.total || 0 | ||||||
|  |                     this.summary = response.summary || {} | ||||||
|  |                     this.loading = false | ||||||
|  |                 } | ||||||
|  |                 this.$refs.scTable?.setScrollTop(0) | ||||||
|  |                 return res | ||||||
|  |             })() | ||||||
|  |  | ||||||
|  |             this.$emit('dataChange', ret, this.tableData) | ||||||
|         }, |         }, | ||||||
|         //清空数据 |         //清空数据 | ||||||
|         _clearData() { |         _clearData() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user