@lambo-design/variant-form 2.2.9-beta.0 → 2.2.9-beta.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.
- package/README.md +201 -0
- package/babel.config.js +5 -0
- package/dist/lib/VFormDesigner.common-report.html +53 -0
- package/dist/lib/VFormDesigner.common.js +123773 -0
- package/dist/lib/VFormDesigner.common.js.map +1 -0
- package/dist/lib/VFormDesigner.css +1 -0
- package/dist/lib/VFormDesigner.umd-report.html +53 -0
- package/dist/lib/VFormDesigner.umd.js +123783 -0
- package/dist/lib/VFormDesigner.umd.js.map +1 -0
- package/dist/lib/VFormDesigner.umd.min-report.html +53 -0
- package/dist/lib/VFormDesigner.umd.min.js +222 -0
- package/dist/lib/demo.html +10 -0
- package/dist/lib/img/indicator-card-header.7291bcc9.png +0 -0
- package/dist/lib/img/lan_navigator.53090c9d.png +0 -0
- package/dist/lib/img/layout-header-bg-canglan.b1d97e4e.png +0 -0
- package/dist/lib/img/layout-header-bg-cuiwei.67019b6d.png +0 -0
- package/dist/lib/img/lv_navigator.f07fb393.png +0 -0
- package/index_template/index_dev.html +19 -0
- package/index_template/index_prod.html +28 -0
- package/install-render.js +29 -0
- package/install.js +41 -0
- package/jsconfig.json +10 -0
- package/license.txt +8 -0
- package/package.json +10 -4
- package/public/favicon.ico +0 -0
- package/public/index.html +19 -0
- package/src/App.vue +45 -0
- package/src/components/form-designer/designer.js +1 -0
- package/src/components/form-designer/form-widget/field-widget/organ-select-widget.vue +254 -0
- package/src/components/form-designer/form-widget/field-widget/relation-form-widget.vue +397 -0
- package/src/components/form-designer/form-widget/field-widget/sub-form-widget.vue +660 -0
- package/src/components/form-designer/form-widget/field-widget/user-select-widget.vue +333 -0
- package/src/components/form-designer/form-widget/index.vue +1 -1
- package/src/components/form-designer/index.vue +14 -12
- package/src/components/form-designer/setting-panel/form-setting.vue +59 -60
- package/src/components/form-designer/setting-panel/index.vue +2 -0
- package/src/components/form-designer/setting-panel/property-editor/allowMultiple-editor.vue +24 -0
- package/src/components/form-designer/setting-panel/property-editor/border-editor.vue +1 -1
- package/src/components/form-designer/setting-panel/property-editor/buttonStyle-editor.vue +1 -1
- package/src/components/form-designer/setting-panel/property-editor/clearable-editor.vue +1 -1
- package/src/components/form-designer/setting-panel/property-editor/displayFields-editor.vue +91 -0
- package/src/components/form-designer/setting-panel/property-editor/displayStyle-editor.vue +1 -1
- package/src/components/form-designer/setting-panel/property-editor/field-relation-form/relation-form-defaultValue-editor.vue +18 -0
- package/src/components/form-designer/setting-panel/property-editor/filterable-editor.vue +1 -1
- package/src/components/form-designer/setting-panel/property-editor/multipleLimit-editor.vue +1 -1
- package/src/components/form-designer/setting-panel/property-editor/name-editor.vue +2 -2
- package/src/components/form-designer/setting-panel/property-editor/operList-editor.vue +64 -0
- package/src/components/form-designer/setting-panel/property-editor/placeholder-editor.vue +1 -1
- package/src/components/form-designer/setting-panel/property-editor/relationForm-editor.vue +74 -0
- package/src/components/form-designer/setting-panel/property-editor/relationItems-editor.vue +91 -0
- package/src/components/form-designer/setting-panel/property-editor/relationType-editor.vue +67 -0
- package/src/components/form-designer/setting-panel/property-editor/rootOrgan-editor.vue +248 -0
- package/src/components/form-designer/setting-panel/property-editor/size-editor.vue +5 -5
- package/src/components/form-designer/setting-panel/property-editor/subFormId-editor.vue +74 -0
- package/src/components/form-designer/setting-panel/propertyRegister.js +144 -133
- package/src/components/form-designer/toolbar-panel/index.vue +11 -10
- package/src/components/form-designer/widget-panel/index.vue +11 -11
- package/src/components/form-designer/widget-panel/widgetsConfig.js +425 -297
- package/src/extension/extension-loader.js +1 -1
- package/src/icons/svg/relation-form-field.svg +1 -0
- package/src/lang/en-US.js +39 -0
- package/src/lang/zh-CN.js +42 -3
- package/src/main.js +29 -0
- package/src/utils/config.js +1 -1
- package/src/utils/util.js +35 -1
- package/vue.config.js +93 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="renderer" content="webkit">
|
|
7
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
8
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
9
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<noscript>
|
|
13
|
+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
14
|
+
</noscript>
|
|
15
|
+
|
|
16
|
+
<div id="app"></div>
|
|
17
|
+
<!-- built files will be auto injected -->
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="renderer" content="webkit">
|
|
7
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
8
|
+
<!-- 禁止浏览器缓存index.html begin -->
|
|
9
|
+
<meta http-equiv="Expires" content="0">
|
|
10
|
+
<meta http-equiv="Pragma" content="no-cache">
|
|
11
|
+
<meta http-equiv="Cache-control" content="no-cache">
|
|
12
|
+
<meta http-equiv="Cache" content="no-cache">
|
|
13
|
+
<!-- 禁止浏览器缓存index.html end -->
|
|
14
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
15
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
16
|
+
<link rel="stylesheet" href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/element-ui/2.15.7/theme-chalk/index.min.css">
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<noscript>
|
|
20
|
+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
21
|
+
</noscript>
|
|
22
|
+
<div id="app"></div>
|
|
23
|
+
<!-- built files will be auto injected -->
|
|
24
|
+
|
|
25
|
+
<script src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.min.js"></script>
|
|
26
|
+
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/element-ui/2.15.7/index.min.js"></script>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import VFormRender from '@/components/form-render/index.vue'
|
|
2
|
+
import {loadExtension} from "@/extension/extension-loader"
|
|
3
|
+
import axios from "axios"
|
|
4
|
+
|
|
5
|
+
loadExtension()
|
|
6
|
+
|
|
7
|
+
VFormRender.install = function (Vue) {
|
|
8
|
+
Vue.component(VFormRender.name, VFormRender)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const components = [
|
|
12
|
+
VFormRender
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const install = (Vue) => {
|
|
16
|
+
window.axios = axios
|
|
17
|
+
components.forEach(component => {
|
|
18
|
+
Vue.component(component.name, component)
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (typeof window !== 'undefined' && window.Vue) { /* script方式引入时主动调用install方法!! */
|
|
23
|
+
install(window.Vue);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
install,
|
|
28
|
+
VFormRender
|
|
29
|
+
}
|
package/install.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
|
|
3
|
+
import VFormDesigner from '@/components/form-designer/index.vue'
|
|
4
|
+
import VFormRender from '@/components/form-render/index.vue'
|
|
5
|
+
import {loadExtension} from "@/extension/extension-loader"
|
|
6
|
+
|
|
7
|
+
import '@/utils/directive'
|
|
8
|
+
import '@/icons'
|
|
9
|
+
import '@/iconfont/iconfont.css'
|
|
10
|
+
|
|
11
|
+
loadExtension()
|
|
12
|
+
|
|
13
|
+
VFormDesigner.install = function (Vue) {
|
|
14
|
+
Vue.component(VFormDesigner.name, VFormDesigner)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
VFormRender.install = function (Vue) {
|
|
18
|
+
Vue.component(VFormRender.name, VFormRender)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const components = [
|
|
22
|
+
VFormDesigner,
|
|
23
|
+
VFormRender
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
const install = (Vue) => {
|
|
27
|
+
window.axios = axios
|
|
28
|
+
components.forEach(component => {
|
|
29
|
+
Vue.component(component.name, component)
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (typeof window !== 'undefined' && window.Vue) { /* script方式引入时主动调用install方法!! */
|
|
34
|
+
install(window.Vue);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
install,
|
|
39
|
+
VFormDesigner,
|
|
40
|
+
VFormRender
|
|
41
|
+
}
|
package/jsconfig.json
ADDED
package/license.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Variant Form 许可条款 1.0
|
|
2
|
+
|
|
3
|
+
1. 免责声明:任何情况下根据任何法律,本作者不对用户因使用VariantForm产生的侵权、数据损坏丢失、软硬件故障和违法犯罪等问题承担任何责任;
|
|
4
|
+
2. 禁止任何用户对VariantForm进行简单包装后,即声称为自己的产品、销售源码获利;
|
|
5
|
+
3. VariantForm为开源项目,获取到源代码的用户可自由修改源码供自身开发使用,可分发build构建后的库代码,也可分发VariantForm源代码(需保留文件头部的作者声明),本作者保留VariantForm的原始著作权;
|
|
6
|
+
4. 个人或公司用户均可将VariantForm项目应用于商业项目开发,为支持本项目持续开发,请尽量购买VariantForm Pro版源码订阅更新服务;
|
|
7
|
+
5. 如果你不同意本许可条款,请勿使用VariantForm;任何情况下,一旦实际使用VariantForm,则代表你已确定完全同意本许可条款;
|
|
8
|
+
6. 条款内容结束。
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambo-design/variant-form",
|
|
3
|
-
"version": "2.2.9-beta.
|
|
3
|
+
"version": "2.2.9-beta.1",
|
|
4
4
|
"description": "VForm Online Form Designer",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/VFormDesigner.umd.min.js",
|
|
6
6
|
"author": "lambo",
|
|
7
7
|
"license": "ISC",
|
|
8
8
|
"publishConfig": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"file-saver": "^2.0.5",
|
|
18
18
|
"vue": "^2.6.11",
|
|
19
19
|
"vue2-editor": "^2.10.2",
|
|
20
|
-
"vuedraggable": "^2.24.3"
|
|
20
|
+
"vuedraggable": "^2.24.3",
|
|
21
|
+
"@lambo-design/shared": "^1.0.0-beta.282"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@vue/cli-plugin-babel": "~4.5.0",
|
|
@@ -59,6 +60,11 @@
|
|
|
59
60
|
"release-minor": "standard-version --release-as minor",
|
|
60
61
|
"release-patch": "standard-version --release-as patch",
|
|
61
62
|
"release-beta": "standard-version --prerelease beta",
|
|
62
|
-
"re-publish": "pnpm publish --access public --no-git-checks"
|
|
63
|
+
"re-publish": "pnpm lib && pnpm publish --access public --no-git-checks",
|
|
64
|
+
"serve": "vue-cli-service serve --open src/main.js",
|
|
65
|
+
"build": "vue-cli-service build --report --dest dist/build",
|
|
66
|
+
"lib": "vue-cli-service build --report --target lib --dest dist/lib --name VFormDesigner install.js",
|
|
67
|
+
"lib-render": "vue-cli-service build --report --target lib --dest dist/lib-render --name VFormRender install-render.js",
|
|
68
|
+
"lint": "vue-cli-service lint"
|
|
63
69
|
}
|
|
64
70
|
}
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="renderer" content="webkit">
|
|
7
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
8
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
9
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<noscript>
|
|
13
|
+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
14
|
+
</noscript>
|
|
15
|
+
|
|
16
|
+
<div id="app"></div>
|
|
17
|
+
<!-- built files will be auto injected -->
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
package/src/App.vue
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="app">
|
|
3
|
+
<VFormDesigner ref="vfDesignerRef" :global-dsv="globalDsv">
|
|
4
|
+
<template #customToolButtons>
|
|
5
|
+
<el-button type="text" @click="printFormJson">测试按钮</el-button>
|
|
6
|
+
</template>
|
|
7
|
+
</VFormDesigner>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
import VFormDesigner from './components/form-designer/index.vue'
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
name: 'App',
|
|
16
|
+
components: {
|
|
17
|
+
VFormDesigner,
|
|
18
|
+
},
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
designerConfig: {
|
|
22
|
+
resetFormJson: false,
|
|
23
|
+
toolbarMaxWidth: 490,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
//全局数据源变量
|
|
27
|
+
globalDsv: {
|
|
28
|
+
testApiHost: 'http://www.test.com/api',
|
|
29
|
+
testPort: 8080,
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
methods: {
|
|
34
|
+
printFormJson() {
|
|
35
|
+
console.log( this.$refs.vfDesignerRef.getFormJson() )
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<style lang="scss">
|
|
42
|
+
#app {
|
|
43
|
+
height: 100%;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<form-item-wrapper :designer="designer" :field="field" :rules="rules" :design-state="designState"
|
|
3
|
+
:parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
|
|
4
|
+
:sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
|
|
5
|
+
<div class="organ-select-wrapper">
|
|
6
|
+
<el-input
|
|
7
|
+
ref="inputRef"
|
|
8
|
+
v-model="fieldModel"
|
|
9
|
+
:placeholder="field.options.placeholder"
|
|
10
|
+
:size="field.options.size"
|
|
11
|
+
readonly
|
|
12
|
+
@click="popoverVisible = true"
|
|
13
|
+
@focus="popoverVisible = true">
|
|
14
|
+
<i slot="suffix" class="el-icon-s-grid el-input__icon" @click.stop="handleClickCustomEvent"></i>
|
|
15
|
+
</el-input>
|
|
16
|
+
|
|
17
|
+
<el-popover
|
|
18
|
+
v-model="popoverVisible"
|
|
19
|
+
placement="bottom-start"
|
|
20
|
+
trigger="click"
|
|
21
|
+
:width="popoverWidth">
|
|
22
|
+
<div v-if="!treeData || treeData.length === 0">
|
|
23
|
+
暂无数据,请选择根组织!
|
|
24
|
+
</div>
|
|
25
|
+
<div class="org-selector-container">
|
|
26
|
+
<el-tree
|
|
27
|
+
v-if="popoverVisible && treeData.length > 0"
|
|
28
|
+
ref="orgTree"
|
|
29
|
+
lazy
|
|
30
|
+
:load="loadNode"
|
|
31
|
+
:data="treeData"
|
|
32
|
+
:props="defaultProps"
|
|
33
|
+
:show-checkbox="field.options.allowMultiple"
|
|
34
|
+
check-strictly
|
|
35
|
+
@node-click="handleNodeClick"
|
|
36
|
+
@check="handleCheck"
|
|
37
|
+
style="margin-top: 10px; max-height: 400px; overflow: auto">
|
|
38
|
+
</el-tree>
|
|
39
|
+
</div>
|
|
40
|
+
</el-popover>
|
|
41
|
+
</div>
|
|
42
|
+
<el-dialog :title="field.options.label || '组织'" :visible.sync="dialogVisible" append-to-body>
|
|
43
|
+
<div v-if="!treeData || treeData.length === 0">
|
|
44
|
+
暂无数据,请选择根组织!
|
|
45
|
+
</div>
|
|
46
|
+
<el-tree
|
|
47
|
+
v-if="dialogVisible && treeData.length > 0"
|
|
48
|
+
ref="dialogTree"
|
|
49
|
+
lazy
|
|
50
|
+
:load="loadNode"
|
|
51
|
+
:data="treeData"
|
|
52
|
+
:props="defaultProps"
|
|
53
|
+
:show-checkbox="field.options.allowMultiple"
|
|
54
|
+
check-strictly
|
|
55
|
+
@node-click="handleNodeClick"
|
|
56
|
+
@check="handleCheck"
|
|
57
|
+
style="margin-top: 10px; height: 60vh; overflow: auto">
|
|
58
|
+
</el-tree>
|
|
59
|
+
<template slot="footer">
|
|
60
|
+
<div class="dialog-footer">
|
|
61
|
+
<el-button type="primary" @click="onOk">确定</el-button>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
64
|
+
</el-dialog>
|
|
65
|
+
</form-item-wrapper>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script>
|
|
69
|
+
import FormItemWrapper from './form-item-wrapper'
|
|
70
|
+
import emitter from '@/utils/emitter'
|
|
71
|
+
import i18n, {translate} from "@/utils/i18n";
|
|
72
|
+
import fieldMixin from "@/components/form-designer/form-widget/field-widget/fieldMixin";
|
|
73
|
+
import ajax from "@lambo-design/shared/utils/ajax";
|
|
74
|
+
|
|
75
|
+
export default {
|
|
76
|
+
name: "organ-select-widget",
|
|
77
|
+
componentName: 'FieldWidget', //必须固定为FieldWidget,用于接收父级组件的broadcast事件
|
|
78
|
+
mixins: [emitter, fieldMixin, i18n],
|
|
79
|
+
props: {
|
|
80
|
+
field: Object,
|
|
81
|
+
parentWidget: Object,
|
|
82
|
+
parentList: Array,
|
|
83
|
+
indexOfParentList: Number,
|
|
84
|
+
designer: Object,
|
|
85
|
+
designState: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: false
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
subFormRowIndex: { /* 子表单组件行索引,从0开始计数 */
|
|
91
|
+
type: Number,
|
|
92
|
+
default: -1
|
|
93
|
+
},
|
|
94
|
+
subFormColIndex: { /* 子表单组件列索引,从0开始计数 */
|
|
95
|
+
type: Number,
|
|
96
|
+
default: -1
|
|
97
|
+
},
|
|
98
|
+
subFormRowId: { /* 子表单组件行Id,唯一id且不可变 */
|
|
99
|
+
type: String,
|
|
100
|
+
default: ''
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
components: {
|
|
104
|
+
FormItemWrapper,
|
|
105
|
+
},
|
|
106
|
+
inject: ['refList', 'formConfig', 'getDesignerConfig', 'globalOptionData', 'globalModel'],
|
|
107
|
+
data() {
|
|
108
|
+
return {
|
|
109
|
+
serverContext: '/dida-manage-server',
|
|
110
|
+
oldFieldValue: null, //field组件change之前的值
|
|
111
|
+
fieldModel: null,
|
|
112
|
+
rules: [],
|
|
113
|
+
treeData: [],
|
|
114
|
+
filteredTreeData: [],
|
|
115
|
+
popoverVisible: false,
|
|
116
|
+
dialogVisible: false,
|
|
117
|
+
searchText: '',
|
|
118
|
+
defaultProps: {
|
|
119
|
+
children: 'children',
|
|
120
|
+
label: 'bizOrganName',
|
|
121
|
+
isLeaf: (data, node) => {
|
|
122
|
+
return data.isLeaf === 'true';
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
popoverWidth: 0
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
computed: {
|
|
129
|
+
},
|
|
130
|
+
beforeCreate() {
|
|
131
|
+
/* 这里不能访问方法和属性!! */
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
created() {
|
|
135
|
+
/* 注意:子组件mounted在父组件created之后、父组件mounted之前触发,故子组件mounted需要用到的prop
|
|
136
|
+
需要在父组件created中初始化!! */
|
|
137
|
+
this.initFieldModel()
|
|
138
|
+
this.registerToRefList()
|
|
139
|
+
this.initEventHandler()
|
|
140
|
+
this.buildFieldRules()
|
|
141
|
+
|
|
142
|
+
this.handleOnCreated()
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
mounted() {
|
|
146
|
+
this.handleOnMounted()
|
|
147
|
+
|
|
148
|
+
this.initData()
|
|
149
|
+
|
|
150
|
+
//点击其他地方隐藏popover
|
|
151
|
+
this.documentClickHandler = (e) => {
|
|
152
|
+
// 判断popover是否可见
|
|
153
|
+
if (this.popoverVisible) {
|
|
154
|
+
// 获取popover元素
|
|
155
|
+
const popoverEl = document.querySelector('.el-popover[aria-hidden="false"]');
|
|
156
|
+
// 获取输入框元素
|
|
157
|
+
const inputEl = this.$refs.inputRef.$el;
|
|
158
|
+
|
|
159
|
+
// 判断点击位置是否在popover内部或输入框内部
|
|
160
|
+
if (popoverEl && !popoverEl.contains(e.target) && !inputEl.contains(e.target)) {
|
|
161
|
+
this.popoverVisible = false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
document.addEventListener('click', this.documentClickHandler);
|
|
166
|
+
},
|
|
167
|
+
beforeDestroy() {
|
|
168
|
+
this.unregisterFromRefList()
|
|
169
|
+
document.removeEventListener('click', this.documentClickHandler);
|
|
170
|
+
},
|
|
171
|
+
methods: {
|
|
172
|
+
initData(){
|
|
173
|
+
this.$nextTick(() => {
|
|
174
|
+
const inputWidth = this.$refs.inputRef.$el.offsetWidth
|
|
175
|
+
const popoverPadding = 24
|
|
176
|
+
this.popoverWidth = Math.max(0, inputWidth - popoverPadding)
|
|
177
|
+
})
|
|
178
|
+
this.getOrgan()
|
|
179
|
+
},
|
|
180
|
+
getOrgan(){
|
|
181
|
+
if (this.field.options.rootOrgan){
|
|
182
|
+
const params = {
|
|
183
|
+
organId: this.field.options.rootOrgan,
|
|
184
|
+
organTreeType: this.field.options.organTreeType || '00',
|
|
185
|
+
}
|
|
186
|
+
ajax.get(this.serverContext + '/manage/organ/getOrganDetail', {params: params}).then((resp) => {
|
|
187
|
+
if (resp.data && (resp.data.code == 1 || resp.data.code == 200)){
|
|
188
|
+
this.treeData = [resp.data.data]
|
|
189
|
+
}
|
|
190
|
+
}).catch((err) => {
|
|
191
|
+
console.error(err)
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
async loadNode(node, resolve) {
|
|
196
|
+
if (node.level === 0) {
|
|
197
|
+
const roots = this.treeData.filter(item => item.bizOrganId === this.field.options.rootOrgan)
|
|
198
|
+
return resolve(roots)
|
|
199
|
+
}
|
|
200
|
+
const params = {
|
|
201
|
+
parentId: node.data.bizOrganId,
|
|
202
|
+
organTreeType: this.field.options.organTreeType || '00',
|
|
203
|
+
manageUnitId: this.field.options.manageUnitId
|
|
204
|
+
}
|
|
205
|
+
ajax.get(this.serverContext + '/manage/organ/getOrgChildren', {params: params}).then((resp) => {
|
|
206
|
+
if (resp.data && (resp.data.code == 1 || resp.data.code == 200)){
|
|
207
|
+
resolve(resp.data.data)
|
|
208
|
+
}
|
|
209
|
+
}).catch((err) => {
|
|
210
|
+
console.error(err)
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
handleCheck(data, checked) {
|
|
214
|
+
if (!this.field.options.allowMultiple) return
|
|
215
|
+
this.fieldModel = checked ? checked.checkedNodes.map(node => node.bizOrganName).join(',') : '';
|
|
216
|
+
},
|
|
217
|
+
handleNodeClick(data) {
|
|
218
|
+
if (this.field.options.allowMultiple) return
|
|
219
|
+
this.fieldModel = data.bizOrganName
|
|
220
|
+
this.popoverVisible = false
|
|
221
|
+
},
|
|
222
|
+
handleClickCustomEvent(event) {
|
|
223
|
+
this.dialogVisible = true
|
|
224
|
+
},
|
|
225
|
+
onOk(event) {
|
|
226
|
+
this.dialogVisible = false
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
watch: {
|
|
230
|
+
'field.options': {
|
|
231
|
+
handler(newVal, oldVal) {
|
|
232
|
+
this.initData();
|
|
233
|
+
},
|
|
234
|
+
deep: true
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
}
|
|
238
|
+
</script>
|
|
239
|
+
|
|
240
|
+
<style lang="scss" scoped>
|
|
241
|
+
.organ-select-wrapper {
|
|
242
|
+
position: relative;
|
|
243
|
+
width: 100%;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.org-selector-container {
|
|
247
|
+
width: 100%;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
::v-deep .el-popover {
|
|
251
|
+
min-width: 0 !important;
|
|
252
|
+
padding: 12px;
|
|
253
|
+
}
|
|
254
|
+
</style>
|