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.
- package/README.md +8 -1
- package/lib/hbte-ui.common.js +31 -10
- package/lib/hbte-ui.umd.js +31 -10
- package/lib/hbte-ui.umd.min.js +1 -1
- package/package.json +8 -2
- package/.browserslistrc +0 -3
- package/.editorconfig +0 -7
- package/.env.development +0 -1
- package/.env.lib +0 -1
- package/.eslintrc.js +0 -14
- package/.prettierrc +0 -3
- package/babel.config.js +0 -3
- package/docs/.vuepress/config.js +0 -23
- package/docs/.vuepress/styles/index.styl +0 -4
- package/docs/AdvQuery.md +0 -26
- package/docs/CustomQuery.md +0 -21
- package/docs/EditArea.md +0 -16
- package/docs/FilterDrop.md +0 -29
- package/docs/FullTable.md +0 -68
- package/docs/Pagination.md +0 -22
- package/docs/QueryForm.md +0 -27
- package/docs/README.md +0 -17
- package/docs/Table.md +0 -58
- package/docs/ToolGroup.md +0 -32
- package/examples/App.vue +0 -97
- package/examples/image/hb-image-viewer/3k.jpg +0 -0
- package/examples/image/hb-image-viewer/a.jpg +0 -0
- package/examples/image/hb-image-viewer/b.jpg +0 -0
- package/examples/main.js +0 -39
- package/examples/mock/authority.js +0 -1108
- package/examples/mock/dept.js +0 -4001
- package/examples/mock/fulltable.js +0 -407
- package/examples/mock/organizeData.js +0 -18965
- package/examples/router/index.js +0 -111
- package/examples/views/ElementCpTest.vue +0 -299
- package/examples/views/Fragment.vue +0 -196
- package/examples/views/HBAdvQuery.vue +0 -150
- package/examples/views/HBAuthority.vue +0 -339
- package/examples/views/HBDialog.vue +0 -39
- package/examples/views/HBEditarea.vue +0 -350
- package/examples/views/HBFilterDrop.vue +0 -72
- package/examples/views/HBFloatFooter.vue +0 -42
- package/examples/views/HBFullTable.vue +0 -751
- package/examples/views/HBImageViewer.vue +0 -57
- package/examples/views/HBNavMenu.vue +0 -37
- package/examples/views/HBOrganizeDialog.vue +0 -133
- package/examples/views/HBPagination.vue +0 -80
- package/examples/views/HBSelectVague.vue +0 -57
- package/examples/views/HBToolgroup.vue +0 -29
- package/examples/views/HBTopBar.vue +0 -16
- package/packages/adv-query/index.js +0 -5
- package/packages/adv-query/src/main.vue +0 -294
- package/packages/area-select/index.js +0 -7
- package/packages/area-select/src/main.vue +0 -37
- package/packages/authority/index.js +0 -5
- package/packages/authority/src/main.vue +0 -606
- package/packages/config.js +0 -3
- package/packages/custom-query/index.js +0 -5
- package/packages/custom-query/src/main.vue +0 -80
- package/packages/dialog/index.js +0 -7
- package/packages/dialog/src/main.vue +0 -176
- package/packages/edit-area/index.js +0 -13
- package/packages/edit-area/src/config.js +0 -3
- package/packages/edit-area/src/main.vue +0 -304
- package/packages/edit-area/src/simulateEvent.js +0 -219
- package/packages/filter-drop/index.js +0 -6
- package/packages/filter-drop/src/main.vue +0 -107
- package/packages/float-footer/index.js +0 -7
- package/packages/float-footer/src/main.vue +0 -40
- package/packages/fragment/index.js +0 -7
- package/packages/fragment/src/main.vue +0 -74
- package/packages/fragment/src/old.vue +0 -144
- package/packages/full-table/index.js +0 -6
- package/packages/full-table/src/config.js +0 -14
- package/packages/full-table/src/main.vue +0 -141
- package/packages/image-viewer/index.js +0 -8
- package/packages/image-viewer/src/main.js +0 -14
- package/packages/image-viewer/src/main.vue +0 -138
- package/packages/image-viewer/src/svg/cancel.svg +0 -2
- package/packages/image-viewer/src/svg/delete.svg +0 -2
- package/packages/image-viewer/src/svg/download.svg +0 -2
- package/packages/image-viewer/src/svg/rotate.svg +0 -77
- package/packages/image-viewer/src/svg/scaledown.svg +0 -71
- package/packages/image-viewer/src/svg/scaleup.svg +0 -72
- package/packages/index.js +0 -43
- package/packages/nav-menu/index.js +0 -7
- package/packages/nav-menu/src/main.vue +0 -277
- package/packages/organize-dialog/index.js +0 -5
- package/packages/organize-dialog/src/main.vue +0 -427
- package/packages/pagination/index.js +0 -6
- package/packages/pagination/src/main.vue +0 -146
- package/packages/query-form/index.js +0 -5
- package/packages/query-form/src/main.vue +0 -142
- package/packages/select-vague/index.js +0 -5
- package/packages/select-vague/src/main.vue +0 -80
- package/packages/table/index.js +0 -5
- package/packages/table/src/main.vue +0 -265
- package/packages/theme-chalk/adv-query.scss +0 -107
- package/packages/theme-chalk/authority.scss +0 -103
- package/packages/theme-chalk/common/elementCover.scss +0 -722
- package/packages/theme-chalk/common/flex.scss +0 -66
- package/packages/theme-chalk/common/global.scss +0 -147
- package/packages/theme-chalk/common/reset.scss +0 -92
- package/packages/theme-chalk/common/var.scss +0 -46
- package/packages/theme-chalk/custom-query.scss +0 -10
- package/packages/theme-chalk/dialog.scss +0 -9
- package/packages/theme-chalk/edit-area.scss +0 -119
- package/packages/theme-chalk/filter-drop.scss +0 -81
- package/packages/theme-chalk/float-footer.scss +0 -14
- package/packages/theme-chalk/fonts/iconfont.ttf +0 -0
- package/packages/theme-chalk/fragment.scss +0 -51
- package/packages/theme-chalk/full-table.scss +0 -40
- package/packages/theme-chalk/icon.scss +0 -96
- package/packages/theme-chalk/image-viewer.scss +0 -94
- package/packages/theme-chalk/images/company-logo--default.png +0 -0
- package/packages/theme-chalk/images/nodata.png +0 -0
- package/packages/theme-chalk/images/user-logo--default.png +0 -0
- package/packages/theme-chalk/index.scss +0 -21
- package/packages/theme-chalk/nav-menu.scss +0 -205
- package/packages/theme-chalk/organize-dialog.scss +0 -170
- package/packages/theme-chalk/pagination.scss +0 -91
- package/packages/theme-chalk/select.scss +0 -8
- package/packages/theme-chalk/table.scss +0 -102
- package/packages/theme-chalk/tool-group.scss +0 -105
- package/packages/theme-chalk/top-bar.scss +0 -195
- package/packages/tool-group/index.js +0 -13
- package/packages/tool-group/src/config.js +0 -40
- package/packages/tool-group/src/main.vue +0 -93
- package/packages/top-bar/index.js +0 -7
- package/packages/top-bar/src/main.vue +0 -280
- package/public/index.html +0 -20
- package/vue.config.js +0 -6
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<hb-dialog
|
|
3
|
-
title="新建筛选"
|
|
4
|
-
width="60%"
|
|
5
|
-
ref="customQuery"
|
|
6
|
-
class="hb-customquery"
|
|
7
|
-
@submit="sumbit"
|
|
8
|
-
>
|
|
9
|
-
<el-form
|
|
10
|
-
ref="queryForm"
|
|
11
|
-
:model="qryFormData"
|
|
12
|
-
size="small"
|
|
13
|
-
label-position="top"
|
|
14
|
-
slot="normal"
|
|
15
|
-
>
|
|
16
|
-
<el-row :gutter="40">
|
|
17
|
-
<el-col v-for="(i, index) in qryFormProps" :span="12" :key="index">
|
|
18
|
-
<el-form-item :label="i.label" :prop="i.prop ? i.prop : ''">
|
|
19
|
-
<hb-query-form
|
|
20
|
-
:formProp="i"
|
|
21
|
-
:qryFormData="qryFormData"
|
|
22
|
-
></hb-query-form>
|
|
23
|
-
</el-form-item>
|
|
24
|
-
</el-col>
|
|
25
|
-
|
|
26
|
-
<p class="hb-customquery-text">谁可以查看此列表视图?</p>
|
|
27
|
-
|
|
28
|
-
<el-col :span="12">
|
|
29
|
-
<el-radio v-model="radio" label="1"
|
|
30
|
-
>只有我可以查看此列表视图</el-radio
|
|
31
|
-
>
|
|
32
|
-
</el-col>
|
|
33
|
-
<el-col :span="12">
|
|
34
|
-
<el-radio v-model="radio" label="2"
|
|
35
|
-
>所有用户均可以查看此列表视图</el-radio
|
|
36
|
-
>
|
|
37
|
-
</el-col>
|
|
38
|
-
</el-row>
|
|
39
|
-
</el-form>
|
|
40
|
-
<!-- <span slot="footer" class="dialog-footer">
|
|
41
|
-
<el-button @click="dialogVisible = false" size="small">取消</el-button>
|
|
42
|
-
<el-button type="primary" @click="sumbit" size="small">保存</el-button>
|
|
43
|
-
</span> -->
|
|
44
|
-
</hb-dialog>
|
|
45
|
-
</template>
|
|
46
|
-
<script>
|
|
47
|
-
export default {
|
|
48
|
-
name: "HbCustomQuery",
|
|
49
|
-
componentName: "HbCustomQuery",
|
|
50
|
-
props: {
|
|
51
|
-
qryFormProps: {
|
|
52
|
-
type: Array,
|
|
53
|
-
default: () => [],
|
|
54
|
-
},
|
|
55
|
-
qryFormData: {
|
|
56
|
-
type: Object,
|
|
57
|
-
default: () => {},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
data() {
|
|
61
|
-
return {
|
|
62
|
-
radio: "1",
|
|
63
|
-
type: "",
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
methods: {
|
|
67
|
-
open(type, data) {
|
|
68
|
-
this.type = type;
|
|
69
|
-
if (type == "edit") {
|
|
70
|
-
Object.assign(this.qryFormData, data);
|
|
71
|
-
}
|
|
72
|
-
this.$refs.customQuery.open();
|
|
73
|
-
},
|
|
74
|
-
sumbit() {
|
|
75
|
-
this.$emit("customQuerySave", this.type, this.qryFormData);
|
|
76
|
-
this.$refs.customQuery.close();
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
</script>
|
package/packages/dialog/index.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="hb-dialog">
|
|
3
|
-
<el-dialog
|
|
4
|
-
v-bind="$attrs"
|
|
5
|
-
v-on="$listeners"
|
|
6
|
-
:title="title"
|
|
7
|
-
:visible.sync="visible"
|
|
8
|
-
:close-on-click-modal="closeOnClick"
|
|
9
|
-
:close-on-press-escape="closeOnEsc"
|
|
10
|
-
:destroy-on-close="true"
|
|
11
|
-
@close="onClose"
|
|
12
|
-
@closed="onClosed"
|
|
13
|
-
>
|
|
14
|
-
<!-- 弹窗主体内容插槽,before和after插槽只是为了普通内容和表单内容的布局考虑 -->
|
|
15
|
-
<div class="content hb-dialog__wrapper">
|
|
16
|
-
<slot name="before"></slot>
|
|
17
|
-
<!-- 表单内容插槽 -->
|
|
18
|
-
<el-form
|
|
19
|
-
class="form-wrapper"
|
|
20
|
-
ref="ruleForm"
|
|
21
|
-
size="small"
|
|
22
|
-
v-if="formData"
|
|
23
|
-
:model="formData"
|
|
24
|
-
:rules="rules"
|
|
25
|
-
:label-width="labelWidth"
|
|
26
|
-
:label-position="labelPosition"
|
|
27
|
-
>
|
|
28
|
-
<slot name="form"></slot>
|
|
29
|
-
</el-form>
|
|
30
|
-
<!-- 普通内容插槽 -->
|
|
31
|
-
<slot name="normal"></slot>
|
|
32
|
-
<slot name="after"></slot>
|
|
33
|
-
</div>
|
|
34
|
-
<slot name="bottom"></slot>
|
|
35
|
-
<!-- 底部按钮插槽 -->
|
|
36
|
-
|
|
37
|
-
<!-- 默认底部按钮组,父组件传自定义按钮组件则默认的不显示 -->
|
|
38
|
-
<div
|
|
39
|
-
class="default-footer-btn-wrapper flex-end hb-dialog__footer-btn"
|
|
40
|
-
slot="footer"
|
|
41
|
-
v-if="showFooter"
|
|
42
|
-
>
|
|
43
|
-
<slot name="dialogFooter" :submit="submit" :loading="loading">
|
|
44
|
-
<el-button
|
|
45
|
-
class="exist-btn"
|
|
46
|
-
size="small"
|
|
47
|
-
@click="close(false, $event)"
|
|
48
|
-
v-show="footerText.exist"
|
|
49
|
-
>{{ footerText.exist }}</el-button
|
|
50
|
-
>
|
|
51
|
-
<el-button
|
|
52
|
-
type="primary"
|
|
53
|
-
class="confirm-btn"
|
|
54
|
-
size="small"
|
|
55
|
-
@click="submit"
|
|
56
|
-
:loading="loading"
|
|
57
|
-
v-show="footerText.confirm"
|
|
58
|
-
>{{ footerText.confirm }}</el-button
|
|
59
|
-
>
|
|
60
|
-
</slot>
|
|
61
|
-
</div>
|
|
62
|
-
</el-dialog>
|
|
63
|
-
</div>
|
|
64
|
-
</template>
|
|
65
|
-
<script>
|
|
66
|
-
export default {
|
|
67
|
-
name: "HbDialog",
|
|
68
|
-
componentName: "HbDialog",
|
|
69
|
-
data() {
|
|
70
|
-
return {
|
|
71
|
-
visible: false,
|
|
72
|
-
loading: false,
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
props: {
|
|
76
|
-
title: {
|
|
77
|
-
type: String,
|
|
78
|
-
default: "",
|
|
79
|
-
},
|
|
80
|
-
labelPosition: {
|
|
81
|
-
type: String,
|
|
82
|
-
default: "top",
|
|
83
|
-
},
|
|
84
|
-
labelWidth: {
|
|
85
|
-
type: String,
|
|
86
|
-
default: "80px",
|
|
87
|
-
},
|
|
88
|
-
closeOnClick: {
|
|
89
|
-
default: () => false,
|
|
90
|
-
},
|
|
91
|
-
closeOnEsc: {
|
|
92
|
-
default: () => false,
|
|
93
|
-
},
|
|
94
|
-
footerText: {
|
|
95
|
-
default: () => {
|
|
96
|
-
// 默认底部按钮组文案
|
|
97
|
-
return {
|
|
98
|
-
confirm: "确定",
|
|
99
|
-
exist: "取消",
|
|
100
|
-
};
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
formData: {
|
|
104
|
-
default: () => null,
|
|
105
|
-
},
|
|
106
|
-
rules: {
|
|
107
|
-
default: () => {},
|
|
108
|
-
},
|
|
109
|
-
appendBody: {
|
|
110
|
-
default: false,
|
|
111
|
-
},
|
|
112
|
-
modalAppendBody: {
|
|
113
|
-
default: true,
|
|
114
|
-
},
|
|
115
|
-
// 是否显示底部按钮区域
|
|
116
|
-
showFooter: {
|
|
117
|
-
default: true,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
methods: {
|
|
121
|
-
open() {
|
|
122
|
-
this.visible = true;
|
|
123
|
-
},
|
|
124
|
-
close() {
|
|
125
|
-
this.visible = false;
|
|
126
|
-
},
|
|
127
|
-
submit(arg) {
|
|
128
|
-
// 发起请求前进行表单值校验
|
|
129
|
-
if (this.formData) {
|
|
130
|
-
this.$refs.ruleForm.validate((valid) => {
|
|
131
|
-
if (valid) {
|
|
132
|
-
this.loading = true;
|
|
133
|
-
this.$emit("submit", arg);
|
|
134
|
-
} else {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
this.loading = true;
|
|
140
|
-
this.$emit("submit", arg);
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
onClose() {
|
|
144
|
-
this.resetRuleForm();
|
|
145
|
-
this.$emit("close");
|
|
146
|
-
},
|
|
147
|
-
onClosed() {
|
|
148
|
-
this.resetLoading(); // 防止弹窗动画结束前暴力点击确认按钮
|
|
149
|
-
this.$emit("closed");
|
|
150
|
-
},
|
|
151
|
-
resetLoading() {
|
|
152
|
-
// 常用于父组件请求失败后关闭按钮的loading状态
|
|
153
|
-
this.loading = false;
|
|
154
|
-
},
|
|
155
|
-
resetRuleForm() {
|
|
156
|
-
// 对话框关闭,还原表单值
|
|
157
|
-
this.formData && this.$refs.ruleForm.resetFields(); // 如果有表单则还原表单的值
|
|
158
|
-
},
|
|
159
|
-
// 重新触发验证
|
|
160
|
-
validate() {
|
|
161
|
-
this.$refs.ruleForm.validate();
|
|
162
|
-
},
|
|
163
|
-
// 清空验证
|
|
164
|
-
clearValidate() {
|
|
165
|
-
this.$nextTick(() => {
|
|
166
|
-
this.$refs.ruleForm && this.$refs.ruleForm.clearValidate();
|
|
167
|
-
});
|
|
168
|
-
},
|
|
169
|
-
// 单独触发某一项的验证
|
|
170
|
-
validateSomeField(fielidName) {
|
|
171
|
-
this.$refs.ruleForm.validateField(fielidName);
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
</script>
|
|
176
|
-
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import HbEditarea from "./src/main.vue";
|
|
2
|
-
import config from "./src/config.js"
|
|
3
|
-
|
|
4
|
-
HbEditarea.install = function (Vue) {
|
|
5
|
-
Vue.component(HbEditarea.name, HbEditarea);
|
|
6
|
-
};
|
|
7
|
-
HbEditarea.config = function (params) {
|
|
8
|
-
// 空值处理策略
|
|
9
|
-
config.emptyClear = !!params.emptyClear
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default HbEditarea;
|
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- 常驻编辑 -->
|
|
3
|
-
<p v-if="keepEdit" class="hb-editarea">
|
|
4
|
-
<i v-if="loading" class="el-icon-loading hb-editarea__loading"></i>
|
|
5
|
-
<span v-else class="hb-editarea__form">
|
|
6
|
-
<hb-query-form
|
|
7
|
-
:formProp="{
|
|
8
|
-
prop: 'cache',
|
|
9
|
-
type: type,
|
|
10
|
-
optList: optList,
|
|
11
|
-
multiple: multiple,
|
|
12
|
-
placeholder: placeholder,
|
|
13
|
-
}"
|
|
14
|
-
:qryFormData="cache"
|
|
15
|
-
size="mini"
|
|
16
|
-
class="hb-editarea__form-item"
|
|
17
|
-
@[passType[type].event]="handleSave(false)"
|
|
18
|
-
@focus="handleFocus"
|
|
19
|
-
></hb-query-form>
|
|
20
|
-
<el-tooltip
|
|
21
|
-
v-if="error"
|
|
22
|
-
effect="dark"
|
|
23
|
-
:content="error"
|
|
24
|
-
placement="bottom"
|
|
25
|
-
>
|
|
26
|
-
<i class="el-icon-warning hb-editarea-error hb-editarea-icon"></i>
|
|
27
|
-
</el-tooltip>
|
|
28
|
-
</span>
|
|
29
|
-
</p>
|
|
30
|
-
<!-- 双击编辑 -->
|
|
31
|
-
<p v-else class="hb-editarea">
|
|
32
|
-
<span v-if="!editing" @dblclick="handleEdit" class="hb-editarea__text"
|
|
33
|
-
>{{ value }}
|
|
34
|
-
<i class="el-icon-edit hb-editarea-icon" @click="handleEdit"></i
|
|
35
|
-
></span>
|
|
36
|
-
<span v-else-if="!loading" class="hb-editarea__edit">
|
|
37
|
-
<hb-query-form
|
|
38
|
-
:formProp="{
|
|
39
|
-
prop: 'cache',
|
|
40
|
-
type: type,
|
|
41
|
-
optList: optList,
|
|
42
|
-
multiple: multiple,
|
|
43
|
-
}"
|
|
44
|
-
:qryFormData="cache"
|
|
45
|
-
size="mini"
|
|
46
|
-
class="hb-editarea__edit-input"
|
|
47
|
-
@[passType[type].event]="handleSave(false)"
|
|
48
|
-
@focus="handleFocus"
|
|
49
|
-
></hb-query-form>
|
|
50
|
-
<el-tooltip
|
|
51
|
-
v-if="error"
|
|
52
|
-
effect="dark"
|
|
53
|
-
:content="error"
|
|
54
|
-
placement="bottom"
|
|
55
|
-
>
|
|
56
|
-
<i class="el-icon-warning hb-editarea-error hb-editarea-icon"></i>
|
|
57
|
-
</el-tooltip>
|
|
58
|
-
<div v-if="border" class="hb-editarea__bg hb-editarea__bg--border"></div>
|
|
59
|
-
<div v-else class="hb-editarea__bg"></div>
|
|
60
|
-
</span>
|
|
61
|
-
<i v-if="loading" class="el-icon-loading hb-editarea__loading"></i>
|
|
62
|
-
</p>
|
|
63
|
-
</template>
|
|
64
|
-
|
|
65
|
-
<script>
|
|
66
|
-
import CONFIG from "./config.js";
|
|
67
|
-
import { bindFocus, unBindFocus } from "./simulateEvent.js";
|
|
68
|
-
export default {
|
|
69
|
-
name: "HbEditarea",
|
|
70
|
-
componentName: "HbEditarea",
|
|
71
|
-
props: {
|
|
72
|
-
keepEdit: {
|
|
73
|
-
type: Boolean,
|
|
74
|
-
default: () => false,
|
|
75
|
-
},
|
|
76
|
-
/** 传递给queryForm控件的事件 */
|
|
77
|
-
type: {
|
|
78
|
-
type: String,
|
|
79
|
-
default: () => "input",
|
|
80
|
-
},
|
|
81
|
-
optList: {
|
|
82
|
-
type: Array,
|
|
83
|
-
default: () => [],
|
|
84
|
-
},
|
|
85
|
-
multiple: {
|
|
86
|
-
type: Boolean,
|
|
87
|
-
default: () => false,
|
|
88
|
-
},
|
|
89
|
-
value: {
|
|
90
|
-
default: () => "",
|
|
91
|
-
},
|
|
92
|
-
placeholder: {
|
|
93
|
-
default: () => "请编辑内容",
|
|
94
|
-
},
|
|
95
|
-
/** 编辑时值为空时是否保存,传入true将会在清空时保存空值 */
|
|
96
|
-
emptyClear: {
|
|
97
|
-
default: () => false,
|
|
98
|
-
},
|
|
99
|
-
/** 编辑时是否显示边框 */
|
|
100
|
-
border: {
|
|
101
|
-
type: Boolean,
|
|
102
|
-
default: () => false,
|
|
103
|
-
},
|
|
104
|
-
/** 回填、保存等回调 */
|
|
105
|
-
insert: {
|
|
106
|
-
type: Function,
|
|
107
|
-
default: null,
|
|
108
|
-
},
|
|
109
|
-
change: {
|
|
110
|
-
type: Function,
|
|
111
|
-
default: null,
|
|
112
|
-
},
|
|
113
|
-
/** 校验 */
|
|
114
|
-
validate: {
|
|
115
|
-
type: Function,
|
|
116
|
-
default: null,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
data() {
|
|
120
|
-
return {
|
|
121
|
-
/** 状态 */
|
|
122
|
-
loading: false,
|
|
123
|
-
error: false,
|
|
124
|
-
editing: false,
|
|
125
|
-
/** 缓存值 */
|
|
126
|
-
cache: { cache: null },
|
|
127
|
-
/** 编辑可用的控件类型及对应的失焦事件、初始值 */
|
|
128
|
-
passType: {
|
|
129
|
-
input: { event: "blur", empty: "" },
|
|
130
|
-
select: { event: "change", empty: [] },
|
|
131
|
-
date: { event: "blur", empty: "" },
|
|
132
|
-
daterange: { event: "blur", empty: [] },
|
|
133
|
-
switch: { event: null, empty: null },
|
|
134
|
-
checkbox: { event: "change", empty: [] },
|
|
135
|
-
radio: { event: "change", empty: "" },
|
|
136
|
-
},
|
|
137
|
-
/** 即使不传入insert的类型,用值自动填充,除此之外会置空 */
|
|
138
|
-
insertType: ["input", "select", "switch", "radio", "date"],
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
computed: {
|
|
142
|
-
empty() {
|
|
143
|
-
const passTypeData = this.passType[this.type];
|
|
144
|
-
return passTypeData ? passTypeData.empty : null;
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
methods: {
|
|
148
|
-
/** api */
|
|
149
|
-
/**
|
|
150
|
-
* @function validateEdit 对外提供一个校验方法,仅在keepEdit=true时有效,会使用validate传参校验控件的输入
|
|
151
|
-
* @param {Function} callback 失败时传入错误
|
|
152
|
-
*/
|
|
153
|
-
validateEdit(callback) {
|
|
154
|
-
if (this.keepEdit) {
|
|
155
|
-
this.cacheValidate(typeof callback === "function" ? callback : null);
|
|
156
|
-
} else {
|
|
157
|
-
typeof callback === "function" &&
|
|
158
|
-
callback(new Error("当前控件不支持手动校验"));
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
/** methods */
|
|
162
|
-
/**
|
|
163
|
-
* @function reset 重置控件,回到初始状态
|
|
164
|
-
*/
|
|
165
|
-
reset() {
|
|
166
|
-
this.$set(this.cache, "cache", null);
|
|
167
|
-
this.editing = false;
|
|
168
|
-
this.loading = false;
|
|
169
|
-
this.error = "";
|
|
170
|
-
},
|
|
171
|
-
/**
|
|
172
|
-
* @function cacheValidate 校验cache,并显示错误
|
|
173
|
-
* @param {Function} callback 校验成功回调,失败时传入错误
|
|
174
|
-
*/
|
|
175
|
-
cacheValidate(callback) {
|
|
176
|
-
const cache = this.cache.cache;
|
|
177
|
-
if (typeof this.validate === "function") {
|
|
178
|
-
this.loading = true;
|
|
179
|
-
this.validate((error) => {
|
|
180
|
-
this.loading = false;
|
|
181
|
-
if (Object.prototype.toString.call(error) === "[object Error]") {
|
|
182
|
-
this.error = String(error.message);
|
|
183
|
-
typeof callback === "function" && callback(error);
|
|
184
|
-
} else {
|
|
185
|
-
this.error = "";
|
|
186
|
-
typeof callback === "function" && callback();
|
|
187
|
-
}
|
|
188
|
-
}, cache);
|
|
189
|
-
} else {
|
|
190
|
-
typeof callback === "function" && callback();
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
/** events */
|
|
194
|
-
/**
|
|
195
|
-
* @event handleEdit 开始编辑单元格
|
|
196
|
-
*/
|
|
197
|
-
handleEdit() {
|
|
198
|
-
// 进入编辑状态,清空上次的cache
|
|
199
|
-
if (this.editing) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
this.reset();
|
|
203
|
-
this.editing = true;
|
|
204
|
-
// 回填值处理
|
|
205
|
-
if (typeof this.insert === "function") {
|
|
206
|
-
// 优先采用传入的insert回填值
|
|
207
|
-
this.$set(this.cache, "cache", this.insert(this.value));
|
|
208
|
-
} else if (this.insertType.indexOf(this.type) !== -1) {
|
|
209
|
-
// 部分类型回填value
|
|
210
|
-
this.$set(this.cache, "cache", this.value);
|
|
211
|
-
} else {
|
|
212
|
-
// 其他情况置空
|
|
213
|
-
this.$set(this.cache, "cache", this.empty);
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
/**
|
|
217
|
-
* @event handleFocus 获得焦点时清空error
|
|
218
|
-
*/
|
|
219
|
-
handleFocus() {
|
|
220
|
-
this.error = "";
|
|
221
|
-
},
|
|
222
|
-
/**
|
|
223
|
-
* @event handleSave 编辑单元格完成
|
|
224
|
-
* @param {Boolean} simulation 模拟标记,模拟失焦触发时传入true,避免多选等控件持续触发change造成错误的保存时机
|
|
225
|
-
*/
|
|
226
|
-
handleSave(simulation) {
|
|
227
|
-
const cache = this.cache.cache;
|
|
228
|
-
if (this.keepEdit) {
|
|
229
|
-
// keepEdit状态,true直接进行保存并同时校验
|
|
230
|
-
if (simulation || this.loading) {
|
|
231
|
-
// 不处理:全局失焦或loading状态不处理
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
// 多选控件change时保存不影响
|
|
235
|
-
// if (this.multiple && !simulation) {
|
|
236
|
-
// return;
|
|
237
|
-
// }
|
|
238
|
-
this.cacheValidate(() => {
|
|
239
|
-
// 无论成功失败都改变值
|
|
240
|
-
this.$emit("update:value", cache);
|
|
241
|
-
});
|
|
242
|
-
} else {
|
|
243
|
-
// 非keepEdit状态完全由组件接管校验
|
|
244
|
-
if (!this.editing || this.loading) {
|
|
245
|
-
// 不处理:未处于编辑状态或loading状态不处理
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
if (this.multiple && !simulation) {
|
|
249
|
-
// 多选类型控件仅全局失焦时处理
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
// 失焦保存处理
|
|
253
|
-
const handler = (er) => {
|
|
254
|
-
if (er) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
// 1.如果值没有变化不触发事件
|
|
258
|
-
if (cache === this.value) {
|
|
259
|
-
this.editing = false;
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
// 2.值为空根据传参决定是否保存空值
|
|
263
|
-
if (cache === this.empty) {
|
|
264
|
-
if (CONFIG.emptyClear || this.emptyClear) {
|
|
265
|
-
this.$emit("update:value", this.empty);
|
|
266
|
-
}
|
|
267
|
-
this.editing = false;
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
// 3.进行保存
|
|
271
|
-
if (typeof this.change === "function") {
|
|
272
|
-
// 3.1如果传入了change函数,将会由change接管处理,不再对value赋值
|
|
273
|
-
this.loading = true;
|
|
274
|
-
this.change(() => {
|
|
275
|
-
this.reset();
|
|
276
|
-
}, cache);
|
|
277
|
-
} else {
|
|
278
|
-
// 3.2未传入change将直接对value进行赋值;注意外面需要使用.sync修饰符绑定value
|
|
279
|
-
this.$emit("update:value", cache);
|
|
280
|
-
this.editing = false;
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
// 校验成功进行保存,失败进入error状态
|
|
284
|
-
this.cacheValidate(handler);
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
},
|
|
288
|
-
mounted() {
|
|
289
|
-
// 配置点击hb-editarea以外的区域触发focus
|
|
290
|
-
// configFocus("hb-editarea__wrap");
|
|
291
|
-
// if (this.$el.parentNode.className.indexOf("hb-editarea__wrap") === -1) {
|
|
292
|
-
// this.$el.parentNode.className += " hb-editarea__wrap";
|
|
293
|
-
// }
|
|
294
|
-
// 测试
|
|
295
|
-
unBindFocus(this.$el);
|
|
296
|
-
bindFocus(this.$el, () => {
|
|
297
|
-
this.handleSave(true);
|
|
298
|
-
});
|
|
299
|
-
if (this.keepEdit) {
|
|
300
|
-
this.$set(this.cache, "cache", this.value);
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
};
|
|
304
|
-
</script>
|