lw-cdp-ui 1.4.23 → 1.4.25

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.
@@ -1,42 +1,67 @@
1
1
  <template>
2
2
  <div class="lw-bi-chart-global-layout">
3
- <lw-search v-if="searchOptions.length > 0" class="search-body" :options="searchOptions" v-model="searchParams"
4
- :hideLabel="true" @search="search" @reset="reset" />
3
+ <lw-search
4
+ v-if="searchOptions.length > 0"
5
+ class="search-body"
6
+ :options="searchOptions"
7
+ v-model="searchParams"
8
+ :hideLabel="true"
9
+ @search="search"
10
+ @reset="reset" />
5
11
 
6
- <GridLayout v-model:layout="chartList" :col-num="12" :row-height="30" :is-draggable="designMode"
7
- :is-resizable="designMode" :use-css-transforms="false" vertical-compact use-css-transforms>
8
- <GridItem v-for="(item, index) in chartList" :key="item.i" :x="item.x" :y="item.y" :w="item.w" :h="item.h"
12
+ <GridLayout
13
+ v-model:layout="chartList"
14
+ :col-num="12"
15
+ :row-height="30"
16
+ :is-draggable="designMode"
17
+ :is-resizable="designMode"
18
+ :use-css-transforms="false"
19
+ vertical-compact
20
+ use-css-transforms>
21
+ <GridItem
22
+ v-for="(item, index) in chartList"
23
+ :key="item.i"
24
+ :x="item.x"
25
+ :y="item.y"
26
+ :w="item.w"
27
+ :h="item.h"
9
28
  :i="item.i">
10
29
  <div class="lw-bi-chart-global-layout-item" :class="{ edit: designMode }">
11
30
  <div v-if="item.data?.setting?.activeDateUnitFilter" class="filter-top">
12
31
  <el-radio-group v-model="item.timeUnit" @change="changeTimeUnit(item, index)">
13
- <el-radio-button :label="key" :value="value"
14
- v-for="(value, key) in item.data?.setting?.optionalDateUnitRanges" :key="key" />
15
- <el-radio-button disabled
16
- v-if="Object.keys(item.data?.setting?.optionalDateUnitRanges).length == 0">未选择周期列表</el-radio-button>
32
+ <el-radio-button
33
+ :label="key"
34
+ :value="value"
35
+ v-for="(value, key) in item.data?.setting?.optionalDateUnitRanges"
36
+ :key="key" />
37
+ <el-radio-button disabled v-if="Object.keys(item.data?.setting?.optionalDateUnitRanges).length == 0"
38
+ >未选择周期列表</el-radio-button
39
+ >
17
40
  </el-radio-group>
18
41
  </div>
19
42
 
20
43
  <div v-if="item?.type == 'Dashboard'" class="grid-item-dashboard">
21
44
  <lwBiChartPage :chartId="item.id" />
22
45
  </div>
23
- <lwBiChartItem :rawData="item.data"
46
+ <lwBiChartItem
47
+ :rawData="item.data"
24
48
  :height="item.data?.setting?.activeDateUnitFilter ? 'calc(100% - 36px)' : '100%'" />
25
49
  <div class="remove" v-if="designMode" @click="removeChart(index)">
26
50
  <el-button type="primary" link icon="el-icon-delete"></el-button>
27
51
  </div>
28
52
  </div>
29
-
30
53
  </GridItem>
31
54
  </GridLayout>
32
55
  <div class="no-record-panel e-unselect" v-if="chartList.length === 0">
33
- <el-empty :description="designMode ? '点击上方工具栏中的按钮,添加图表至当前仪表板' : '仪表板中还没有添加任何图表'" />
56
+ <el-empty
57
+ :description="designMode ? '点击上方工具栏中的按钮,添加图表至当前仪表板' : '仪表板中还没有添加任何图表'" />
34
58
  </div>
35
59
  </div>
36
60
  </template>
37
61
 
38
62
  <script>
39
63
  import { GridLayout, GridItem } from 'grid-layout-plus'
64
+ import dayjs from 'dayjs'
40
65
  export default {
41
66
  components: { GridLayout, GridItem },
42
67
  data() {
@@ -81,8 +106,8 @@ export default {
81
106
  let visualize = await this.$http.get(
82
107
  `${this.$config.API_URL}/bi-manage/{tenantId}/{buCode}/visualize/${chartData.id}`
83
108
  )
84
- visualize?.models.forEach(item => {
85
- item?.dimensions.forEach(d => {
109
+ visualize?.models.forEach((item) => {
110
+ item?.dimensions.forEach((d) => {
86
111
  d.timeSetting.timeUnit = chartItem.timeUnit
87
112
  })
88
113
  })
@@ -160,6 +185,25 @@ export default {
160
185
  removeChart(index) {
161
186
  this.modelValue.splice(index, 1)
162
187
  },
188
+ listToTree(data) {
189
+ const result = []
190
+ const map = {}
191
+
192
+ data.forEach((item) => {
193
+ map[item.id] = { value: item.id, label: item.name, children: [] }
194
+ })
195
+
196
+ data.forEach((item) => {
197
+ const parent = map[item.parent]
198
+ if (parent) {
199
+ parent.children.push(map[item.id])
200
+ } else {
201
+ result.push(map[item.id])
202
+ }
203
+ })
204
+
205
+ return result
206
+ },
163
207
  async getFilter(filterControls) {
164
208
  for (const control of filterControls) {
165
209
  const { type } = control
@@ -194,11 +238,13 @@ export default {
194
238
  case 'DATA_PICKER': {
195
239
  const setting = control.dataPickerSetting
196
240
  const options = await getOptions(setting)
241
+ this.searchParams[`values.${setting.code}`] = setting?.value || []
197
242
  this.searchOptions.push({
198
243
  label: control.name,
199
244
  prop: `values.${setting.code}`,
200
245
  renderType: 'select',
201
246
  options,
247
+ value: setting?.value || '',
202
248
  valueKey: 'value',
203
249
  labelKey: 'label'
204
250
  })
@@ -208,10 +254,11 @@ export default {
208
254
  case 'DATA_CASCADE': {
209
255
  const setting = control.dataPickerSetting
210
256
  const items = await getTreeOptions(setting)
257
+ this.searchParams[`values.${setting.code}`] = setting?.value || []
211
258
  this.searchOptions.push({
212
259
  label: control.name,
213
260
  name: `values.${setting.code}`,
214
- value: '',
261
+ value: setting?.value || [],
215
262
  component: 'treeSelect',
216
263
  options: {
217
264
  items,
@@ -223,9 +270,11 @@ export default {
223
270
  }
224
271
 
225
272
  case 'DATA_INPUT': {
273
+ this.searchParams[`values.${control.dataInputSetting.code}`] = control.dataInputSetting?.value || ''
226
274
  this.searchOptions.push({
227
275
  label: control.name,
228
276
  prop: `values.${control.dataInputSetting.code}`,
277
+ value: control.dataInputSetting?.value || '',
229
278
  renderType: 'input'
230
279
  })
231
280
  break
@@ -233,10 +282,88 @@ export default {
233
282
 
234
283
  case 'DATE_PICKER': {
235
284
  const setting = control.datePickerSetting
285
+ let value = []
286
+ switch (control.datePickerSetting.type) {
287
+ case 'TODAY':
288
+ value = [dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZ'), dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZ')]
289
+ break
290
+ case 'THIS_MONTH':
291
+ value = [
292
+ dayjs().startOf('month').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
293
+ dayjs().endOf('month').format('YYYY-MM-DDTHH:mm:ss.SSSZ')
294
+ ]
295
+ break
296
+ case 'THIS_YEAR':
297
+ value = [
298
+ dayjs().startOf('year').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
299
+ dayjs().endOf('year').format('YYYY-MM-DDTHH:mm:ss.SSSZ')
300
+ ]
301
+ break
302
+ case 'LAST_10_DAYS':
303
+ value = [
304
+ dayjs().subtract(10, 'day').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
305
+ dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZ')
306
+ ]
307
+ break
308
+ case 'LAST_30_DAYS':
309
+ value = [
310
+ dayjs().subtract(30, 'day').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
311
+ dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZ')
312
+ ]
313
+ break
314
+ case 'LAST_12_MONTH':
315
+ value = [
316
+ dayjs().subtract(12, 'month').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
317
+ dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZ')
318
+ ]
319
+ break
320
+ case 'LAST_5_YEAR':
321
+ value = [
322
+ dayjs().subtract(5, 'year').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
323
+ dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZ')
324
+ ]
325
+ break
326
+ case 'LAST_60_SECONDS':
327
+ value = [dayjs().subtract(60, 'second').toISOString(), dayjs().toISOString()]
328
+ break
329
+ case 'LAST_30_MINUTES':
330
+ value = [dayjs().subtract(30, 'minute').toISOString(), dayjs().toISOString()]
331
+ break
332
+ case 'LAST_24_HOURS':
333
+ value = [dayjs().subtract(24, 'hour').toISOString(), dayjs().toISOString()]
334
+ break
335
+ case 'CURRENT_MONDAY_TO_TODAY':
336
+ value = [
337
+ dayjs().startOf('week').add(1, 'day').format('YYYY-MM-DDTHH:mm:ss.SSSZ'), // 周一
338
+ dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZ')
339
+ ]
340
+ break
341
+ case 'YESTERDAY':
342
+ value = [
343
+ dayjs().subtract(1, 'day').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
344
+ dayjs().subtract(1, 'day').format('YYYY-MM-DDTHH:mm:ss.SSSZ')
345
+ ]
346
+ break
347
+ case 'LAST_YEAR':
348
+ value = [
349
+ dayjs().subtract(1, 'year').startOf('year').format('YYYY-MM-DDTHH:mm:ss.SSSZ'),
350
+ dayjs().subtract(1, 'year').endOf('year').format('YYYY-MM-DDTHH:mm:ss.SSSZ')
351
+ ]
352
+ break
353
+ case 'ABSOLUTE':
354
+ value = [control.datePickerSetting.timeRange.from, control.datePickerSetting.timeRange.to] // 用户指定区间,不设置默认值
355
+ break
356
+ default:
357
+ value = []
358
+ break
359
+ }
360
+ this.searchParams[`ranges.${setting.code}`] = value
361
+
236
362
  this.searchOptions.push({
237
363
  label: control.name,
238
364
  prop: `ranges.${setting.code}`,
239
365
  renderType: 'dateRange',
366
+ value,
240
367
  valueFormat: 'YYYY-MM-DDTHH:mm:ss.SSSZ'
241
368
  })
242
369
  this.globalFilter.ranges[setting.code] = {
@@ -1,43 +1,39 @@
1
1
  <template>
2
2
  <!-- 动态组件 -->
3
- <component :is="componentMap[item.component]"
4
- v-model="defaultValue"
5
- @change="handleChange"
6
- :size="size"
7
- :disabled="disabled"
8
- v-bind="getComponentProps(item)">
3
+ <component
4
+ :is="componentMap[item.component]"
5
+ v-model="defaultValue"
6
+ @change="handleChange"
7
+ :size="size"
8
+ :disabled="disabled"
9
+ v-bind="getComponentProps(item)">
9
10
  <!-- 处理组件插槽 -->
10
11
  <template v-if="item.component === 'select'">
11
- <el-option v-for="option in item.options.items"
12
- :key="option.value"
13
- :disabled="option.disabled"
14
- :label="option.label"
15
- :value="option.value" />
12
+ <el-option
13
+ v-for="option in item.options.items"
14
+ :key="option.value"
15
+ :disabled="option.disabled"
16
+ :label="option.label"
17
+ :value="option.value" />
16
18
  </template>
17
19
  <template v-if="item.component === 'checkboxGroup'">
18
- <el-checkbox v-for="_item in item.options.items"
19
- :key="_item.value"
20
- :label="_item.value">{{_item.label}}</el-checkbox>
20
+ <el-checkbox v-for="_item in item.options.items" :key="_item.value" :label="_item.value">{{
21
+ _item.label
22
+ }}</el-checkbox>
21
23
  </template>
22
24
  <template v-if="item.component === 'radio'">
23
- <el-radio v-for="_item in item.options.items"
24
- :key="_item.value"
25
- :label="_item.value">{{_item.label}}</el-radio>
25
+ <el-radio v-for="_item in item.options.items" :key="_item.value" :label="_item.value">{{ _item.label }}</el-radio>
26
26
  </template>
27
- <template v-if="item.component === 'number' && item?.options?.suffix"
28
- #suffix>
27
+ <template v-if="item.component === 'number' && item?.options?.suffix" #suffix>
29
28
  {{ item.options.suffix }}
30
29
  </template>
31
- <template v-if="item.component === 'input' && item?.options?.prepend"
32
- #prepend>
30
+ <template v-if="item.component === 'input' && item?.options?.prepend" #prepend>
33
31
  {{ item.options.prepend }}
34
32
  </template>
35
- <template v-if="item.component === 'input' && item?.options?.append"
36
- #append>
33
+ <template v-if="item.component === 'input' && item?.options?.append" #append>
37
34
  {{ item.options.append }}
38
35
  </template>
39
36
  </component>
40
-
41
37
  </template>
42
38
 
43
39
  <script>
@@ -123,7 +119,7 @@ export default {
123
119
  // 获取组件属性
124
120
  getComponentProps(item) {
125
121
  let propsItem = {}
126
- const {type, startPlaceholder, endPlaceholder, controlsPosition, items, ...options} = item?.options || {}
122
+ const { type, startPlaceholder, endPlaceholder, controlsPosition, items, ...options } = item?.options || {}
127
123
  if (item?.options) {
128
124
  // 通用属性
129
125
  propsItem.placeholder = item.options.placeholder || ''
@@ -173,4 +169,4 @@ export default {
173
169
  }
174
170
  }
175
171
  }
176
- </script>
172
+ </script>
@@ -180,11 +180,10 @@ export default {
180
180
  // 用来兼容旧配置
181
181
  defaultOptions() {
182
182
  return this.options.map((item) => {
183
- const { label, span, prop: name, renderType: component, placeholder = label, ...other } = item || {}
184
- const componentObj = { label, name, component, span }
183
+ const { label, value, span, prop: name, renderType: component, placeholder = label, ...other } = item || {}
184
+ const componentObj = { label, name, value, component, span }
185
185
 
186
186
  const baseOptions = { placeholder, ...other }
187
-
188
187
  switch (component) {
189
188
  case 'dateRange':
190
189
  return {