hbte-saas-ui 0.0.2 → 1.0.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.
Files changed (132) hide show
  1. package/README.md +8 -1
  2. package/lib/hbte-ui.common.js +31 -10
  3. package/lib/hbte-ui.umd.js +31 -10
  4. package/lib/hbte-ui.umd.min.js +1 -1
  5. package/package.json +8 -2
  6. package/.browserslistrc +0 -3
  7. package/.editorconfig +0 -7
  8. package/.env.development +0 -1
  9. package/.env.lib +0 -1
  10. package/.eslintrc.js +0 -14
  11. package/.prettierrc +0 -3
  12. package/babel.config.js +0 -3
  13. package/docs/.vuepress/config.js +0 -23
  14. package/docs/.vuepress/styles/index.styl +0 -4
  15. package/docs/AdvQuery.md +0 -26
  16. package/docs/CustomQuery.md +0 -21
  17. package/docs/EditArea.md +0 -16
  18. package/docs/FilterDrop.md +0 -29
  19. package/docs/FullTable.md +0 -68
  20. package/docs/Pagination.md +0 -22
  21. package/docs/QueryForm.md +0 -27
  22. package/docs/README.md +0 -17
  23. package/docs/Table.md +0 -58
  24. package/docs/ToolGroup.md +0 -32
  25. package/examples/App.vue +0 -97
  26. package/examples/image/hb-image-viewer/3k.jpg +0 -0
  27. package/examples/image/hb-image-viewer/a.jpg +0 -0
  28. package/examples/image/hb-image-viewer/b.jpg +0 -0
  29. package/examples/main.js +0 -39
  30. package/examples/mock/authority.js +0 -1108
  31. package/examples/mock/dept.js +0 -4001
  32. package/examples/mock/fulltable.js +0 -407
  33. package/examples/mock/organizeData.js +0 -18965
  34. package/examples/router/index.js +0 -111
  35. package/examples/views/ElementCpTest.vue +0 -299
  36. package/examples/views/Fragment.vue +0 -196
  37. package/examples/views/HBAdvQuery.vue +0 -150
  38. package/examples/views/HBAuthority.vue +0 -339
  39. package/examples/views/HBDialog.vue +0 -39
  40. package/examples/views/HBEditarea.vue +0 -350
  41. package/examples/views/HBFilterDrop.vue +0 -72
  42. package/examples/views/HBFloatFooter.vue +0 -42
  43. package/examples/views/HBFullTable.vue +0 -751
  44. package/examples/views/HBImageViewer.vue +0 -57
  45. package/examples/views/HBNavMenu.vue +0 -37
  46. package/examples/views/HBOrganizeDialog.vue +0 -133
  47. package/examples/views/HBPagination.vue +0 -80
  48. package/examples/views/HBSelectVague.vue +0 -57
  49. package/examples/views/HBToolgroup.vue +0 -29
  50. package/examples/views/HBTopBar.vue +0 -16
  51. package/packages/adv-query/index.js +0 -5
  52. package/packages/adv-query/src/main.vue +0 -294
  53. package/packages/area-select/index.js +0 -7
  54. package/packages/area-select/src/main.vue +0 -37
  55. package/packages/authority/index.js +0 -5
  56. package/packages/authority/src/main.vue +0 -606
  57. package/packages/config.js +0 -3
  58. package/packages/custom-query/index.js +0 -5
  59. package/packages/custom-query/src/main.vue +0 -80
  60. package/packages/dialog/index.js +0 -7
  61. package/packages/dialog/src/main.vue +0 -176
  62. package/packages/edit-area/index.js +0 -13
  63. package/packages/edit-area/src/config.js +0 -3
  64. package/packages/edit-area/src/main.vue +0 -304
  65. package/packages/edit-area/src/simulateEvent.js +0 -219
  66. package/packages/filter-drop/index.js +0 -6
  67. package/packages/filter-drop/src/main.vue +0 -107
  68. package/packages/float-footer/index.js +0 -7
  69. package/packages/float-footer/src/main.vue +0 -40
  70. package/packages/fragment/index.js +0 -7
  71. package/packages/fragment/src/main.vue +0 -74
  72. package/packages/fragment/src/old.vue +0 -144
  73. package/packages/full-table/index.js +0 -6
  74. package/packages/full-table/src/config.js +0 -14
  75. package/packages/full-table/src/main.vue +0 -141
  76. package/packages/image-viewer/index.js +0 -8
  77. package/packages/image-viewer/src/main.js +0 -14
  78. package/packages/image-viewer/src/main.vue +0 -138
  79. package/packages/image-viewer/src/svg/cancel.svg +0 -2
  80. package/packages/image-viewer/src/svg/delete.svg +0 -2
  81. package/packages/image-viewer/src/svg/download.svg +0 -2
  82. package/packages/image-viewer/src/svg/rotate.svg +0 -77
  83. package/packages/image-viewer/src/svg/scaledown.svg +0 -71
  84. package/packages/image-viewer/src/svg/scaleup.svg +0 -72
  85. package/packages/index.js +0 -43
  86. package/packages/nav-menu/index.js +0 -7
  87. package/packages/nav-menu/src/main.vue +0 -277
  88. package/packages/organize-dialog/index.js +0 -5
  89. package/packages/organize-dialog/src/main.vue +0 -427
  90. package/packages/pagination/index.js +0 -6
  91. package/packages/pagination/src/main.vue +0 -146
  92. package/packages/query-form/index.js +0 -5
  93. package/packages/query-form/src/main.vue +0 -142
  94. package/packages/select-vague/index.js +0 -5
  95. package/packages/select-vague/src/main.vue +0 -80
  96. package/packages/table/index.js +0 -5
  97. package/packages/table/src/main.vue +0 -265
  98. package/packages/theme-chalk/adv-query.scss +0 -107
  99. package/packages/theme-chalk/authority.scss +0 -103
  100. package/packages/theme-chalk/common/elementCover.scss +0 -722
  101. package/packages/theme-chalk/common/flex.scss +0 -66
  102. package/packages/theme-chalk/common/global.scss +0 -147
  103. package/packages/theme-chalk/common/reset.scss +0 -92
  104. package/packages/theme-chalk/common/var.scss +0 -46
  105. package/packages/theme-chalk/custom-query.scss +0 -10
  106. package/packages/theme-chalk/dialog.scss +0 -9
  107. package/packages/theme-chalk/edit-area.scss +0 -119
  108. package/packages/theme-chalk/filter-drop.scss +0 -81
  109. package/packages/theme-chalk/float-footer.scss +0 -14
  110. package/packages/theme-chalk/fonts/iconfont.ttf +0 -0
  111. package/packages/theme-chalk/fragment.scss +0 -51
  112. package/packages/theme-chalk/full-table.scss +0 -40
  113. package/packages/theme-chalk/icon.scss +0 -96
  114. package/packages/theme-chalk/image-viewer.scss +0 -94
  115. package/packages/theme-chalk/images/company-logo--default.png +0 -0
  116. package/packages/theme-chalk/images/nodata.png +0 -0
  117. package/packages/theme-chalk/images/user-logo--default.png +0 -0
  118. package/packages/theme-chalk/index.scss +0 -21
  119. package/packages/theme-chalk/nav-menu.scss +0 -205
  120. package/packages/theme-chalk/organize-dialog.scss +0 -170
  121. package/packages/theme-chalk/pagination.scss +0 -91
  122. package/packages/theme-chalk/select.scss +0 -8
  123. package/packages/theme-chalk/table.scss +0 -102
  124. package/packages/theme-chalk/tool-group.scss +0 -105
  125. package/packages/theme-chalk/top-bar.scss +0 -195
  126. package/packages/tool-group/index.js +0 -13
  127. package/packages/tool-group/src/config.js +0 -40
  128. package/packages/tool-group/src/main.vue +0 -93
  129. package/packages/top-bar/index.js +0 -7
  130. package/packages/top-bar/src/main.vue +0 -280
  131. package/public/index.html +0 -20
  132. package/vue.config.js +0 -6
@@ -1,6 +0,0 @@
1
- import HbPagination from "./src/main.vue";
2
- HbPagination.install = function (Vue) {
3
- Vue.component(HbPagination.name, HbPagination);
4
- };
5
-
6
- export default HbPagination;
@@ -1,146 +0,0 @@
1
- <template>
2
- <div class="hb-pagination">
3
- <span>~</span>
4
- <el-pagination
5
- v-if="pageData"
6
- background
7
- @size-change="handleSizeChange"
8
- @current-change="handleCurrentChange"
9
- :current-page="pageData.pageNum"
10
- :page-sizes="pageSizes"
11
- :page-size="pageData.pageSize"
12
- layout="total, sizes, prev, slot"
13
- :total="total"
14
- >
15
- <div class="hb-pagination-slot">
16
- <div slot="input">
17
- <span class="hb-pagination-slot_text">第</span>
18
- <el-input
19
- @input="handleCurrentInput"
20
- @blur="handleCurrentBlur"
21
- class="hb-pagination-slot_input"
22
- v-model="pageData.pageNum"
23
- :clearable="false"
24
- ></el-input>
25
- <span class="hb-pagination-slot_text">共{{ pageNumber }}页</span>
26
- </div>
27
- </div>
28
- </el-pagination>
29
- <el-pagination
30
- v-if="pageData"
31
- background
32
- @size-change="handleSizeChange"
33
- @current-change="handleCurrentChange"
34
- :current-page="pageData.pageNum"
35
- :page-sizes="pageSizes"
36
- :page-size="pageData.pageSize"
37
- layout="next, slot"
38
- :total="total"
39
- >
40
- <hb-filterdrop
41
- v-if="showFilter"
42
- :columns="columns"
43
- :placement="placement"
44
- :disabledFilter="disabledFilter"
45
- @columnsChange="columnsChange"
46
- v-bind="$attrs"
47
- >
48
- <i
49
- slot="dropdown"
50
- class="hb-pagination__dropdown-icon el-icon-s-operation"
51
- ></i>
52
- </hb-filterdrop>
53
- </el-pagination>
54
- </div>
55
- </template>
56
- <script>
57
- export default {
58
- name: "hbPagination",
59
- cpName: "hbPagination",
60
- props: {
61
- pageData: {
62
- type: Object,
63
- default: () => ({
64
- pageSize: 50,
65
- pageNum: 1,
66
- total: 0,
67
- }),
68
- },
69
- pageSizes: {
70
- type: Array,
71
- default: () => [5, 30, 50],
72
- },
73
- showFilter: {
74
- type: Boolean,
75
- default: true,
76
- },
77
- columns: {
78
- type: Array,
79
- default: () => [],
80
- },
81
- placement: {
82
- type: String,
83
- default: "bottom-end",
84
- },
85
- disabledFilter: {
86
- type: Boolean,
87
- default: false,
88
- },
89
- },
90
- data() {
91
- return {};
92
- },
93
- computed: {
94
- total() {
95
- const { total } = this.pageData;
96
- return typeof total === "number" ? total : total ? Number(total) : 0;
97
- },
98
- pageNumber() {
99
- return Math.ceil(this.pageData.total / this.pageData.pageSize);
100
- },
101
- },
102
- methods: {
103
- /**
104
- * @event handleSizeChange 切换每页数量
105
- */
106
- handleSizeChange(num) {
107
- // 每页条数改变时,建议重置当前的页码
108
- this.$emit("pageSizeChange", num);
109
- },
110
- /**
111
- * @event handleCurrentChange 切换页码
112
- */
113
- handleCurrentChange(num) {
114
- this.$emit("pageNumChange", num);
115
- },
116
- /**
117
- * @event handleCurrentInput 自定义翻页页码输入时
118
- */
119
- handleCurrentInput() {
120
- // 处理输入格式
121
- if (isNaN(this.pageData.pageNum)) {
122
- this.pageData.pageNum = 1;
123
- } else {
124
- this.pageData.pageNum = Number(this.pageData.pageNum);
125
- }
126
- },
127
- /**
128
- * @event handleCurrentBlur 自定义翻页页码失焦触发翻页
129
- */
130
- handleCurrentBlur() {
131
- let currentPage = 1;
132
- if (this.pageData.pageNum > this.pageNumber) {
133
- currentPage = this.pageNumber;
134
- } else if (this.pageData.pageNum <= 0) {
135
- currentPage = 1;
136
- } else {
137
- currentPage = this.pageData.pageNum;
138
- }
139
- this.handleCurrentChange(currentPage);
140
- },
141
- columnsChange(newColumns) {
142
- this.$emit("columnsChange", newColumns);
143
- },
144
- },
145
- };
146
- </script>
@@ -1,5 +0,0 @@
1
- import HbQueryForm from "./src/main.vue";
2
- HbQueryForm.install = function (Vue) {
3
- Vue.component(HbQueryForm.name, HbQueryForm);
4
- };
5
- export default HbQueryForm;
@@ -1,142 +0,0 @@
1
- <template>
2
- <div class="hb-queryform">
3
- <template v-if="formProp.type === 'input'">
4
- <el-input
5
- clearable
6
- :type="formProp.type"
7
- :placeholder="formProp.placeholder"
8
- v-model="qryFormData[formProp.prop]"
9
- :size="size"
10
- v-on="$listeners"
11
- v-bind="$attrs"
12
- style="width: 100%"
13
- ></el-input>
14
- </template>
15
- <template v-if="formProp.type === 'select'">
16
- <el-select
17
- clearable
18
- :size="size"
19
- v-model="qryFormData[formProp.prop]"
20
- :placeholder="formProp.placeholder"
21
- :multiple="formProp.multiple"
22
- collapse-tags
23
- :filterable="formProp.filterable"
24
- v-on="$listeners"
25
- v-bind="$attrs"
26
- style="width: 100%"
27
- >
28
- <el-option
29
- v-for="(item, index) in formProp.optList"
30
- :key="index"
31
- :label="
32
- formProp.optListProp ? item[formProp.optListProp.label] : item.label
33
- "
34
- :value="
35
- formProp.optListProp ? item[formProp.optListProp.value] : item.value
36
- "
37
- ></el-option>
38
- </el-select>
39
- </template>
40
- <template v-if="formProp.type === 'daterange'">
41
- <el-date-picker
42
- :size="size"
43
- v-model="qryFormData[formProp.prop]"
44
- type="daterange"
45
- unlink-panels
46
- range-separator="至"
47
- start-placeholder="开始日期"
48
- end-placeholder="结束日期"
49
- :value-format="formProp.format ? formProp.format : 'yyyy-MM-dd'"
50
- v-on="$listeners"
51
- v-bind="$attrs"
52
- style="width: 100%"
53
- >
54
- </el-date-picker>
55
- </template>
56
- <template v-if="formProp.type === 'date'">
57
- <el-date-picker
58
- :size="size"
59
- v-model="qryFormData[formProp.prop]"
60
- type="date"
61
- unlink-panels
62
- :placeholder="formProp.placeholder"
63
- :value-format="formProp.format ? formProp.format : 'yyyy-MM-dd'"
64
- v-on="$listeners"
65
- v-bind="$attrs"
66
- style="width: 100%"
67
- >
68
- </el-date-picker>
69
- </template>
70
- <template v-if="formProp.type == 'switch'">
71
- <el-switch
72
- :size="size"
73
- v-model="qryFormData[formProp.prop]"
74
- :active-text="formProp.optList ? formProp.optList[0] : ''"
75
- :inactive-text="formProp.optList ? formProp.optList[1] : ''"
76
- v-on="$listeners"
77
- v-bind="$attrs"
78
- style="width: 100%"
79
- ></el-switch>
80
- </template>
81
- <template v-if="formProp.type == 'radio'">
82
- <el-radio-group
83
- :size="size"
84
- v-model="qryFormData[formProp.prop]"
85
- style="width: 100%"
86
- >
87
- <el-radio
88
- v-for="(j, k) in formProp.optList"
89
- :label="
90
- formProp.optListProp ? j[formProp.optListProp.value] : j.value
91
- "
92
- :key="k"
93
- >{{
94
- formProp.optListProp ? j[formProp.optListProp.label] : j.lable
95
- }}</el-radio
96
- >
97
- </el-radio-group>
98
- </template>
99
- <template v-if="formProp.type === 'checkbox'">
100
- <el-checkbox-group
101
- :size="size"
102
- v-model="qryFormData[formProp.prop]"
103
- style="width: 100%; display: flex"
104
- >
105
- <el-checkbox
106
- v-for="(j, k) in formProp.optList"
107
- :label="
108
- formProp.optListProp ? j[formProp.optListProp.value] : j.value
109
- "
110
- :key="k"
111
- >{{ formProp.optListProp ? j[formProp.optListProp.label] : j.lable }}
112
- </el-checkbox>
113
- </el-checkbox-group>
114
- </template>
115
- <template v-if="formProp.slot == true">
116
- <slot :name="formProp.prop"></slot>
117
- </template>
118
- </div>
119
- </template>
120
- <script>
121
- export default {
122
- name: "HbQueryForm",
123
- componentName: "HbQueryForm",
124
- props: {
125
- formProp: {
126
- type: Object,
127
- default: () => {},
128
- },
129
- qryFormData: {
130
- type: Object,
131
- default: () => {},
132
- },
133
- size: {
134
- type: String,
135
- default: "",
136
- },
137
- },
138
- data() {
139
- return {};
140
- },
141
- };
142
- </script>
@@ -1,5 +0,0 @@
1
- import HbSelectVague from "./src/main.vue";
2
- HbSelectVague.install = function (Vue) {
3
- Vue.component(HbSelectVague.name, HbSelectVague);
4
- };
5
- export default HbSelectVague;
@@ -1,80 +0,0 @@
1
- <template>
2
- <div class="hb-select">
3
- <el-select
4
- filterable
5
- :filter-method="filter"
6
- v-bind="$attrs"
7
- v-on="$listeners"
8
- >
9
- <el-option
10
- v-for="item in data"
11
- :key="item[defaultProps.value]"
12
- :label="item[defaultProps.label]"
13
- :value="item[defaultProps.value]"
14
- :disabled="item.disabled"
15
- >
16
- <span v-html="item[defaultProps.label]"></span>
17
- </el-option>
18
- </el-select>
19
- </div>
20
- </template>
21
- <script>
22
- import lodash from "lodash";
23
- import pinyinMatch from "pinyin-match";
24
- export default {
25
- name: "HbSelectVague",
26
- componentName: "HbSelectVague",
27
- data() {
28
- return {
29
- data: [],
30
- };
31
- },
32
- methods: {
33
- filter(keyWords) {
34
- this.data = lodash.cloneDeep(this.options);
35
- if (!keyWords.trim()) return;
36
- //操作返回options其中匹配的项即可
37
- let searchData = [];
38
- this.data.forEach((item) => {
39
- let matched = pinyinMatch.match(
40
- item[this.defaultProps.label],
41
- keyWords
42
- );
43
- if (matched) {
44
- searchData.push(item);
45
- }
46
- });
47
- searchData.forEach((item) => {
48
- item[this.defaultProps.label] = item[this.defaultProps.label].replace(
49
- new RegExp(keyWords, "g"),
50
- `<span class="high-light">${keyWords}</span>`
51
- );
52
- });
53
- this.data = searchData;
54
- },
55
- },
56
- props: {
57
- options: {
58
- type: Array,
59
- default: () => [],
60
- },
61
- defaultProps: {
62
- type: Object,
63
- default: () => {
64
- return {
65
- value: "value",
66
- label: "label",
67
- };
68
- },
69
- },
70
- },
71
- watch: {
72
- options: {
73
- immediate: true,
74
- handler: function (to) {
75
- this.data = lodash.cloneDeep(to);
76
- },
77
- },
78
- },
79
- };
80
- </script>
@@ -1,5 +0,0 @@
1
- import HbTable from "./src/main.vue";
2
- HbTable.install = function (Vue) {
3
- Vue.component(HbTable.name, HbTable);
4
- };
5
- export default HbTable;
@@ -1,265 +0,0 @@
1
- <template>
2
- <div class="hb-table">
3
- <!-- 测试代码 -->
4
- <!-- <template v-for="item in columns">
5
- <span :key="item.prop">{{ item.prop }}</span>
6
- </template> -->
7
- <el-table
8
- ref="table"
9
- v-loading="loading"
10
- :data="tableData"
11
- v-bind="tableProp"
12
- :stripe="false"
13
- :border="true"
14
- :height="height"
15
- style="flex: 1"
16
- :key="key"
17
- @select="selectData"
18
- @select-all="selectData"
19
- v-on="$listeners"
20
- >
21
- <template slot="empty">
22
- <div class="hb-table-nodata"></div>
23
- <div class="hb-table-nodata-text">暂无数据</div>
24
- </template>
25
- <!-- 序号列 -->
26
- <el-table-column
27
- v-if="serial"
28
- label="序号"
29
- type="index"
30
- align="center"
31
- width="44"
32
- fixed="left"
33
- class-name="hb-table-index"
34
- ></el-table-column>
35
- <!-- 选择框列 -->
36
- <el-table-column
37
- v-if="select"
38
- type="selection"
39
- align="center"
40
- width="44"
41
- :selectable="selectable"
42
- :reserve-selection="reserveSelect"
43
- fixed="left"
44
- ></el-table-column>
45
- <!-- 只有一列时在左支撑这一列的空白列 -->
46
- <el-table-column
47
- v-if="columns.length === 0"
48
- min-width="1px"
49
- key="beforeBlank"
50
- :resizable="false"
51
- ></el-table-column>
52
- <template v-for="(item, colIndex) in columns">
53
- <!-- 插槽列 -->
54
- <slot
55
- v-if="item.slot && item.currentSelect"
56
- :name="item.prop"
57
- :column="item"
58
- ></slot>
59
- <!-- 编辑列 -->
60
- <el-table-column
61
- v-else-if="item.edit && item.currentSelect"
62
- :key="item.prop"
63
- :prop="item.prop"
64
- :label="item.label"
65
- :width="item.minWidth > 0 ? undefined : item.width"
66
- :min-width="item.minWidth"
67
- :formatter="item.formatter"
68
- :fixed="item.fixed"
69
- :align="item.align || 'left'"
70
- :show-overflow-tooltip="!item.edit.keepEdit"
71
- :resizable="!!item.resizable || true"
72
- >
73
- <template v-slot="{ row, col, $index }">
74
- <hb-editarea
75
- :ref="
76
- item.edit.keepEdit
77
- ? `editarea_${$index}_${colIndex}`
78
- : undefined
79
- "
80
- v-if="!item.editCondition || item.editCondition($index, row)"
81
- :keepEdit="item.edit.keepEdit"
82
- :value.sync="row[item.prop]"
83
- v-bind="item.edit"
84
- :class="item.edit.keepEdit ? 'hb-table__keep' : 'hb-table__edit'"
85
- :border="true"
86
- :insert="handleInsertCell(row, item)"
87
- :change="handleChangeCell(row, item)"
88
- ></hb-editarea>
89
- <font v-else>{{ row[item.prop] }}</font>
90
- </template>
91
- </el-table-column>
92
- <!-- 普通列 -->
93
- <el-table-column
94
- v-else-if="item.currentSelect"
95
- :key="item.prop"
96
- :prop="item.prop"
97
- :label="item.label"
98
- :width="item.minWidth > 0 ? undefined : item.width"
99
- :min-width="item.minWidth"
100
- :formatter="item.formatter"
101
- :fixed="item.fixed"
102
- :align="item.align || 'left'"
103
- :show-overflow-tooltip="true"
104
- :resizable="!!item.resizable || true"
105
- >
106
- </el-table-column>
107
- </template>
108
- <!-- 只有一列时在右支撑这一列的空白列 -->
109
- <el-table-column
110
- v-if="columns.length === 1"
111
- min-width="1px"
112
- key="afterBlank"
113
- ></el-table-column>
114
- </el-table>
115
- </div>
116
- </template>
117
- <script>
118
- export default {
119
- name: "HbTable",
120
- componentName: "HbTable",
121
- props: {
122
- tableData: {
123
- type: Array,
124
- default: () => [],
125
- },
126
- // 表格列配置数组
127
- height: {
128
- type: String,
129
- default: () => "auto",
130
- },
131
- serial: {
132
- type: Boolean,
133
- default: () => true,
134
- },
135
- select: {
136
- type: Boolean,
137
- default: () => false,
138
- },
139
- reserveSelect: {
140
- type: Boolean,
141
- default: () => false,
142
- },
143
- selectable: {
144
- type: Function,
145
- default: () => () => false,
146
- },
147
- columns: {
148
- type: Array,
149
- default: () => [],
150
- },
151
- },
152
- data() {
153
- return {
154
- loading: false,
155
- /** 列表样式 */
156
- tableStyles: {
157
- "highlight-current-row": true,
158
- "header-cell-class-name": "hb-table-header-cell",
159
- "cell-class-name": "hb-table-cell",
160
- },
161
- /** 列表数据 */
162
- key: 0,
163
- selectedData: [],
164
- };
165
- },
166
- methods: {
167
- /* api */
168
- elTable() {
169
- return this.$refs?.table;
170
- },
171
- /**
172
- * @function validateEdit 对于编辑单元格进行校验,仅对edit.keepEdit的单元格有效
173
- * @param {Function} callback 回调,传入校验结果布尔值
174
- * @param {[Number|Function]} who 校验目标,数字表示行下标,函数传入行和列信息,根据返回值确定是否校验
175
- */
176
- validateEdit(callback, who) {
177
- const cols = this.columns;
178
- const rows = this.tableData;
179
- let errorCount = 0;
180
- let validCount = rows.length * cols.length;
181
- // 确定哪些单元格需要校验
182
- let validIt = () => true;
183
- if (typeof who === "number") {
184
- validIt = (colIndex, rowIndex) => rowIndex === who;
185
- } else if (typeof who === "function") {
186
- validIt = who;
187
- }
188
- rows.forEach((row, rowIndex) => {
189
- cols.forEach((col, colIndex) => {
190
- validCount--;
191
- // 对存在keepEdit控件的单元格进行校验
192
- if (
193
- col.edit &&
194
- col.edit.keepEdit &&
195
- (typeof col.editCondition !== "function" ||
196
- col.editCondition(rowIndex, row))
197
- ) {
198
- if (validIt(colIndex, rowIndex, col, row)) {
199
- const area = this.$refs[`editarea_${rowIndex}_${colIndex}`];
200
- // area数组内都是指定节点,只有最后一个vnode是响应式的
201
- area.length &&
202
- area[area.length - 1].validateEdit((error) => {
203
- error && errorCount++;
204
- });
205
- }
206
- }
207
- !validCount &&
208
- typeof callback === "function" &&
209
- callback(!errorCount);
210
- });
211
- });
212
- },
213
- /** methods */
214
- openLoading() {
215
- this.loading = true;
216
- },
217
- closeLoading() {
218
- this.loading = false;
219
- },
220
- selectData(arr) {
221
- this.selectedData = arr;
222
- this.$emit("selectData", this.selectedData);
223
- },
224
- /** events */
225
- /**
226
- * @event handleInsertCell 改写cell传参,用于抛出row信息
227
- */
228
- handleInsertCell(row, column) {
229
- if (typeof column.edit.insert === "function") {
230
- return () => {
231
- // 推给area的传参
232
- return column.edit.insert(row); // 被改写的处理内容:为insert科利华
233
- };
234
- }
235
- return null;
236
- },
237
- /**
238
- * @event handleChangeCell 改写change传参,用于抛出row信息
239
- */
240
- handleChangeCell(row, column) {
241
- if (typeof column.edit.change === "function") {
242
- return (next, value) => {
243
- column.edit.change(next, row, value);
244
- };
245
- }
246
- return null;
247
- },
248
- },
249
- computed: {
250
- // 传入el-table的prop:将自带的一些prop和传入的prop(权重更高)合并
251
- tableProp() {
252
- const props = this.$lodash.assign({}, this.tableStyles, this.$attrs);
253
- return props;
254
- },
255
- },
256
- watch: {
257
- columns: {
258
- handler: function () {
259
- this.key = new Date().getTime();
260
- },
261
- },
262
- },
263
- };
264
- </script>
265
-