Commit 3ec5a6daeb3e43a3950a7ba16109cf68e3205e9c
Merge branch 'perf/configuration-id' into 'main_dev'
perf:优化组态节点保存 See merge request yunteng/thingskit-scada!257
Showing
11 changed files
with
87 additions
and
52 deletions
... | ... | @@ -5672,16 +5672,36 @@ App.prototype.save = function (name, done) { |
5672 | 5672 | // const data = `${Graph.xmlDeclaration}\n${this.getFileData(true, null, null, null, true, true, null, null, null, false)}`; |
5673 | 5673 | // this.currentFile.setData(data) |
5674 | 5674 | |
5675 | - const allCells = this.editor.graph.getModel().cells || {} | |
5675 | + const graph = this.editor.graph | |
5676 | + const model = graph.model | |
5677 | + const pages = this.pages | |
5678 | + | |
5679 | + const currentPageContentId = this.ui.currentPage.getId() | |
5680 | + let originalPage | |
5681 | + const contentPageInfos = pages.map(page => { | |
5682 | + this.ui.selectPage(page) | |
5683 | + const cells = model.getChildCells(graph.getDefaultParent()) | |
5684 | + const nodeIds = cells.map(cell => cell.getId()) | |
5685 | + const contentId = this.ui.currentPage.getId() | |
5686 | + | |
5687 | + if (contentId === currentPageContentId) | |
5688 | + originalPage = page | |
5689 | + | |
5690 | + return { | |
5691 | + nodeIds, | |
5692 | + contentId | |
5693 | + } | |
5694 | + }) | |
5695 | + originalPage && this.ui.selectPage(originalPage) | |
5696 | + | |
5676 | 5697 | await doSaveConfigurationContent({ |
5677 | 5698 | configurationContentList: [ |
5678 | 5699 | { |
5679 | 5700 | id: currentFile.getHash(), |
5680 | 5701 | content: this.currentFile.getData(), |
5681 | - contentId: this.currentPage.getId(), | |
5682 | 5702 | type: 1, |
5683 | - nodeIds: Object.keys(allCells), | |
5684 | - name: this.currentPage.getName() | |
5703 | + name: this.currentPage.getName(), | |
5704 | + contentPageInfos | |
5685 | 5705 | } |
5686 | 5706 | ], |
5687 | 5707 | configurationName: currentFile.title, | ... | ... |
... | ... | @@ -167,26 +167,36 @@ LocalFile.prototype.saveFile = function (title, revision, success, error, useCur |
167 | 167 | const handleSaveContent = async () => { |
168 | 168 | const { doSaveConfigurationContent, configurationId } = useContentData() |
169 | 169 | try { |
170 | - const allCells = this.ui.editor.graph.getModel().cells || {} | |
171 | - // const allCells = this.shadowPages | |
172 | - // .map(item => { | |
173 | - // console.log(item) | |
174 | - // return this.ui.editor.graph.createCellLookup([item.root]) | |
175 | - // }) | |
176 | - // .map(obj => Object.values(obj)) | |
177 | - // .reduce((prev, next) => [...prev, ...next], []) | |
178 | - | |
170 | + const graph = this.ui.editor.graph | |
171 | + const model = graph.model | |
172 | + const pages = this.ui.pages | |
173 | + | |
174 | + const currentPageContentId = this.ui.currentPage.getId() | |
175 | + let originalPage | |
176 | + const contentPageInfos = pages.map(page => { | |
177 | + this.ui.selectPage(page) | |
178 | + const cells = model.getChildCells(graph.getDefaultParent()) | |
179 | + const nodeIds = cells.map(cell => cell.getId()) | |
180 | + const contentId = this.ui.currentPage.getId() | |
181 | + | |
182 | + if (contentId === currentPageContentId) | |
183 | + originalPage = page | |
184 | + | |
185 | + return { | |
186 | + nodeIds, | |
187 | + contentId | |
188 | + } | |
189 | + }) | |
190 | + originalPage && this.ui.selectPage(originalPage) | |
191 | + | |
179 | 192 | await doSaveConfigurationContent({ |
180 | 193 | configurationContentList: [ |
181 | 194 | { |
182 | 195 | id: this.ui.configurationContentId, |
183 | 196 | content: savedData, |
184 | - // contentId: this.ui.configurationContentId, | |
185 | - contentId: this.ui.currentPage.getId(), | |
186 | 197 | type: 1, |
187 | - // nodeIds: Array.from(new Set(allCells)), | |
188 | - nodeIds: Object.keys(allCells), | |
189 | - name: this.ui.currentPage.getName() | |
198 | + name: this.ui.currentPage.getName(), | |
199 | + contentPageInfos | |
190 | 200 | } |
191 | 201 | ], |
192 | 202 | configurationName: this.ui.currentFile.title, | ... | ... |
... | ... | @@ -25,28 +25,28 @@ export const doSaveNodeAllData = (data: SaveNodeDataParamsType) => { |
25 | 25 | } |
26 | 26 | |
27 | 27 | export const doSaveNodeAct = (params: SaveNodeActParamsType) => { |
28 | - const { configurationId, contentId, id, data } = params | |
28 | + const { configurationId, contentId, configurationNodeId, data } = params | |
29 | 29 | return defHttp.post({ |
30 | 30 | url: Api.SAVE_NODE_ACT, |
31 | - params: { configurationId, contentId, id }, | |
31 | + params: { configurationId, contentId, configurationNodeId }, | |
32 | 32 | data, |
33 | 33 | }) |
34 | 34 | } |
35 | 35 | |
36 | 36 | export const doSaveNodeDataSource = (params: SaveNodeDataSourceParamsType) => { |
37 | - const { configurationId, contentId, id, data } = params | |
37 | + const { configurationId, contentId, configurationNodeId, data } = params | |
38 | 38 | return defHttp.post({ |
39 | 39 | url: Api.SAVE_NODE_DATASOURCE, |
40 | - params: { configurationId, contentId, id }, | |
40 | + params: { configurationId, contentId, configurationNodeId }, | |
41 | 41 | data, |
42 | 42 | }) |
43 | 43 | } |
44 | 44 | |
45 | 45 | export const doSaveNodeEvent = (params: SaveNodeEventParamsType) => { |
46 | - const { configurationId, contentId, id, data } = params | |
46 | + const { configurationId, contentId, configurationNodeId, data } = params | |
47 | 47 | return defHttp.post({ |
48 | 48 | url: Api.SAVE_NODE_EVENT, |
49 | - params: { configurationId, contentId, id }, | |
49 | + params: { configurationId, contentId, configurationNodeId }, | |
50 | 50 | data, |
51 | 51 | }) |
52 | 52 | } | ... | ... |
... | ... | @@ -11,9 +11,10 @@ export enum DeleteNodeDataTypeEnum { |
11 | 11 | } |
12 | 12 | |
13 | 13 | export interface BasicNodeBindType { |
14 | - id: string | |
15 | 14 | contentId: string |
15 | + configurationNodeId: string | |
16 | 16 | configurationId: string |
17 | + id?: string | |
17 | 18 | } |
18 | 19 | |
19 | 20 | export interface SaveNodeDataParamsType extends BasicNodeBindType { |
... | ... | @@ -45,6 +46,7 @@ export interface NodeDataBasicType { |
45 | 46 | enabled: boolean |
46 | 47 | tenantId: string |
47 | 48 | configurationId: string |
49 | + configurationNodeId: string | |
48 | 50 | contentId: string |
49 | 51 | } |
50 | 52 | ... | ... |
1 | 1 | <script lang="ts" setup> |
2 | 2 | import { Button } from 'ant-design-vue' |
3 | 3 | import { basicProps } from '../props' |
4 | +import { useTranslation } from '@/hooks/useTranslation' | |
4 | 5 | defineProps(basicProps) |
5 | 6 | const emit = defineEmits(['ok', 'cancel']) |
7 | + | |
8 | +const { t } = useTranslation() | |
6 | 9 | function handleOk(e: Event) { |
7 | 10 | emit('ok', e) |
8 | 11 | } |
... | ... | @@ -16,17 +19,11 @@ function handleCancel(e: Event) { |
16 | 19 | <div> |
17 | 20 | <slot name="insertFooter" /> |
18 | 21 | <Button v-if="showCancelBtn" v-bind="cancelButtonProps" @click="handleCancel"> |
19 | - {{ cancelText }} | |
22 | + {{ cancelText || t('cancel') }} | |
20 | 23 | </Button> |
21 | 24 | <slot name="centerFooter" /> |
22 | - <Button | |
23 | - v-if="showOkBtn" | |
24 | - :type="okType" | |
25 | - :loading="confirmLoading" | |
26 | - v-bind="okButtonProps" | |
27 | - @click="handleOk" | |
28 | - > | |
29 | - {{ okText }} | |
25 | + <Button v-if="showOkBtn" :type="okType" :loading="confirmLoading" v-bind="okButtonProps" @click="handleOk"> | |
26 | + {{ okText || t('ok') }} | |
30 | 27 | </Button> |
31 | 28 | <slot name="appendFooter" /> |
32 | 29 | </div> | ... | ... |
... | ... | @@ -3,9 +3,7 @@ import type { ButtonProps } from 'ant-design-vue/es/button/buttonTypes' |
3 | 3 | import type { ButtonType } from 'ant-design-vue/lib/button' |
4 | 4 | import type { VueNode } from 'ant-design-vue/es/_util/type' |
5 | 5 | import type { ModalWrapperProps } from './typing' |
6 | -import { useTranslation } from '@/hooks/useTranslation' | |
7 | 6 | |
8 | -const { t } = useTranslation() | |
9 | 7 | export const modalProps = { |
10 | 8 | open: { type: Boolean }, |
11 | 9 | scrollTop: { type: Boolean, default: true }, |
... | ... | @@ -14,8 +12,8 @@ export const modalProps = { |
14 | 12 | // open drag |
15 | 13 | draggable: { type: Boolean, default: true }, |
16 | 14 | centered: { type: Boolean }, |
17 | - cancelText: { type: String, default: t('cancel') }, | |
18 | - okText: { type: String, default: t('ok') }, | |
15 | + cancelText: { type: String }, | |
16 | + okText: { type: String }, | |
19 | 17 | |
20 | 18 | closeFunc: Function as PropType<() => Promise<boolean>>, |
21 | 19 | } | ... | ... |
... | ... | @@ -37,7 +37,7 @@ export const getFormSchemas = (event: EventTypeEnum): FormSchema[] => { |
37 | 37 | componentProps: { |
38 | 38 | allowClear: false, |
39 | 39 | options: [ |
40 | - { label: EventTypeNameEnum[event], value: EventTypeEnum[event] }, | |
40 | + { label: t(EventTypeNameEnum[event]), value: EventTypeEnum[event] }, | |
41 | 41 | ], |
42 | 42 | }, |
43 | 43 | }, | ... | ... |
... | ... | @@ -177,8 +177,8 @@ defineExpose<ComponentExposeType>({ |
177 | 177 | :validate-status="getValidateStatus(record[TableColumnFieldEnum.DEVICE_PROFILE_ID])" |
178 | 178 | > |
179 | 179 | <Select |
180 | - v-model:value="record[TableColumnFieldEnum.DEVICE_PROFILE_ID]" :options="productList" :field-names="{ label: 'name', value: 'profileId' }" placeholder="请选择产品" | |
181 | - class="w-full" | |
180 | + v-model:value="record[TableColumnFieldEnum.DEVICE_PROFILE_ID]" :options="productList" | |
181 | + :field-names="{ label: 'name', value: 'profileId' }" placeholder="请选择产品" class="w-full" | |
182 | 182 | @change="(value, option) => handleSelectProduct(value, option, record as TableRecordItemType)" |
183 | 183 | /> |
184 | 184 | </FormItem> |
... | ... | @@ -189,8 +189,8 @@ defineExpose<ComponentExposeType>({ |
189 | 189 | :validate-status="getValidateStatus(record[TableColumnFieldEnum.DEVICE_ID])" |
190 | 190 | > |
191 | 191 | <Select |
192 | - v-model:value="record[TableColumnFieldEnum.DEVICE_ID]" :options="deviceList" :placeholder="t('chooseDevice')" | |
193 | - class="w-full" | |
192 | + v-model:value="record[TableColumnFieldEnum.DEVICE_ID]" :options="deviceList" | |
193 | + :placeholder="t('chooseDevice')" class="w-full" | |
194 | 194 | @change="(value, option) => handleSelectDevice(value, option, record as TableRecordItemType)" |
195 | 195 | /> |
196 | 196 | </FormItem> |
... | ... | @@ -198,8 +198,8 @@ defineExpose<ComponentExposeType>({ |
198 | 198 | <template v-if="column.key === TableColumnFieldEnum.WAY"> |
199 | 199 | <RadioGroup |
200 | 200 | v-model:value="record[TableColumnFieldEnum.WAY]" :options="[ |
201 | - { label: CommandWayNameEnum.ONE_WAY, value: CommandWayEnum.ONE_WAY }, | |
202 | - { label: CommandWayNameEnum.TWO_WAY, value: CommandWayEnum.TWO_WAY }, | |
201 | + { label: t(CommandWayNameEnum.ONE_WAY), value: CommandWayEnum.ONE_WAY }, | |
202 | + { label: t(CommandWayNameEnum.TWO_WAY), value: CommandWayEnum.TWO_WAY }, | |
203 | 203 | ]" |
204 | 204 | /> |
205 | 205 | </template> | ... | ... |
... | ... | @@ -2,6 +2,7 @@ import { isBoolean } from '@wry-smile/utils-is' |
2 | 2 | import type { BasicContentComponentProps } from '../..' |
3 | 3 | import type { PublicFormSettingType } from '../../..' |
4 | 4 | import { DataSourceTypeEnum, EventTypeEnum, EventTypeNameEnum } from '@/enums/datasource' |
5 | +import { useTranslation } from '@/hooks/useTranslation' | |
5 | 6 | |
6 | 7 | export interface DynamicEffectItemType { |
7 | 8 | label: string |
... | ... | @@ -10,29 +11,31 @@ export interface DynamicEffectItemType { |
10 | 11 | componentProps?: BasicContentComponentProps |
11 | 12 | } |
12 | 13 | |
14 | +const { t } = useTranslation() | |
15 | + | |
13 | 16 | export const getEventItem = (formSetting?: PublicFormSettingType): DynamicEffectItemType[] => { |
14 | 17 | const list = [ |
15 | 18 | { |
16 | - label: EventTypeNameEnum.DOWN, | |
19 | + label: t(EventTypeNameEnum.DOWN), | |
17 | 20 | key: EventTypeEnum.DOWN, |
18 | 21 | component: () => import('./MouseDownOrUpSetting/index.vue'), |
19 | 22 | componentProps: { event: EventTypeEnum.DOWN, type: DataSourceTypeEnum.EVENT }, |
20 | 23 | }, |
21 | 24 | { |
22 | - label: EventTypeNameEnum.UP, | |
25 | + label: t(EventTypeNameEnum.UP), | |
23 | 26 | key: EventTypeEnum.UP, |
24 | 27 | component: () => import('./MouseDownOrUpSetting/index.vue'), |
25 | 28 | componentProps: { event: EventTypeEnum.UP, type: DataSourceTypeEnum.EVENT }, |
26 | 29 | |
27 | 30 | }, |
28 | 31 | { |
29 | - label: EventTypeNameEnum.SINGLE, | |
32 | + label: t(EventTypeNameEnum.SINGLE), | |
30 | 33 | key: EventTypeEnum.SINGLE, |
31 | 34 | component: () => import('./SingleClickOrDoubleClickSetting/index.vue'), |
32 | 35 | componentProps: { event: EventTypeEnum.SINGLE, type: DataSourceTypeEnum.EVENT }, |
33 | 36 | }, |
34 | 37 | { |
35 | - label: EventTypeNameEnum.DOUBLE, | |
38 | + label: t(EventTypeNameEnum.DOUBLE), | |
36 | 39 | key: EventTypeEnum.DOUBLE, |
37 | 40 | component: () => import('./SingleClickOrDoubleClickSetting/index.vue'), |
38 | 41 | componentProps: { event: EventTypeEnum.DOUBLE, type: DataSourceTypeEnum.EVENT }, | ... | ... |
... | ... | @@ -52,11 +52,16 @@ export function useNodeData({ cell, immediate = true }: UseNodeDataParamsType) { |
52 | 52 | } |
53 | 53 | |
54 | 54 | const basicNodeBindData = (type: ActionType): BasicNodeBindType => { |
55 | - return { | |
56 | - id: type === ActionType.GET ? getSourceCellID () || getCellID () : getCellID(), | |
55 | + const res: BasicNodeBindType = { | |
56 | + configurationNodeId: type === ActionType.GET ? getSourceCellID() || getCellID() : getCellID(), | |
57 | 57 | contentId: window.DrawApp.currentPage.getId(), |
58 | 58 | configurationId, |
59 | 59 | } |
60 | + | |
61 | + if (unref(nodeData)?.id) | |
62 | + res.id = unref(nodeData)?.id | |
63 | + | |
64 | + return res | |
60 | 65 | } |
61 | 66 | |
62 | 67 | const getCellInfo = computed(() => { | ... | ... |
... | ... | @@ -9,7 +9,7 @@ export function useAuth() { |
9 | 9 | const result = { permissions: [] as string[], hasPreview: true, hasDesign: true } |
10 | 10 | |
11 | 11 | if (isFromEdge()) |
12 | - return result | |
12 | + return Object.assign(result, { hasDesignAuth: true, hasPreviewAuth: true }) | |
13 | 13 | |
14 | 14 | if (isShareMode()) return result |
15 | 15 | ... | ... |