| 1 | 1 | <script setup lang="ts"> | 
| 2 |  | -import { Button, Divider } from 'ant-design-vue' | 
| 3 |  | -import { onMounted, ref, unref } from 'vue' | 
| 4 |  | -import { DataSourceForm } from '@/core/Library/components/PublicForm/components/DataSourceForm' | 
| 5 |  | -import { useNodeData } from '@/core/Library/hook/useNodeData' | 
| 6 |  | -import { useMessage } from '@/hooks/web/useMessage' | 
| 7 | 2 | import type { ConfigComponentProps } from '@/core/Library/types' | 
| 8 |  | -import { useSavePageContent } from '@/core/Library/hook/useSavePageContent' | 
| 9 |  | -import { useContentDataStoreWithOut } from '@/store/modules/contentData' | 
|  | 3 | +import { PublicForm } from '@/core/Library/components/PublicForm' | 
| 10 | 4 |  | 
| 11 | 5 | const props = defineProps<ConfigComponentProps>() | 
| 12 |  | - | 
| 13 |  | -const { createMessage } = useMessage() | 
| 14 |  | - | 
| 15 |  | -const loading = ref(false) | 
| 16 |  | - | 
| 17 |  | -const dataSourceFormRef = ref<Nullable<InstanceType<typeof DataSourceForm>>>(null) | 
| 18 |  | - | 
| 19 |  | -const nodeDataActinType = useNodeData({ cell: props.cell!, immediate: false }) | 
| 20 |  | - | 
| 21 |  | -const { getNodeAllData, saveNodeAllData, getNodeData } = nodeDataActinType | 
| 22 |  | - | 
| 23 |  | -const { savePageContent } = useSavePageContent() | 
| 24 |  | -const contentDataStore = useContentDataStoreWithOut() | 
| 25 |  | - | 
| 26 |  | -const handleSubmit = async () => { | 
| 27 |  | -  try { | 
| 28 |  | -    loading.value = true | 
| 29 |  | -    await unref(dataSourceFormRef)?.validate() | 
| 30 |  | -    const formValues = unref(dataSourceFormRef)?.getFieldsValue() | 
| 31 |  | -    let dataSourceJson = formValues | 
| 32 |  | -    if (contentDataStore.getIsTemplate) | 
| 33 |  | -      dataSourceJson = { ...formValues, deviceProfileId: formValues?.deviceProfileTemplateId, deviceId: null } | 
| 34 |  | - | 
| 35 |  | -    await saveNodeAllData({ dataSourceJson: { ...formValues } }) | 
| 36 |  | -    createMessage.success('保存成功~') | 
| 37 |  | -    savePageContent() | 
| 38 |  | -  } | 
| 39 |  | -  finally { | 
| 40 |  | -    loading.value = false | 
| 41 |  | -  } | 
| 42 |  | -} | 
| 43 |  | - | 
| 44 |  | -onMounted(async () => { | 
| 45 |  | -  await getNodeAllData() | 
| 46 |  | -  const { dataSourceJson } = unref(getNodeData) || {} | 
| 47 |  | -  if (dataSourceJson) | 
| 48 |  | -    dataSourceFormRef.value?.setFieldsValue(dataSourceJson) | 
| 49 |  | -}) | 
| 50 | 6 | </script> | 
| 51 | 7 |  | 
| 52 | 8 | <template> | 
| 53 |  | -  <main class="w-full h-full flex flex-col px-2 py-4 box-border"> | 
| 54 |  | -    <main class="form-container"> | 
| 55 |  | -      <Divider orientation="left"> | 
| 56 |  | -        数据源 | 
| 57 |  | -      </Divider> | 
| 58 |  | -      <DataSourceForm ref="dataSourceFormRef" /> | 
| 59 |  | -    </main> | 
| 60 |  | -    <Button class="mt-3" type="primary" :loading="loading" @click="handleSubmit"> | 
| 61 |  | -      保存 | 
| 62 |  | -    </Button> | 
|  | 9 | +  <main class="w-full flex flex-col"> | 
|  | 10 | +    <PublicForm v-bind="props" /> | 
| 63 | 11 | </main> | 
| 64 | 12 | </template> | 
... | ... |  |