@handaotech-design/bom 0.0.16
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 +13 -0
- package/build.config.ts +27 -0
- package/dist/es/all-components.d.ts +3 -0
- package/dist/es/all-components.js +10 -0
- package/dist/es/assets/icons/operation-selected.svg +3 -0
- package/dist/es/assets/icons/operation.svg +3 -0
- package/dist/es/assets/icons/process-path-selected.svg +3 -0
- package/dist/es/assets/icons/process-path.svg +3 -0
- package/dist/es/assets/icons/process-plan-selected.svg +3 -0
- package/dist/es/assets/icons/process-plan.svg +3 -0
- package/dist/es/assets/icons/remove-minus.svg +4 -0
- package/dist/es/assets/icons/remove-plus.svg +5 -0
- package/dist/es/assets/icons/search.svg +4 -0
- package/dist/es/components/bom-tree/index.d.ts +3 -0
- package/dist/es/components/bom-tree/index.js +5 -0
- package/dist/es/components/bom-tree/index.vue +358 -0
- package/dist/es/components/bom-workbench/index.d.ts +3 -0
- package/dist/es/components/bom-workbench/index.js +5 -0
- package/dist/es/components/bom-workbench/index.vue +98 -0
- package/dist/es/components/gray-input/index.d.ts +3 -0
- package/dist/es/components/gray-input/index.js +5 -0
- package/dist/es/components/gray-input/index.vue +44 -0
- package/dist/es/components/index.d.ts +4 -0
- package/dist/es/components/index.js +4 -0
- package/dist/es/components/left-right/index.d.ts +3 -0
- package/dist/es/components/left-right/index.js +5 -0
- package/dist/es/components/left-right/index.vue +142 -0
- package/dist/es/defaults.d.ts +4 -0
- package/dist/es/defaults.js +3 -0
- package/dist/es/hooks/index.d.ts +1 -0
- package/dist/es/hooks/index.js +1 -0
- package/dist/es/hooks/use-ppboms.d.ts +19 -0
- package/dist/es/hooks/use-ppboms.js +81 -0
- package/dist/es/index.d.ts +7 -0
- package/dist/es/index.js +7 -0
- package/dist/es/models/bom.d.ts +35 -0
- package/dist/es/models/bom.js +1 -0
- package/dist/es/models/common.d.ts +5 -0
- package/dist/es/models/common.js +5 -0
- package/dist/es/models/index.d.ts +2 -0
- package/dist/es/models/index.js +2 -0
- package/dist/es/shared/keys.d.ts +1 -0
- package/dist/es/shared/keys.js +1 -0
- package/dist/es/shared/make-installer.d.ts +4 -0
- package/dist/es/shared/make-installer.js +13 -0
- package/dist/es/shims-vue.d.ts +5 -0
- package/dist/es/tokens/index.d.ts +0 -0
- package/dist/es/tokens/index.js +0 -0
- package/dist/es/types/components.d.ts +17 -0
- package/dist/es/utils/bom.d.ts +3 -0
- package/dist/es/utils/bom.js +29 -0
- package/dist/es/utils/config.d.ts +1 -0
- package/dist/es/utils/config.js +11 -0
- package/dist/es/utils/index.d.ts +4 -0
- package/dist/es/utils/index.js +4 -0
- package/dist/es/utils/rule-engine.d.ts +20 -0
- package/dist/es/utils/rule-engine.js +50 -0
- package/dist/es/utils/template.d.ts +1 -0
- package/dist/es/utils/template.js +11 -0
- package/dist/lib/all-components.d.ts +3 -0
- package/dist/lib/all-components.js +12 -0
- package/dist/lib/assets/icons/operation-selected.svg +3 -0
- package/dist/lib/assets/icons/operation.svg +3 -0
- package/dist/lib/assets/icons/process-path-selected.svg +3 -0
- package/dist/lib/assets/icons/process-path.svg +3 -0
- package/dist/lib/assets/icons/process-plan-selected.svg +3 -0
- package/dist/lib/assets/icons/process-plan.svg +3 -0
- package/dist/lib/assets/icons/remove-minus.svg +4 -0
- package/dist/lib/assets/icons/remove-plus.svg +5 -0
- package/dist/lib/assets/icons/search.svg +4 -0
- package/dist/lib/components/bom-tree/index.d.ts +3 -0
- package/dist/lib/components/bom-tree/index.js +26 -0
- package/dist/lib/components/bom-tree/index.vue +358 -0
- package/dist/lib/components/bom-workbench/index.d.ts +3 -0
- package/dist/lib/components/bom-workbench/index.js +26 -0
- package/dist/lib/components/bom-workbench/index.vue +98 -0
- package/dist/lib/components/gray-input/index.d.ts +3 -0
- package/dist/lib/components/gray-input/index.js +26 -0
- package/dist/lib/components/gray-input/index.vue +44 -0
- package/dist/lib/components/index.d.ts +4 -0
- package/dist/lib/components/index.js +49 -0
- package/dist/lib/components/left-right/index.d.ts +3 -0
- package/dist/lib/components/left-right/index.js +26 -0
- package/dist/lib/components/left-right/index.vue +142 -0
- package/dist/lib/defaults.d.ts +4 -0
- package/dist/lib/defaults.js +10 -0
- package/dist/lib/hooks/index.d.ts +1 -0
- package/dist/lib/hooks/index.js +16 -0
- package/dist/lib/hooks/use-ppboms.d.ts +19 -0
- package/dist/lib/hooks/use-ppboms.js +94 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/index.js +61 -0
- package/dist/lib/models/bom.d.ts +35 -0
- package/dist/lib/models/bom.js +7 -0
- package/dist/lib/models/common.d.ts +5 -0
- package/dist/lib/models/common.js +11 -0
- package/dist/lib/models/index.d.ts +2 -0
- package/dist/lib/models/index.js +27 -0
- package/dist/lib/shared/keys.d.ts +1 -0
- package/dist/lib/shared/keys.js +7 -0
- package/dist/lib/shared/make-installer.d.ts +4 -0
- package/dist/lib/shared/make-installer.js +20 -0
- package/dist/lib/shims-vue.d.ts +5 -0
- package/dist/lib/tokens/index.d.ts +0 -0
- package/dist/lib/tokens/index.js +1 -0
- package/dist/lib/types/components.d.ts +17 -0
- package/dist/lib/utils/bom.d.ts +3 -0
- package/dist/lib/utils/bom.js +40 -0
- package/dist/lib/utils/config.d.ts +1 -0
- package/dist/lib/utils/config.js +18 -0
- package/dist/lib/utils/index.d.ts +4 -0
- package/dist/lib/utils/index.js +49 -0
- package/dist/lib/utils/rule-engine.d.ts +20 -0
- package/dist/lib/utils/rule-engine.js +57 -0
- package/dist/lib/utils/template.d.ts +1 -0
- package/dist/lib/utils/template.js +19 -0
- package/dist/style.css +86 -0
- package/package.json +65 -0
- package/rollup.config.ts +47 -0
- package/src/all-components.ts +12 -0
- package/src/assets/icons/operation-selected.svg +3 -0
- package/src/assets/icons/operation.svg +3 -0
- package/src/assets/icons/process-path-selected.svg +3 -0
- package/src/assets/icons/process-path.svg +3 -0
- package/src/assets/icons/process-plan-selected.svg +3 -0
- package/src/assets/icons/process-plan.svg +3 -0
- package/src/assets/icons/remove-minus.svg +4 -0
- package/src/assets/icons/remove-plus.svg +5 -0
- package/src/assets/icons/search.svg +4 -0
- package/src/components/bom-tree/index.ts +5 -0
- package/src/components/bom-tree/index.vue +377 -0
- package/src/components/bom-workbench/index.ts +5 -0
- package/src/components/bom-workbench/index.vue +97 -0
- package/src/components/gray-input/index.ts +5 -0
- package/src/components/gray-input/index.vue +40 -0
- package/src/components/index.ts +4 -0
- package/src/components/left-right/index.ts +5 -0
- package/src/components/left-right/index.vue +149 -0
- package/src/defaults.ts +3 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-ppboms.ts +97 -0
- package/src/index.ts +9 -0
- package/src/models/bom.ts +43 -0
- package/src/models/common.ts +6 -0
- package/src/models/index.ts +2 -0
- package/src/shared/keys.ts +1 -0
- package/src/shared/make-installer.ts +21 -0
- package/src/shims-vue.d.ts +5 -0
- package/src/tokens/index.ts +0 -0
- package/src/types/components.d.ts +17 -0
- package/src/utils/bom.ts +33 -0
- package/src/utils/config.ts +11 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/rule-engine.ts +83 -0
- package/src/utils/template.ts +13 -0
- package/tsconfig.json +7 -0
- package/unocss.config.ts +55 -0
- package/vite-env.d.ts +1 -0
- package/vite.config.ts +79 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { debounce, throttle } from 'lodash-es'
|
|
3
|
+
import { onMounted, onUnmounted, ref } from 'vue'
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
moduleKey: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
maxLeftWidth: {
|
|
11
|
+
type: Number,
|
|
12
|
+
required: false,
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
const COMPONENT_NAME = 'HdLeftRight'
|
|
16
|
+
defineOptions({
|
|
17
|
+
name: COMPONENT_NAME,
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// 默认宽度 & 本地存储
|
|
21
|
+
const defaultLeftWidth = 300
|
|
22
|
+
const savedWidth = localStorage.getItem(`${props.moduleKey}LeftPanelWidth`)
|
|
23
|
+
const initialWidth = savedWidth ? parseInt(savedWidth) : defaultLeftWidth
|
|
24
|
+
|
|
25
|
+
// 响应式宽度
|
|
26
|
+
const leftWidth = ref(initialWidth)
|
|
27
|
+
const isDragging = ref(false)
|
|
28
|
+
let startX = 0
|
|
29
|
+
let startWidth = 0
|
|
30
|
+
|
|
31
|
+
// 节流更新UI(60fps)
|
|
32
|
+
const throttledUpdate = throttle((width: number) => {
|
|
33
|
+
leftWidth.value = width
|
|
34
|
+
}, 16)
|
|
35
|
+
|
|
36
|
+
// 防抖保存到本地存储(300ms延迟)
|
|
37
|
+
const debouncedSave = debounce(
|
|
38
|
+
(val: number) => {
|
|
39
|
+
localStorage.setItem(`${props.moduleKey}LeftPanelWidth`, val.toString())
|
|
40
|
+
},
|
|
41
|
+
300,
|
|
42
|
+
{ trailing: true }, // 确保最后一次触发
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
// 处理拖动
|
|
46
|
+
const handleDrag = (e: MouseEvent) => {
|
|
47
|
+
if (!isDragging.value) {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
const delta = e.clientX - startX
|
|
51
|
+
const newWidth = Math.max(
|
|
52
|
+
200,
|
|
53
|
+
Math.min(props.maxLeftWidth ?? 500, startWidth + delta),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
throttledUpdate(newWidth) // 节流更新UI
|
|
57
|
+
debouncedSave(newWidth) // 防抖保存
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 停止拖动
|
|
61
|
+
const stopDrag = () => {
|
|
62
|
+
isDragging.value = false
|
|
63
|
+
document.removeEventListener('mousemove', handleDrag)
|
|
64
|
+
document.removeEventListener('mouseup', stopDrag)
|
|
65
|
+
|
|
66
|
+
debouncedSave.flush() // 立即执行未完成的保存
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 开始拖动
|
|
70
|
+
const startDrag = (e: MouseEvent) => {
|
|
71
|
+
isDragging.value = true
|
|
72
|
+
startX = e.clientX
|
|
73
|
+
startWidth = leftWidth.value
|
|
74
|
+
document.addEventListener('mousemove', handleDrag)
|
|
75
|
+
document.addEventListener('mouseup', stopDrag)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 清理
|
|
79
|
+
onUnmounted(() => {
|
|
80
|
+
document.removeEventListener('mousemove', handleDrag)
|
|
81
|
+
document.removeEventListener('mouseup', stopDrag)
|
|
82
|
+
throttledUpdate.cancel()
|
|
83
|
+
debouncedSave.cancel()
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// 初始化
|
|
87
|
+
onMounted(() => {
|
|
88
|
+
leftWidth.value = initialWidth
|
|
89
|
+
})
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<template>
|
|
93
|
+
<div class="wrapper">
|
|
94
|
+
<div class="left" :style="{ width: `${leftWidth}px` }">
|
|
95
|
+
<slot name="left" />
|
|
96
|
+
</div>
|
|
97
|
+
<div
|
|
98
|
+
class="divider"
|
|
99
|
+
:style="{ left: `${leftWidth}px` }"
|
|
100
|
+
@mousedown="startDrag"
|
|
101
|
+
>
|
|
102
|
+
<div class="vertical-line" />
|
|
103
|
+
</div>
|
|
104
|
+
<div class="right">
|
|
105
|
+
<slot name="right" />
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</template>
|
|
109
|
+
|
|
110
|
+
<style scoped>
|
|
111
|
+
.wrapper {
|
|
112
|
+
display: flex;
|
|
113
|
+
position: relative;
|
|
114
|
+
height: 100%;
|
|
115
|
+
}
|
|
116
|
+
.wrapper .left {
|
|
117
|
+
height: 100%;
|
|
118
|
+
overflow: hidden;
|
|
119
|
+
}
|
|
120
|
+
.wrapper .divider {
|
|
121
|
+
position: absolute;
|
|
122
|
+
height: 100%;
|
|
123
|
+
cursor: col-resize;
|
|
124
|
+
z-index: 1;
|
|
125
|
+
transition: background 0.2s;
|
|
126
|
+
}
|
|
127
|
+
.wrapper .divider .vertical-line {
|
|
128
|
+
width: 1px;
|
|
129
|
+
height: 100%;
|
|
130
|
+
background: #E9EBED;
|
|
131
|
+
}
|
|
132
|
+
.wrapper .divider:hover .vertical-line {
|
|
133
|
+
background: #2e72d2;
|
|
134
|
+
width: 2px;
|
|
135
|
+
}
|
|
136
|
+
.wrapper .right {
|
|
137
|
+
flex: 1;
|
|
138
|
+
overflow-y: auto;
|
|
139
|
+
overflow-x: hidden;
|
|
140
|
+
padding: 0 16px;
|
|
141
|
+
}
|
|
142
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _makeInstaller = require("./shared/make-installer");
|
|
8
|
+
var _allComponents = _interopRequireDefault(require("./all-components"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
module.exports = (0, _makeInstaller.makeInstaller)([..._allComponents.default]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-ppboms';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _usePpboms = require("./use-ppboms");
|
|
7
|
+
Object.keys(_usePpboms).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _usePpboms[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _usePpboms[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum QueryType {
|
|
2
|
+
ALL = "ALL",
|
|
3
|
+
MODEL_ESN = "MODEL_ESN"
|
|
4
|
+
}
|
|
5
|
+
interface UsePpbomsParams {
|
|
6
|
+
host: string;
|
|
7
|
+
appId: string;
|
|
8
|
+
appSecret: string;
|
|
9
|
+
queryType?: QueryType;
|
|
10
|
+
options?: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
export declare const UsePpboms: (params: UsePpbomsParams) => {
|
|
13
|
+
data: import("vue").Ref<any>;
|
|
14
|
+
layoutConfig: import("vue").Ref<any>;
|
|
15
|
+
treeConfig: import("vue").Ref<any>;
|
|
16
|
+
loading: import("vue").Ref<boolean>;
|
|
17
|
+
getDataAndConfig: () => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UsePpboms = exports.QueryType = void 0;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
var _models = require("../models");
|
|
10
|
+
const ppbomPageConfigCode = "PPBOM_PAGE";
|
|
11
|
+
var QueryType = exports.QueryType = /* @__PURE__ */(QueryType2 => {
|
|
12
|
+
QueryType2["ALL"] = "ALL";
|
|
13
|
+
QueryType2["MODEL_ESN"] = "MODEL_ESN";
|
|
14
|
+
return QueryType2;
|
|
15
|
+
})(QueryType || {});
|
|
16
|
+
const UsePpboms = params => {
|
|
17
|
+
const {
|
|
18
|
+
host,
|
|
19
|
+
appId,
|
|
20
|
+
appSecret,
|
|
21
|
+
queryType,
|
|
22
|
+
options
|
|
23
|
+
} = params;
|
|
24
|
+
const loading = (0, _vue.ref)(false);
|
|
25
|
+
const data = (0, _vue.ref)();
|
|
26
|
+
const treeConfig = (0, _vue.ref)();
|
|
27
|
+
const layoutConfig = (0, _vue.ref)();
|
|
28
|
+
const queryBoms = async () => {
|
|
29
|
+
const body = {
|
|
30
|
+
page: 1,
|
|
31
|
+
pageSize: Number.MAX_SAFE_INTEGER,
|
|
32
|
+
...(options ?? {})
|
|
33
|
+
};
|
|
34
|
+
const response = await fetch(`http://${host}/api/public/v2/ppboms/query/all`, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
headers: {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
"X-CONSUMER-ID": appId,
|
|
39
|
+
"Authorization": `Bearer ${appSecret}`
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify(body)
|
|
42
|
+
});
|
|
43
|
+
return response.json();
|
|
44
|
+
};
|
|
45
|
+
const queryBomsByModelEsn = async () => {
|
|
46
|
+
const body = {
|
|
47
|
+
page: 1,
|
|
48
|
+
pageSize: Number.MAX_SAFE_INTEGER,
|
|
49
|
+
forceSettle: _models.YesNo.YES,
|
|
50
|
+
lookupOnly: _models.YesNo.YES,
|
|
51
|
+
...(options ?? {})
|
|
52
|
+
};
|
|
53
|
+
const response = await fetch(`http://${host}/api/public/v2/ppboms/query/by-model-esn`, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: {
|
|
56
|
+
"Content-Type": "application/json",
|
|
57
|
+
"X-CONSUMER-ID": appId,
|
|
58
|
+
"Authorization": `Bearer ${appSecret}`
|
|
59
|
+
},
|
|
60
|
+
body: JSON.stringify(body)
|
|
61
|
+
});
|
|
62
|
+
return response.json();
|
|
63
|
+
};
|
|
64
|
+
const getData = async () => {
|
|
65
|
+
switch (queryType) {
|
|
66
|
+
case "MODEL_ESN" /* MODEL_ESN */:
|
|
67
|
+
return await queryBomsByModelEsn();
|
|
68
|
+
default:
|
|
69
|
+
return await queryBoms();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const getDataAndConfig = async () => {
|
|
73
|
+
try {
|
|
74
|
+
loading.value = true;
|
|
75
|
+
const dataResp = await getData();
|
|
76
|
+
const configResp = await (0, _utils.getConfig)(host, ppbomPageConfigCode, appId, appSecret);
|
|
77
|
+
loading.value = false;
|
|
78
|
+
const props = configResp.config.props;
|
|
79
|
+
data.value = (0, _utils.convertBomDataToTree)(dataResp.data.items, props.content.tree.nodeConfig.rule);
|
|
80
|
+
treeConfig.value = props.content.tree;
|
|
81
|
+
layoutConfig.value = props.content.tree.layout;
|
|
82
|
+
} finally {
|
|
83
|
+
loading.value = false;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
data,
|
|
88
|
+
layoutConfig,
|
|
89
|
+
treeConfig,
|
|
90
|
+
loading,
|
|
91
|
+
getDataAndConfig
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
exports.UsePpboms = UsePpboms;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
install: true
|
|
8
|
+
};
|
|
9
|
+
exports.install = exports.default = void 0;
|
|
10
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
11
|
+
var _components = require("./components");
|
|
12
|
+
Object.keys(_components).forEach(function (key) {
|
|
13
|
+
if (key === "default" || key === "__esModule") return;
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
15
|
+
if (key in exports && exports[key] === _components[key]) return;
|
|
16
|
+
Object.defineProperty(exports, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _components[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
var _hooks = require("./hooks");
|
|
24
|
+
Object.keys(_hooks).forEach(function (key) {
|
|
25
|
+
if (key === "default" || key === "__esModule") return;
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
27
|
+
if (key in exports && exports[key] === _hooks[key]) return;
|
|
28
|
+
Object.defineProperty(exports, key, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () {
|
|
31
|
+
return _hooks[key];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
var _models = require("./models");
|
|
36
|
+
Object.keys(_models).forEach(function (key) {
|
|
37
|
+
if (key === "default" || key === "__esModule") return;
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
39
|
+
if (key in exports && exports[key] === _models[key]) return;
|
|
40
|
+
Object.defineProperty(exports, key, {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () {
|
|
43
|
+
return _models[key];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
var _utils = require("./utils");
|
|
48
|
+
Object.keys(_utils).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
51
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
52
|
+
Object.defineProperty(exports, key, {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () {
|
|
55
|
+
return _utils[key];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
60
|
+
const install = exports.install = _defaults.default.install;
|
|
61
|
+
module.exports = _defaults.default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BaseRule } from '../utils';
|
|
2
|
+
import type { YesNo } from './common';
|
|
3
|
+
export declare const defaultTitleTemplate = "${code}";
|
|
4
|
+
export interface BomNodeTitleConfig {
|
|
5
|
+
template: string;
|
|
6
|
+
}
|
|
7
|
+
export interface WorkBenchLayoutConfig {
|
|
8
|
+
maxLeftWidth: number;
|
|
9
|
+
}
|
|
10
|
+
export interface BomTreeNodeConfig {
|
|
11
|
+
title?: BomNodeTitleConfig;
|
|
12
|
+
selectable?: YesNo;
|
|
13
|
+
icon?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface BomLocalFilter {
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface BomTreeConfig {
|
|
19
|
+
filter?: BomLocalFilter;
|
|
20
|
+
nodeConfig: {
|
|
21
|
+
rule: BaseRule<BomTreeNodeConfig>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface BomNode {
|
|
25
|
+
id: string;
|
|
26
|
+
key: string;
|
|
27
|
+
code: string;
|
|
28
|
+
version: string;
|
|
29
|
+
name: string;
|
|
30
|
+
qty: number;
|
|
31
|
+
children?: BomNode[];
|
|
32
|
+
businessType: string;
|
|
33
|
+
raw: Record<string, any>;
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _common = require("./common");
|
|
7
|
+
Object.keys(_common).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _common[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _common[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _bom = require("./bom");
|
|
18
|
+
Object.keys(_bom).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _bom[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _bom[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const INSTALLED_KEY: unique symbol;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeInstaller = void 0;
|
|
7
|
+
var _keys = require("./keys");
|
|
8
|
+
const makeInstaller = (components = []) => {
|
|
9
|
+
const install = app => {
|
|
10
|
+
if (app[_keys.INSTALLED_KEY]) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
app[_keys.INSTALLED_KEY] = true;
|
|
14
|
+
components.forEach(c => app.use(c));
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
install
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
exports.makeInstaller = makeInstaller;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// generated by unplugin-vue-components
|
|
2
|
+
// We suggest you to commit this file into source control
|
|
3
|
+
// Read more: https://github.com/vuejs/core/pull/3399
|
|
4
|
+
import '@vue/runtime-core'
|
|
5
|
+
|
|
6
|
+
export {}
|
|
7
|
+
|
|
8
|
+
declare module '@vue/runtime-core' {
|
|
9
|
+
export interface GlobalComponents {
|
|
10
|
+
BomTree: typeof import('./../components/bom-tree/index.vue')['default']
|
|
11
|
+
BomWorkbench: typeof import('./../components/bom-workbench/index.vue')['default']
|
|
12
|
+
GrayInput: typeof import('./../components/gray-input/index.vue')['default']
|
|
13
|
+
LeftRight: typeof import('./../components/left-right/index.vue')['default']
|
|
14
|
+
RouterLink: typeof import('vue-router')['RouterLink']
|
|
15
|
+
RouterView: typeof import('vue-router')['RouterView']
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertBomDataToTree = void 0;
|
|
7
|
+
var _ = _interopRequireWildcard(require("lodash-es"));
|
|
8
|
+
var _models = require("../models");
|
|
9
|
+
var _ruleEngine = require("./rule-engine");
|
|
10
|
+
var _template = require("./template");
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
const defaultTreeNodeConfig = {
|
|
14
|
+
title: {
|
|
15
|
+
template: _models.defaultTitleTemplate
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const convertBomDataToTree = (treeData, nodeConfigRule) => {
|
|
19
|
+
const ruleEngine = new _ruleEngine.RuleEngine(nodeConfigRule);
|
|
20
|
+
const traverse = (nodes = []) => {
|
|
21
|
+
for (const node of nodes) {
|
|
22
|
+
const nodeConfig = ruleEngine.matchOne({
|
|
23
|
+
bomNode: node
|
|
24
|
+
}, defaultTreeNodeConfig);
|
|
25
|
+
const titleTemplate = nodeConfig?.title?.template ?? _models.defaultTitleTemplate;
|
|
26
|
+
Object.assign(node, {
|
|
27
|
+
key: node.key,
|
|
28
|
+
title: (0, _template.genText)(node, titleTemplate),
|
|
29
|
+
selectable: nodeConfig?.selectable === _models.YesNo.YES,
|
|
30
|
+
icon: nodeConfig?.icon
|
|
31
|
+
});
|
|
32
|
+
if (!_.isEmpty(node.children)) {
|
|
33
|
+
traverse(node.children);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
traverse(treeData);
|
|
38
|
+
return treeData;
|
|
39
|
+
};
|
|
40
|
+
exports.convertBomDataToTree = convertBomDataToTree;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getConfig: (host: string, code: string, appId: string, appSecret: string) => Promise<any>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getConfig = void 0;
|
|
7
|
+
const getConfig = async (host, code, appId, appSecret) => {
|
|
8
|
+
const response = await fetch(`http://${host}/api/public/v2/business-configs/${code}`, {
|
|
9
|
+
method: "GET",
|
|
10
|
+
headers: {
|
|
11
|
+
"Content-Type": "application/json",
|
|
12
|
+
"X-CONSUMER-ID": appId,
|
|
13
|
+
"Authorization": `Bearer ${appSecret}`
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return await response.json();
|
|
17
|
+
};
|
|
18
|
+
exports.getConfig = getConfig;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _bom = require("./bom");
|
|
7
|
+
Object.keys(_bom).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _bom[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _bom[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _ruleEngine = require("./rule-engine");
|
|
18
|
+
Object.keys(_ruleEngine).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _ruleEngine[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _ruleEngine[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _template = require("./template");
|
|
29
|
+
Object.keys(_template).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _template[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _template[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _config = require("./config");
|
|
40
|
+
Object.keys(_config).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _config[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _config[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Optional } from '../models/common';
|
|
2
|
+
export type RuleCondition = 'default' | 'always' | string | LogicExpression;
|
|
3
|
+
export interface LogicExpression {
|
|
4
|
+
logic: any;
|
|
5
|
+
conditions: any[];
|
|
6
|
+
}
|
|
7
|
+
export interface BaseRule<T> {
|
|
8
|
+
cases: BaseCase<T>[];
|
|
9
|
+
}
|
|
10
|
+
export interface BaseCase<T> {
|
|
11
|
+
key?: string;
|
|
12
|
+
condition: RuleCondition;
|
|
13
|
+
result: T;
|
|
14
|
+
}
|
|
15
|
+
export declare class RuleEngine<T> {
|
|
16
|
+
private readonly rule;
|
|
17
|
+
constructor(rule: BaseRule<T>);
|
|
18
|
+
matchOne(context: any, defaultResult?: T): Optional<T> | T;
|
|
19
|
+
matchMany(context: any, defaultResult?: T): T[];
|
|
20
|
+
}
|