haiwei-ui 1.3.1 → 1.3.2

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.
@@ -279,6 +279,8 @@ export default {
279
279
  }
280
280
  this.loading_ = true
281
281
  let fullModel = Object.assign({}, this.model)
282
+ // 新增:检查并设置默认排序(在执行查询前(2026-03-23新增))
283
+ this.checkAndSetDefaultSort()
282
284
  // 设置分页
283
285
  fullModel.page = this.page
284
286
  this.action(fullModel)
@@ -337,11 +339,13 @@ export default {
337
339
  /** 刷新 */
338
340
  refresh(goFirst) {
339
341
  if (goFirst) this.page.index = 1
342
+ // 新增:检查并设置默认排序(在执行查询前(2026-03-23新增))
343
+ this.checkAndSetDefaultSort()
340
344
  this.query()
341
345
  },
342
346
  /** 查询表单重置 */
343
347
  reset() {
344
- this.$refs.querybar.reset()
348
+ this.$refs.querybar.reset()
345
349
  },
346
350
  /** 获取序号 */
347
351
  getNo(index) {
@@ -441,6 +445,8 @@ export default {
441
445
  /** 查询栏重置事件 */
442
446
  onQueryBarReset() {
443
447
  this.$refs.table.clearSort()
448
+ // 重置后清空排序,让下次查询时重新应用默认排序 2026-03-23新增
449
+ this.page.sort = []
444
450
  this.$emit('reset')
445
451
  },
446
452
  /** 删除行 */
@@ -482,26 +488,26 @@ export default {
482
488
  /** 递归选择所有树形节点 */
483
489
  selectAllTreeNodes(nodes, selection) {
484
490
  if (!nodes || !Array.isArray(nodes)) return
485
-
491
+
486
492
  nodes.forEach(node => {
487
493
  // 获取行键值
488
494
  const rowKeyValue = typeof this.rowKey === 'function' ? this.rowKey(node) : node[this.rowKey]
489
-
495
+
490
496
  // 检查是否已经选择
491
497
  const isSelected = selection.some(s => {
492
498
  const selectedKey = typeof this.rowKey === 'function' ? this.rowKey(s) : s[this.rowKey]
493
499
  return selectedKey === rowKeyValue
494
500
  })
495
-
501
+
496
502
  if (!isSelected) {
497
503
  selection.push(node)
498
-
504
+
499
505
  // 更新表格UI选择状态
500
506
  if (this.$refs.table && this.$refs.table.toggleRowSelection) {
501
507
  this.$refs.table.toggleRowSelection(node, true)
502
508
  }
503
509
  }
504
-
510
+
505
511
  // 递归处理子节点
506
512
  if (this.treeProps && this.treeProps.children) {
507
513
  const children = node[this.treeProps.children]
@@ -515,26 +521,26 @@ export default {
515
521
  /** 递归取消选择所有树形节点 */
516
522
  deselectAllTreeNodes(nodes, selection) {
517
523
  if (!nodes || !Array.isArray(nodes)) return
518
-
524
+
519
525
  nodes.forEach(node => {
520
526
  // 获取行键值
521
527
  const rowKeyValue = typeof this.rowKey === 'function' ? this.rowKey(node) : node[this.rowKey]
522
-
528
+
523
529
  // 从选择中移除当前节点
524
530
  const selectedIndex = selection.findIndex(s => {
525
531
  const selectedKey = typeof this.rowKey === 'function' ? this.rowKey(s) : s[this.rowKey]
526
532
  return selectedKey === rowKeyValue
527
533
  })
528
-
534
+
529
535
  if (selectedIndex > -1) {
530
536
  selection.splice(selectedIndex, 1)
531
-
537
+
532
538
  // 更新表格UI选择状态
533
539
  if (this.$refs.table && this.$refs.table.toggleRowSelection) {
534
540
  this.$refs.table.toggleRowSelection(node, false)
535
541
  }
536
542
  }
537
-
543
+
538
544
  // 递归处理子节点
539
545
  if (this.treeProps && this.treeProps.children) {
540
546
  const children = node[this.treeProps.children]
@@ -549,21 +555,50 @@ export default {
549
555
  isTreeSelectAllEnabled() {
550
556
  const treeSelectAllOptions = this.$_.assignIn({}, def.treeSelectAllOptions, this.treeSelectAll)
551
557
  const enabled = treeSelectAllOptions.enabled
552
-
558
+
553
559
  // 检查是否启用树形全选:需要同时满足以下条件:
554
560
  // 1. treeSelectAll.enabled 为 true
555
561
  // 2. treeProps 存在
556
562
  // 3. treeProps.children 存在(可以是任何值,只要存在就行)
557
563
  const hasTreeProps = !!this.treeProps
558
564
  const hasChildrenProp = hasTreeProps && this.treeProps.children !== undefined && this.treeProps.children !== null
559
-
565
+
560
566
  return enabled && hasTreeProps && hasChildrenProp
561
567
  },
562
568
 
563
569
  /** 获取选中的记录 */
564
570
  getSelection() {
565
571
  return this.selection
566
- }
572
+ },
573
+ /** 检查并设置默认排序(2026-03-23添加默认排序功能) */
574
+ checkAndSetDefaultSort() {
575
+ // 只有在sort数组为空时才设置默认排序
576
+ if (!this.page.sort || this.page.sort.length === 0) {
577
+ // 查找有默认排序配置的列
578
+ const defaultSortCol = this.columns.find(col => col.defaultSort && col.sortable)
579
+ if (defaultSortCol) {
580
+ // 解析排序方向,支持多种格式:asc/ascending, desc/descending
581
+ const sortDirection = defaultSortCol.defaultSort.toLowerCase()
582
+ let sortType = 0 // 默认升序
583
+ if (sortDirection === 'desc' || sortDirection === 'descending') {
584
+ sortType = 1 // 降序
585
+ } else if (sortDirection === 'asc' || sortDirection === 'ascending') {
586
+ sortType = 0 // 升序
587
+ } else {
588
+ // 如果是不认识的排序方向,默认使用升序
589
+ console.warn(`未知的排序方向: ${defaultSortCol.defaultSort},使用默认升序`)
590
+ sortType = 0
591
+ }
592
+ // 设置默认排序
593
+ this.page.sort = [
594
+ {
595
+ field: defaultSortCol.name,
596
+ type: sortType
597
+ }
598
+ ]
599
+ }
600
+ }
601
+ },
567
602
  },
568
603
  mounted() {
569
604
  this.$nextTick(() => {
@@ -1,10 +1,12 @@
1
1
  <template>
2
2
  <section class="nm-map-search-box" v-loading="loading">
3
- <el-input v-model="keyword" class="nm-map-search-input" size="small" placeholder="请输入关键字" prefix-icon="el-icon-search" clearable></el-input>
3
+ <el-input v-model="keyword" class="nm-map-search-input" size="small" placeholder="请输入关键字"
4
+ prefix-icon="el-icon-search" clearable></el-input>
4
5
  <div class="nm-map-search-list">
5
6
  <el-scrollbar>
6
7
  <ul v-if="data.length > 0" class="nm-map-search-list-box">
7
- <li v-for="(item, i) in data" :key="i" :class="['nm-map-search-list-item', active === i ? 'active' : '']" @click="onSelect(item, i)">
8
+ <li v-for="(item, i) in data" :key="i" :class="['nm-map-search-list-item', active === i ? 'active' : '']"
9
+ @click="onSelect(item, i)">
8
10
  <div class="title">
9
11
  <i class="el-icon-location-information" />
10
12
  {{ item.title }}
@@ -19,83 +21,83 @@
19
21
  </section>
20
22
  </template>
21
23
  <script>
22
- export default {
23
- name: 'MapSearch',
24
- data() {
25
- return {
26
- /**关键字 */
27
- keyword: '',
28
- /**搜索实例 */
29
- local: null,
30
- /**定时器 */
31
- timer: null,
32
- /**数据 */
33
- data: [],
34
- /**显示加载动画 */
35
- loading: false,
36
- /**已选择的 */
37
- active: ''
38
- }
24
+ export default {
25
+ name: 'MapSearch',
26
+ data() {
27
+ return {
28
+ /**关键字 */
29
+ keyword: '',
30
+ /**搜索实例 */
31
+ local: null,
32
+ /**定时器 */
33
+ timer: null,
34
+ /**数据 */
35
+ data: [],
36
+ /**显示加载动画 */
37
+ loading: false,
38
+ /**已选择的 */
39
+ active: ''
40
+ }
41
+ },
42
+ props: {
43
+ /**查询延时,默认800ms */
44
+ delay: {
45
+ type: Number,
46
+ default: 700
39
47
  },
40
- props: {
41
- /**查询延时,默认800ms */
42
- delay: {
43
- type: Number,
44
- default: 700
45
- },
46
- /**保留小数位精度 */
47
- precision: {
48
- type: Number,
49
- default: 4
50
- },
51
- /**查询时每页数量,默认15 */
52
- searchPageCapacity: {
53
- type: Number,
54
- default: 15
55
- }
48
+ /**保留小数位精度 */
49
+ precision: {
50
+ type: Number,
51
+ default: 4
56
52
  },
57
- methods: {
58
- init(map) {
59
- this.local = new BMap.LocalSearch(map, { searchPageCapacity: this.searchPageCapacity, onSearchComplete: this.onSearchComplete })
60
- },
61
- search() {
62
- //删除定时器
63
- clearTimeout(this.timer)
64
-
65
- this.timer = setTimeout(() => {
66
- this.data = []
67
- if (this.keyword) {
68
- this.loading = true
69
- this.local.search(this.keyword)
70
- }
71
- }, this.delay)
72
- },
73
- onSearchComplete(results) {
74
- this.loading = false
75
- if (this.local.getStatus() == BMAP_STATUS_SUCCESS) {
76
- this.data = results.Sq.map(m => {
77
- return { title: m.title, address: m.address, point: m.point }
78
- })
79
- } else {
80
- this.$message.error('查询失败~')
81
- }
53
+ /**查询时每页数量,默认15 */
54
+ searchPageCapacity: {
55
+ type: Number,
56
+ default: 15
57
+ }
58
+ },
59
+ methods: {
60
+ init(map) {
61
+ this.local = new BMap.LocalSearch(map, { searchPageCapacity: this.searchPageCapacity, onSearchComplete: this.onSearchComplete })
62
+ },
63
+ search() {
64
+ //删除定时器
65
+ clearTimeout(this.timer)
82
66
 
83
- this.$emit('search', this.data)
84
- },
85
- onSelect(item, i) {
86
- this.active = i
87
- this.$emit('select', item.point, item)
88
- },
89
- reset() {
90
- this.active = ''
91
- this.keyword = ''
67
+ this.timer = setTimeout(() => {
92
68
  this.data = []
93
- }
69
+ if (this.keyword) {
70
+ this.loading = true
71
+ this.local.search(this.keyword)
72
+ }
73
+ }, this.delay)
94
74
  },
95
- watch: {
96
- keyword() {
97
- this.search()
75
+ onSearchComplete(results) {
76
+ this.loading = false
77
+ if (this.local.getStatus() == BMAP_STATUS_SUCCESS) {
78
+ this.data = results.Sq.map(m => {
79
+ return { title: m.title, address: m.address, point: m.point }
80
+ })
81
+ } else {
82
+ this.$message.error('查询失败~')
98
83
  }
84
+
85
+ this.$emit('search', this.data)
86
+ },
87
+ onSelect(item, i) {
88
+ this.active = i
89
+ this.$emit('select', item.point, item)
90
+ },
91
+ reset() {
92
+ this.active = ''
93
+ this.keyword = ''
94
+ this.data = []
95
+ }
96
+ },
97
+ watch: {
98
+ keyword() {
99
+ this.search()
99
100
  }
100
101
  }
102
+ }
101
103
  </script>
@@ -9,40 +9,40 @@
9
9
  </section>
10
10
  </template>
11
11
  <script>
12
- export default {
13
- name: 'Tabs',
14
- data() {
15
- return {
16
- fullscreen_: false
17
- }
12
+ export default {
13
+ name: 'Tabs',
14
+ data() {
15
+ return {
16
+ fullscreen_: false
17
+ }
18
+ },
19
+ props: {
20
+ fullscreen: {
21
+ type: Boolean,
22
+ default: true
23
+ }
24
+ },
25
+ methods: {
26
+ /** 开启全屏 */
27
+ openFullscreen() {
28
+ this.fullscreen_ = true
29
+ // 全屏事件
30
+ this.$emit('fullscreen-change', this.fullscreen_)
18
31
  },
19
- props: {
20
- fullscreen: {
21
- type: Boolean,
22
- default: true
23
- }
32
+ /** 关闭全屏 */
33
+ closeFullscreen() {
34
+ this.fullscreen_ = false
35
+ // 全屏事件
36
+ this.$emit('fullscreen-change', this.fullscreen_)
24
37
  },
25
- methods: {
26
- /** 开启全屏 */
27
- openFullscreen() {
28
- this.fullscreen_ = true
29
- // 全屏事件
30
- this.$emit('fullscreen-change', this.fullscreen_)
31
- },
32
- /** 关闭全屏 */
33
- closeFullscreen() {
34
- this.fullscreen_ = false
35
- // 全屏事件
36
- this.$emit('fullscreen-change', this.fullscreen_)
37
- },
38
- /** 全屏事件 */
39
- onFullscreen() {
40
- if (this.fullscreen_) {
41
- this.closeFullscreen()
42
- } else {
43
- this.openFullscreen()
44
- }
38
+ /** 全屏事件 */
39
+ onFullscreen() {
40
+ if (this.fullscreen_) {
41
+ this.closeFullscreen()
42
+ } else {
43
+ this.openFullscreen()
45
44
  }
46
45
  }
47
46
  }
47
+ }
48
48
  </script>
@@ -2,7 +2,8 @@
2
2
  <nm-drawer class="nm-skin-toggle" v-bind="deawer" :visible.sync="visible_" v-on="on">
3
3
  <el-divider>皮肤</el-divider>
4
4
  <section class="skin-list">
5
- <div v-for="item in list" :key="item.code" :class="['skin-list-item', model.name === item.code ? 'active' : '']" @click="onSkinChange(item)">
5
+ <div v-for="item in list" :key="item.code" :class="['skin-list-item', model.name === item.code ? 'active' : '']"
6
+ @click="onSkinChange(item)">
6
7
  <div class="img">
7
8
  <img :src="item.preview" />
8
9
  </div>
@@ -18,7 +19,8 @@
18
19
  </section>
19
20
  <el-divider>主题</el-divider>
20
21
  <section class="theme-list">
21
- <div :class="['theme-list-item', model.theme === item.name ? 'active' : '']" v-for="item in themes" :key="item.name" :style="{ backgroundColor: item.color }" @click="onThemeChange(item)"></div>
22
+ <div :class="['theme-list-item', model.theme === item.name ? 'active' : '']" v-for="item in themes"
23
+ :key="item.name" :style="{ backgroundColor: item.color }" @click="onThemeChange(item)"></div>
22
24
  </section>
23
25
  <el-divider>字号</el-divider>
24
26
  <section class="fontsize-list">
@@ -34,67 +36,67 @@
34
36
  </nm-drawer>
35
37
  </template>
36
38
  <script>
37
- import drawer from '../../../../mixins/components/drawer'
38
- import { mapState, mapMutations } from 'vuex'
39
- export default {
40
- mixins: [drawer],
41
- data() {
42
- return {
43
- deawer: {
44
- header: true,
45
- footer: true,
46
- title: '皮肤设置',
47
- icon: 'skin',
48
- width: '650px',
49
- fullscreen: false,
50
- modal: false
51
- },
52
- model: {
53
- name: '',
54
- theme: '',
55
- fontSize: ''
56
- },
57
- on: {
58
- success: this.onSuccess,
59
- open: this.onOpen
60
- }
61
- }
62
- },
63
- computed: {
64
- ...mapState('app/system', { saveSkin: s => s.actions.saveSkin }),
65
- ...mapState('app/skins', ['current', 'list']),
66
- currSkin() {
67
- return this.list.find(m => m.code === this.model.name)
39
+ import drawer from '../../../../mixins/components/drawer'
40
+ import { mapState, mapMutations } from 'vuex'
41
+ export default {
42
+ mixins: [drawer],
43
+ data() {
44
+ return {
45
+ deawer: {
46
+ header: true,
47
+ footer: true,
48
+ title: '皮肤设置',
49
+ icon: 'skin',
50
+ width: '650px',
51
+ fullscreen: false,
52
+ modal: false
68
53
  },
69
- themes() {
70
- return this.currSkin ? this.currSkin.themes : []
54
+ model: {
55
+ name: '',
56
+ theme: '',
57
+ fontSize: ''
58
+ },
59
+ on: {
60
+ success: this.onSuccess,
61
+ open: this.onOpen
71
62
  }
63
+ }
64
+ },
65
+ computed: {
66
+ ...mapState('app/system', { saveSkin: s => s.actions.saveSkin }),
67
+ ...mapState('app/skins', ['current', 'list']),
68
+ currSkin() {
69
+ return this.list.find(m => m.code === this.model.name)
72
70
  },
73
- methods: {
74
- ...mapMutations('app/skins', ['toggle', 'init']),
75
- onSuccess() {
76
- this.$emit('success')
77
- },
78
- onOpen() {
79
- this.model = {
80
- name: this.current.name,
81
- theme: this.current.theme,
82
- fontSize: this.current.fontSize || 'default'
83
- }
84
- },
85
- onSkinChange(skin) {
86
- this.model.name = skin.code
87
- this.model.theme = skin.themes[0].name
88
- this.model.fontSize = 'default'
89
- },
90
- onThemeChange(theme) {
91
- this.model.theme = theme.name
92
- },
93
- onSave() {
94
- this.saveSkin(this.model).then(() => {
95
- this.init(this.model)
96
- })
71
+ themes() {
72
+ return this.currSkin ? this.currSkin.themes : []
73
+ }
74
+ },
75
+ methods: {
76
+ ...mapMutations('app/skins', ['toggle', 'init']),
77
+ onSuccess() {
78
+ this.$emit('success')
79
+ },
80
+ onOpen() {
81
+ this.model = {
82
+ name: this.current.name,
83
+ theme: this.current.theme,
84
+ fontSize: this.current.fontSize || 'default'
97
85
  }
86
+ },
87
+ onSkinChange(skin) {
88
+ this.model.name = skin.code
89
+ this.model.theme = skin.themes[0].name
90
+ this.model.fontSize = 'default'
91
+ },
92
+ onThemeChange(theme) {
93
+ this.model.theme = theme.name
94
+ },
95
+ onSave() {
96
+ this.saveSkin(this.model).then(() => {
97
+ this.init(this.model)
98
+ })
98
99
  }
99
100
  }
101
+ }
100
102
  </script>