@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,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
HdBomTree: true
|
|
8
|
+
};
|
|
9
|
+
module.exports = exports.HdBomTree = void 0;
|
|
10
|
+
var _vue = require("@handaotech-design/vue");
|
|
11
|
+
var _index = _interopRequireWildcard(require("./index.vue"));
|
|
12
|
+
Object.keys(_index).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] === _index[key]) return;
|
|
16
|
+
Object.defineProperty(exports, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _index[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
25
|
+
const HdBomTree = exports.HdBomTree = (0, _vue.withInstall)(_index.default);
|
|
26
|
+
module.exports = HdBomTree;
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { nextTick, onBeforeUnmount, onMounted, ref, toRefs, watch } from 'vue'
|
|
3
|
+
import type { TreeProps } from 'ant-design-vue'
|
|
4
|
+
import { watchDebounced } from '@vueuse/shared'
|
|
5
|
+
import * as _ from 'lodash-es'
|
|
6
|
+
import type { DataNode } from 'ant-design-vue/es/vc-tree-select/interface'
|
|
7
|
+
import type { EventDataNode } from 'ant-design-vue/es/tree'
|
|
8
|
+
import HdGrayInput from '../gray-input'
|
|
9
|
+
import type { BomTreeConfig } from '../../models'
|
|
10
|
+
|
|
11
|
+
const props = defineProps<Props>()
|
|
12
|
+
const emits = defineEmits(['select'])
|
|
13
|
+
const COMPONENT_NAME = 'HdBomTree'
|
|
14
|
+
defineOptions({
|
|
15
|
+
name: COMPONENT_NAME,
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
type TreeNodeWithMeta = DataNode & {
|
|
19
|
+
parentKeys: string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
treeData: TreeProps['treeData']
|
|
24
|
+
config: BomTreeConfig
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const expandedKeys = ref<(string | number)[]>([])
|
|
28
|
+
const searchValue = ref<string>('')
|
|
29
|
+
const autoExpandParent = ref<boolean>(true)
|
|
30
|
+
const { treeData: _treeData } = toRefs(props)
|
|
31
|
+
const filteredTreeData = ref<TreeProps['treeData']>([])
|
|
32
|
+
const treeContainerHeight = ref<number>(0)
|
|
33
|
+
const treeContainerId = 'treeContainer'
|
|
34
|
+
let keyToNodeMap = new Map<string, TreeNodeWithMeta>()
|
|
35
|
+
const selectedKeys = ref<string[]>([])
|
|
36
|
+
const initTreeState = async () => {
|
|
37
|
+
searchValue.value = ''
|
|
38
|
+
filteredTreeData.value = _treeData.value
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const onExpand = (keys: Key[]) => {
|
|
42
|
+
expandedKeys.value = keys
|
|
43
|
+
autoExpandParent.value = false
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const updateTreeContainerHeight = () => {
|
|
47
|
+
const treeContainer = document.getElementById(treeContainerId)
|
|
48
|
+
if (treeContainer) {
|
|
49
|
+
treeContainerHeight.value = treeContainer.clientHeight
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const buildKeyToNodeMap = (treeData: TreeProps['treeData']) => {
|
|
54
|
+
const keyMap = new Map<string, TreeNodeWithMeta>()
|
|
55
|
+
const traverse = (nodes: TreeProps['treeData'] = [], parentKeys: string[] = []) => {
|
|
56
|
+
for (const node of nodes) {
|
|
57
|
+
if (parentKeys) {
|
|
58
|
+
keyMap.set(node.key as string, {
|
|
59
|
+
...node,
|
|
60
|
+
parentKeys: parentKeys || [],
|
|
61
|
+
} as any)
|
|
62
|
+
}
|
|
63
|
+
if (!_.isEmpty(node.children)) {
|
|
64
|
+
traverse(node.children, [...parentKeys, node.key as string])
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
traverse(treeData)
|
|
69
|
+
return keyMap
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const filterTreeData = (data: TreeProps['treeData'], filteredKeys: string[]) => {
|
|
73
|
+
const getNodes = (result: any, node: any) => {
|
|
74
|
+
if (_.includes(filteredKeys, node.key)) {
|
|
75
|
+
result.push({ ...node })
|
|
76
|
+
return result
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(node.children)) {
|
|
79
|
+
const children = node.children.reduce(getNodes, [])
|
|
80
|
+
if (!_.isEmpty(children)) {
|
|
81
|
+
result.push({ ...node, children })
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result
|
|
85
|
+
}
|
|
86
|
+
return (data || []).reduce(getNodes, [])
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 获取直接父节点的 key
|
|
90
|
+
const getParentKey = (key: string): string[] | undefined => {
|
|
91
|
+
const treeNode = keyToNodeMap.get(key)
|
|
92
|
+
return treeNode?.parentKeys || []
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const selectFirstSelectableNode = () => {
|
|
96
|
+
const firstNode: any = _.find(Array.from(keyToNodeMap.values()), node => (node as any)?.selectable)
|
|
97
|
+
if (!firstNode) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
nextTick(() => {
|
|
102
|
+
expandedKeys.value = getParentKey(firstNode.key as string) as any
|
|
103
|
+
selectedKeys.value = firstNode ? [firstNode.key] as string[] : []
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type Key = string | number
|
|
108
|
+
const onSelected = (keys: Key[], { node }: { node: EventDataNode }) => {
|
|
109
|
+
const key = node?.dataRef?.key
|
|
110
|
+
if (key) {
|
|
111
|
+
selectedKeys.value = [key as string]
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
selectedKeys.value = []
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
onMounted(async () => {
|
|
119
|
+
window.addEventListener('resize', updateTreeContainerHeight)
|
|
120
|
+
await nextTick(() => {
|
|
121
|
+
updateTreeContainerHeight()
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
onBeforeUnmount(() => {
|
|
126
|
+
window.removeEventListener('resize', updateTreeContainerHeight)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
watch(
|
|
130
|
+
() => _treeData.value,
|
|
131
|
+
async () => {
|
|
132
|
+
if (!_.isEmpty(_treeData.value)) {
|
|
133
|
+
keyToNodeMap = buildKeyToNodeMap(_treeData.value)
|
|
134
|
+
await initTreeState()
|
|
135
|
+
selectFirstSelectableNode()
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
keyToNodeMap.clear()
|
|
139
|
+
await initTreeState()
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
immediate: true,
|
|
144
|
+
},
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
watchDebounced(
|
|
148
|
+
searchValue, (value: string) => {
|
|
149
|
+
let expanded: any[]
|
|
150
|
+
if (_.isEmpty(value)) {
|
|
151
|
+
expanded = getParentKey(selectedKeys.value[0]) || []
|
|
152
|
+
filteredTreeData.value = _treeData.value
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const filteredNodes: TreeProps['treeData'] = []
|
|
156
|
+
expanded = (Array.from(keyToNodeMap.values()))
|
|
157
|
+
.map((item: any) => {
|
|
158
|
+
if (hasSearchMatch(item.title)) {
|
|
159
|
+
filteredNodes.push(item)
|
|
160
|
+
return getParentKey(item.key)
|
|
161
|
+
}
|
|
162
|
+
return null
|
|
163
|
+
})
|
|
164
|
+
.filter((item, i, self) => item && self.indexOf(item) === i)
|
|
165
|
+
const filteredKeys = filteredNodes.map(item => item.key)
|
|
166
|
+
filteredTreeData.value = _.isEmpty(filteredKeys) ? [] : filterTreeData(_treeData.value, filteredKeys as unknown as string[])
|
|
167
|
+
}
|
|
168
|
+
expandedKeys.value = expanded
|
|
169
|
+
nextTick(() => {
|
|
170
|
+
expandedKeys.value = _.uniq(expanded.flat(1)) as any as string[]
|
|
171
|
+
})
|
|
172
|
+
}, { debounce: 500 })
|
|
173
|
+
|
|
174
|
+
watch(
|
|
175
|
+
() => selectedKeys.value,
|
|
176
|
+
() => {
|
|
177
|
+
if (selectedKeys.value && selectedKeys.value.length) {
|
|
178
|
+
return emits('select', keyToNodeMap.get(selectedKeys.value[0]))
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
function getIconClass(icon: string, isSelected: boolean) {
|
|
184
|
+
return isSelected ? `i-icon-${icon}-selected` : `i-icon-${icon}`
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function getTitlePart(title: string, partType: 'before' | 'after') {
|
|
188
|
+
const _searchValue = searchValue.value || ''
|
|
189
|
+
const index = title.indexOf(_searchValue)
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
before: title.substring(0, index),
|
|
193
|
+
after: title.substring(index + _searchValue.length),
|
|
194
|
+
}[partType]
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function hasSearchMatch(title: string) {
|
|
198
|
+
return searchValue.value && title.includes(searchValue.value)
|
|
199
|
+
}
|
|
200
|
+
</script>
|
|
201
|
+
|
|
202
|
+
<template>
|
|
203
|
+
<div class="flex flex-col h-100%">
|
|
204
|
+
<div class="search-box">
|
|
205
|
+
<HdGrayInput
|
|
206
|
+
v-model:value="searchValue"
|
|
207
|
+
:placeholder="props.config?.filter?.placeholder || '输入关键词进行筛选(如名称/编号)'"
|
|
208
|
+
class="search-input"
|
|
209
|
+
>
|
|
210
|
+
<template #prefix>
|
|
211
|
+
<div class="i-icon-search w-16px h-16px" />
|
|
212
|
+
</template>
|
|
213
|
+
</HdGrayInput>
|
|
214
|
+
</div>
|
|
215
|
+
<div :id="treeContainerId" class="flex-grow tree-wrapper mt-12px overflow-y-hidden">
|
|
216
|
+
<div v-if="!_.isEmpty(filteredTreeData)">
|
|
217
|
+
<a-tree
|
|
218
|
+
:height="treeContainerHeight"
|
|
219
|
+
:expanded-keys="expandedKeys"
|
|
220
|
+
:auto-expand-parent="autoExpandParent"
|
|
221
|
+
:tree-data="filteredTreeData"
|
|
222
|
+
:block-node="true"
|
|
223
|
+
:selected-keys="selectedKeys"
|
|
224
|
+
@expand="onExpand"
|
|
225
|
+
@select="onSelected"
|
|
226
|
+
>
|
|
227
|
+
<template #title="{ title, dataRef }">
|
|
228
|
+
<div :class="`tree-node-tittle flex items-center ${dataRef.selectable ? 'selectable' : 'not-selectable'}`">
|
|
229
|
+
<div
|
|
230
|
+
v-if="!!dataRef.icon"
|
|
231
|
+
class="icon w-20px h-20px mr-4px min-w-20px"
|
|
232
|
+
:class="[getIconClass(dataRef.icon, selectedKeys.includes(dataRef.key))]"
|
|
233
|
+
/>
|
|
234
|
+
<a-dropdown :trigger="['contextmenu']">
|
|
235
|
+
<div v-if="hasSearchMatch(title)" class="tree-node-text">
|
|
236
|
+
<span>{{ getTitlePart(title, 'before') }}</span>
|
|
237
|
+
<span class="highlight" style="background-color: #FFD499">{{ searchValue }}</span>
|
|
238
|
+
<span>{{ getTitlePart(title, 'after') }}</span>
|
|
239
|
+
</div>
|
|
240
|
+
<div v-else class="tree-node-text">
|
|
241
|
+
{{ title }}
|
|
242
|
+
</div>
|
|
243
|
+
<template #overlay>
|
|
244
|
+
<slot name="right-click" :tree-node="dataRef" />
|
|
245
|
+
</template>
|
|
246
|
+
</a-dropdown>
|
|
247
|
+
</div>
|
|
248
|
+
</template>
|
|
249
|
+
<template #switcherIcon="{ dataRef }">
|
|
250
|
+
<div
|
|
251
|
+
v-if="expandedKeys.includes(dataRef.key)" class="i-icon-remove-minus icon w-16px h-16px"
|
|
252
|
+
style="font-size: 20px;"
|
|
253
|
+
/>
|
|
254
|
+
<div v-else class="i-icon-remove-plus icon w-16px h-16px" />
|
|
255
|
+
</template>
|
|
256
|
+
</a-tree>
|
|
257
|
+
</div>
|
|
258
|
+
<div v-show="_.isEmpty(filteredTreeData)" class="w-100% h-100% flex justify-center items-center">
|
|
259
|
+
<span>暂无数据</span>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
</template>
|
|
264
|
+
|
|
265
|
+
<style scoped>
|
|
266
|
+
.tree-wrapper {
|
|
267
|
+
background-color: #fff;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.search-box {
|
|
271
|
+
padding: 0 16px;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
:deep(.ant-tree-list) .ant-tree-treenode-motion {
|
|
275
|
+
width: 100%;
|
|
276
|
+
}
|
|
277
|
+
:deep(.ant-tree-list) .ant-tree-treenode {
|
|
278
|
+
width: 100%;
|
|
279
|
+
align-items: center;
|
|
280
|
+
color: #2C2C2C;
|
|
281
|
+
font-size: 16px;
|
|
282
|
+
display: flex;
|
|
283
|
+
justify-content: center;
|
|
284
|
+
padding: 4px 12px;
|
|
285
|
+
}
|
|
286
|
+
:deep(.ant-tree-list) .ant-tree-treenode .ant-tree-indent-unit {
|
|
287
|
+
width: 10px;
|
|
288
|
+
}
|
|
289
|
+
:deep(.ant-tree-list) .ant-tree-treenode .ant-tree-switcher {
|
|
290
|
+
width: 16px;
|
|
291
|
+
height: 16px;
|
|
292
|
+
padding: 0;
|
|
293
|
+
margin: 0 10px 0 0;
|
|
294
|
+
align-self: center;
|
|
295
|
+
line-height: 16px;
|
|
296
|
+
}
|
|
297
|
+
:deep(.ant-tree-list) .ant-tree-treenode .ant-tree-node-content-wrapper {
|
|
298
|
+
transition: none;
|
|
299
|
+
white-space: nowrap;
|
|
300
|
+
text-overflow: ellipsis;
|
|
301
|
+
margin-bottom: 0;
|
|
302
|
+
display: inline-flex;
|
|
303
|
+
overflow: visible !important;
|
|
304
|
+
flex: 1;
|
|
305
|
+
min-width: 0;
|
|
306
|
+
}
|
|
307
|
+
:deep(.ant-tree-list) .ant-tree-treenode .ant-tree-node-content-wrapper:hover {
|
|
308
|
+
background-color: #E9EBED;
|
|
309
|
+
}
|
|
310
|
+
:deep(.ant-tree-list) .ant-tree-treenode .ant-tree-node-content-wrapper .ant-tree-title {
|
|
311
|
+
text-overflow: ellipsis;
|
|
312
|
+
white-space: nowrap;
|
|
313
|
+
flex: 1;
|
|
314
|
+
min-width: 0;
|
|
315
|
+
}
|
|
316
|
+
:deep(.ant-tree-list) .ant-tree-treenode .ant-tree-node-content-wrapper .ant-tree-title .tree-node-tittle.selectable {
|
|
317
|
+
cursor: pointer;
|
|
318
|
+
}
|
|
319
|
+
:deep(.ant-tree-list) .ant-tree-treenode .ant-tree-node-content-wrapper .ant-tree-title .tree-node-tittle.not-selectable {
|
|
320
|
+
cursor: auto;
|
|
321
|
+
}
|
|
322
|
+
:deep(.ant-tree-list) .ant-tree-treenode:hover {
|
|
323
|
+
background-color: #E9EBED;
|
|
324
|
+
}
|
|
325
|
+
:deep(.ant-tree-list) .ant-tree-treenode .ant-tree-node-content-wrapper {
|
|
326
|
+
user-select: auto;
|
|
327
|
+
}
|
|
328
|
+
:deep(.ant-tree-list) .ant-tree-treenode.ant-tree-treenode-selected {
|
|
329
|
+
background-color: #EDF4FF;
|
|
330
|
+
border-radius: 4px;
|
|
331
|
+
color: #1E3B9D;
|
|
332
|
+
font-weight: 700;
|
|
333
|
+
}
|
|
334
|
+
:deep(.ant-tree-list) .ant-tree-treenode.ant-tree-treenode-selected .ant-tree-switcher, :deep(.ant-tree-list) .ant-tree-treenode.ant-tree-treenode-selected .ant-tree-node-content-wrapper {
|
|
335
|
+
background-color: #EDF4FF;
|
|
336
|
+
}
|
|
337
|
+
:deep(.ant-tree-list) .ant-tree-node-content-wrapper {
|
|
338
|
+
align-items: center;
|
|
339
|
+
padding: 0;
|
|
340
|
+
}
|
|
341
|
+
:deep(.ant-tree-list) .ant-tree-node-content-wrapper {
|
|
342
|
+
display: flex;
|
|
343
|
+
margin-bottom: -4px;
|
|
344
|
+
}
|
|
345
|
+
:deep(.ant-tree-list) .ant-tree-node-content-wrapper .ant-tree-title {
|
|
346
|
+
flex-grow: 1;
|
|
347
|
+
display: block;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.tree-node-text {
|
|
351
|
+
display: inline-block;
|
|
352
|
+
max-width: 100%;
|
|
353
|
+
overflow: hidden;
|
|
354
|
+
text-overflow: ellipsis;
|
|
355
|
+
white-space: nowrap;
|
|
356
|
+
vertical-align: middle;
|
|
357
|
+
}
|
|
358
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
HdBomWorkbench: true
|
|
8
|
+
};
|
|
9
|
+
module.exports = exports.HdBomWorkbench = void 0;
|
|
10
|
+
var _vue = require("@handaotech-design/vue");
|
|
11
|
+
var _index = _interopRequireWildcard(require("./index.vue"));
|
|
12
|
+
Object.keys(_index).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] === _index[key]) return;
|
|
16
|
+
Object.defineProperty(exports, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _index[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
25
|
+
const HdBomWorkbench = exports.HdBomWorkbench = (0, _vue.withInstall)(_index.default);
|
|
26
|
+
module.exports = HdBomWorkbench;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ref, watch } from 'vue'
|
|
3
|
+
import * as _ from 'lodash-es'
|
|
4
|
+
import type { BomNode, BomTreeConfig, Optional, WorkBenchLayoutConfig } from '../../models'
|
|
5
|
+
import { convertBomDataToTree } from '../../utils'
|
|
6
|
+
import HdLeftRight from '../left-right/index'
|
|
7
|
+
import HdBomTree from '../bom-tree/index'
|
|
8
|
+
|
|
9
|
+
const props = defineProps<Props>()
|
|
10
|
+
const COMPONENT_NAME = 'HdBomWorkbench'
|
|
11
|
+
defineOptions({
|
|
12
|
+
name: COMPONENT_NAME,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
moduleKey: string
|
|
17
|
+
bomData: Optional<BomNode[]>
|
|
18
|
+
treeConfig: BomTreeConfig
|
|
19
|
+
layoutConfig?: WorkBenchLayoutConfig
|
|
20
|
+
}
|
|
21
|
+
const bomDataForTree = ref<BomNode[]>()
|
|
22
|
+
const selectedNode = ref<BomNode>()
|
|
23
|
+
|
|
24
|
+
async function onSelected(data: BomNode) {
|
|
25
|
+
selectedNode.value = data
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
watch(
|
|
29
|
+
() => props.bomData,
|
|
30
|
+
() => {
|
|
31
|
+
if (_.isEmpty(props.bomData)) {
|
|
32
|
+
selectedNode.value = undefined
|
|
33
|
+
bomDataForTree.value = undefined
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
bomDataForTree.value = convertBomDataToTree(props.bomData!, props.treeConfig.nodeConfig.rule)
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{ immediate: true },
|
|
40
|
+
)
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<HdLeftRight
|
|
45
|
+
v-if="bomDataForTree"
|
|
46
|
+
:module-key="props.moduleKey"
|
|
47
|
+
:max-left-width="props?.layoutConfig?.maxLeftWidth"
|
|
48
|
+
>
|
|
49
|
+
<template #left>
|
|
50
|
+
<div class="left-content">
|
|
51
|
+
<div class="bom-tree-container">
|
|
52
|
+
<HdBomTree
|
|
53
|
+
:tree-data="bomDataForTree"
|
|
54
|
+
:config="props.treeConfig"
|
|
55
|
+
@select="(data: BomNode) => onSelected(data)"
|
|
56
|
+
>
|
|
57
|
+
<template #right-click>
|
|
58
|
+
<slot name="tree-right-click" :bom-node="selectedNode" />
|
|
59
|
+
</template>
|
|
60
|
+
</HdBomTree>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
64
|
+
<template #right>
|
|
65
|
+
<div class="m-20px">
|
|
66
|
+
<slot name="content" :bom-node="selectedNode" />
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
69
|
+
</HdLeftRight>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<style scoped>
|
|
73
|
+
.v-h-center {
|
|
74
|
+
width: 100%;
|
|
75
|
+
height: 100%;
|
|
76
|
+
display: flex;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
align-items: center;
|
|
79
|
+
transition: all 1s ease;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.left-content {
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
height: 100%;
|
|
86
|
+
padding: 20px 0 16px 0;
|
|
87
|
+
}
|
|
88
|
+
.left-content .bom-tree-container {
|
|
89
|
+
flex-grow: 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:deep(.spinning-wrapper) {
|
|
93
|
+
height: 100%;
|
|
94
|
+
}
|
|
95
|
+
:deep(.spinning-wrapper) .ant-spin-container {
|
|
96
|
+
height: 100%;
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
HdGrayInput: true
|
|
8
|
+
};
|
|
9
|
+
module.exports = exports.HdGrayInput = void 0;
|
|
10
|
+
var _vue = require("@handaotech-design/vue");
|
|
11
|
+
var _index = _interopRequireWildcard(require("./index.vue"));
|
|
12
|
+
Object.keys(_index).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] === _index[key]) return;
|
|
16
|
+
Object.defineProperty(exports, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _index[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
25
|
+
const HdGrayInput = exports.HdGrayInput = (0, _vue.withInstall)(_index.default);
|
|
26
|
+
module.exports = HdGrayInput;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const COMPONENT_NAME = 'HdBomGrayInput'
|
|
3
|
+
defineOptions({
|
|
4
|
+
name: COMPONENT_NAME,
|
|
5
|
+
})
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<span class="inline-block gray-a-input-wrapper">
|
|
10
|
+
<a-input
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
>
|
|
13
|
+
<template v-for="(key, index) in Object.keys($slots)" :key="index" #[key]>
|
|
14
|
+
<slot :name="key" />
|
|
15
|
+
</template>
|
|
16
|
+
</a-input>
|
|
17
|
+
</span>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<style scoped>
|
|
21
|
+
.gray-a-input-wrapper {
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:deep(.ant-input),
|
|
26
|
+
:deep(.ant-input-affix-wrapper) {
|
|
27
|
+
background-color: #F5F5F5;
|
|
28
|
+
border-radius: 2px;
|
|
29
|
+
padding: 6px 12px;
|
|
30
|
+
font-size: 14px;
|
|
31
|
+
border-color: transparent;
|
|
32
|
+
}
|
|
33
|
+
:deep(.ant-input):hover,
|
|
34
|
+
:deep(.ant-input-affix-wrapper):hover {
|
|
35
|
+
border-color: #1E3B9D;
|
|
36
|
+
}
|
|
37
|
+
:deep(.ant-input):focus, :deep(.ant-input).ant-input-affix-wrapper-focused,
|
|
38
|
+
:deep(.ant-input-affix-wrapper):focus,
|
|
39
|
+
:deep(.ant-input-affix-wrapper).ant-input-affix-wrapper-focused {
|
|
40
|
+
border-color: #1E3B9D;
|
|
41
|
+
background-color: #fff;
|
|
42
|
+
box-shadow: none;
|
|
43
|
+
}
|
|
44
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _bomTree = require("./bom-tree");
|
|
7
|
+
Object.keys(_bomTree).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _bomTree[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _bomTree[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _bomWorkbench = require("./bom-workbench");
|
|
18
|
+
Object.keys(_bomWorkbench).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _bomWorkbench[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _bomWorkbench[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _grayInput = require("./gray-input");
|
|
29
|
+
Object.keys(_grayInput).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _grayInput[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _grayInput[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _leftRight = require("./left-right");
|
|
40
|
+
Object.keys(_leftRight).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _leftRight[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _leftRight[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
HdLeftRight: true
|
|
8
|
+
};
|
|
9
|
+
module.exports = exports.HdLeftRight = void 0;
|
|
10
|
+
var _vue = require("@handaotech-design/vue");
|
|
11
|
+
var _index = _interopRequireWildcard(require("./index.vue"));
|
|
12
|
+
Object.keys(_index).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] === _index[key]) return;
|
|
16
|
+
Object.defineProperty(exports, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _index[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
25
|
+
const HdLeftRight = exports.HdLeftRight = (0, _vue.withInstall)(_index.default);
|
|
26
|
+
module.exports = HdLeftRight;
|