hbte-saas-ui 0.0.1 → 1.0.1

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 (128) hide show
  1. package/package.json +8 -2
  2. package/.browserslistrc +0 -3
  3. package/.editorconfig +0 -7
  4. package/.env.development +0 -1
  5. package/.env.lib +0 -1
  6. package/.eslintrc.js +0 -14
  7. package/.prettierrc +0 -3
  8. package/babel.config.js +0 -3
  9. package/docs/.vuepress/config.js +0 -23
  10. package/docs/.vuepress/styles/index.styl +0 -4
  11. package/docs/AdvQuery.md +0 -26
  12. package/docs/CustomQuery.md +0 -21
  13. package/docs/EditArea.md +0 -16
  14. package/docs/FilterDrop.md +0 -29
  15. package/docs/FullTable.md +0 -68
  16. package/docs/Pagination.md +0 -22
  17. package/docs/QueryForm.md +0 -27
  18. package/docs/README.md +0 -17
  19. package/docs/Table.md +0 -58
  20. package/docs/ToolGroup.md +0 -32
  21. package/examples/App.vue +0 -97
  22. package/examples/image/hb-image-viewer/3k.jpg +0 -0
  23. package/examples/image/hb-image-viewer/a.jpg +0 -0
  24. package/examples/image/hb-image-viewer/b.jpg +0 -0
  25. package/examples/main.js +0 -39
  26. package/examples/mock/authority.js +0 -1108
  27. package/examples/mock/dept.js +0 -4001
  28. package/examples/mock/fulltable.js +0 -407
  29. package/examples/mock/organizeData.js +0 -18965
  30. package/examples/router/index.js +0 -111
  31. package/examples/views/ElementCpTest.vue +0 -299
  32. package/examples/views/Fragment.vue +0 -196
  33. package/examples/views/HBAdvQuery.vue +0 -150
  34. package/examples/views/HBAuthority.vue +0 -339
  35. package/examples/views/HBDialog.vue +0 -39
  36. package/examples/views/HBEditarea.vue +0 -350
  37. package/examples/views/HBFilterDrop.vue +0 -72
  38. package/examples/views/HBFloatFooter.vue +0 -42
  39. package/examples/views/HBFullTable.vue +0 -751
  40. package/examples/views/HBImageViewer.vue +0 -57
  41. package/examples/views/HBNavMenu.vue +0 -37
  42. package/examples/views/HBOrganizeDialog.vue +0 -133
  43. package/examples/views/HBPagination.vue +0 -80
  44. package/examples/views/HBSelectVague.vue +0 -57
  45. package/examples/views/HBToolgroup.vue +0 -29
  46. package/examples/views/HBTopBar.vue +0 -16
  47. package/packages/adv-query/index.js +0 -5
  48. package/packages/adv-query/src/main.vue +0 -294
  49. package/packages/area-select/index.js +0 -7
  50. package/packages/area-select/src/main.vue +0 -37
  51. package/packages/authority/index.js +0 -5
  52. package/packages/authority/src/main.vue +0 -606
  53. package/packages/config.js +0 -3
  54. package/packages/custom-query/index.js +0 -5
  55. package/packages/custom-query/src/main.vue +0 -80
  56. package/packages/dialog/index.js +0 -7
  57. package/packages/dialog/src/main.vue +0 -176
  58. package/packages/edit-area/index.js +0 -13
  59. package/packages/edit-area/src/config.js +0 -3
  60. package/packages/edit-area/src/main.vue +0 -304
  61. package/packages/edit-area/src/simulateEvent.js +0 -219
  62. package/packages/filter-drop/index.js +0 -6
  63. package/packages/filter-drop/src/main.vue +0 -107
  64. package/packages/float-footer/index.js +0 -7
  65. package/packages/float-footer/src/main.vue +0 -40
  66. package/packages/fragment/index.js +0 -7
  67. package/packages/fragment/src/main.vue +0 -74
  68. package/packages/fragment/src/old.vue +0 -144
  69. package/packages/full-table/index.js +0 -6
  70. package/packages/full-table/src/config.js +0 -14
  71. package/packages/full-table/src/main.vue +0 -141
  72. package/packages/image-viewer/index.js +0 -8
  73. package/packages/image-viewer/src/main.js +0 -14
  74. package/packages/image-viewer/src/main.vue +0 -138
  75. package/packages/image-viewer/src/svg/cancel.svg +0 -2
  76. package/packages/image-viewer/src/svg/delete.svg +0 -2
  77. package/packages/image-viewer/src/svg/download.svg +0 -2
  78. package/packages/image-viewer/src/svg/rotate.svg +0 -77
  79. package/packages/image-viewer/src/svg/scaledown.svg +0 -71
  80. package/packages/image-viewer/src/svg/scaleup.svg +0 -72
  81. package/packages/index.js +0 -43
  82. package/packages/nav-menu/index.js +0 -7
  83. package/packages/nav-menu/src/main.vue +0 -277
  84. package/packages/organize-dialog/index.js +0 -5
  85. package/packages/organize-dialog/src/main.vue +0 -427
  86. package/packages/pagination/index.js +0 -6
  87. package/packages/pagination/src/main.vue +0 -145
  88. package/packages/query-form/index.js +0 -5
  89. package/packages/query-form/src/main.vue +0 -142
  90. package/packages/select-vague/index.js +0 -5
  91. package/packages/select-vague/src/main.vue +0 -80
  92. package/packages/table/index.js +0 -5
  93. package/packages/table/src/main.vue +0 -265
  94. package/packages/theme-chalk/adv-query.scss +0 -107
  95. package/packages/theme-chalk/authority.scss +0 -103
  96. package/packages/theme-chalk/common/elementCover.scss +0 -722
  97. package/packages/theme-chalk/common/flex.scss +0 -66
  98. package/packages/theme-chalk/common/global.scss +0 -147
  99. package/packages/theme-chalk/common/reset.scss +0 -92
  100. package/packages/theme-chalk/common/var.scss +0 -46
  101. package/packages/theme-chalk/custom-query.scss +0 -10
  102. package/packages/theme-chalk/dialog.scss +0 -9
  103. package/packages/theme-chalk/edit-area.scss +0 -119
  104. package/packages/theme-chalk/filter-drop.scss +0 -81
  105. package/packages/theme-chalk/float-footer.scss +0 -14
  106. package/packages/theme-chalk/fonts/iconfont.ttf +0 -0
  107. package/packages/theme-chalk/fragment.scss +0 -51
  108. package/packages/theme-chalk/full-table.scss +0 -40
  109. package/packages/theme-chalk/icon.scss +0 -96
  110. package/packages/theme-chalk/image-viewer.scss +0 -94
  111. package/packages/theme-chalk/images/company-logo--default.png +0 -0
  112. package/packages/theme-chalk/images/nodata.png +0 -0
  113. package/packages/theme-chalk/images/user-logo--default.png +0 -0
  114. package/packages/theme-chalk/index.scss +0 -21
  115. package/packages/theme-chalk/nav-menu.scss +0 -205
  116. package/packages/theme-chalk/organize-dialog.scss +0 -170
  117. package/packages/theme-chalk/pagination.scss +0 -91
  118. package/packages/theme-chalk/select.scss +0 -8
  119. package/packages/theme-chalk/table.scss +0 -102
  120. package/packages/theme-chalk/tool-group.scss +0 -105
  121. package/packages/theme-chalk/top-bar.scss +0 -195
  122. package/packages/tool-group/index.js +0 -13
  123. package/packages/tool-group/src/config.js +0 -40
  124. package/packages/tool-group/src/main.vue +0 -93
  125. package/packages/top-bar/index.js +0 -7
  126. package/packages/top-bar/src/main.vue +0 -280
  127. package/public/index.html +0 -20
  128. 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,145 +0,0 @@
1
- <template>
2
- <div class="hb-pagination">
3
- <el-pagination
4
- v-if="pageData"
5
- background
6
- @size-change="handleSizeChange"
7
- @current-change="handleCurrentChange"
8
- :current-page="pageData.pageNum"
9
- :page-sizes="pageSizes"
10
- :page-size="pageData.pageSize"
11
- layout="total, sizes, prev, slot"
12
- :total="total"
13
- >
14
- <div class="hb-pagination-slot">
15
- <div slot="input">
16
- <span class="hb-pagination-slot_text">第</span>
17
- <el-input
18
- @input="handleCurrentInput"
19
- @blur="handleCurrentBlur"
20
- class="hb-pagination-slot_input"
21
- v-model="pageData.pageNum"
22
- :clearable="false"
23
- ></el-input>
24
- <span class="hb-pagination-slot_text">共{{ pageNumber }}页</span>
25
- </div>
26
- </div>
27
- </el-pagination>
28
- <el-pagination
29
- v-if="pageData"
30
- background
31
- @size-change="handleSizeChange"
32
- @current-change="handleCurrentChange"
33
- :current-page="pageData.pageNum"
34
- :page-sizes="pageSizes"
35
- :page-size="pageData.pageSize"
36
- layout="next, slot"
37
- :total="total"
38
- >
39
- <hb-filterdrop
40
- v-if="showFilter"
41
- :columns="columns"
42
- :placement="placement"
43
- :disabledFilter="disabledFilter"
44
- @columnsChange="columnsChange"
45
- v-bind="$attrs"
46
- >
47
- <i
48
- slot="dropdown"
49
- class="hb-pagination__dropdown-icon el-icon-s-operation"
50
- ></i>
51
- </hb-filterdrop>
52
- </el-pagination>
53
- </div>
54
- </template>
55
- <script>
56
- export default {
57
- name: "hbPagination",
58
- cpName: "hbPagination",
59
- props: {
60
- pageData: {
61
- type: Object,
62
- default: () => ({
63
- pageSize: 50,
64
- pageNum: 1,
65
- total: 0,
66
- }),
67
- },
68
- pageSizes: {
69
- type: Array,
70
- default: () => [5, 30, 50],
71
- },
72
- showFilter: {
73
- type: Boolean,
74
- default: true,
75
- },
76
- columns: {
77
- type: Array,
78
- default: () => [],
79
- },
80
- placement: {
81
- type: String,
82
- default: "bottom-end",
83
- },
84
- disabledFilter: {
85
- type: Boolean,
86
- default: false,
87
- },
88
- },
89
- data() {
90
- return {};
91
- },
92
- computed: {
93
- total() {
94
- const { total } = this.pageData;
95
- return typeof total === "number" ? total : total ? Number(total) : 0;
96
- },
97
- pageNumber() {
98
- return Math.ceil(this.pageData.total / this.pageData.pageSize);
99
- },
100
- },
101
- methods: {
102
- /**
103
- * @event handleSizeChange 切换每页数量
104
- */
105
- handleSizeChange(num) {
106
- // 每页条数改变时,建议重置当前的页码
107
- this.$emit("pageSizeChange", num);
108
- },
109
- /**
110
- * @event handleCurrentChange 切换页码
111
- */
112
- handleCurrentChange(num) {
113
- this.$emit("pageNumChange", num);
114
- },
115
- /**
116
- * @event handleCurrentInput 自定义翻页页码输入时
117
- */
118
- handleCurrentInput() {
119
- // 处理输入格式
120
- if (isNaN(this.pageData.pageNum)) {
121
- this.pageData.pageNum = 1;
122
- } else {
123
- this.pageData.pageNum = Number(this.pageData.pageNum);
124
- }
125
- },
126
- /**
127
- * @event handleCurrentBlur 自定义翻页页码失焦触发翻页
128
- */
129
- handleCurrentBlur() {
130
- let currentPage = 1;
131
- if (this.pageData.pageNum > this.pageNumber) {
132
- currentPage = this.pageNumber;
133
- } else if (this.pageData.pageNum <= 0) {
134
- currentPage = 1;
135
- } else {
136
- currentPage = this.pageData.pageNum;
137
- }
138
- this.handleCurrentChange(currentPage);
139
- },
140
- columnsChange(newColumns) {
141
- this.$emit("columnsChange", newColumns);
142
- },
143
- },
144
- };
145
- </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
-