|
@@ -40,7 +40,9 @@ const viewer = {
|
|
|
setActivePinia(createPinia())
|
|
setActivePinia(createPinia())
|
|
|
const store = usePipeEnhancementStore()
|
|
const store = usePipeEnhancementStore()
|
|
|
const pipes = ['P-1', 'P-2'].map((code) => ({ code, positions: [[110.1, 28.4], [110.101, 28.401]] }))
|
|
const pipes = ['P-1', 'P-2'].map((code) => ({ code, positions: [[110.1, 28.4], [110.101, 28.401]] }))
|
|
|
-const plan = Vue.computed(() => planPipeEnhancement({ selected: store.selected, visiblePipes: pipes, radiusM: store.radiusM }))
|
|
|
|
|
|
|
+const demoDevice = { code: 'D-real', pointCode: 'MP-real', name: '真实设备', placement: 'nearby', placementText: '邻近设备 · 示意安装' }
|
|
|
|
|
+const plan = Vue.computed(() => ({ ...planPipeEnhancement({ selected: store.selected, visiblePipes: pipes, radiusM: store.radiusM }),
|
|
|
|
|
+ deviceList: [demoDevice], devices: [demoDevice], deviceCoverage: { loading: false, partial: false } }))
|
|
|
const selectContext = vm.createContext({ PIPE_ENHANCEMENT_KIND, pipeEnhancementStore: store })
|
|
const selectContext = vm.createContext({ PIPE_ENHANCEMENT_KIND, pipeEnhancementStore: store })
|
|
|
vm.runInContext(`${functions(shell.scriptSetup.content, ['selectPipeEnhancement'])}\nglobalThis.select = selectPipeEnhancement`, selectContext)
|
|
vm.runInContext(`${functions(shell.scriptSetup.content, ['selectPipeEnhancement'])}\nglobalThis.select = selectPipeEnhancement`, selectContext)
|
|
|
const context = vm.createContext({
|
|
const context = vm.createContext({
|
|
@@ -76,7 +78,7 @@ function click(x = 120, y = 230, upX = x) {
|
|
|
const enhancement = parse(src('components/PipeEnhancement.vue')).descriptor
|
|
const enhancement = parse(src('components/PipeEnhancement.vue')).descriptor
|
|
|
let mounts = 0
|
|
let mounts = 0
|
|
|
let releases = 0
|
|
let releases = 0
|
|
|
-let devicePick, objectPick
|
|
|
|
|
|
|
+let devicePick, objectPick, focusedDevice
|
|
|
let syncs = 0
|
|
let syncs = 0
|
|
|
const script = compileScript(enhancement, { id: 't23-click', inlineTemplate: true }).content
|
|
const script = compileScript(enhancement, { id: 't23-click', inlineTemplate: true }).content
|
|
|
const imports = { vue: Vue, './EquipmentDetailSections.vue': { default: { props: ['deviceCode', 'aggregate'], render() { return Vue.h('div', { 'data-device-detail': this.deviceCode }) } } }, '../services/threePipeEnhancement.js': { mountPipeEnhancement(_host, next, options) {
|
|
const imports = { vue: Vue, './EquipmentDetailSections.vue': { default: { props: ['deviceCode', 'aggregate'], render() { return Vue.h('div', { 'data-device-detail': this.deviceCode }) } } }, '../services/threePipeEnhancement.js': { mountPipeEnhancement(_host, next, options) {
|
|
@@ -84,7 +86,7 @@ const imports = { vue: Vue, './EquipmentDetailSections.vue': { default: { props:
|
|
|
objectPick = options.onObjectPick
|
|
objectPick = options.onObjectPick
|
|
|
assert.equal(next.object.code, 'P-2')
|
|
assert.equal(next.object.code, 'P-2')
|
|
|
mounts += 1
|
|
mounts += 1
|
|
|
- return { sync() { syncs += 1 }, destroy() { releases += 1 } }
|
|
|
|
|
|
|
+ return { sync() { syncs += 1 }, focusDevice(code) { focusedDevice = code; return true }, destroy() { releases += 1 } }
|
|
|
} } }
|
|
} } }
|
|
|
let compiled = script
|
|
let compiled = script
|
|
|
for (const node of parseJS(script, { sourceType: 'module' }).program.body.filter((n) => n.type === 'ImportDeclaration').reverse()) {
|
|
for (const node of parseJS(script, { sourceType: 'module' }).program.body.filter((n) => n.type === 'ImportDeclaration').reverse()) {
|
|
@@ -108,6 +110,7 @@ const app = renderer.createApp({ setup: () => () => Vue.h(Component, {
|
|
|
onClose: () => { store.clear(); deviceStore.clear() },
|
|
onClose: () => { store.clear(); deviceStore.clear() },
|
|
|
onObjectPick: (hit) => selectContext.select(hit),
|
|
onObjectPick: (hit) => selectContext.select(hit),
|
|
|
onDevicePick: (device) => deviceStore.open(device, { fetchDetail: async (code) => ({ state: 'success', data: { deviceCode: code, sections: {} } }) }),
|
|
onDevicePick: (device) => deviceStore.open(device, { fetchDetail: async (code) => ({ state: 'success', data: { deviceCode: code, sections: {} } }) }),
|
|
|
|
|
+ onDeviceClose: () => deviceStore.closeDetail(),
|
|
|
}) })
|
|
}) })
|
|
|
app.mount(root)
|
|
app.mount(root)
|
|
|
function find(node, key) {
|
|
function find(node, key) {
|
|
@@ -121,12 +124,27 @@ assert.ok(store.selected, `点击未派发:device/point=${JSON.stringify(conte
|
|
|
assert.equal(store.selected.code, 'P-2')
|
|
assert.equal(store.selected.code, 'P-2')
|
|
|
assert.equal(mounts, 1)
|
|
assert.equal(mounts, 1)
|
|
|
assert.ok(find(root, 'data-pipe-enhancement'), 'pointer hit must render the enhancement dialog')
|
|
assert.ok(find(root, 'data-pipe-enhancement'), 'pointer hit must render the enhancement dialog')
|
|
|
-devicePick({ code: 'D-real', pointCode: 'MP-real', name: '真实设备', placementText: '邻近设备 · 示意安装' })
|
|
|
|
|
|
|
+assert.ok(find(root, 'data-device-list'))
|
|
|
|
|
+assert.ok(find(root, 'data-pipe-status-list'))
|
|
|
|
|
+const deviceButton = find(root, 'data-device-code')
|
|
|
|
|
+assert.equal(deviceButton.props['data-device-code'], 'D-real')
|
|
|
|
|
+deviceButton.props.onClick()
|
|
|
|
|
+assert.equal(focusedDevice, 'D-real')
|
|
|
await Vue.nextTick(); await Vue.nextTick()
|
|
await Vue.nextTick(); await Vue.nextTick()
|
|
|
assert.equal(deviceStore.aggregate.data.deviceCode, 'D-real')
|
|
assert.equal(deviceStore.aggregate.data.deviceCode, 'D-real')
|
|
|
assert.equal(find(root, 'data-device-detail').props['data-device-detail'], 'D-real')
|
|
assert.equal(find(root, 'data-device-detail').props['data-device-detail'], 'D-real')
|
|
|
-assert.equal(mounts, 1, '打开设备详情不能重建三维场景')
|
|
|
|
|
-assert.equal(store.selected.code, 'P-2')
|
|
|
|
|
|
|
+devicePick(demoDevice)
|
|
|
|
|
+await Vue.nextTick(); await Vue.nextTick()
|
|
|
|
|
+assert.equal(find(root, 'data-device-detail').props['data-device-detail'], 'D-real', '场景图标射线点击直接打开设备详情')
|
|
|
|
|
+assert.equal(find(root, 'data-device-list') !== undefined, true, '详情覆盖层打开时清单仍保留于其下')
|
|
|
|
|
+find(root, 'data-enhancement-device-detail').children
|
|
|
|
|
+ .filter((node) => node.tag === 'header')[0].children
|
|
|
|
|
+ .find((node) => node.tag === 'button').props.onClick()
|
|
|
|
|
+await Vue.nextTick()
|
|
|
|
|
+assert.equal(deviceStore.selected, null)
|
|
|
|
|
+assert.ok(find(root, 'data-device-list'), '关闭设备详情不关闭设备列表')
|
|
|
|
|
+assert.equal(mounts, 1, '设备详情关闭不重建三维场景')
|
|
|
|
|
+
|
|
|
function findTag(node, tag) { return node.tag === tag ? node : (node.children || []).map((child) => findTag(child, tag)).find(Boolean) }
|
|
function findTag(node, tag) { return node.tag === tag ? node : (node.children || []).map((child) => findTag(child, tag)).find(Boolean) }
|
|
|
findTag(root, 'select').props.onChange({ target: { value: '100' } })
|
|
findTag(root, 'select').props.onChange({ target: { value: '100' } })
|
|
|
await Vue.nextTick(); await Vue.nextTick()
|
|
await Vue.nextTick(); await Vue.nextTick()
|