|
3 | 3 | <!-- 表单设计器 -->
|
4 | 4 | <fc-designer ref="designer" height="780px">
|
5 | 5 | <template #handle>
|
| 6 | + <XButton type="primary" title="生成JSON" @click="showJson" /> |
| 7 | + <XButton type="primary" title="生成Options" @click="showOption" /> |
6 | 8 | <XButton type="primary" :title="t('action.save')" @click="handleSave" />
|
7 | 9 | </template>
|
8 | 10 | </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> |
9 | 21 | <!-- 表单保存的弹窗 -->
|
10 | 22 | <XModal v-model="dialogVisible" title="保存表单">
|
11 | 23 | <el-form ref="formRef" :model="formValues" :rules="formRules" label-width="80px">
|
@@ -48,13 +60,18 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
48 | 60 | import { CommonStatusEnum } from '@/utils/constants'
|
49 | 61 | import * as FormApi from '@/api/bpm/form'
|
50 | 62 | import { encodeConf, encodeFields, setConfAndFields } from '@/utils/formCreate'
|
| 63 | +import { useClipboard } from '@vueuse/core' |
| 64 | +
|
51 | 65 | const { t } = useI18n() // 国际化
|
52 | 66 | const message = useMessage() // 消息
|
53 | 67 | const { query } = useRoute() // 路由
|
54 | 68 |
|
55 | 69 | const designer = ref() // 表单设计器
|
56 |
| -
|
| 70 | +const type = ref(-1) |
| 71 | +const formValue = ref('') |
| 72 | +const dialogTitle = ref('') |
57 | 73 | const dialogVisible = ref(false) // 弹窗是否展示
|
| 74 | +const dialogVisible1 = ref(false) // 弹窗是否展示 |
58 | 75 | const dialogLoading = ref(false) // 弹窗的加载中
|
59 | 76 | const formRef = ref<FormInstance>()
|
60 | 77 | const formRules = reactive({
|
@@ -98,7 +115,32 @@ const submitForm = async () => {
|
98 | 115 | dialogLoading.value = false
|
99 | 116 | }
|
100 | 117 | }
|
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 | +} |
102 | 144 | // ========== 初始化 ==========
|
103 | 145 | onMounted(() => {
|
104 | 146 | // 场景一:新增表单
|
|
0 commit comments