|
@@ -1,17 +1,19 @@
|
|
<!-- eslint-disable @typescript-eslint/no-explicit-any -->
|
|
<!-- eslint-disable @typescript-eslint/no-explicit-any -->
|
|
-<!-- eslint-disable @typescript-eslint/ban-ts-comment -->
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { ref, onMounted, nextTick } from 'vue'
|
|
|
|
-import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
|
|
|
|
|
|
+import { ref, onMounted } from 'vue'
|
|
import type { Config, Handle } from '@form-create/designer'
|
|
import type { Config, Handle } from '@form-create/designer'
|
|
-// import { formCreate } from '@form-create/designer'
|
|
|
|
import { formConfig } from './form.config.ts'
|
|
import { formConfig } from './form.config.ts'
|
|
import FcDesigner from '@form-create/designer'
|
|
import FcDesigner from '@form-create/designer'
|
|
|
|
+// 组件
|
|
import { RcSelect } from './plugins/components/rc-select.config.ts'
|
|
import { RcSelect } from './plugins/components/rc-select.config.ts'
|
|
import { RcRadio } from './plugins/components/rc-radio.config.ts'
|
|
import { RcRadio } from './plugins/components/rc-radio.config.ts'
|
|
|
|
+import { RcCheckbox } from './plugins/components/rc-checkbox.config.ts'
|
|
|
|
+// 菜单
|
|
import { MenuOptions } from './plugins/menu/options.ts'
|
|
import { MenuOptions } from './plugins/menu/options.ts'
|
|
|
|
+import { MenuUpload } from './plugins/menu/upload.ts'
|
|
|
|
+
|
|
import type { FcDesignerInstance } from '@form-create/designer' // 注册组件
|
|
import type { FcDesignerInstance } from '@form-create/designer' // 注册组件
|
|
-import { RcCheckbox } from './plugins/components/rc-checkbox.ts'
|
|
|
|
|
|
+import { RcUpload } from './plugins/components/rc-upload.config.ts'
|
|
|
|
|
|
/**
|
|
/**
|
|
* @see https://view.form-create.com/methods
|
|
* @see https://view.form-create.com/methods
|
|
@@ -20,11 +22,12 @@ declare global {
|
|
interface Window {
|
|
interface Window {
|
|
__QIANKUN__EVENT__: {
|
|
__QIANKUN__EVENT__: {
|
|
on: (name: string, fn: (...arg: any[]) => void) => void
|
|
on: (name: string, fn: (...arg: any[]) => void) => void
|
|
- emit: (name: string, ...arg: any[]) => void
|
|
|
|
|
|
+ emit: (name: string, ...arg: any[]) => boolean
|
|
} // 事件中心
|
|
} // 事件中心
|
|
- __QIANKUN__REQUSET__: () => void // 请求API接口
|
|
|
|
|
|
+ __QIANKUN__REQUSET__: any // 请求API接口
|
|
__QIANKUN__GUID__: () => string // 获取唯一标识
|
|
__QIANKUN__GUID__: () => string // 获取唯一标识
|
|
__QIANKUN__OPEN__TAG__: () => void // 打开标签页
|
|
__QIANKUN__OPEN__TAG__: () => void // 打开标签页
|
|
|
|
+ __QIANKUN__QUITE__: () => void // 返回页面
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 表单实例
|
|
// 表单实例
|
|
@@ -32,33 +35,41 @@ const designer = ref<FcDesignerInstance | null>(null)
|
|
const api = ref(null)
|
|
const api = ref(null)
|
|
// 表单模板元素
|
|
// 表单模板元素
|
|
// 判断是独立运行的还是qiankun子应用
|
|
// 判断是独立运行的还是qiankun子应用
|
|
-const height = ref(qiankunWindow.__POWERED_BY_QIANKUN__ ? '90vh' : '100vh')
|
|
|
|
|
|
+const height = ref('100vh')
|
|
const config = ref<Config>(formConfig)
|
|
const config = ref<Config>(formConfig)
|
|
// 顶部更多操作按钮
|
|
// 顶部更多操作按钮
|
|
const handle = ref<Handle>([])
|
|
const handle = ref<Handle>([])
|
|
// console.log('子应用', window.__QIANKUN__EVENT__)
|
|
// console.log('子应用', window.__QIANKUN__EVENT__)
|
|
|
|
|
|
-const onSave = (config: { options: string; rule: string }) => {
|
|
|
|
|
|
+const onSave = async (config: { options: string; rule: string }) => {
|
|
const rule = config.rule
|
|
const rule = config.rule
|
|
- console.log(rule)
|
|
|
|
|
|
+ const options = config.options
|
|
|
|
+ // 接收从主应用过来的事件
|
|
|
|
+ window.__QIANKUN__EVENT__?.emit('save', {
|
|
|
|
+ rule: JSON.parse(rule),
|
|
|
|
+ options: JSON.parse(options),
|
|
|
|
+ original: config,
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
|
- designer.value?.openPreview()
|
|
|
|
- nextTick(() => {
|
|
|
|
- // @ts-ignore
|
|
|
|
- designer.value!.preview.state = false
|
|
|
|
- })
|
|
|
|
-})
|
|
|
|
|
|
+const rule = ref(
|
|
|
|
+ '[{"type":"rc-checkbox","title":"多选框","props":{"clearable":true,"options":[{"key":"cw_1iqkm6k0p1n4111p61q8g8katdn1","label":"1234","value":"1234","validate":false,"tags":[]}]},"_fc_id":"id_Fd0jmadjp53oaec","name":"ref_Fw5smadjp53oafc","field":"Fnqymadjp53oagc","display":true,"hidden":false,"_fc_drag_tag":"rc-checkbox","options":[{"key":"cw_1iqkm6k0p1n4111p61q8g8katdn1","label":"1234","value":"1234","validate":false,"tags":[]}]},{"type":"rc-radio","title":"单选框","props":{"clearable":true,"options":[{"key":"cw_1iqkm6nli1v4f8p01pn01rs715r62","label":"1234","value":"1234","validate":false,"tags":[]}]},"_fc_id":"id_Fo8imadjp7v1ahc","name":"ref_F6j0madjp7v1aic","field":"Fhyhmadjp7v1ajc","display":true,"hidden":false,"_fc_drag_tag":"rc-radio","options":[{"key":"cw_1iqkm6nli1v4f8p01pn01rs715r62","label":"1234","value":"1234","validate":false,"tags":[]}]},{"type":"rc-upload","title":"图片","props":{"clearable":true},"_fc_id":"id_Fyhlmadknfeuabc","name":"ref_Fz6bmadknfeuacc","field":"Fj86madknfeuadc","display":true,"hidden":false,"_fc_drag_tag":"rc-upload"}]',
|
|
|
|
+)
|
|
|
|
|
|
-onMounted(() => {
|
|
|
|
|
|
+onMounted(async () => {
|
|
// 注册拖拽规则
|
|
// 注册拖拽规则
|
|
|
|
+ designer.value?.addMenu(MenuOptions)
|
|
|
|
+ designer.value?.addMenu(MenuUpload)
|
|
designer.value?.addComponent(RcSelect)
|
|
designer.value?.addComponent(RcSelect)
|
|
designer.value?.addComponent(RcRadio)
|
|
designer.value?.addComponent(RcRadio)
|
|
designer.value?.addComponent(RcCheckbox)
|
|
designer.value?.addComponent(RcCheckbox)
|
|
|
|
+ designer.value?.addComponent(RcUpload)
|
|
|
|
|
|
// 注册菜单
|
|
// 注册菜单
|
|
- designer.value?.addMenu(MenuOptions)
|
|
|
|
|
|
+ console.log(designer.value)
|
|
|
|
+
|
|
|
|
+ // 设置拖拽规则
|
|
|
|
+ designer.value?.setRule(rule.value)
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|
|
|
|
|
|
@@ -68,7 +79,12 @@ onMounted(() => {
|
|
:height="height"
|
|
:height="height"
|
|
:handle="handle"
|
|
:handle="handle"
|
|
:config="config"
|
|
:config="config"
|
|
- @save="onSave"
|
|
|
|
v-model:api="api"
|
|
v-model:api="api"
|
|
|
|
+ @save="onSave"
|
|
|
|
+ @inputDate="
|
|
|
|
+ () => {
|
|
|
|
+ console.log(12313213)
|
|
|
|
+ }
|
|
|
|
+ "
|
|
/>
|
|
/>
|
|
</template>
|
|
</template>
|