@idooel/components 0.0.2-beta.15 → 0.0.2-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idooel/components",
3
- "version": "0.0.2-beta.15",
3
+ "version": "0.0.2-beta.17",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "main": "dist/@idooel/components.umd.js",
@@ -18,10 +18,15 @@
18
18
  您可以请点击上方按钮查看任务进度或关闭弹框
19
19
  </div>
20
20
  </div>
21
- <div v-if="!isFileEmpty && statusList.length > 0 && mode === 'sync'" class="ele-modal-import__errors">
22
- <div v-for="(value, idx) in statusList" :key="idx">
23
- {{ value.message }}
24
- </div>
21
+ <div v-if="!isFileEmpty && mode === 'sync'" class="ele-modal-import__errors">
22
+ <template v-if="statusList.length > 0">
23
+ <div v-for="(value, idx) in statusList" :key="idx">
24
+ {{ value.message }}
25
+ </div>
26
+ </template>
27
+ <template v-else>
28
+ <ele-alert :type="hooks.uploaded.messages.type" :message="hooks.uploaded.messages.message"></ele-alert>
29
+ </template>
25
30
  </div>
26
31
  </ele-modal>
27
32
  </template>
@@ -56,9 +61,17 @@ export default {
56
61
  url: '',
57
62
  requestType: 'POST',
58
63
  params: {},
59
- fieldMap: {}
64
+ fieldMap: {},
65
+ messages: {
66
+ type: 'success',
67
+ message: '文件上传成功'
68
+ }
60
69
  }
61
70
  })
71
+ },
72
+ errorList: {
73
+ type: Array,
74
+ default: () => []
62
75
  }
63
76
  },
64
77
  data() {
@@ -84,6 +97,9 @@ export default {
84
97
  },
85
98
  statusList () {
86
99
  // 0 default
100
+ if (this.errorList.length > 0) {
101
+ return this.buildErrorList(this.errorList)
102
+ }
87
103
  return this.innerErrorList
88
104
  }
89
105
  },
@@ -110,6 +126,20 @@ export default {
110
126
  const ctx = { _route: this.$route.query, route: this.$route, ...payloads }
111
127
  return parseFieldMap(fieldMap, ctx)
112
128
  },
129
+ buildErrorList (dataSource = []) {
130
+ const ret = dataSource.map(item => {
131
+ if (type.isStr(item)) {
132
+ return {
133
+ statusCode: '0',
134
+ message: item
135
+ }
136
+ } else {
137
+ // TODO
138
+ console.warn('not support error list type', item)
139
+ }
140
+ })
141
+ return ret
142
+ },
113
143
  uploadFileSuccess (props) {
114
144
  const { uploaded } = this.hooks
115
145
  const { url, requestType = 'POST', params = {}, fieldMap = {} } = uploaded
@@ -124,16 +154,7 @@ export default {
124
154
  net[requestType.toLowerCase()](url, formData , { headers: { 'Content-Type': 'multipart/form-data' } }).then(resp => {
125
155
  const { code, data } = resp
126
156
  if (code !== '2000') {
127
- this.innerErrorList = data.map(item => {
128
- if (type.isStr(item)) {
129
- return {
130
- statusCode: '0',
131
- message: item
132
- }
133
- } else {
134
- // TODO
135
- }
136
- })
157
+ this.innerErrorList = this.buildErrorList(data || [])
137
158
  } else {
138
159
  this.innerErrorList = []
139
160
  }
@@ -671,8 +671,7 @@ export default {
671
671
  },
672
672
  async requestTableData (props = {}) {
673
673
  const { url, requestType = 'GET', page = {} } = this.tableMeta
674
- const { pageSize = 10 } = page
675
- this.tableQuerys = Object.assign(this.tableQuerys, { currentPage: 1, pageSize }, props)
674
+ this.tableQuerys = Object.assign(this.tableQuerys, { currentPage: this.tableQuerys.currentPage || 1, pageSize: this.tableQuerys.pageSize || 10 }, props)
676
675
  this.$emit(RESERVE_EVENT_NAMES.WATCH, { ...this.exposed })
677
676
  this.loading = true
678
677
  const ret = await net[requestType.toLowerCase()](
@@ -706,6 +705,24 @@ export default {
706
705
  const modelTableContainerRef = this.$refs[this.modelTableContainerRef]
707
706
  const { height } = modelTableContainerRef.getBoundingClientRect()
708
707
  this.treeWrapperHeight = height
708
+ },
709
+ async keepAliveRefresh () {
710
+ // 重新计算表格高度(应对窗口大小变化)
711
+ this.$nextTick(() => {
712
+ this.calculateTableHeight()
713
+ if (this.showTree) {
714
+ this.calculateTreeHeight()
715
+ }
716
+ })
717
+ // 刷新列表数据
718
+ const { overrideInit = false } = this.tableMeta
719
+ if (overrideInit) {
720
+ // 如果使用自定义初始化模式,触发 INIT 事件
721
+ this.$emit(RESERVE_EVENT_NAMES.INIT, { ...this.exposed })
722
+ } else {
723
+ // 使用当前查询参数刷新表格数据
724
+ await this.requestTableData(this.tableQuerys)
725
+ }
709
726
  }
710
727
  },
711
728
  mounted () {
@@ -739,23 +756,7 @@ export default {
739
756
  }
740
757
  },
741
758
  async activated () {
742
- // 重新计算表格高度(应对窗口大小变化)
743
- this.$nextTick(() => {
744
- this.calculateTableHeight()
745
- if (this.showTree) {
746
- this.calculateTreeHeight()
747
- }
748
- })
749
-
750
- // 刷新列表数据
751
- const { overrideInit = false } = this.tableMeta
752
- if (overrideInit) {
753
- // 如果使用自定义初始化模式,触发 INIT 事件
754
- this.$emit(RESERVE_EVENT_NAMES.INIT, { ...this.exposed })
755
- } else {
756
- // 使用当前查询参数刷新表格数据
757
- await this.requestTableData()
758
- }
759
+ await this.keepAliveRefresh()
759
760
  }
760
761
  }
761
762
  </script>
package/vitest.config.js CHANGED
@@ -1,17 +1,17 @@
1
- import { defineConfig } from 'vitest/config'
2
- import vue from '@vitejs/plugin-vue2'
3
- import path from 'path'
4
-
5
- export default defineConfig({
6
- plugins: [vue()],
7
- resolve: {
8
- alias: {
9
- '@': path.resolve(__dirname, 'packages')
10
- }
11
- },
12
- test: {
13
- environment: 'jsdom',
14
- globals: true,
15
- setupFiles: ['__tests__/setup.js']
16
- }
17
- })
1
+ import { defineConfig } from 'vitest/config'
2
+ import vue from '@vitejs/plugin-vue2'
3
+ import path from 'path'
4
+
5
+ export default defineConfig({
6
+ plugins: [vue()],
7
+ resolve: {
8
+ alias: {
9
+ '@': path.resolve(__dirname, 'packages')
10
+ }
11
+ },
12
+ test: {
13
+ environment: 'jsdom',
14
+ globals: true,
15
+ setupFiles: ['__tests__/setup.js']
16
+ }
17
+ })