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 | <template> | 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 | <Tabs :animated="true" v-model:activeKey="activeKey" @change="handlePanelChange"> | 3 | <Tabs :animated="true" v-model:activeKey="activeKey" @change="handlePanelChange"> |
4 | <TabPane key="product" tab="产品"> | 4 | <TabPane key="product" tab="产品"> |
5 | <div class="relative"> | 5 | <div class="relative"> |
@@ -23,7 +23,7 @@ export const steps = [ | @@ -23,7 +23,7 @@ export const steps = [ | ||
23 | export const formatFunctionType: Record<FunctionType, string> = { | 23 | export const formatFunctionType: Record<FunctionType, string> = { |
24 | [FunctionType.PROPERTIES]: '属性', | 24 | [FunctionType.PROPERTIES]: '属性', |
25 | [FunctionType.EVENTS]: '事件', | 25 | [FunctionType.EVENTS]: '事件', |
26 | - [FunctionType.SERVICE]: '事件', | 26 | + [FunctionType.SERVICE]: '服务', |
27 | }; | 27 | }; |
28 | 28 | ||
29 | export const physicalColumn: BasicColumn[] = [ | 29 | export const physicalColumn: BasicColumn[] = [ |
@@ -83,9 +83,9 @@ export const modelOfMatterForm: FormSchema[] = [ | @@ -83,9 +83,9 @@ export const modelOfMatterForm: FormSchema[] = [ | ||
83 | colProps: { span: 8 }, | 83 | colProps: { span: 8 }, |
84 | componentProps: { | 84 | componentProps: { |
85 | options: [ | 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,6 +32,9 @@ | ||
32 | 新增物模型 | 32 | 新增物模型 |
33 | </Button> | 33 | </Button> |
34 | <Button type="primary" @click="handleOpenTsl"> 物模型TSL </Button> | 34 | <Button type="primary" @click="handleOpenTsl"> 物模型TSL </Button> |
35 | + <Button v-if="isShowBtn" type="primary" @click="handleImportModel" | ||
36 | + >导入物模型</Button | ||
37 | + > | ||
35 | </Authority> | 38 | </Authority> |
36 | </div> | 39 | </div> |
37 | <div class="flex gap-2"> | 40 | <div class="flex gap-2"> |
@@ -224,6 +227,8 @@ | @@ -224,6 +227,8 @@ | ||
224 | } | 227 | } |
225 | }; | 228 | }; |
226 | 229 | ||
230 | + const handleImportModel = async () => {}; | ||
231 | + | ||
227 | defineExpose({}); | 232 | defineExpose({}); |
228 | </script> | 233 | </script> |
229 | <style lang="less" scoped> | 234 | <style lang="less" scoped> |
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | @ok="handleSubmit" | 9 | @ok="handleSubmit" |
10 | @cancel="handleCancel" | 10 | @cancel="handleCancel" |
11 | > | 11 | > |
12 | - <div> | 12 | + <div class="relative"> |
13 | <div v-if="openModalMode === OpenModelMode.CREATE"> | 13 | <div v-if="openModalMode === OpenModelMode.CREATE"> |
14 | <Typography> | 14 | <Typography> |
15 | <TypographyParagraph> | 15 | <TypographyParagraph> |
@@ -38,6 +38,10 @@ | @@ -38,6 +38,10 @@ | ||
38 | ref="ServiceRef" | 38 | ref="ServiceRef" |
39 | /> | 39 | /> |
40 | <Events v-show="activeKey === FunctionType.EVENTS" ref="EventsRef" /> | 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 | </div> | 45 | </div> |
42 | </BasicModal> | 46 | </BasicModal> |
43 | </div> | 47 | </div> |
@@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
6 | width="55rem" | 6 | width="55rem" |
7 | @register="register" | 7 | @register="register" |
8 | @ok="handleSubmit" | 8 | @ok="handleSubmit" |
9 | + okText="导出物模型" | ||
9 | @cancel="handleCancel" | 10 | @cancel="handleCancel" |
10 | > | 11 | > |
11 | <TslContent :record="$props.record" ref="TslConRef" /> | 12 | <TslContent :record="$props.record" ref="TslConRef" /> |
@@ -19,7 +20,7 @@ | @@ -19,7 +20,7 @@ | ||
19 | 20 | ||
20 | defineEmits(['register']); | 21 | defineEmits(['register']); |
21 | 22 | ||
22 | - defineProps<{ | 23 | + const props = defineProps<{ |
23 | record: DeviceRecord; | 24 | record: DeviceRecord; |
24 | }>(); | 25 | }>(); |
25 | 26 | ||
@@ -42,7 +43,17 @@ | @@ -42,7 +43,17 @@ | ||
42 | const handleSubmit = () => { | 43 | const handleSubmit = () => { |
43 | const value = TslConRef.value?.getFormData(); | 44 | const value = TslConRef.value?.getFormData(); |
44 | if (!value) return; | 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 | </script> | 58 | </script> |
48 | 59 |