@bsgoal/common 1.6.3 → 1.6.5

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": "@bsgoal/common",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "private": false,
5
5
  "files": [
6
6
  "dist",
@@ -2,7 +2,7 @@
2
2
  * @Author: canlong.shen
3
3
  * @Date: 2023-04-18 17:04:53
4
4
  * @LastEditors: canlong.shen
5
- * @LastEditTime: 2023-04-27 17:45:41
5
+ * @LastEditTime: 2023-05-18 10:12:16
6
6
  * @FilePath: \common\src\components\bsgoal-base-search-table\demo.vue
7
7
  * @Description: 查询 + 表格 组合公共组件
8
8
  *
@@ -705,8 +705,9 @@ const tableDataVal = unref(tableData)
705
705
 
706
706
  const fetch = (params) => {
707
707
  console.log('params >>>', params)
708
- return new Promise((resolve, reject) => {
708
+ return new Promise((resolve) => {
709
709
  setTimeout(() => {
710
+ // 存在分页
710
711
  resolve({
711
712
  data: {
712
713
  rows: tableDataVal,
@@ -714,6 +715,11 @@ const fetch = (params) => {
714
715
  },
715
716
  message: '获取数据成功'
716
717
  })
718
+ // 不存在分页
719
+ // resolve({
720
+ // data: tableDataVal,
721
+ // message: '获取数据成功'
722
+ // })
717
723
  }, 3000)
718
724
  })
719
725
  }
@@ -731,6 +737,18 @@ const fetch = (params) => {
731
737
  :expression="75"
732
738
  @on-search="triggerSearch"
733
739
  >
740
+ <!--
741
+ <BsgoalBaseSearchTable
742
+ selection
743
+ operation
744
+ :has-search="false"
745
+ :has-page="false"
746
+ :call="call"
747
+ :fetch="fetch"
748
+ :config-options="configOptions"
749
+ :expression="75"
750
+ @on-search="triggerSearch"
751
+ > -->
734
752
  <template v-slot:menu>
735
753
  <el-button type="primary">操作按钮</el-button>
736
754
  </template>
@@ -2,7 +2,7 @@
2
2
  * @Author: canlong.shen
3
3
  * @Date: 2023-04-18 17:04:47
4
4
  * @LastEditors: canlong.shen
5
- * @LastEditTime: 2023-04-28 08:46:38
5
+ * @LastEditTime: 2023-05-18 10:13:34
6
6
  * @FilePath: \common\src\components\bsgoal-base-search-table\index.vue
7
7
  * @Description: 查询+表格 基础组件
8
8
  *
@@ -92,12 +92,38 @@ const props = defineProps({
92
92
  type: [Object, Function],
93
93
  default: null
94
94
  },
95
- /**
95
+ /**
96
96
  * 表格高度 下边距值
97
97
  */
98
- expression:{
99
- type:[Number],
98
+ expression: {
99
+ type: [Number],
100
100
  default: 75
101
+ },
102
+ /**
103
+ * 映射字段
104
+ */
105
+ mapProps: {
106
+ type: [Object],
107
+ default: () => ({
108
+ currentPage: 'currentPage',
109
+ pageSize: 'pageSize',
110
+ rows: 'rows',
111
+ total: 'total'
112
+ })
113
+ },
114
+ /**
115
+ * 是否显示分页
116
+ */
117
+ hasPage: {
118
+ type: Boolean,
119
+ default: true
120
+ },
121
+ /**
122
+ * 是否显示查询
123
+ */
124
+ hasSearch: {
125
+ type: Boolean,
126
+ default: true
101
127
  }
102
128
  })
103
129
 
@@ -108,17 +134,17 @@ const options = unref(props.configOptions)
108
134
 
109
135
  // 查询 配置项
110
136
  const searchOptions = computed(() => {
111
- return options.filter(fi => {
112
- const {type = '' } = fi
113
- return !!type
137
+ return options.filter((fi) => {
138
+ const { type = '' } = fi
139
+ return !!type
114
140
  })
115
141
  })
116
142
 
117
143
  // 表格 配置项
118
144
  const tableOptions = computed(() => {
119
- return options.filter(fi => {
120
- const { item = false } = fi
121
- return !item
145
+ return options.filter((fi) => {
146
+ const { item = false } = fi
147
+ return !item
122
148
  })
123
149
  })
124
150
 
@@ -131,24 +157,41 @@ const BSGOAL_BASE_TABLE_REF = ref(null)
131
157
  const triggerSearch = (searchParams) => {
132
158
  BSGOAL_BASE_TABLE_REF.value.refreshList(searchParams)
133
159
  }
160
+
161
+ // ---> S 计算expression <---
162
+ const expresionGet = computed(() => {
163
+ const { expression, hasPage } = props
164
+ if (hasPage === false) {
165
+ return 25
166
+ }
167
+ return expression
168
+ })
169
+ // ---> E 计算expression <---
134
170
  </script>
135
171
  <template>
136
172
  <div class="bsgoal-base-search-table">
137
173
  <div class="base_search_table">
138
174
  <!-- S 查询 -->
139
- <BsgoalBaseSearch :config-options="searchOptions" @on-search="triggerSearch" @on-clear="triggerSearch" />
175
+ <BsgoalBaseSearch
176
+ v-show="hasSearch"
177
+ :config-options="searchOptions"
178
+ @on-search="triggerSearch"
179
+ @on-clear="triggerSearch"
180
+ />
140
181
  <!-- E 查询 -->
141
182
  <!-- S 表格 -->
142
183
  <BsgoalBaseTable
143
184
  ref="BSGOAL_BASE_TABLE_REF"
185
+ :map-props="mapProps"
144
186
  :operationWidth="operationWidth"
145
187
  :config-options="tableOptions"
146
188
  :data="tableData"
147
189
  :selection="selection"
148
190
  :operation="operation"
149
- :expression="expression"
191
+ :expression="expresionGet"
150
192
  :fetch="fetch"
151
193
  :call="call"
194
+ :has-page="hasPage"
152
195
  >
153
196
  <!-- S 顶部菜单 -->
154
197
 
@@ -2,7 +2,7 @@
2
2
  * @Author: canlong.shen
3
3
  * @Date: 2023-04-10 11:29:04
4
4
  * @LastEditors: canlong.shen
5
- * @LastEditTime: 2023-05-15 14:50:19
5
+ * @LastEditTime: 2023-05-18 10:05:33
6
6
  * @FilePath: \common\src\components\bsgoal-base-table\index.vue
7
7
  * @Description:
8
8
  *
@@ -111,7 +111,7 @@ const props = defineProps({
111
111
  },
112
112
  /**
113
113
  * 表格高度
114
- *
114
+ *
115
115
  * 默认 : 自动计算
116
116
  * 布尔值 : 默认表格高度
117
117
  * 字符串 : 直接赋值给 height
@@ -124,7 +124,7 @@ const props = defineProps({
124
124
  /**
125
125
  * 是否显示分页
126
126
  */
127
- page: {
127
+ hasPage: {
128
128
  type: Boolean,
129
129
  default: true
130
130
  }
@@ -166,6 +166,15 @@ watchEffect(() => {
166
166
  })
167
167
 
168
168
  // 触发搜索
169
+ const mapPropsVal = unref(props.mapProps)
170
+ const mapPropsFuse = {
171
+ currentPage: 'currentPage',
172
+ pageSize: 'pageSize',
173
+ rows: 'rows',
174
+ total: 'total',
175
+ ...mapPropsVal
176
+ }
177
+
169
178
  const currentPage = ref(1)
170
179
  const pageSize = ref(10)
171
180
  const total = ref(0)
@@ -174,25 +183,28 @@ const tableLoading = ref(props.loading)
174
183
  const tableData = ref(props.data)
175
184
  const resData = ref({})
176
185
  const ping = () => {
177
- const { fetch, call, mapProps } = props
186
+ const { fetch, call, hasPage } = props
178
187
  const searchParamsVal = searchParams.value
179
188
  const currentPageVal = currentPage.value
180
189
  const pageSizeVal = pageSize.value
181
190
  const fetchParams = { ...searchParamsVal }
182
- const mapPropsVal = unref(mapProps)
183
-
184
- fetchParams[mapPropsVal.currentPage] = currentPageVal
185
- fetchParams[mapPropsVal.pageSize] = pageSizeVal
191
+ // 显示分页的注入分页参数
192
+ if (hasPage) {
193
+ fetchParams[mapPropsFuse.currentPage] = currentPageVal
194
+ fetchParams[mapPropsFuse.pageSize] = pageSizeVal
195
+ }
186
196
 
187
197
  useFetch(fetch(fetchParams), call, tableLoading, resData)
188
198
  }
189
199
 
190
200
  watch(resData, (data) => {
191
- const { mapProps } = props
192
- const mapPropsVal = unref(mapProps)
193
-
194
- tableData.value = data[mapPropsVal.rows]
195
- total.value = data[mapPropsVal.total]
201
+ // 存在分页才注入
202
+ if (props.hasPage) {
203
+ tableData.value = data[mapPropsFuse.rows]
204
+ total.value = data[mapPropsFuse.total]
205
+ } else {
206
+ tableData.value = data
207
+ }
196
208
  })
197
209
 
198
210
  // 查询
@@ -230,13 +242,20 @@ defineExpose({
230
242
  <!-- E 表头操作区域 -->
231
243
  <!-- S 表格区域 -->
232
244
  <div ref="EL_TABLE_WRAP_REF">
233
- <el-table stripe border highlight-current-row style="width: 100%" v-loading="tableLoading" :data="tableData"
245
+ <el-table
246
+ stripe
247
+ border
248
+ highlight-current-row
249
+ style="width: 100%"
250
+ v-loading="tableLoading"
251
+ :data="tableData"
234
252
  :header-cell-style="{
235
253
  fontWeight: 'bold',
236
254
  backgroundColor: '#EBEEF5',
237
255
  color: 'rgba(0,0,0,.85)',
238
256
  fontSize: '14px'
239
- }">
257
+ }"
258
+ >
240
259
  <!-- / 无数据展示内容 -->
241
260
  <template #empty>
242
261
  <BsgoalBaseTableEmpty />
@@ -246,11 +265,28 @@ defineExpose({
246
265
  <el-table-column v-if="selection" fixed="left" type="selection" width="40" />
247
266
  <!-- / 多选 -->
248
267
  <!-- / 表格内容 -->
249
- <template v-for="(
250
- { prop = '', label = '', align = 'center', width = '', fixed = false, tooltip = false, limit = 0 } = {}, index
251
- ) of configOptionsGet" :key="index">
252
- <el-table-column :label="label" :align="align" :width="width" :fixed="fixed"
253
- :min-width="`${label.length * 14 + 24}px`">
268
+ <template
269
+ v-for="(
270
+ {
271
+ prop = '',
272
+ label = '',
273
+ align = 'center',
274
+ width = '',
275
+ fixed = false,
276
+ tooltip = false,
277
+ limit = 0
278
+ } = {},
279
+ index
280
+ ) of configOptionsGet"
281
+ :key="index"
282
+ >
283
+ <el-table-column
284
+ :label="label"
285
+ :align="align"
286
+ :width="width"
287
+ :fixed="fixed"
288
+ :min-width="`${label.length * 14 + 24}px`"
289
+ >
254
290
  <template v-slot:default="{ row }">
255
291
  <slot :name="prop" :row="row">
256
292
  <BsgoalBaseTableContent :limit="limit" :tooltip="tooltip" :data="row[prop]" />
@@ -265,8 +301,12 @@ defineExpose({
265
301
  <!-- E 表格区域 -->
266
302
 
267
303
  <!-- S 分页 -->
268
- <BsgoalBaseTablePagination v-if="page" :total="total" @on-current-change="triggerPaginationCurrentChange"
269
- @on-size-change="triggerPaginationSizeChange" />
304
+ <BsgoalBaseTablePagination
305
+ v-if="hasPage"
306
+ :total="total"
307
+ @on-current-change="triggerPaginationCurrentChange"
308
+ @on-size-change="triggerPaginationSizeChange"
309
+ />
270
310
  <!-- E 分页 -->
271
311
  </div>
272
312
  </div>