Skip to content

Commit 8e575f3

Browse files
committed
生成json和options
1 parent fcb9afd commit 8e575f3

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

src/views/bpm/form/formEditor.vue

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,21 @@
33
<!-- 表单设计器 -->
44
<fc-designer ref="designer" height="780px">
55
<template #handle>
6+
<XButton type="primary" title="生成JSON" @click="showJson" />
7+
<XButton type="primary" title="生成Options" @click="showOption" />
68
<XButton type="primary" :title="t('action.save')" @click="handleSave" />
79
</template>
810
</fc-designer>
11+
<Dialog :title="dialogTitle" v-model="dialogVisible1" maxHeight="600">
12+
<div ref="editor" v-if="dialogVisible1">
13+
<XTextButton style="float: right" :title="t('common.copy')" @click="copy(formValue)" />
14+
<el-scrollbar height="580">
15+
<pre>
16+
{{ formValue }}
17+
</pre>
18+
</el-scrollbar>
19+
</div>
20+
</Dialog>
921
<!-- 表单保存的弹窗 -->
1022
<XModal v-model="dialogVisible" title="保存表单">
1123
<el-form ref="formRef" :model="formValues" :rules="formRules" label-width="80px">
@@ -48,13 +60,18 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
4860
import { CommonStatusEnum } from '@/utils/constants'
4961
import * as FormApi from '@/api/bpm/form'
5062
import { encodeConf, encodeFields, setConfAndFields } from '@/utils/formCreate'
63+
import { useClipboard } from '@vueuse/core'
64+
5165
const { t } = useI18n() // 国际化
5266
const message = useMessage() // 消息
5367
const { query } = useRoute() // 路由
5468
5569
const designer = ref() // 表单设计器
56-
70+
const type = ref(-1)
71+
const formValue = ref('')
72+
const dialogTitle = ref('')
5773
const dialogVisible = ref(false) // 弹窗是否展示
74+
const dialogVisible1 = ref(false) // 弹窗是否展示
5875
const dialogLoading = ref(false) // 弹窗的加载中
5976
const formRef = ref<FormInstance>()
6077
const formRules = reactive({
@@ -98,7 +115,32 @@ const submitForm = async () => {
98115
dialogLoading.value = false
99116
}
100117
}
101-
118+
const showJson = () => {
119+
openModel('生成JSON')
120+
type.value = 0
121+
formValue.value = designer.value.getRule()
122+
}
123+
const showOption = () => {
124+
openModel('生成Options')
125+
type.value = 1
126+
formValue.value = designer.value.getOption()
127+
}
128+
const openModel = (title: string) => {
129+
dialogVisible1.value = true
130+
dialogTitle.value = title
131+
}
132+
/** 复制 **/
133+
const copy = async (text: string) => {
134+
const { copy, copied, isSupported } = useClipboard({ source: text })
135+
if (!isSupported) {
136+
message.error(t('common.copyError'))
137+
} else {
138+
await copy()
139+
if (unref(copied)) {
140+
message.success(t('common.copySuccess'))
141+
}
142+
}
143+
}
102144
// ========== 初始化 ==========
103145
onMounted(() => {
104146
// 场景一:新增表单

0 commit comments

Comments
 (0)