@ibiz-template/mob-vue3-components 0.0.10 → 0.0.11
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/dist/index.min.css +1 -1
- package/dist/index.system.min.js +2 -2
- package/dist/index.system.min.js.map +1 -1
- package/dist/tree-3raJSAQR.js +2 -0
- package/dist/tree-3raJSAQR.js.map +1 -0
- package/es/control/tree/tree.d.ts +1 -1
- package/es/control/tree/tree.mjs +7 -7
- package/es/editor/cascader/ibiz-cascader/ibiz-cascader.d.ts +8 -0
- package/es/editor/check-box/ibiz-checkbox/ibiz-checkbox.d.ts +8 -0
- package/es/editor/check-box-list/ibiz-checkbox-list/ibiz-checkbox-list.d.ts +8 -0
- package/es/editor/color-picker/ibiz-color-picker/ibiz-color-picker.d.ts +8 -0
- package/es/editor/data-picker/ibiz-mpicker/ibiz-mpicker.d.ts +8 -0
- package/es/editor/data-picker/ibiz-picker/ibiz-picker.d.ts +8 -0
- package/es/editor/data-picker/ibiz-picker-select-view/ibiz-picker-select-view.d.ts +8 -0
- package/es/editor/date-picker/ibiz-date-picker/ibiz-date-picker.d.ts +8 -0
- package/es/editor/date-range/ibiz-date-range-picker/ibiz-date-range-picker.d.ts +8 -0
- package/es/editor/dropdown-list/ibiz-dropdown/ibiz-dropdown.d.ts +8 -0
- package/es/editor/dropdown-list/ibiz-dropdown-list/ibiz-dropdown-list.d.ts +8 -0
- package/es/editor/number-range/ibiz-number-range-picker/ibiz-number-range-picker.d.ts +8 -0
- package/es/editor/radio-button-list/ibiz-radio/ibiz-radio.d.ts +8 -0
- package/es/editor/rate/ibiz-rate/ibiz-rate.d.ts +8 -0
- package/es/editor/slider/ibiz-slider/ibiz-slider.d.ts +8 -0
- package/es/editor/span/span/span.d.ts +8 -0
- package/es/editor/span/span-link/span-link.d.ts +8 -0
- package/es/editor/stepper/ibiz-stepper/ibiz-stepper.d.ts +8 -0
- package/es/editor/switch/ibiz-switch/ibiz-switch.d.ts +8 -0
- package/es/editor/text-box/ibiz-input-number/ibiz-input-number.d.ts +8 -0
- package/es/editor/text-box/input/input.d.ts +8 -0
- package/es/editor/upload/ibiz-carousel/ibiz-carousel.d.ts +8 -0
- package/es/editor/upload/ibiz-file-upload/ibiz-file-upload.d.ts +8 -0
- package/es/editor/upload/ibiz-image-select/ibiz-image-select.d.ts +8 -0
- package/es/editor/upload/ibiz-image-upload/ibiz-image-upload.d.ts +8 -0
- package/es/index.mjs +2 -1
- package/es/util/directive/loading.mjs +10 -1
- package/es/util/loading-util/loading-util.mjs +6 -1
- package/es/util/message-util/message-util.d.ts +4 -4
- package/es/util/message-util/message-util.mjs +13 -13
- package/es/view-engine/mob-edit-view.engine.d.ts +2 -2
- package/es/view-engine/mob-edit-view.engine.mjs +2 -2
- package/es/view-engine/mob-wf-dyna-action-view.engine.mjs +1 -1
- package/es/view-engine/mob-wf-dyna-edit-view.engine.mjs +1 -1
- package/lib/control/tree/tree.cjs +7 -7
- package/lib/index.cjs +1 -0
- package/lib/util/directive/loading.cjs +10 -1
- package/lib/util/loading-util/loading-util.cjs +6 -1
- package/lib/util/message-util/message-util.cjs +12 -12
- package/lib/view-engine/mob-edit-view.engine.cjs +2 -2
- package/lib/view-engine/mob-wf-dyna-action-view.engine.cjs +1 -1
- package/lib/view-engine/mob-wf-dyna-edit-view.engine.cjs +1 -1
- package/package.json +7 -7
- package/dist/tree-xaVRfp-8.js +0 -2
- package/dist/tree-xaVRfp-8.js.map +0 -1
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import { useNamespace } from '@ibiz-template/vue3-util';
|
|
1
2
|
import { showLoadingToast } from 'vant';
|
|
2
3
|
|
|
3
4
|
"use strict";
|
|
4
5
|
const INSTANCE_KEY = Symbol("vanLoading");
|
|
5
6
|
const createInstance = (el) => {
|
|
6
|
-
const
|
|
7
|
+
const ns = useNamespace("loading");
|
|
8
|
+
const options = {
|
|
9
|
+
message: "\u52A0\u8F7D\u4E2D...",
|
|
10
|
+
forbidClick: true,
|
|
11
|
+
teleport: el,
|
|
12
|
+
className: ns.b(),
|
|
13
|
+
loadingType: "spinner",
|
|
14
|
+
overlayClass: ns.e("overlay")
|
|
15
|
+
};
|
|
7
16
|
el[INSTANCE_KEY] = {
|
|
8
17
|
instance: showLoadingToast(options)
|
|
9
18
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useNamespace } from '@ibiz-template/vue3-util';
|
|
1
2
|
import { showLoadingToast } from 'vant';
|
|
2
3
|
|
|
3
4
|
"use strict";
|
|
@@ -41,10 +42,14 @@ class LoadingUtil {
|
|
|
41
42
|
* @date 2022-12-29 15:12:26
|
|
42
43
|
*/
|
|
43
44
|
show() {
|
|
45
|
+
const ns = useNamespace("loading");
|
|
44
46
|
if (this.count === 0) {
|
|
45
47
|
this.loading = showLoadingToast({
|
|
46
48
|
message: "\u52A0\u8F7D\u4E2D...",
|
|
47
|
-
forbidClick: true
|
|
49
|
+
forbidClick: true,
|
|
50
|
+
className: ns.b(),
|
|
51
|
+
loadingType: "spinner",
|
|
52
|
+
overlayClass: ns.e("overlay")
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
this.count += 1;
|
|
@@ -9,8 +9,8 @@ import { IMessageUtil } from '@ibiz-template/runtime';
|
|
|
9
9
|
* @implements {IMessageUtil}
|
|
10
10
|
*/
|
|
11
11
|
export declare class MessageUtil implements IMessageUtil {
|
|
12
|
-
info(msg: string, duration?: number,
|
|
13
|
-
success(msg: string, duration?: number,
|
|
14
|
-
warning(msg: string, duration?: number,
|
|
15
|
-
error(msg: string, duration?: number,
|
|
12
|
+
info(msg: string, duration?: number, _closable?: boolean): void;
|
|
13
|
+
success(msg: string, duration?: number, _closable?: boolean): void;
|
|
14
|
+
warning(msg: string, duration?: number, _closable?: boolean): void;
|
|
15
|
+
error(msg: string, duration?: number, _closable?: boolean): void;
|
|
16
16
|
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { showNotify } from 'vant';
|
|
2
2
|
|
|
3
3
|
"use strict";
|
|
4
4
|
class MessageUtil {
|
|
5
|
-
info(msg, duration,
|
|
6
|
-
|
|
5
|
+
info(msg, duration, _closable) {
|
|
6
|
+
showNotify({
|
|
7
7
|
message: msg,
|
|
8
8
|
duration: duration != null ? duration * 1e3 : 1500,
|
|
9
|
-
|
|
9
|
+
type: "primary"
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
success(msg, duration,
|
|
13
|
-
|
|
12
|
+
success(msg, duration, _closable) {
|
|
13
|
+
showNotify({
|
|
14
14
|
message: msg,
|
|
15
15
|
duration: duration != null ? duration * 1e3 : 1500,
|
|
16
|
-
|
|
16
|
+
type: "success"
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
warning(msg, duration,
|
|
20
|
-
|
|
19
|
+
warning(msg, duration, _closable) {
|
|
20
|
+
showNotify({
|
|
21
21
|
message: msg,
|
|
22
22
|
duration: duration != null ? duration * 1e3 : 1500,
|
|
23
|
-
|
|
23
|
+
type: "warning"
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
error(msg, duration,
|
|
27
|
-
|
|
26
|
+
error(msg, duration, _closable) {
|
|
27
|
+
showNotify({
|
|
28
28
|
message: msg,
|
|
29
29
|
duration: duration != null ? duration * 1e3 : 1500,
|
|
30
|
-
|
|
30
|
+
type: "danger"
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ViewController, IEditFormController, IEditViewState, IEditViewEvent, ViewEngineBase, IToolbarController } from '@ibiz-template/runtime';
|
|
1
|
+
import { ViewController, IEditFormController, IEditViewState, IEditViewEvent, ViewEngineBase, IToolbarController, FormSaveParams } from '@ibiz-template/runtime';
|
|
2
2
|
import { IAppDEEditView } from '@ibiz/model-core';
|
|
3
3
|
export declare class MobEditViewEngine extends ViewEngineBase {
|
|
4
4
|
/**
|
|
@@ -27,7 +27,7 @@ export declare class MobEditViewEngine extends ViewEngineBase {
|
|
|
27
27
|
onMounted(): Promise<void>;
|
|
28
28
|
getData(): IData[];
|
|
29
29
|
load(): Promise<IData>;
|
|
30
|
-
save(): Promise<IData>;
|
|
30
|
+
save(args?: FormSaveParams): Promise<IData>;
|
|
31
31
|
refresh(): Promise<void>;
|
|
32
32
|
call(key: string, args: any): Promise<IData | null | undefined>;
|
|
33
33
|
/**
|
|
@@ -97,8 +97,8 @@ class MobEditViewEngine extends ViewEngineBase {
|
|
|
97
97
|
async load() {
|
|
98
98
|
return this.form.load();
|
|
99
99
|
}
|
|
100
|
-
async save() {
|
|
101
|
-
return this.form.save();
|
|
100
|
+
async save(args) {
|
|
101
|
+
return this.form.save(args);
|
|
102
102
|
}
|
|
103
103
|
async refresh() {
|
|
104
104
|
await this.load();
|
|
@@ -215,7 +215,7 @@ class MobWFDynaEditViewEngine extends MobEditViewEngine {
|
|
|
215
215
|
*/
|
|
216
216
|
async wfSubmitByLink(link) {
|
|
217
217
|
if (this.isEditable) {
|
|
218
|
-
await this.save();
|
|
218
|
+
await this.save({ silent: true });
|
|
219
219
|
}
|
|
220
220
|
const { sequenceflowmobform } = link;
|
|
221
221
|
const newContext = Object.assign(this.view.context.clone(), {
|
|
@@ -66,8 +66,8 @@ const TreeControl = /* @__PURE__ */ vue.defineComponent({
|
|
|
66
66
|
return [];
|
|
67
67
|
}
|
|
68
68
|
return c.model.rootVisible ? c.state.rootNodes : c.state.rootNodes.reduce((result, nodeData) => {
|
|
69
|
-
if (nodeData.
|
|
70
|
-
return result.concat(nodeData.
|
|
69
|
+
if (nodeData._children) {
|
|
70
|
+
return result.concat(nodeData._children);
|
|
71
71
|
}
|
|
72
72
|
return result;
|
|
73
73
|
}, []);
|
|
@@ -90,7 +90,7 @@ const TreeControl = /* @__PURE__ */ vue.defineComponent({
|
|
|
90
90
|
const {
|
|
91
91
|
originData
|
|
92
92
|
} = opts;
|
|
93
|
-
if (!originData.
|
|
93
|
+
if (!originData._leaf) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
c.onTreeNodeClick(originData, event);
|
|
@@ -98,16 +98,16 @@ const TreeControl = /* @__PURE__ */ vue.defineComponent({
|
|
|
98
98
|
const treeDataFormat = (data) => {
|
|
99
99
|
return {
|
|
100
100
|
id: data.srfkey,
|
|
101
|
-
name: data.
|
|
102
|
-
children: data.
|
|
103
|
-
isLeaf: data.
|
|
101
|
+
name: data._text,
|
|
102
|
+
children: data._children,
|
|
103
|
+
isLeaf: data._leaf
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
106
|
const renderContent = (h, opts) => {
|
|
107
107
|
const {
|
|
108
108
|
originData
|
|
109
109
|
} = opts;
|
|
110
|
-
if (!originData.
|
|
110
|
+
if (!originData._leaf) {
|
|
111
111
|
return h("div", {
|
|
112
112
|
text: "\u4E0B\u7EA7",
|
|
113
113
|
className: "tree-button",
|
package/lib/index.cjs
CHANGED
|
@@ -175,6 +175,7 @@ var index = {
|
|
|
175
175
|
v.use(index$2.IBizCommonComponents);
|
|
176
176
|
v.use(index$B.IBizViewEngine);
|
|
177
177
|
v.use(vue3Util.IBizView);
|
|
178
|
+
v.use(vue3Util.IBizDeRedirectView);
|
|
178
179
|
v.use(vue3Util.IBizViewLayoutPanelControl);
|
|
179
180
|
v.use(index$C.IBizPortalView);
|
|
180
181
|
v.use(index$3.IBizPanelComponents);
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var vue3Util = require('@ibiz-template/vue3-util');
|
|
3
4
|
var vant = require('vant');
|
|
4
5
|
|
|
5
6
|
"use strict";
|
|
6
7
|
const INSTANCE_KEY = Symbol("vanLoading");
|
|
7
8
|
const createInstance = (el) => {
|
|
8
|
-
const
|
|
9
|
+
const ns = vue3Util.useNamespace("loading");
|
|
10
|
+
const options = {
|
|
11
|
+
message: "\u52A0\u8F7D\u4E2D...",
|
|
12
|
+
forbidClick: true,
|
|
13
|
+
teleport: el,
|
|
14
|
+
className: ns.b(),
|
|
15
|
+
loadingType: "spinner",
|
|
16
|
+
overlayClass: ns.e("overlay")
|
|
17
|
+
};
|
|
9
18
|
el[INSTANCE_KEY] = {
|
|
10
19
|
instance: vant.showLoadingToast(options)
|
|
11
20
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var vue3Util = require('@ibiz-template/vue3-util');
|
|
3
4
|
var vant = require('vant');
|
|
4
5
|
|
|
5
6
|
"use strict";
|
|
@@ -43,10 +44,14 @@ class LoadingUtil {
|
|
|
43
44
|
* @date 2022-12-29 15:12:26
|
|
44
45
|
*/
|
|
45
46
|
show() {
|
|
47
|
+
const ns = vue3Util.useNamespace("loading");
|
|
46
48
|
if (this.count === 0) {
|
|
47
49
|
this.loading = vant.showLoadingToast({
|
|
48
50
|
message: "\u52A0\u8F7D\u4E2D...",
|
|
49
|
-
forbidClick: true
|
|
51
|
+
forbidClick: true,
|
|
52
|
+
className: ns.b(),
|
|
53
|
+
loadingType: "spinner",
|
|
54
|
+
overlayClass: ns.e("overlay")
|
|
50
55
|
});
|
|
51
56
|
}
|
|
52
57
|
this.count += 1;
|
|
@@ -4,32 +4,32 @@ var vant = require('vant');
|
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
6
|
class MessageUtil {
|
|
7
|
-
info(msg, duration,
|
|
8
|
-
vant.
|
|
7
|
+
info(msg, duration, _closable) {
|
|
8
|
+
vant.showNotify({
|
|
9
9
|
message: msg,
|
|
10
10
|
duration: duration != null ? duration * 1e3 : 1500,
|
|
11
|
-
|
|
11
|
+
type: "primary"
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
success(msg, duration,
|
|
15
|
-
vant.
|
|
14
|
+
success(msg, duration, _closable) {
|
|
15
|
+
vant.showNotify({
|
|
16
16
|
message: msg,
|
|
17
17
|
duration: duration != null ? duration * 1e3 : 1500,
|
|
18
|
-
|
|
18
|
+
type: "success"
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
warning(msg, duration,
|
|
22
|
-
vant.
|
|
21
|
+
warning(msg, duration, _closable) {
|
|
22
|
+
vant.showNotify({
|
|
23
23
|
message: msg,
|
|
24
24
|
duration: duration != null ? duration * 1e3 : 1500,
|
|
25
|
-
|
|
25
|
+
type: "warning"
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
error(msg, duration,
|
|
29
|
-
vant.
|
|
28
|
+
error(msg, duration, _closable) {
|
|
29
|
+
vant.showNotify({
|
|
30
30
|
message: msg,
|
|
31
31
|
duration: duration != null ? duration * 1e3 : 1500,
|
|
32
|
-
|
|
32
|
+
type: "danger"
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -99,8 +99,8 @@ class MobEditViewEngine extends runtime.ViewEngineBase {
|
|
|
99
99
|
async load() {
|
|
100
100
|
return this.form.load();
|
|
101
101
|
}
|
|
102
|
-
async save() {
|
|
103
|
-
return this.form.save();
|
|
102
|
+
async save(args) {
|
|
103
|
+
return this.form.save(args);
|
|
104
104
|
}
|
|
105
105
|
async refresh() {
|
|
106
106
|
await this.load();
|
|
@@ -217,7 +217,7 @@ class MobWFDynaEditViewEngine extends mobEditView_engine.MobEditViewEngine {
|
|
|
217
217
|
*/
|
|
218
218
|
async wfSubmitByLink(link) {
|
|
219
219
|
if (this.isEditable) {
|
|
220
|
-
await this.save();
|
|
220
|
+
await this.save({ silent: true });
|
|
221
221
|
}
|
|
222
222
|
const { sequenceflowmobform } = link;
|
|
223
223
|
const newContext = Object.assign(this.view.context.clone(), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/mob-vue3-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "使用 rollup 编译 vue 组件或者 jsx",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "es/index.mjs",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@ibiz-template-package/vs-tree-ex": "^0.1.1",
|
|
27
|
-
"@ibiz-template/core": "^0.5.
|
|
28
|
-
"@ibiz-template/model-helper": "^0.5.
|
|
29
|
-
"@ibiz-template/runtime": "^0.5.
|
|
30
|
-
"@ibiz-template/theme": "^0.
|
|
31
|
-
"@ibiz-template/vue3-util": "^0.5.
|
|
32
|
-
"@ibiz/model-core": "^0.
|
|
27
|
+
"@ibiz-template/core": "^0.5.2",
|
|
28
|
+
"@ibiz-template/model-helper": "^0.5.2",
|
|
29
|
+
"@ibiz-template/runtime": "^0.5.2",
|
|
30
|
+
"@ibiz-template/theme": "^0.5.0",
|
|
31
|
+
"@ibiz-template/vue3-util": "^0.5.2",
|
|
32
|
+
"@ibiz/model-core": "^0.1.2",
|
|
33
33
|
"async-validator": "^4.2.5",
|
|
34
34
|
"cherry-markdown": "^0.8.26",
|
|
35
35
|
"dayjs": "^1.11.10",
|
package/dist/tree-xaVRfp-8.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
System.register(["vue","@ibiz-template/vue3-util","@ibiz-template/runtime","qx-util","@ibiz-template-package/vs-tree-ex"],function(g){"use strict";var l,a,u,s,c,d,h,m,f,p;return{setters:[function(t){l=t.defineComponent,a=t.computed,u=t.ref,s=t.createVNode,c=t.resolveComponent},function(t){d=t.useControlController,h=t.useNamespace},function(t){m=t.TreeController},function(t){f=t.createUUID},function(t){p=t.VsTreeComponent}],execute:function(){const t=l({name:"IBizTreeControl",components:{"vs-tree":p},props:{modelData:{type:Object,required:!0},context:{type:Object,required:!0},params:{type:Object,default:()=>({})},mdctrlActiveMode:{type:Number,default:2},singleSelect:{type:Boolean,default:!0}},setup(){var C,b;const o=d((...e)=>new m(...e)),D=h(`control-${o.model.controlType.toLowerCase()}`),T=a(()=>o.state.selectedData.map(e=>e.srfkey)),k=f(),N=u(!0),x=a(()=>o.state.isLoaded?o.model.rootVisible?o.state.rootNodes:o.state.rootNodes.reduce((e,r)=>r.children?e.concat(r.children):e,[]):[]),z=async(e,r)=>{if(!o.state.isLoaded)return;const n=await o.loadNodes(e.data);r(n)},L=(e,r)=>{const{originData:n}=r;o.onTreeNodeClick(n,e)},v=(e,r)=>{e.stopPropagation();const{originData:n}=r;n.leaf&&o.onTreeNodeClick(n,e)},w=e=>({id:e.srfkey,name:e.text,children:e.children,isLeaf:e.leaf}),B=(e,r)=>{const{originData:n}=r;if(!n.leaf)return e("div",{text:"\u4E0B\u7EA7",className:"tree-button",click:(j,i)=>{i.store.breadcrumb.list.push(i),i.setExpand(!0)}})},V=(e,r)=>{const{checked:n}=r;r.setChecked(!n),v(e,r)},y={maxHeight:"100%",checkInherit:!1,nocheckParent:!0,rootName:(b=(C=o.model.detreeNodes)==null?void 0:C.find(e=>e.rootNode))==null?void 0:b.name,renderContent:B,customNodeClick:V};return N.value&&Object.assign(y,{breadcrumb:{el:`#breadcrumb${k}`,link:(e,r)=>r.name}}),{c:o,ns:D,treeData:x,options:y,breadcrumb:N,checkedKeys:T,uuid:k,onNodeCheck:L,onNodeClick:v,loadData:z,treeDataFormat:w}},render(){return s(c("iBizControlBase"),{controller:this.c},{default:()=>[this.breadcrumb&&s(c("van-sticky"),null,{default:()=>[s("div",{id:`breadcrumb${this.uuid}`,class:[this.ns.b("header")]},null)]}),this.c.state.isCreated&&this.c.state.isLoaded&&s(c("vs-tree"),{"show-line":!0,class:[this.ns.b("content")],lazy:!0,strictLeaf:!0,options:this.options,"show-checkbox":!this.c.state.singleSelect,data:this.treeData,highlightCurrent:!0,checkedKeys:this.checkedKeys,format:this.treeDataFormat,load:this.loadData,onCheck:this.onNodeCheck},null)]})}});g({TreeControl:t,default:t})}}});
|
|
2
|
-
//# sourceMappingURL=tree-xaVRfp-8.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tree-xaVRfp-8.js","sources":["../src/control/tree/tree.tsx"],"sourcesContent":["import { useControlController, useNamespace } from '@ibiz-template/vue3-util';\nimport { computed, defineComponent, PropType, ref, VNode } from 'vue';\nimport { IDETree } from '@ibiz/model-core';\nimport { ITreeNodeData, TreeController } from '@ibiz-template/runtime';\nimport { createUUID } from 'qx-util';\nimport { VsTreeComponent } from '@ibiz-template-package/vs-tree-ex';\nimport './tree.scss';\n\nexport const TreeControl = defineComponent({\n name: 'IBizTreeControl',\n components: {\n 'vs-tree': VsTreeComponent,\n },\n props: {\n modelData: { type: Object as PropType<IDETree>, required: true },\n context: { type: Object as PropType<IContext>, required: true },\n params: { type: Object as PropType<IParams>, default: () => ({}) },\n /**\n * 部件行数据默认激活模式\n * - 0 不激活\n * - 1 单击激活\n * - 2 双击激活(默认值)\n *\n * @type {(number | 0 | 1 | 2)}\n */\n mdctrlActiveMode: { type: Number, default: 2 },\n\n /**\n * 是否为单选\n * - true 单选\n * - false 多选\n *\n * @type {(Boolean)}\n */\n singleSelect: { type: Boolean, default: true },\n },\n setup() {\n const c = useControlController<TreeController>(\n (...args) => new TreeController(...args),\n );\n const ns = useNamespace(`control-${c.model.controlType!.toLowerCase()}`);\n // 默认选中项\n const checkedKeys = computed(() => {\n return c.state.selectedData.map(item => item.srfkey);\n });\n\n const uuid = createUUID();\n\n // 启用面包屑功能\n const breadcrumb = ref(true);\n // 节点单击\n\n /** 树展示数据 */\n const treeData = computed(() => {\n if (!c.state.isLoaded) {\n return [];\n }\n return c.model.rootVisible\n ? c.state.rootNodes\n : c.state.rootNodes.reduce<ITreeNodeData[]>((result, nodeData) => {\n if (nodeData.children) {\n return result.concat(nodeData.children);\n }\n return result;\n }, []);\n });\n\n /**\n * 触发节点加载数据\n * @author zk\n * @date 2023-05-29 09:16:07\n * @param {IData} item\n * @param {(nodes: IData[]) => void} callback\n */\n const loadData = async (\n item: IData,\n callback: (nodes: IData[]) => void,\n ) => {\n // 没加载前拦截\n if (!c.state.isLoaded) {\n return;\n }\n // 加载时拦截点击事件\n const nodes = await c.loadNodes(item.data);\n callback(nodes);\n };\n\n /**\n * 多选时选中节点变更\n *\n * @param {ITreeNodeData} nodeData\n */\n const onNodeCheck = (event: MouseEvent, opts: IData) => {\n const { originData } = opts;\n c.onTreeNodeClick(originData, event);\n };\n\n const onNodeClick = (event: MouseEvent, opts: IData) => {\n event.stopPropagation();\n const { originData } = opts;\n if (!originData.leaf) {\n return;\n }\n c.onTreeNodeClick(originData, event);\n };\n\n /**\n * 树数据格式化\n *\n * @author zk\n * @date 2023-07-03 11:07:59\n * @param {ITreeNodeData} data\n * @return {*}\n */\n const treeDataFormat = (data: ITreeNodeData) => {\n return {\n id: data.srfkey,\n name: data.text,\n children: data.children,\n isLeaf: data.leaf,\n };\n };\n\n const renderContent = (\n h: (tag: string, opt: IData) => VNode,\n opts: IData,\n ) => {\n const { originData } = opts;\n if (!originData.leaf) {\n return h('div', {\n text: '下级',\n className: 'tree-button',\n click: (e: Event, _opts: IData) => {\n _opts.store.breadcrumb.list.push(_opts);\n _opts.setExpand(true);\n },\n });\n }\n };\n\n const customNodeClick = (event: MouseEvent, opts: IData) => {\n const { checked } = opts;\n opts.setChecked(!checked);\n onNodeClick(event, opts);\n };\n\n // vs树配置项\n const options = {\n maxHeight: '100%',\n // 继承父状态\n checkInherit: false,\n // 不能选择父节点\n nocheckParent: true,\n rootName: c.model.detreeNodes?.find(item => item.rootNode)?.name,\n renderContent,\n customNodeClick,\n };\n\n if (breadcrumb.value) {\n Object.assign(options, {\n breadcrumb: {\n el: `#breadcrumb${uuid}`,\n link: (node: IData, data: IData) => {\n return data.name;\n },\n },\n });\n }\n return {\n c,\n ns,\n treeData,\n options,\n breadcrumb,\n checkedKeys,\n uuid,\n onNodeCheck,\n onNodeClick,\n loadData,\n treeDataFormat,\n };\n },\n render() {\n return (\n <iBizControlBase controller={this.c}>\n {this.breadcrumb && (\n <van-sticky>\n <div\n id={`breadcrumb${this.uuid}`}\n class={[this.ns.b('header')]}\n ></div>\n </van-sticky>\n )}\n {this.c.state.isCreated && this.c.state.isLoaded && (\n <vs-tree\n show-line\n class={[this.ns.b('content')]}\n lazy={true}\n strictLeaf={true}\n options={this.options}\n show-checkbox={!this.c.state.singleSelect}\n data={this.treeData}\n highlightCurrent={true}\n checkedKeys={this.checkedKeys}\n format={this.treeDataFormat}\n load={this.loadData}\n onCheck={this.onNodeCheck}\n ></vs-tree>\n )}\n </iBizControlBase>\n );\n },\n});\n\nexport default TreeControl;\n"],"names":["TreeControl","defineComponent","components","VsTreeComponent","props","modelData","type","required","context","params","Object","default","setup","c","_a","_b","useControlController","args","TreeController","checkedKeys","useNamespace","computed","item","breadcrumb","ref","result","nodeData","model","loadData","callback","nodes","onNodeCheck","event","opts","originData","onNodeClick","treeDataFormat","data","renderContent","h","e","_opts","customNodeClick","checked","options","srfkey","text","uuid","className","ns","treeData","maxHeight","checkInherit","_createVNode","_resolveComponent","nocheckParent","rootName","value","assign","link","node"],"mappings":"8bASyB,MAAAA,EAAAC,EAAA,CACvBC,KAAAA,kBACE,WAAWC,CACZ,UAAAA,CACDC,EACEC,MAAAA,CAAaC,UAAiC,CAAEC,KAAAA,OAAgB,SAAA,EAChEC,EAAWF,QAAkC,CAAEC,KAAAA,OAAgB,SAAA,EAC/DE,EAAUH,OAAMI,CAA6BC,KAAAA,OAAqB,QAAA,KAAA,CAAA,EAClE,EAQoBL,iBAAY,CAAEK,KAAAA,OAAY,QAAA,CAE9C,EAOgBL,aAAa,CAAEK,KAAAA,QAAc,QAAA,EAC9C,CACDC,EACE,OAAMC,CAGN,IAAAC,EAAQC,EACR,MAAAF,EAAAG,EAAA,IAAAC,IAAA,IAAAC,EAAA,GAAAD,CAAA,CAAA,EACME,EAAWC,EAAW,WAAOP,EAAA,MAAA,YAAA,aAAA,EAAA,EACjCM,EAA2BE,EAAA,IAC3BR,EAAA,MAAA,aAAA,IAAAS,GAAAA,EAAA,MAAA,CAEF,QAEAC,EAAAC,EAAA,EAAA,EACMD,EAAUF,MAChBR,EAAA,MAAA,SAGcA,EAAA,MAAGQ,YAAe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