Commit 8df1fba8cc9b9be632fc42767850a9731014a9a5
1 parent
2ae23072
perf: on view mode not allowed edit form in product profiles's model of matter
Showing
5 changed files
with
28 additions
and
8 deletions
1 | 1 | <template> |
2 | - <BasicDrawer v-bind="$attrs" title="产品详情" @register="register" width="60%"> | |
2 | + <BasicDrawer v-bind="$attrs" title="产品详情" @register="register" width="60%" destroy-on-close> | |
3 | 3 | <Tabs :animated="true" v-model:activeKey="activeKey" @change="handlePanelChange"> |
4 | 4 | <TabPane key="product" tab="产品"> |
5 | 5 | <div class="relative"> | ... | ... |
... | ... | @@ -23,7 +23,7 @@ export const steps = [ |
23 | 23 | export const formatFunctionType: Record<FunctionType, string> = { |
24 | 24 | [FunctionType.PROPERTIES]: '属性', |
25 | 25 | [FunctionType.EVENTS]: '事件', |
26 | - [FunctionType.SERVICE]: '事件', | |
26 | + [FunctionType.SERVICE]: '服务', | |
27 | 27 | }; |
28 | 28 | |
29 | 29 | export const physicalColumn: BasicColumn[] = [ |
... | ... | @@ -83,9 +83,9 @@ export const modelOfMatterForm: FormSchema[] = [ |
83 | 83 | colProps: { span: 8 }, |
84 | 84 | componentProps: { |
85 | 85 | options: [ |
86 | - { label: '属性', value: FunctionType.PROPERTIES }, | |
87 | - { label: '事件', value: FunctionType.EVENTS }, | |
88 | - { label: '服务', value: FunctionType.SERVICE }, | |
86 | + { label: formatFunctionType[FunctionType.PROPERTIES], value: FunctionType.PROPERTIES }, | |
87 | + { label: formatFunctionType[FunctionType.EVENTS], value: FunctionType.EVENTS }, | |
88 | + { label: formatFunctionType[FunctionType.SERVICE], value: FunctionType.SERVICE }, | |
89 | 89 | ], |
90 | 90 | }, |
91 | 91 | }, | ... | ... |
... | ... | @@ -32,6 +32,9 @@ |
32 | 32 | 新增物模型 |
33 | 33 | </Button> |
34 | 34 | <Button type="primary" @click="handleOpenTsl"> 物模型TSL </Button> |
35 | + <Button v-if="isShowBtn" type="primary" @click="handleImportModel" | |
36 | + >导入物模型</Button | |
37 | + > | |
35 | 38 | </Authority> |
36 | 39 | </div> |
37 | 40 | <div class="flex gap-2"> |
... | ... | @@ -224,6 +227,8 @@ |
224 | 227 | } |
225 | 228 | }; |
226 | 229 | |
230 | + const handleImportModel = async () => {}; | |
231 | + | |
227 | 232 | defineExpose({}); |
228 | 233 | </script> |
229 | 234 | <style lang="less" scoped> | ... | ... |
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | @ok="handleSubmit" |
10 | 10 | @cancel="handleCancel" |
11 | 11 | > |
12 | - <div> | |
12 | + <div class="relative"> | |
13 | 13 | <div v-if="openModalMode === OpenModelMode.CREATE"> |
14 | 14 | <Typography> |
15 | 15 | <TypographyParagraph> |
... | ... | @@ -38,6 +38,10 @@ |
38 | 38 | ref="ServiceRef" |
39 | 39 | /> |
40 | 40 | <Events v-show="activeKey === FunctionType.EVENTS" ref="EventsRef" /> |
41 | + <div | |
42 | + v-if="openModalMode === OpenModelMode.VIEW" | |
43 | + class="absolute w-full h-full top-0 cursor-not-allowed" | |
44 | + ></div> | |
41 | 45 | </div> |
42 | 46 | </BasicModal> |
43 | 47 | </div> | ... | ... |
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | width="55rem" |
7 | 7 | @register="register" |
8 | 8 | @ok="handleSubmit" |
9 | + okText="导出物模型" | |
9 | 10 | @cancel="handleCancel" |
10 | 11 | > |
11 | 12 | <TslContent :record="$props.record" ref="TslConRef" /> |
... | ... | @@ -19,7 +20,7 @@ |
19 | 20 | |
20 | 21 | defineEmits(['register']); |
21 | 22 | |
22 | - defineProps<{ | |
23 | + const props = defineProps<{ | |
23 | 24 | record: DeviceRecord; |
24 | 25 | }>(); |
25 | 26 | |
... | ... | @@ -42,7 +43,17 @@ |
42 | 43 | const handleSubmit = () => { |
43 | 44 | const value = TslConRef.value?.getFormData(); |
44 | 45 | if (!value) return; |
45 | - console.log('搜集值', value); | |
46 | + | |
47 | + const blob = new Blob([JSON.stringify(value, null, 2)], { type: 'text/json' }); | |
48 | + const objectURL = URL.createObjectURL(blob); | |
49 | + const element = document.createElement('a'); | |
50 | + element.href = objectURL; | |
51 | + element.download = `${props.record.name}-model.json`; | |
52 | + element.style.display = 'none'; | |
53 | + document.body.appendChild(element); | |
54 | + element.click(); | |
55 | + element.remove(); | |
56 | + URL.revokeObjectURL(objectURL); | |
46 | 57 | }; |
47 | 58 | </script> |
48 | 59 | ... | ... |